0001: /*
0002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0003: *
0004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
0005: *
0006: * The contents of this file are subject to the terms of either the GNU
0007: * General Public License Version 2 only ("GPL") or the Common
0008: * Development and Distribution License("CDDL") (collectively, the
0009: * "License"). You may not use this file except in compliance with the
0010: * License. You can obtain a copy of the License at
0011: * http://www.netbeans.org/cddl-gplv2.html
0012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
0013: * specific language governing permissions and limitations under the
0014: * License. When distributing the software, include this License Header
0015: * Notice in each file and include the License file at
0016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
0017: * particular file as subject to the "Classpath" exception as provided
0018: * by Sun in the GPL Version 2 section of the License file that
0019: * accompanied this code. If applicable, add the following below the
0020: * License Header, with the fields enclosed by brackets [] replaced by
0021: * your own identifying information:
0022: * "Portions Copyrighted [year] [name of copyright owner]"
0023: *
0024: * Contributor(s):
0025: *
0026: * The Original Software is NetBeans. The Initial Developer of the Original
0027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
0028: * Microsystems, Inc. All Rights Reserved.
0029: *
0030: * If you wish your version of this file to be governed by only the CDDL
0031: * or only the GPL Version 2, indicate your decision by adding
0032: * "[Contributor] elects to include this software in this distribution
0033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
0034: * single choice of license, a recipient has the option to distribute
0035: * your version of this file under either the CDDL, the GPL Version 2 or
0036: * to extend the choice of license to its licensees as provided above.
0037: * However, if you add GPL Version 2 code and therefore, elected the GPL
0038: * Version 2 license, then the option applies only if the new code is
0039: * made subject to such option by the copyright holder.
0040: */
0041:
0042: package org.netbeans.modules.apisupport.project.ui.wizard;
0043:
0044: import java.awt.event.ActionEvent;
0045: import java.awt.event.ActionListener;
0046: import java.io.File;
0047: import java.io.IOException;
0048: import java.text.MessageFormat;
0049: import javax.swing.ButtonModel;
0050: import javax.swing.JComboBox;
0051: import javax.swing.JFileChooser;
0052: import javax.swing.event.DocumentEvent;
0053: import javax.swing.event.DocumentListener;
0054: import org.netbeans.api.project.Project;
0055: import org.netbeans.api.project.ProjectManager;
0056: import org.netbeans.api.project.ProjectUtils;
0057: import org.netbeans.modules.apisupport.project.ui.ModuleUISettings;
0058: import org.netbeans.modules.apisupport.project.universe.ModuleList;
0059: import org.netbeans.modules.apisupport.project.universe.NbPlatform;
0060: import org.netbeans.modules.apisupport.project.ui.UIUtil;
0061: import org.netbeans.modules.apisupport.project.ui.customizer.SuiteUtils;
0062: import org.netbeans.modules.apisupport.project.ui.platform.PlatformComponentFactory;
0063: import org.netbeans.modules.apisupport.project.ui.platform.NbPlatformCustomizer;
0064: import org.netbeans.spi.project.ui.support.ProjectChooser;
0065: import org.openide.DialogDescriptor;
0066: import org.openide.DialogDisplayer;
0067: import org.openide.ErrorManager;
0068: import org.openide.filesystems.FileUtil;
0069: import org.openide.util.NbBundle;
0070:
0071: /**
0072: * First panel of <code>NewNbModuleWizardIterator</code>. Allow user to enter
0073: * basic module information:
0074: *
0075: * <ul>
0076: * <li>Project name</li>
0077: * <li>Project Location</li>
0078: * <li>Project Folder</li>
0079: * <li>If should be set as a Main Project</li>
0080: * <li>NetBeans Platform (for standalone modules)</li>
0081: * <li>Module Suite (for suite modules)</li>
0082: * </ul>
0083: *
0084: * @author Martin Krauskopf
0085: */
0086: public class BasicInfoVisualPanel extends
0087: BasicVisualPanel.NewTemplatePanel {
0088:
0089: private ButtonModel lastSelectedType;
0090: private static String lastSelectedSuite;
0091: private boolean locationUpdated;
0092: private boolean nameUpdated;
0093: private boolean moduleTypeGroupAttached = true;
0094: private boolean mainProjectTouched;
0095:
0096: /** Creates new form BasicInfoVisualPanel */
0097: BasicInfoVisualPanel(final NewModuleProjectData data) {
0098: super (data);
0099: initComponents();
0100: initAccessibility();
0101: initPlatformCombos();
0102: setComponentsVisibility();
0103: switch (data.getWizardType()) {
0104: case NewNbModuleWizardIterator.TYPE_SUITE:
0105: detachModuleTypeGroup();
0106: break;
0107: case NewNbModuleWizardIterator.TYPE_MODULE:
0108: case NewNbModuleWizardIterator.TYPE_SUITE_COMPONENT:
0109: if (moduleSuiteValue.getItemCount() > 0) {
0110: restoreSelectedSuite();
0111: suiteComponent.setSelected(true);
0112: mainProject.setSelected(false);
0113: }
0114: break;
0115: case NewNbModuleWizardIterator.TYPE_LIBRARY_MODULE:
0116: moduleSuite.setText(getMessage("LBL_Add_to_Suite")); // NOI18N
0117: suiteComponent.setSelected(true);
0118: if (moduleSuiteValue.getItemCount() > 0) {
0119: restoreSelectedSuite();
0120: }
0121: break;
0122: default:
0123: assert false : "Unknown wizard type = "
0124: + data.getWizardType();
0125: }
0126: attachDocumentListeners();
0127: setInitialLocation();
0128: setInitialProjectName();
0129: updateEnabled();
0130: }
0131:
0132: private void setInitialLocation() {
0133: if (isSuiteComponent()) {
0134: computeAndSetLocation((String) moduleSuiteValue
0135: .getSelectedItem(), true);
0136: } else { // suite or standalone module
0137: String location = computeLocationValue(ProjectChooser
0138: .getProjectsFolder().getAbsolutePath());
0139: File locationF = new File(location);
0140: if (SuiteUtils.isSuite(locationF)) {
0141: computeAndSetLocation(locationF.getParent(), true);
0142: } else {
0143: setLocation(location, true);
0144: }
0145: }
0146: }
0147:
0148: private void initAccessibility() {
0149: this .getAccessibleContext().setAccessibleDescription(
0150: getMessage("ACS_BasicInfoVisualPanel"));
0151: browseButton.getAccessibleContext().setAccessibleDescription(
0152: getMessage("ACS_CTL_BrowseButton"));
0153: browseSuiteButton.getAccessibleContext()
0154: .setAccessibleDescription(
0155: getMessage("ACS_CTL_BrowseSuiteButton"));
0156: folderValue.getAccessibleContext().setAccessibleDescription(
0157: getMessage("ACS_CTL_FolderValue"));
0158: locationValue.getAccessibleContext().setAccessibleDescription(
0159: getMessage("ACS_CTL_LocationValue"));
0160: mainProject.getAccessibleContext().setAccessibleDescription(
0161: getMessage("ACS_CTL_MainProject"));
0162: managePlatform.getAccessibleContext().setAccessibleDescription(
0163: getMessage("ACS_CTL_ManagePlatform"));
0164: manageSuitePlatform.getAccessibleContext()
0165: .setAccessibleDescription(
0166: getMessage("ACS_CTL_ManageSuitePlatform"));
0167: moduleSuiteValue.getAccessibleContext()
0168: .setAccessibleDescription(
0169: getMessage("ACS_CTL_ModuleSuiteValue"));
0170: nameValue.getAccessibleContext().setAccessibleDescription(
0171: getMessage("ACS_CTL_NameValue"));
0172: platformValue.getAccessibleContext().setAccessibleDescription(
0173: getMessage("ACS_CTL_PlatformValue"));
0174: standAloneModule.getAccessibleContext()
0175: .setAccessibleDescription(
0176: getMessage("ACS_CTL_StandAloneModule"));
0177: suiteComponent.getAccessibleContext().setAccessibleDescription(
0178: getMessage("ACS_CTL_SuiteModule"));
0179: suitePlatformValue.getAccessibleContext()
0180: .setAccessibleDescription(
0181: getMessage("ACS_CTL_SuitePlatformValue"));
0182: }
0183:
0184: private void setComponentsVisibility() {
0185: boolean isSuiteWizard = isSuiteWizard();
0186: boolean isSuiteComponentWizard = isSuiteComponentWizard();
0187: boolean isLibraryWizard = isLibraryWizard();
0188:
0189: typeChooserPanel.setVisible(!isSuiteWizard);
0190: suitePlatform.setVisible(isSuiteWizard);
0191: suitePlatformValue.setVisible(isSuiteWizard);
0192: manageSuitePlatform.setVisible(isSuiteWizard);
0193: mainProject.setVisible(!isLibraryWizard);
0194:
0195: suiteComponent.setVisible(!isLibraryWizard);
0196: platform.setVisible(!isLibraryWizard);
0197: platformValue.setVisible(!isLibraryWizard);
0198: managePlatform.setVisible(!isLibraryWizard);
0199: standAloneModule.setVisible(!isLibraryWizard);
0200: mainProject.setSelected(!isLibraryWizard);
0201:
0202: standAloneModule.setVisible(!isSuiteComponentWizard
0203: && !isLibraryWizard);
0204: platform
0205: .setVisible(!isSuiteComponentWizard && !isLibraryWizard);
0206: platformValue.setVisible(!isSuiteComponentWizard
0207: && !isLibraryWizard);
0208: managePlatform.setVisible(!isSuiteComponentWizard
0209: && !isLibraryWizard);
0210: suiteComponent.setVisible(!isSuiteComponentWizard
0211: && !isLibraryWizard);
0212: }
0213:
0214: private void restoreSelectedSuite() {
0215: String preferredSuiteDir = getPreferredSuiteDir();
0216: if (preferredSuiteDir != null) {
0217: lastSelectedSuite = preferredSuiteDir;
0218: }
0219: if (lastSelectedSuite != null) {
0220: int max = moduleSuiteValue.getModel().getSize();
0221: for (int i = 0; i < max; i++) {
0222: if (lastSelectedSuite.equals(moduleSuiteValue
0223: .getModel().getElementAt(i))) {
0224: moduleSuiteValue.setSelectedItem(lastSelectedSuite);
0225: break;
0226: }
0227: }
0228: }
0229: }
0230:
0231: private String getPreferredSuiteDir() {
0232: return (String) getSettings().getProperty(
0233: NewNbModuleWizardIterator.PREFERRED_SUITE_DIR);
0234: }
0235:
0236: private boolean isOneSuiteDedicatedMode() {
0237: Boolean b = (Boolean) getSettings().getProperty(
0238: NewNbModuleWizardIterator.ONE_SUITE_DEDICATED_MODE);
0239: return b != null ? b.booleanValue() : false;
0240: }
0241:
0242: private String getNameValue() {
0243: return nameValue.getText().trim();
0244: }
0245:
0246: private String getLocationValue() {
0247: return locationValue.getText().trim();
0248: }
0249:
0250: private File getLocationFile() {
0251: return new File(getLocationValue());
0252: }
0253:
0254: private void updateEnabled() {
0255: boolean isNetBeansOrg = isNetBeansOrgFolder();
0256: standAloneModule.setEnabled(!isNetBeansOrg);
0257: suiteComponent.setEnabled(!isNetBeansOrg);
0258:
0259: boolean standalone = isStandAlone();
0260: boolean suiteModuleSelected = isSuiteComponent();
0261: platform.setEnabled(standalone);
0262: platformValue.setEnabled(standalone);
0263: managePlatform.setEnabled(standalone);
0264: moduleSuite.setEnabled(suiteModuleSelected);
0265: moduleSuiteValue.setEnabled(suiteModuleSelected
0266: && !isOneSuiteDedicatedMode());
0267: browseSuiteButton.setEnabled(suiteModuleSelected
0268: && !isOneSuiteDedicatedMode());
0269: }
0270:
0271: void updateAndCheck() {
0272: updateGUI();
0273:
0274: if ("".equals(getNameValue())) {
0275: setError(getMessage("MSG_NameCannotBeEmpty"));
0276: } else if ("".equals(getLocationValue())) {
0277: setError(getMessage("MSG_LocationCannotBeEmpty"));
0278: } else if (isLibraryWizard() && isNetBeansOrgFolder()) {
0279: setError(getMessage("MSG_LibraryWrapperForNBOrgUnsupported"));
0280: } else if (isSuiteComponent()
0281: && moduleSuiteValue.getSelectedItem() == null) {
0282: setError(getMessage("MSG_ChooseRegularSuite"));
0283: } else if (isStandAlone()
0284: && (platformValue.getSelectedItem() == null || !((NbPlatform) platformValue
0285: .getSelectedItem()).isValid())) {
0286: setError(getMessage("MSG_ChosenPlatformIsInvalid"));
0287: } else if (isSuiteWizard()
0288: && (suitePlatformValue.getSelectedItem() == null || !((NbPlatform) suitePlatformValue
0289: .getSelectedItem()).isValid())) {
0290: setError(getMessage("MSG_ChosenPlatformIsInvalid"));
0291: } else if (getFolder().exists()) {
0292: setError(getMessage("MSG_ProjectFolderExists"));
0293: } else if (!getLocationFile().exists()) {
0294: setError(getMessage("MSG_LocationMustExist"));
0295: } else if (!getLocationFile().canWrite()) {
0296: setError(getMessage("MSG_LocationNotWritable"));
0297: } else {
0298: markValid();
0299: }
0300: }
0301:
0302: private void updateGUI() {
0303: // update project folder
0304: folderValue.setText(getFolder().getPath());
0305:
0306: if (isSuiteWizard() || isNetBeansOrgFolder()) {
0307: detachModuleTypeGroup();
0308: } else {
0309: attachModuleTypeGroup();
0310: }
0311: updateEnabled();
0312: }
0313:
0314: private void detachModuleTypeGroup() {
0315: if (moduleTypeGroupAttached) {
0316: lastSelectedType = moduleTypeGroup.getSelection();
0317: moduleTypeGroup.remove(standAloneModule);
0318: moduleTypeGroup.remove(suiteComponent);
0319: standAloneModule.setSelected(false);
0320: suiteComponent.setSelected(false);
0321: moduleTypeGroupAttached = false;
0322: }
0323: }
0324:
0325: private void attachModuleTypeGroup() {
0326: if (!moduleTypeGroupAttached) {
0327: moduleTypeGroup.add(standAloneModule);
0328: moduleTypeGroup.add(suiteComponent);
0329: if (isLibraryWizard()) {
0330: suiteComponent.setSelected(true);
0331: } else {
0332: moduleTypeGroup.setSelected(lastSelectedType, true);
0333: }
0334: moduleTypeGroupAttached = true;
0335: }
0336: }
0337:
0338: /** Set <em>next</em> free project name. */
0339: private void setProjectName(String formater, int counter) {
0340: String name;
0341: while ((name = validFreeModuleName(formater, counter)) == null) {
0342: counter++;
0343: }
0344: nameValue.setText(name);
0345: }
0346:
0347: // stolen (then adjusted) from j2seproject
0348: private String validFreeModuleName(String formater, int index) {
0349: String name = MessageFormat.format(formater,
0350: new Object[] { new Integer(index) });
0351: File file = new File(getLocationValue(), name);
0352: return file.exists() ? null : name;
0353: }
0354:
0355: /** Stores collected data into model. */
0356: void storeData() {
0357: getData().setProjectName(getNameValue());
0358: getData().setProjectLocation(getLocationValue());
0359: getData().setProjectFolder(folderValue.getText());
0360: getData().setMainProject(mainProject.isSelected());
0361: getData().setNetBeansOrg(isNetBeansOrgFolder());
0362: getData().setStandalone(isStandAlone());
0363: getData().setSuiteRoot(
0364: (String) moduleSuiteValue.getSelectedItem());
0365: if (isSuiteWizard()
0366: && suitePlatformValue.getSelectedItem() != null) {
0367: getData().setPlatformID(
0368: ((NbPlatform) suitePlatformValue.getSelectedItem())
0369: .getID());
0370: } else if (platformValue.getSelectedItem() != null) {
0371: getData().setPlatformID(
0372: ((NbPlatform) platformValue.getSelectedItem())
0373: .getID());
0374: }
0375: }
0376:
0377: void refreshData() {
0378: if (getData().getProjectName() != null) {
0379: nameValue.setText(getData().getProjectName());
0380: } else {
0381: setInitialProjectName();
0382: }
0383: }
0384:
0385: private void setInitialProjectName() {
0386: String bundlekey = null;
0387: int counter = 0;
0388: switch (getData().getWizardType()) {
0389: case NewNbModuleWizardIterator.TYPE_SUITE:
0390: counter = ModuleUISettings.getDefault()
0391: .getNewSuiteCounter() + 1;
0392: bundlekey = "TXT_Suite"; //NOI18N
0393: getData().setSuiteCounter(counter);
0394: break;
0395: case NewNbModuleWizardIterator.TYPE_MODULE:
0396: case NewNbModuleWizardIterator.TYPE_SUITE_COMPONENT:
0397: counter = ModuleUISettings.getDefault()
0398: .getNewModuleCounter() + 1;
0399: bundlekey = "TXT_Module"; //NOI18N
0400: getData().setModuleCounter(counter);
0401: break;
0402: case NewNbModuleWizardIterator.TYPE_LIBRARY_MODULE:
0403: counter = ModuleUISettings.getDefault()
0404: .getNewModuleCounter() + 1;
0405: bundlekey = "TXT_Library"; //NOI18N
0406: getData().setModuleCounter(counter);
0407: break;
0408: default:
0409: assert false : "Unknown wizard type = "
0410: + getData().getWizardType();
0411: }
0412: setProjectName(getMessage(bundlekey), counter);
0413: nameValue.select(0, nameValue.getText().length());
0414: nameUpdated = false;
0415: }
0416:
0417: private void attachDocumentListeners() {
0418: DocumentListener fieldsDL = new UIUtil.DocumentAdapter() {
0419: public void insertUpdate(DocumentEvent e) {
0420: updateAndCheck();
0421: }
0422: };
0423: nameValue.getDocument().addDocumentListener(fieldsDL);
0424: nameValue.getDocument().addDocumentListener(
0425: new UIUtil.DocumentAdapter() {
0426: public void insertUpdate(DocumentEvent e) {
0427: nameUpdated = true;
0428: }
0429: });
0430: locationValue.getDocument().addDocumentListener(fieldsDL);
0431: locationValue.getDocument().addDocumentListener(
0432: new UIUtil.DocumentAdapter() {
0433: public void insertUpdate(DocumentEvent e) {
0434: locationUpdated = true;
0435: }
0436: });
0437: ActionListener plafAL = new ActionListener() {
0438: public void actionPerformed(ActionEvent e) {
0439: updateAndCheck();
0440: }
0441: };
0442: platformValue.addActionListener(plafAL);
0443: suitePlatformValue.addActionListener(plafAL);
0444: }
0445:
0446: private File getFolder() {
0447: StringBuffer destFolder = new StringBuffer(getLocationValue());
0448: if (destFolder.length() != 0) {
0449: destFolder.append(File.separator);
0450: }
0451: destFolder.append(getNameValue());
0452: return FileUtil.normalizeFile(new File(destFolder.toString()));
0453: }
0454:
0455: private boolean isNetBeansOrgFolder() {
0456: return ModuleList.findNetBeansOrg(getFolder()) != null;
0457: }
0458:
0459: private static String getMessage(String key) {
0460: return NbBundle.getMessage(BasicInfoVisualPanel.class, key);
0461: }
0462:
0463: private void initPlatformCombos() {
0464: if (platformValue.getItemCount() <= 0) {
0465: return;
0466: }
0467: boolean set = false;
0468: String idToSelect = ModuleUISettings.getDefault()
0469: .getLastUsedPlatformID();
0470: for (int i = 0; i < platformValue.getItemCount(); i++) {
0471: if (((NbPlatform) platformValue.getItemAt(i)).getID()
0472: .equals(idToSelect)) {
0473: platformValue.setSelectedIndex(i);
0474: suitePlatformValue.setSelectedIndex(i);
0475: set = true;
0476: break;
0477: }
0478: }
0479: if (!set) {
0480: NbPlatform defPlaf = NbPlatform.getDefaultPlatform();
0481: platformValue
0482: .setSelectedItem(defPlaf == null ? platformValue
0483: .getItemAt(0) : defPlaf);
0484: suitePlatformValue
0485: .setSelectedItem(defPlaf == null ? suitePlatformValue
0486: .getItemAt(0)
0487: : defPlaf);
0488: }
0489: }
0490:
0491: private void setLocation(String location, boolean silently) {
0492: boolean revert = silently && !locationUpdated;
0493: locationValue.setText(location);
0494: locationUpdated = revert ^ true;
0495: }
0496:
0497: private void computeAndSetLocation(String value, boolean silently) {
0498: setLocation(computeLocationValue(value), silently);
0499: }
0500:
0501: private String computeLocationValue(String value) {
0502: if (value == null) {
0503: value = System.getProperty("user.home"); // NOI18N
0504: }
0505: File file = new File(value);
0506: if (!file.exists() && file.getParent() != null) {
0507: return computeLocationValue(file.getParent());
0508: } else {
0509: return file.exists() ? value : System
0510: .getProperty("user.home"); // NOI18N
0511: }
0512: }
0513:
0514: private boolean isStandAlone() {
0515: return standAloneModule.isSelected();
0516: }
0517:
0518: private boolean isSuiteComponent() {
0519: return suiteComponent.isSelected();
0520: }
0521:
0522: /** This method is called from within the constructor to
0523: * initialize the form.
0524: * WARNING: Do NOT modify this code. The content of this method is
0525: * always regenerated by the Form Editor.
0526: */
0527: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
0528: private void initComponents() {
0529: java.awt.GridBagConstraints gridBagConstraints;
0530:
0531: moduleTypeGroup = new javax.swing.ButtonGroup();
0532: infoPanel = new javax.swing.JPanel();
0533: nameLbl = new javax.swing.JLabel();
0534: locationLbl = new javax.swing.JLabel();
0535: folderLbl = new javax.swing.JLabel();
0536: nameValue = new javax.swing.JTextField();
0537: locationValue = new javax.swing.JTextField();
0538: browseButton = new javax.swing.JButton();
0539: filler = new javax.swing.JLabel();
0540: folderValue = new javax.swing.JTextField();
0541: suitePlatform = new javax.swing.JLabel();
0542: suitePlatformValue = PlatformComponentFactory
0543: .getNbPlatformsComboxBox();
0544: manageSuitePlatform = new javax.swing.JButton();
0545: separator3 = new javax.swing.JSeparator();
0546: mainProject = new javax.swing.JCheckBox();
0547: typeChooserPanel = new javax.swing.JPanel();
0548: standAloneModule = new javax.swing.JRadioButton();
0549: platform = new javax.swing.JLabel();
0550: platformValue = PlatformComponentFactory
0551: .getNbPlatformsComboxBox();
0552: managePlatform = new javax.swing.JButton();
0553: suiteComponent = new javax.swing.JRadioButton();
0554: moduleSuite = new javax.swing.JLabel();
0555: moduleSuiteValue = PlatformComponentFactory.getSuitesComboBox();
0556: browseSuiteButton = new javax.swing.JButton();
0557: chooserFiller = new javax.swing.JLabel();
0558: pnlThouShaltBeholdLayout = new javax.swing.JPanel();
0559:
0560: setLayout(new java.awt.GridBagLayout());
0561:
0562: infoPanel.setLayout(new java.awt.GridBagLayout());
0563:
0564: nameLbl.setLabelFor(nameValue);
0565: org.openide.awt.Mnemonics.setLocalizedText(nameLbl,
0566: org.openide.util.NbBundle.getMessage(
0567: BasicInfoVisualPanel.class, "LBL_ProjectName"));
0568: gridBagConstraints = new java.awt.GridBagConstraints();
0569: gridBagConstraints.gridx = 0;
0570: gridBagConstraints.gridy = 0;
0571: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0572: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12);
0573: infoPanel.add(nameLbl, gridBagConstraints);
0574:
0575: locationLbl.setLabelFor(locationValue);
0576: org.openide.awt.Mnemonics.setLocalizedText(locationLbl,
0577: org.openide.util.NbBundle.getMessage(
0578: BasicInfoVisualPanel.class,
0579: "LBL_ProjectLocation"));
0580: gridBagConstraints = new java.awt.GridBagConstraints();
0581: gridBagConstraints.gridx = 0;
0582: gridBagConstraints.gridy = 1;
0583: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0584: gridBagConstraints.insets = new java.awt.Insets(6, 0, 6, 12);
0585: infoPanel.add(locationLbl, gridBagConstraints);
0586:
0587: folderLbl.setLabelFor(folderValue);
0588: org.openide.awt.Mnemonics.setLocalizedText(folderLbl,
0589: org.openide.util.NbBundle
0590: .getMessage(BasicInfoVisualPanel.class,
0591: "LBL_ProjectFolder"));
0592: gridBagConstraints = new java.awt.GridBagConstraints();
0593: gridBagConstraints.gridx = 0;
0594: gridBagConstraints.gridy = 2;
0595: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0596: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12);
0597: infoPanel.add(folderLbl, gridBagConstraints);
0598:
0599: nameValue.setHorizontalAlignment(javax.swing.JTextField.LEFT);
0600: gridBagConstraints = new java.awt.GridBagConstraints();
0601: gridBagConstraints.gridx = 1;
0602: gridBagConstraints.gridy = 0;
0603: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0604: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0605: gridBagConstraints.weightx = 1.0;
0606: infoPanel.add(nameValue, gridBagConstraints);
0607:
0608: locationValue
0609: .setHorizontalAlignment(javax.swing.JTextField.LEFT);
0610: gridBagConstraints = new java.awt.GridBagConstraints();
0611: gridBagConstraints.gridx = 1;
0612: gridBagConstraints.gridy = 1;
0613: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0614: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0615: gridBagConstraints.insets = new java.awt.Insets(6, 0, 6, 0);
0616: infoPanel.add(locationValue, gridBagConstraints);
0617:
0618: org.openide.awt.Mnemonics.setLocalizedText(browseButton,
0619: org.openide.util.NbBundle.getMessage(
0620: BasicInfoVisualPanel.class,
0621: "CTL_BrowseButton_o"));
0622: browseButton
0623: .addActionListener(new java.awt.event.ActionListener() {
0624: public void actionPerformed(
0625: java.awt.event.ActionEvent evt) {
0626: browseLocation(evt);
0627: }
0628: });
0629:
0630: gridBagConstraints = new java.awt.GridBagConstraints();
0631: gridBagConstraints.gridx = 2;
0632: gridBagConstraints.gridy = 1;
0633: gridBagConstraints.insets = new java.awt.Insets(6, 12, 6, 0);
0634: infoPanel.add(browseButton, gridBagConstraints);
0635:
0636: gridBagConstraints = new java.awt.GridBagConstraints();
0637: gridBagConstraints.gridx = 1;
0638: gridBagConstraints.gridy = 5;
0639: gridBagConstraints.weighty = 1.0;
0640: infoPanel.add(filler, gridBagConstraints);
0641:
0642: folderValue.setEditable(false);
0643: gridBagConstraints = new java.awt.GridBagConstraints();
0644: gridBagConstraints.gridx = 1;
0645: gridBagConstraints.gridy = 2;
0646: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0647: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0648: infoPanel.add(folderValue, gridBagConstraints);
0649:
0650: suitePlatform.setLabelFor(suitePlatformValue);
0651: org.openide.awt.Mnemonics.setLocalizedText(suitePlatform,
0652: org.openide.util.NbBundle.getMessage(
0653: BasicInfoVisualPanel.class,
0654: "LBL_NetBeansPlatform"));
0655: gridBagConstraints = new java.awt.GridBagConstraints();
0656: gridBagConstraints.gridx = 0;
0657: gridBagConstraints.gridy = 4;
0658: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0659: gridBagConstraints.insets = new java.awt.Insets(6, 0, 6, 12);
0660: infoPanel.add(suitePlatform, gridBagConstraints);
0661:
0662: gridBagConstraints = new java.awt.GridBagConstraints();
0663: gridBagConstraints.gridx = 1;
0664: gridBagConstraints.gridy = 4;
0665: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0666: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0667: gridBagConstraints.weightx = 1.0;
0668: gridBagConstraints.insets = new java.awt.Insets(6, 0, 6, 0);
0669: infoPanel.add(suitePlatformValue, gridBagConstraints);
0670:
0671: org.openide.awt.Mnemonics.setLocalizedText(manageSuitePlatform,
0672: org.openide.util.NbBundle.getMessage(
0673: BasicInfoVisualPanel.class,
0674: "CTL_ManagePlatforms_g"));
0675: manageSuitePlatform
0676: .addActionListener(new java.awt.event.ActionListener() {
0677: public void actionPerformed(
0678: java.awt.event.ActionEvent evt) {
0679: manageSuitePlatformActionPerformed(evt);
0680: }
0681: });
0682:
0683: gridBagConstraints = new java.awt.GridBagConstraints();
0684: gridBagConstraints.gridx = 2;
0685: gridBagConstraints.gridy = 4;
0686: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0687: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0688: gridBagConstraints.insets = new java.awt.Insets(6, 12, 6, 0);
0689: infoPanel.add(manageSuitePlatform, gridBagConstraints);
0690:
0691: gridBagConstraints = new java.awt.GridBagConstraints();
0692: gridBagConstraints.gridx = 0;
0693: gridBagConstraints.gridy = 3;
0694: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
0695: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0696: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0697: gridBagConstraints.insets = new java.awt.Insets(12, 0, 6, 0);
0698: infoPanel.add(separator3, gridBagConstraints);
0699:
0700: gridBagConstraints = new java.awt.GridBagConstraints();
0701: gridBagConstraints.gridx = 0;
0702: gridBagConstraints.gridy = 0;
0703: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0704: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0705: add(infoPanel, gridBagConstraints);
0706:
0707: mainProject.setSelected(true);
0708: org.openide.awt.Mnemonics.setLocalizedText(mainProject,
0709: org.openide.util.NbBundle.getMessage(
0710: BasicInfoVisualPanel.class,
0711: "CTL_SetAsMainProject"));
0712: mainProject
0713: .addActionListener(new java.awt.event.ActionListener() {
0714: public void actionPerformed(
0715: java.awt.event.ActionEvent evt) {
0716: mainProjectActionPerformed(evt);
0717: }
0718: });
0719:
0720: gridBagConstraints = new java.awt.GridBagConstraints();
0721: gridBagConstraints.gridx = 0;
0722: gridBagConstraints.gridy = 2;
0723: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0724: gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
0725: add(mainProject, gridBagConstraints);
0726:
0727: typeChooserPanel.setLayout(new java.awt.GridBagLayout());
0728:
0729: moduleTypeGroup.add(standAloneModule);
0730: standAloneModule.setSelected(true);
0731: org.openide.awt.Mnemonics.setLocalizedText(standAloneModule,
0732: org.openide.util.NbBundle.getMessage(
0733: BasicInfoVisualPanel.class,
0734: "CTL_StandaloneModule"));
0735: standAloneModule
0736: .addActionListener(new java.awt.event.ActionListener() {
0737: public void actionPerformed(
0738: java.awt.event.ActionEvent evt) {
0739: typeChanged(evt);
0740: }
0741: });
0742:
0743: gridBagConstraints = new java.awt.GridBagConstraints();
0744: gridBagConstraints.gridx = 0;
0745: gridBagConstraints.gridy = 0;
0746: gridBagConstraints.gridwidth = 3;
0747: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0748: gridBagConstraints.insets = new java.awt.Insets(0, 0, 6, 0);
0749: typeChooserPanel.add(standAloneModule, gridBagConstraints);
0750:
0751: platform.setLabelFor(platformValue);
0752: org.openide.awt.Mnemonics.setLocalizedText(platform,
0753: org.openide.util.NbBundle.getMessage(
0754: BasicInfoVisualPanel.class,
0755: "LBL_NetBeansPlatform"));
0756: gridBagConstraints = new java.awt.GridBagConstraints();
0757: gridBagConstraints.gridx = 0;
0758: gridBagConstraints.gridy = 1;
0759: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0760: gridBagConstraints.insets = new java.awt.Insets(0, 18, 0, 12);
0761: typeChooserPanel.add(platform, gridBagConstraints);
0762:
0763: platformValue
0764: .addActionListener(new java.awt.event.ActionListener() {
0765: public void actionPerformed(
0766: java.awt.event.ActionEvent evt) {
0767: platformChosen(evt);
0768: }
0769: });
0770:
0771: gridBagConstraints = new java.awt.GridBagConstraints();
0772: gridBagConstraints.gridx = 1;
0773: gridBagConstraints.gridy = 1;
0774: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0775: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0776: gridBagConstraints.weightx = 1.0;
0777: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12);
0778: typeChooserPanel.add(platformValue, gridBagConstraints);
0779:
0780: org.openide.awt.Mnemonics.setLocalizedText(managePlatform,
0781: org.openide.util.NbBundle.getMessage(
0782: BasicInfoVisualPanel.class,
0783: "CTL_ManagePlatforms_g"));
0784: managePlatform
0785: .addActionListener(new java.awt.event.ActionListener() {
0786: public void actionPerformed(
0787: java.awt.event.ActionEvent evt) {
0788: managePlatformActionPerformed(evt);
0789: }
0790: });
0791:
0792: gridBagConstraints = new java.awt.GridBagConstraints();
0793: gridBagConstraints.gridx = 2;
0794: gridBagConstraints.gridy = 1;
0795: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0796: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0797: typeChooserPanel.add(managePlatform, gridBagConstraints);
0798:
0799: moduleTypeGroup.add(suiteComponent);
0800: org.openide.awt.Mnemonics.setLocalizedText(suiteComponent,
0801: org.openide.util.NbBundle.getMessage(
0802: BasicInfoVisualPanel.class,
0803: "CTL_AddToModuleSuite"));
0804: suiteComponent
0805: .addActionListener(new java.awt.event.ActionListener() {
0806: public void actionPerformed(
0807: java.awt.event.ActionEvent evt) {
0808: typeChanged(evt);
0809: }
0810: });
0811:
0812: gridBagConstraints = new java.awt.GridBagConstraints();
0813: gridBagConstraints.gridx = 0;
0814: gridBagConstraints.gridy = 2;
0815: gridBagConstraints.gridwidth = 3;
0816: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0817: gridBagConstraints.insets = new java.awt.Insets(18, 0, 0, 0);
0818: typeChooserPanel.add(suiteComponent, gridBagConstraints);
0819:
0820: moduleSuite.setLabelFor(moduleSuiteValue);
0821: org.openide.awt.Mnemonics.setLocalizedText(moduleSuite,
0822: org.openide.util.NbBundle.getMessage(
0823: BasicInfoVisualPanel.class, "LBL_ModuleSuite"));
0824: gridBagConstraints = new java.awt.GridBagConstraints();
0825: gridBagConstraints.gridx = 0;
0826: gridBagConstraints.gridy = 3;
0827: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0828: gridBagConstraints.insets = new java.awt.Insets(6, 18, 0, 12);
0829: typeChooserPanel.add(moduleSuite, gridBagConstraints);
0830:
0831: moduleSuiteValue
0832: .addActionListener(new java.awt.event.ActionListener() {
0833: public void actionPerformed(
0834: java.awt.event.ActionEvent evt) {
0835: moduleSuiteChosen(evt);
0836: }
0837: });
0838:
0839: gridBagConstraints = new java.awt.GridBagConstraints();
0840: gridBagConstraints.gridx = 1;
0841: gridBagConstraints.gridy = 3;
0842: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0843: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0844: gridBagConstraints.weightx = 1.0;
0845: gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 12);
0846: typeChooserPanel.add(moduleSuiteValue, gridBagConstraints);
0847:
0848: org.openide.awt.Mnemonics.setLocalizedText(browseSuiteButton,
0849: org.openide.util.NbBundle.getMessage(
0850: BasicInfoVisualPanel.class,
0851: "CTL_BrowseButton_w"));
0852: browseSuiteButton
0853: .addActionListener(new java.awt.event.ActionListener() {
0854: public void actionPerformed(
0855: java.awt.event.ActionEvent evt) {
0856: browseModuleSuite(evt);
0857: }
0858: });
0859:
0860: gridBagConstraints = new java.awt.GridBagConstraints();
0861: gridBagConstraints.gridx = 2;
0862: gridBagConstraints.gridy = 3;
0863: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
0864: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
0865: gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
0866: typeChooserPanel.add(browseSuiteButton, gridBagConstraints);
0867:
0868: gridBagConstraints = new java.awt.GridBagConstraints();
0869: gridBagConstraints.gridx = 0;
0870: gridBagConstraints.gridy = 4;
0871: gridBagConstraints.weighty = 1.0;
0872: typeChooserPanel.add(chooserFiller, gridBagConstraints);
0873:
0874: gridBagConstraints = new java.awt.GridBagConstraints();
0875: gridBagConstraints.gridx = 0;
0876: gridBagConstraints.gridy = 1;
0877: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0878: add(typeChooserPanel, gridBagConstraints);
0879:
0880: gridBagConstraints = new java.awt.GridBagConstraints();
0881: gridBagConstraints.gridx = 0;
0882: gridBagConstraints.gridy = 3;
0883: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
0884: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
0885: gridBagConstraints.weightx = 1.0;
0886: gridBagConstraints.weighty = 1.0;
0887: add(pnlThouShaltBeholdLayout, gridBagConstraints);
0888:
0889: }// </editor-fold>//GEN-END:initComponents
0890:
0891: private void manageSuitePlatformActionPerformed(
0892: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_manageSuitePlatformActionPerformed
0893: managePlatform(suitePlatformValue);
0894: }//GEN-LAST:event_manageSuitePlatformActionPerformed
0895:
0896: private void mainProjectActionPerformed(
0897: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mainProjectActionPerformed
0898: mainProjectTouched = true;
0899: }//GEN-LAST:event_mainProjectActionPerformed
0900:
0901: private void managePlatformActionPerformed(
0902: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_managePlatformActionPerformed
0903: managePlatform(platformValue);
0904: }//GEN-LAST:event_managePlatformActionPerformed
0905:
0906: private void managePlatform(final JComboBox platformCombo) {
0907: NbPlatformCustomizer.showCustomizer();
0908: platformCombo
0909: .setModel(new PlatformComponentFactory.NbPlatformListModel()); // refresh
0910: platformCombo.requestFocus();
0911: updateAndCheck();
0912: }
0913:
0914: private void platformChosen(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_platformChosen
0915: updateAndCheck();
0916: }//GEN-LAST:event_platformChosen
0917:
0918: private void moduleSuiteChosen(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moduleSuiteChosen
0919: if (!locationUpdated) {
0920: String suite = (String) moduleSuiteValue.getSelectedItem();
0921: computeAndSetLocation(suite, true);
0922: lastSelectedSuite = suite;
0923: }
0924: updateAndCheck();
0925: }//GEN-LAST:event_moduleSuiteChosen
0926:
0927: private void browseModuleSuite(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseModuleSuite
0928: JFileChooser chooser = ProjectChooser.projectChooser();
0929: int option = chooser.showOpenDialog(this );
0930: if (option == JFileChooser.APPROVE_OPTION) {
0931: File projectDir = chooser.getSelectedFile();
0932: UIUtil.setProjectChooserDirParent(projectDir);
0933: try {
0934: Project suite = ProjectManager.getDefault()
0935: .findProject(FileUtil.toFileObject(projectDir));
0936: if (suite != null) {
0937: String suiteDir = SuiteUtils
0938: .getSuiteDirectoryPath(suite);
0939: if (suiteDir != null) {
0940: // register for this session
0941: PlatformComponentFactory.addUserSuite(suiteDir);
0942: // add to current combobox
0943: moduleSuiteValue.addItem(suiteDir);
0944: moduleSuiteValue.setSelectedItem(suiteDir);
0945: } else {
0946: DialogDisplayer
0947: .getDefault()
0948: .notify(
0949: new DialogDescriptor.Message(
0950: NbBundle
0951: .getMessage(
0952: BasicInfoVisualPanel.class,
0953: "MSG_NotRegularSuite",
0954: ProjectUtils
0955: .getInformation(
0956: suite)
0957: .getDisplayName())));
0958: }
0959: }
0960: } catch (IOException e) {
0961: ErrorManager.getDefault().notify(ErrorManager.WARNING,
0962: e);
0963: }
0964: }
0965: }//GEN-LAST:event_browseModuleSuite
0966:
0967: private void typeChanged(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_typeChanged
0968: if (!mainProjectTouched) {
0969: mainProject.setSelected(isStandAlone());
0970: }
0971: if (!locationUpdated) {
0972: setInitialLocation();
0973: }
0974: if (!nameUpdated) {
0975: setInitialProjectName();
0976: }
0977: updateAndCheck();
0978: }//GEN-LAST:event_typeChanged
0979:
0980: private void browseLocation(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseLocation
0981: JFileChooser chooser = new JFileChooser(getLocationValue());
0982: chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
0983: int ret = chooser.showOpenDialog(this );
0984: if (ret == JFileChooser.APPROVE_OPTION) {
0985: computeAndSetLocation(chooser.getSelectedFile()
0986: .getAbsolutePath(), false);
0987: }
0988: }//GEN-LAST:event_browseLocation
0989:
0990: // Variables declaration - do not modify//GEN-BEGIN:variables
0991: private javax.swing.JButton browseButton;
0992: private javax.swing.JButton browseSuiteButton;
0993: private javax.swing.JLabel chooserFiller;
0994: private javax.swing.JLabel filler;
0995: private javax.swing.JLabel folderLbl;
0996: private javax.swing.JTextField folderValue;
0997: private javax.swing.JPanel infoPanel;
0998: private javax.swing.JLabel locationLbl;
0999: private javax.swing.JTextField locationValue;
1000: private javax.swing.JCheckBox mainProject;
1001: private javax.swing.JButton managePlatform;
1002: private javax.swing.JButton manageSuitePlatform;
1003: private javax.swing.JLabel moduleSuite;
1004: private javax.swing.JComboBox moduleSuiteValue;
1005: private javax.swing.ButtonGroup moduleTypeGroup;
1006: private javax.swing.JLabel nameLbl;
1007: javax.swing.JTextField nameValue;
1008: private javax.swing.JLabel platform;
1009: private javax.swing.JComboBox platformValue;
1010: private javax.swing.JPanel pnlThouShaltBeholdLayout;
1011: private javax.swing.JSeparator separator3;
1012: private javax.swing.JRadioButton standAloneModule;
1013: private javax.swing.JRadioButton suiteComponent;
1014: private javax.swing.JLabel suitePlatform;
1015: private javax.swing.JComboBox suitePlatformValue;
1016: private javax.swing.JPanel typeChooserPanel;
1017: // End of variables declaration//GEN-END:variables
1018:
1019: }
|