Java Code Examples for org.openide.filesystems.FileChooserBuilder#setTitle()

The following examples show how to use org.openide.filesystems.FileChooserBuilder#setTitle() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SearchScopeBrowse.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Open file chooser to choose search roots.
 */
private FileObject[] chooseRoots() {
    FileChooserBuilder chooserBuilder =
            new FileChooserBuilder(SearchScopeBrowse.class);
    chooserBuilder.setTitle(UiUtils.getText(
            "LBL_ScopeBrowseFileChooserTitle"));                    //NOI18N
    chooserBuilder.setApproveText(UiUtils.getText(
            "LBL_ScopeBrowseFileChooserApprove"));                  //NOI18N
    File[] files = chooserBuilder.showMultiOpenDialog();
    if (files == null) {
        files = new File[0];
    }
    List<File> existingFiles = selectExistingFiles(files);
    FileObject[] fileObjects = new FileObject[existingFiles.size()];
    for (int i = 0; i < existingFiles.size(); i++) {
        fileObjects[i] = FileUtil.toFileObject(existingFiles.get(i));
    }
    if (fileObjects.length > 0) {
        roots = fileObjects;
    }
    return fileObjects;
}
 
Example 2
Source File: AvdHwProfile.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
private void skinButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_skinButtonActionPerformed
    // TODO add your handling code here:
    FileChooserBuilder builder = new FileChooserBuilder("ANDROID_SKIN");
    builder.setDirectoriesOnly(true);
    builder.setTitle("Select skin directory...");
    File skinFolder = builder.showOpenDialog();
    if (skinFolder != null && skinFolder.exists()) {
        File layout = new File(skinFolder.getAbsolutePath() + File.separator + "layout");
        if (layout.exists()) {
            skin.setModel(new SkinsComboboxModel(new File(skinFolder.getParent())));
            skin.setSelectedItem(skinFolder);
        } else {
            NotifyDescriptor nd = new NotifyDescriptor.Message("The selected directory does not contain a skin!", NotifyDescriptor.WARNING_MESSAGE);
            DialogDisplayer.getDefault().notifyLater(nd);
        }
    }
}
 
Example 3
Source File: CreateAvdVisualPanel3.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
private void skinSelectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_skinSelectActionPerformed
    // TODO add your handling code here:
    FileChooserBuilder builder = new FileChooserBuilder("ANDROID_SKIN");
    builder.setDirectoriesOnly(true);
    builder.setTitle("Select skin directory...");
    File skinFolder = builder.showOpenDialog();
    if (skinFolder != null && skinFolder.exists()) {
        File layout = new File(skinFolder.getAbsolutePath() + File.separator + "layout");
        if (layout.exists()) {
            skinCombo.setModel(new SkinsComboboxModel(new File(skinFolder.getParent())));
            skinCombo.setSelectedItem(skinFolder);
        } else {
            NotifyDescriptor nd = new NotifyDescriptor.Message("The selected directory does not contain a skin!", NotifyDescriptor.WARNING_MESSAGE);
            DialogDisplayer.getDefault().notifyLater(nd);
        }
    }
}
 
Example 4
Source File: CreateProjectVisualPanel1.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
//        File path = new File(jTextField1.getText());
//        if (path.isDirectory()) {

        FileChooserBuilder builder = new FileChooserBuilder(this.getClass());
        builder.setDirectoriesOnly(true);
        builder.setTitle("Select Project Folder");
        File file = builder.showOpenDialog();
        if (file != null) {
            try {
                jTextField1.setText(file.getAbsolutePath() + File.separator + jTextField2.getText());
            } catch (Exception e) {
            }
        }
//        }
    }
 
Example 5
Source File: BigStringCustomEditor.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
@NbBundle.Messages("DLG_SaveToFile=Save to File")
public void actionPerformed(ActionEvent e) {
    // Save
    FileChooserBuilder fchb = new FileChooserBuilder(BigStringCustomEditor.class);
    fchb.setTitle(Bundle.DLG_SaveToFile());
    final File f = fchb.showSaveDialog();
    if (f != null) {
        new RequestProcessor(BigStringCustomEditor.class).post(new Runnable() {
            @Override
            public void run() {
                save(f);
            }
        });
    }
}
 
