Lines 36-41
Link Here
|
36 |
import javax.swing.event.ChangeEvent; |
36 |
import javax.swing.event.ChangeEvent; |
37 |
import javax.swing.event.ChangeListener; |
37 |
import javax.swing.event.ChangeListener; |
38 |
import javax.swing.event.DocumentListener; |
38 |
import javax.swing.event.DocumentListener; |
|
|
39 |
import org.netbeans.api.project.PotentialSourceGroup; |
39 |
import org.netbeans.api.project.Project; |
40 |
import org.netbeans.api.project.Project; |
40 |
import org.netbeans.api.project.ProjectUtils; |
41 |
import org.netbeans.api.project.ProjectUtils; |
41 |
import org.netbeans.api.project.SourceGroup; |
42 |
import org.netbeans.api.project.SourceGroup; |
Lines 43-48
Link Here
|
43 |
import org.openide.filesystems.FileObject; |
44 |
import org.openide.filesystems.FileObject; |
44 |
import org.openide.filesystems.FileUtil; |
45 |
import org.openide.filesystems.FileUtil; |
45 |
import org.openide.awt.Mnemonics; |
46 |
import org.openide.awt.Mnemonics; |
|
|
47 |
import org.openide.filesystems.URLMapper; |
46 |
import org.openide.loaders.DataObject; |
48 |
import org.openide.loaders.DataObject; |
47 |
import org.openide.loaders.DataObjectNotFoundException; |
49 |
import org.openide.loaders.DataObjectNotFoundException; |
48 |
import org.openide.util.NbBundle; |
50 |
import org.openide.util.NbBundle; |
Lines 190-196
Link Here
|
190 |
} |
192 |
} |
191 |
|
193 |
|
192 |
public FileObject getRootFolder() { |
194 |
public FileObject getRootFolder() { |
193 |
return ((SourceGroup) rootComboBox.getSelectedItem()).getRootFolder(); |
195 |
SourceGroup sg = (SourceGroup) rootComboBox.getSelectedItem(); |
|
|
196 |
if (sg instanceof PotentialSourceGroup) { |
197 |
File file = new File(((PotentialSourceGroup)sg).getPotencialRootFolder()); |
198 |
file.mkdirs(); |
199 |
return FileUtil.toFileObject(file); |
200 |
} |
201 |
return sg.getRootFolder(); |
194 |
} |
202 |
} |
195 |
|
203 |
|
196 |
public String getPackageFileName() { |
204 |
public String getPackageFileName() { |
Lines 477-483
Link Here
|
477 |
private void updateText() { |
485 |
private void updateText() { |
478 |
|
486 |
|
479 |
SourceGroup g = (SourceGroup) rootComboBox.getSelectedItem(); |
487 |
SourceGroup g = (SourceGroup) rootComboBox.getSelectedItem(); |
480 |
FileObject rootFolder = g.getRootFolder(); |
|
|
481 |
String packageName = getPackageFileName(); |
488 |
String packageName = getPackageFileName(); |
482 |
String documentName = documentNameTextField.getText().trim(); |
489 |
String documentName = documentNameTextField.getText().trim(); |
483 |
if ( type == NewJavaFileWizardIterator.TYPE_PACKAGE ) { |
490 |
if ( type == NewJavaFileWizardIterator.TYPE_PACKAGE ) { |
Lines 486-492
Link Here
|
486 |
else if ( documentName.length() > 0 ) { |
493 |
else if ( documentName.length() > 0 ) { |
487 |
documentName = documentName + expectedExtension; |
494 |
documentName = documentName + expectedExtension; |
488 |
} |
495 |
} |
489 |
String createdFileName = FileUtil.getFileDisplayName( rootFolder ) + |
496 |
String start = ""; |
|
|
497 |
if (g instanceof PotentialSourceGroup) { |
498 |
start = ((PotentialSourceGroup)g).getPotencialRootFolder().getPath(); |
499 |
} else { |
500 |
FileObject rootFolder = g.getRootFolder(); |
501 |
start = FileUtil.getFileDisplayName( rootFolder ); |
502 |
} |
503 |
String createdFileName = start + |
490 |
( packageName.startsWith("/") || packageName.startsWith( File.separator ) ? "" : "/" ) + // NOI18N |
504 |
( packageName.startsWith("/") || packageName.startsWith( File.separator ) ? "" : "/" ) + // NOI18N |
491 |
packageName + |
505 |
packageName + |
492 |
( packageName.endsWith("/") || packageName.endsWith( File.separator ) || packageName.length() == 0 ? "" : "/" ) + // NOI18N |
506 |
( packageName.endsWith("/") || packageName.endsWith( File.separator ) || packageName.length() == 0 ? "" : "/" ) + // NOI18N |
Lines 497-502
Link Here
|
497 |
|
511 |
|
498 |
private SourceGroup getPreselectedGroup(FileObject folder) { |
512 |
private SourceGroup getPreselectedGroup(FileObject folder) { |
499 |
for(int i = 0; folder != null && i < groups.length; i++) { |
513 |
for(int i = 0; folder != null && i < groups.length; i++) { |
|
|
514 |
if (groups[i] instanceof PotentialSourceGroup) { |
515 |
// not a parent for sure. |
516 |
continue; |
517 |
} |
500 |
FileObject root = groups[i].getRootFolder(); |
518 |
FileObject root = groups[i].getRootFolder(); |
501 |
if (root.equals(folder) || FileUtil.isParentOf(root, folder)) { |
519 |
if (root.equals(folder) || FileUtil.isParentOf(root, folder)) { |
502 |
return groups[i]; |
520 |
return groups[i]; |