# HG changeset patch
# User akorostelev@netbeans.org
# Date 1219951571 -14400
# Node ID e4be93651686cabb2d2a89e76ee0bb23cad03041
# Parent 15806e5514acb5e0a9afe996c862f884ccd326fd
patch for issue #142283 - expose Module type and suite selection panel
diff -r 15806e5514ac -r e4be93651686 apisupport.project/nbproject/project.xml
--- a/apisupport.project/nbproject/project.xml Thu Aug 28 17:27:10 2008 +0400
+++ b/apisupport.project/nbproject/project.xml Thu Aug 28 23:26:11 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 15806e5514ac -r e4be93651686 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 Thu Aug 28 17:27:10 2008 +0400
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/BasicInfoVisualPanel.form Thu Aug 28 23:26:11 2008 +0400
@@ -1,12 +1,21 @@
-
diff -r 15806e5514ac -r e4be93651686 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 Thu Aug 28 17:27:10 2008 +0400
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/BasicInfoVisualPanel.java Thu Aug 28 23:26:11 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.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,30 @@
*
* @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 +111,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_ID.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 +200,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(getSettings(), getData().getWizardType());
+ typeChooserPanelContainer.add(typeChooserPanel);
+ typeChooserPanelContainer.validate();
}
-
+
private void setComponentsVisibility() {
boolean isSuiteWizard = isSuiteWizard();
boolean isSuiteComponentWizard = isSuiteComponentWizard();
@@ -170,44 +221,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 +240,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 (!ModuleTypePanel.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 +276,8 @@
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;
- }
+
+ ModuleTypePanel.setProjectFolder(getSettings(), getFolder());
}
/** Set next free project name. */
@@ -324,12 +303,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 +344,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 +366,8 @@
updateAndCheck();
}
};
- platformValue.addActionListener(plafAL);
suitePlatformValue.addActionListener(plafAL);
+ getSettings().addPropertyChangeListener(this);
}
private File getFolder() {
@@ -401,32 +380,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 +405,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 +429,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 +446,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 +455,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 +471,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 +482,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 +512,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 +531,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 +547,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 +567,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 +591,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 +609,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 +628,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 +635,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 15806e5514ac -r e4be93651686 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 Thu Aug 28 17:27:10 2008 +0400
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/BasicVisualPanel.java Thu Aug 28 23:26:11 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 15806e5514ac -r e4be93651686 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 Thu Aug 28 17:27:10 2008 +0400
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/Bundle.properties Thu Aug 28 23:26:11 2008 +0400
@@ -63,7 +63,6 @@
LBL_ProjectFolder=Project Fol&der:
LBL_ProjectLocation=Project &Location:
LBL_ProjectName=Project &Name:
-MSG_ChooseRegularSuite=Regular suite must be chosen
MSG_ChosenPlatformIsInvalid=The selected platform is invalid. You may choose a valid one or resolve the invalid platform in NetBeans Platform Manager.
MSG_ClassInDefaultPackage=There are classes in the default package in {0}
MSG_Invalid_Library_Path=Library JAR does not exist
@@ -80,7 +79,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 15806e5514ac -r e4be93651686 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 Thu Aug 28 17:27:10 2008 +0400
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/NewNbModuleWizardIterator.java Thu Aug 28 23:26:11 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 15806e5514ac -r e4be93651686 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 23:26:11 2008 +0400
@@ -0,0 +1,230 @@
+
+
+
diff -r 15806e5514ac -r e4be93651686 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 23:26:11 2008 +0400
@@ -0,0 +1,603 @@
+/*
+ * 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.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+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.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
+ */
+public class TypeChooserPanelImpl extends javax.swing.JPanel{
+
+ private ButtonModel lastSelectedType;
+ private static String lastSelectedSuite;
+ private boolean moduleTypeGroupAttached = false;
+ private WizardDescriptor settings;
+ private Type wizardType;
+
+ public TypeChooserPanelImpl(final WizardDescriptor settings) {
+ this();
+ this.settings = settings;
+ attachModuleTypeGroup();
+ storeInitialValuesToWD(getSettings());
+ attachPropertyChangeListener(getSettings());
+ }
+
+ TypeChooserPanelImpl() {
+ initComponents();
+ init();
+ }
+
+ /** Creates new form TypeChooserPanel */
+ TypeChooserPanelImpl(final WizardDescriptor settings, Type wizardType) {
+ this();
+ this.settings = settings;
+ this.wizardType = wizardType;
+ storeInitialValuesToWD(getSettings());
+ attachPropertyChangeListener(getSettings());
+ 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();
+ }
+
+ protected boolean isStandAlone() {
+ return standAloneModule.isSelected();
+ }
+
+ protected boolean isSuiteComponent() {
+ return suiteComponent.isSelected();
+ }
+
+ protected String getSelectedSuite() {
+ return (String) moduleSuiteValue.getSelectedItem();
+ }
+
+ protected boolean isNetBeansOrgFolder() {
+ File folder = ModuleTypePanelInner.getProjectFolder(getSettings());
+ if (folder != null){
+ return BasicInfoVisualPanel.isNetBeansOrgFolder(folder);
+ }
+ return false;
+ }
+
+ // TODO rename to platformID
+ protected String getSelectedPlatform() {
+ Object selected = platformValue.getSelectedItem();
+ if (selected != null){
+ return ((NbPlatform) platformValue.getSelectedItem()).getID();
+ } else {
+ return null;
+ }
+ }
+ // todo rename to platform
+ protected NbPlatform getSelectedNbPlatform() {
+ Object selected = platformValue.getSelectedItem();
+ if (selected != null){
+ return (NbPlatform) platformValue.getSelectedItem();
+ } 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 projectFolderIsUpdated() {
+
+ if (isSuiteWizard(getWizardType()) || isNetBeansOrgFolder()) {
+ detachModuleTypeGroup();
+ } else {
+ attachModuleTypeGroup();
+ }
+ updateEnabled();
+ ModuleTypePanelInner.setIsNetBeansOrg(getSettings(), isNetBeansOrgFolder());
+ }
+
+ private void storeInitialValuesToWD(WizardDescriptor settings){
+ ModuleTypePanelInner.setIsNetBeansOrg(settings, isNetBeansOrgFolder());
+ ModuleTypePanelInner.setIsStandaloneOrSuiteComponent(settings, isStandAlone());
+ ModuleTypePanelInner.setSuiteRoot(settings, getSelectedSuite());
+ ModuleTypePanelInner.setActivePlatformId(settings, getSelectedPlatform());
+ ModuleTypePanelInner.setActiveNbPlatform(settings, getSelectedNbPlatform());
+ }
+
+ private void attachPropertyChangeListener(WizardDescriptor settings){
+ settings.addPropertyChangeListener(new ProjectFolderChangeListener());
+ }
+
+ private void detachModuleTypeGroup() {
+ if (moduleTypeGroupAttached) {
+ lastSelectedType = moduleTypeGroup.getSelection();
+ moduleTypeGroup.remove(standAloneModule);
+ moduleTypeGroup.remove(suiteComponent);
+ standAloneModule.setSelected(false);
+ suiteComponent.setSelected(false);
+ ModuleTypePanelInner.setIsStandaloneOrSuiteComponent(getSettings(), null);
+ moduleTypeGroupAttached = false;
+ }
+ }
+
+ /**
+ * Adds radiobuttons to ButtonGroup and sets selection.
+ */
+ protected void attachModuleTypeGroup() {
+ if (!moduleTypeGroupAttached) {
+ moduleTypeGroup.add(standAloneModule);
+ moduleTypeGroup.add(suiteComponent);
+ if (isLibraryWizard(getWizardType())) {
+ 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;
+ }
+
+ /** 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
+ ModuleTypePanelInner.setIsStandaloneOrSuiteComponent(getSettings(), isStandAlone());
+ updateEnabled();
+}//GEN-LAST:event_standAloneModuleTypeChanged
+
+private void platformChosen(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_platformChosen
+ ModuleTypePanelInner.setActivePlatformId(getSettings(), getSelectedPlatform());
+ ModuleTypePanelInner.setActiveNbPlatform(getSettings(), getSelectedNbPlatform());
+ updateEnabled();
+}//GEN-LAST:event_platformChosen
+
+private void managePlatformActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_managePlatformActionPerformed
+ managePlatform(platformValue);
+ ModuleTypePanelInner.setActivePlatformId(getSettings(), getSelectedPlatform());
+ ModuleTypePanelInner.setActiveNbPlatform(getSettings(), getSelectedNbPlatform());
+ 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
+ ModuleTypePanelInner.setIsStandaloneOrSuiteComponent(getSettings(), 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;
+ ModuleTypePanelInner.setSuiteRoot(getSettings(), 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
+
+
+
+ protected WizardDescriptor getSettings(){
+ return settings;
+ }
+
+ private Type getWizardType(){
+ return this.wizardType;
+ }
+
+ private static boolean isSuiteWizard(Type type) {
+ return type != null
+ ? NewNbModuleWizardIterator.isSuiteWizard(type)
+ : false;
+ }
+
+ private static boolean isLibraryWizard(Type type) {
+ return type != null
+ ? NewNbModuleWizardIterator.isLibraryWizard(type)
+ : false;
+ }
+
+ private class ProjectFolderChangeListener extends ModuleTypePanelInner
+ implements PropertyChangeListener
+ {
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ String name = evt.getPropertyName();
+
+ if (ModuleTypePanel.PROJECT_FOLDER.equals(name)) {
+ projectFolderIsUpdated();
+ }
+ }
+ }
+
+ /**
+ * is used to have access to propected attributes of ModuleTypePanel
+ */
+ private static class ModuleTypePanelInner extends ModuleTypePanel {
+ protected static void setIsStandaloneOrSuiteComponent(
+ WizardDescriptor settings, Boolean value)
+ {
+ if (settings != null){
+ settings.putProperty(IS_STANDALONE_OR_SUITE_COMPONENT, value);
+ }
+ }
+
+ protected static void setIsNetBeansOrg( WizardDescriptor settings, Boolean value) {
+ if (settings != null){
+ settings.putProperty(IS_NETBEANS_ORG, value);
+ }
+ }
+
+ protected static void setActivePlatformId( WizardDescriptor settings, String value) {
+ if (settings != null){
+ settings.putProperty(ACTIVE_PLATFORM_ID, value);
+ }
+ }
+
+ protected static void setActiveNbPlatform( WizardDescriptor settings, NbPlatform value) {
+ if (settings != null){
+ settings.putProperty(ACTIVE_NB_PLATFORM, value);
+ }
+ }
+
+ protected static void setSuiteRoot( WizardDescriptor settings, String value) {
+ if (settings != null){
+ settings.putProperty(SUITE_ROOT, value);
+ }
+ }
+
+ protected static File getProjectFolder( WizardDescriptor settings) {
+ if (settings != null) {
+ Object value = settings.getProperty(PROJECT_FOLDER);
+ if (value != null && value instanceof File) {
+ return (File) value;
+ }
+ }
+ return null;
+ }
+
+
+ }
+
+}
diff -r 15806e5514ac -r e4be93651686 apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/spi/Bundle.properties
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/spi/Bundle.properties Thu Aug 28 23:26:11 2008 +0400
@@ -0,0 +1,41 @@
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+#
+# Copyright 1997-2007 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]"
+#
+# Contributor(s):
+#
+# The Original Software is NetBeans. The Initial Developer of the Original
+# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 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.
+
+MSG_ChooseRegularSuite=Regular suite must be chosen
+MSG_ChosenPlatformIsInvalid=The selected platform is invalid. You may choose a valid one or resolve the invalid platform in NetBeans Platform Manager.
diff -r 15806e5514ac -r e4be93651686 apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/spi/ModuleTypePanel.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/ui/wizard/spi/ModuleTypePanel.java Thu Aug 28 23:26:11 2008 +0400
@@ -0,0 +1,226 @@
+/*
+ * 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.io.File;
+import javax.swing.JComponent;
+import org.netbeans.modules.apisupport.project.ui.wizard.TypeChooserPanelImpl;
+import org.netbeans.modules.apisupport.project.universe.NbPlatform;
+import org.openide.WizardDescriptor;
+import org.openide.util.NbBundle;
+
+/**
+ * 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 class ModuleTypePanel{
+
+ /**
+ * Key for module type property.
+ * key for Boolean value. use
+ */
+ public final static String IS_STANDALONE_OR_SUITE_COMPONENT
+ = "tc_isStandaloneOrSuiteComp"; // NOI18N
+
+ /**
+ * Suite root directory.
+ * key for String value.
+ */
+ public final static 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.
+ */
+ public final static String ACTIVE_PLATFORM_ID = "tc_activePlatform_id"; // NOI18N
+
+ /**
+ * Active platform Object.
+ * key for org.netbeans.modules.apisupport.project.universe.NbPlatform value.
+ */
+ protected final static String ACTIVE_NB_PLATFORM = "tc_activeNBPlatform"; // NOI18N
+
+ /**
+ * true if project is created in NetBeans sources.
+ * key for Boolean value.
+ */
+ protected final static String IS_NETBEANS_ORG = "isNetBeansOrg"; // NOI18N
+
+ /**
+ * 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.
+ */
+ protected final static String PROJECT_FOLDER = "tc_projectFolderForTypeChooser"; // NOI18N
+
+
+ /**
+ * creates Panel's UI Component.
+ * @param wizard Wizard descriptor to be used for getting property changge updates from Component.
+ * @return JComponent Panel object
+ */
+ public static JComponent createComponent(WizardDescriptor wizard) {
+ return (JComponent) new TypeChooserPanelImpl(wizard);
+ }
+
+ /**
+ * 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.
+ */
+ public static boolean validate(WizardDescriptor settings) {
+ if (isSuiteComponent(settings) && getSuiteRoot(settings) == null) {
+ setErrorMessage(settings, NbBundle.getMessage(
+ ModuleTypePanel.class, "MSG_ChooseRegularSuite"));// NOI18N
+ return false;
+ } else if (isStandalone(settings) &&
+ (getActiveNbPlatform(settings) == null || !(getActiveNbPlatform(settings)).isValid())) {
+ setErrorMessage(settings, NbBundle.getMessage(
+ ModuleTypePanel.class, "MSG_ChosenPlatformIsInvalid"));// NOI18N
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Notifies panel that project folder is changed
+ * and panel UI should be updated.
+ * @param settings Wizard descriptor
+ * @param folder new Project folder value
+ */
+ public static void setProjectFolder(WizardDescriptor settings, File value) {
+ settings.putProperty(PROJECT_FOLDER, value);
+ }
+
+ /**
+ * Checks in Wizard Descriptor properties if "Add To Module Suite" was selected
+ * on Component created using createComponent(WizardDescriptor).
+ * @param wizard Wizard descriptor
+ * @return true if "Add To Module Suite" radiobutton was selected. false if not.
+ */
+ public static boolean isSuiteComponent(WizardDescriptor wizard){
+ Object value = wizard.getProperty(IS_STANDALONE_OR_SUITE_COMPONENT);
+ return !extractBoolean(value, true);
+ }
+
+ /**
+ * Checks in Wizard Descriptor properties if "Standalone Module" was selected
+ * on Component created using createComponent(WizardDescriptor).
+ * @param wizard Wizard descriptor
+ * @return true if "Standalone Module" radiobutton was selected. false if not.
+ */
+ public static boolean isStandalone(WizardDescriptor wizard){
+ Object value = wizard.getProperty(IS_STANDALONE_OR_SUITE_COMPONENT);
+ return extractBoolean(value, false);
+ }
+
+ /**
+ * Returns true if Module with project folder set by setProjectFolder(WizardDescriptor, File)
+ * is NetBeans sourcees root
+ * @param wizard Wizard descriptor
+ * @return true if specified Project folder is NetBeans sourcees root
+ */
+ public static boolean isNetBeansOrg(WizardDescriptor wizard){
+ Object value = wizard.getProperty(IS_NETBEANS_ORG);
+ return extractBoolean(value, false);
+ }
+
+ /**
+ * Returns suite root directory stored in wizard descriptor by
+ * Component created using createComponent(WizardDescriptor).
+ * @param wizard Wizard descriptor
+ * @return suite root directory
+ */
+ public static String getSuiteRoot(WizardDescriptor wizard){
+ Object value = wizard.getProperty(SUITE_ROOT);
+ return extractString(value, null);
+ }
+
+ /**
+ * Returns platform id stored in wizard descriptor by
+ * Component created using createComponent(WizardDescriptor).
+ * @param wizard Wizard descriptor
+ * @return platform id
+ */
+ public static String getActivePlatformId(WizardDescriptor wizard){
+ Object value = wizard.getProperty(ACTIVE_PLATFORM_ID);
+ return extractString(value, null);
+ }
+
+ private static NbPlatform getActiveNbPlatform(WizardDescriptor wizard){
+ Object value = wizard.getProperty(ACTIVE_NB_PLATFORM);
+ if (value != null && value instanceof NbPlatform){
+ return (NbPlatform)value;
+ }
+ return null;
+ }
+
+ private static boolean extractBoolean(Object value, boolean defaultValue){
+ if (value != null && value instanceof Boolean){
+ return (Boolean)value;
+ }
+ return defaultValue;
+ }
+
+ private static String extractString(Object value, String defaultValue){
+ if (value != null && value instanceof String){
+ return (String)value;
+ }
+ return defaultValue;
+ }
+
+ private static void setErrorMessage(WizardDescriptor settings, String message) {
+ settings.putProperty(WizardDescriptor.PROP_ERROR_MESSAGE, message);
+ }
+
+}
diff -r 15806e5514ac -r e4be93651686 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 23:26:11 2008 +0400
@@ -0,0 +1,151 @@
+/*
+ * 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 javax.swing.JComponent;
+import org.netbeans.modules.apisupport.project.TestBase;
+import org.netbeans.modules.apisupport.project.ui.wizard.TypeChooserPanelImpl;
+import org.netbeans.modules.apisupport.project.universe.NbPlatform;
+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 ModuleTypePanel.
+ */
+ public void testCreate() {
+ WizardDescriptor wizardDescriptor = new WizardDescriptor() {};
+ JComponent result = ModuleTypePanel.createComponent(wizardDescriptor);
+ // panel is created
+ assertNotNull(result);
+ // expected panel implementation is returned
+ assertTrue(result instanceof TypeChooserPanelImpl);
+ }
+
+ public void testPropertyChangeNotifications() {
+ WizardDescriptor wizardDescriptor = new WizardDescriptor() {};
+ MockPropertyChangeListener l = new MockPropertyChangeListener();
+ wizardDescriptor.addPropertyChangeListener(l);
+
+ JComponent typeChooserPanel = ModuleTypePanel.createComponent(wizardDescriptor);
+ // test that changes notifications are received
+ ModuleTypePanel.setProjectFolder(wizardDescriptor, new File(""));
+
+ l.assertEvents(ModuleTypePanel.IS_NETBEANS_ORG,
+ ModuleTypePanel.IS_STANDALONE_OR_SUITE_COMPONENT,
+ ModuleTypePanel.SUITE_ROOT,
+ ModuleTypePanel.ACTIVE_PLATFORM_ID,
+ ModuleTypePanel.ACTIVE_NB_PLATFORM,
+ ModuleTypePanel.PROJECT_FOLDER);
+ }
+
+ public void testPanelDisabledForNbOrg(){
+ WizardDescriptor wizardDescriptor = new WizardDescriptor() {};
+ JComponent typeChooserPanel = ModuleTypePanel.createComponent(wizardDescriptor);
+
+ ModuleTypePanel.setProjectFolder(wizardDescriptor,
+ new File(nbRootFile(), "testProject"));
+
+ assertTrue("project is in Nb Root",
+ ModuleTypePanel.isNetBeansOrg(wizardDescriptor));
+ assertFalse("standalone radio buttyon is deselected",
+ ModuleTypePanel.isStandalone(wizardDescriptor));
+ assertFalse("suite component radio buttyon is deselected",
+ ModuleTypePanel.isSuiteComponent(wizardDescriptor));
+ }
+
+ public void testPanelValuesForStandaloneModule(){
+ WizardDescriptor wizardDescriptor = new WizardDescriptor() {};
+ JComponent typeChooserPanel = ModuleTypePanel.createComponent(wizardDescriptor);
+
+ ModuleTypePanel.setProjectFolder(wizardDescriptor, new File(""));
+
+ assertFalse("project is NOT in Nb Root",
+ ModuleTypePanel.isNetBeansOrg(wizardDescriptor));
+ assertTrue("standalone radios is selected",
+ ModuleTypePanel.isStandalone(wizardDescriptor));
+ assertNotNull("platrorm is selected",
+ ModuleTypePanel.getActivePlatformId(wizardDescriptor));
+ assertNotNull("platrorm is selected(test NbPlatform value)",
+ (NbPlatform)wizardDescriptor.getProperty(ModuleTypePanel.ACTIVE_NB_PLATFORM));
+ }
+
+ public void testIsNetBeansOrgProperty() {
+ WizardDescriptor wizardDescriptor = new WizardDescriptor() {};
+ JComponent typeChooserPanel = ModuleTypePanel.createComponent(wizardDescriptor);
+
+ File folder = new File("");
+ Boolean isNbOrg = isFolderNbRoot(wizardDescriptor, folder);
+ assertNotNull(isNbOrg);
+ assertFalse(folder.getAbsolutePath() + " folder is NOT in NetBeans Root", isNbOrg);
+
+ folder = new File(nbRootFile(), "testProject");//NOI18N
+ isNbOrg = isFolderNbRoot(wizardDescriptor, folder );
+ assertNotNull(isNbOrg);
+ assertTrue(folder.getAbsolutePath() + " folder is in NetBeans Root", isNbOrg);
+
+ }
+
+ private Boolean isFolderNbRoot(WizardDescriptor wizardDescriptor, File folder){
+ ModuleTypePanel.setProjectFolder(wizardDescriptor, folder);
+ return ModuleTypePanel.isNetBeansOrg(wizardDescriptor);
+ }
+
+ public void testValidate(){
+ WizardDescriptor wizardDescriptor = new WizardDescriptor() {};
+ JComponent typeChooserPanel = ModuleTypePanel.createComponent(wizardDescriptor);
+ // test default state
+ ModuleTypePanel.validate(wizardDescriptor);
+ assertNull("No error messages",
+ wizardDescriptor.getProperty(WizardDescriptor.PROP_ERROR_MESSAGE));
+
+ }
+
+}