Example usage for com.intellij.openapi.fileChooser FileChooserDescriptor setTitle

List of usage examples for com.intellij.openapi.fileChooser FileChooserDescriptor setTitle

Introduction

In this page you can find the example usage for com.intellij.openapi.fileChooser FileChooserDescriptor setTitle.

Prototype

public void setTitle(@Nls(capitalization = Nls.Capitalization.Title) String title) 

Source Link

Usage

From source file:org.jetbrains.plugins.ruby.ruby.module.ui.roots.loadPath.RLoadPathCooserPanel.java

License:Apache License

public RLoadPathCooserPanel(@NotNull final Module module,
        @NotNull final CheckableDirectoriesContainer dirsContainer) {
    myModule = module;//from   w  w w .j a v a 2s  .  c  o  m
    myDirsContainer = dirsContainer;

    // fill list
    final List<CheckableDirectoryItem> dirs = myDirsContainer.getCheckableDirectories();
    for (CheckableDirectoryItem directoryItem : dirs) {
        myListModel.addElement(directoryItem.createCheckBox());
    }

    // listeners
    myAddButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            final FileChooserDescriptor dirChooser = FileChooserDescriptorFactory
                    .createSingleFolderDescriptor();
            dirChooser.setShowFileSystemRoots(true);
            dirChooser.setHideIgnored(true);
            dirChooser
                    .setTitle(RBundle.message("module.settings.dialog.load.path.filechooser.add.dialog.title"));
            // dirChooser.setContextModule(module);
            FileChooserDialog chooser = FileChooserFactory.getInstance().createFileChooser(dirChooser,
                    module.getProject(), myContentPane);
            VirtualFile[] files = chooser.choose(null, null);
            for (VirtualFile file : files) {
                // adding to the end
                CheckableDirectoryItem docDirectory = new CheckableDirectoryItem(file.getPath(), true);
                if (myDirsContainer.addCheckableDir(docDirectory)) {
                    myListModel.addElement(docDirectory.createCheckBox());
                } else {
                    final String msg = RBundle.message("module.settings.dialog.load.path.error.add.message");
                    final String title = RBundle.message("module.settings.dialog.load.path.error.add.title");
                    Messages.showErrorDialog(module.getProject(), msg, title);
                }
            }
        }
    });

    myRemoveButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int selected = myList.getSelectedIndex();
            if (selected != -1) {
                // removing index
                final JCheckBox checkBox = (JCheckBox) myListModel.get(selected);
                myDirsContainer.removeDirByPath(getPath(checkBox));
                myListModel.remove(selected);
            }
        }
    });
}

From source file:org.jetbrains.plugins.ruby.ruby.ri.SettingsPane.java

License:Apache License

public SettingsPane(final RDocPanel docPanel, final RDocSettings settings) {
    myDocPanel = docPanel;/*from  w ww .j a  va  2s. co  m*/
    mySettings = settings;
    myDocDirs = settings.getDocDirs();

    addButton.setText(RBundle.message("ruby.ri.settings.pane.add"));
    addButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            FileChooserDescriptor dirChooser = FileChooserDescriptorFactory.createSingleFolderDescriptor();
            dirChooser.setShowFileSystemRoots(true);
            dirChooser.setHideIgnored(true);
            dirChooser.setTitle("Select directory");
            FileChooserDialog chooser = FileChooserFactory.getInstance().createFileChooser(dirChooser,
                    docPanel.getProject(), mainPanel);
            VirtualFile[] files = chooser.choose(null, null);
            if (files.length > 0) {
                // adding to the end
                CheckableDirectoryItem docDirectory = new CheckableDirectoryItem(files[0].getPath(), true);
                myDocDirs.addCheckableDir(docDirectory);
                myListModel.addElement(docDirectory.createCheckBox());
            }
        }
    });

    removeButton.setText(RBundle.message("ruby.ri.settings.pane.remove"));
    removeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int selected = myList.getSelectedIndex();
            if (selected != -1) {
                // removing index
                final JCheckBox checkBox = (JCheckBox) myListModel.get(selected);
                myDocDirs.removeDirByPath(checkBox.getText());
                myListModel.remove(selected);
            }
        }
    });
    defaultRadioButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            mySettings.setUseDefaults(defaultRadioButton.isSelected());
            updateUI();
        }
    });
    selectedRadioButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            mySettings.setUseDefaults(defaultRadioButton.isSelected());
            updateUI();
        }
    });

    myDescription.setText(RBundle.message("ruby.ri.settings.pane.description"));
    myLabel.setText(RBundle.message("ruby.ri.settings.pane.label"));

    // restoring settings
    for (CheckableDirectoryItem docDirectory : getDocDirs()) {
        myListModel.addElement(docDirectory.createCheckBox());
    }
    updateUI();
}

