This is an automated email from the ASF dual-hosted git repository.

thurka pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 264f11ae41 "Copy OCID" action added
     new 3cc6d772eb Merge pull request #6786 from thurka/GCN-3756
264f11ae41 is described below

commit 264f11ae41e866513b2076dfefd5d9cf8b3e5166
Author: Tomas Hurka <tomas.hu...@gmail.com>
AuthorDate: Mon Dec 4 10:38:13 2023 +0100

    "Copy OCID" action added
---
 .../nbcode/integration/nbproject/project.xml       | 24 ++++---
 .../nbcode/integration/commands/OCIDCommand.java   | 81 ++++++++++++++++++++++
 java/java.lsp.server/vscode/package.json           | 27 ++++++--
 java/java.lsp.server/vscode/src/extension.ts       |  7 ++
 4 files changed, 126 insertions(+), 13 deletions(-)

diff --git a/java/java.lsp.server/nbcode/integration/nbproject/project.xml 
b/java/java.lsp.server/nbcode/integration/nbproject/project.xml
index e176ec66dd..debf5ec044 100644
--- a/java/java.lsp.server/nbcode/integration/nbproject/project.xml
+++ b/java/java.lsp.server/nbcode/integration/nbproject/project.xml
@@ -119,6 +119,14 @@
                         <specification-version>9.24.0.8</specification-version>
                     </run-dependency>
                 </dependency>
+                <dependency>
+                    
<code-name-base>org.netbeans.modules.project.dependency</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <implementation-version/>
+                    </run-dependency>
+                </dependency>
                 <dependency>
                     
<code-name-base>org.netbeans.modules.projectapi</code-name-base>
                     <build-prerequisite/>
@@ -191,35 +199,35 @@
                     </run-dependency>
                 </dependency>
                 <dependency>
-                    <code-name-base>org.openide.util</code-name-base>
+                    <code-name-base>org.openide.nodes</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
-                        <specification-version>9.18</specification-version>
+                        <specification-version>7.68</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
-                    <code-name-base>org.openide.util.lookup</code-name-base>
+                    <code-name-base>org.openide.util</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
-                        <specification-version>8.44</specification-version>
+                        <specification-version>9.18</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
-                    <code-name-base>org.openide.util.ui</code-name-base>
+                    <code-name-base>org.openide.util.lookup</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
-                        <specification-version>9.24</specification-version>
+                        <specification-version>8.44</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
-                    
<code-name-base>org.netbeans.modules.project.dependency</code-name-base>
+                    <code-name-base>org.openide.util.ui</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
-                        <implementation-version/>
+                        <specification-version>9.24</specification-version>
                     </run-dependency>
                 </dependency>
             </module-dependencies>
diff --git 
a/java/java.lsp.server/nbcode/integration/src/org/netbeans/modules/nbcode/integration/commands/OCIDCommand.java
 
b/java/java.lsp.server/nbcode/integration/src/org/netbeans/modules/nbcode/integration/commands/OCIDCommand.java
new file mode 100644
index 0000000000..7cf88de519
--- /dev/null
+++ 
b/java/java.lsp.server/nbcode/integration/src/org/netbeans/modules/nbcode/integration/commands/OCIDCommand.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.nbcode.integration.commands;
+
+import com.google.gson.JsonPrimitive;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.netbeans.modules.cloud.oracle.items.OCIItem;
+import org.netbeans.modules.java.lsp.server.explorer.TreeNodeRegistry;
+import org.netbeans.modules.java.lsp.server.explorer.TreeViewProvider;
+import org.netbeans.spi.lsp.CommandProvider;
+import org.openide.nodes.Node;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ * @author Tomas Hurka
+ */
+@ServiceProvider(service = CommandProvider.class)
+public class OCIDCommand implements CommandProvider {
+
+    private static final Logger LOG = 
Logger.getLogger(OCIDCommand.class.getName());
+
+    private static final String COMMAND_CLOUD_OCID_GET = 
"nbls.cloud.ocid.get"; // NOI18N
+
+    public OCIDCommand() {
+    }
+
+    @Override
+    public Set<String> getCommands() {
+        return Collections.singleton(COMMAND_CLOUD_OCID_GET);
+    }
+
+    @Override
+    public CompletableFuture<Object> runCommand(String command, List<Object> 
arguments) {
+        if (arguments.size() < 1) {
+            throw new IllegalArgumentException("Expected nodeid");      // 
NOI18N
+        }
+        TreeNodeRegistry r = 
Lookup.getDefault().lookup(TreeNodeRegistry.class);
+        if (r == null) {
+            return CompletableFuture.completedFuture(null);
+        }
+        int nodeId = ((JsonPrimitive) arguments.get(0)).getAsInt();
+        LOG.log(Level.FINE, "Running OCID command with context: {0}", nodeId); 
 // NOI18N
+
+        TreeViewProvider nodeProvider = r.providerOf(nodeId);
+        Node node = null;
+        if (nodeProvider != null) {
+            node = nodeProvider.findNode(nodeId);
+        }
+        if (node == null) {
+            return CompletableFuture.completedFuture(null);
+        }
+        OCIItem item = node.getLookup().lookup(OCIItem.class);
+        if (item != null) {
+            return CompletableFuture.completedFuture(item.getKey().getValue());
+        }
+        return CompletableFuture.completedFuture(null);
+    }
+}
diff --git a/java/java.lsp.server/vscode/package.json 
b/java/java.lsp.server/vscode/package.json
index b9f9a23fb2..3da5b70d12 100644
--- a/java/java.lsp.server/vscode/package.json
+++ b/java/java.lsp.server/vscode/package.json
@@ -449,6 +449,10 @@
                                "command": "nbls.node.properties.edit",
                                "title": "Properties"
                        },
