# HG changeset patch # Parent 7b5b85f654629ffccfbc43126c5d603fef85e46e diff -r 7b5b85f65462 java.j2seproject/apichanges.xml --- a/java.j2seproject/apichanges.xml Tue Aug 09 11:35:50 2011 +0200 +++ b/java.j2seproject/apichanges.xml Tue Aug 09 11:37:52 2011 +0200 @@ -127,6 +127,25 @@ + Enable extending existing JSE Project category panels in Project Properties dialog + + + + + + Replace the existing J2SERunConfigProvider interface by + J2SECategoryExtensionProvider. The old interface was hardwired + to enable extension of Run panel only with one extension panel only. The + new interface provides this mechanism for any category and allows + multiple extension panels per category. The new functionality is needed + for JavaFX 2.0 support module, but is not limited to it. + + + + + + + Added class for accessing PropertyEvaluator for given JSE Project diff -r 7b5b85f65462 java.j2seproject/src/org/netbeans/modules/java/j2seproject/api/J2SECategoryExtensionProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/api/J2SECategoryExtensionProvider.java Tue Aug 09 11:37:52 2011 +0200 @@ -0,0 +1,110 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 1997-2010 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]" + * + * Contributor(s): + * + * The Original Software is NetBeans. The Initial Developer of the Original + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun + * Microsystems, Inc. All Rights Reserved. + * + * 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. + */ + +package org.netbeans.modules.java.j2seproject.api; + +import java.util.Map; +import javax.swing.JComponent; + +import org.netbeans.api.project.Project; + +/** + * Provider of component that will be added to customizer panel of category specified + * by getCategory() return value. Component will be used for additional customization + * of a set of additional properties not customized by standard J2SE Project controls. + * Implementation of the interface should be registered using {@link org.netbeans.spi.project.ProjectServiceProvider}. + * + * @author Petr Somol + * @author Milan Kubec + * @since 1.46 + */ +public interface J2SECategoryExtensionProvider { + + /** + * Enumeration of categories for which extension is currently allowed + */ + enum ExtendableCategory { PACKAGING, RUN } + + /** + * Provides identifier of category whose panel should be extended by this component provider + * + * @returns identifier of the category to be extended + */ + ExtendableCategory getCategory(); + + /** + * Provides component that is added to the customizer panel of j2seproject + * selected by getCategory() return value + * + * @param proj project to create the customizer component for + * @param listener listener to be notified when properties should be updated + * @returns extension panel to be added to the specified category + */ + JComponent createComponent(Project proj, ConfigChangeListener listener); + + /** + * Method is called when properties exposed by the provided component + * get changed externally and the component needs to be updated accordingly + * + * @param props all properties (shared + private); + * properites are not evaluated + */ + void configUpdated(Map props); + + /** + * Callback listener for setting properties that are changed by interaction + * with the component + */ + interface ConfigChangeListener { + /** + * Method is called when properties should be updated, null prop value + * means property will be removed from the property file, only shared + * properties are updated; properties are not evaluated + * + * @param updates map holding updated properties + */ + void propertiesChanged(Map updates); + } + +} diff -r 7b5b85f65462 java.j2seproject/src/org/netbeans/modules/java/j2seproject/api/J2SERunConfigProvider.java --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/api/J2SERunConfigProvider.java Tue Aug 09 11:35:50 2011 +0200 +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/api/J2SERunConfigProvider.java Tue Aug 09 11:37:52 2011 +0200 @@ -53,10 +53,13 @@ * Provider of component that will be added to Run customizer panel that will * be used for additional customization of set of properties affected by given * run configuration. Implementation of the interface should be registered using {@link org.openide.util.lookup.ServiceProvider}. + * This interface is deprecated, use {@link org.netbeans.modules.java.j2seproject.api.J2SECategoryExtensionProvider} instead. * + * @deprecated * @author Milan Kubec * @since 1.10 */ +@Deprecated public interface J2SERunConfigProvider { /** diff -r 7b5b85f65462 java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerJar.form --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerJar.form Tue Aug 09 11:35:50 2011 +0200 +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerJar.form Tue Aug 09 11:37:52 2011 +0200 @@ -1,4 +1,4 @@ - +
@@ -11,152 +11,177 @@ + - - - - - + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff -r 7b5b85f65462 java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerJar.java --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerJar.java Tue Aug 09 11:35:50 2011 +0200 +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerJar.java Tue Aug 09 11:37:52 2011 +0200 @@ -44,16 +44,38 @@ package org.netbeans.modules.java.j2seproject.ui.customizer; +import java.awt.Dimension; +import java.util.LinkedList; +import javax.swing.Box; +import javax.swing.JComponent; import javax.swing.JPanel; +import org.netbeans.api.project.Project; +import org.netbeans.modules.java.j2seproject.J2SEProject; import org.openide.util.HelpCtx; +import org.netbeans.modules.java.j2seproject.api.J2SECategoryExtensionProvider; /** Customizer for general project attributes. */ public class CustomizerJar extends JPanel implements HelpCtx.Provider { + private J2SEProject project; + private java.util.List compProviders = new LinkedList(); + public CustomizerJar( J2SEProjectProperties uiProperties ) { initComponents(); + int nextExtensionYPos = 0; + this.project = uiProperties.getProject(); + for (J2SECategoryExtensionProvider compProvider : project.getLookup().lookupAll(J2SECategoryExtensionProvider.class)) { + if( compProvider.getCategory() == J2SECategoryExtensionProvider.ExtendableCategory.PACKAGING ) { + if( addExtPanel(project,compProvider,nextExtensionYPos) ) { + compProviders.add(compProvider); + nextExtensionYPos++; + } + } + } + addPanelFiller(nextExtensionYPos); + distDirField.setDocument(uiProperties.DIST_JAR_MODEL); excludeField.setDocument(uiProperties.BUILD_CLASSES_EXCLUDES_MODEL); @@ -67,13 +89,16 @@ copyLibs.setModel(uiProperties.COPY_LIBS_MODEL); } + @Override public HelpCtx getHelpCtx() { return new HelpCtx( CustomizerJar.class ); } // //GEN-BEGIN:initComponents private void initComponents() { + java.awt.GridBagConstraints gridBagConstraints; + mainPanel = new javax.swing.JPanel(); distDirLabel = new javax.swing.JLabel(); distDirField = new javax.swing.JTextField(); excludeLabel = new javax.swing.JLabel(); @@ -82,6 +107,9 @@ compressCheckBox = new javax.swing.JCheckBox(); doJarCheckBox = new javax.swing.JCheckBox(); copyLibs = new javax.swing.JCheckBox(); + extPanel = new javax.swing.JPanel(); + + setLayout(new java.awt.GridBagLayout()); distDirLabel.setLabelFor(distDirField); org.openide.awt.Mnemonics.setLocalizedText(distDirLabel, org.openide.util.NbBundle.getMessage(CustomizerJar.class, "LBL_CustomizeJar_DistDir_JTextField")); // NOI18N @@ -101,56 +129,78 @@ org.openide.awt.Mnemonics.setLocalizedText(copyLibs, org.openide.util.NbBundle.getMessage(CustomizerJar.class, "TXT_CopyLibraries")); // NOI18N - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() + javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel); + mainPanel.setLayout(mainPanelLayout); + mainPanelLayout.setHorizontalGroup( + mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 404, Short.MAX_VALUE) + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(mainPanelLayout.createSequentialGroup() + .addGap(0, 0, 0) + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(compressCheckBox) + .addGroup(mainPanelLayout.createSequentialGroup() + .addComponent(doJarCheckBox) + .addGap(245, 245, 245)) + .addComponent(copyLibs) + .addGroup(mainPanelLayout.createSequentialGroup() + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(excludeLabel) + .addComponent(distDirLabel)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(excludeMessage) + .addComponent(excludeField, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE) + .addComponent(distDirField, javax.swing.GroupLayout.DEFAULT_SIZE, 289, Short.MAX_VALUE)))) + .addGap(0, 0, 0))) + ); + mainPanelLayout.setVerticalGroup( + mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 161, Short.MAX_VALUE) + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(mainPanelLayout.createSequentialGroup() + .addContainerGap() + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(distDirLabel) - .addGap(88, 88, 88) - .addComponent(distDirField, javax.swing.GroupLayout.DEFAULT_SIZE, 391, Short.MAX_VALUE)) + .addComponent(distDirField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(excludeLabel) + .addComponent(excludeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(excludeMessage) + .addGap(8, 8, 8) .addComponent(compressCheckBox) - .addGroup(layout.createSequentialGroup() - .addComponent(excludeLabel) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(excludeMessage) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 209, Short.MAX_VALUE)) - .addComponent(excludeField, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE))) - .addGroup(layout.createSequentialGroup() - .addComponent(doJarCheckBox) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 340, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addComponent(copyLibs)) - .addContainerGap()) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(distDirLabel) - .addComponent(distDirField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(excludeLabel) - .addComponent(excludeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(excludeMessage) - .addGap(8, 8, 8) - .addComponent(compressCheckBox) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(doJarCheckBox) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(copyLibs) - .addContainerGap(163, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(doJarCheckBox) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(copyLibs) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) ); distDirField.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(CustomizerJar.class).getString("AD_jTextFieldDistDir")); // NOI18N excludeField.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(CustomizerJar.class).getString("AD_jTextFieldExcludes")); // NOI18N compressCheckBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(CustomizerJar.class).getString("AD_jCheckBoxCompress")); // NOI18N doJarCheckBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerJar.class, "ACSD_BuildJarAfterCompile")); // NOI18N + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 0; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; + add(mainPanel, gridBagConstraints); + + extPanel.setLayout(new java.awt.GridBagLayout()); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; + gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; + gridBagConstraints.weightx = 0.1; + gridBagConstraints.weighty = 0.1; + add(extPanel, gridBagConstraints); }// //GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables @@ -162,6 +212,38 @@ private javax.swing.JTextField excludeField; private javax.swing.JLabel excludeLabel; private javax.swing.JLabel excludeMessage; + private javax.swing.JPanel extPanel; + private javax.swing.JPanel mainPanel; // End of variables declaration//GEN-END:variables + private boolean addExtPanel(Project p, J2SECategoryExtensionProvider compProvider, int gridY) { + if (compProvider != null) { + JComponent comp = compProvider.createComponent(p, null); + if (comp != null) { + java.awt.GridBagConstraints constraints = new java.awt.GridBagConstraints(); + constraints.anchor = java.awt.GridBagConstraints.NORTHWEST; + constraints.gridx = 0; + constraints.gridy = gridY; + constraints.weightx = 1.0; + extPanel.add(comp, constraints); + return true; + } + } + return false; + } + + private void addPanelFiller(int gridY) { + java.awt.GridBagConstraints constraints = new java.awt.GridBagConstraints(); + constraints.anchor = java.awt.GridBagConstraints.NORTHWEST; + constraints.gridx = 0; + constraints.gridy = gridY; + constraints.weightx = 1.0; + constraints.weighty = 1.0; + extPanel.add( new Box.Filler( + new Dimension(), + new Dimension(), + new Dimension(10000,10000) ), + constraints); + } + } diff -r 7b5b85f65462 java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerRun.form --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerRun.form Tue Aug 09 11:35:50 2011 +0200 +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerRun.form Tue Aug 09 11:37:52 2011 +0200 @@ -1,4 +1,4 @@ - +
diff -r 7b5b85f65462 java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerRun.java --- a/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerRun.java Tue Aug 09 11:35:50 2011 +0200 +++ b/java.j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerRun.java Tue Aug 09 11:37:52 2011 +0200 @@ -49,6 +49,7 @@ import org.netbeans.modules.java.api.common.project.ProjectProperties; import org.netbeans.modules.java.api.common.project.ui.customizer.MainClassChooser; import org.netbeans.modules.java.j2seproject.J2SEProject; +import org.netbeans.modules.java.j2seproject.api.J2SECategoryExtensionProvider; import org.netbeans.modules.java.j2seproject.api.J2SERunConfigProvider; import org.netbeans.modules.java.j2seproject.ui.customizer.vmo.OptionsDialog; import org.openide.DialogDescriptor; @@ -88,7 +89,9 @@ private Map/*|null*/> configs; J2SEProjectProperties uiProperties; - private J2SERunConfigProvider compProvider; + private java.util.List compProviders = new LinkedList(); + private J2SERunConfigProvider compProviderDeprecated; + private int nextExtensionYPos; public CustomizerRun( J2SEProjectProperties uiProperties ) { this.uiProperties = uiProperties; @@ -96,8 +99,21 @@ this.project = uiProperties.getProject(); - compProvider = Lookup.getDefault().lookup(J2SERunConfigProvider.class); + nextExtensionYPos = 0; + // BEGIN Deprecated + compProviderDeprecated = Lookup.getDefault().lookup(J2SERunConfigProvider.class); initExtPanel(project); + // END Deprecated + + for (J2SECategoryExtensionProvider compProvider : project.getLookup().lookupAll(J2SECategoryExtensionProvider.class)) { + if( compProvider.getCategory() == J2SECategoryExtensionProvider.ExtendableCategory.RUN ) { + if( addExtPanel(project,compProvider,nextExtensionYPos) ) { + compProviders.add(compProvider); + nextExtensionYPos++; + } + } + } + addPanelFiller(nextExtensionYPos); configs = uiProperties.RUN_CONFIGS; @@ -396,9 +412,31 @@ add(extPanel, gridBagConstraints); }// //GEN-END:initComponents + @Deprecated private void initExtPanel(Project p) { + if (compProviderDeprecated != null) { + J2SERunConfigProvider.ConfigChangeListener ccl = new J2SERunConfigProvider.ConfigChangeListener() { + public void propertiesChanged(Map updates) { + // update active configuration + Map m = configs.get(uiProperties.activeConfig); + m.putAll(updates); + } + }; + JComponent comp = compProviderDeprecated.createComponent(p, ccl); + if (comp != null) { + java.awt.GridBagConstraints constraints = new java.awt.GridBagConstraints(); + constraints.anchor = java.awt.GridBagConstraints.NORTHWEST; + constraints.gridx = 0; + constraints.gridy = nextExtensionYPos++; + constraints.weightx = 1.0; + extPanel.add(comp, constraints); + } + } + } + + private boolean addExtPanel(Project p, J2SECategoryExtensionProvider compProvider, int gridY) { if (compProvider != null) { - J2SERunConfigProvider.ConfigChangeListener ccl = new J2SERunConfigProvider.ConfigChangeListener() { + J2SECategoryExtensionProvider.ConfigChangeListener ccl = new J2SECategoryExtensionProvider.ConfigChangeListener() { public void propertiesChanged(Map updates) { // update active configuration Map m = configs.get(uiProperties.activeConfig); @@ -410,12 +448,27 @@ java.awt.GridBagConstraints constraints = new java.awt.GridBagConstraints(); constraints.anchor = java.awt.GridBagConstraints.NORTHWEST; constraints.gridx = 0; - constraints.gridy = 0; + constraints.gridy = gridY; constraints.weightx = 1.0; - constraints.weighty = 1.0; extPanel.add(comp, constraints); + return true; } } + return false; + } + + private void addPanelFiller(int gridY) { + java.awt.GridBagConstraints constraints = new java.awt.GridBagConstraints(); + constraints.anchor = java.awt.GridBagConstraints.NORTHWEST; + constraints.gridx = 0; + constraints.gridy = gridY; + constraints.weightx = 1.0; + constraints.weighty = 1.0; + extPanel.add( new Box.Filler( + new Dimension(), + new Dimension(), + new Dimension(10000,10000) ), + constraints); } private void configDelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_configDelActionPerformed @@ -524,7 +577,12 @@ Map m = configs.get(activeConfig); Map def = configs.get(null); if (m != null) { - if (compProvider != null) { + // BEGIN Deprecated + if (compProviderDeprecated != null) { + compProviderDeprecated.configUpdated(m); + } + // END Deprecated + for(J2SECategoryExtensionProvider compProvider : compProviders) { compProvider.configUpdated(m); } for (int i = 0; i < data.length; i++) { diff -r 8f961aa2f775 -r 3d0868375aa6 java.j2seproject/test/unit/src/org/netbeans/modules/java/j2seproject/api/J2SECategoryExtensionProviderTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java.j2seproject/test/unit/src/org/netbeans/modules/java/j2seproject/api/J2SECategoryExtensionProviderTest.java Wed Aug 10 11:31:25 2011 +0200 @@ -0,0 +1,283 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2011 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 2011 Sun Microsystems, Inc. + */ +package org.netbeans.modules.java.j2seproject.api; + +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.LinkedList; +import java.util.Map; +import java.util.TreeMap; +import javax.swing.JComponent; +import javax.swing.JPanel; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; +import org.netbeans.api.project.Project; +import org.netbeans.junit.MockServices; +import org.netbeans.modules.java.j2seproject.api.J2SECategoryExtensionProvider.ConfigChangeListener; +import org.netbeans.modules.java.j2seproject.api.J2SECategoryExtensionProvider.ExtendableCategory; +import org.openide.util.Lookup; + +/** + * + * @author Petr Somol + */ +public class J2SECategoryExtensionProviderTest { + + public J2SECategoryExtensionProviderTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + MockServices.setServices(J2SEMockRunProvider1.class, J2SEMockPackagingProvider.class, J2SEMockRunProvider2.class); + } + + private Map properties = new TreeMap(); + + /** + * Test of J2SECategoryExtensionProvider. + */ + @Test + public void testCustomizerExtension() { + System.out.println("testCustomizerExtension():"); + assertEquals(Lookup.getDefault().lookupAll(J2SECategoryExtensionProvider.class).size(), 3); + + java.util.List compProviders = new LinkedList(); + JPanel pane = new JPanel(); + int nextExtensionYPos = 0; + for (J2SECategoryExtensionProvider compProvider : Lookup.getDefault().lookupAll(J2SECategoryExtensionProvider.class)) { + if( compProvider.getCategory() == J2SECategoryExtensionProvider.ExtendableCategory.RUN ) { + if( addExtPanel(pane,compProvider,nextExtensionYPos) ) { + compProviders.add(compProvider); + nextExtensionYPos++; + } + } + } + System.out.println("registered extension components"); + assertEquals(compProviders.size(), 2); + assertEquals(pane.getComponents().length, 2); + for(J2SECategoryExtensionProvider provider: compProviders) { + assertEquals( provider.getCategory(), J2SECategoryExtensionProvider.ExtendableCategory.RUN); + } + for(Component comp : pane.getComponents()) { + assertTrue(comp instanceof MockupComponent); + assertEquals(((MockupComponent)comp).getState(), false); + } + assertNull(properties.get("MockupRunExtender1")); + assertNull(properties.get("MockupRunExtender2")); + assertNull(properties.get("MockupPackagingExtender")); + System.out.println("OK"); + + System.out.println("simulate event generated by user using the extension component"); + MockupComponent extComp = (MockupComponent)pane.getComponent(0); + assertNotNull(extComp); + extComp.setState(true); + extComp.actionPerformed(null); + assertEquals(properties.get("MockupRunExtender1"), "true"); + assertNull(properties.get("MockupRunExtender2")); + assertNull(properties.get("MockupPackagingExtender")); + System.out.println("OK"); + + System.out.println("simulate event from outside the extension component"); + properties.put("MockupRunExtender2", "true"); + for(J2SECategoryExtensionProvider provider: compProviders) { + provider.configUpdated(properties); + } + for(Component comp : pane.getComponents()) { + assertTrue(comp instanceof MockupComponent); + assertEquals(((MockupComponent)comp).getState(), true); + } + System.out.println("OK"); + } + + private boolean addExtPanel(JPanel p, J2SECategoryExtensionProvider compProvider, int gridY) { + if (compProvider != null) { + J2SECategoryExtensionProvider.ConfigChangeListener ccl = new J2SECategoryExtensionProvider.ConfigChangeListener() { + @Override + public void propertiesChanged(Map updates) { + properties.putAll(updates); + } + }; + JComponent comp = compProvider.createComponent(null, ccl); + if (comp != null) { + java.awt.GridBagConstraints constraints = new java.awt.GridBagConstraints(); + constraints.anchor = java.awt.GridBagConstraints.NORTHWEST; + constraints.gridx = 0; + constraints.gridy = gridY; + constraints.weightx = 1.0; + p.add(comp, constraints); + return true; + } + } + return false; + } + + public static final class J2SEMockRunProvider1 implements J2SECategoryExtensionProvider { + + MockupComponent extender; + + @Override + public ExtendableCategory getCategory() { + return ExtendableCategory.RUN; + } + + @Override + public JComponent createComponent(Project proj, ConfigChangeListener listener) { + extender = new MockupComponent("MockupRunExtender1"); + extender.setState(false); + extender.addListener(listener); + return extender; + } + + @Override + public void configUpdated(Map props) { + String value = props.get("MockupRunExtender1"); + if(value != null) { + if( "true".equals(value)) { + extender.setState(true); + } else { + if( "false".equals(value)) { + extender.setState(false); + } + } + } + } + } + + public static final class J2SEMockRunProvider2 implements J2SECategoryExtensionProvider { + + MockupComponent extender; + + @Override + public ExtendableCategory getCategory() { + return ExtendableCategory.RUN; + } + + @Override + public JComponent createComponent(Project proj, ConfigChangeListener listener) { + extender = new MockupComponent("MockupRunExtender2"); + extender.setState(false); + extender.addListener(listener); + return extender; + } + + @Override + public void configUpdated(Map props) { + String value = props.get("MockupRunExtender2"); + if(value != null) { + if( "true".equals(value)) { + extender.setState(true); + } else { + if( "false".equals(value)) { + extender.setState(false); + } + } + } + } + } + + public static final class J2SEMockPackagingProvider implements J2SECategoryExtensionProvider { + + MockupComponent extender; + + @Override + public ExtendableCategory getCategory() { + return ExtendableCategory.PACKAGING; + } + + @Override + public JComponent createComponent(Project proj, ConfigChangeListener listener) { + extender = new MockupComponent("MockupPackagingExtender"); + extender.setState(false); + extender.addListener(listener); + return extender; + } + + @Override + public void configUpdated(Map props) { + String value = props.get("MockupPackagingExtender"); + if(value != null) { + if( "true".equals(value)) { + extender.setState(true); + } else { + if( "false".equals(value)) { + extender.setState(false); + } + } + } + } + } + + public static final class MockupComponent extends JComponent implements ActionListener { + + public boolean state; + private String name; + + private J2SECategoryExtensionProvider.ConfigChangeListener listener; + + public MockupComponent(String name) { + state = false; + this.name = name; + } + + public void setState(boolean state) { + this.state = state; + } + + public boolean getState() { + return state; + } + + public void addListener(J2SECategoryExtensionProvider.ConfigChangeListener l) { + listener = l; + } + + @Override + public void actionPerformed(ActionEvent e) { + Map props = new TreeMap(); + if( getState() ) { + props.put(name, "true"); + } else { + props.put(name, "false"); + } + listener.propertiesChanged(props); + } + } + +} diff -r 5dee59c736e6 javawebstart/manifest.mf --- a/javawebstart/manifest.mf Tue Aug 09 13:09:39 2011 +0200 +++ b/javawebstart/manifest.mf Tue Aug 09 13:16:52 2011 +0200 @@ -2,5 +2,5 @@ OpenIDE-Module: org.netbeans.modules.javawebstart OpenIDE-Module-Layer: org/netbeans/modules/javawebstart/layer.xml OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/javawebstart/Bundle.properties -OpenIDE-Module-Specification-Version: 1.13 +OpenIDE-Module-Specification-Version: 1.14 AutoUpdate-Show-In-Client: false diff -r 5dee59c736e6 javawebstart/nbproject/project.xml --- a/javawebstart/nbproject/project.xml Tue Aug 09 13:09:39 2011 +0200 +++ b/javawebstart/nbproject/project.xml Tue Aug 09 13:16:52 2011 +0200 @@ -50,15 +50,6 @@ org.netbeans.modules.javawebstart - org.netbeans.core.multiview - - - - 1 - 1.25 - - - org.netbeans.api.java.classpath @@ -77,6 +68,15 @@ + org.netbeans.core.multiview + + + + 1 + 1.25 + + + org.netbeans.libs.javacapi @@ -90,7 +90,7 @@ 1 - 1.41 + 1.46 diff -r 5dee59c736e6 javawebstart/src/org/netbeans/modules/javawebstart/CustomizerRunComponent.java --- a/javawebstart/src/org/netbeans/modules/javawebstart/CustomizerRunComponent.java Tue Aug 09 13:09:39 2011 +0200 +++ b/javawebstart/src/org/netbeans/modules/javawebstart/CustomizerRunComponent.java Tue Aug 09 13:16:52 2011 +0200 @@ -50,7 +50,7 @@ import java.util.HashMap; import java.util.Map; -import org.netbeans.modules.java.j2seproject.api.J2SERunConfigProvider; +import org.netbeans.modules.java.j2seproject.api.J2SECategoryExtensionProvider; import org.netbeans.modules.javawebstart.ui.customizer.JWSProjectProperties; /** @@ -62,7 +62,7 @@ private Map runSelectedMap = new HashMap(); private Map runUnselectedMap = new HashMap(); - private J2SERunConfigProvider.ConfigChangeListener listener; + private J2SECategoryExtensionProvider.ConfigChangeListener listener; public CustomizerRunComponent() { initComponents(); @@ -107,7 +107,7 @@ add(hintLabel, gridBagConstraints); }// //GEN-END:initComponents - public void addListener(J2SERunConfigProvider.ConfigChangeListener l) { + public void addListener(J2SECategoryExtensionProvider.ConfigChangeListener l) { listener = l; } diff -r 5dee59c736e6 javawebstart/src/org/netbeans/modules/javawebstart/J2SERunConfigProviderImpl.java --- a/javawebstart/src/org/netbeans/modules/javawebstart/J2SERunConfigProviderImpl.java Tue Aug 09 13:09:39 2011 +0200 +++ b/javawebstart/src/org/netbeans/modules/javawebstart/J2SERunConfigProviderImpl.java Tue Aug 09 13:16:52 2011 +0200 @@ -50,23 +50,30 @@ import org.netbeans.api.project.Project; -import org.netbeans.modules.java.j2seproject.api.J2SERunConfigProvider; +import org.netbeans.modules.java.j2seproject.api.J2SECategoryExtensionProvider; import org.netbeans.modules.java.j2seproject.api.J2SEPropertyEvaluator; import org.netbeans.modules.javawebstart.ui.customizer.JWSCustomizerPanel; +import org.netbeans.spi.project.ProjectServiceProvider; import org.netbeans.spi.project.support.ant.PropertyEvaluator; /** * * @author Milan Kubec + * @author Petr Somol + * @since 1.14 */ -@org.openide.util.lookup.ServiceProvider(service=org.netbeans.modules.java.j2seproject.api.J2SERunConfigProvider.class) -public class J2SERunConfigProviderImpl implements J2SERunConfigProvider { +@ProjectServiceProvider(service=J2SECategoryExtensionProvider.class, projectType="org-netbeans-modules-java-j2seproject") +public class J2SERunConfigProviderImpl implements J2SECategoryExtensionProvider { public J2SERunConfigProviderImpl() {} - public JComponent createComponent(Project p, J2SERunConfigProvider.ConfigChangeListener listener) { + public ExtendableCategory getCategory() { + return ExtendableCategory.RUN; + } + + public JComponent createComponent(Project p, J2SECategoryExtensionProvider.ConfigChangeListener listener) { J2SEPropertyEvaluator j2sePropEval = p.getLookup().lookup(J2SEPropertyEvaluator.class); PropertyEvaluator evaluator = j2sePropEval.evaluator(); String enabled = evaluator.getProperty("jnlp.enabled"); // NOI18N