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:de.mprengemann.intellij.plugin.androidicons.listeners.ImageFileBrowserFolderActionListener.java

License:Apache License

@Override
public void actionPerformed(ActionEvent e) {
    FileChooserDescriptor fileChooserDescriptor = this.myFileChooserDescriptor;
    if (this.title != null) {
        fileChooserDescriptor = (FileChooserDescriptor) this.myFileChooserDescriptor.clone();
        fileChooserDescriptor.setTitle(this.title);
    }// ww  w .j  a va2 s  .com

    FileChooser.chooseFile(fileChooserDescriptor, this.getProject(), this.getInitialFile(),
            new Consumer<VirtualFile>() {
                @SuppressWarnings("deprecation")
                @Override
                public void consume(VirtualFile file) {
                    container.getControllerFactory().getSettingsController().saveLastImageFolder(project,
                            file.getCanonicalPath());
                    onFileChoosen(file);
                }
            });
}

From source file:de.mprengemann.intellij.plugin.androidicons.settings.PluginSettings.java

License:Apache License

private void initAndroidIconsSettings() {
    FileChooserDescriptor workingDirectoryChooserDescriptor = FileChooserDescriptorFactory
            .createSingleFolderDescriptor();
    if (persistedAndroidIconsFile != null) {
        VirtualFile loadedFile = VirtualFileManager.getInstance().findFileByUrl(persistedAndroidIconsFile);
        if (loadedFile != null) {
            androidIconsAssetHome.setText(loadedFile.getCanonicalPath());
            selectedAndroidIconsFile = loadedFile;
        }/*from  w ww  .ja  v  a 2s. c o  m*/
    }
    String title = "Select res directory";
    workingDirectoryChooserDescriptor.setTitle(title);
    androidIconsAssetHome.addBrowseFolderListener(title, null, null, workingDirectoryChooserDescriptor);
    androidIconsAssetHome
            .addBrowseFolderListener(new TextBrowseFolderListener(workingDirectoryChooserDescriptor) {
                @Override
                @SuppressWarnings("deprecation") // Otherwise not compatible to AndroidStudio
                protected void onFileChoosen(@NotNull VirtualFile chosenFile) {
                    super.onFileChoosen(chosenFile);
                    selectionPerformed = true;
                    selectedAndroidIconsFile = chosenFile;
                    scanForAndroidIconsAssets();
                }
            });
    androidIconsOpenBrowser.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);
            BrowserUtil.browse(ANDROID_ICONS_URL);
        }
    });
    scanForAndroidIconsAssets();
}

From source file:de.mprengemann.intellij.plugin.androidicons.settings.PluginSettings.java

License:Apache License

private void initMaterialIconsSettings() {
    FileChooserDescriptor workingDirectoryChooserDescriptor = FileChooserDescriptorFactory
            .createSingleFolderDescriptor();
    if (persistedMaterialIconsFile != null) {
        VirtualFile loadedFile = VirtualFileManager.getInstance().findFileByUrl(persistedMaterialIconsFile);
        if (loadedFile != null) {
            materialIconsAssetHome.setText(loadedFile.getCanonicalPath());
            selectedMaterialIconsFile = loadedFile;
        }/*from  www  .  ja v  a  2s.  com*/
    }
    String title = "Select res directory";
    workingDirectoryChooserDescriptor.setTitle(title);
    materialIconsAssetHome.addBrowseFolderListener(title, null, null, workingDirectoryChooserDescriptor);
    materialIconsAssetHome
            .addBrowseFolderListener(new TextBrowseFolderListener(workingDirectoryChooserDescriptor) {
                @Override
                @SuppressWarnings("deprecation") // Otherwise not compatible to AndroidStudio
                protected void onFileChoosen(@NotNull VirtualFile chosenFile) {
                    super.onFileChoosen(chosenFile);
                    selectionPerformed = true;
                    selectedMaterialIconsFile = chosenFile;
                    scanForMaterialIconsAssets();
                }
            });
    materialIconsOpenBrowser.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            super.mouseClicked(e);
            BrowserUtil.browse(MATERIAL_ICONS_URL);
        }
    });
    scanForMaterialIconsAssets();
}

From source file:de.mprengemann.intellij.plugin.androidicons.util.AndroidResourcesHelper.java

License:Apache License