Example 6
Source File: MobilePanel.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    FileChooserBuilder builder = new FileChooserBuilder(AndroidSdkTool.class);
    builder.setTitle("Please select Android SDK Folder");
    builder.setDirectoriesOnly(true);
    File file = builder.showOpenDialog();
    if (file != null) {
        FileObject folder = FileUtil.toFileObject(file);
        if (folder.getFileObject("tools") == null) {
            Message msg = new NotifyDescriptor.Message(
                    "Not a valid SDK folder!",
                    NotifyDescriptor.ERROR_MESSAGE);
            DialogDisplayer.getDefault().notifyLater(msg);

        } else {
            String name = file.getPath();
            jTextField1.setText(name);
        }
    }
}
 
Example 7
Source File: SDKVisualPanelSelect.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private void browseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseActionPerformed
    // TODO add your handling code here:
    FileChooserBuilder chooserBuilder = new FileChooserBuilder(SDKVisualPanelSelect.class);
    chooserBuilder.setDirectoriesOnly(true);
    chooserBuilder.setTitle("Choose the folder where is the Android SDK installed.");
    chooserBuilder.setApproveText("OK");
    File tmp = chooserBuilder.showOpenDialog();
    if (tmp != null) {
        path.setText(tmp.getAbsolutePath());
    }
}
 
Example 8
Source File: CodelessProjectWizardVisualPanel1.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    FileChooserBuilder builder = new FileChooserBuilder(System.getProperty("user.home"));
    builder.setDirectoriesOnly(true);
    builder.setTitle("Select Project Folder");
    File file = builder.showOpenDialog();
    if (file != null) {
        jTextField1.setText(file.getPath());
    }
}
 
Example 9
Source File: InstallBlenderExporterPanel.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    FileChooserBuilder builder = new FileChooserBuilder("");
    builder.setDirectoriesOnly(true);
    builder.setTitle("Select Blender Scripts Directory");
    File file = builder.showOpenDialog();
    if (file != null) {
        jTextField1.setText(file.getPath());
    }
}
 
Example 10
Source File: PublishAssetPackVisualPanel2.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    FileChooserBuilder builder = new FileChooserBuilder(this.getClass());
    builder.setDirectoriesOnly(true);
    builder.setTitle("Select Export Folder");
    File file = builder.showOpenDialog();
    if (file != null) {
        try {
            jTextField1.setText(file.getAbsolutePath());
        } catch (Exception e) {
        }
    }
}
 
Example 11
Source File: ImportVisualPanel2.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void selectFile() {
    FileChooserBuilder builder = new FileChooserBuilder(this.getClass());
    builder.setFilesOnly(true);
    builder.setTitle("Select Asset File");
    File[] file = builder.showMultiOpenDialog();
    if (file != null) {
        for (int i = 0; i < file.length; i++) {
            File file1 = file[i];
            FileDescription description = AssetPackLoader.getFileDescription(file1);
            description.setPath(pathString());
            list.add(description);
        }
        updateList();
    }
}
 
Example 12
Source File: CodelessProjectWizardVisualPanel1.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    File path=new File(jTextField1.getText());
    if(path.isDirectory()){
        FileChooserBuilder builder = new FileChooserBuilder(path.getAbsolutePath());
        builder.setDirectoriesOnly(true);
        builder.setTitle("Select Assets Folder");
        File file = builder.showOpenDialog();
        if (file != null) {
            try {
                jTextField2.setText(file.getAbsolutePath().substring(path.getAbsolutePath().length(), file.getAbsolutePath().length()));
            } catch (Exception e) {
            }
        }
    }
}
 
Example 13
Source File: AndroidSdkTool.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Returns a String with the path to the SDK or null if none is specified.
 * @return 
 */
public static String getSdkPath() {
    String path = NbPreferences.forModule(AndroidSdkTool.class).get("sdk_path", null);
    if (path == null) {
        FileChooserBuilder builder = new FileChooserBuilder(AndroidSdkTool.class);
        builder.setTitle("Please select Android SDK Folder");
        builder.setDirectoriesOnly(true);
        File file = builder.showOpenDialog();
        if (file != null) {
            FileObject folder = FileUtil.toFileObject(file);
            if (folder.getFileObject("tools") == null) {
                Message msg = new NotifyDescriptor.Message(
                        "Not a valid SDK folder!",
                        NotifyDescriptor.ERROR_MESSAGE);
                DialogDisplayer.getDefault().notifyLater(msg);

            } else {
                String name = file.getPath();
                NbPreferences.forModule(AndroidSdkTool.class).put("sdk_path", name);
                return name;
            }
        }
    } else {
        return path;
    }
    return null;
}
 
