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/03 10:15:25 UTC

[GitHub] [netbeans] jhorvath commented on a diff in pull request #5118: Support for OCI profiles.

jhorvath commented on code in PR #5118:
URL: https://github.com/apache/netbeans/pull/5118#discussion_r1053262312


##########
enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/ConnectProfilePanel.java:
##########
@@ -0,0 +1,275 @@
+/*
+ * 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;
+
+import java.awt.CardLayout;
+import java.awt.Component;
+import java.awt.Desktop;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.DefaultListModel;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
+import org.openide.util.ImageUtilities;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author sdedic
+ */
+public class ConnectProfilePanel extends javax.swing.JPanel{
+    private List<OCIProfile> allProfiles;
+    
+    private DefaultListModel<OCIProfile> model = new DefaultListModel<>();
+    /**
+     * Creates new form AddProfilePanel
+     */
+    public ConnectProfilePanel() {
+        initComponents();
+        ((CardLayout)cards.getLayout()).show(cards, "msg");
+        lblMessageIcon.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/cloud/oracle/resources/info.png", false));
+        lstProfiles.setCellRenderer(new R());
+
+        textMessage.setEditable(false);
+        textMessage.addHyperlinkListener(new HyperlinkListener() {
+             @Override
+             public void hyperlinkUpdate(HyperlinkEvent hle) {
+                 if (HyperlinkEvent.EventType.ACTIVATED.equals(hle.getEventType())) {
+                     Desktop desktop = Desktop.getDesktop();
+                     try {
+                         desktop.browse(hle.getURL().toURI());
+                     } catch (Exception ex) {
+                         ex.printStackTrace();
+                     }
+                 }
+             }
+         });
+    }
+    
+    public void setProfiles(List<OCIProfile> profiles) {
+        DefaultListModel mdl = new DefaultListModel();
+        for (OCIProfile p : profiles) {
+            mdl.addElement(p);
+        }
+        lstProfiles.setModel(mdl);
+        model = mdl;
+        
+        // switch the card:
+        ((CardLayout)cards.getLayout()).show(cards, "profiles");
+    }
+    
+    public void showErrorMessage(String msg) {
+        lblMessageIcon.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/cloud/oracle/resources/error.png", false));
+        textMessage.setContentType("text/html");
+        textMessage.setText(msg);
+        ((CardLayout)cards.getLayout()).show(cards, "msg");
+    }
+    
+    public void setSelectedProfiles(List<OCIProfile> profiles) {
+        lstProfiles.clearSelection();
+        for (OCIProfile p : profiles) {
+            int index = model.indexOf(p);
+            if (index >= 0) {
+                lstProfiles.getSelectionModel().addSelectionInterval(index, index);
+            }
+        }
+    }
+    
+    public boolean isContentValid() {
+        return !lstProfiles.getSelectedValuesList().isEmpty();
+    }
+    
+    public List<OCIProfile> getSelectedProfiles() {
+        return new ArrayList<>(lstProfiles.getSelectedValuesList());
+    }
+
+    @NbBundle.Messages({
+        "# {0} profile name",
+        "# {1} region",
+        "LBL_DefaultConfigProfile={0} - {1}",
+        "# {0} profile name",
+        "# {1} region",
+        "# {2} custom config filename",
+        "LBL_CustomConfigProfile={2}: {0} - {1}"
+    })
+    static class R extends DefaultListCellRenderer {
+
+        @Override
+        public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+            OCIProfile p = (OCIProfile)value;
+            Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+            if (!(c instanceof JLabel)) {
+                return c;
+            }
+            JLabel l = (JLabel)c;
+            l.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/cloud/oracle/resources/tenancy.svg", false));
+            if (p.isDefaultConfig()) {
+                l.setText(Bundle.LBL_DefaultConfigProfile(p.getId(), p.getConfigProvider().getRegion().getRegionId()));

Review Comment:
   I would prefer tenancy name instead of default region here.



-- 
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