[hg] releases: Introduced a HostPropertiesPanelProvider to allow...

  • From: Andrew Krasny < >
  • To: ,
  • Subject: [hg] releases: Introduced a HostPropertiesPanelProvider to allow...
  • Date: Wed, 09 Jan 2013 17:08:33 -0800

changeset 543afe48199e in releases ((none))
details: http://hg.netbeans.org/releases/rev/543afe48199e
description:
        Introduced a HostPropertiesPanelProvider to allow adding host 
configuration UI
        to the 'New Host' wizard and 'Host Properties' dialog

diffstat:

 
cnd.remote/src/org/netbeans/modules/cnd/remote/ui/wizard/CreateHostVisualPanel2.java
                         |   14 +
 
dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/util/ConnectionManager.java
              |    6 +-
 
dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/spi/HostPropertiesPanelProvider.java
         |   58 +++
 
dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/HostConfigurationPanel.java
          |  148 ++++++++++
 
dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/HostPropertiesPanelProviderImpl.java
 |   65 ++++
 5 files changed, 287 insertions(+), 4 deletions(-)

diffs (342 lines):

diff --git 
a/cnd.remote/src/org/netbeans/modules/cnd/remote/ui/wizard/CreateHostVisualPanel2.java
 
b/cnd.remote/src/org/netbeans/modules/cnd/remote/ui/wizard/CreateHostVisualPanel2.java
--- 
a/cnd.remote/src/org/netbeans/modules/cnd/remote/ui/wizard/CreateHostVisualPanel2.java
+++ 
b/cnd.remote/src/org/netbeans/modules/cnd/remote/ui/wizard/CreateHostVisualPanel2.java
@@ -109,6 +109,13 @@
     private void fireChange() {
         hostFound = null;
         wizardListener.stateChanged(null);
+        // This is a hack - now there is no way to pass *changed* execution
+        // environment to a configuration panel..
+        // (The problem is that exec env could change after the panel 
creation)
+        configurationPanel.putClientProperty("ExecutionEnvironment", // 
NOI18N
+                textLoginName.getText().concat("@"). // NOI18N
+                concat(data.getHostName()).concat(":") // NOI18N
+                .concat(Integer.toString(data.getPort())));
     }
 
     @Override
@@ -117,6 +124,13 @@
     }
 
     void init() {
+        // This is a hack - now there is no way to pass *changed* execution
+        // environment to a configuration panel..
+        // (The problem is that exec env is null when panel is created)
+        configurationPanel.putClientProperty("ExecutionEnvironment", // 
NOI18N
+                data.getUserName().concat("@"). // NOI18N
+                concat(data.getHostName()).concat(":") // NOI18N
+                .concat(Integer.toString(data.getPort())));
     }
 
     private String getLoginName() {
diff --git 
a/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/util/ConnectionManager.java
 
b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/util/ConnectionManager.java
--- 
a/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/util/ConnectionManager.java
+++ 
b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/api/util/ConnectionManager.java
@@ -66,9 +66,9 @@
 import org.netbeans.modules.nativeexecution.jsch.JSchChannelsSupport;
 import org.netbeans.modules.nativeexecution.jsch.JSchConnectionTask;
 import org.netbeans.modules.nativeexecution.support.Authentication;
+import org.netbeans.modules.nativeexecution.support.HostConfigurationPanel;
 import org.netbeans.modules.nativeexecution.support.Logger;
 import 
org.netbeans.modules.nativeexecution.support.NativeTaskExecutorService;
-import 
org.netbeans.modules.nativeexecution.support.ui.AuthenticationSettingsPanel;
 import org.openide.DialogDisplayer;
 import org.openide.NotifyDescriptor;
 import org.openide.awt.StatusDisplayer;
@@ -485,9 +485,7 @@
     }
 
     public ValidateablePanel getConfigurationPanel(ExecutionEnvironment env) 
{
-        Authentication auth = Authentication.getFor(env);
-        AuthenticationSettingsPanel panel = new 
AuthenticationSettingsPanel(auth, env != null);
-        return panel;
+        return new HostConfigurationPanel(env);
     }
 
     /**
diff --git 
a/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/spi/HostPropertiesPanelProvider.java
 
b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/spi/HostPropertiesPanelProvider.java
new file mode 100644
--- /dev/null
+++ 
b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/spi/HostPropertiesPanelProvider.java
@@ -0,0 +1,58 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2012 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.nativeexecution.spi;
+
+import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
+import org.netbeans.modules.nativeexecution.api.util.ConnectionManager;
+import org.netbeans.modules.nativeexecution.api.util.ValidateablePanel;
+
+/**
+ * An SPI for providing a configuration panel for a given 
ExecutionEnvironment.
+ * <p> See:
+ * {@link ConnectionManager#getConfigurationPanel(ExecutionEnvironment)} </p>
+ *
+ * @author akrasny
+ */
+public interface HostPropertiesPanelProvider {
+
+    ValidateablePanel getHostPropertyPanel(ExecutionEnvironment env);
+}
diff --git 
a/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/HostConfigurationPanel.java
 