From source file:org.jetbrains.plugins.ruby.ruby.run.confuguration.RubyRunConfigurationUIUtil.java

License:Apache License

public static FileChooserDescriptor addFolderChooser(@NotNull final String title,
        @NotNull final TextFieldWithBrowseButton textField, final Project project) {
    final FileChooserDescriptor folderChooserDescriptor = FileChooserDescriptorFactory
            .createSingleFolderDescriptor();
    folderChooserDescriptor.setTitle(title);
    textField.addBrowseFolderListener(title, null, project, folderChooserDescriptor);
    return folderChooserDescriptor;
}

From source file:org.jetbrains.plugins.ruby.ruby.run.confuguration.RubyRunConfigurationUIUtil.java

License:Apache License

public static FileChooserDescriptor addFileChooser(@NotNull final String title,
        @NotNull final TextFieldWithBrowseButton textField, @Nullable final Project project) {
    final FileChooserDescriptor fileChooserDescriptor = FileChooserDescriptorFactory
            .createSingleFileNoJarsDescriptor();
    fileChooserDescriptor.setTitle(title);
    textField.addBrowseFolderListener(title, null, project, fileChooserDescriptor);
    return fileChooserDescriptor;
}

From source file:org.jetbrains.tfsIntegration.actions.BranchAction.java

License:Apache License

protected void execute(final @NotNull Project project, final @NotNull WorkspaceInfo workspace,
        final @NotNull FilePath sourceLocalPath, final @NotNull ExtendedItem sourceExtendedItem) {
    try {/* w ww.  j  a  v a2 s .  co  m*/
        final String sourceServerPath = sourceExtendedItem.getSitem();
        CreateBranchDialog d = new CreateBranchDialog(project, workspace, sourceServerPath,
                sourceExtendedItem.getType() == ItemType.Folder);
        if (!d.showAndGet()) {
            return;
        }

        VersionSpecBase version = d.getVersionSpec();
        if (version == null) {
            Messages.showErrorDialog(project, "Incorrect version specified", "Create Branch");
            return;
        }

        final String targetServerPath = d.getTargetPath();
        if (d.isCreateWorkingCopies()) {
            FilePath targetLocalPath = workspace.findLocalPathByServerPath(targetServerPath, true, project);
            if (targetLocalPath == null) {
                FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
                descriptor.setTitle("Select Local Folder");
                descriptor.setShowFileSystemRoots(true);
                final String message = MessageFormat.format(
                        "Branch target folder ''{0}'' is not mapped. Select a local folder to create a mapping in workspace ''{1}''",
                        targetServerPath, workspace.getName());
                descriptor.setDescription(message);

                VirtualFile selectedFile = FileChooser.chooseFile(descriptor, project, null);
                if (selectedFile == null) {
                    return;
                }

                workspace.addWorkingFolderInfo(new WorkingFolderInfo(WorkingFolderInfo.Status.Active,
                        TfsFileUtil.getFilePath(selectedFile), targetServerPath));
                workspace.saveToServer(project, workspace);
            }
        }

        final ResultWithFailures<GetOperation> createBranchResult = workspace.getServer().getVCS().createBranch(
                workspace.getName(), workspace.getOwnerName(), sourceServerPath, version, targetServerPath,
                project, TFSBundle.message("creating.branch"));
        if (!createBranchResult.getFailures().isEmpty()) {
            StringBuilder s = new StringBuilder("Failed to create branch:\n");
            for (Failure failure : createBranchResult.getFailures()) {
                s.append(failure.getMessage()).append("\n");
            }
            Messages.showErrorDialog(project, s.toString(), "Create Branch");
            return;
        }

        if (d.isCreateWorkingCopies()) {
            final Ref<Collection<VcsException>> downloadErrors = new Ref<Collection<VcsException>>(
                    Collections.<VcsException>emptyList());
            ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
                public void run() {
                    downloadErrors
                            .set(ApplyGetOperations.execute(project, workspace, createBranchResult.getResult(),
                                    new ApplyProgress.ProgressIndicatorWrapper(
                                            ProgressManager.getInstance().getProgressIndicator()),
                                    null, ApplyGetOperations.DownloadMode.ALLOW));
                }
            }, "Creating target working copies", false, project);

            if (!downloadErrors.get().isEmpty()) {
                AbstractVcsHelper.getInstance(project)
                        .showErrors(new ArrayList<VcsException>(downloadErrors.get()), "Create Branch");
            }
        }

        // TODO checkin requires proper configuration
        final Collection<PendingChange> pendingChanges = workspace.getServer().getVCS()
                .queryPendingSetsByServerItems(workspace.getName(), workspace.getOwnerName(),
                        Collections.singletonList(targetServerPath), RecursionType.Full, project,
                        TFSBundle.message("loading.changes"));
        Collection<String> checkin = new ArrayList<String>();
        for (PendingChange change : pendingChanges) {
            if (new ChangeTypeMask(change.getChg()).contains(ChangeType_type0.Branch)) {
                checkin.add(change.getItem());
            }
        }
        final String comment = MessageFormat.format("Branched from {0}", sourceServerPath);
        final ResultWithFailures<CheckinResult> checkinResult = workspace.getServer().getVCS().checkIn(
                workspace.getName(), workspace.getOwnerName(), checkin, comment,
                Collections.<WorkItem, CheckinWorkItemAction>emptyMap(),
                Collections.<Pair<String, String>>emptyList(), null, project, TFSBundle.message("checking.in"));

        if (!checkinResult.getFailures().isEmpty()) {
            final List<VcsException> checkinErrors = TfsUtil.getVcsExceptions(checkinResult.getFailures());
            AbstractVcsHelper.getInstance(project).showErrors(checkinErrors, "Create Branch");
        }

        final FilePath targetLocalPath = workspace.findLocalPathByServerPath(targetServerPath, true, project);
        if (targetLocalPath != null) {
            TfsFileUtil.markDirtyRecursively(project, targetLocalPath);
        }

        String message = MessageFormat.format("''{0}'' branched successfully to ''{1}''.", sourceServerPath,
                targetServerPath);
        Messages.showInfoMessage(project, message, "Create Branch");
    } catch (TfsException ex) {
        String message = "Failed to create branch: " + ex.getMessage();
        Messages.showErrorDialog(project, message, "Create Branch");
    }
}