+                       {
+                               "command": "nbls.cloud.ocid.copy",
+                               "title": "Copy OCID"
+                       },
                        {
                                "command": "nbls.workspace.compile",
                                "title": "Compile Workspace",
@@ -681,6 +685,10 @@
                                        "command": "nbls.node.properties.edit",
                                        "when": "false"
                                },
+                               {
+                                       "command": "nbls.cloud.ocid.copy",
+                                       "when": "false"
+                               },
                                {
                                        "command": 
"nbls:Database:netbeans.db.explorer.action.Connect",
                                        "when": "false"
@@ -845,19 +853,28 @@
                                },
                                {
                                        "command": 
"nbls:Tools:org.netbeans.modules.cloud.oracle.actions.DownloadWalletAction",
-                                       "when": "viewItem =~ 
/class:oracle.database.DatabaseItem/"
+                                       "when": "viewItem =~ 
/class:oracle.database.DatabaseItem/",
+                                       "group": "oci@200"
                                },
                                {
                                        "command": 
"nbls:Tools:org.netbeans.modules.cloud.oracle.actions.OpenServiceConsoleAction",
-                                       "when": "viewItem =~ 
/class:oracle.database.DatabaseItem/"
+                                       "when": "viewItem =~ 
/class:oracle.database.DatabaseItem/",
+                                       "group": "oci@300"
                                },
                                {
                                        "command": 
"nbls:Tools:org.netbeans.modules.cloud.oracle.actions.AddDbConnectionToVault",
-                                       "when": "viewItem =~ 
/class:org.netbeans.api.db.explorer.DatabaseConnection/"
+                                       "when": "viewItem =~ 
/class:org.netbeans.api.db.explorer.DatabaseConnection/",
+                                       "group": "oci@400"
                                },
                                {
                                        "command": 
"nbls:Tools:org.netbeans.modules.cloud.oracle.actions.CreateAutonomousDBAction",
-                                       "when": "viewItem =~ 
/class:oracle.compartment.CompartmentItem/"
+                                       "when": "viewItem =~ 
/class:oracle.compartment.CompartmentItem/",
+                                        "group": "oci@100"
+                               },
+                               {
+                                       "command": "nbls.cloud.ocid.copy",
+                                       "when": "viewItem =~ 
/class:oracle.items.OCIItem/",
+                                        "group": "oci@1000"
                                },
                                {
                                        "command": 
"nbls:Tools:org.netbeans.modules.cloud.oracle.actions.AddRepository",
@@ -965,7 +982,7 @@
                                "uriExpression": 
"nbres:/org/netbeans/modules/cloud/oracle/resources/vault.svg",
                                "codeicon": "lock"
                        },
-                        {
+                       {
                                "uriExpression": 
"nbres:/org/netbeans/modules/cloud/oracle/resources/key.svg",
                                "codeicon": "gist-secret"
                        },
diff --git a/java/java.lsp.server/vscode/src/extension.ts 
b/java/java.lsp.server/vscode/src/extension.ts
index 29a6ac1ed5..9b2f7a7b89 100644
--- a/java/java.lsp.server/vscode/src/extension.ts
+++ b/java/java.lsp.server/vscode/src/extension.ts
@@ -664,6 +664,13 @@ export function activate(context: ExtensionContext): 
VSNetBeansAPI {
     
context.subscriptions.push(commands.registerCommand('nbls.node.properties.edit',
         async (node) => await PropertiesView.createOrShow(context, node, 
(await client).findTreeViewService())));
 
+    context.subscriptions.push(commands.registerCommand(COMMAND_PREFIX + 
'.cloud.ocid.copy',
+        async (node) => {
+            const ocid : string = await commands.executeCommand(COMMAND_PREFIX 
+ '.cloud.ocid.get', node.id);
+            vscode.env.clipboard.writeText(ocid);
+        }
+    ));
+
     const archiveFileProvider = <vscode.TextDocumentContentProvider> {
         provideTextDocumentContent: async (uri: vscode.Uri, token: 
vscode.CancellationToken): Promise<string> => {
             return await 
commands.executeCommand('nbls.get.archive.file.content', uri.toString());


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

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

Reply via email to