b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/HostConfigurationPanel.java
new file mode 100644
--- /dev/null
+++ 
b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/HostConfigurationPanel.java
@@ -0,0 +1,148 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2012 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.nativeexecution.support;
+
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import javax.swing.JPanel;
+import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
+import 
org.netbeans.modules.nativeexecution.api.util.ValidatablePanelListener;
+import org.netbeans.modules.nativeexecution.api.util.ValidateablePanel;
+import org.netbeans.modules.nativeexecution.spi.HostPropertiesPanelProvider;
+import org.openide.util.Lookup;
+
+/**
+ * A Composite panel that contains all panels provided by
+ * {@link HostPropertiesPanelProvider}s.
+ *
+ * <p>The panel has
+ * <code>GridBagLayout</code> layout and all panels are placed one under 
another
+ * (in the order, of providers registration)</p>
+ *
+ * @author akrasny
+ */
+public final class HostConfigurationPanel extends ValidateablePanel {
+
+    private final ValidatablePanelListener listener;
+    private final List<ValidateablePanel> panels;
+
+    public HostConfigurationPanel(final ExecutionEnvironment env) {
+        panels = new ArrayList<ValidateablePanel>();
+
+        GridBagConstraints gridBagConstraints;
+        GridBagLayout layout = new GridBagLayout();
+        setLayout(layout);
+
+        listener = new ValidatablePanelListener() {
+            @Override
+            public void stateChanged(ValidateablePanel src) {
+                fireChange();
+            }
+        };
+
+        addPropertyChangeListener("ExecutionEnvironment", new 
PropertyChangeListener() { // NOI18N
+            @Override
+            public void propertyChange(PropertyChangeEvent evt) {
+                for (ValidateablePanel panel : panels) {
+                    panel.putClientProperty(evt.getPropertyName(), 
evt.getNewValue());
+                }
+            }
+        });
+
+        Collection<? extends HostPropertiesPanelProvider> allProviders =
+                
Lookup.getDefault().lookupAll(HostPropertiesPanelProvider.class);
+
+        int y = 0;
+
+        for (HostPropertiesPanelProvider provider : allProviders) {
+            ValidateablePanel panel = provider.getHostPropertyPanel(env);
+            panels.add(panel);
+            panel.addValidationListener(listener);
+            gridBagConstraints = new java.awt.GridBagConstraints();
+            gridBagConstraints.gridx = 0;
+            gridBagConstraints.gridy = y++;
+            gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
+            gridBagConstraints.weightx = 1.0;
+            add(panel, gridBagConstraints);
+        }
+
+        gridBagConstraints = new java.awt.GridBagConstraints();
+        gridBagConstraints.gridx = 0;
+        gridBagConstraints.gridy = y++;
+        gridBagConstraints.fill = GridBagConstraints.BOTH;
+        gridBagConstraints.weighty = 1.0;
+        add(new JPanel(), gridBagConstraints);
+    }
+
+    @Override
+    public boolean hasProblem() {
+        for (ValidateablePanel panel : panels) {
+            if (panel.hasProblem()) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public String getProblem() {
+        for (ValidateablePanel panel : panels) {
+            String problem = panel.getProblem();
+            if (problem != null) {
+                return problem;
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public void applyChanges(Object customData) {
+        for (ValidateablePanel panel : panels) {
+            panel.applyChanges(customData);
+        }
+    }
+}
diff --git 
a/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/HostPropertiesPanelProviderImpl.java
 
b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/HostPropertiesPanelProviderImpl.java
new file mode 100644
--- /dev/null
+++ 
b/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/support/HostPropertiesPanelProviderImpl.java
@@ -0,0 +1,65 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2012 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2012 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.nativeexecution.support;
+
+import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment;
+import org.netbeans.modules.nativeexecution.api.util.ValidateablePanel;
+import org.netbeans.modules.nativeexecution.spi.HostPropertiesPanelProvider;
+import 
org.netbeans.modules.nativeexecution.support.ui.AuthenticationSettingsPanel;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ * Default implementation of HostsPropertiesPanelProvider that returns a 
panel
+ * with authentication settings.
+ *
+ * @author akrasny
+ */
+@ServiceProvider(service = 
org.netbeans.modules.nativeexecution.spi.HostPropertiesPanelProvider.class, 
position = 100)
+public class HostPropertiesPanelProviderImpl implements 
HostPropertiesPanelProvider {
+
+    @Override
+    public ValidateablePanel getHostPropertyPanel(ExecutionEnvironment env) {
+        Authentication auth = Authentication.getFor(env);
+        AuthenticationSettingsPanel panel = new 
AuthenticationSettingsPanel(auth, env != null);
+        return panel;
+    }
+}

[hg] releases: Introduced a HostPropertiesPanelProvider to allow...

Andrew Krasny 01/10/2013

Project Features

About this Project

CND was started in November 2009, is owned by Leonid Lenyashin, and has 130 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close