1 19 20 package org.netbeans.modules.ruby.railsprojects.ui.wizards; 21 22 import java.io.File ; 23 import javax.swing.JPanel ; 24 import javax.swing.event.DocumentEvent ; 25 import javax.swing.event.DocumentListener ; 26 import javax.swing.text.Document ; 27 import org.netbeans.modules.ruby.rubyproject.api.RubyInstallation; 28 import org.openide.WizardDescriptor; 29 import org.openide.WizardValidationException; 30 import org.openide.util.NbBundle; 31 import org.openide.util.Utilities; 32 33 38 public class PanelConfigureProjectVisual extends JPanel { 39 40 private PanelConfigureProject panel; 41 42 private boolean ignoreProjectDirChanges; 43 44 private boolean ignoreRakeProjectNameChanges; 45 46 private boolean noDir = true; 47 48 private SettingsPanel projectLocationPanel; 49 50 private PanelOptionsVisual optionsPanel; 51 52 private int type; 53 54 55 public PanelConfigureProjectVisual( PanelConfigureProject panel, int type ) { 56 this.panel = panel; 57 initComponents(); 58 this.type = type; 59 setName(NbBundle.getMessage(PanelConfigureProjectVisual.class,"TXT_NameAndLoc")); if (type == NewRailsProjectWizardIterator.TYPE_APP) { 61 projectLocationPanel = new PanelProjectLocationVisual( panel, type ); 62 putClientProperty ("NewProjectWizard_Title", NbBundle.getMessage(PanelConfigureProjectVisual.class,"TXT_NewJavaApp")); jSeparator1.setVisible(true); 64 getAccessibleContext ().setAccessibleName (NbBundle.getMessage(PanelConfigureProjectVisual.class,"TXT_NewJavaApp")); getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage(PanelConfigureProjectVisual.class,"ACSD_NewJavaApp")); } 67 else { 75 projectLocationPanel = new PanelProjectLocationExtSrc ( panel ); 76 jSeparator1.setVisible(true); 77 putClientProperty ("NewProjectWizard_Title", NbBundle.getMessage(PanelConfigureProjectVisual.class,"TXT_JavaExtSourcesProjectLocation")); getAccessibleContext ().setAccessibleName (NbBundle.getMessage(PanelConfigureProjectVisual.class,"TXT_JavaExtSourcesProjectLocation")); getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage(PanelConfigureProjectVisual.class,"ACSD_JavaExtSourcesProjectLocation")); } 81 locationContainer.add( projectLocationPanel, java.awt.BorderLayout.CENTER ); 82 optionsPanel = new PanelOptionsVisual( panel, type ); 83 projectLocationPanel.addPropertyChangeListener(optionsPanel); 84 optionsContainer.add( optionsPanel, java.awt.BorderLayout.CENTER ); 85 } 86 87 boolean valid( WizardDescriptor wizardDescriptor ) { 88 if (Utilities.isWindows()) { 91 String rails = RubyInstallation.getInstance().getRails(); 92 if (rails.indexOf(' ') != -1) { 93 wizardDescriptor.putProperty("WizardPanel_errorMessage", "Rails path contains spaces; fails on Windows.\n " + rails); 94 } 96 } 97 98 99 wizardDescriptor.putProperty( "WizardPanel_errorMessage", "" ); return projectLocationPanel.valid( wizardDescriptor ) && optionsPanel.valid(wizardDescriptor); 101 } 102 103 void read (WizardDescriptor d) { 104 Integer lastType = (Integer ) d.getProperty("rails-wizard-type"); if (lastType == null || lastType.intValue() != this.type) { 106 d.putProperty ("name", null); 108 d.putProperty ("projdir",null); 109 } 110 projectLocationPanel.read (d); 111 optionsPanel.read (d); 112 } 113 114 void store( WizardDescriptor d ) { 115 d.putProperty("rails-wizard-type", new Integer (this.type)); projectLocationPanel.store( d ); 117 optionsPanel.store( d ); 118 } 119 120 void validate (WizardDescriptor d) throws WizardValidationException { 121 projectLocationPanel.validate (d); 122 } 123 124 125 130 private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; 132 133 locationContainer = new javax.swing.JPanel (); 134 jSeparator1 = new javax.swing.JSeparator (); 135 optionsContainer = new javax.swing.JPanel (); 136 137 setLayout(new java.awt.GridBagLayout ()); 138 139 locationContainer.setLayout(new java.awt.BorderLayout ()); 140 141 gridBagConstraints = new java.awt.GridBagConstraints (); 142 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 143 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 144 gridBagConstraints.weightx = 1.0; 145 add(locationContainer, gridBagConstraints); 146 locationContainer.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getBundle(PanelConfigureProjectVisual.class).getString("ACSN_locationContainer")); 147 locationContainer.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(PanelConfigureProjectVisual.class).getString("ACSD_locationContainer")); 148 149 gridBagConstraints = new java.awt.GridBagConstraints (); 150 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 151 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 152 gridBagConstraints.weightx = 1.0; 153 gridBagConstraints.insets = new java.awt.Insets (12, 0, 12, 0); 154 add(jSeparator1, gridBagConstraints); 155 156 optionsContainer.setLayout(new java.awt.BorderLayout ()); 157 158 gridBagConstraints = new java.awt.GridBagConstraints (); 159 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 160 gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; 161 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 162 gridBagConstraints.weightx = 1.0; 163 gridBagConstraints.weighty = 1.0; 164 add(optionsContainer, gridBagConstraints); 165 optionsContainer.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getBundle(PanelConfigureProjectVisual.class).getString("ACSN_optionsContainer")); 166 optionsContainer.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getBundle(PanelConfigureProjectVisual.class).getString("ACSD_optionsContainer")); 167 168 } 170 172 173 private javax.swing.JSeparator jSeparator1; 175 private javax.swing.JPanel locationContainer; 176 private javax.swing.JPanel optionsContainer; 177 179 180 } 181 | Popular Tags |