sdedic commented on code in PR #7559:
URL: https://github.com/apache/netbeans/pull/7559#discussion_r1672250549


##########
enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compute/ComputeInstanceItem.java:
##########
@@ -18,21 +18,75 @@
  */
 package org.netbeans.modules.cloud.oracle.compute;
 
+import com.oracle.bmc.core.ComputeClient;
+import com.oracle.bmc.core.VirtualNetworkClient;
+import com.oracle.bmc.core.model.Vnic;
+import com.oracle.bmc.core.model.VnicAttachment;
+import com.oracle.bmc.core.requests.GetVnicRequest;
+import com.oracle.bmc.core.requests.ListVnicAttachmentsRequest;
+import com.oracle.bmc.core.responses.GetVnicResponse;
+import com.oracle.bmc.core.responses.ListVnicAttachmentsResponse;
+import java.util.List;
+import org.netbeans.modules.cloud.oracle.OCIManager;
 import org.netbeans.modules.cloud.oracle.items.OCID;
 import org.netbeans.modules.cloud.oracle.items.OCIItem;
+import org.openide.util.RequestProcessor;
 
 /**
  *
  * @author Jan Horvath
  */
 public final class ComputeInstanceItem extends OCIItem {
-
+    private String publicIp = null;
+    private final RequestProcessor RP = new RequestProcessor();

Review Comment:
   Rather use `new RequestProcessor(ComputeInstanceItem.class)` so it is is 
annotated on thread dump (will set the name of the daemon thread).



##########
java/java.lsp.server/vscode/src/extension.ts:
##########
@@ -896,6 +910,11 @@ function activateWithJDK(specifiedJDK: string | null, 
context: ExtensionContext,
     }
 }
 
+function openSSHSession(username: string, host: string) {
+    const terminal = vscode.window.createTerminal(`SSH: ${username}@${host}`);

Review Comment:
   could be the Compute Instance node's name/display name be somehow 
incoporated ? The user would easily connect the SSH session to the cloud 
browser contents.



##########
java/java.lsp.server/nbcode/integration/src/org/netbeans/modules/nbcode/integration/LspAssetsDecorationProvider.java:
##########
@@ -85,6 +87,10 @@ public TreeItemData createDecorations(Node n, boolean 
expanded) {
                 d.addContextValues(CTXVALUE_PREFIX_REFERENCE_NAME + refName);
                 set = true;
             }
+            if (item instanceof ComputeInstanceItem && ((ComputeInstanceItem) 
item).getPublicIp() != null) {
+                d.addContextValues(CTXVALUE_CAP_PUBLIC_IP);

Review Comment:
   an idea: could be the public IP value itself added as the context value on 
the item (with some prefix to identify) ? Then the LSP client can process the 
context values, saving some round-trips.



##########
enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/compute/ComputeInstanceItem.java:
##########
@@ -18,21 +18,75 @@
  */
 package org.netbeans.modules.cloud.oracle.compute;
 
+import com.oracle.bmc.core.ComputeClient;
+import com.oracle.bmc.core.VirtualNetworkClient;
+import com.oracle.bmc.core.model.Vnic;
+import com.oracle.bmc.core.model.VnicAttachment;
+import com.oracle.bmc.core.requests.GetVnicRequest;
+import com.oracle.bmc.core.requests.ListVnicAttachmentsRequest;
+import com.oracle.bmc.core.responses.GetVnicResponse;
+import com.oracle.bmc.core.responses.ListVnicAttachmentsResponse;
+import java.util.List;
+import org.netbeans.modules.cloud.oracle.OCIManager;
 import org.netbeans.modules.cloud.oracle.items.OCID;
 import org.netbeans.modules.cloud.oracle.items.OCIItem;
+import org.openide.util.RequestProcessor;
 
 /**
  *
  * @author Jan Horvath
  */
 public final class ComputeInstanceItem extends OCIItem {
-
+    private String publicIp = null;
+    private final RequestProcessor RP = new RequestProcessor();
+    
     public ComputeInstanceItem(OCID id, String compartmentId, String name) {
         super(id, compartmentId, name);
     }
 
     public ComputeInstanceItem() {
         super();
     }
+
+    public String getPublicIp() {
+        if (publicIp == null) {
+            RP.post(() -> {
+                String oldPublicIp = publicIp;
+                loadDetails();
+                firePropertyChange("publicIp", oldPublicIp, publicIp); //NOI18N
+            });
+            return "---"; //NOI18N
+        }
+        return publicIp;
+    } 
+    
+    private void loadDetails() {
+        ComputeClient computeClient = ComputeClient.builder()
+                
.build(OCIManager.getDefault().getActiveProfile().getAuthenticationProvider());
+        
+        VirtualNetworkClient virtualNetworkClient = 
VirtualNetworkClient.builder()
+                
.build(OCIManager.getDefault().getActiveProfile().getAuthenticationProvider());
+
+        
+        ListVnicAttachmentsRequest listVnicAttachmentsRequest = 
ListVnicAttachmentsRequest.builder()
+                .compartmentId(getCompartmentId())
+                .instanceId(getKey().getValue())
+                .build();
+        ListVnicAttachmentsResponse listVnicAttachmentsResponse = 
computeClient.listVnicAttachments(listVnicAttachmentsRequest);
+        List<VnicAttachment> vnicAttachments = 
listVnicAttachmentsResponse.getItems();

Review Comment:
   No nextPage handling/loop is neccessary ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to