本文整理匯總了Java中com.intellij.openapi.fileChooser.FileChooserDescriptorFactory類的典型用法代碼示例。如果您正苦於以下問題:Java FileChooserDescriptorFactory類的具體用法?Java FileChooserDescriptorFactory怎麽用?Java FileChooserDescriptorFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FileChooserDescriptorFactory類屬於com.intellij.openapi.fileChooser包,在下文中一共展示了FileChooserDescriptorFactory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: EduLocalCoursePanel
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入依賴的package包/類
public EduLocalCoursePanel(final StudyProjectGenerator generator, EduCustomCourseModuleBuilder builder) {
myGenerator = generator;
myBuilder = builder;
myCourseArchivePath.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
String coursePath = myCourseArchivePath.getText();
Course courseInfo = generator.addLocalCourse(coursePath);
if (courseInfo != null) {
myBuilder.setSelectedCourse(courseInfo);
myGenerator.setSelectedCourse(courseInfo);
myStudyPanel.updateInfoPanel(courseInfo);
}
else {
//TODO: implement validation
}
}
});
myCourseArchivePath.addBrowseFolderListener("Select Course Archive", null, null,
FileChooserDescriptorFactory.createSingleFileDescriptor());
}
示例2: 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);
}
});
}
示例3: 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);
}
}
示例4: actionPerformed
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入依賴的package包/類
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
logger.debug("Loading sample!");
final Project project = anActionEvent.getProject();
final PsiFile psiFile = anActionEvent.getData(CommonDataKeys.PSI_FILE);
VirtualFile sample = FileChooser.chooseFile(FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor(),
project, null);
if (sample == null)
return;
try {
final String text = new String(sample.contentsToByteArray(), sample.getCharset());
new WriteCommandAction.Simple(project, psiFile) {
@Override
protected void run() throws Throwable {
document.setText(text);
}
}.execute();
} catch (Exception e) {
logger.error(e);
}
}
示例5: createUIComponents
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入依賴的package包/類
private void createUIComponents() {
defaultExtensionLabel = new JBLabel(TesterBundle.message("settings.defaultExtension"));
defaultExtensionCombobox = new ComboBox<>(new String[]{"phpt", "php"});
bootstrapFileLabel = new JBLabel(TesterBundle.message("settings.bootstrapFile"));
bootstrapFileField = new TextFieldWithBrowseButton();
bootstrapFileField.addBrowseFolderListener(null, null, project, FileChooserDescriptorFactory.createSingleFileDescriptor("php"));
namespaceMappingTable = new NamespaceMappingTable(project);
namespaceMappingPanel = ToolbarDecorator.createDecorator(namespaceMappingTable.getTableView(), new ElementProducer<TesterNamespaceMapping>() {
@Override
public TesterNamespaceMapping createElement() {
return new TesterNamespaceMapping();
}
@Override
public boolean canCreateElement() {
return true;
}
}).createPanel();
namespaceMappingPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, JBColor.LIGHT_GRAY), TesterBundle.message("settings.namespaceMappings.title")));
}
示例6: createUIComponents
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入依賴的package包/類
private void createUIComponents() {
phpInterpreter = new PhpInterpreterComboBox(project, null);
phpInterpreter.setModel(PhpInterpretersManagerImpl.getInstance(project).getInterpreters(), null);
phpInterpreter.setNoItemText("<default project interpreter>");
interpreterOptions = new PhpConfigurationOptionsComponent();
phpIniPath = new TextFieldWithBrowseButton();
phpIniPath.addBrowseFolderListener(null, null, project, FileChooserDescriptorFactory.createSingleFileDescriptor("ini"));
useSystemPhpIniCheckbox = new JBCheckBox(TesterBundle.message("runConfiguration.editor.testEnv.useSystemPhpIni"));
interpreterLabel = new JBLabel(TesterBundle.message("runConfiguration.editor.testEnv.interpreter"));
interpreterOptionsLabel = new JBLabel(TesterBundle.message("runConfiguration.editor.testEnv.interpreterOptions"));
pathToPhpIniLabel = new JBLabel(TesterBundle.message("runConfiguration.editor.testEnv.phpIni"));
}
示例7: createUIComponents
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入依賴的package包/類
private void createUIComponents() {
testScope = new TextFieldWithBrowseButton();
testScope.addBrowseFolderListener(null, null, project, FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor());
testerExecutable = new TextFieldWithBrowseButton();
testerExecutable.addBrowseFolderListener(null, null, project, FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor());
testerOptions = new RawCommandLineEditor();
testerOptions.setDialogCaption("Options");
userSetupScript = new TextFieldWithBrowseButton();
userSetupScript.addBrowseFolderListener(null, null, project, FileChooserDescriptorFactory.createSingleFileDescriptor("php"));
testScopeLabel = new JBLabel(TesterBundle.message("runConfiguration.editor.tester.testScope"));
testerExecutableLabel = new JBLabel(TesterBundle.message("runConfiguration.editor.tester.testerExecutable"));
testerOptionsLabel = new JBLabel(TesterBundle.message("runConfiguration.editor.tester.testerOptions"));
setupScriptLabel = new JBLabel(TesterBundle.message("runConfiguration.editor.tester.setupScript"));
}
示例8: specifyADBPath
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入依賴的package包/類
private void specifyADBPath() {
final String adbPath = Global.instance().adbPath();
final VirtualFile toSelect;
if (Utils.isBlank(adbPath)) {
toSelect = null;
} else {
toSelect = LocalFileSystem.getInstance().refreshAndFindFileByPath(adbPath);
}
final VirtualFile vFile = FileChooser.chooseFile(
FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(), Global.instance().project(), toSelect);
if (vFile == null || !vFile.exists()) {
return;
}
mPresenter.chooseADBPath(vFile);
}
示例9: createComponent
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入依賴的package包/類
@Nullable
@Override
public JComponent createComponent() {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
imageFolder.addBrowseFolderListener(new TextBrowseFolderListener(descriptor) {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fc = new JFileChooser();
String current = imageFolder.getText();
if (!current.isEmpty()) {
fc.setCurrentDirectory(new File(current));
}
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.showOpenDialog(rootPanel);
File file = fc.getSelectedFile();
String path = file == null
? ""
: file.getAbsolutePath();
imageFolder.setText(path);
}
});
autoChangeCheckBox.addActionListener(e -> intervalSpinner.setEnabled(autoChangeCheckBox.isSelected()));
return rootPanel;
}
示例10: 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);
}
示例11: createLogFileChooser
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入依賴的package包/類
private void createLogFileChooser() {
myLogFile = new TextFieldWithHistory();
JPanel panel = GuiUtils.constructFieldWithBrowseButton(myLogFile, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor();
FileChooser.chooseFiles(descriptor, myProject, null, new Consumer<List<VirtualFile>>() {
@Override
public void consume(List<VirtualFile> files) {
myLogFile.setText(FileUtil.toSystemDependentName(files.get(files.size() - 1).getPath()));
}
});
}
});
myLogFileChooserPanel.setLayout(new BorderLayout());
myLogFileChooserPanel.add(panel, BorderLayout.CENTER);
}
示例12: downloadJar
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入依賴的package包/類
private void downloadJar(String jarUrl, String jarName) {
final Project project = myModule.getProject();
final String dirPath = PropertiesComponent.getInstance(project).getValue("findjar.last.used.dir");
VirtualFile toSelect = dirPath == null ? null : LocalFileSystem.getInstance().findFileByIoFile(new File(dirPath));
final VirtualFile file = FileChooser.chooseFile(FileChooserDescriptorFactory.createSingleFolderDescriptor(), project, toSelect);
if (file != null) {
PropertiesComponent.getInstance(project).setValue("findjar.last.used.dir", file.getPath());
final DownloadableFileService downloader = DownloadableFileService.getInstance();
final DownloadableFileDescription description = downloader.createFileDescription(jarUrl, jarName);
final List<VirtualFile> jars =
downloader.createDownloader(Arrays.asList(description), jarName)
.downloadFilesWithProgress(file.getPath(), project, myEditorComponent);
if (jars != null && jars.size() == 1) {
AccessToken token = WriteAction.start();
try {
OrderEntryFix.addJarToRoots(jars.get(0).getPresentableUrl(), myModule, myRef);
}
finally {
token.finish();
}
}
}
}
示例13: createUIComponents
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入依賴的package包/類
private void createUIComponents() {
myLanguageLevelCombo = new LanguageLevelCombo(JavaCoreBundle.message("default.language.level.description")) {
@Override
protected LanguageLevel getDefaultLevel() {
Sdk sdk = myProjectJdkConfigurable.getSelectedProjectJdk();
if (sdk == null) return null;
JavaSdkVersion version = JavaSdk.getInstance().getVersion(sdk);
return version == null ? null : version.getMaxLanguageLevel();
}
};
final JTextField textField = new JTextField();
final FileChooserDescriptor outputPathsChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
InsertPathAction.addTo(textField, outputPathsChooserDescriptor);
outputPathsChooserDescriptor.setHideIgnored(false);
BrowseFilesListener listener = new BrowseFilesListener(textField, "", ProjectBundle.message("project.compiler.output"), outputPathsChooserDescriptor);
myProjectCompilerOutput = new FieldPanel(textField, null, null, listener, EmptyRunnable.getInstance());
FileChooserFactory.getInstance().installFileCompletion(myProjectCompilerOutput.getTextField(), outputPathsChooserDescriptor, true, null);
}
示例14: GroovyDocGenerationPanel
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入依賴的package包/類
GroovyDocGenerationPanel() {
myInputDir.addBrowseFolderListener(GroovyDocBundle.message("groovydoc.generate.directory.browse"), null, null,
FileChooserDescriptorFactory.createSingleFolderDescriptor());
myOutputDir.addBrowseFolderListener(GroovyDocBundle.message("groovydoc.generate.directory.browse"), null, null,
FileChooserDescriptorFactory.createSingleFolderDescriptor());
myDataModel = new DefaultListModel();
myPackagesList = new JBList(myDataModel);
myPackagesList.setMinimumSize(JBUI.size(100, 150));
JScrollPane packagesScrollPane = ScrollPaneFactory.createScrollPane(myPackagesList);
myPackagesPanel.setLayout(new BorderLayout());
myPackagesPanel.setBorder(IdeBorderFactory.createTitledBorder("Source packages", false));
ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar("GroovyDoc", getActionGroup(), true);
myPackagesPanel.add(actionToolbar.getComponent(), BorderLayout.NORTH);
myPackagesPanel.add(packagesScrollPane, BorderLayout.SOUTH);
actionToolbar.updateActionsImmediately();
myPanel.setMinimumSize(JBUI.size(275, 350));
}
示例15: constructFileURLBrowserField
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; //導入依賴的package包/類
public static JPanel constructFileURLBrowserField(final TextFieldWithHistory field, final String objectName) {
return constructFieldWithBrowseButton(field, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
FileChooserDescriptor descriptor =
FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor().withTitle("Select " + objectName);
VirtualFile file = FileChooser.chooseFile(descriptor, field, null, null);
if (file != null) {
try {
field.setText(VfsUtilCore.virtualToIoFile(file).toURI().toURL().toString());
}
catch (MalformedURLException e1) {
field.setText("");
}
}
}
});
}