本文整理匯總了Java中com.intellij.openapi.fileChooser.FileChooserDescriptorFactory.createSingleFolderDescriptor方法的典型用法代碼示例。如果您正苦於以下問題:Java FileChooserDescriptorFactory.createSingleFolderDescriptor方法的具體用法?Java FileChooserDescriptorFactory.createSingleFolderDescriptor怎麽用?Java FileChooserDescriptorFactory.createSingleFolderDescriptor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
的用法示例。
在下文中一共展示了FileChooserDescriptorFactory.createSingleFolderDescriptor方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: CreateCourseArchivePanel
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入方法依賴的package包/類
public CreateCourseArchivePanel(@NotNull final Project project, CreateCourseArchiveDialog dlg, String name) {
setLayout(new BorderLayout());
add(myPanel, BorderLayout.CENTER);
myErrorIcon.setIcon(AllIcons.Actions.Lightning);
setState(false);
myDlg = dlg;
String sanitizedName = FileUtil.sanitizeFileName(name);
myNameField.setText(sanitizedName.startsWith("_") ? EduNames.COURSE : sanitizedName);
myLocationField.setText(project.getBasePath());
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
myLocationField.addBrowseFolderListener("Choose Location Folder", null, project, descriptor);
myLocationField.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String location = myLocationField.getText();
File file = new File(location);
if (!file.exists() || !file.isDirectory()) {
myDlg.enableOKAction(false);
setError("Invalid location");
}
myDlg.enableOKAction(true);
}
});
}
示例2: createDirectory
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入方法依賴的package包/類
public static PsiDirectory createDirectory(Project project, String title, String description) {
final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
descriptor.setTitle(title);
descriptor.setShowFileSystemRoots(false);
descriptor.setDescription(description);
descriptor.setHideIgnored(true);
descriptor.setRoots(project.getBaseDir());
descriptor.setForcedToUseIdeaFileChooser(true);
VirtualFile file = FileChooser.chooseFile(descriptor, project, project.getBaseDir());
if(Objects.isNull(file)){
Messages.showInfoMessage("Cancel " + title, "Error");
return null;
}
PsiDirectory psiDirectory = PsiDirectoryFactory.getInstance(project).createDirectory(file);
if(PsiDirectoryFactory.getInstance(project).isPackage(psiDirectory)){
return psiDirectory;
}else {
Messages.showInfoMessage("請選擇正確的 package 路徑。", "Error");
return createDirectory(project, title, description);
}
}
示例3: actionPerformed
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入方法依賴的package包/類
@Override
public void actionPerformed(final AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
if (project == null) {
project = ProjectManager.getInstance().getDefaultProject();
}
FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
fcd.setShowFileSystemRoots(true);
fcd.setTitle(GitBundle.getString("init.destination.directory.title"));
fcd.setDescription(GitBundle.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);
}
示例4: selectFile
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入方法依賴的package包/類
@Nullable
private File selectFile(String title, String description) {
FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
fcd.setShowFileSystemRoots(true);
fcd.setTitle(title);
fcd.setDescription(description);
fcd.setHideIgnored(false);
VirtualFile file = FileChooser.chooseFile(fcd, myProject, null);
if (file == null) {
return null;
}
final String path = file.getPath();
if (path.endsWith(":")) { // workaround for VFS oddities with drive root (IDEADEV-20870)
return new File(path + "/");
}
return new File(path);
}
示例5: run
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入方法依賴的package包/類
public void run() {
final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
VirtualFile selectedFile = FileChooser.chooseFile(descriptor, myProject, null);
if (selectedFile == null) {
return;
}
final List<AbstractFilePatchInProgress.PatchChange> selectedChanges = myChangesTreeList.getSelectedChanges();
if (selectedChanges.size() >= 1) {
for (AbstractFilePatchInProgress.PatchChange patchChange : selectedChanges) {
final AbstractFilePatchInProgress patch = patchChange.getPatchInProgress();
patch.setNewBase(selectedFile);
}
updateTree(false);
}
}
示例6: TemplateLanguagePanel
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入方法依賴的package包/類
public TemplateLanguagePanel() {
super(new BorderLayout());
add(myMainPanel, BorderLayout.CENTER);
myTemplatesFolderLabel.setLabelFor(myTemplatesFolder);
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
descriptor.withTreeRootVisible(true);
descriptor.setShowFileSystemRoots(true);
List<String> templateConfigurations = TemplatesService.getAllTemplateLanguages();
for (String configuration : templateConfigurations) {
if (!configuration.equals(TemplatesService.WEB2PY)) {
myTemplateLanguage.addItem(configuration);
}
}
myTemplatesFolder.setText(DEFAULT_TEMPLATES_FOLDER);
myTemplatesFolder.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
final int dot = myTemplatesFolder.getCaret().getDot();
final int index = myTemplatesFolder.getText().indexOf(File.separator);
if (index >= dot) {
myTemplateFolderModified = true;
}
}
});
}
示例7: CreateCourseArchivePanel
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入方法依賴的package包/類
public CreateCourseArchivePanel(@NotNull final Project project, CreateCourseArchiveDialog dlg, String name) {
setLayout(new BorderLayout());
add(myPanel, BorderLayout.CENTER);
myErrorIcon.setIcon(AllIcons.Actions.Lightning);
setState(false);
myDlg = dlg;
String sanitizedName = FileUtil.sanitizeFileName(name);
myNameField.setText(sanitizedName.startsWith("_") ? EduNames.COURSE : sanitizedName);
myLocationField.setText(project.getBasePath());
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
myLocationField.addBrowseFolderListener("Choose location folder", null, project, descriptor);
myLocationField.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String location = myLocationField.getText();
File file = new File(location);
if (!file.exists() || !file.isDirectory()) {
myDlg.enableOKAction(false);
setError("Invalid location");
}
myDlg.enableOKAction(true);
}
});
}
示例8: chooseFolder
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入方法依賴的package包/類
public static VirtualFile chooseFolder(@Nullable Project project, String title, String description, boolean showFileSystemRoots, boolean hideIgnored, @Nullable VirtualFile toSelect){
final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
descriptor.setTitle(title);
descriptor.setDescription(description);
descriptor.setShowFileSystemRoots(showFileSystemRoots);
descriptor.setHideIgnored(hideIgnored);
return FileChooser.chooseFile(descriptor, project, toSelect);
}
示例9: actionPerformed
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入方法依賴的package包/類
public void actionPerformed(ActionEvent e) {
// choose directory here/
FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFolderDescriptor();
fcd.setShowFileSystemRoots(true);
fcd.setTitle("Export Directory");
fcd.setDescription("Select directory to export from subversion");
fcd.setHideIgnored(false);
VirtualFile file = FileChooser.chooseFile(fcd, getContentPane(), myProject, null);
if (file == null) {
return;
}
myPathField.setText(file.getPath().replace('/', File.separatorChar));
}
示例10: setupRootAndAnnotateExternally
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入方法依賴的package包/類
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(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(@NotNull 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();
}
示例11: AdtImportLocationStep
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入方法依賴的package包/類
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;
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;
}
});
}
示例12: getFileChooserDescriptor
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入方法依賴的package包/類
public FileChooserDescriptor getFileChooserDescriptor() {
if (myFileChooserDescriptor == null) {
myFileChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
if (myTitle != null) {
myFileChooserDescriptor.setTitle(myTitle);
}
myFileChooserDescriptor.setShowFileSystemRoots(true);
}
return myFileChooserDescriptor;
}
示例13: initComponents
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入方法依賴的package包/類
protected void initComponents() {
myProgramParametersComponent = LabeledComponent.create(new RawCommandLineEditor(),
ExecutionBundle.message("run.configuration.program.parameters"));
FileChooserDescriptor fileChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
//noinspection DialogTitleCapitalization
fileChooserDescriptor.setTitle(ExecutionBundle.message("select.working.directory.message"));
myWorkingDirectoryField = new TextFieldWithBrowseButton();
myWorkingDirectoryField.addBrowseFolderListener(new MacroAwareTextBrowseFolderListener(fileChooserDescriptor, getProject()) {
@Override
public void actionPerformed(ActionEvent e) {
myFileChooserDescriptor.putUserData(LangDataKeys.MODULE_CONTEXT, myModuleContext);
setProject(getProject());
super.actionPerformed(e);
}
});
myWorkingDirectoryComponent = LabeledComponent.create(createComponentWithMacroBrowse(myWorkingDirectoryField), ExecutionBundle.message("run.configuration.working.directory.label"));
myEnvVariablesComponent = new EnvironmentVariablesComponent();
myEnvVariablesComponent.setLabelLocation(BorderLayout.WEST);
myProgramParametersComponent.setLabelLocation(BorderLayout.WEST);
myWorkingDirectoryComponent.setLabelLocation(BorderLayout.WEST);
addComponents();
setPreferredSize(new Dimension(10, 10));
setAnchor(myEnvVariablesComponent.getLabel());
}
示例14: JdkLocationStep
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入方法依賴的package包/類
public JdkLocationStep(@NotNull ScopedStateStore.Key<String> pathKey, @NotNull FirstRunWizardMode mode) {
super("Java Settings");
myPathKey = pathKey;
myMode = mode;
myDownloadPageLink.setText(getLinkText());
WelcomeUIUtils.makeButtonAHyperlink(myDownloadPageLink, Jdks.DOWNLOAD_JDK_7_URL);
myDownloadPageLink.getParent().invalidate();
setComponent(myContents);
myError.setForeground(JBColor.red);
FileChooserDescriptor folderDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
myJdkPath.addBrowseFolderListener("Select JDK Location", "Select compatible JDK location", null, folderDescriptor);
myError.setText(null);
myDetectButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
myDetectButton.setEnabled(false);
JdkDetection.startWithProgressIndicator(new JdkDetection.JdkDetectionResult() {
@Override
public void onSuccess(String newJdkPath) {
if (newJdkPath == null) {
String message = AndroidBundle.message("android.wizard.jdk.autodetect.result.not.found");
ExternalSystemUiUtil.showBalloon(myJdkPath, MessageType.INFO, message);
}
else {
myJdkPath.setText(newJdkPath);
}
myDetectButton.setEnabled(true);
}
@Override
public void onCancel() {
myDetectButton.setEnabled(true);
}
});
}
});
}
示例15: create
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入方法依賴的package包/類
public AntInstallation create() {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
VirtualFile file = FileChooser.chooseFile(descriptor, myParent, null, null);
if (file == null) return null;
try {
final AntInstallation inst = AntInstallation.fromHome(file.getPresentableUrl());
adjustName(inst);
return inst;
}
catch (AntInstallation.ConfigurationException e) {
Messages.showErrorDialog(myParent, e.getMessage(), AntBundle.message("ant.setup.dialog.title"));
return null;
}
}