From source file:org.moe.idea.runconfig.configuration.MOERunConfigurationEditor.java

License:Apache License

private void showPropertiesChoicerDialog() {
    final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileDescriptor();
    descriptor.setTitle("Select remote build properties file");
    descriptor.setHideIgnored(true);//from ww w  .  j  a  v a2  s .  co  m
    VirtualFile selected = FileChooser.chooseFile(descriptor, myProject, null);

    if (selected != null) {

        try {
            Properties property = RemoteSettings.readProperties(selected.getCanonicalPath());
            String remoteHost = property.getProperty("host");
            String port = property.getProperty("port");
            port = port == null || port.isEmpty() ? "0" : port;
            int remotePort = Integer.parseInt(port);
            String remoteUser = property.getProperty("user");
            String remoteKnownhosts = property.getProperty("knownhosts");
            String remoteIdentity = property.getProperty("identity");
            String remoteKeychainName = property.getProperty("keychain.name");
            String remoteKeychainPass = property.getProperty("keychain.pass");
            String timeout = property.getProperty("keychain.locktimeout");
            timeout = timeout == null || timeout.isEmpty() ? "0" : timeout;
            int remoteKeychainLocktimeout = Integer.parseInt(timeout);
            String remoteGradleRepositories = property.getProperty("gradle.repositories");

            updateRemoteBuildSettings(remoteHost, remotePort, remoteUser, remoteKnownhosts, remoteIdentity,
                    remoteKeychainName, remoteKeychainPass, remoteKeychainLocktimeout,
                    remoteGradleRepositories);
        } catch (Exception e) {
            showMessage("Unable load properties file");
        }
    }
}

From source file:org.moe.idea.runconfig.configuration.MOERunConfigurationEditor.java

License:Apache License

