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

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

Introduction

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

Prototype

public void setDescription(@Nls(capitalization = Nls.Capitalization.Sentence) String description) 

Source Link

Usage

From source file:bazaar4idea.action.BzrInit.java

License:Apache License

@Override
public void actionPerformed(final AnActionEvent e) {
    Project project = e.getData(CommonDataKeys.PROJECT);
    if (project == null) {
        project = ProjectManager.getInstance().getDefaultProject();
    }/*from  www. j  av a  2  s.c  o  m*/
    FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    fcd.setShowFileSystemRoots(true);
    fcd.setTitle(BzrBundle.getString("init.destination.directory.title"));
    fcd.setDescription(BzrBundle.getString("init.destination.directory.description"));
    fcd.setHideIgnored(false);
    VirtualFile baseDir = e.getData(CommonDataKeys.VIRTUAL_FILE);
    if (baseDir == null) {
        baseDir = project.getBaseDir();
    }
    doInit(project, fcd, baseDir, baseDir);
}

From source file:com.android.tools.idea.actions.AndroidImportProjectAction.java

License:Apache License

@NotNull
protected FileChooserDescriptor createFileChooserDescriptor() {
    FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, true, true, false, false) {
        FileChooserDescriptor myDelegate = new OpenProjectFileChooserDescriptor(true);

        @Override/*from   w  w  w . ja  va 2 s. c o m*/
        public Icon getIcon(VirtualFile file) {
            Icon icon = myDelegate.getIcon(file);
            return icon == null ? super.getIcon(file) : icon;
        }
    };
    descriptor.setHideIgnored(false);
    descriptor.setTitle(WIZARD_TITLE);
    descriptor.setDescription(WIZARD_DESCRIPTION);
    return descriptor;
}

From source file:com.android.tools.idea.gradle.eclipse.AdtImportLocationStep.java

License:Apache License

public AdtImportLocationStep(WizardContext context) {
    super(context);

    myDestinationLabel.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD));

    String prev = context.getProjectFileDirectory();
    mySourceProject = new File(FileUtil.toSystemDependentName(prev));

    String name = new File(prev).getName();
    //noinspection ConstantConditions
    context.setProjectFileDirectory(null);
    String defaultDir = context.getProjectFileDirectory();
    int index = 0;
    File file;// w ww . j  a va  2 s.  c o  m
    do {
        String suffix = index == 0 ? "" : Integer.toString(index);
        index++;
        file = new File(defaultDir, name + suffix);
    } while (file.exists());
    myDestDirText.setText(file.getPath());
    context.setProjectFileDirectory(prev);

    FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    descriptor.setTitle("Choose Destination Directory");
    descriptor.setDescription("Pick a directory to import the given Eclipse Android project into");
    myDestDirText.addBrowseFolderListener(new TextBrowseFolderListener(descriptor) {
        @Override
        protected void onFileChosen(@NotNull VirtualFile chosenFile) {
            super.onFileChosen(chosenFile);
            myIsPathChangedByUser = true;
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            super.actionPerformed(e);
            myIsPathChangedByUser = true;
        }
    });
}

From source file:com.android.tools.idea.npw.deprecated.ImportSourceLocationStep.java

License:Apache License

private void setupSourceLocationControls() {
    FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor();
    descriptor.setTitle("Select Source Location");
    descriptor.setDescription("Select existing ADT or Gradle project to import as a new subproject");
    mySourceLocation.addBrowseFolderListener(new TextBrowseFolderListener(descriptor));
    mySourceLocation.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
        @Override//from  ww w  .j  av  a2s  .co m
        protected void textChanged(DocumentEvent e) {
            invalidate();
        }
    });

    applyBackgroundOperationResult(checkPath(mySourceLocation.getText()));
    myErrorWarning.setIcon(null);
    myErrorWarning.setText(null);
}

From source file:com.android.tools.idea.wizard.ImportSourceLocationStep.java

License:Apache License

