diff -r 3ee3cc758b01 j2ee.sun.appsrv81/src/org/netbeans/modules/j2ee/sun/ide/Bundle.properties --- a/j2ee.sun.appsrv81/src/org/netbeans/modules/j2ee/sun/ide/Bundle.properties Fri Apr 10 13:32:27 2009 +0200 +++ b/j2ee.sun.appsrv81/src/org/netbeans/modules/j2ee/sun/ide/Bundle.properties Fri Apr 10 14:44:10 2009 +0200 @@ -44,3 +44,4 @@ LBL_JavaEEPlusSIP=Sailfin v1 CTL_InfoAction=Java EE Usage... +CTL_InfoWizard=Servers for Java EE diff -r 3ee3cc758b01 j2ee.sun.appsrv81/src/org/netbeans/modules/j2ee/sun/ide/j2ee/layer.xml --- a/j2ee.sun.appsrv81/src/org/netbeans/modules/j2ee/sun/ide/j2ee/layer.xml Fri Apr 10 13:32:27 2009 +0200 +++ b/j2ee.sun.appsrv81/src/org/netbeans/modules/j2ee/sun/ide/j2ee/layer.xml Fri Apr 10 14:44:10 2009 +0200 @@ -312,6 +312,7 @@ + diff -r 3ee3cc758b01 ruby.help/src/org/netbeans/modules/ruby/help/Bundle.properties --- a/ruby.help/src/org/netbeans/modules/ruby/help/Bundle.properties Fri Apr 10 13:32:27 2009 +0200 +++ b/ruby.help/src/org/netbeans/modules/ruby/help/Bundle.properties Fri Apr 10 14:44:10 2009 +0200 @@ -44,3 +44,5 @@ Contains the actual JavaHelp content files for the Ruby Support CTL_InfoAction=Ruby Usage... +CTL_InfoWizard=Servers for Ruby on Rails + diff -r 3ee3cc758b01 ruby.help/src/org/netbeans/modules/ruby/help/InfoAction.java --- a/ruby.help/src/org/netbeans/modules/ruby/help/InfoAction.java Fri Apr 10 13:32:27 2009 +0200 +++ b/ruby.help/src/org/netbeans/modules/ruby/help/InfoAction.java Fri Apr 10 14:44:10 2009 +0200 @@ -48,6 +48,9 @@ public final class InfoAction implements ActionListener { public void actionPerformed(ActionEvent e) { + if ("noui".equals(e.getActionCommand())) { // NOI18N + return; + } Help h = (Help)Lookup.getDefault().lookup(Help.class); if (h == null) { Toolkit.getDefaultToolkit().beep(); diff -r 3ee3cc758b01 ruby.help/src/org/netbeans/modules/ruby/help/layer.xml --- a/ruby.help/src/org/netbeans/modules/ruby/help/layer.xml Fri Apr 10 13:32:27 2009 +0200 +++ b/ruby.help/src/org/netbeans/modules/ruby/help/layer.xml Fri Apr 10 14:44:10 2009 +0200 @@ -22,6 +22,7 @@ + diff -r 3ee3cc758b01 server/arch.xml --- a/server/arch.xml Fri Apr 10 13:32:27 2009 +0200 +++ b/server/arch.xml Fri Apr 10 14:44:10 2009 +0200 @@ -72,9 +72,35 @@

- By registering actions to Servers/Actions you - can extend the list of popup actions on Servers node in - Services tab. + By registering actions to Servers/Actions you + can extend the list of popup actions on Servers node in + Services tab. + + +

+ By adding additional attributes to files in Servers/Actions + folder you can influence behaviour of the Servers node. +

+

+ By adding property-something attribute you identify + an action that will be called as soon as the node is expanded and + System.getProperty("something") is non-null. +

+

+ By adding wizardMessage attribute you tell the + Add Server... action to display this message as an + option, if no servers are yet registered. If user agrees, your + action will be called then to enable some server providers. +

+

+ In both of these cases, the action receives command noui, + to know that it shall only enable given functionality, but there + is no need to show user anything. +

+

+ These attribute based APIs shall be seen as temporary and subject + to replacement. Please notify us as soon as you start to use them. +

diff -r 3ee3cc758b01 server/src/org/netbeans/modules/server/ui/wizard/AddServerInstanceWizard.java --- a/server/src/org/netbeans/modules/server/ui/wizard/AddServerInstanceWizard.java Fri Apr 10 13:32:27 2009 +0200 +++ b/server/src/org/netbeans/modules/server/ui/wizard/AddServerInstanceWizard.java Fri Apr 10 14:44:10 2009 +0200 @@ -42,15 +42,21 @@ package org.netbeans.modules.server.ui.wizard; import java.awt.Dialog; +import java.awt.event.ActionEvent; import java.io.IOException; import java.text.MessageFormat; +import java.util.ArrayList; import java.util.Collection; +import java.util.Enumeration; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; +import javax.swing.Action; import javax.swing.JComponent; +import javax.swing.JRadioButton; import javax.swing.event.ChangeListener; import org.netbeans.api.server.ServerInstance; import org.netbeans.modules.server.ServerRegistry; @@ -58,6 +64,9 @@ import org.openide.DialogDescriptor; import org.openide.DialogDisplayer; import org.openide.WizardDescriptor; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.util.Lookup; import org.openide.util.NbBundle; import org.openide.util.lookup.Lookups; @@ -114,21 +123,45 @@ ServerRegistry.SERVERS_PATH).lookupAll(ServerWizardProvider.class); // this will almost never happen if this module will be autoload if (providers.isEmpty()) { - // display the warning dialog - no server plugins - String close = NbBundle.getMessage(AddServerInstanceWizard.class, "LBL_NoServerPlugins_Close"); - DialogDescriptor descriptor = new DialogDescriptor( - NbBundle.getMessage(AddServerInstanceWizard.class, "LBL_NoServerPlugins_Text"), - NbBundle.getMessage(AddServerInstanceWizard.class, "LBL_NoServerPlugins_Title"), - true, - new Object[] {close}, - close, - DialogDescriptor.DEFAULT_ALIGN, - null, - null); + // except we run in ergonomics mode and providers are not yet on + // inspite there some are ready + JRadioButton[] ready = listAvailableProviders(); + if (ready.length == 0) { + // display the warning dialog - no server plugins + String close = NbBundle.getMessage(AddServerInstanceWizard.class, "LBL_NoServerPlugins_Close"); + DialogDescriptor descriptor = new DialogDescriptor( + NbBundle.getMessage(AddServerInstanceWizard.class, "LBL_NoServerPlugins_Text"), + NbBundle.getMessage(AddServerInstanceWizard.class, "LBL_NoServerPlugins_Title"), + true, + new Object[] {close}, + close, + DialogDescriptor.DEFAULT_ALIGN, + null, + null); - // TODO invoke plugin manager once API to do that will be available - DialogDisplayer.getDefault().notify(descriptor); - return null; + // TODO invoke plugin manager once API to do that will be available + DialogDisplayer.getDefault().notify(descriptor); + return null; + } else { + AvailableProvidersPanel available = new AvailableProvidersPanel(ready); + DialogDescriptor descriptor = new DialogDescriptor( + available, + NbBundle.getMessage(AddServerInstanceWizard.class, "LBL_NoServerPlugins_Title"), + true, + new Object[] {DialogDescriptor.OK_OPTION, DialogDescriptor.CANCEL_OPTION }, + null, + DialogDescriptor.DEFAULT_ALIGN, + null, + null); + + DialogDisplayer.getDefault().notify(descriptor); + if (descriptor.getValue() == DialogDescriptor.OK_OPTION) { + Action a = (Action)available.getSelected().getClientProperty("action"); // NOI18N + a.actionPerformed(new ActionEvent(descriptor, 0, "noui")); // NOI18N + } else { + return null; + } + } } AddServerInstanceWizard wizard = new AddServerInstanceWizard(); @@ -172,6 +205,31 @@ putProperty(PROP_CONTENT_SELECTED_INDEX, Integer.valueOf(getContentSelectedIndex())); } } + + static JRadioButton[] listAvailableProviders() { + List res = new ArrayList(); + + FileObject fo = FileUtil.getConfigFile("Servers/Actions"); // NOI18N + if (fo != null) { + for (FileObject o : fo.getChildren()) { + Object msg = o.getAttribute("wizardMessage"); // NOI18N + if (msg instanceof String) { + Lookup l = Lookups.forPath("Servers/Actions"); // NOI18N + for (Lookup.Item item : l.lookupResult(Action.class).allItems()) { + if (item.getId().contains(o.getName())) { + Action a = item.getInstance(); + JRadioButton button = new JRadioButton((String)msg); + button.putClientProperty("action", a); // NOI18N + res.add(button); + } + } + } + } + } + + return res.toArray(new JRadioButton[0]); + } + private ServerWizardPanel getChooser() { if (chooser == null) { diff -r 3ee3cc758b01 server/src/org/netbeans/modules/server/ui/wizard/AvailableProvidersPanel.form --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/org/netbeans/modules/server/ui/wizard/AvailableProvidersPanel.form Fri Apr 10 14:44:10 2009 +0200 @@ -0,0 +1,101 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -r 3ee3cc758b01 server/src/org/netbeans/modules/server/ui/wizard/AvailableProvidersPanel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/org/netbeans/modules/server/ui/wizard/AvailableProvidersPanel.java Fri Apr 10 14:44:10 2009 +0200 @@ -0,0 +1,153 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * + * 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 2009 Sun Microsystems, Inc. + */ + +/* + * AvailableProvidersPanel.java + * + * Created on 10.4.2009, 12:12:45 + */ + +package org.netbeans.modules.server.ui.wizard; + +import java.util.Enumeration; +import javax.swing.AbstractButton; +import javax.swing.JRadioButton; + +/** + * + * @author Jaroslav Tulach + */ +final class AvailableProvidersPanel extends javax.swing.JPanel { + + /** Creates new form AvailableProvidersPanel */ + public AvailableProvidersPanel(JRadioButton[] arr) { + initComponents(); + + radioPanel.removeAll(); + for (JRadioButton b : arr) { + radioGroup.add(b); + radioPanel.add(b); + } + arr[0].setSelected(true); + } + + public JRadioButton getSelected() { + Enumeration en = radioGroup.getElements(); + while (en.hasMoreElements()) { + AbstractButton b = en.nextElement(); + if (b.isSelected()) { + return (JRadioButton)b; + } + } + throw new IllegalStateException(); + } + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + radioGroup = new javax.swing.ButtonGroup(); + radioPanel = new javax.swing.JPanel(); + jRadioButton2 = new javax.swing.JRadioButton(); + jRadioButton3 = new javax.swing.JRadioButton(); + msgPanel = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + + radioPanel.setLayout(new java.awt.GridLayout(0, 1)); + + radioGroup.add(jRadioButton2); + jRadioButton2.setText(org.openide.util.NbBundle.getBundle(AvailableProvidersPanel.class).getString("AvailableProvidersPanel.jRadioButton2.text")); // NOI18N + radioPanel.add(jRadioButton2); + + radioGroup.add(jRadioButton3); + jRadioButton3.setText(org.openide.util.NbBundle.getBundle(AvailableProvidersPanel.class).getString("AvailableProvidersPanel.jRadioButton3.text")); // NOI18N + radioPanel.add(jRadioButton3); + + jLabel1.setText(org.openide.util.NbBundle.getBundle(AvailableProvidersPanel.class).getString("MSG_AvailableProviders")); // NOI18N + + javax.swing.GroupLayout msgPanelLayout = new javax.swing.GroupLayout(msgPanel); + msgPanel.setLayout(msgPanelLayout); + msgPanelLayout.setHorizontalGroup( + msgPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(msgPanelLayout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 402, Short.MAX_VALUE) + .addContainerGap()) + ); + msgPanelLayout.setVerticalGroup( + msgPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(msgPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createSequentialGroup() + .addGap(12, 12, 12) + .addComponent(radioPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 402, Short.MAX_VALUE) + .addGap(12, 12, 12)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(msgPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(radioPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JRadioButton jRadioButton2; + private javax.swing.JRadioButton jRadioButton3; + private javax.swing.JPanel msgPanel; + private javax.swing.ButtonGroup radioGroup; + private javax.swing.JPanel radioPanel; + // End of variables declaration//GEN-END:variables + +} diff -r 3ee3cc758b01 server/src/org/netbeans/modules/server/ui/wizard/Bundle.properties --- a/server/src/org/netbeans/modules/server/ui/wizard/Bundle.properties Fri Apr 10 13:32:27 2009 +0200 +++ b/server/src/org/netbeans/modules/server/ui/wizard/Bundle.properties Fri Apr 10 14:44:10 2009 +0200 @@ -71,3 +71,9 @@ The IDE needs a server plugin (e.g. GlassFish plugin) to enable registering
\ and using a server. Use Plugins Manager to install server plugins. LBL_NoServerPlugins_Close=Close +MSG_AvailableProviders=No server plugins are enabled in the IDE right now. \ +However some server plugins seem to be available. \ +Please choose the type of servers you wish to work with \ +and proceed with enabling necessary functionality. +AvailableProvidersPanel.jRadioButton2.text= +AvailableProvidersPanel.jRadioButton3.text= diff -r 3ee3cc758b01 server/test/unit/src/org/netbeans/modules/server/ui/wizard/AddServerInstanceWizardTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/test/unit/src/org/netbeans/modules/server/ui/wizard/AddServerInstanceWizardTest.java Fri Apr 10 14:44:10 2009 +0200 @@ -0,0 +1,133 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. + * + * 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. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun 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 2009 Sun Microsystems, Inc. + */ + +package org.netbeans.modules.server.ui.wizard; + +import java.awt.EventQueue; +import java.awt.event.ActionEvent; +import java.io.IOException; +import javax.swing.AbstractAction; +import javax.swing.JRadioButton; +import org.junit.Test; +import static org.junit.Assert.*; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; + +/** + * + * @author Jaroslav Tulach + */ +public class AddServerInstanceWizardTest { + + public AddServerInstanceWizardTest() { + } + + @Test + public void testListAvailableProviders() throws Throwable { + class Work implements Runnable { + int action; + Throwable t; + CntAction a; + CntAction b; + + + public void run() { + switch (action) { + case 0: setup(); break; + case 1: check1(); break; + default: fail(); + } + } + + private void setup() { + try { + FileObject fo = FileUtil.getConfigFile("Servers/Actions"); + assertNotNull("Folder for actions precreated", fo); + a = new CntAction(); + FileObject afo = fo.createData("A2.instance"); + afo.setAttribute("instanceCreate", a); + afo.setAttribute("wizardMessage", "Ahoj"); + afo.setAttribute("position", 309); + b = new CntAction(); + FileObject bfo = fo.createData("A3.instance"); + bfo.setAttribute("instanceCreate", b); + bfo.setAttribute("position", 159); + } catch (IOException ex) { + this.t = ex; + } + } + + private void check1() { + try { + JRadioButton[] result = AddServerInstanceWizard.listAvailableProviders(); + assertEquals("One action found", 1, result.length); + assertEquals("Message is taken from attribute", "Ahoj", result[0].getText()); + assertSame("Not part of API, but behaviour: Action is stored in property", + a, + result[0].getClientProperty("action") + ); + } catch (Throwable ex) { + this.t = ex; + } + } + } + + Work w = new Work(); + w.action = 0; + FileUtil.runAtomicAction(w); + w.action = 1; + EventQueue.invokeAndWait(w); + + if (w.t != null) { + throw w.t; + } + + + } + + public static final class CntAction extends AbstractAction { + int cnt; + + public void actionPerformed(ActionEvent e) { + assertEquals("noui", e.getActionCommand()); + cnt++; + } + } + +} \ No newline at end of file