public static void initResourceBrowser(final Project project, Module module, final String title,
        @Nullable final TextFieldWithBrowseButton browser) {
    final VirtualFile resRoot = SettingsHelper.getResRootForProject(project);

    if (resRoot == null) {
        getResRootFile(project, module, new ResourcesDialog.ResourceSelectionListener() {
            @Override/*from w  w w.  ja  v  a  2  s. co m*/
            public void onResourceSelected(VirtualFile resDir) {
                if (browser != null) {
                    browser.setText(resDir.getCanonicalPath());
                }
                SettingsHelper.saveResRootForProject(project, resDir.getUrl());
            }
        });
    } else {
        if (browser != null) {
            browser.setText(resRoot.getCanonicalPath());
        }
    }

    if (browser != null) {
        FileChooserDescriptor workingDirectoryChooserDescriptor = FileChooserDescriptorFactory
                .createSingleFolderDescriptor();
        workingDirectoryChooserDescriptor.setTitle(title);
        browser.addBrowseFolderListener(title, null, project, workingDirectoryChooserDescriptor);
        browser.addBrowseFolderListener(new TextBrowseFolderListener(workingDirectoryChooserDescriptor) {
            @Override
            @SuppressWarnings("deprecation") // Otherwise not compatible to AndroidStudio
            protected void onFileChoosen(@NotNull VirtualFile chosenFile) {
                super.onFileChoosen(chosenFile);
                SettingsHelper.saveResRootForProject(project, chosenFile.getUrl());
            }
        });
    }
}

From source file:fr.vdl.android.holocolors.HoloColorsDialog.java

License:Apache License

/**
 * @param project/*  w  w w . j  ava2  s.c o m*/
 */
public HoloColorsDialog(@Nullable final Project project) {
    super(project, true);

    loadingDialog = new JDialog(getWindow(), "Downloading, please wait...", Dialog.ModalityType.MODELESS);
    loadingDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    loadingDialog.setSize(300, 20);
    loadingDialog.setLocationRelativeTo(ahcPanel);

    this.project = project;

    checkLicence();

    setTitle("Android Holo Colors Generator");
    setResizable(true);

    FileChooserDescriptor workingDirectoryChooserDescriptor = FileChooserDescriptorFactory
            .createSingleFolderDescriptor();
    String title = "Select res directory";
    workingDirectoryChooserDescriptor.setTitle(title);
    resPathTextField.addBrowseFolderListener(title, null, project, workingDirectoryChooserDescriptor);

    colorTextField.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Color color = ColorChooser.chooseColor(WindowManager.getInstance().suggestParentWindow(project),
                    "Select color", null);
            if (color != null) {
                colorTextField.setText('#' + ColorUtil.toHex(color));
                colorTextField.setForeground(color);
            }
        }
    });

    // select appcompat by default
    compatComboBox.setSelectedIndex(2);
    oldSdkRadio.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            compatComboBox.setEnabled(oldSdkRadio.isSelected());
        }
    });

    init();
}

From source file:git4idea.actions.GitClone.java

License:Apache License

@Override
public void perform(@NotNull Project project, GitVcs vcs, @NotNull List<VcsException> exceptions,
        @NotNull VirtualFile[] affectedFiles) throws VcsException {
    saveAll();// w w w .j  a  va 2 s  .  c om

    // TODO: implement remote repository login/password - setup remote repos in Git config,
    // TODO: then just reference repo name here
    final String src_repo = Messages.showInputDialog(project, "Specify source repository URL", "clone",
            Messages.getQuestionIcon());
    if (src_repo == null)
        return;

    FileChooserDescriptor fcd = new FileChooserDescriptor(false, true, false, false, false, false);
    fcd.setShowFileSystemRoots(true);
    fcd.setTitle("Destination Directory");
    fcd.setDescription("Select destination directory for clone.");
    fcd.setHideIgnored(false);
    VirtualFile[] files = FileChooser.chooseFiles(project, fcd, null);
    if (files.length != 1 || files[0] == null) {
        return;
    }

    final Map<VirtualFile, List<VirtualFile>> roots = GitUtil.sortFilesByVcsRoot(project, affectedFiles);
    for (VirtualFile root : roots.keySet()) {
        GitCommandRunnable cmdr = new GitCommandRunnable(project, vcs.getSettings(), root);
        cmdr.setCommand(GitCommand.CLONE_CMD);
        cmdr.setArgs(new String[] { src_repo, files[0].getPath() });

        ProgressManager manager = ProgressManager.getInstance();
        //TODO: make this async so the git command output can be seen in the version control window as it happens...
        manager.runProcessWithProgressSynchronously(cmdr, "Cloning source repo " + src_repo, false, project);

        VcsException ex = cmdr.getException();
        if (ex != null) {
            Messages.showErrorDialog(project, ex.getMessage(), "Error occurred during 'git clone'");
            break;
        }
    }

    VcsDirtyScopeManager mgr = VcsDirtyScopeManager.getInstance(project);
    for (VirtualFile file : affectedFiles) {
        mgr.fileDirty(file);
        file.refresh(true, true);
    }
}

From source file:intellijeval.git.GitCloneDialog.java

License:Apache License

/**
 * Init components/*from  w w w. jav  a  2 s.c om*/
 */
