Lines 59-84
Link Here
|
59 |
private Project project; |
59 |
private Project project; |
60 |
private String expectedExtension; |
60 |
private String expectedExtension; |
61 |
private final List/*<ChangeListener>*/ listeners = new ArrayList(); |
61 |
private final List/*<ChangeListener>*/ listeners = new ArrayList(); |
62 |
private boolean isPackage; |
62 |
private int type; |
63 |
private SourceGroup groups[]; |
63 |
private SourceGroup groups[]; |
64 |
private boolean ignoreRootCombo; |
64 |
private boolean ignoreRootCombo; |
65 |
|
65 |
|
66 |
/** Creates new form SimpleTargetChooserGUI */ |
66 |
/** Creates new form SimpleTargetChooserGUI */ |
67 |
public JavaTargetChooserPanelGUI( Project p, SourceGroup[] groups, Component bottomPanel, boolean isPackage ) { |
67 |
public JavaTargetChooserPanelGUI( Project p, SourceGroup[] groups, Component bottomPanel, int type ) { |
68 |
this.isPackage = isPackage; |
68 |
this.type = type; |
69 |
this.project = p; |
69 |
this.project = p; |
70 |
this.groups = groups; |
70 |
this.groups = groups; |
71 |
|
71 |
|
72 |
initComponents(); |
72 |
initComponents(); |
73 |
|
73 |
|
74 |
if ( isPackage ) { |
74 |
if ( type == NewJavaFileWizardIterator.TYPE_PACKAGE ) { |
75 |
packageComboBox.setVisible( false ); |
75 |
packageComboBox.setVisible( false ); |
76 |
packageLabel.setVisible( false ); |
76 |
packageLabel.setVisible( false ); |
77 |
Mnemonics.setLocalizedText (fileLabel, NbBundle.getMessage (JavaTargetChooserPanelGUI.class, "LBL_JavaTargetChooserPanelGUI_CreatedFolder_Label")); // NOI18N |
77 |
Mnemonics.setLocalizedText (fileLabel, NbBundle.getMessage (JavaTargetChooserPanelGUI.class, "LBL_JavaTargetChooserPanelGUI_CreatedFolder_Label")); // NOI18N |
78 |
Mnemonics.setLocalizedText (documentNameLabel, NbBundle.getMessage (JavaTargetChooserPanelGUI.class, "LBL_JavaTargetChooserPanelGUI_PackageName_Label")); // NOI18N |
78 |
Mnemonics.setLocalizedText (documentNameLabel, NbBundle.getMessage (JavaTargetChooserPanelGUI.class, "LBL_JavaTargetChooserPanelGUI_PackageName_Label")); // NOI18N |
79 |
} |
79 |
documentNameTextField.getDocument().addDocumentListener( this ); |
|
|
80 |
} |
81 |
else if ( type == NewJavaFileWizardIterator.TYPE_PKG_INFO ) { |
82 |
documentNameTextField.setEditable (false); |
83 |
} |
80 |
else { |
84 |
else { |
81 |
packageComboBox.getEditor().addActionListener( this ); |
85 |
packageComboBox.getEditor().addActionListener( this ); |
|
|
86 |
documentNameTextField.getDocument().addDocumentListener( this ); |
82 |
} |
87 |
} |
83 |
|
88 |
|
84 |
|
89 |
|
Lines 87-93
Link Here
|
87 |
} |
92 |
} |
88 |
|
93 |
|
89 |
//initValues( project, null, null ); |
94 |
//initValues( project, null, null ); |
90 |
documentNameTextField.getDocument().addDocumentListener( this ); |
95 |
|
91 |
|
96 |
|
92 |
// Not very nice |
97 |
// Not very nice |
93 |
Component packageEditor = packageComboBox.getEditor().getEditorComponent(); |
98 |
Component packageEditor = packageComboBox.getEditor().getEditorComponent(); |
Lines 128-134
Link Here
|
128 |
rootComboBox.setSelectedItem( preselectedGroup ); |
133 |
rootComboBox.setSelectedItem( preselectedGroup ); |
129 |
ignoreRootCombo = false; |
134 |
ignoreRootCombo = false; |
130 |
Object preselectedPackage = getPreselectedPackage(preselectedGroup, preselectedFolder, packageComboBox.getModel()); |
135 |
Object preselectedPackage = getPreselectedPackage(preselectedGroup, preselectedFolder, packageComboBox.getModel()); |
131 |
if ( isPackage ) { |
136 |
if ( type == NewJavaFileWizardIterator.TYPE_PACKAGE ) { |
132 |
String docName = preselectedPackage == null || preselectedPackage.toString().length() == 0 ? |
137 |
String docName = preselectedPackage == null || preselectedPackage.toString().length() == 0 ? |
133 |
DEFAULT_NEW_PACKAGE_NAME : |
138 |
DEFAULT_NEW_PACKAGE_NAME : |
134 |
preselectedPackage.toString() + "." + DEFAULT_NEW_PACKAGE_NAME; |
139 |
preselectedPackage.toString() + "." + DEFAULT_NEW_PACKAGE_NAME; |
Lines 146-157
Link Here
|
146 |
} |
151 |
} |
147 |
if (template != null) { |
152 |
if (template != null) { |
148 |
if ( documentNameTextField.getText().trim().length() == 0 ) { // To preserve the class name on back in the wiazard |
153 |
if ( documentNameTextField.getText().trim().length() == 0 ) { // To preserve the class name on back in the wiazard |
149 |
documentNameTextField.setText (NEW_CLASS_PREFIX + template.getName ()); |
154 |
if (this.type == NewJavaFileWizardIterator.TYPE_PKG_INFO) { |
150 |
documentNameTextField.selectAll (); |
155 |
documentNameTextField.setText (template.getName ()); |
|
|
156 |
} |
157 |
else { |
158 |
//Ordinary file |
159 |
documentNameTextField.setText (NEW_CLASS_PREFIX + template.getName ()); |
160 |
documentNameTextField.selectAll (); |
161 |
} |
151 |
} |
162 |
} |
152 |
} |
163 |
} |
153 |
} |
|
|
154 |
if ( !isPackage ) { |
155 |
updatePackages( false ); |
164 |
updatePackages( false ); |
156 |
} |
165 |
} |
157 |
// Determine the extension |
166 |
// Determine the extension |
Lines 168-174
Link Here
|
168 |
|
177 |
|
169 |
public String getPackageFileName() { |
178 |
public String getPackageFileName() { |
170 |
|
179 |
|
171 |
if ( isPackage ) { |
180 |
if ( type == NewJavaFileWizardIterator.TYPE_PACKAGE ) { |
172 |
return ""; // NOI18N |
181 |
return ""; // NOI18N |
173 |
} |
182 |
} |
174 |
|
183 |
|
Lines 180-186
Link Here
|
180 |
* Name of selected package, or "" for default package. |
189 |
* Name of selected package, or "" for default package. |
181 |
*/ |
190 |
*/ |
182 |
String getPackageName() { |
191 |
String getPackageName() { |
183 |
if ( isPackage ) { |
192 |
if ( type == NewJavaFileWizardIterator.TYPE_PACKAGE ) { |
184 |
return ""; // NOI18N |
193 |
return ""; // NOI18N |
185 |
} |
194 |
} |
186 |
return packageComboBox.getEditor().getItem().toString(); |
195 |
return packageComboBox.getEditor().getItem().toString(); |
Lines 372-378
Link Here
|
372 |
|
381 |
|
373 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
382 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
374 |
if ( rootComboBox == e.getSource() ) { |
383 |
if ( rootComboBox == e.getSource() ) { |
375 |
if ( !ignoreRootCombo && !isPackage ) { |
384 |
if ( !ignoreRootCombo && type != NewJavaFileWizardIterator.TYPE_PACKAGE ) { |
376 |
updatePackages( true ); |
385 |
updatePackages( true ); |
377 |
} |
386 |
} |
378 |
updateText(); |
387 |
updateText(); |
Lines 459-465
Link Here
|
459 |
FileObject rootFolder = g.getRootFolder(); |
468 |
FileObject rootFolder = g.getRootFolder(); |
460 |
String packageName = getPackageFileName(); |
469 |
String packageName = getPackageFileName(); |
461 |
String documentName = documentNameTextField.getText().trim(); |
470 |
String documentName = documentNameTextField.getText().trim(); |
462 |
if ( isPackage ) { |
471 |
if ( type == NewJavaFileWizardIterator.TYPE_PACKAGE ) { |
463 |
documentName = documentName.replace( '.', '/' ); // NOI18N |
472 |
documentName = documentName.replace( '.', '/' ); // NOI18N |
464 |
} |
473 |
} |
465 |
else if ( documentName.length() > 0 ) { |
474 |
else if ( documentName.length() > 0 ) { |