Example 14
Source File: SDKVisualPanelInstall.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private void browseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseActionPerformed
    // TODO add your handling code here:
    FileChooserBuilder chooserBuilder = new FileChooserBuilder(SDKVisualPanelInstall.class);
    chooserBuilder.setDirectoriesOnly(true);
    chooserBuilder.setTitle("Choose the folder in which to install Android SDK Tools.");
    chooserBuilder.setApproveText("OK");
    File tmp = chooserBuilder.showOpenDialog();
    if (tmp != null) {
        path.setText(tmp.getAbsolutePath());
    }
}
 
Example 15
Source File: AndroidPlatformCustomizer.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private void addSourcesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addSourcesActionPerformed
    FileChooserBuilder builder = new FileChooserBuilder(AndroidPlatformCustomizer.class);
    builder.setAcceptAllFileFilterUsed(false);
    builder.setFileFilter(new ArchiveFileFilter("src files", new String[]{"JAR", "ZIP"}));
    builder.setTitle("Select Sources to add");
    File[] files = builder.showMultiOpenDialog();
    if (files != null) {
        for (File file : files) {
            aPackage.addSrcPath(FileUtil.toFileObject(file).toURL(), true);
        }
        sdk.store();
        fireSourcesAdded();
    }
}
 
Example 16
Source File: AndroidPlatformCustomizer.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private void addClasspathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addClasspathActionPerformed
    FileChooserBuilder builder = new FileChooserBuilder(AndroidPlatformCustomizer.class);
    builder.setAcceptAllFileFilterUsed(false);
    builder.setFileFilter(new ArchiveFileFilter("Jar files", new String[]{"JAR"}));
    builder.setTitle("Select ClassPath to add");
    File[] files = builder.showMultiOpenDialog();
    if (files != null) {
        for (File file : files) {
            aPackage.addBootPath(FileUtil.toFileObject(file).toURL(), true);
        }
        sdk.store();
        fireClassPathAdded();
    }
}
 
Example 17
Source File: AndroidPlatformCustomizer.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private void addJavadocActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addJavadocActionPerformed
    FileChooserBuilder builder = new FileChooserBuilder(AndroidPlatformCustomizer.class);
    builder.setAcceptAllFileFilterUsed(false);
    builder.setFileFilter(new ArchiveFileFilter("javadoc files", new String[]{"JAR", "ZIP"}));
    builder.setTitle("Select Javadocs to add");
    File[] files = builder.showMultiOpenDialog();
    if (files != null) {
        for (File file : files) {
            aPackage.addJavadocPath(FileUtil.toFileObject(file).toURL(), true);
        }
        sdk.store();
        fireJavadocAdded();
    }
}
 
Example 18
Source File: SaveAsAction.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void performAction(Node[] activatedNodes) {
    Node node = activatedNodes[0];
    FileObject fo = node.getLookup().lookup(FileObject.class);
    if (fo != null) {
        FileChooserBuilder builder = new FileChooserBuilder(SaveAsAction.class);
        builder.setDirectoriesOnly(false);
        builder.setApproveText("Save");
        builder.setControlButtonsAreShown(true);
        builder.setTitle("Save As...");
        builder.setFilesOnly(true);
        builder.setFileFilter(new FileNameExtensionFilter(fo.getExt(), fo.getExt()));
        JFileChooser chooser = builder.createFileChooser();
        chooser.setSelectedFile(new File(fo.getNameExt()));
        int resp = chooser.showSaveDialog(findDialogParent());
        if (JFileChooser.APPROVE_OPTION == resp) {
            File saveFile = chooser.getSelectedFile();
            if (saveFile != null) {
                try {
                    saveFile.getParentFile().mkdirs();
                    FileObject dfo = FileUtil.toFileObject(saveFile.getParentFile());
                    if (dfo == null) {
                        NotifyDescriptor nd = new NotifyDescriptor.Message("Unable to Save file!", NotifyDescriptor.ERROR_MESSAGE);
                        DialogDisplayer.getDefault().notifyLater(nd);
                        return;
                    }
                    if (saveFile.exists()) {
                        saveFile.delete();
                    }
                    fo.copy(dfo, saveFile.getName(), "");
                } catch (IOException ex) {
                    Exceptions.printStackTrace(ex);
                }
            }
        }
    }
}
 