private void initListeners() {
    FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    fcd.setShowFileSystemRoots(true);
    fcd.setTitle(GitBundle.getString("clone.destination.directory.title"));
    fcd.setDescription(GitBundle.getString("clone.destination.directory.description"));
    fcd.setHideIgnored(false);
    myParentDirectory.addActionListener(new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(
            fcd.getTitle(), fcd.getDescription(), myParentDirectory, myProject, fcd,
            TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) {
        @Override
        protected VirtualFile getInitialFile() {
            // suggest project base directory only if nothing is typed in the component.
            String text = getComponentText();
            if (text.length() == 0) {
                VirtualFile file = myProject.getBaseDir();
                if (file != null) {
                    return file;
                }
            }
            return super.getInitialFile();
        }
    });

    final DocumentListener updateOkButtonListener = new DocumentAdapter() {
        @Override
        protected void textChanged(DocumentEvent e) {
            updateButtons();
        }
    };
    myParentDirectory.getChildComponent().getDocument().addDocumentListener(updateOkButtonListener);
    String parentDir = GitRememberedInputs.getInstance().getCloneParentDir();
    //    if (StringUtil.isEmptyOrSpaces(parentDir)) {
    //      parentDir = ProjectUtil.getBaseDir();
    //    }

    //noinspection ConstantIfStatement
    myParentDirectory.setText(EvalComponent.pluginsRootPath()); // FORK DIFF

    myDirectoryName.getDocument().addDocumentListener(updateOkButtonListener);

    myTestButton.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            test();
        }
    });

    setOKActionEnabled(false);
    myTestButton.setEnabled(false);
}

From source file:krasa.formatter.plugin.ProjectSettingsForm.java

License:Apache License

private void browseForFile(@NotNull final JTextField target) {
    final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor();
    descriptor.setHideIgnored(false);/*from  w ww.ja v  a2s.c om*/

    descriptor.setTitle("Select config file");
    String text = target.getText();
    final VirtualFile toSelect = text == null || text.isEmpty() ? getProject().getBaseDir()
            : LocalFileSystem.getInstance().findFileByPath(text);

    // 10.5 does not have #chooseFile
    VirtualFile[] virtualFile = FileChooser.chooseFiles(descriptor, getProject(), toSelect);
    if (virtualFile != null && virtualFile.length > 0) {
        target.setText(virtualFile[0].getPath());
    }
}

From source file:liveplugin.toolwindow.addplugin.git.GitCloneDialog.java

License:Apache License

/**
 * Init components//from  w w w. jav a  2  s .com
 */
private void initListeners() {
    FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    fcd.setShowFileSystemRoots(true);
    fcd.setTitle(DvcsBundle.getString("clone.destination.directory.title"));
    fcd.setDescription(DvcsBundle.getString("clone.destination.directory.description"));
    fcd.setHideIgnored(false);
    myParentDirectory.addActionListener(new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(
            fcd.getTitle(), fcd.getDescription(), myParentDirectory, myProject, fcd,
            TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) {
        @Override
        protected VirtualFile getInitialFile() {
            // suggest project base directory only if nothing is typed in the component.
            String text = getComponentText();
            if (text.length() == 0) {
                VirtualFile file = myProject.getBaseDir();
                if (file != null) {
                    return file;
                }
            }
            return super.getInitialFile();
        }
    });

    final DocumentListener updateOkButtonListener = new DocumentAdapter() {
        @Override
        protected void textChanged(DocumentEvent e) {
            updateButtons();
        }
    };
    myParentDirectory.getChildComponent().getDocument().addDocumentListener(updateOkButtonListener);
    String parentDir = GitRememberedInputs.getInstance().getCloneParentDir();
    //    if (StringUtil.isEmptyOrSpaces(parentDir)) {
    //      parentDir = ProjectUtil.getBaseDir();
    //    }

    //noinspection ConstantIfStatement
    myParentDirectory.setText(LivePluginAppComponent.pluginsRootPath()); // FORK DIFF

    myDirectoryName.getDocument().addDocumentListener(updateOkButtonListener);

    myTestButton.addActionListener(new ActionListener() {
        public void actionPerformed(@NotNull final ActionEvent e) {
            test();
        }
    });

    setOKActionEnabled(false);
    myTestButton.setEnabled(false);
}

From source file:net.andydvorak.intellij.lessc.ui.configurable.LessProfileConfigurableForm.java

License:Apache License

private FileChooserDescriptor getFileChooserDescriptor() {
    FileChooserDescriptor d = new FileChooserDescriptor(false, true, false, false, false, false);
    d.setTitle(UIBundle.message("file.chooser.css.title"));
    d.setShowFileSystemRoots(true);/*from w w w.  j ava2  s .  c om*/
    return d;
}