This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 253154
Collapse All | Expand All

(-)a/projectui/src/org/netbeans/modules/project/ui/SimpleTargetChooserPanelGUI.java (-6 / +63 lines)
Lines 70-75 Link Here
70
import org.openide.util.ChangeSupport;
70
import org.openide.util.ChangeSupport;
71
import static org.netbeans.modules.project.ui.Bundle.*;
71
import static org.netbeans.modules.project.ui.Bundle.*;
72
import org.openide.filesystems.FileChooserBuilder;
72
import org.openide.filesystems.FileChooserBuilder;
73
import org.openide.filesystems.FileStateInvalidException;
74
import org.openide.util.NbBundle;
73
import org.openide.util.NbBundle.Messages;
75
import org.openide.util.NbBundle.Messages;
74
76
75
/**
77
/**
Lines 92-97 Link Here
92
    private boolean isFolder;
94
    private boolean isFolder;
93
    private boolean freeFileExtension;
95
    private boolean freeFileExtension;
94
    private final char separatorChar;
96
    private final char separatorChar;
97
    private final String separator;
95
98
96
    @SuppressWarnings("LeakingThisInConstructor")
99
    @SuppressWarnings("LeakingThisInConstructor")
97
    @Messages("LBL_SimpleTargetChooserPanel_Name=Name and Location")
100
    @Messages("LBL_SimpleTargetChooserPanel_Name=Name and Location")
Lines 101-106 Link Here
101
        this.isFolder = isFolder;
104
        this.isFolder = isFolder;
102
        this.freeFileExtension = freeFileExtension;
105
        this.freeFileExtension = freeFileExtension;
103
        this.separatorChar = getPathNameSeparator(project, folders);
106
        this.separatorChar = getPathNameSeparator(project, folders);
107
        this.separator = Character.toString(separatorChar);
104
        initComponents();
108
        initComponents();
105
        
109
        
106
        locationComboBox.setRenderer( CELL_RENDERER );
110
        locationComboBox.setRenderer( CELL_RENDERER );
Lines 479-497 Link Here
479
        if (folderName == null) {
483
        if (folderName == null) {
480
            folderName = "";
484
            folderName = "";
481
        }
485
        }
482
        
486
483
        String createdFileName = (root != null ? FileUtil.getFileDisplayName( root ) : "") +
487
        String path = ( root == null || folderName.startsWith("/") || folderName.startsWith( File.separator ) ? "" : "/" ) + // NOI18N
484
            ( root == null || folderName.startsWith("/") || folderName.startsWith( File.separator ) ? "" : "/" ) + // NOI18N
488
            folderName +
485
            folderName + 
486
            ( folderName.endsWith("/") || folderName.endsWith( File.separator ) || folderName.length() == 0 ? "" : "/" ) + // NOI18N
489
            ( folderName.endsWith("/") || folderName.endsWith( File.separator ) || folderName.length() == 0 ? "" : "/" ) + // NOI18N
487
            documentName + (!freeFileExtension || documentName.indexOf('.') == -1 ? expectedExtension : "");
490
            documentName + (!freeFileExtension || documentName.indexOf('.') == -1 ? expectedExtension : "");
491
492
        String createdFileName = (root != null) ? getFileDisplayName(root, path) : path;
488
            
493
            
489
        fileTextField.setText( createdFileName.replace( '/', this.separatorChar ) ); // NOI18N
494
        fileTextField.setText( createdFileName.replace( '/', this.separatorChar ) ); // NOI18N
490
            
495
            
491
        changeSupport.fireChange();
496
        changeSupport.fireChange();
492
    }
497
    }
493
    
498
494
   
499
    private String getFileDisplayName(FileObject fo, String relativePath) {
500
        String displayName = null;
501
        File f = FileUtil.toFile(fo);
502
503
        if (f != null) {
504
            displayName = new File(f, relativePath).getAbsolutePath();
505
        } else {
506
            FileObject archiveFile = FileUtil.getArchiveFile(fo);
507
508
            if (archiveFile != null) {
509
                displayName = getArchiveDisplayName(fo, archiveFile, relativePath);
510
            }
511
        }
512
513
        if (displayName == null) {
514
            try {
515
                String path = fo.getPath() + 
516
                        ((relativePath.startsWith("/") || relativePath.startsWith(separator)) ? "" : separatorChar) + //NOI18N
517
                        relativePath;
518
                displayName = NbBundle.getMessage(
519
                        SimpleTargetChooserPanelGUI.class, "LBL_file_in_filesystem",
520
                        path, fo.getFileSystem().getDisplayName()
521
                );
522
            } catch (FileStateInvalidException e) {
523
                // Not relevant now, just use the simple path.
524
                displayName = fo.getPath();
525
            }
526
        }
527
528
        return displayName;
529
    }
530
531
    private String getArchiveDisplayName(FileObject fo, FileObject archiveFile, String relativePath) {
532
        String displayName = null;
533
534
        File f = FileUtil.toFile(archiveFile);
535
536
        if (f != null) {
537
            String archivDisplayName = new File(f, relativePath).getAbsolutePath();
538
539
            String entryPath = fo.getPath();
540
            String path = entryPath
541
                    + ((relativePath.startsWith("/") || relativePath.startsWith(separator)) ? "" : separatorChar) + //NOI18N
542
                    relativePath;
543
544
            displayName = NbBundle.getMessage(
545
                    FileUtil.class, "LBL_file_in_filesystem", path, archivDisplayName
546
            );
547
        }
548
549
        return displayName;
550
    }
551
495
    // ActionListener implementation -------------------------------------------
552
    // ActionListener implementation -------------------------------------------
496
    
553
    
497
    public @Override void actionPerformed(ActionEvent e) {
554
    public @Override void actionPerformed(ActionEvent e) {

Return to bug 253154