private void setupSourceLocationControls(@Nullable VirtualFile importSource) {
    if (importSource == null) {
        FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor();
        descriptor.setTitle("Select Source Location");
        descriptor.setDescription("Select existing ADT or Gradle project to import as a new subproject");
        mySourceLocation.addBrowseFolderListener(new TextBrowseFolderListener(descriptor));
        mySourceLocation.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
            @Override/*from www.j  a  v a2s.c o  m*/
            protected void textChanged(DocumentEvent e) {
                invalidate();
            }
        });
    } else {
        mySourceLocation.setVisible(false);
        myLocationLabel.setVisible(false);
        mySourceLocation.setText(importSource.getPath());
    }
    applyBackgroundOperationResult(checkPath(mySourceLocation.getText()));
    myErrorWarning.setIcon(null);
    myErrorWarning.setText(null);
}

From source file:com.github.rholder.gradle.intellij.DependencyViewer.java

License:Apache License

private void promptForGradleBaseDir() {
    FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    fcd.setShowFileSystemRoots(true);//from  w  w  w . j a v  a2 s.c  om
    fcd.setTitle("Choose a Gradle folder...");
    fcd.setDescription(
            "Pick the top level directory to use when viewing dependencies (in case you have a multi-module project)");
    fcd.setHideIgnored(false);

    FileChooser.chooseFiles(fcd, project, project.getBaseDir(), new Consumer<List<VirtualFile>>() {
        @Override
        public void consume(List<VirtualFile> files) {
            gradleBaseDir = files.get(0).getPath();
        }
    });
}

From source file:com.google.cloud.tools.intellij.vcs.CloneCloudRepositoryDialog.java

License:Apache License

private void initComponents() {
    FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    fcd.setShowFileSystemRoots(true);//from  w w w .j a  va  2  s . co  m
    fcd.setTitle(GctBundle.message("clonefromgcp.destination.directory.title"));
    fcd.setDescription(GctBundle.message("clonefromgcp.destination.directory.description"));
    fcd.setHideIgnored(false);
    parentDirectory.addActionListener(new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>(
            fcd.getTitle(), fcd.getDescription(), parentDirectory, project, fcd,
            TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT) {
        @Override
        protected VirtualFile getInitialFile() {
            String text = getComponentText();
            if (text.length() == 0) {
                VirtualFile file = project.getBaseDir();
                if (file != null) {
                    return file;
                }
            }
            return super.getInitialFile();
        }
    });

    final DocumentListener updateOkButtonListener = new DocumentAdapter() {
        @Override
        protected void textChanged(DocumentEvent event) {
            updateButtons();
        }
    };
    parentDirectory.getChildComponent().getDocument().addDocumentListener(updateOkButtonListener);
    parentDirectory.setText(ProjectUtil.getBaseDir());
    directoryName.getDocument().addDocumentListener(updateOkButtonListener);

    setOKActionEnabled(false);
}

From source file:com.google.gct.idea.git.CloneGcpDialog.java

License:Apache License

