# HG changeset patch
# User akorostelev@netbeans.org
# Date 1219911988 -14400
# Node ID 722fd79ea6d8f4acb37a5c9c2c93afef6dea549a
# Parent b40223f61a69e5442954c2a8e504c84568543fe7
patch for issue #142283 - expose Module type and suite selection panel
diff -r b40223f61a69 -r 722fd79ea6d8 apisupport.project/nbproject/project.xml
--- a/apisupport.project/nbproject/project.xml Wed Aug 27 18:40:21 2008 +0400
+++ b/apisupport.project/nbproject/project.xml Thu Aug 28 12:26:28 2008 +0400
@@ -447,7 +447,9 @@
org.codehaus.mevenide.netbeans.apisupport
org.netbeans.modules.maven.apisupport
+ org.netbeans.modules.vmd.componentssupport
org.netbeans.modules.apisupport.project.spi
+ org.netbeans.modules.apisupport.project.ui.wizard.spi
diff -r b40223f61a69 -r 722fd79ea6d8 apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/BasicInfoVisualPanel.form
--- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/BasicInfoVisualPanel.form Wed Aug 27 18:40:21 2008 +0400
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/BasicInfoVisualPanel.form Thu Aug 28 12:26:28 2008 +0400
@@ -1,12 +1,21 @@
-
diff -r b40223f61a69 -r 722fd79ea6d8 apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/BasicInfoVisualPanel.java
--- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/BasicInfoVisualPanel.java Wed Aug 27 18:40:21 2008 +0400
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/BasicInfoVisualPanel.java Thu Aug 28 12:26:28 2008 +0400
@@ -43,17 +43,14 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import java.io.File;
-import java.io.IOException;
import java.text.MessageFormat;
-import javax.swing.ButtonModel;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
-import org.netbeans.api.project.Project;
-import org.netbeans.api.project.ProjectManager;
-import org.netbeans.api.project.ProjectUtils;
import org.netbeans.modules.apisupport.project.ui.ModuleUISettings;
import org.netbeans.modules.apisupport.project.universe.ModuleList;
import org.netbeans.modules.apisupport.project.universe.NbPlatform;
@@ -61,10 +58,9 @@
import org.netbeans.modules.apisupport.project.ui.customizer.SuiteUtils;
import org.netbeans.modules.apisupport.project.ui.platform.PlatformComponentFactory;
import org.netbeans.modules.apisupport.project.ui.platform.NbPlatformCustomizer;
+import org.netbeans.modules.apisupport.project.ui.wizard.spi.ModuleTypePanelCreator.ModuleTypePanel;
import org.netbeans.spi.project.ui.support.ProjectChooser;
-import org.openide.DialogDescriptor;
-import org.openide.DialogDisplayer;
-import org.openide.ErrorManager;
+import org.openide.WizardDescriptor;
import org.openide.filesystems.FileUtil;
import org.openide.util.NbBundle;
@@ -83,40 +79,31 @@
*
* @author Martin Krauskopf
*/
-public class BasicInfoVisualPanel extends BasicVisualPanel.NewTemplatePanel {
+public class BasicInfoVisualPanel extends BasicVisualPanel.NewTemplatePanel
+ implements PropertyChangeListener
+{
- private ButtonModel lastSelectedType;
private static String lastSelectedSuite;
private boolean locationUpdated;
private boolean nameUpdated;
- private boolean moduleTypeGroupAttached = true;
private boolean mainProjectTouched;
/** Creates new form BasicInfoVisualPanel */
BasicInfoVisualPanel(final NewModuleProjectData data) {
super(data);
initComponents();
- initAccessibility();
- initPlatformCombos();
+ initPlatformCombo(suitePlatformValue);
+ initPanels();
setComponentsVisibility();
switch (data.getWizardType()) {
case SUITE:
case APPLICATION:
- detachModuleTypeGroup();
+ case LIBRARY_MODULE:
break;
case MODULE:
case SUITE_COMPONENT:
- if (moduleSuiteValue.getItemCount() > 0) {
- restoreSelectedSuite();
- suiteComponent.setSelected(true);
+ if (TypeChooserPanelImpl.getDefaultSuitesComboBox().getItemCount() > 0) {
mainProject.setSelected(false);
- }
- break;
- case LIBRARY_MODULE:
- moduleSuite.setText(getMessage("LBL_Add_to_Suite")); // NOI18N
- suiteComponent.setSelected(true);
- if (moduleSuiteValue.getItemCount() > 0) {
- restoreSelectedSuite();
}
break;
default:
@@ -125,12 +112,84 @@
attachDocumentListeners();
setInitialLocation();
setInitialProjectName();
- updateEnabled();
+ }
+
+ protected static boolean isNetBeansOrgFolder(File folder) {
+ return ModuleList.findNetBeansOrg(folder) != null;
+ }
+
+ protected static void initPlatformCombo(JComboBox combo) {
+ if (combo == null){
+ return;
+ }
+ if (combo.getItemCount() <= 0) {
+ return;
+ }
+ boolean set = false;
+ String idToSelect = ModuleUISettings.getDefault().getLastUsedPlatformID();
+ for (int i = 0; i < combo.getItemCount(); i++) {
+ if (((NbPlatform) combo.getItemAt(i)).getID().equals(idToSelect)) {
+ combo.setSelectedIndex(i);
+ set = true;
+ break;
+ }
+ }
+ if (!set) {
+ NbPlatform defPlaf = NbPlatform.getDefaultPlatform();
+ combo.setSelectedItem(defPlaf == null ? combo.getItemAt(0) : defPlaf);
+ }
+ }
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ String name = evt.getPropertyName();
+ Object value = evt.getNewValue();
+
+ if (ModuleTypePanel.IS_STANDALONE_OR_SUITE_COMPONENT.equals(name)){
+ moduletypeChanged(value);
+ } else if (ModuleTypePanel.SUITE_ROOT.equals(name)){
+ moduleSuiteValueChanged(value);
+ } else if (ModuleTypePanel.ACTIVE_PLATFORM.equals(name)){
+ updateAndCheck();
+ }
+ }
+
+ private void moduleSuiteValueChanged(Object val) {
+ String suite = null;
+ if (val != null && val instanceof String){
+ suite = (String)val;
+ }
+ if (!locationUpdated) {
+ computeAndSetLocation(suite, true);
+ }
+ updateAndCheck();
+ }
+
+ private void moduletypeChanged(Object val) {
+ Boolean isStandAlone = null;
+ if (val != null && val instanceof Boolean){
+ isStandAlone = ((Boolean)val).booleanValue();
+ // todo TEST
+ }
+ // null means both radio uttons are deselected and disaled
+ if (isStandAlone == null){
+ return;
+ }
+
+ if (!mainProjectTouched) {
+ mainProject.setSelected(isStandAlone);
+ }
+ if (!locationUpdated) {
+ setInitialLocation();
+ }
+ if (!nameUpdated) {
+ setInitialProjectName();
+ }
+ updateAndCheck();
}
private void setInitialLocation() {
- if (isSuiteComponent()) {
- computeAndSetLocation((String) moduleSuiteValue.getSelectedItem(), true);
+ if (typeChooserPanel.isSuiteComponent()) {
+ computeAndSetLocation(typeChooserPanel.getSelectedSuite(), true);
} else { // suite or standalone module
String location = computeLocationValue(ProjectChooser.getProjectsFolder().getAbsolutePath());
File locationF = new File(location);
@@ -142,23 +201,16 @@
}
}
- private void initAccessibility() {
- this.getAccessibleContext().setAccessibleDescription(getMessage("ACS_BasicInfoVisualPanel"));
- browseButton.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_BrowseButton"));
- browseSuiteButton.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_BrowseSuiteButton"));
- folderValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_FolderValue"));
- locationValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_LocationValue"));
- mainProject.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_MainProject"));
- managePlatform.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ManagePlatform"));
- manageSuitePlatform.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ManageSuitePlatform"));
- moduleSuiteValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_ModuleSuiteValue"));
- nameValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_NameValue"));
- platformValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_PlatformValue"));
- standAloneModule.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_StandAloneModule"));
- suiteComponent.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_SuiteModule"));
- suitePlatformValue.getAccessibleContext().setAccessibleDescription(getMessage("ACS_CTL_SuitePlatformValue"));
+ private void initPanels(){
+ if (typeChooserPanel != null){
+ typeChooserPanelContainer.removeAll();
+ typeChooserPanel = null;
+ }
+ typeChooserPanel = new TypeChooserPanelImpl();
+ typeChooserPanelContainer.add(typeChooserPanel);
+ typeChooserPanelContainer.validate();
}
-
+
private void setComponentsVisibility() {
boolean isSuiteWizard = isSuiteWizard();
boolean isSuiteComponentWizard = isSuiteComponentWizard();
@@ -170,44 +222,11 @@
manageSuitePlatform.setVisible(isSuiteWizard);
mainProject.setVisible(!isLibraryWizard);
- suiteComponent.setVisible(!isLibraryWizard);
- platform.setVisible(!isLibraryWizard);
- platformValue.setVisible(!isLibraryWizard);
- managePlatform.setVisible(!isLibraryWizard);
- standAloneModule.setVisible(!isLibraryWizard);
mainProject.setSelected(!isLibraryWizard);
- standAloneModule.setVisible(!isSuiteComponentWizard && !isLibraryWizard);
- platform.setVisible(!isSuiteComponentWizard && !isLibraryWizard);
- platformValue.setVisible(!isSuiteComponentWizard && !isLibraryWizard);
- managePlatform.setVisible(!isSuiteComponentWizard && !isLibraryWizard);
- suiteComponent.setVisible(!isSuiteComponentWizard && !isLibraryWizard);
- }
-
- private void restoreSelectedSuite() {
- String preferredSuiteDir = getPreferredSuiteDir();
- if (preferredSuiteDir != null) {
- lastSelectedSuite = preferredSuiteDir;
+ if (typeChooserPanel != null){
+ typeChooserPanel.setComponentsVisibility(isSuiteComponentWizard, isLibraryWizard);
}
- if (lastSelectedSuite != null) {
- int max = moduleSuiteValue.getModel().getSize();
- for (int i=0; i < max; i++) {
- if (lastSelectedSuite.equals(moduleSuiteValue.getModel().getElementAt(i))) {
- moduleSuiteValue.setSelectedItem(lastSelectedSuite);
- break;
- }
- }
- }
- }
-
- private String getPreferredSuiteDir() {
- return (String) getSettings().getProperty(NewNbModuleWizardIterator.PREFERRED_SUITE_DIR);
- }
-
- private boolean isOneSuiteDedicatedMode() {
- Boolean b = (Boolean) getSettings().getProperty(
- NewNbModuleWizardIterator.ONE_SUITE_DEDICATED_MODE);
- return b != null ? b.booleanValue() : false;
}
private String getNameValue() {
@@ -222,44 +241,34 @@
return new File(getLocationValue());
}
- private void updateEnabled() {
- boolean isNetBeansOrg = isNetBeansOrgFolder();
- standAloneModule.setEnabled(!isNetBeansOrg);
- suiteComponent.setEnabled(!isNetBeansOrg);
-
- boolean standalone = isStandAlone();
- boolean suiteModuleSelected = isSuiteComponent();
- platform.setEnabled(standalone);
- platformValue.setEnabled(standalone);
- managePlatform.setEnabled(standalone);
- moduleSuite.setEnabled(suiteModuleSelected);
- moduleSuiteValue.setEnabled(suiteModuleSelected && !isOneSuiteDedicatedMode());
- browseSuiteButton.setEnabled(suiteModuleSelected && !isOneSuiteDedicatedMode());
- }
-
void updateAndCheck() {
updateGUI();
if ("".equals(getNameValue())) {
- setError(getMessage("MSG_NameCannotBeEmpty"));
+ setError(NbBundle.getMessage(
+ BasicInfoVisualPanel.class, "MSG_NameCannotBeEmpty"));//NOI18N
} else if ("".equals(getLocationValue())) {
- setError(getMessage("MSG_LocationCannotBeEmpty"));
+ setError(NbBundle.getMessage(
+ BasicInfoVisualPanel.class, "MSG_LocationCannotBeEmpty"));//NOI18N
} else if (isLibraryWizard() && isNetBeansOrgFolder()) {
- setError(getMessage("MSG_LibraryWrapperForNBOrgUnsupported"));
- } else if (isSuiteComponent() && moduleSuiteValue.getSelectedItem() == null) {
- setError(getMessage("MSG_ChooseRegularSuite"));
- } else if (isStandAlone() &&
- (platformValue.getSelectedItem() == null || !((NbPlatform) platformValue.getSelectedItem()).isValid())) {
- setError(getMessage("MSG_ChosenPlatformIsInvalid"));
+ setError(NbBundle.getMessage(
+ BasicInfoVisualPanel.class, "MSG_LibraryWrapperForNBOrgUnsupported"));//NOI18N
+ } else if (!typeChooserPanel.validate(getSettings())) {
+ setError((String)getSettings().getProperty(WizardDescriptor.PROP_ERROR_MESSAGE));
} else if (isSuiteWizard() &&
- (suitePlatformValue.getSelectedItem() == null || !((NbPlatform) suitePlatformValue.getSelectedItem()).isValid())) {
- setError(getMessage("MSG_ChosenPlatformIsInvalid"));
+ (suitePlatformValue.getSelectedItem() == null || !((NbPlatform) suitePlatformValue.getSelectedItem()).isValid()))
+ {
+ setError(NbBundle.getMessage(
+ BasicInfoVisualPanel.class, "MSG_ChosenPlatformIsInvalid"));//NOI18N
} else if (getFolder().exists()) {
- setError(getMessage("MSG_ProjectFolderExists"));
+ setError(NbBundle.getMessage(
+ BasicInfoVisualPanel.class, "MSG_ProjectFolderExists"));//NOI18N
} else if (!getLocationFile().exists()) {
- setError(getMessage("MSG_LocationMustExist"));
+ setError(NbBundle.getMessage(
+ BasicInfoVisualPanel.class, "MSG_LocationMustExist"));//NOI18N
} else if (!getLocationFile().canWrite()) {
- setError(getMessage("MSG_LocationNotWritable"));
+ setError(NbBundle.getMessage(
+ BasicInfoVisualPanel.class, "MSG_LocationNotWritable"));//NOI18N
} else {
markValid();
}
@@ -268,37 +277,9 @@
private void updateGUI() {
// update project folder
folderValue.setText(getFolder().getPath());
-
- if (isSuiteWizard() || isNetBeansOrgFolder()) {
- detachModuleTypeGroup();
- } else {
- attachModuleTypeGroup();
- }
- updateEnabled();
- }
-
- private void detachModuleTypeGroup() {
- if (moduleTypeGroupAttached) {
- lastSelectedType = moduleTypeGroup.getSelection();
- moduleTypeGroup.remove(standAloneModule);
- moduleTypeGroup.remove(suiteComponent);
- standAloneModule.setSelected(false);
- suiteComponent.setSelected(false);
- moduleTypeGroupAttached = false;
- }
- }
-
- private void attachModuleTypeGroup() {
- if (!moduleTypeGroupAttached) {
- moduleTypeGroup.add(standAloneModule);
- moduleTypeGroup.add(suiteComponent);
- if (isLibraryWizard()) {
- suiteComponent.setSelected(true);
- } else {
- moduleTypeGroup.setSelected(lastSelectedType, true);
- }
- moduleTypeGroupAttached = true;
- }
+
+ getSettings().putProperty(ModuleTypePanel.PROJECT_FOLDER, getFolder());
+ typeChooserPanel.setProjectFolder(getSettings());
}
/** Set next free project name. */
@@ -324,12 +305,12 @@
getData().setProjectFolder(folderValue.getText());
getData().setMainProject(mainProject.isSelected());
getData().setNetBeansOrg(isNetBeansOrgFolder());
- getData().setStandalone(isStandAlone());
- getData().setSuiteRoot((String) moduleSuiteValue.getSelectedItem());
+ getData().setStandalone(typeChooserPanel.isStandAlone());
+ getData().setSuiteRoot(typeChooserPanel.getSelectedSuite());
if (isSuiteWizard() && suitePlatformValue.getSelectedItem() != null) {
getData().setPlatformID(((NbPlatform) suitePlatformValue.getSelectedItem()).getID());
- } else if (platformValue.getSelectedItem() != null) {
- getData().setPlatformID(((NbPlatform) platformValue.getSelectedItem()).getID());
+ } else if (typeChooserPanel.getSelectedPlatform() != null) {
+ getData().setPlatformID(typeChooserPanel.getSelectedPlatform());
}
}
@@ -365,7 +346,7 @@
default:
assert false : "Unknown wizard type = " + getData().getWizardType();
}
- setProjectName(getMessage(bundlekey), counter);
+ setProjectName(NbBundle.getMessage(BasicInfoVisualPanel.class, bundlekey), counter);
nameValue.select(0, nameValue.getText().length());
nameUpdated = false;
}
@@ -387,8 +368,8 @@
updateAndCheck();
}
};
- platformValue.addActionListener(plafAL);
suitePlatformValue.addActionListener(plafAL);
+ getSettings().addPropertyChangeListener(this);
}
private File getFolder() {
@@ -401,32 +382,7 @@
}
private boolean isNetBeansOrgFolder() {
- return ModuleList.findNetBeansOrg(getFolder()) != null;
- }
-
- private static String getMessage(String key) {
- return NbBundle.getMessage(BasicInfoVisualPanel.class, key);
- }
-
- private void initPlatformCombos() {
- if (platformValue.getItemCount() <= 0) {
- return;
- }
- boolean set = false;
- String idToSelect = ModuleUISettings.getDefault().getLastUsedPlatformID();
- for (int i = 0; i < platformValue.getItemCount(); i++) {
- if (((NbPlatform) platformValue.getItemAt(i)).getID().equals(idToSelect)) {
- platformValue.setSelectedIndex(i);
- suitePlatformValue.setSelectedIndex(i);
- set = true;
- break;
- }
- }
- if (!set) {
- NbPlatform defPlaf = NbPlatform.getDefaultPlatform();
- platformValue.setSelectedItem(defPlaf == null ? platformValue.getItemAt(0) : defPlaf);
- suitePlatformValue.setSelectedItem(defPlaf == null ? suitePlatformValue.getItemAt(0) : defPlaf);
- }
+ return isNetBeansOrgFolder(getFolder());
}
private void setLocation(String location, boolean silently) {
@@ -451,20 +407,12 @@
}
}
- private boolean isStandAlone() {
- return standAloneModule.isSelected();
- }
-
- private boolean isSuiteComponent() {
- return suiteComponent.isSelected();
- }
-
/** 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.
*/
- // //GEN-BEGIN:initComponents
+ // //GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
@@ -483,24 +431,15 @@
manageSuitePlatform = new javax.swing.JButton();
separator3 = new javax.swing.JSeparator();
mainProject = new javax.swing.JCheckBox();
- typeChooserPanel = new javax.swing.JPanel();
- standAloneModule = new javax.swing.JRadioButton();
- platform = new javax.swing.JLabel();
- platformValue = PlatformComponentFactory.getNbPlatformsComboxBox();
- managePlatform = new javax.swing.JButton();
- suiteComponent = new javax.swing.JRadioButton();
- moduleSuite = new javax.swing.JLabel();
- moduleSuiteValue = PlatformComponentFactory.getSuitesComboBox();
- browseSuiteButton = new javax.swing.JButton();
- chooserFiller = new javax.swing.JLabel();
pnlThouShaltBeholdLayout = new javax.swing.JPanel();
+ typeChooserPanelContainer = new javax.swing.JPanel();
setLayout(new java.awt.GridBagLayout());
infoPanel.setLayout(new java.awt.GridBagLayout());
nameLbl.setLabelFor(nameValue);
- org.openide.awt.Mnemonics.setLocalizedText(nameLbl, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "LBL_ProjectName"));
+ org.openide.awt.Mnemonics.setLocalizedText(nameLbl, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "LBL_ProjectName")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
@@ -509,7 +448,7 @@
infoPanel.add(nameLbl, gridBagConstraints);
locationLbl.setLabelFor(locationValue);
- org.openide.awt.Mnemonics.setLocalizedText(locationLbl, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "LBL_ProjectLocation"));
+ org.openide.awt.Mnemonics.setLocalizedText(locationLbl, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "LBL_ProjectLocation")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
@@ -518,7 +457,7 @@
infoPanel.add(locationLbl, gridBagConstraints);
folderLbl.setLabelFor(folderValue);
- org.openide.awt.Mnemonics.setLocalizedText(folderLbl, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "LBL_ProjectFolder"));
+ org.openide.awt.Mnemonics.setLocalizedText(folderLbl, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "LBL_ProjectFolder")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
@@ -534,6 +473,8 @@
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.weightx = 1.0;
infoPanel.add(nameValue, gridBagConstraints);
+ nameValue.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "ACS_CTL_NameValue")); // NOI18N
+ nameValue.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "ACS_CTL_NameValue")); // NOI18N
locationValue.setHorizontalAlignment(javax.swing.JTextField.LEFT);
gridBagConstraints = new java.awt.GridBagConstraints();
@@ -543,19 +484,22 @@
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(6, 0, 6, 0);
infoPanel.add(locationValue, gridBagConstraints);
+ locationValue.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "ACS_CTL_LocationValue")); // NOI18N
+ locationValue.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "ACS_CTL_LocationValue")); // NOI18N
- org.openide.awt.Mnemonics.setLocalizedText(browseButton, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "CTL_BrowseButton_o"));
+ org.openide.awt.Mnemonics.setLocalizedText(browseButton, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "CTL_BrowseButton_o")); // NOI18N
browseButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
browseLocation(evt);
}
});
-
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 1;
gridBagConstraints.insets = new java.awt.Insets(6, 12, 6, 0);
infoPanel.add(browseButton, gridBagConstraints);
+ browseButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "ACS_CTL_BrowseButton")); // NOI18N
+ browseButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "ACS_CTL_BrowseButton")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
@@ -570,16 +514,17 @@
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
infoPanel.add(folderValue, gridBagConstraints);
+ folderValue.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "ACS_CTL_FolderValue")); // NOI18N
+ folderValue.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "ACS_CTL_FolderValue")); // NOI18N
suitePlatform.setLabelFor(suitePlatformValue);
- org.openide.awt.Mnemonics.setLocalizedText(suitePlatform, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "LBL_NetBeansPlatform"));
+ org.openide.awt.Mnemonics.setLocalizedText(suitePlatform, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "LBL_NetBeansPlatform")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 4;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(6, 0, 6, 12);
infoPanel.add(suitePlatform, gridBagConstraints);
-
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 4;
@@ -588,14 +533,15 @@
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new java.awt.Insets(6, 0, 6, 0);
infoPanel.add(suitePlatformValue, gridBagConstraints);
+ suitePlatformValue.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "ACS_CTL_SuitePlatformValue")); // NOI18N
+ suitePlatformValue.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "ACS_CTL_SuitePlatformValue")); // NOI18N
- org.openide.awt.Mnemonics.setLocalizedText(manageSuitePlatform, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "CTL_ManagePlatforms_g"));
+ org.openide.awt.Mnemonics.setLocalizedText(manageSuitePlatform, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "CTL_ManagePlatforms_g")); // NOI18N
manageSuitePlatform.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
manageSuitePlatformActionPerformed(evt);
}
});
-
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 2;
gridBagConstraints.gridy = 4;
@@ -603,6 +549,8 @@
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(6, 12, 6, 0);
infoPanel.add(manageSuitePlatform, gridBagConstraints);
+ manageSuitePlatform.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "ACS_CTL_ManageSuitePlatform")); // NOI18N
+ manageSuitePlatform.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "ACS_CTL_ManageSuitePlatform")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
@@ -621,143 +569,20 @@
add(infoPanel, gridBagConstraints);
mainProject.setSelected(true);
- org.openide.awt.Mnemonics.setLocalizedText(mainProject, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "CTL_SetAsMainProject"));
+ org.openide.awt.Mnemonics.setLocalizedText(mainProject, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "CTL_SetAsMainProject")); // NOI18N
mainProject.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
mainProjectActionPerformed(evt);
}
});
-
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
add(mainProject, gridBagConstraints);
-
- typeChooserPanel.setLayout(new java.awt.GridBagLayout());
-
- moduleTypeGroup.add(standAloneModule);
- standAloneModule.setSelected(true);
- org.openide.awt.Mnemonics.setLocalizedText(standAloneModule, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "CTL_StandaloneModule"));
- standAloneModule.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- typeChanged(evt);
- }
- });
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 0;
- gridBagConstraints.gridwidth = 3;
- gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
- gridBagConstraints.insets = new java.awt.Insets(0, 0, 6, 0);
- typeChooserPanel.add(standAloneModule, gridBagConstraints);
-
- platform.setLabelFor(platformValue);
- org.openide.awt.Mnemonics.setLocalizedText(platform, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "LBL_NetBeansPlatform"));
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 1;
- gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
- gridBagConstraints.insets = new java.awt.Insets(0, 18, 0, 12);
- typeChooserPanel.add(platform, gridBagConstraints);
-
- platformValue.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- platformChosen(evt);
- }
- });
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 1;
- gridBagConstraints.gridy = 1;
- gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
- gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
- gridBagConstraints.weightx = 1.0;
- gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12);
- typeChooserPanel.add(platformValue, gridBagConstraints);
-
- org.openide.awt.Mnemonics.setLocalizedText(managePlatform, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "CTL_ManagePlatforms_g"));
- managePlatform.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- managePlatformActionPerformed(evt);
- }
- });
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 2;
- gridBagConstraints.gridy = 1;
- gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
- gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
- typeChooserPanel.add(managePlatform, gridBagConstraints);
-
- moduleTypeGroup.add(suiteComponent);
- org.openide.awt.Mnemonics.setLocalizedText(suiteComponent, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "CTL_AddToModuleSuite"));
- suiteComponent.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- typeChanged(evt);
- }
- });
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 2;
- gridBagConstraints.gridwidth = 3;
- gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
- gridBagConstraints.insets = new java.awt.Insets(18, 0, 0, 0);
- typeChooserPanel.add(suiteComponent, gridBagConstraints);
-
- moduleSuite.setLabelFor(moduleSuiteValue);
- org.openide.awt.Mnemonics.setLocalizedText(moduleSuite, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "LBL_ModuleSuite"));
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 3;
- gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
- gridBagConstraints.insets = new java.awt.Insets(6, 18, 0, 12);
- typeChooserPanel.add(moduleSuite, gridBagConstraints);
-
- moduleSuiteValue.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- moduleSuiteChosen(evt);
- }
- });
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 1;
- gridBagConstraints.gridy = 3;
- gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
- gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
- gridBagConstraints.weightx = 1.0;
- gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 12);
- typeChooserPanel.add(moduleSuiteValue, gridBagConstraints);
-
- org.openide.awt.Mnemonics.setLocalizedText(browseSuiteButton, org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "CTL_BrowseButton_w"));
- browseSuiteButton.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- browseModuleSuite(evt);
- }
- });
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 2;
- gridBagConstraints.gridy = 3;
- gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
- gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
- gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
- typeChooserPanel.add(browseSuiteButton, gridBagConstraints);
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 4;
- gridBagConstraints.weighty = 1.0;
- typeChooserPanel.add(chooserFiller, gridBagConstraints);
-
- gridBagConstraints = new java.awt.GridBagConstraints();
- gridBagConstraints.gridx = 0;
- gridBagConstraints.gridy = 1;
- gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
- add(typeChooserPanel, gridBagConstraints);
+ mainProject.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "ACS_CTL_MainProject")); // NOI18N
+ mainProject.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "ACS_CTL_MainProject")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
@@ -768,6 +593,15 @@
gridBagConstraints.weighty = 1.0;
add(pnlThouShaltBeholdLayout, gridBagConstraints);
+ typeChooserPanelContainer.setLayout(new java.awt.BorderLayout());
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
+ add(typeChooserPanelContainer, gridBagConstraints);
+
+ getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "ACS_BasicInfoVisualPanel")); // NOI18N
+ getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BasicInfoVisualPanel.class, "ACS_BasicInfoVisualPanel")); // NOI18N
}// //GEN-END:initComponents
private void manageSuitePlatformActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_manageSuitePlatformActionPerformed
@@ -777,73 +611,14 @@
private void mainProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mainProjectActionPerformed
mainProjectTouched = true;
}//GEN-LAST:event_mainProjectActionPerformed
-
- private void managePlatformActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_managePlatformActionPerformed
- managePlatform(platformValue);
- }//GEN-LAST:event_managePlatformActionPerformed
-
+
private void managePlatform(final JComboBox platformCombo) {
NbPlatformCustomizer.showCustomizer();
platformCombo.setModel(new PlatformComponentFactory.NbPlatformListModel()); // refresh
platformCombo.requestFocus();
updateAndCheck();
}
-
- private void platformChosen(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_platformChosen
- updateAndCheck();
- }//GEN-LAST:event_platformChosen
-
- private void moduleSuiteChosen(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moduleSuiteChosen
- if (!locationUpdated) {
- String suite = (String) moduleSuiteValue.getSelectedItem();
- computeAndSetLocation(suite, true);
- lastSelectedSuite = suite;
- }
- updateAndCheck();
- }//GEN-LAST:event_moduleSuiteChosen
-
- private void browseModuleSuite(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseModuleSuite
- JFileChooser chooser = ProjectChooser.projectChooser();
- int option = chooser.showOpenDialog(this);
- if (option == JFileChooser.APPROVE_OPTION) {
- File projectDir = chooser.getSelectedFile();
- UIUtil.setProjectChooserDirParent(projectDir);
- try {
- Project suite = ProjectManager.getDefault().findProject(
- FileUtil.toFileObject(projectDir));
- if (suite != null) {
- String suiteDir = SuiteUtils.getSuiteDirectoryPath(suite);
- if (suiteDir != null) {
- // register for this session
- PlatformComponentFactory.addUserSuite(suiteDir);
- // add to current combobox
- moduleSuiteValue.addItem(suiteDir);
- moduleSuiteValue.setSelectedItem(suiteDir);
- } else {
- DialogDisplayer.getDefault().notify(new DialogDescriptor.Message(
- NbBundle.getMessage(BasicInfoVisualPanel.class, "MSG_NotRegularSuite",
- ProjectUtils.getInformation(suite).getDisplayName())));
- }
- }
- } catch (IOException e) {
- ErrorManager.getDefault().notify(ErrorManager.WARNING, e);
- }
- }
- }//GEN-LAST:event_browseModuleSuite
-
- private void typeChanged(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_typeChanged
- if (!mainProjectTouched) {
- mainProject.setSelected(isStandAlone());
- }
- if (!locationUpdated) {
- setInitialLocation();
- }
- if (!nameUpdated) {
- setInitialProjectName();
- }
- updateAndCheck();
- }//GEN-LAST:event_typeChanged
-
+
private void browseLocation(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseLocation
JFileChooser chooser = new JFileChooser(getLocationValue());
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
@@ -855,8 +630,6 @@
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton browseButton;
- private javax.swing.JButton browseSuiteButton;
- private javax.swing.JLabel chooserFiller;
private javax.swing.JLabel filler;
private javax.swing.JLabel folderLbl;
private javax.swing.JTextField folderValue;
@@ -864,22 +637,16 @@
private javax.swing.JLabel locationLbl;
private javax.swing.JTextField locationValue;
private javax.swing.JCheckBox mainProject;
- private javax.swing.JButton managePlatform;
private javax.swing.JButton manageSuitePlatform;
- private javax.swing.JLabel moduleSuite;
- private javax.swing.JComboBox moduleSuiteValue;
private javax.swing.ButtonGroup moduleTypeGroup;
private javax.swing.JLabel nameLbl;
javax.swing.JTextField nameValue;
- private javax.swing.JLabel platform;
- private javax.swing.JComboBox platformValue;
private javax.swing.JPanel pnlThouShaltBeholdLayout;
private javax.swing.JSeparator separator3;
- private javax.swing.JRadioButton standAloneModule;
- private javax.swing.JRadioButton suiteComponent;
private javax.swing.JLabel suitePlatform;
private javax.swing.JComboBox suitePlatformValue;
- private javax.swing.JPanel typeChooserPanel;
+ private javax.swing.JPanel typeChooserPanelContainer;
// End of variables declaration//GEN-END:variables
+ private TypeChooserPanelImpl typeChooserPanel;
}
diff -r b40223f61a69 -r 722fd79ea6d8 apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/BasicVisualPanel.java
--- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/BasicVisualPanel.java Wed Aug 27 18:40:21 2008 +0400
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/BasicVisualPanel.java Thu Aug 28 12:26:28 2008 +0400
@@ -166,15 +166,15 @@
}
protected boolean isSuiteWizard() {
- return getData().getWizardType() == NewNbModuleWizardIterator.Type.SUITE || getData().getWizardType() == NewNbModuleWizardIterator.Type.APPLICATION;
+ return NewNbModuleWizardIterator.isSuiteWizard(getData().getWizardType());
}
protected boolean isSuiteComponentWizard() {
- return getData().getWizardType() == NewNbModuleWizardIterator.Type.SUITE_COMPONENT;
+ return NewNbModuleWizardIterator.isSuiteComponentWizard(getData().getWizardType());
}
protected boolean isLibraryWizard() {
- return getData().getWizardType() == NewNbModuleWizardIterator.Type.LIBRARY_MODULE;
+ return NewNbModuleWizardIterator.isLibraryWizard(getData().getWizardType());
}
}
diff -r b40223f61a69 -r 722fd79ea6d8 apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/Bundle.properties
--- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/Bundle.properties Wed Aug 27 18:40:21 2008 +0400
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/Bundle.properties Thu Aug 28 12:26:28 2008 +0400
@@ -80,7 +80,7 @@
TXT_Library=library{0}
TXT_Module=module{0}
TXT_Suite=suite{0}
-ACS_BasicInfoVisualPanel=
+ACS_BasicInfoVisualPanel=Basic Information panel
ACS_CTL_BrowseButton=Browse
ACS_CTL_BrowseSuiteButton=Browse Suite
ACS_CTL_FolderValue=Project Folder
diff -r b40223f61a69 -r 722fd79ea6d8 apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/NewNbModuleWizardIterator.java
--- a/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/NewNbModuleWizardIterator.java Wed Aug 27 18:40:21 2008 +0400
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/NewNbModuleWizardIterator.java Thu Aug 28 12:26:28 2008 +0400
@@ -152,7 +152,19 @@
public static NewNbModuleWizardIterator createLibraryModuleIterator() {
return new NewNbModuleWizardIterator(Type.LIBRARY_MODULE);
}
-
+
+ static boolean isSuiteWizard(Type type) {
+ return type == Type.SUITE || type == Type.APPLICATION;
+ }
+
+ static boolean isSuiteComponentWizard(Type type) {
+ return type == Type.SUITE_COMPONENT;
+ }
+
+ static boolean isLibraryWizard(Type type) {
+ return type == Type.LIBRARY_MODULE;
+ }
+
public FileObject getCreateProjectFolder() {
return createdProjectFolder;
}
diff -r b40223f61a69 -r 722fd79ea6d8 apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/TypeChooserPanelExternalImpl.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/TypeChooserPanelExternalImpl.java Thu Aug 28 12:26:28 2008 +0400
@@ -0,0 +1,78 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008 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 2008 Sun Microsystems, Inc.
+ */
+
+package org.netbeans.modules.apisupport.project.ui.wizard;
+
+import java.awt.Component;
+import org.netbeans.modules.apisupport.project.ui.wizard.spi.ModuleTypePanelCreator.ModuleTypePanel;
+import org.openide.WizardDescriptor;
+
+/**
+ * ModuleTypePanelCreator.ModuleTypePanel implementation to e used y froend projects.
+ * The only difference from internal implementation
+ * is that attachModuleTypeGroup is invoked in constructor.
+ *
+ * TODO check if this can't e done in internal implementation
+ * @author akorostelev
+ */
+public class TypeChooserPanelExternalImpl extends TypeChooserPanelImpl
+ implements ModuleTypePanel
+{
+
+ public TypeChooserPanelExternalImpl() {
+ super();
+ attachModuleTypeGroup();
+ }
+
+ public Component getComponent() {
+ return this;
+ }
+
+ @Override
+ protected void storeSettings(WizardDescriptor settings) {
+ if (getSettings() == null){
+ settings.putProperty(IS_NETBEANS_ORG, isNetBeansOrgFolder());
+ settings.putProperty(IS_STANDALONE_OR_SUITE_COMPONENT, isStandAlone());
+ settings.putProperty(SUITE_ROOT, getSelectedSuite());
+ settings.putProperty(ACTIVE_PLATFORM, getSelectedPlatform());
+ }
+ super.storeSettings(settings);
+ }
+
+}
diff -r b40223f61a69 -r 722fd79ea6d8 apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/TypeChooserPanelImpl.form
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/TypeChooserPanelImpl.form Thu Aug 28 12:26:28 2008 +0400
@@ -0,0 +1,230 @@
+
+
+
diff -r b40223f61a69 -r 722fd79ea6d8 apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/TypeChooserPanelImpl.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/TypeChooserPanelImpl.java Thu Aug 28 12:26:28 2008 +0400
@@ -0,0 +1,555 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008 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 2008 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.apisupport.project.ui.wizard;
+
+import java.awt.Component;
+import java.io.File;
+import java.io.IOException;
+import javax.swing.ButtonModel;
+import javax.swing.JComboBox;
+import javax.swing.JFileChooser;
+import org.netbeans.api.project.Project;
+import org.netbeans.api.project.ProjectManager;
+import org.netbeans.api.project.ProjectUtils;
+import org.netbeans.modules.apisupport.project.ui.UIUtil;
+import org.netbeans.modules.apisupport.project.ui.customizer.SuiteUtils;
+import org.netbeans.modules.apisupport.project.ui.platform.PlatformComponentFactory;
+import org.netbeans.modules.apisupport.project.ui.wizard.NewNbModuleWizardIterator.Type;
+import org.netbeans.modules.apisupport.project.universe.NbPlatform;
+import org.netbeans.modules.apisupport.project.ui.platform.NbPlatformCustomizer;
+import org.netbeans.modules.apisupport.project.ui.wizard.spi.ModuleTypePanelCreator.ModuleTypePanel;
+import org.netbeans.spi.project.ui.support.ProjectChooser;
+import org.openide.DialogDescriptor;
+import org.openide.DialogDisplayer;
+import org.openide.ErrorManager;
+import org.openide.WizardDescriptor;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author akorostelev
+ */
+class TypeChooserPanelImpl extends javax.swing.JPanel
+ implements ModuleTypePanel
+{
+
+ private ButtonModel lastSelectedType;
+ private static String lastSelectedSuite;
+ private boolean moduleTypeGroupAttached = false;
+ private WizardDescriptor settings;
+ private Type wizardType;
+
+ public TypeChooserPanelImpl() {
+ initComponents();
+ init();
+ }
+
+ public Component getComponent() {
+ return TypeChooserPanelImpl.this;
+ }
+
+ /** Creates new form TypeChooserPanel */
+ protected TypeChooserPanelImpl(final WizardDescriptor settings, Type wizardType) {
+ this();
+ storeSettings(settings);
+ this.wizardType = wizardType;
+ switch (wizardType) {
+ case SUITE:
+ case APPLICATION:
+ detachModuleTypeGroup();
+ break;
+ case LIBRARY_MODULE:
+ moduleSuite.setText(NbBundle.getMessage(
+ TypeChooserPanelImpl.class, "LBL_Add_to_Suite")); // NOI18N
+ suiteComponent.setSelected(true);
+ if (moduleSuiteValue.getItemCount() > 0) {
+ restoreSelectedSuite();
+ }
+ break;
+ case MODULE:
+ case SUITE_COMPONENT:
+ default:
+ if (moduleSuiteValue.getItemCount() > 0) {
+ restoreSelectedSuite();
+ suiteComponent.setSelected(true);
+ }
+ }
+ }
+
+ protected static JComboBox getDefaultSuitesComboBox(){
+ return PlatformComponentFactory.getSuitesComboBox();
+ }
+
+ public boolean validate(WizardDescriptor settings) {
+ storeSettings(settings);
+ if (isSuiteComponent() && moduleSuiteValue.getSelectedItem() == null) {
+ setMessage(NbBundle.getMessage(
+ TypeChooserPanelImpl.class, "MSG_ChooseRegularSuite"));// NOI18N
+ return false;
+ } else if (isStandAlone() &&
+ (platformValue.getSelectedItem() == null || !((NbPlatform) platformValue.getSelectedItem()).isValid())) {
+ setMessage(NbBundle.getMessage(
+ TypeChooserPanelImpl.class, "MSG_ChosenPlatformIsInvalid"));// NOI18N
+ return false;
+ }
+ return true;
+ }
+
+ public void setProjectFolder(WizardDescriptor settings) {
+ storeSettings(settings);
+ if (isSuiteWizard() || isNetBeansOrgFolder()) {
+ detachModuleTypeGroup();
+ } else {
+ attachModuleTypeGroup();
+ }
+ updateEnabled();
+ updateProperty(IS_NETBEANS_ORG, isNetBeansOrgFolder());
+ }
+
+ protected void storeSettings(WizardDescriptor settings){
+ this.settings = settings;
+ }
+
+ private void updateProperty(String name, Object value){
+ if (settings != null){
+ settings.putProperty(name, value);
+ }
+ }
+
+ protected boolean isStandAlone() {
+ return standAloneModule.isSelected();
+ }
+
+ protected boolean isSuiteComponent() {
+ return suiteComponent.isSelected();
+ }
+
+ protected String getSelectedSuite() {
+ return (String) moduleSuiteValue.getSelectedItem();
+ }
+
+ protected boolean isNetBeansOrgFolder() {
+ File folder = getFolder();
+ if (folder != null){
+ return BasicInfoVisualPanel.isNetBeansOrgFolder(folder);
+ }
+ return false;
+ }
+
+ protected String getSelectedPlatform() {
+ Object selected = platformValue.getSelectedItem();
+ if (selected != null){
+ return ((NbPlatform) platformValue.getSelectedItem()).getID();
+ } else {
+ return null;
+ }
+ }
+
+ protected void setComponentsVisibility(boolean isSuiteComponentWizard,
+ boolean isLibraryWizard)
+ {
+ suiteComponent.setVisible(!isLibraryWizard);
+ platform.setVisible(!isLibraryWizard);
+ platformValue.setVisible(!isLibraryWizard);
+ managePlatform.setVisible(!isLibraryWizard);
+ standAloneModule.setVisible(!isLibraryWizard);
+
+ standAloneModule.setVisible(!isSuiteComponentWizard && !isLibraryWizard);
+ platform.setVisible(!isSuiteComponentWizard && !isLibraryWizard);
+ platformValue.setVisible(!isSuiteComponentWizard && !isLibraryWizard);
+ managePlatform.setVisible(!isSuiteComponentWizard && !isLibraryWizard);
+ suiteComponent.setVisible(!isSuiteComponentWizard && !isLibraryWizard);
+
+ }
+
+ private void updateEnabled(){
+ boolean isNetBeansOrg = isNetBeansOrgFolder();
+ standAloneModule.setEnabled(!isNetBeansOrg);
+ suiteComponent.setEnabled(!isNetBeansOrg);
+
+ boolean standalone = isStandAlone();
+ boolean suiteModuleSelected = isSuiteComponent();
+ platform.setEnabled(standalone);
+ platformValue.setEnabled(standalone);
+ managePlatform.setEnabled(standalone);
+ moduleSuite.setEnabled(suiteModuleSelected);
+ moduleSuiteValue.setEnabled(suiteModuleSelected && !isOneSuiteDedicatedMode());
+ browseSuiteButton.setEnabled(suiteModuleSelected && !isOneSuiteDedicatedMode());
+ }
+
+ private void detachModuleTypeGroup() {
+ if (moduleTypeGroupAttached) {
+ lastSelectedType = moduleTypeGroup.getSelection();
+ moduleTypeGroup.remove(standAloneModule);
+ moduleTypeGroup.remove(suiteComponent);
+ standAloneModule.setSelected(false);
+ suiteComponent.setSelected(false);
+ updateProperty(IS_STANDALONE_OR_SUITE_COMPONENT, null);
+ moduleTypeGroupAttached = false;
+ }
+ }
+
+ /**
+ * Adds radiobuttons to ButtonGroup and sets selection.
+ */
+ protected void attachModuleTypeGroup() {
+ if (!moduleTypeGroupAttached) {
+ moduleTypeGroup.add(standAloneModule);
+ moduleTypeGroup.add(suiteComponent);
+ if (isLibraryWizard()) {
+ suiteComponent.setSelected(true);
+ } else {
+ moduleTypeGroup.setSelected(lastSelectedType, true);
+ }
+ moduleTypeGroupAttached = true;
+ }
+ }
+
+ private void init(){
+ BasicInfoVisualPanel.initPlatformCombo(platformValue);
+ if (moduleSuiteValue.getItemCount() > 0) {
+ restoreSelectedSuite();
+ suiteComponent.setSelected(true);
+ }
+ }
+
+ private void restoreSelectedSuite() {
+ String preferredSuiteDir = getPreferredSuiteDir();
+ if (preferredSuiteDir != null) {
+ lastSelectedSuite = preferredSuiteDir;
+ }
+ if (lastSelectedSuite != null) {
+ int max = moduleSuiteValue.getModel().getSize();
+ for (int i=0; i < max; i++) {
+ if (lastSelectedSuite.equals(moduleSuiteValue.getModel().getElementAt(i))) {
+ moduleSuiteValue.setSelectedItem(lastSelectedSuite);
+ break;
+ }
+ }
+ }
+ }
+
+ private String getPreferredSuiteDir() {
+ if (getSettings() != null){
+ return (String) getSettings().getProperty(NewNbModuleWizardIterator.PREFERRED_SUITE_DIR);
+ }
+ return null;
+ }
+
+ private boolean isOneSuiteDedicatedMode() {
+ Boolean b = false;
+ if (getSettings() != null){
+ b = (Boolean) getSettings().getProperty(
+ NewNbModuleWizardIterator.ONE_SUITE_DEDICATED_MODE);
+ }
+ return b != null ? b.booleanValue() : false;
+ }
+
+ private File getFolder() {
+ if (getSettings() != null){
+ return (File)getSettings().getProperty(PROJECT_FOLDER);
+ }
+ return null;
+ }
+
+ /** 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() {
+ java.awt.GridBagConstraints gridBagConstraints;
+
+ moduleTypeGroup = new javax.swing.ButtonGroup();
+ typeChooserPanel = new javax.swing.JPanel();
+ standAloneModule = new javax.swing.JRadioButton();
+ platform = new javax.swing.JLabel();
+ platformValue = PlatformComponentFactory.getNbPlatformsComboxBox();
+ managePlatform = new javax.swing.JButton();
+ suiteComponent = new javax.swing.JRadioButton();
+ moduleSuite = new javax.swing.JLabel();
+ moduleSuiteValue = getDefaultSuitesComboBox();
+ browseSuiteButton = new javax.swing.JButton();
+ chooserFiller = new javax.swing.JLabel();
+
+ setLayout(new java.awt.BorderLayout());
+
+ typeChooserPanel.setLayout(new java.awt.GridBagLayout());
+
+ moduleTypeGroup.add(standAloneModule);
+ standAloneModule.setSelected(true);
+ org.openide.awt.Mnemonics.setLocalizedText(standAloneModule, org.openide.util.NbBundle.getMessage(TypeChooserPanelImpl.class, "CTL_StandaloneModule")); // NOI18N
+ standAloneModule.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ standAloneModuleTypeChanged(evt);
+ }
+ });
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 0;
+ gridBagConstraints.gridwidth = 3;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints.insets = new java.awt.Insets(0, 0, 6, 0);
+ typeChooserPanel.add(standAloneModule, gridBagConstraints);
+ standAloneModule.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TypeChooserPanelImpl.class, "ACS_CTL_StandAloneModule")); // NOI18N
+ standAloneModule.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TypeChooserPanelImpl.class, "ACS_CTL_StandAloneModule")); // NOI18N
+
+ platform.setLabelFor(platformValue);
+ org.openide.awt.Mnemonics.setLocalizedText(platform, org.openide.util.NbBundle.getMessage(TypeChooserPanelImpl.class, "LBL_NetBeansPlatform")); // NOI18N
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints.insets = new java.awt.Insets(0, 18, 0, 12);
+ typeChooserPanel.add(platform, gridBagConstraints);
+
+ platformValue.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ platformChosen(evt);
+ }
+ });
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12);
+ typeChooserPanel.add(platformValue, gridBagConstraints);
+ platformValue.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TypeChooserPanelImpl.class, "ACS_CTL_PlatformValue")); // NOI18N
+ platformValue.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TypeChooserPanelImpl.class, "ACS_CTL_PlatformValue")); // NOI18N
+
+ org.openide.awt.Mnemonics.setLocalizedText(managePlatform, org.openide.util.NbBundle.getMessage(TypeChooserPanelImpl.class, "CTL_ManagePlatforms_g")); // NOI18N
+ managePlatform.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ managePlatformActionPerformed(evt);
+ }
+ });
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridy = 1;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ typeChooserPanel.add(managePlatform, gridBagConstraints);
+ managePlatform.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TypeChooserPanelImpl.class, "ACS_CTL_ManagePlatform")); // NOI18N
+ managePlatform.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TypeChooserPanelImpl.class, "ACS_CTL_ManagePlatform")); // NOI18N
+
+ moduleTypeGroup.add(suiteComponent);
+ org.openide.awt.Mnemonics.setLocalizedText(suiteComponent, org.openide.util.NbBundle.getMessage(TypeChooserPanelImpl.class, "CTL_AddToModuleSuite")); // NOI18N
+ suiteComponent.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ suiteComponentTypeChanged(evt);
+ }
+ });
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 2;
+ gridBagConstraints.gridwidth = 3;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints.insets = new java.awt.Insets(18, 0, 0, 0);
+ typeChooserPanel.add(suiteComponent, gridBagConstraints);
+ suiteComponent.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TypeChooserPanelImpl.class, "ACS_CTL_SuiteModule")); // NOI18N
+ suiteComponent.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TypeChooserPanelImpl.class, "ACS_CTL_SuiteModule")); // NOI18N
+
+ moduleSuite.setLabelFor(moduleSuiteValue);
+ org.openide.awt.Mnemonics.setLocalizedText(moduleSuite, org.openide.util.NbBundle.getMessage(TypeChooserPanelImpl.class, "LBL_ModuleSuite")); // NOI18N
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 3;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints.insets = new java.awt.Insets(6, 18, 0, 12);
+ typeChooserPanel.add(moduleSuite, gridBagConstraints);
+
+ moduleSuiteValue.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ moduleSuiteChosen(evt);
+ }
+ });
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 1;
+ gridBagConstraints.gridy = 3;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints.weightx = 1.0;
+ gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 12);
+ typeChooserPanel.add(moduleSuiteValue, gridBagConstraints);
+ moduleSuiteValue.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TypeChooserPanelImpl.class, "ACS_CTL_ModuleSuiteValue")); // NOI18N
+ moduleSuiteValue.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TypeChooserPanelImpl.class, "ACS_CTL_ModuleSuiteValue")); // NOI18N
+
+ org.openide.awt.Mnemonics.setLocalizedText(browseSuiteButton, org.openide.util.NbBundle.getMessage(TypeChooserPanelImpl.class, "CTL_BrowseButton_w")); // NOI18N
+ browseSuiteButton.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ browseModuleSuite(evt);
+ }
+ });
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 2;
+ gridBagConstraints.gridy = 3;
+ gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
+ gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
+ gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
+ typeChooserPanel.add(browseSuiteButton, gridBagConstraints);
+ browseSuiteButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TypeChooserPanelImpl.class, "ACS_CTL_BrowseSuiteButton")); // NOI18N
+ browseSuiteButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TypeChooserPanelImpl.class, "ACS_CTL_BrowseSuiteButton")); // NOI18N
+
+ gridBagConstraints = new java.awt.GridBagConstraints();
+ gridBagConstraints.gridx = 0;
+ gridBagConstraints.gridy = 4;
+ gridBagConstraints.weighty = 1.0;
+ typeChooserPanel.add(chooserFiller, gridBagConstraints);
+
+ add(typeChooserPanel, java.awt.BorderLayout.CENTER);
+ }// //GEN-END:initComponents
+
+private void standAloneModuleTypeChanged(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_standAloneModuleTypeChanged
+ updateProperty(IS_STANDALONE_OR_SUITE_COMPONENT, isStandAlone());
+ updateEnabled();
+}//GEN-LAST:event_standAloneModuleTypeChanged
+
+private void platformChosen(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_platformChosen
+ updateProperty(ACTIVE_PLATFORM, getSelectedPlatform());
+ updateEnabled();
+}//GEN-LAST:event_platformChosen
+
+private void managePlatformActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_managePlatformActionPerformed
+ managePlatform(platformValue);
+ updateProperty(ACTIVE_PLATFORM, getSelectedPlatform());
+ updateEnabled();
+}//GEN-LAST:event_managePlatformActionPerformed
+
+ private void managePlatform(final JComboBox platformCombo) {
+ NbPlatformCustomizer.showCustomizer();
+ platformCombo.setModel(new PlatformComponentFactory.NbPlatformListModel()); // refresh
+ platformCombo.requestFocus();
+ }
+
+private void suiteComponentTypeChanged(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_suiteComponentTypeChanged
+ updateProperty(IS_STANDALONE_OR_SUITE_COMPONENT, isStandAlone());
+ updateEnabled();
+}//GEN-LAST:event_suiteComponentTypeChanged
+
+private void moduleSuiteChosen(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moduleSuiteChosen
+ String suite = (String) moduleSuiteValue.getSelectedItem();
+ lastSelectedSuite = suite;
+ updateProperty(SUITE_ROOT, getSelectedSuite());
+ updateEnabled();
+}//GEN-LAST:event_moduleSuiteChosen
+
+private void browseModuleSuite(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseModuleSuite
+JFileChooser chooser = ProjectChooser.projectChooser();
+ int option = chooser.showOpenDialog(this);
+ if (option == JFileChooser.APPROVE_OPTION) {
+ File projectDir = chooser.getSelectedFile();
+ UIUtil.setProjectChooserDirParent(projectDir);
+ try {
+ Project suite = ProjectManager.getDefault().findProject(
+ FileUtil.toFileObject(projectDir));
+ if (suite != null) {
+ String suiteDir = SuiteUtils.getSuiteDirectoryPath(suite);
+ if (suiteDir != null) {
+ // register for this session
+ PlatformComponentFactory.addUserSuite(suiteDir);
+ // add to current combobox
+ moduleSuiteValue.addItem(suiteDir);
+ moduleSuiteValue.setSelectedItem(suiteDir);
+ } else {
+ DialogDisplayer.getDefault().notify(new DialogDescriptor.Message(
+ NbBundle.getMessage(BasicInfoVisualPanel.class, "MSG_NotRegularSuite",
+ ProjectUtils.getInformation(suite).getDisplayName())));
+ }
+ }
+ } catch (IOException e) {
+ ErrorManager.getDefault().notify(ErrorManager.WARNING, e);
+ }
+ }
+}//GEN-LAST:event_browseModuleSuite
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton browseSuiteButton;
+ private javax.swing.JLabel chooserFiller;
+ private javax.swing.JButton managePlatform;
+ private javax.swing.JLabel moduleSuite;
+ private javax.swing.JComboBox moduleSuiteValue;
+ private javax.swing.ButtonGroup moduleTypeGroup;
+ private javax.swing.JLabel platform;
+ private javax.swing.JComboBox platformValue;
+ private javax.swing.JRadioButton standAloneModule;
+ private javax.swing.JRadioButton suiteComponent;
+ private javax.swing.JPanel typeChooserPanel;
+ // End of variables declaration//GEN-END:variables
+
+
+
+ private final void setMessage(String message) {
+ getSettings().putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, message);
+ }
+
+ protected WizardDescriptor getSettings(){
+ return settings;
+ }
+
+ private Type getWizardType(){
+ return this.wizardType;
+ }
+
+ // TODO movo implementation to static methods
+ private boolean isSuiteWizard() {
+ return getWizardType() != null
+ ? NewNbModuleWizardIterator.isSuiteWizard(getWizardType())
+ : false;
+ }
+
+ private boolean isSuiteComponentWizard() {
+ return getWizardType() != null
+ ? NewNbModuleWizardIterator.isSuiteComponentWizard(getWizardType())
+ : false;
+ }
+
+ private boolean isLibraryWizard() {
+ return getWizardType() != null
+ ? NewNbModuleWizardIterator.isLibraryWizard(getWizardType())
+ : false;
+ }
+
+
+}
diff -r b40223f61a69 -r 722fd79ea6d8 apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/spi/ModuleTypePanelCreator.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/spi/ModuleTypePanelCreator.java Thu Aug 28 12:26:28 2008 +0400
@@ -0,0 +1,139 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008 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 2008 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.apisupport.project.ui.wizard.spi;
+
+import java.awt.Component;
+import org.netbeans.modules.apisupport.project.ui.wizard.TypeChooserPanelExternalImpl;
+import org.openide.WizardDescriptor;
+
+/**
+ *
+ * @author avk
+ */
+public class ModuleTypePanelCreator {
+
+ /**
+ * Interface of UI panel for embedding into the First step
+ * of NetBeans module project wizard.
+ * Panel contains UI to select
+ *
+ * - NetBeans Platform (for standalone modules)
+ * - Module Suite (for suite modules)
+ *
+ *
+ * @author akorostelev
+ */
+ public interface ModuleTypePanel {
+
+ /**
+ * Is used to provide project's folder to TypeChooserPanel before
+ * updateUI(WizardDescriptor) invocation. Is used by TypeChooserPanel
+ * implementation to decide whether specified forder
+ * is in NetBeans.org repository.
+ * key for File value.
+ */
+ String PROJECT_FOLDER = "tc_projectFolderForTypeChooser"; // NOI18N
+
+ /**
+ * True if "Standalone Module" radiobutton is selected,
+ * false if "Add To Module Suite" radiobutton is selected.
+ * null if nothing is selected.
+ * key for Boolean value.
+ */
+ String IS_STANDALONE_OR_SUITE_COMPONENT = "tc_isStandaloneOrSuiteComp"; // NOI18N
+
+ /**
+ * Suite root directory.
+ * key for String value.
+ */
+ String SUITE_ROOT = "tc_suiteRoot"; // NOI18N
+
+ /**
+ * Active platform ID value to be used as value
+ * for nbplatform.active property in platform.properties file.
+ * key for String value.
+ */
+ String ACTIVE_PLATFORM = "tc_activePlatform"; // NOI18N
+
+ /**
+ * true if project is created in NetBeans sources.
+ * key for Boolean value.
+ */
+ String IS_NETBEANS_ORG = "isNetBeansOrg"; // NOI18N
+
+
+ /**
+ * validates panel. Error messages should be added to provided settings
+ * by setting WizardDescriptor.PROP_ERROR_MESSAGE property value:
+ *
+ * settings.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, message);
+ *
+ * @param settings
+ * @return true if panel is valid. false otherwise.
+ */
+ boolean validate(WizardDescriptor settings);
+
+ /**
+ * Notifies panel that project folder is changed
+ * and panel UI should e updated accordingly.
+ * on provided WizardDescriptor.
+ * New value is provided as WizardDescriptor property
+ * with name PROJECT_FOLDER:
+ *
+ * wizardDescriptor.putProperty(ModuleTypeChooserPanelExt.PROJECT_FOLDER, folder);
+ * typeChooserPanel.setProjectFolder(wizardDescriptor);
+ *
+ *
+ * @param settings Wizard descriptor with PROJECT_FOLDER property
+ * useful for UI updating (e.g. to calculate IS_NETBEANS_ORG value ).
+ */
+ void setProjectFolder(WizardDescriptor settings);
+
+ /**
+ * returns java.awt.Component for this panel
+ * @return
+ */
+ Component getComponent();
+
+ }
+
+ public static ModuleTypePanel create() {
+ return (ModuleTypePanel) new TypeChooserPanelExternalImpl();
+ }
+}
diff -r b40223f61a69 -r 722fd79ea6d8 apisupport.project/test/unit/src/org/netbeans/modules/apisupport/project/ui/wizard/spi/ModuleTypePanelCreatorTest.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/apisupport.project/test/unit/src/org/netbeans/modules/apisupport/project/ui/wizard/spi/ModuleTypePanelCreatorTest.java Thu Aug 28 12:26:28 2008 +0400
@@ -0,0 +1,154 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008 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 2008 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.apisupport.project.ui.wizard.spi;
+
+import java.awt.Component;
+import java.io.File;
+import org.netbeans.modules.apisupport.project.TestBase;
+import org.netbeans.modules.apisupport.project.ui.wizard.TypeChooserPanelExternalImpl;
+import org.netbeans.modules.apisupport.project.ui.wizard.spi.ModuleTypePanelCreator.ModuleTypePanel;
+import org.openide.WizardDescriptor;
+import org.openide.util.test.MockPropertyChangeListener;
+
+/**
+ *
+ * @author avk
+ */
+public class ModuleTypePanelCreatorTest extends TestBase {
+
+ public ModuleTypePanelCreatorTest(String testName) {
+ super(testName);
+ }
+
+ /**
+ * Test of create method, of class ModuleTypePanelCreator.
+ */
+ public void testCreate() {
+ ModuleTypePanel result = ModuleTypePanelCreator.create();
+ // panel is created
+ assertNotNull(result);
+ // expected panel implementation is returned
+ assertTrue(result instanceof TypeChooserPanelExternalImpl);
+ }
+
+ public void testGetComponent() {
+ ModuleTypePanel typeChooserPanel = ModuleTypePanelCreator.create();
+ Component ui = typeChooserPanel.getComponent();
+ assertNotNull(ui);
+ }
+
+ public void testPropertyChangeNotifications() {
+ WizardDescriptor wizardDescriptor = new WizardDescriptor() {};
+ ModuleTypePanel typeChooserPanel = ModuleTypePanelCreator.create();
+ MockPropertyChangeListener l = new MockPropertyChangeListener();
+ wizardDescriptor.addPropertyChangeListener(l);
+ // test that changes notifications are received
+ wizardDescriptor.putProperty(ModuleTypePanel.PROJECT_FOLDER, new File(""));
+ typeChooserPanel.setProjectFolder(wizardDescriptor);
+
+ l.assertEvents(ModuleTypePanel.IS_NETBEANS_ORG);
+ l.assertEvents(ModuleTypePanel.IS_STANDALONE_OR_SUITE_COMPONENT);
+ l.assertEvents(ModuleTypePanel.SUITE_ROOT);
+ l.assertEvents(ModuleTypePanel.ACTIVE_PLATFORM);
+ }
+
+ public void testPanelDisabledForNbOrg(){
+ WizardDescriptor wizardDescriptor = new WizardDescriptor() {};
+ ModuleTypePanel typeChooserPanel = ModuleTypePanelCreator.create();
+
+ wizardDescriptor.putProperty(ModuleTypePanel.PROJECT_FOLDER,
+ new File(nbRootFile(), "testProject"));
+ typeChooserPanel.setProjectFolder(wizardDescriptor);
+
+ assertTrue("project is in Nb Root",
+ (Boolean)wizardDescriptor.getProperty(ModuleTypePanel.IS_NETBEANS_ORG));
+ assertNull("standalone and suite component radios are deselected",
+ (Boolean)wizardDescriptor.getProperty(ModuleTypePanel.IS_STANDALONE_OR_SUITE_COMPONENT));
+ }
+
+ public void testPanelValuesForStandaloneModule(){
+ WizardDescriptor wizardDescriptor = new WizardDescriptor() {};
+ ModuleTypePanel typeChooserPanel = ModuleTypePanelCreator.create();
+
+ wizardDescriptor.putProperty(ModuleTypePanel.PROJECT_FOLDER, new File(""));
+ typeChooserPanel.setProjectFolder(wizardDescriptor);
+
+ assertFalse("project is NOT in Nb Root",
+ (Boolean)wizardDescriptor.getProperty(ModuleTypePanel.IS_NETBEANS_ORG));
+ assertTrue("standalone radios is selected",
+ (Boolean)wizardDescriptor.getProperty(ModuleTypePanel.IS_STANDALONE_OR_SUITE_COMPONENT));
+ assertNotNull("platrorm is selected",
+ (String)wizardDescriptor.getProperty(ModuleTypePanel.ACTIVE_PLATFORM));
+ }
+
+ public void testIsNetBeansOrgProperty() {
+ ModuleTypePanel typeChooserPanel = ModuleTypePanelCreator.create();
+
+ File folder = new File("");
+ Boolean isNbOrg = isFolderNbRoot(typeChooserPanel, folder);
+ assertNotNull(isNbOrg);
+ assertFalse(folder.getAbsolutePath() + " folder is NOT in NetBeans Root", isNbOrg);
+
+ folder = new File(nbRootFile(), "testProject");//NOI18N
+ isNbOrg = isFolderNbRoot(typeChooserPanel, folder );
+ assertNotNull(isNbOrg);
+ assertTrue(folder.getAbsolutePath() + " folder is in NetBeans Root", isNbOrg);
+
+ }
+
+ private Boolean isFolderNbRoot(ModuleTypePanel typeChooserPanel, File folder){
+ WizardDescriptor wizardDescriptor = new WizardDescriptor() {};
+
+ wizardDescriptor.putProperty(ModuleTypePanel.PROJECT_FOLDER, folder);
+ typeChooserPanel.setProjectFolder(wizardDescriptor);
+
+ return (Boolean)wizardDescriptor.getProperty(ModuleTypePanel.IS_NETBEANS_ORG);
+ }
+
+ public void testValidate(){
+ ModuleTypePanel typeChooserPanel = ModuleTypePanelCreator.create();
+ WizardDescriptor wizardDescriptor = new WizardDescriptor() {};
+ // test default state
+ typeChooserPanel.validate(wizardDescriptor);
+ assertNull("No error messages",
+ wizardDescriptor.getProperty(WizardDescriptor.PROP_ERROR_MESSAGE));
+
+ }
+
+}