Lines 42-53
Link Here
|
42 |
|
42 |
|
43 |
package org.netbeans.modules.vmd.componentssupport.ui.wizard; |
43 |
package org.netbeans.modules.vmd.componentssupport.ui.wizard; |
44 |
|
44 |
|
|
|
45 |
import java.awt.BorderLayout; |
46 |
import java.awt.Component; |
47 |
import java.awt.GridBagConstraints; |
48 |
import java.awt.event.ActionEvent; |
49 |
import java.awt.event.ActionListener; |
50 |
import java.beans.PropertyChangeEvent; |
51 |
import java.beans.PropertyChangeListener; |
45 |
import java.io.File; |
52 |
import java.io.File; |
46 |
import javax.swing.JFileChooser; |
53 |
import javax.swing.JFileChooser; |
47 |
import javax.swing.JPanel; |
54 |
import javax.swing.JPanel; |
48 |
import javax.swing.event.DocumentEvent; |
55 |
import javax.swing.event.DocumentEvent; |
49 |
import javax.swing.event.DocumentListener; |
56 |
import javax.swing.event.DocumentListener; |
50 |
import javax.swing.text.Document; |
57 |
import javax.swing.text.Document; |
|
|
58 |
import org.netbeans.modules.apisupport.project.ui.wizard.spi.ModuleTypeChooserPanelExt; |
51 |
import org.netbeans.spi.project.ui.support.ProjectChooser; |
59 |
import org.netbeans.spi.project.ui.support.ProjectChooser; |
52 |
import org.openide.WizardDescriptor; |
60 |
import org.openide.WizardDescriptor; |
53 |
import org.openide.WizardValidationException; |
61 |
import org.openide.WizardValidationException; |
Lines 55-61
Link Here
|
55 |
import org.openide.util.HelpCtx; |
63 |
import org.openide.util.HelpCtx; |
56 |
import org.openide.util.NbBundle; |
64 |
import org.openide.util.NbBundle; |
57 |
|
65 |
|
58 |
class CustomComponentVisualPanel extends JPanel implements DocumentListener { |
66 |
class CustomComponentVisualPanel extends JPanel { |
59 |
|
67 |
|
60 |
public static final String PROP_PROJECT_NAME = "projectName"; |
68 |
public static final String PROP_PROJECT_NAME = "projectName"; |
61 |
public static final String BROWSE = "BROWSE"; |
69 |
public static final String BROWSE = "BROWSE"; |
Lines 76-111
Link Here
|
76 |
|
84 |
|
77 |
public CustomComponentVisualPanel(CustomComponentWizardPanel panel) { |
85 |
public CustomComponentVisualPanel(CustomComponentWizardPanel panel) { |
78 |
initComponents(); |
86 |
initComponents(); |
|
|
87 |
initPanels(); |
79 |
this.myPanel = panel; |
88 |
this.myPanel = panel; |
|
|
89 |
|
80 |
putClientProperty("NewProjectWizard_Title", NbBundle.getMessage(CustomComponentVisualPanel.class, "TXT_MobileDesigner")); |
90 |
putClientProperty("NewProjectWizard_Title", NbBundle.getMessage(CustomComponentVisualPanel.class, "TXT_MobileDesigner")); |
81 |
// Register listener on the textFields to make the automatic updates |
91 |
initDocumentListeners(); |
82 |
projectNameTextField.getDocument().addDocumentListener(this); |
92 |
attachDocumentListeners(); |
83 |
projectLocationTextField.getDocument().addDocumentListener(this); |
|
|
84 |
|
93 |
|
85 |
initAccessibility();; |
94 |
initAccessibility(); |
86 |
} |
95 |
} |
87 |
|
96 |
|
88 |
@Override |
97 |
@Override |
89 |
public void addNotify() { |
98 |
public void addNotify() { |
90 |
super.addNotify(); |
99 |
super.addNotify(); |
|
|
100 |
attachDocumentListeners(); |
91 |
//same problem as in 31086, initial focus on Cancel button |
101 |
//same problem as in 31086, initial focus on Cancel button |
92 |
projectNameTextField.requestFocus(); |
102 |
projectNameTextField.requestFocus(); |
93 |
} |
103 |
} |
94 |
|
104 |
|
95 |
// Implementation of DocumentListener -------------------------------------- |
105 |
@Override |
96 |
public void changedUpdate(DocumentEvent e) { |
106 |
public void removeNotify() { |
97 |
updateTexts(e); |
107 |
// prevent checking when the panel is not "active" |
98 |
checkValidity(); |
108 |
removeDocumentListeners(); |
|
|
109 |
super.removeNotify(); |
99 |
} |
110 |
} |
100 |
|
|
|
101 |
public void insertUpdate(DocumentEvent e) { |
102 |
changedUpdate(e); |
103 |
} |
104 |
|
105 |
public void removeUpdate(DocumentEvent e) { |
106 |
changedUpdate(e); |
107 |
} |
108 |
// ------------- |
109 |
|
111 |
|
110 |
void store(WizardDescriptor d) { |
112 |
void store(WizardDescriptor d) { |
111 |
String name = projectNameTextField.getText().trim(); |
113 |
String name = projectNameTextField.getText().trim(); |
Lines 115-130
Link Here
|
115 |
d.putProperty(CustomComponentWizardIterator.PROJECT_DIR, new File(folder)); |
117 |
d.putProperty(CustomComponentWizardIterator.PROJECT_DIR, new File(folder)); |
116 |
d.putProperty(CustomComponentWizardIterator.PROJECT_NAME, name); |
118 |
d.putProperty(CustomComponentWizardIterator.PROJECT_NAME, name); |
117 |
d.putProperty(CustomComponentWizardIterator.SET_AS_MAIN, setAsMain); |
119 |
d.putProperty(CustomComponentWizardIterator.SET_AS_MAIN, setAsMain); |
|
|
120 |
|
121 |
typeChooserPanel.store(d); |
118 |
} |
122 |
} |
119 |
|
123 |
|
120 |
void read(WizardDescriptor settings) { |
124 |
void read(WizardDescriptor settings) { |
121 |
mySettings = settings; |
125 |
mySettings = settings; |
122 |
|
126 |
|
|
|
127 |
typeChooserPanel.read(mySettings); |
128 |
// invoke store to have changes in mySettings |
129 |
typeChooserPanel.store(mySettings); |
130 |
|
123 |
if (getIsMainProject() != null){ |
131 |
if (getIsMainProject() != null){ |
124 |
this.mainProject.setSelected(getIsMainProject()); |
132 |
this.mainProject.setSelected(getIsMainProject()); |
125 |
} |
133 |
} |
126 |
this.projectLocationTextField.setText( |
134 |
setLocation(getProjectLocation().getAbsolutePath()); |
127 |
getProjectLocation().getAbsolutePath()); |
|
|
128 |
|
135 |
|
129 |
this.projectNameTextField.setText(getProjectName()); |
136 |
this.projectNameTextField.setText(getProjectName()); |
130 |
this.projectNameTextField.selectAll(); |
137 |
this.projectNameTextField.selectAll(); |
Lines 134-139
Link Here
|
134 |
return new HelpCtx(CustomComponentVisualPanel.class); |
141 |
return new HelpCtx(CustomComponentVisualPanel.class); |
135 |
} |
142 |
} |
136 |
|
143 |
|
|
|
144 |
private void initDocumentListeners() { |
145 |
nameDL = new DocumentAdapter() { |
146 |
public void insertUpdate(DocumentEvent e) { |
147 |
updateTexts(e); |
148 |
checkValidity(); |
149 |
} |
150 |
}; |
151 |
locationDL = new DocumentAdapter() { |
152 |
public void insertUpdate(DocumentEvent e) { |
153 |
locationUpdated = true; |
154 |
updateTexts(e); |
155 |
checkValidity(); |
156 |
} |
157 |
}; |
158 |
isMainAL = new ActionListener() { |
159 |
public void actionPerformed(ActionEvent e) { |
160 |
mainProjectTouched = true; |
161 |
} |
162 |
}; |
163 |
} |
164 |
|
165 |
private void attachDocumentListeners() { |
166 |
if (!listenersAttached) { |
167 |
projectNameTextField.getDocument().addDocumentListener(nameDL); |
168 |
projectLocationTextField.getDocument().addDocumentListener(locationDL); |
169 |
mainProject.addActionListener(isMainAL); |
170 |
listenersAttached = true; |
171 |
} |
172 |
} |
173 |
|
174 |
private void removeDocumentListeners() { |
175 |
if (listenersAttached) { |
176 |
projectNameTextField.getDocument().removeDocumentListener(nameDL); |
177 |
projectLocationTextField.getDocument().removeDocumentListener(locationDL); |
178 |
mainProject.removeActionListener(isMainAL); |
179 |
listenersAttached = false; |
180 |
} |
181 |
} |
182 |
|
183 |
private void initPanels(){ |
184 |
if (typeChooserPanel != null){ |
185 |
typeChooserPanelContainer.removeAll(); |
186 |
typeChooserPanel = null; |
187 |
} |
188 |
typeChooserPanel = ModuleTypeChooserPanelExt.PanelCreator.create(); |
189 |
Component component = typeChooserPanel.getComponent(); |
190 |
typeChooserPanelContainer.add(component, BorderLayout.CENTER); |
191 |
typeChooserPanelContainer.validate(); |
192 |
validate(); |
193 |
|
194 |
typeChooserPanel.addPropertyChangeListener(new PropertyChangeListener() { |
195 |
public void propertyChange(PropertyChangeEvent evt) { |
196 |
String name = evt.getPropertyName(); |
197 |
Object value = evt.getNewValue(); |
198 |
|
199 |
typeChooserPanel.store(getSettings()); |
200 |
|
201 |
if (ModuleTypeChooserPanelExt.IS_STANDALONE.equals(name)) { |
202 |
standAloneModuletypeChanged(value); |
203 |
} else if (ModuleTypeChooserPanelExt.IS_SUITE_COMPONENT.equals(name)) { |
204 |
suiteComponenttypeChanged(value); |
205 |
} else if (ModuleTypeChooserPanelExt.SUITE_ROOT.equals(name)) { |
206 |
moduleSuiteValueChanged(value); |
207 |
} |
208 |
checkValidity(); |
209 |
} |
210 |
}); |
211 |
} |
212 |
|
213 |
private void moduleSuiteValueChanged(Object val) { |
214 |
String suite = null; |
215 |
if (val != null && val instanceof String){ |
216 |
suite = (String)val; |
217 |
} |
218 |
if (!locationUpdated) { |
219 |
setLocation(computeLocationValue(suite)); |
220 |
} |
221 |
} |
222 |
|
223 |
private void suiteComponenttypeChanged(Object val) { |
224 |
Boolean isSuiteComp = false; |
225 |
if (val != null && val instanceof Boolean){ |
226 |
isSuiteComp = ((Boolean)val).booleanValue(); |
227 |
} |
228 |
|
229 |
if (!mainProjectTouched) { |
230 |
mainProject.setSelected(!isSuiteComp); |
231 |
} |
232 |
if (!locationUpdated) { |
233 |
setLocation(computeInitialLocationValue()); |
234 |
} |
235 |
} |
236 |
|
237 |
private void standAloneModuletypeChanged(Object val) { |
238 |
Boolean isStandAlone = false; |
239 |
if (val != null && val instanceof Boolean){ |
240 |
isStandAlone = ((Boolean)val).booleanValue(); |
241 |
} |
242 |
|
243 |
if (!mainProjectTouched) { |
244 |
mainProject.setSelected(isStandAlone); |
245 |
} |
246 |
if (!locationUpdated) { |
247 |
setLocation(computeInitialLocationValue()); |
248 |
} |
249 |
} |
250 |
|
251 |
private void setLocation(String location) { |
252 |
boolean revert = !locationUpdated; |
253 |
projectLocationTextField.setText(location); |
254 |
locationUpdated = revert ^ true; |
255 |
} |
256 |
|
257 |
boolean checkValidity() { |
258 |
if (!isProjectNameValid()){ |
259 |
return false; |
260 |
} else if (!isProjectLocationValid()){ |
261 |
return false; |
262 |
} else if (!isCreatedFolderValid()){ |
263 |
return false; |
264 |
} else if (!typeChooserPanel.validate(getSettings())){ |
265 |
return false; |
266 |
} |
267 |
|
268 |
markValid(); |
269 |
return true; |
270 |
} |
271 |
|
137 |
private boolean isProjectNameValid(){ |
272 |
private boolean isProjectNameValid(){ |
138 |
if (getProjectNameValue().trim().length() == 0) { |
273 |
if (getProjectNameValue().trim().length() == 0) { |
139 |
setError(getMessage(MSG_NAME_CANNOT_BE_EMPTY)); |
274 |
setError(getMessage(MSG_NAME_CANNOT_BE_EMPTY)); |
Lines 187-207
Link Here
|
187 |
return true; |
322 |
return true; |
188 |
} |
323 |
} |
189 |
|
324 |
|
190 |
// TODO |
|
|
191 |
boolean checkValidity() { |
192 |
if (!isProjectNameValid()){ |
193 |
return false; |
194 |
} else if (!isProjectLocationValid()){ |
195 |
return false; |
196 |
} else if (!isCreatedFolderValid()){ |
197 |
return false; |
198 |
} |
199 |
|
200 |
|
201 |
markValid(); |
202 |
return true; |
203 |
} |
204 |
|
205 |
private String getProjectNameValue(){ |
325 |
private String getProjectNameValue(){ |
206 |
return projectNameTextField.getText(); |
326 |
return projectNameTextField.getText(); |
207 |
} |
327 |
} |
Lines 232-238
Link Here
|
232 |
} |
352 |
} |
233 |
|
353 |
|
234 |
private final void setMessage(String message) { |
354 |
private final void setMessage(String message) { |
235 |
mySettings.putProperty( |
355 |
getSettings().putProperty( |
236 |
CustomComponentWizardIterator.WIZARD_PANEL_ERROR_MESSAGE, |
356 |
CustomComponentWizardIterator.WIZARD_PANEL_ERROR_MESSAGE, |
237 |
message); |
357 |
message); |
238 |
} |
358 |
} |
Lines 252-271
Link Here
|
252 |
* @return File Directory that will contain project folder |
372 |
* @return File Directory that will contain project folder |
253 |
*/ |
373 |
*/ |
254 |
File getProjectLocation(){ |
374 |
File getProjectLocation(){ |
255 |
File projectLocation = (File) mySettings |
375 |
File projectLocation = (File) getSettings() |
256 |
.getProperty(CustomComponentWizardIterator.PROJECT_DIR); |
376 |
.getProperty(CustomComponentWizardIterator.PROJECT_DIR); |
257 |
// project directory |
377 |
// project directory |
258 |
if (projectLocation == null |
378 |
if (projectLocation == null |
259 |
|| projectLocation.getParentFile() == null |
379 |
|| projectLocation.getParentFile() == null |
260 |
|| !projectLocation.getParentFile().isDirectory()) |
380 |
|| !projectLocation.getParentFile().isDirectory()) |
261 |
{ |
381 |
{ |
262 |
projectLocation = ProjectChooser.getProjectsFolder(); |
382 |
projectLocation = new File(computeInitialLocationValue()); |
263 |
} else { |
383 |
} else { |
264 |
projectLocation = projectLocation.getParentFile(); |
384 |
projectLocation = projectLocation.getParentFile(); |
265 |
} |
385 |
} |
266 |
return projectLocation; |
386 |
return projectLocation; |
267 |
} |
387 |
} |
268 |
|
388 |
|
|
|
389 |
private String computeInitialLocationValue(){ |
390 |
if (typeChooserPanel != null && isSuiteComponent()) { |
391 |
return computeLocationValue(getSelectedSuite()); |
392 |
} else { |
393 |
String path = ProjectChooser.getProjectsFolder().getAbsolutePath(); |
394 |
return computeLocationValue(path); |
395 |
} |
396 |
} |
397 |
|
398 |
private String computeLocationValue(String value) { |
399 |
if (value == null) { |
400 |
value = System.getProperty("user.home"); // NOI18N |
401 |
} |
402 |
File file = new File(value); |
403 |
if (!file.exists() && file.getParent() != null) { |
404 |
return computeLocationValue(file.getParent()); |
405 |
} else { |
406 |
return file.exists() ? value : System.getProperty("user.home"); // NOI18N |
407 |
} |
408 |
} |
409 |
|
410 |
private Boolean isSuiteComponent(){ |
411 |
Boolean result = (Boolean)getSettings().getProperty(ModuleTypeChooserPanelExt.IS_SUITE_COMPONENT); |
412 |
return result != null ? result : false; |
413 |
} |
414 |
|
415 |
private String getSelectedSuite(){ |
416 |
return (String)getSettings().getProperty(ModuleTypeChooserPanelExt.SUITE_ROOT); |
417 |
} |
418 |
|
269 |
/** |
419 |
/** |
270 |
* Returns project name value stored in WizardDescriptor, or |
420 |
* Returns project name value stored in WizardDescriptor, or |
271 |
* default value if it wasn't stored yet |
421 |
* default value if it wasn't stored yet |
Lines 274-280
Link Here
|
274 |
* name wich is not used as directory name in project location directory yet. |
424 |
* name wich is not used as directory name in project location directory yet. |
275 |
*/ |
425 |
*/ |
276 |
String getProjectName(){ |
426 |
String getProjectName(){ |
277 |
String projectName = (String) mySettings |
427 |
String projectName = (String) getSettings() |
278 |
.getProperty(CustomComponentWizardIterator.PROJECT_NAME); |
428 |
.getProperty(CustomComponentWizardIterator.PROJECT_NAME); |
279 |
// project name |
429 |
// project name |
280 |
if (projectName == null) { |
430 |
if (projectName == null) { |
Lines 284-290
Link Here
|
284 |
} |
434 |
} |
285 |
|
435 |
|
286 |
Boolean getIsMainProject(){ |
436 |
Boolean getIsMainProject(){ |
287 |
Boolean isMain = (Boolean) mySettings |
437 |
Boolean isMain = (Boolean) getSettings() |
288 |
.getProperty(CustomComponentWizardIterator.SET_AS_MAIN); |
438 |
.getProperty(CustomComponentWizardIterator.SET_AS_MAIN); |
289 |
return isMain; |
439 |
return isMain; |
290 |
} |
440 |
} |
Lines 304-324
Link Here
|
304 |
*/ |
454 |
*/ |
305 |
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
455 |
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents |
306 |
private void initComponents() { |
456 |
private void initComponents() { |
|
|
457 |
java.awt.GridBagConstraints gridBagConstraints; |
307 |
|
458 |
|
|
|
459 |
mainProject = new javax.swing.JCheckBox(); |
460 |
infoPanel = new javax.swing.JPanel(); |
308 |
projectNameLabel = new javax.swing.JLabel(); |
461 |
projectNameLabel = new javax.swing.JLabel(); |
309 |
projectNameTextField = new javax.swing.JTextField(); |
462 |
projectNameTextField = new javax.swing.JTextField(); |
|
|
463 |
createdFolderTextField = new javax.swing.JTextField(); |
310 |
projectLocationLabel = new javax.swing.JLabel(); |
464 |
projectLocationLabel = new javax.swing.JLabel(); |
|
|
465 |
createdFolderLabel = new javax.swing.JLabel(); |
311 |
projectLocationTextField = new javax.swing.JTextField(); |
466 |
projectLocationTextField = new javax.swing.JTextField(); |
312 |
browseButton = new javax.swing.JButton(); |
467 |
browseButton = new javax.swing.JButton(); |
313 |
createdFolderLabel = new javax.swing.JLabel(); |
468 |
typeChooserPanelContainer = new javax.swing.JPanel(); |
314 |
createdFolderTextField = new javax.swing.JTextField(); |
469 |
fillerPanel = new javax.swing.JPanel(); |
315 |
mainProject = new javax.swing.JCheckBox(); |
470 |
|
|
|
471 |
setLayout(new java.awt.GridBagLayout()); |
472 |
|
473 |
mainProject.setSelected(true); |
474 |
org.openide.awt.Mnemonics.setLocalizedText(mainProject, org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "LBL_SetAsMainProject")); // NOI18N |
475 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
476 |
gridBagConstraints.gridx = 0; |
477 |
gridBagConstraints.gridy = 2; |
478 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
479 |
gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0); |
480 |
add(mainProject, gridBagConstraints); |
481 |
mainProject.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "ACSN_SetAsMainProject")); // NOI18N |
482 |
mainProject.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "ACSD_SetAsMainProject")); // NOI18N |
483 |
|
484 |
infoPanel.setLayout(new java.awt.GridBagLayout()); |
316 |
|
485 |
|
317 |
projectNameLabel.setLabelFor(projectNameTextField); |
486 |
projectNameLabel.setLabelFor(projectNameTextField); |
318 |
org.openide.awt.Mnemonics.setLocalizedText(projectNameLabel, org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "LBL_ProjectName")); // NOI18N |
487 |
org.openide.awt.Mnemonics.setLocalizedText(projectNameLabel, org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "LBL_ProjectName")); // NOI18N |
|
|
488 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
489 |
gridBagConstraints.gridx = 0; |
490 |
gridBagConstraints.gridy = 0; |
491 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
492 |
gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12); |
493 |
infoPanel.add(projectNameLabel, gridBagConstraints); |
494 |
projectNameLabel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "ACSN_ProjectName")); // NOI18N |
495 |
projectNameLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "ACSD_ProjectName")); // NOI18N |
496 |
|
497 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
498 |
gridBagConstraints.gridx = 1; |
499 |
gridBagConstraints.gridy = 0; |
500 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
501 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
502 |
gridBagConstraints.weightx = 1.0; |
503 |
infoPanel.add(projectNameTextField, gridBagConstraints); |
504 |
|
505 |
createdFolderTextField.setEditable(false); |
506 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
507 |
gridBagConstraints.gridx = 1; |
508 |
gridBagConstraints.gridy = 2; |
509 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
510 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
511 |
gridBagConstraints.insets = new java.awt.Insets(0, 0, 6, 0); |
512 |
infoPanel.add(createdFolderTextField, gridBagConstraints); |
319 |
|
513 |
|
320 |
projectLocationLabel.setLabelFor(projectLocationTextField); |
514 |
projectLocationLabel.setLabelFor(projectLocationTextField); |
321 |
org.openide.awt.Mnemonics.setLocalizedText(projectLocationLabel, org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "LBL_ProjectLocation")); // NOI18N |
515 |
org.openide.awt.Mnemonics.setLocalizedText(projectLocationLabel, org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "LBL_ProjectLocation")); // NOI18N |
|
|
516 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
517 |
gridBagConstraints.gridx = 0; |
518 |
gridBagConstraints.gridy = 1; |
519 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
520 |
gridBagConstraints.insets = new java.awt.Insets(6, 0, 6, 12); |
521 |
infoPanel.add(projectLocationLabel, gridBagConstraints); |
522 |
projectLocationLabel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "ACSN_ProjectLocation")); // NOI18N |
523 |
projectLocationLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "ACSD_ProjectLocation")); // NOI18N |
524 |
|
525 |
createdFolderLabel.setLabelFor(createdFolderTextField); |
526 |
org.openide.awt.Mnemonics.setLocalizedText(createdFolderLabel, org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "LBL_ProjectFolder")); // NOI18N |
527 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
528 |
gridBagConstraints.gridx = 0; |
529 |
gridBagConstraints.gridy = 2; |
530 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
531 |
gridBagConstraints.insets = new java.awt.Insets(0, 0, 6, 12); |
532 |
infoPanel.add(createdFolderLabel, gridBagConstraints); |
533 |
createdFolderLabel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "ACSN_ProjectFolder")); // NOI18N |
534 |
createdFolderLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "ACSD_ProjectFolder")); // NOI18N |
535 |
|
536 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
537 |
gridBagConstraints.gridx = 1; |
538 |
gridBagConstraints.gridy = 1; |
539 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
540 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
541 |
gridBagConstraints.insets = new java.awt.Insets(6, 0, 6, 0); |
542 |
infoPanel.add(projectLocationTextField, gridBagConstraints); |
322 |
|
543 |
|
323 |
org.openide.awt.Mnemonics.setLocalizedText(browseButton, org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "LBL_Browse_Button")); // NOI18N |
544 |
org.openide.awt.Mnemonics.setLocalizedText(browseButton, org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "LBL_Browse_Button")); // NOI18N |
324 |
browseButton.setActionCommand(BROWSE); |
545 |
browseButton.setActionCommand(BROWSE); |
Lines 327-392
Link Here
|
327 |
browseButtonActionPerformed(evt); |
548 |
browseButtonActionPerformed(evt); |
328 |
} |
549 |
} |
329 |
}); |
550 |
}); |
330 |
|
551 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
331 |
createdFolderLabel.setLabelFor(createdFolderTextField); |
552 |
gridBagConstraints.gridx = 2; |
332 |
org.openide.awt.Mnemonics.setLocalizedText(createdFolderLabel, org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "LBL_ProjectFolder")); // NOI18N |
553 |
gridBagConstraints.gridy = 1; |
333 |
|
554 |
gridBagConstraints.insets = new java.awt.Insets(6, 12, 6, 0); |
334 |
createdFolderTextField.setEditable(false); |
555 |
infoPanel.add(browseButton, gridBagConstraints); |
335 |
|
|
|
336 |
mainProject.setSelected(true); |
337 |
org.openide.awt.Mnemonics.setLocalizedText(mainProject, org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "LBL_SetAsMainProject")); // NOI18N |
338 |
|
339 |
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); |
340 |
this.setLayout(layout); |
341 |
layout.setHorizontalGroup( |
342 |
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
343 |
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() |
344 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) |
345 |
.add(org.jdesktop.layout.GroupLayout.LEADING, mainProject, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 541, Short.MAX_VALUE) |
346 |
.add(layout.createSequentialGroup() |
347 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
348 |
.add(projectLocationLabel) |
349 |
.add(createdFolderLabel) |
350 |
.add(projectNameLabel)) |
351 |
.add(19, 19, 19) |
352 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
353 |
.add(projectNameTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 441, Short.MAX_VALUE) |
354 |
.add(org.jdesktop.layout.GroupLayout.TRAILING, projectLocationTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 441, Short.MAX_VALUE) |
355 |
.add(org.jdesktop.layout.GroupLayout.TRAILING, createdFolderTextField, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 441, Short.MAX_VALUE)))) |
356 |
.add(18, 18, 18) |
357 |
.add(browseButton) |
358 |
.add(0, 0, 0)) |
359 |
); |
360 |
layout.setVerticalGroup( |
361 |
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
362 |
.add(layout.createSequentialGroup() |
363 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) |
364 |
.add(projectNameLabel) |
365 |
.add(projectNameTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) |
366 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
367 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) |
368 |
.add(projectLocationTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
369 |
.add(projectLocationLabel) |
370 |
.add(browseButton)) |
371 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
372 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) |
373 |
.add(createdFolderTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
374 |
.add(createdFolderLabel)) |
375 |
.add(18, 18, 18) |
376 |
.add(mainProject) |
377 |
.addContainerGap(183, Short.MAX_VALUE)) |
378 |
); |
379 |
|
380 |
projectNameLabel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "ACSN_ProjectName")); // NOI18N |
381 |
projectNameLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "ACSD_ProjectName")); // NOI18N |
382 |
projectLocationLabel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "ACSN_ProjectLocation")); // NOI18N |
383 |
projectLocationLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "ACSD_ProjectLocation")); // NOI18N |
384 |
browseButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "ACSN_Browse_Button")); // NOI18N |
556 |
browseButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "ACSN_Browse_Button")); // NOI18N |
385 |
browseButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "ACSN_Browse_Button")); // NOI18N |
557 |
browseButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "ACSN_Browse_Button")); // NOI18N |
386 |
createdFolderLabel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "ACSN_ProjectFolder")); // NOI18N |
558 |
|
387 |
createdFolderLabel.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "ACSD_ProjectFolder")); // NOI18N |
559 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
388 |
mainProject.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "ACSN_SetAsMainProject")); // NOI18N |
560 |
gridBagConstraints.gridx = 0; |
389 |
mainProject.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomComponentVisualPanel.class, "ACSD_SetAsMainProject")); // NOI18N |
561 |
gridBagConstraints.gridy = 0; |
|
|
562 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
563 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; |
564 |
add(infoPanel, gridBagConstraints); |
565 |
|
566 |
typeChooserPanelContainer.setLayout(new java.awt.BorderLayout()); |
567 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
568 |
gridBagConstraints.gridx = 0; |
569 |
gridBagConstraints.gridy = 1; |
570 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
571 |
add(typeChooserPanelContainer, gridBagConstraints); |
572 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
573 |
gridBagConstraints.gridx = 0; |
574 |
gridBagConstraints.gridy = 3; |
575 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
576 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
577 |
gridBagConstraints.weightx = 1.0; |
578 |
gridBagConstraints.weighty = 1.0; |
579 |
add(fillerPanel, gridBagConstraints); |
390 |
}// </editor-fold>//GEN-END:initComponents |
580 |
}// </editor-fold>//GEN-END:initComponents |
391 |
|
581 |
|
392 |
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed |
582 |
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed |
Lines 405-412
Link Here
|
405 |
} |
595 |
} |
406 |
if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { |
596 |
if (JFileChooser.APPROVE_OPTION == chooser.showOpenDialog(this)) { |
407 |
File projectDir = chooser.getSelectedFile();//GEN-LAST:event_browseButtonActionPerformed |
597 |
File projectDir = chooser.getSelectedFile();//GEN-LAST:event_browseButtonActionPerformed |
408 |
projectLocationTextField.setText( |
598 |
String projectDirPath = FileUtil.normalizeFile(projectDir).getAbsolutePath(); |
409 |
FileUtil.normalizeFile(projectDir).getAbsolutePath()); |
599 |
projectLocationTextField.setText(computeLocationValue(projectDirPath)); |
410 |
} |
600 |
} |
411 |
//myPanel.fireChangeEvent(); |
601 |
//myPanel.fireChangeEvent(); |
412 |
} |
602 |
} |
Lines 424-434
Link Here
|
424 |
private javax.swing.JButton browseButton; |
614 |
private javax.swing.JButton browseButton; |
425 |
private javax.swing.JLabel createdFolderLabel; |
615 |
private javax.swing.JLabel createdFolderLabel; |
426 |
private javax.swing.JTextField createdFolderTextField; |
616 |
private javax.swing.JTextField createdFolderTextField; |
|
|
617 |
private javax.swing.JPanel fillerPanel; |
618 |
private javax.swing.JPanel infoPanel; |
427 |
private javax.swing.JCheckBox mainProject; |
619 |
private javax.swing.JCheckBox mainProject; |
428 |
private javax.swing.JLabel projectLocationLabel; |
620 |
private javax.swing.JLabel projectLocationLabel; |
429 |
private javax.swing.JTextField projectLocationTextField; |
621 |
private javax.swing.JTextField projectLocationTextField; |
430 |
private javax.swing.JLabel projectNameLabel; |
622 |
private javax.swing.JLabel projectNameLabel; |
431 |
private javax.swing.JTextField projectNameTextField; |
623 |
private javax.swing.JTextField projectNameTextField; |
|
|
624 |
private javax.swing.JPanel typeChooserPanelContainer; |
432 |
// End of variables declaration//GEN-END:variables |
625 |
// End of variables declaration//GEN-END:variables |
433 |
|
626 |
|
434 |
// TODO: use FileUtil.findFreeFolderName here |
627 |
// TODO: use FileUtil.findFreeFolderName here |
Lines 464-478
Link Here
|
464 |
String projectName = projectNameTextField.getText(); |
657 |
String projectName = projectNameTextField.getText(); |
465 |
String projectFolder = projectLocationTextField.getText(); |
658 |
String projectFolder = projectLocationTextField.getText(); |
466 |
|
659 |
|
467 |
//if (projectFolder.trim().length() == 0 || projectFolder.equals(oldName)) { |
|
|
468 |
createdFolderTextField.setText(projectFolder + File.separatorChar + projectName); |
660 |
createdFolderTextField.setText(projectFolder + File.separatorChar + projectName); |
469 |
//} |
661 |
projectFolderChanged(getCreatedFolderValue()); |
|
|
662 |
typeChooserPanel.updateUI(getSettings()); |
470 |
|
663 |
|
471 |
} |
664 |
} |
472 |
//myPanel.fireChangeEvent(); // Notify that the myPanel changed |
665 |
//myPanel.fireChangeEvent(); // Notify that the myPanel changed |
473 |
|
666 |
|
474 |
} |
667 |
} |
|
|
668 |
|
669 |
private void projectFolderChanged(String projectFolder){ |
670 |
File folder = FileUtil.normalizeFile(new File(projectFolder)); |
671 |
getSettings().putProperty(ModuleTypeChooserPanelExt.PROJECT_FOLDER, folder); |
672 |
} |
673 |
|
674 |
private WizardDescriptor getSettings(){ |
675 |
return mySettings; |
676 |
} |
475 |
|
677 |
|
476 |
private WizardDescriptor mySettings; |
678 |
private WizardDescriptor mySettings; |
477 |
private CustomComponentWizardPanel myPanel; |
679 |
private CustomComponentWizardPanel myPanel; |
|
|
680 |
private ModuleTypeChooserPanelExt typeChooserPanel; |
681 |
private boolean locationUpdated; |
682 |
private boolean mainProjectTouched; |
683 |
|
684 |
private boolean listenersAttached; |
685 |
private DocumentListener nameDL; |
686 |
private DocumentListener locationDL; |
687 |
private ActionListener isMainAL; |
478 |
} |
688 |
} |