Index: java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerRun.java
===================================================================
RCS file: /cvs/java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerRun.java,v
retrieving revision 1.22
diff -u -r1.22 CustomizerRun.java
--- java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerRun.java 8 Sep 2006 18:33:48 -0000 1.22
+++ java/j2seproject/src/org/netbeans/modules/java/j2seproject/ui/customizer/CustomizerRun.java 29 Jan 2007 15:26:33 -0000
@@ -25,17 +25,21 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.io.File;
import java.text.Collator;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import javax.swing.DefaultComboBoxModel;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JButton;
+import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JList;
@@ -45,14 +49,17 @@
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
+import org.netbeans.api.project.Project;
import org.netbeans.modules.java.j2seproject.J2SEProject;
import org.netbeans.modules.java.j2seproject.SourceRoots;
+import org.netbeans.modules.java.j2seproject.api.ConfigComponentProvider;
import org.openide.DialogDescriptor;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.awt.MouseUtils;
import org.openide.filesystems.FileUtil;
import org.openide.util.HelpCtx;
+import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.util.Utilities;
@@ -66,12 +73,17 @@
private Map/*|null*/> configs;
J2SEProjectProperties uiProperties;
+ private ConfigComponentProvider compProvider;
+
public CustomizerRun( J2SEProjectProperties uiProperties ) {
this.uiProperties = uiProperties;
initComponents();
-
+
this.project = uiProperties.getProject();
+ compProvider = Lookup.getDefault().lookup(ConfigComponentProvider.class);
+ initExtPanel(project);
+
configs = uiProperties.RUN_CONFIGS;
data = new JTextField[] {
@@ -192,9 +204,9 @@
jLabelVMOptions = new javax.swing.JLabel();
jTextVMOptions = new javax.swing.JTextField();
jLabelVMOptionsExample = new javax.swing.JLabel();
+ extPanel = new javax.swing.JPanel();
setLayout(new java.awt.GridBagLayout());
-
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
@@ -218,7 +230,6 @@
configComboActionPerformed(evt);
}
});
-
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
@@ -232,7 +243,6 @@
configNewActionPerformed(evt);
}
});
-
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(2, 6, 2, 0);
@@ -244,7 +254,6 @@
configDelActionPerformed(evt);
}
});
-
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(2, 6, 2, 0);
@@ -264,7 +273,6 @@
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
mainPanel.add(jLabelMainClass, gridBagConstraints);
-
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
@@ -286,7 +294,6 @@
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 0);
mainPanel.add(jLabelArgs, gridBagConstraints);
-
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
@@ -302,7 +309,6 @@
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
mainPanel.add(jLabelWorkingDirectory, gridBagConstraints);
-
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
@@ -319,7 +325,6 @@
jButtonWorkingDirectoryBrowseActionPerformed(evt);
}
});
-
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
@@ -334,7 +339,6 @@
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
mainPanel.add(jLabelVMOptions, gridBagConstraints);
-
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
@@ -347,8 +351,6 @@
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 4;
- gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
- gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(0, 12, 12, 0);
@@ -361,12 +363,43 @@
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.weightx = 1.0;
- gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(6, 0, 6, 0);
add(mainPanel, gridBagConstraints);
+ extPanel.setLayout(new java.awt.GridBagLayout());
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 3;
+ gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
+ gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.weighty = 1.0;
+ add(extPanel, gridBagConstraints);
}// //GEN-END:initComponents
+ private void initExtPanel(Project p) {
+ if (compProvider != null) {
+ ConfigComponentProvider.ConfigChangedListener ccl = new ConfigComponentProvider.ConfigChangedListener() {
+ public void propertiesChanged(Map updates) {
+ // update active configuration
+ Map m = configs.get(uiProperties.activeConfig);
+ m.putAll(updates);
+ }
+ };
+ JComponent comp = compProvider.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 = 0;
+ constraints.weightx = 1.0;
+ constraints.weighty = 1.0;
+ extPanel.add(comp, constraints);
+ }
+ }
+ }
+
private void configDelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_configDelActionPerformed
String config = (String) configCombo.getSelectedItem();
assert config != null;
@@ -454,6 +487,7 @@
Map m = configs.get(activeConfig);
Map def = configs.get(null);
if (m != null) {
+ compProvider.configUpdated(m);
for (int i = 0; i < data.length; i++) {
String v = m.get(keys[i]);
if (v == null) {
@@ -474,6 +508,7 @@
private javax.swing.JButton configNew;
private javax.swing.JPanel configPanel;
private javax.swing.JSeparator configSep;
+ private javax.swing.JPanel extPanel;
private javax.swing.JButton jButtonMainClass;
private javax.swing.JButton jButtonWorkingDirectoryBrowse;
private javax.swing.JLabel jLabelArgs;
Index: java/j2seproject/src/org/netbeans/modules/java/j2seproject/api/ConfigComponentProvider.java
===================================================================
RCS file: java/j2seproject/src/org/netbeans/modules/java/j2seproject/api/ConfigComponentProvider.java
diff -N java/j2seproject/src/org/netbeans/modules/java/j2seproject/api/ConfigComponentProvider.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ java/j2seproject/src/org/netbeans/modules/java/j2seproject/api/ConfigComponentProvider.java 29 Jan 2007 15:26:33 -0000
@@ -0,0 +1,67 @@
+/*
+ * The contents of this file are subject to the terms of the Common Development
+ * and Distribution License (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.html
+ * or http://www.netbeans.org/cddl.txt.
+ *
+ * When distributing Covered Code, include this CDDL Header Notice in each file
+ * and include the License file at http://www.netbeans.org/cddl.txt.
+ * If applicable, add the following below the CDDL Header, with the fields
+ * enclosed by brackets [] replaced by your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * 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.
+ */
+
+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 Run customizer panel that will
+ * be used for additional customization of set of properties affected by given
+ * run configuration. Implementation of the interface will be registered via
+ * META-INF/services/.
+ *
+ * @author Milan Kubec
+ */
+public interface ConfigComponentProvider {
+
+ /**
+ * Provides component that is added to Run Customizer panel of j2seproject
+ *
+ * @param proj project to create the customizer component for
+ * @param listener listener to be notified when properties should be updated
+ */
+ JComponent createComponent(Project proj, ConfigChangedListener listener);
+
+ /**
+ * Method is called when the config is changed (or created),
+ * component is updated according to properties of the config
+ *
+ * @param props properties of the new config
+ */
+ void configUpdated(Map props);
+
+ /**
+ * Callback listener for setting properties that are changed by interaction
+ * with the component
+ */
+ interface ConfigChangedListener {
+ /**
+ * Method is called when properties should be updated, null prop value
+ * means property will be removed from the property file
+ *
+ * @param updates map holding updated properties
+ */
+ void propertiesChanged(Map updates);
+ }
+
+}