/* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved. * * Oracle and Java are registered trademarks of Oracle and/or its affiliates. * Other names may be trademarks of their respective owners. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common * Development and Distribution License("CDDL") (collectively, the * "License"). You may not use this file except in compliance with the * License. You can obtain a copy of the License at * http://www.netbeans.org/cddl-gplv2.html * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the * specific language governing permissions and limitations under the * License. When distributing the software, include this License Header * Notice in each file and include the License file at * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this * particular file as subject to the "Classpath" exception as provided * by Oracle in the GPL Version 2 section of the License file that * accompanied this code. If applicable, add the following below the * License Header, with the fields enclosed by brackets [] replaced by * your own identifying information: * "Portions Copyrighted [year] [name of copyright owner]" * * Contributor(s): * * The Original Software is NetBeans. The Initial Developer of the Original * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun * Microsystems, Inc. All Rights Reserved. * * If you wish your version of this file to be governed by only the CDDL * or only the GPL Version 2, indicate your decision by adding * "[Contributor] elects to include this software in this distribution * under the [CDDL or GPL Version 2] license." If you do not indicate a * single choice of license, a recipient has the option to distribute * your version of this file under either the CDDL, the GPL Version 2 or * to extend the choice of license to its licensees as provided above. * However, if you add GPL Version 2 code and therefore, elected the GPL * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ package org.netbeans.modules.ruby.merbproject.ui.wizards; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import org.netbeans.modules.ruby.platform.PlatformComponentFactory; import org.netbeans.modules.ruby.platform.RubyPlatformCustomizer; import org.netbeans.modules.ruby.merbproject.ui.wizards.NewMerbProjectWizardIterator.Type; import org.netbeans.modules.ruby.rubyproject.Util; import org.openide.WizardDescriptor; import org.openide.WizardValidationException; import org.openide.util.NbBundle; import org.openide.util.Utilities; public final class PanelOptionsVisual extends SettingsPanel implements ActionListener, PropertyChangeListener { private final PanelConfigureProject panel; private boolean valid; PanelOptionsVisual(PanelConfigureProject panel, Type type) { initComponents(); appTypeButtonGroup.add(standard); appTypeButtonGroup.add(flat); appTypeButtonGroup.add(veryFlat); standard.setSelected(true); Util.preselectWizardPlatform(platforms); this.panel = panel; fireChangeEvent(); PlatformComponentFactory.addPlatformChangeListener(platforms, new PlatformComponentFactory.PlatformChangeListener() { public void platformChanged() { fireChangeEvent(); } }); } public @Override void removeNotify() { Util.storeWizardPlatform(platforms); super.removeNotify(); } public void actionPerformed( ActionEvent e ) { } public void propertyChange (PropertyChangeEvent event) { if ("roots".equals(event.getPropertyName())) { fireChangeEvent(); } if (PanelProjectLocationVisual.PROP_PROJECT_NAME.equals(event.getPropertyName())) { String newProjectName = NewMerbProjectWizardIterator.getPackageName((String) event.getNewValue()); if (!Utilities.isJavaIdentifier(newProjectName)) { newProjectName = NbBundle.getMessage (PanelOptionsVisual.class, "TXT_PackageNameSuffix", newProjectName); } } } private void fireChangeEvent() { this.panel.fireChangeEvent(); } /** 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. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { appTypeButtonGroup = new javax.swing.ButtonGroup(); rubyPlatformLabel = new javax.swing.JLabel(); platforms = org.netbeans.modules.ruby.platform.PlatformComponentFactory.getRubyPlatformsComboxBox(); manageButton = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); standard = new javax.swing.JRadioButton(); flat = new javax.swing.JRadioButton(); veryFlat = new javax.swing.JRadioButton(); rubyPlatformLabel.setLabelFor(platforms); org.openide.awt.Mnemonics.setLocalizedText(rubyPlatformLabel, org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "RubyPlatformLabel")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(manageButton, org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "RubyHomeBrowse")); // NOI18N manageButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { manageButtonActionPerformed(evt); } }); org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "PanelOptionsVisual.jLabel1.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(standard, org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "PanelOptionsVisual.standard.text")); // NOI18N standard.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { standardActionPerformed(evt); } }); org.openide.awt.Mnemonics.setLocalizedText(flat, org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "PanelOptionsVisual.flat.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(veryFlat, org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "PanelOptionsVisual.veryFlat.text")); // NOI18N org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(jLabel1) .add(18, 18, 18) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(flat) .add(standard) .add(veryFlat)) .add(327, 327, 327)) .add(layout.createSequentialGroup() .add(rubyPlatformLabel) .add(27, 27, 27) .add(platforms, 0, 323, Short.MAX_VALUE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(manageButton) .addContainerGap()))) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel1) .add(standard)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(flat) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(veryFlat) .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(rubyPlatformLabel) .add(manageButton) .add(platforms, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); rubyPlatformLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "PanelOptionsVisual.rubyPlatformLabel.AccessibleContext.accessibleDescription")); // NOI18N manageButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "PanelOptionsVisual.manageButton.AccessibleContext.accessibleDescription")); // NOI18N getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "ACSN_PanelOptionsVisual")); // NOI18N getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(PanelOptionsVisual.class, "ACSD_PanelOptionsVisual")); // NOI18N }// </editor-fold>//GEN-END:initComponents private void manageButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_manageButtonActionPerformed RubyPlatformCustomizer.manage(platforms); }//GEN-LAST:event_manageButtonActionPerformed private void standardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_standardActionPerformed // TODO add your handling code here: }//GEN-LAST:event_standardActionPerformed boolean valid(WizardDescriptor settings) { if (PlatformComponentFactory.getPlatform(platforms) == null) { return false; } return true; } void read(WizardDescriptor d) { } void validate (WizardDescriptor d) throws WizardValidationException { // nothing to validate } void store( WizardDescriptor d ) { d.putProperty( /*XXX Define somewhere */ "setAsMain", Boolean.FALSE); // NOI18N d.putProperty("platform", PlatformComponentFactory.getPlatform(platforms)); d.putProperty("appType", getAppType()); } private String getAppType() { if (flat.isSelected()) { return "--flat"; //NOI18N } if (veryFlat.isSelected()) { return "--very-flat"; //NOI18N } return ""; //NOI18N } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.ButtonGroup appTypeButtonGroup; private javax.swing.JRadioButton flat; private javax.swing.JLabel jLabel1; private javax.swing.JButton manageButton; private javax.swing.JComboBox platforms; private javax.swing.JLabel rubyPlatformLabel; private javax.swing.JRadioButton standard; private javax.swing.JRadioButton veryFlat; // End of variables declaration//GEN-END:variables }