Example 19
Source File: SourceRootsUi.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Handles button events
 */        
public void actionPerformed( ActionEvent e ) {
    
    Object source = e.getSource();
    
    if ( source == addFolderButton ) { 
        
        // Let user search for the Jar file
        FileChooserBuilder builder = new FileChooserBuilder(SourceRootsUi.class).setDirectoriesOnly(true);
        builder.setDefaultWorkingDirectory(FileUtil.toFile(this.project.getProjectDirectory()));
        String type = RootsAccessor.getInstance().getType(sourceRoots);
        boolean isModule = JavaProjectConstants.SOURCES_TYPE_MODULES.equals(type);
        if (sourceRoots.isTest()) {
            builder.setTitle(NbBundle.getMessage(SourceRootsUi.class, isModule ? "LBL_TestModuleFolder_DialogTitle" : "LBL_TestFolder_DialogTitle"));  // NOI18N
        } else {
            builder.setTitle(NbBundle.getMessage(SourceRootsUi.class, isModule ? "LBL_ModuleFolder_DialogTitle" : "LBL_SourceFolder_DialogTitle")); // NOI18N
        }
        File files[] = builder.showMultiOpenDialog();
        if ( files != null ) {
            addFolders( files );
        }
    }
    else if ( source == removeButton ) { 
        removeElements();
    }
    else if ( source == upButton ) {
        moveUp();
    }
    else if ( source == downButton ) {
        moveDown();
    }
}
 
Example 20
Source File: AddDriverDialog.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
    stopProgress();

    FileChooserBuilder fileChooserBuilder = new FileChooserBuilder(AddDriverDialog.class);
    fileChooserBuilder.setTitle(NbBundle.getMessage(AddDriverDialog.class, "AddDriver_Chooser_Title")); //NOI18N
    //.jar and .zip file filter
    fileChooserBuilder.setFileFilter(new FileFilter() {

        @Override
        public boolean accept(File f) {
            return (f.isDirectory() || f.getName().endsWith(".jar") || f.getName().endsWith(".zip")); //NOI18N
        }

        @Override
        public String getDescription() {
            return NbBundle.getMessage(AddDriverDialog.class, "AddDriver_Chooser_Filter"); //NOI18N
        }
    });

    File[] selectedFiles = fileChooserBuilder.showMultiOpenDialog();
    if (selectedFiles != null) {
        for (final File file : selectedFiles) {
            if (file.isFile()) {
                if (dlm.contains(file.toString())) {
                    // file already added
                    NotifyDescriptor msgDesc = new NotifyDescriptor.Message(NbBundle.getMessage(AddDriverDialog.class, "AddDriverDuplicateFile", file.toString()));
                    DialogDisplayer.getDefault().notify(msgDesc);
                    continue;
                }
                if (drvs.isEmpty()) {
                    dlm.clear();
                }
                dlm.addElement(file.toString());
                try {
                    drvs.add(file.toURI().toURL());
                } catch (MalformedURLException exc) {
                    LOGGER.log(Level.WARNING,
                            "Unable to add driver jar file " +
                            file.getAbsolutePath() +
                            ": can not convert to URL", exc);
                }
                if (wd != null) {
                    boolean privileged = wd.getAllPrivilegedNames().isEmpty();
                    for (String name : wd.getAllPrivilegedNames()) {
                        if (file.getName().startsWith(name)) {
                            privileged = true;
                            break;
                        }
                    }
                    if (privileged) {
                        SwingUtilities.invokeLater(new Runnable() {
                            @Override
                            public void run() {
                                notifyUser(null, false);
                            }
                        });
                    } else {
                        SwingUtilities.invokeLater(new Runnable() {
                            @Override
                            public void run() {
                                notifyUser(NbBundle.getMessage(AddDriverDialog.class, "AddDriverDialog_NotPrivilegedDriver", // NOI18N
                                        file.getName(), wd.getPrivilegedName()), true);
                            }
                        });
                    }
                }
            }
        }
        findDriverClass();
        if (wp != null) {
            wp.fireChangeEvent();
        }
    }
    updateState();
}