You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2023/01/13 13:40:59 UTC

[GitHub] [netbeans] jhorvath opened a new pull request, #5291: Adding new action which registers ADB connection

jhorvath opened a new pull request, #5291:
URL: https://github.com/apache/netbeans/pull/5291

   Adding a new action which registers database connection for ADB from Oracle Cloud


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] jhorvath commented on a diff in pull request #5291: Adding new action which registers ADB connection

Posted by GitBox <gi...@apache.org>.
jhorvath commented on code in PR #5291:
URL: https://github.com/apache/netbeans/pull/5291#discussion_r1069659008


##########
enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/AddADBAction.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cloud.oracle.actions;
+
+import com.oracle.bmc.model.BmcException;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.netbeans.modules.cloud.oracle.OCIManager;
+import org.netbeans.modules.cloud.oracle.compartment.CompartmentItem;
+import org.netbeans.modules.cloud.oracle.compartment.CompartmentNode;
+import org.netbeans.modules.cloud.oracle.database.DatabaseItem;
+import org.netbeans.modules.cloud.oracle.database.DatabaseNode;
+import org.netbeans.modules.cloud.oracle.items.OCIItem;
+import org.netbeans.modules.cloud.oracle.items.TenancyItem;
+import org.openide.DialogDescriptor;
+import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
+import org.openide.NotifyDescriptor.QuickPick.Item;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionReferences;
+import org.openide.awt.ActionRegistration;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author Jan Horvath
+ */
+@ActionID(
+        category = "Tools",
+        id = "org.netbeans.modules.cloud.oracle.actions.AddADBAction"
+)
+@ActionRegistration( 
+        displayName = "#AddADB", 
+        asynchronous = true
+)
+
+@ActionReferences(value = {
+    @ActionReference(path = "Cloud/Oracle/Common/Actions", position = 260)
+})
+@NbBundle.Messages({
+    "AddADB=Add Oracle ADB",
+    "SelectTenancy=Select Tenancy",
+    "SelectCompartment=Select Compartment",
+    "SelectDatabase=Select Database"
+})
+public class AddADBAction implements ActionListener {
+    private static final Logger LOGGER = Logger.getLogger(AddADBAction.class.getName());
+    
+
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        List<TenancyItem> tenancies = OCIManager.getDefault()
+                .getConnectedProfiles()
+                .stream()
+                .map(p -> p.getTenancy())
+                .filter(Optional::isPresent)
+                .map(Optional::get)
+                .collect(Collectors.toList());
+        Optional<TenancyItem> selectedTenancy = chooseOneItem(tenancies, Bundle.SelectTenancy());
+        
+        Optional<CompartmentItem> selectedCompartment = Optional.empty();
+                
+        if (selectedTenancy.isPresent()) {
+            List<CompartmentItem> compartments = CompartmentNode.getCompartments().apply(selectedTenancy.get());
+            selectedCompartment = chooseOneItem(compartments, Bundle.SelectCompartment());
+        }
+        Optional<DatabaseItem> selectedDatabase = Optional.empty();
+        
+        if (selectedCompartment.isPresent()) {
+            while(!selectedDatabase.isPresent()) {
+                OCIItem item = chooseCopartmentOrDb(selectedCompartment.get());
+                if (item == null) {
+                    return;
+                }
+                if (item instanceof DatabaseItem) {
+                    selectedDatabase = Optional.of((DatabaseItem) item);
+                }
+                if (item instanceof CompartmentItem) {
+                    selectedCompartment = Optional.of((CompartmentItem) item);
+                }
+            }
+        }
+        if (selectedDatabase.isPresent()) {
+            DownloadWalletAction action = new DownloadWalletAction(selectedDatabase.get());
+            action.actionPerformed(null);
+        }
+    }
+    
+    private <T extends OCIItem> Optional<T> chooseOneItem(List<T> ociItems, String title) {
+        Optional<T> result = Optional.empty();
+        if (ociItems.size() > 0) {
+            List<Item> items = ociItems.stream()
+                    .map(tenancy -> new Item(tenancy.getName(), tenancy.getDescription()))
+                    .collect(Collectors.toList());
+            NotifyDescriptor.QuickPick qp = new NotifyDescriptor.QuickPick(title, title, items, false);
+            if (DialogDescriptor.OK_OPTION == DialogDisplayer.getDefault().notify(qp)) {
+                Optional<String> selected = qp.getItems().stream().filter(item -> item.isSelected()).map(item -> item.getLabel()).findFirst();
+                if (selected.isPresent()) {
+                    result = ociItems.stream().filter(t -> t.getName().equals(selected.get())).findFirst();
+                }
+                
+            }
+        } else if (ociItems.size() == 1) {
+            result = Optional.of(ociItems.get(0));
+        }
+        return result;
+    }
+    
+    
+    private OCIItem chooseCopartmentOrDb(CompartmentItem compartment) {
+        List<OCIItem> items = new ArrayList<> ();
+        try {
+            items.addAll(DatabaseNode.getDatabases().apply(compartment));
+        } catch (BmcException e) {
+            LOGGER.log(Level.SEVERE, "Unable to load compartment list", e); // NOI18N

Review Comment:
   This exception occurs in some cases when scanning the root compartment and doesn't affect the result



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #5291: Adding new action which registers ADB connection

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #5291:
URL: https://github.com/apache/netbeans/pull/5291#discussion_r1069602073


##########
enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/AddADBAction.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cloud.oracle.actions;
+
+import com.oracle.bmc.model.BmcException;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.netbeans.modules.cloud.oracle.OCIManager;
+import org.netbeans.modules.cloud.oracle.compartment.CompartmentItem;
+import org.netbeans.modules.cloud.oracle.compartment.CompartmentNode;
+import org.netbeans.modules.cloud.oracle.database.DatabaseItem;
+import org.netbeans.modules.cloud.oracle.database.DatabaseNode;
+import org.netbeans.modules.cloud.oracle.items.OCIItem;
+import org.netbeans.modules.cloud.oracle.items.TenancyItem;
+import org.openide.DialogDescriptor;
+import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
+import org.openide.NotifyDescriptor.QuickPick.Item;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionReferences;
+import org.openide.awt.ActionRegistration;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author Jan Horvath
+ */
+@ActionID(
+        category = "Tools",
+        id = "org.netbeans.modules.cloud.oracle.actions.AddADBAction"
+)
+@ActionRegistration( 
+        displayName = "#AddADB", 
+        asynchronous = true
+)
+
+@ActionReferences(value = {
+    @ActionReference(path = "Cloud/Oracle/Common/Actions", position = 260)
+})
+@NbBundle.Messages({
+    "AddADB=Add Oracle ADB",
+    "SelectTenancy=Select Tenancy",
+    "SelectCompartment=Select Compartment",
+    "SelectDatabase=Select Database"
+})
+public class AddADBAction implements ActionListener {
+    private static final Logger LOGGER = Logger.getLogger(AddADBAction.class.getName());
+    
+
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        List<TenancyItem> tenancies = OCIManager.getDefault()

Review Comment:
   ```
   List<TenancyItem> tenancies = new ArrayList<>();
   for (OCIProfile p : OCIManager.getDefault() .getConnectedProfiles()) {
      p.getTenancy().ifPresent(tenancies::add);
   }
   ``` 
   ?
     



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] mbien commented on pull request #5291: Adding new action which registers ADB connection

Posted by GitBox <gi...@apache.org>.
mbien commented on PR #5291:
URL: https://github.com/apache/netbeans/pull/5291#issuecomment-1381891472

   added LSP label and restarting tests to activate them.


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #5291: Adding new action which registers ADB connection

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #5291:
URL: https://github.com/apache/netbeans/pull/5291#discussion_r1069590680


##########
enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/AddADBAction.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cloud.oracle.actions;
+
+import com.oracle.bmc.model.BmcException;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.netbeans.modules.cloud.oracle.OCIManager;
+import org.netbeans.modules.cloud.oracle.compartment.CompartmentItem;
+import org.netbeans.modules.cloud.oracle.compartment.CompartmentNode;
+import org.netbeans.modules.cloud.oracle.database.DatabaseItem;
+import org.netbeans.modules.cloud.oracle.database.DatabaseNode;
+import org.netbeans.modules.cloud.oracle.items.OCIItem;
+import org.netbeans.modules.cloud.oracle.items.TenancyItem;
+import org.openide.DialogDescriptor;
+import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
+import org.openide.NotifyDescriptor.QuickPick.Item;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionReferences;
+import org.openide.awt.ActionRegistration;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author Jan Horvath
+ */
+@ActionID(
+        category = "Tools",
+        id = "org.netbeans.modules.cloud.oracle.actions.AddADBAction"
+)
+@ActionRegistration( 
+        displayName = "#AddADB", 
+        asynchronous = true
+)
+
+@ActionReferences(value = {
+    @ActionReference(path = "Cloud/Oracle/Common/Actions", position = 260)
+})
+@NbBundle.Messages({
+    "AddADB=Add Oracle ADB",

Review Comment:
   Is it sure that "ADB" is acronym known enough in OCI world - maybe Autonomous DB would be better (but long) ?



##########
enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/AddADBAction.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cloud.oracle.actions;
+
+import com.oracle.bmc.model.BmcException;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.netbeans.modules.cloud.oracle.OCIManager;
+import org.netbeans.modules.cloud.oracle.compartment.CompartmentItem;
+import org.netbeans.modules.cloud.oracle.compartment.CompartmentNode;
+import org.netbeans.modules.cloud.oracle.database.DatabaseItem;
+import org.netbeans.modules.cloud.oracle.database.DatabaseNode;
+import org.netbeans.modules.cloud.oracle.items.OCIItem;
+import org.netbeans.modules.cloud.oracle.items.TenancyItem;
+import org.openide.DialogDescriptor;
+import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
+import org.openide.NotifyDescriptor.QuickPick.Item;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionReferences;
+import org.openide.awt.ActionRegistration;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author Jan Horvath
+ */
+@ActionID(
+        category = "Tools",
+        id = "org.netbeans.modules.cloud.oracle.actions.AddADBAction"
+)
+@ActionRegistration( 
+        displayName = "#AddADB", 
+        asynchronous = true
+)
+
+@ActionReferences(value = {
+    @ActionReference(path = "Cloud/Oracle/Common/Actions", position = 260)
+})
+@NbBundle.Messages({
+    "AddADB=Add Oracle ADB",
+    "SelectTenancy=Select Tenancy",
+    "SelectCompartment=Select Compartment",
+    "SelectDatabase=Select Database"
+})
+public class AddADBAction implements ActionListener {
+    private static final Logger LOGGER = Logger.getLogger(AddADBAction.class.getName());
+    
+
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        List<TenancyItem> tenancies = OCIManager.getDefault()
+                .getConnectedProfiles()
+                .stream()
+                .map(p -> p.getTenancy())
+                .filter(Optional::isPresent)
+                .map(Optional::get)
+                .collect(Collectors.toList());
+        Optional<TenancyItem> selectedTenancy = chooseOneItem(tenancies, Bundle.SelectTenancy());
+        
+        Optional<CompartmentItem> selectedCompartment = Optional.empty();
+                
+        if (selectedTenancy.isPresent()) {
+            List<CompartmentItem> compartments = CompartmentNode.getCompartments().apply(selectedTenancy.get());
+            selectedCompartment = chooseOneItem(compartments, Bundle.SelectCompartment());
+        }
+        Optional<DatabaseItem> selectedDatabase = Optional.empty();
+        
+        if (selectedCompartment.isPresent()) {
+            while(!selectedDatabase.isPresent()) {
+                OCIItem item = chooseCopartmentOrDb(selectedCompartment.get());
+                if (item == null) {
+                    return;
+                }
+                if (item instanceof DatabaseItem) {
+                    selectedDatabase = Optional.of((DatabaseItem) item);
+                }
+                if (item instanceof CompartmentItem) {
+                    selectedCompartment = Optional.of((CompartmentItem) item);
+                }
+            }
+        }
+        if (selectedDatabase.isPresent()) {
+            DownloadWalletAction action = new DownloadWalletAction(selectedDatabase.get());
+            action.actionPerformed(null);
+        }
+    }
+    
+    private <T extends OCIItem> Optional<T> chooseOneItem(List<T> ociItems, String title) {
+        Optional<T> result = Optional.empty();
+        if (ociItems.size() > 0) {
+            List<Item> items = ociItems.stream()
+                    .map(tenancy -> new Item(tenancy.getName(), tenancy.getDescription()))
+                    .collect(Collectors.toList());
+            NotifyDescriptor.QuickPick qp = new NotifyDescriptor.QuickPick(title, title, items, false);
+            if (DialogDescriptor.OK_OPTION == DialogDisplayer.getDefault().notify(qp)) {
+                Optional<String> selected = qp.getItems().stream().filter(item -> item.isSelected()).map(item -> item.getLabel()).findFirst();
+                if (selected.isPresent()) {
+                    result = ociItems.stream().filter(t -> t.getName().equals(selected.get())).findFirst();
+                }
+                
+            }
+        } else if (ociItems.size() == 1) {

Review Comment:
   Seems that the `size() > 0` branch is executed instead of this one ?



##########
enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/AddADBAction.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cloud.oracle.actions;
+
+import com.oracle.bmc.model.BmcException;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.netbeans.modules.cloud.oracle.OCIManager;
+import org.netbeans.modules.cloud.oracle.compartment.CompartmentItem;
+import org.netbeans.modules.cloud.oracle.compartment.CompartmentNode;
+import org.netbeans.modules.cloud.oracle.database.DatabaseItem;
+import org.netbeans.modules.cloud.oracle.database.DatabaseNode;
+import org.netbeans.modules.cloud.oracle.items.OCIItem;
+import org.netbeans.modules.cloud.oracle.items.TenancyItem;
+import org.openide.DialogDescriptor;
+import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
+import org.openide.NotifyDescriptor.QuickPick.Item;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionReferences;
+import org.openide.awt.ActionRegistration;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author Jan Horvath
+ */
+@ActionID(
+        category = "Tools",
+        id = "org.netbeans.modules.cloud.oracle.actions.AddADBAction"
+)
+@ActionRegistration( 
+        displayName = "#AddADB", 
+        asynchronous = true
+)
+
+@ActionReferences(value = {
+    @ActionReference(path = "Cloud/Oracle/Common/Actions", position = 260)
+})
+@NbBundle.Messages({
+    "AddADB=Add Oracle ADB",
+    "SelectTenancy=Select Tenancy",
+    "SelectCompartment=Select Compartment",
+    "SelectDatabase=Select Database"
+})
+public class AddADBAction implements ActionListener {
+    private static final Logger LOGGER = Logger.getLogger(AddADBAction.class.getName());
+    
+
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        List<TenancyItem> tenancies = OCIManager.getDefault()

Review Comment:
   ```
   List<TenancyItem> tenancies = new ArrayList<>();
   for (OCIProfile p : OCIManager.getDefault() {
      p.getTenancy().ifPresent(tenancies::add);
   }
   ``` 
   ?
     



##########
enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/AddADBAction.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cloud.oracle.actions;
+
+import com.oracle.bmc.model.BmcException;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.netbeans.modules.cloud.oracle.OCIManager;
+import org.netbeans.modules.cloud.oracle.compartment.CompartmentItem;
+import org.netbeans.modules.cloud.oracle.compartment.CompartmentNode;
+import org.netbeans.modules.cloud.oracle.database.DatabaseItem;
+import org.netbeans.modules.cloud.oracle.database.DatabaseNode;
+import org.netbeans.modules.cloud.oracle.items.OCIItem;
+import org.netbeans.modules.cloud.oracle.items.TenancyItem;
+import org.openide.DialogDescriptor;
+import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
+import org.openide.NotifyDescriptor.QuickPick.Item;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionReferences;
+import org.openide.awt.ActionRegistration;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author Jan Horvath
+ */
+@ActionID(
+        category = "Tools",
+        id = "org.netbeans.modules.cloud.oracle.actions.AddADBAction"
+)
+@ActionRegistration( 
+        displayName = "#AddADB", 
+        asynchronous = true
+)
+
+@ActionReferences(value = {
+    @ActionReference(path = "Cloud/Oracle/Common/Actions", position = 260)
+})
+@NbBundle.Messages({
+    "AddADB=Add Oracle ADB",
+    "SelectTenancy=Select Tenancy",
+    "SelectCompartment=Select Compartment",
+    "SelectDatabase=Select Database"
+})
+public class AddADBAction implements ActionListener {
+    private static final Logger LOGGER = Logger.getLogger(AddADBAction.class.getName());
+    
+
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        List<TenancyItem> tenancies = OCIManager.getDefault()
+                .getConnectedProfiles()
+                .stream()
+                .map(p -> p.getTenancy())
+                .filter(Optional::isPresent)
+                .map(Optional::get)
+                .collect(Collectors.toList());
+        Optional<TenancyItem> selectedTenancy = chooseOneItem(tenancies, Bundle.SelectTenancy());
+        
+        Optional<CompartmentItem> selectedCompartment = Optional.empty();
+                
+        if (selectedTenancy.isPresent()) {
+            List<CompartmentItem> compartments = CompartmentNode.getCompartments().apply(selectedTenancy.get());
+            selectedCompartment = chooseOneItem(compartments, Bundle.SelectCompartment());
+        }
+        Optional<DatabaseItem> selectedDatabase = Optional.empty();
+        
+        if (selectedCompartment.isPresent()) {
+            while(!selectedDatabase.isPresent()) {
+                OCIItem item = chooseCopartmentOrDb(selectedCompartment.get());
+                if (item == null) {
+                    return;
+                }
+                if (item instanceof DatabaseItem) {
+                    selectedDatabase = Optional.of((DatabaseItem) item);
+                }
+                if (item instanceof CompartmentItem) {
+                    selectedCompartment = Optional.of((CompartmentItem) item);
+                }
+            }
+        }
+        if (selectedDatabase.isPresent()) {
+            DownloadWalletAction action = new DownloadWalletAction(selectedDatabase.get());
+            action.actionPerformed(null);
+        }
+    }
+    
+    private <T extends OCIItem> Optional<T> chooseOneItem(List<T> ociItems, String title) {
+        Optional<T> result = Optional.empty();
+        if (ociItems.size() > 0) {
+            List<Item> items = ociItems.stream()
+                    .map(tenancy -> new Item(tenancy.getName(), tenancy.getDescription()))
+                    .collect(Collectors.toList());
+            NotifyDescriptor.QuickPick qp = new NotifyDescriptor.QuickPick(title, title, items, false);
+            if (DialogDescriptor.OK_OPTION == DialogDisplayer.getDefault().notify(qp)) {
+                Optional<String> selected = qp.getItems().stream().filter(item -> item.isSelected()).map(item -> item.getLabel()).findFirst();
+                if (selected.isPresent()) {
+                    result = ociItems.stream().filter(t -> t.getName().equals(selected.get())).findFirst();
+                }
+                
+            }
+        } else if (ociItems.size() == 1) {
+            result = Optional.of(ociItems.get(0));
+        }
+        return result;
+    }
+    
+    
+    private OCIItem chooseCopartmentOrDb(CompartmentItem compartment) {
+        List<OCIItem> items = new ArrayList<> ();
+        try {
+            items.addAll(DatabaseNode.getDatabases().apply(compartment));
+        } catch (BmcException e) {
+            LOGGER.log(Level.SEVERE, "Unable to load compartment list", e); // NOI18N

Review Comment:
   Shouldn't be this reported somehow to the user ?



##########
enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/AddADBAction.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cloud.oracle.actions;
+
+import com.oracle.bmc.model.BmcException;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.netbeans.modules.cloud.oracle.OCIManager;
+import org.netbeans.modules.cloud.oracle.compartment.CompartmentItem;
+import org.netbeans.modules.cloud.oracle.compartment.CompartmentNode;
+import org.netbeans.modules.cloud.oracle.database.DatabaseItem;
+import org.netbeans.modules.cloud.oracle.database.DatabaseNode;
+import org.netbeans.modules.cloud.oracle.items.OCIItem;
+import org.netbeans.modules.cloud.oracle.items.TenancyItem;
+import org.openide.DialogDescriptor;
+import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
+import org.openide.NotifyDescriptor.QuickPick.Item;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionReferences;
+import org.openide.awt.ActionRegistration;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author Jan Horvath
+ */
+@ActionID(
+        category = "Tools",
+        id = "org.netbeans.modules.cloud.oracle.actions.AddADBAction"
+)
+@ActionRegistration( 
+        displayName = "#AddADB", 
+        asynchronous = true
+)
+
+@ActionReferences(value = {
+    @ActionReference(path = "Cloud/Oracle/Common/Actions", position = 260)
+})
+@NbBundle.Messages({
+    "AddADB=Add Oracle ADB",
+    "SelectTenancy=Select Tenancy",
+    "SelectCompartment=Select Compartment",
+    "SelectDatabase=Select Database"
+})
+public class AddADBAction implements ActionListener {
+    private static final Logger LOGGER = Logger.getLogger(AddADBAction.class.getName());
+    
+
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        List<TenancyItem> tenancies = OCIManager.getDefault()
+                .getConnectedProfiles()
+                .stream()
+                .map(p -> p.getTenancy())
+                .filter(Optional::isPresent)
+                .map(Optional::get)
+                .collect(Collectors.toList());
+        Optional<TenancyItem> selectedTenancy = chooseOneItem(tenancies, Bundle.SelectTenancy());
+        
+        Optional<CompartmentItem> selectedCompartment = Optional.empty();
+                
+        if (selectedTenancy.isPresent()) {

Review Comment:
   If the absence of the selection should cause action temination, consider more expressive `if (!selectedTenancy.isPresent()) { return; }`; same for other choices.
   



##########
enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/actions/AddADBAction.java:
##########
@@ -0,0 +1,144 @@
+/*
+ * 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.cloud.oracle.actions;
+
+import com.oracle.bmc.model.BmcException;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import org.netbeans.modules.cloud.oracle.OCIManager;
+import org.netbeans.modules.cloud.oracle.compartment.CompartmentItem;
+import org.netbeans.modules.cloud.oracle.compartment.CompartmentNode;
+import org.netbeans.modules.cloud.oracle.database.DatabaseItem;
+import org.netbeans.modules.cloud.oracle.database.DatabaseNode;
+import org.netbeans.modules.cloud.oracle.items.OCIItem;
+import org.netbeans.modules.cloud.oracle.items.TenancyItem;
+import org.openide.DialogDescriptor;
+import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
+import org.openide.NotifyDescriptor.QuickPick.Item;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionReferences;
+import org.openide.awt.ActionRegistration;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author Jan Horvath
+ */
+@ActionID(
+        category = "Tools",
+        id = "org.netbeans.modules.cloud.oracle.actions.AddADBAction"
+)
+@ActionRegistration( 
+        displayName = "#AddADB", 
+        asynchronous = true
+)
+
+@ActionReferences(value = {
+    @ActionReference(path = "Cloud/Oracle/Common/Actions", position = 260)
+})
+@NbBundle.Messages({
+    "AddADB=Add Oracle ADB",
+    "SelectTenancy=Select Tenancy",
+    "SelectCompartment=Select Compartment",
+    "SelectDatabase=Select Database"
+})
+public class AddADBAction implements ActionListener {
+    private static final Logger LOGGER = Logger.getLogger(AddADBAction.class.getName());
+    
+
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        List<TenancyItem> tenancies = OCIManager.getDefault()
+                .getConnectedProfiles()
+                .stream()
+                .map(p -> p.getTenancy())
+                .filter(Optional::isPresent)
+                .map(Optional::get)
+                .collect(Collectors.toList());
+        Optional<TenancyItem> selectedTenancy = chooseOneItem(tenancies, Bundle.SelectTenancy());
+        
+        Optional<CompartmentItem> selectedCompartment = Optional.empty();
+                
+        if (selectedTenancy.isPresent()) {
+            List<CompartmentItem> compartments = CompartmentNode.getCompartments().apply(selectedTenancy.get());
+            selectedCompartment = chooseOneItem(compartments, Bundle.SelectCompartment());
+        }
+        Optional<DatabaseItem> selectedDatabase = Optional.empty();

Review Comment:
   why Optional<DatabaseItem> and not simply DatabaseItem that can be checked for `null` ?



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] jhorvath merged pull request #5291: Adding new action which registers ADB connection

Posted by GitBox <gi...@apache.org>.
jhorvath merged PR #5291:
URL: https://github.com/apache/netbeans/pull/5291


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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