private void initComponents() {
    FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    fcd.setShowFileSystemRoots(true);/* w ww.  ja v a 2 s .c o  m*/
    fcd.setTitle(GctBundle.message("clonefromgcp.destination.directory.title"));
    fcd.setDescription(GctBundle.message("clonefromgcp.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() {
            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);
    myParentDirectory.setText(ProjectUtil.getBaseDir());
    myDirectoryName.getDocument().addDocumentListener(updateOkButtonListener);

    setOKActionEnabled(false);
}

From source file:com.intellij.codeInsight.ExternalAnnotationsManagerImpl.java

License:Apache License

private void setupRootAndAnnotateExternally(@NotNull final OrderEntry entry, @NotNull final Project project,
        @NotNull final PsiModifierListOwner listOwner, @NotNull final String annotationFQName,
        @NotNull final PsiFile fromFile, @NotNull final String packageName,
        @Nullable final PsiNameValuePair[] value) {
    final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
    descriptor.setTitle(//from   w ww  .  ja v a  2 s. co m
            ProjectBundle.message("external.annotations.root.chooser.title", entry.getPresentableName()));
    descriptor.setDescription(ProjectBundle.message("external.annotations.root.chooser.description"));
    final VirtualFile newRoot = FileChooser.chooseFile(descriptor, project, null);
    if (newRoot == null) {
        notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
        return;
    }
    new WriteCommandAction(project) {
        @Override
        protected void run(final Result result) throws Throwable {
            appendChosenAnnotationsRoot(entry, newRoot);
            XmlFile xmlFileInRoot = findXmlFileInRoot(findExternalAnnotationsXmlFiles(listOwner), newRoot);
            if (xmlFileInRoot != null) { //file already exists under appeared content root
                if (!FileModificationService.getInstance().preparePsiElementForWrite(xmlFileInRoot)) {
                    notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
                    return;
                }
                annotateExternally(listOwner, annotationFQName, xmlFileInRoot, fromFile, value);
            } else {
                final XmlFile annotationsXml = createAnnotationsXml(newRoot, packageName);
                if (annotationsXml != null) {
                    List<PsiFile> createdFiles = new SmartList<PsiFile>(annotationsXml);
                    cacheExternalAnnotations(packageName, fromFile, createdFiles);
                }
                annotateExternally(listOwner, annotationFQName, annotationsXml, fromFile, value);
            }
        }
    }.execute();
}

From source file:com.intellij.codeInspection.actions.ViewOfflineResultsAction.java

License:Apache License

@Override
public void actionPerformed(AnActionEvent event) {
    final Project project = event.getData(CommonDataKeys.PROJECT);

    LOG.assertTrue(project != null);/* ww  w. j av a  2  s .c o  m*/

    final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, false, false,
            false) {
        @Override
        public Icon getIcon(VirtualFile file) {
            if (file.isDirectory()) {
                if (file.findChild(InspectionApplication.DESCRIPTIONS + "."
                        + InternalStdFileTypes.XML.getDefaultExtension()) != null) {
                    return AllIcons.Nodes.InspectionResults;
                }
            }
            return super.getIcon(file);
        }
    };
    descriptor.setTitle("Select Path");
    descriptor.setDescription("Select directory which contains exported inspections results");
    final VirtualFile virtualFile = FileChooser.chooseFile(descriptor, project, null);
    if (virtualFile == null || !virtualFile.isDirectory())
        return;

    final Map<String, Map<String, Set<OfflineProblemDescriptor>>> resMap = new HashMap<String, Map<String, Set<OfflineProblemDescriptor>>>();
    final String[] profileName = new String[1];
    final Runnable process = new Runnable() {
        @Override
        public void run() {
            final VirtualFile[] files = virtualFile.getChildren();
            try {
                for (final VirtualFile inspectionFile : files) {
                    if (inspectionFile.isDirectory())
                        continue;
                    final String shortName = inspectionFile.getNameWithoutExtension();
                    final String extension = inspectionFile.getExtension();
                    if (shortName.equals(InspectionApplication.DESCRIPTIONS)) {
                        profileName[0] = ApplicationManager.getApplication()
                                .runReadAction(new Computable<String>() {
                                    @Override
                                    @Nullable
                                    public String compute() {
                                        return OfflineViewParseUtil.parseProfileName(
                                                LoadTextUtil.loadText(inspectionFile).toString());
                                    }
                                });
                    } else if (XML_EXTENSION.equals(extension)) {
                        resMap.put(shortName, ApplicationManager.getApplication()
                                .runReadAction(new Computable<Map<String, Set<OfflineProblemDescriptor>>>() {
                                    @Override
                                    public Map<String, Set<OfflineProblemDescriptor>> compute() {
                                        return OfflineViewParseUtil
                                                .parse(LoadTextUtil.loadText(inspectionFile).toString());
                                    }
                                }));
                    }
                }
            } catch (final Exception e) { //all parse exceptions
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        Messages.showInfoMessage(e.getMessage(),
                                InspectionsBundle.message("offline.view.parse.exception.title"));
                    }
                });
                throw new ProcessCanceledException(); //cancel process
            }
        }
    };
    ProgressManager.getInstance().runProcessWithProgressAsynchronously(project,
            InspectionsBundle.message("parsing.inspections.dump.progress.title"), process, new Runnable() {
                @Override
                public void run() {
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            final String name = profileName[0];
                            showOfflineView(project, name, resMap,
                                    InspectionsBundle.message("offline.view.title") + " ("
                                            + (name != null ? name
                                                    : InspectionsBundle
                                                            .message("offline.view.editor.settings.title"))
                                            + ")");
                        }
                    });
                }
            }, null, new PerformAnalysisInBackgroundOption(project));
}