private void showSavePropertyDialog() {
    final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    descriptor.setTitle("Select save folder");
    descriptor.setHideIgnored(true);/*  w w w.j a v a  2 s  . co m*/
    VirtualFile selected = FileChooser.chooseFile(descriptor, myProject, null);

    if (selected != null) {
        Properties properties = RemoteSettings.getProperties(hostTextField.getText(), portTextField.getText(),
                userTextField.getText(), knownhostsTextField.getText(), identityTextField.getText(),
                keychainNameTextField.getText(), keychainPassTextField.getText(),
                keychainLocktimeoutTextField.getText(), gradleRepositoriesTextField.getText());
        try {
            RemoteSettings.validate(properties);
            RemoteSettings.saveProperties(selected.getCanonicalPath(), properties);
            VfsUtil.markDirtyAndRefresh(false, true, true, selected);

            showMessage("Property file saved.");
        } catch (ConfigurationValidationException e) {
            showMessage(e.getErrorMessage());
            return;
        } catch (IOException e) {
            showMessage(e.getMessage());
            return;
        }
    }
}

From source file:org.napile.idea.thermit.config.explorer.AntExplorer.java

License:Apache License

private void addBuildFile() {
    final FileChooserDescriptor descriptor = createXmlDescriptor();
    descriptor.setTitle(ThermitBundle.message("select.ant.build.file.dialog.title"));
    descriptor.setDescription(ThermitBundle.message("select.ant.build.file.dialog.description"));
    final VirtualFile[] files = FileChooser.chooseFiles(descriptor, myProject, null);
    if (files.length == 0) {
        return;//from w ww. ja va  2  s  .c  om
    }
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        public void run() {
            final ThermitConfiguration thermitConfiguration = myConfig;
            if (thermitConfiguration == null) {
                return;
            }
            final List<VirtualFile> ignoredFiles = new ArrayList<VirtualFile>();
            for (VirtualFile file : files) {
                try {
                    thermitConfiguration.addBuildFile(file);
                } catch (AntNoFileException e) {
                    ignoredFiles.add(e.getFile());
                }
            }
            if (ignoredFiles.size() != 0) {
                String messageText;
                final StringBuilder message = StringBuilderSpinAllocator.alloc();
                try {
                    String separator = "";
                    for (final VirtualFile virtualFile : ignoredFiles) {
                        message.append(separator);
                        message.append(virtualFile.getPresentableUrl());
                        separator = "\n";
                    }
                    messageText = message.toString();
                } finally {
                    StringBuilderSpinAllocator.dispose(message);
                }
                Messages.showWarningDialog(myProject, messageText,
                        ThermitBundle.message("cannot.add.ant.files.dialog.title"));
            }
        }
    });
}

From source file:org.onehippo.intellij.freemarker.config.PluginConfiguration.java

License:Apache License

private void chooseFolder(final TextAccessor field, final boolean chooseFiles) {
    final FileChooserDescriptor descriptor = new FileChooserDescriptor(chooseFiles, !chooseFiles, false, false,
            false, false) {/*from   w ww. jav a 2s. c  o m*/
        @Override
        public String getName(VirtualFile virtualFile) {
            return virtualFile.getName();
        }

        @Override
        @Nullable
        public String getComment(VirtualFile virtualFile) {
            return virtualFile.getPresentableUrl();
        }
    };
    descriptor.setTitle("Select Freemarker Root Folder");

    final String selectedPath = field.getText();
    final VirtualFile preselectedFolder = LocalFileSystem.getInstance().findFileByPath(selectedPath);

    final VirtualFile[] files = FileChooser.chooseFiles(descriptor, mainPanel, getProject(mainPanel),
            preselectedFolder);
    if (files.length > 0) {
        field.setText(files[0].getPath());
    }
}

From source file:org.onehippo.intellij.groovy.config.PluginConfiguration.java

License:Apache License

private void chooseFolder(final TextAccessor field, final boolean chooseFiles) {
    final FileChooserDescriptor descriptor = new FileChooserDescriptor(chooseFiles, !chooseFiles, false, false,
            false, false) {/*from  w  w  w .jav a 2 s  .c  o  m*/
        @Override
        public String getName(VirtualFile virtualFile) {
            return virtualFile.getName();
        }

        @Override
        @Nullable
        public String getComment(VirtualFile virtualFile) {
            return virtualFile.getPresentableUrl();
        }
    };
    descriptor.setTitle("Select Groovy Root Folder");

    final String selectedPath = field.getText();
    final VirtualFile preselectedFolder = LocalFileSystem.getInstance().findFileByPath(selectedPath);

    final VirtualFile[] files = FileChooser.chooseFiles(descriptor, mainPanel, getProject(mainPanel),
            preselectedFolder);
    if (files.length > 0) {
        field.setText(files[0].getPath());
    }
}