本文整理汇总了Java中com.intellij.openapi.fileChooser.FileChooserFactory类的典型用法代码示例。如果您正苦于以下问题:Java FileChooserFactory类的具体用法?Java FileChooserFactory怎么用?Java FileChooserFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileChooserFactory类属于com.intellij.openapi.fileChooser包,在下文中一共展示了FileChooserFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: browseForFile
import com.intellij.openapi.fileChooser.FileChooserFactory; //导入依赖的package包/类
private void browseForFile() {
FileSaverDescriptor fileSaverDescriptor = new FileSaverDescriptor("Project location", "Please choose a location for your project");
File currentPath = new File(myProjectLocation.getText());
File parentPath = currentPath.getParentFile();
if (parentPath == null) {
String homePath = System.getProperty("user.home");
parentPath = homePath == null ? new File("/") : new File(homePath);
}
VirtualFile parent = LocalFileSystem.getInstance().findFileByIoFile(parentPath);
String filename = currentPath.getName();
VirtualFileWrapper fileWrapper =
FileChooserFactory.getInstance().createSaveFileDialog(fileSaverDescriptor, (Project)null).save(parent, filename);
if (fileWrapper != null) {
myProjectLocation.setText(fileWrapper.getFile().getAbsolutePath());
}
}
示例2: createUIComponents
import com.intellij.openapi.fileChooser.FileChooserFactory; //导入依赖的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);
}
示例3: selectFileAndCreateWizard
import com.intellij.openapi.fileChooser.FileChooserFactory; //导入依赖的package包/类
@Nullable
public static AddModuleWizard selectFileAndCreateWizard(@Nullable Project project,
@Nullable Component dialogParent,
@NotNull FileChooserDescriptor descriptor,
ProjectImportProvider[] providers) {
FileChooserDialog chooser = FileChooserFactory.getInstance().createFileChooser(descriptor, project, dialogParent);
VirtualFile toSelect = null;
String lastLocation = PropertiesComponent.getInstance().getValue(LAST_IMPORTED_LOCATION);
if (lastLocation != null) {
toSelect = LocalFileSystem.getInstance().refreshAndFindFileByPath(lastLocation);
}
VirtualFile[] files = chooser.choose(project, toSelect);
if (files.length == 0) {
return null;
}
final VirtualFile file = files[0];
PropertiesComponent.getInstance().setValue(LAST_IMPORTED_LOCATION, file.getPath());
return createImportWizard(project, dialogParent, file, providers);
}
示例4: doInstall
import com.intellij.openapi.fileChooser.FileChooserFactory; //导入依赖的package包/类
private static <T extends JComponent> void doInstall(@Nullable Project project,
@NotNull ComponentWithBrowseButton<T> componentWithBrowseButton,
@NotNull JTextField textField,
@NotNull @Nls(capitalization = Nls.Capitalization.Title) String browseDialogTitle,
@NotNull FileChooserDescriptor fileChooserDescriptor,
@NotNull TextComponentAccessor<T> textComponentAccessor) {
fileChooserDescriptor = fileChooserDescriptor.withShowHiddenFiles(SystemInfo.isUnix);
componentWithBrowseButton.addBrowseFolderListener(
project,
new ComponentWithBrowseButton.BrowseFolderActionListener<T>(
browseDialogTitle,
null,
componentWithBrowseButton,
project,
fileChooserDescriptor,
textComponentAccessor
),
true
);
FileChooserFactory.getInstance().installFileCompletion(
textField,
fileChooserDescriptor,
true,
project
);
}
示例5: addWorkingDirectoryBrowseAction
import com.intellij.openapi.fileChooser.FileChooserFactory; //导入依赖的package包/类
protected void addWorkingDirectoryBrowseAction(final JPanel pane,
FixedSizeButton browseDirectoryButton,
JTextField tfCommandWorkingDirectory) {
browseDirectoryButton.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, myProject, pane);
chooser.choose(null, new Consumer<List<VirtualFile>>() {
@Override
public void consume(List<VirtualFile> files) {
VirtualFile file = !files.isEmpty() ? files.get(0) : null;
if (file != null) {
myTfCommandWorkingDirectory.setText(file.getPresentableUrl());
}
}
});
}
}
);
}
示例6: selectFileAndCreateWizard
import com.intellij.openapi.fileChooser.FileChooserFactory; //导入依赖的package包/类
@Nullable
private AddModuleWizard selectFileAndCreateWizard(@NotNull FileChooserDescriptor descriptor)
throws IOException, ConfigurationException {
FileChooserDialog chooser = FileChooserFactory.getInstance().createFileChooser(descriptor, null, null);
VirtualFile toSelect = null;
String lastLocation = PropertiesComponent.getInstance().getValue(LAST_IMPORTED_LOCATION);
if (lastLocation != null) {
toSelect = LocalFileSystem.getInstance().refreshAndFindFileByPath(lastLocation);
}
VirtualFile[] files = chooser.choose(null, toSelect);
if (files.length == 0) {
return null;
}
VirtualFile file = files[0];
PropertiesComponent.getInstance().setValue(LAST_IMPORTED_LOCATION, file.getPath());
return createImportWizard(file);
}
示例7: actionPerformed
import com.intellij.openapi.fileChooser.FileChooserFactory; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, false, true);
String homePath = System.getProperty("user.home");
File parentPath = homePath == null ? new File("/") : new File(homePath);
VirtualFile parent = LocalFileSystem.getInstance().findFileByIoFile(parentPath);
VirtualFile[] files =
FileChooserFactory.getInstance().createFileChooser(descriptor, null, null).choose(parent, null);
List<Device> importedDevices = Lists.newArrayList();
for (VirtualFile vf : files) {
for (Device d : DeviceManagerConnection.getDevicesFromFile(VfsUtilCore.virtualToIoFile(vf))) {
importedDevices.add(d);
}
}
if (!importedDevices.isEmpty()) {
DeviceManagerConnection.getDefaultDeviceManagerConnection().createDevices(importedDevices);
myProvider.refreshDevices();
}
}
示例8: chooseDirectory
import com.intellij.openapi.fileChooser.FileChooserFactory; //导入依赖的package包/类
private void chooseDirectory() {
FileChooserDescriptor descriptor =
FileChooserDescriptorFactory.createSingleFolderDescriptor()
.withTitle("Export Directory Location")
.withDescription("Choose directory to export run configurations to")
.withHideIgnored(false);
FileChooserDialog chooser =
FileChooserFactory.getInstance().createFileChooser(descriptor, null, null);
final VirtualFile[] files;
File existingLocation = new File(getOutputDirectoryPath());
if (existingLocation.exists()) {
VirtualFile toSelect =
LocalFileSystem.getInstance().refreshAndFindFileByPath(existingLocation.getPath());
files = chooser.choose(null, toSelect);
} else {
files = chooser.choose(null);
}
if (files.length == 0) {
return;
}
VirtualFile file = files[0];
outputDirectoryPanel.setText(file.getPath());
}
示例9: AddFileChooserToPanel
import com.intellij.openapi.fileChooser.FileChooserFactory; //导入依赖的package包/类
private void AddFileChooserToPanel(JBLabel chooserLabel, TextFieldWithBrowseButton textFieldWithBrowseButton, boolean hideFiles){
chooserLabel.setAnchor(textFieldWithBrowseButton);
chooserLabel.setLabelFor(textFieldWithBrowseButton);
final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, false, false);
final JTextField myTextField = textFieldWithBrowseButton.getTextField();
FileChooserFactory.getInstance().installFileCompletion(myTextField, descriptor, false, null);
textFieldWithBrowseButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser chooser = new JFileChooser();
chooser.setFileHidingEnabled(hideFiles);
int returnVal = chooser.showDialog(panel, "Create");
if (returnVal == JFileChooser.APPROVE_OPTION) {
myTextField.setText(chooser.getSelectedFile().getPath());
}
}
});
AddFieldToPanel(chooserLabel, textFieldWithBrowseButton);
}
示例10: getFileSaverListener
import com.intellij.openapi.fileChooser.FileChooserFactory; //导入依赖的package包/类
private ActionListener getFileSaverListener(final TextFieldWithBrowseButton field, final TextFieldWithBrowseButton fieldToUpdate,
final String suffixToReplace, final String suffix) {
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final FileSaverDialog dialog = FileChooserFactory.getInstance().createSaveFileDialog(
new FileSaverDescriptor(message("newCertDlgBrwFldr"), "", suffixToReplace), field);
final VirtualFile baseDir = myProject.getBaseDir();
final VirtualFileWrapper save = dialog.save(baseDir, "");
if (save != null) {
field.setText(FileUtil.toSystemDependentName(save.getFile().getAbsolutePath()));
if (fieldToUpdate.getText().isEmpty()) {
fieldToUpdate.setText(Utils.replaceLastSubString(field.getText(), suffixToReplace, suffix));
}
}
}
};
}
示例11: actionPerformed
import com.intellij.openapi.fileChooser.FileChooserFactory; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent anActionEvent) {
final Project project = PlatformDataKeys.PROJECT.getData(anActionEvent.getDataContext());
if (project == null) return;
final FileSaverDialog dialog = FileChooserFactory.getInstance().createSaveFileDialog(new FileSaverDescriptor("Init Fossil Repository",
"Select file where to create new Fossil repository."), project);
final VirtualFileWrapper wrapper = dialog.save(null, null);
if (wrapper == null) return;
final Task.Backgroundable task = new Task.Backgroundable(project, "Init Fossil Repository", false, PerformInBackgroundOption.ALWAYS_BACKGROUND) {
@Override
public void run(@NotNull ProgressIndicator progressIndicator) {
try {
new CheckoutUtil(project).initRepository(wrapper.getFile());
VcsBalloonProblemNotifier.showOverVersionControlView(project, "Fossil repository successfully created: " + wrapper.getFile().getPath(), MessageType.INFO);
} catch (VcsException e) {
VcsBalloonProblemNotifier.showOverVersionControlView(project, "Fossil repository not created: " + e.getMessage(), MessageType.ERROR);
}
}
};
ProgressManager.getInstance().run(task);
}
示例12: selectFileAndCreateWizard
import com.intellij.openapi.fileChooser.FileChooserFactory; //导入依赖的package包/类
@Nullable
public static AddModuleWizard selectFileAndCreateWizard(final Project project,
@Nullable Component dialogParent,
@NotNull FileChooserDescriptor descriptor,
ProjectImportProvider[] providers)
{
FileChooserDialog chooser = FileChooserFactory.getInstance().createFileChooser(descriptor, project, dialogParent);
VirtualFile toSelect = null;
String lastLocation = PropertiesComponent.getInstance().getValue(LAST_IMPORTED_LOCATION);
if (lastLocation != null) {
toSelect = LocalFileSystem.getInstance().refreshAndFindFileByPath(lastLocation);
}
VirtualFile[] files = chooser.choose(toSelect, project);
if (files.length == 0) {
return null;
}
final VirtualFile file = files[0];
PropertiesComponent.getInstance().setValue(LAST_IMPORTED_LOCATION, file.getPath());
return createImportWizard(project, dialogParent, file, providers);
}
示例13: addWorkingDirectoryBrowseAction
import com.intellij.openapi.fileChooser.FileChooserFactory; //导入依赖的package包/类
protected void addWorkingDirectoryBrowseAction(final JPanel pane,
FixedSizeButton browseDirectoryButton,
JTextField tfCommandWorkingDirectory) {
browseDirectoryButton.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
PathChooserDialog chooser = FileChooserFactory.getInstance().createPathChooser(descriptor, myProject, pane);
chooser.choose(null, new Consumer<List<VirtualFile>>() {
@Override
public void consume(List<VirtualFile> files) {
VirtualFile file = files.size() > 0 ? files.get(0) : null;
if (file != null) {
myTfCommandWorkingDirectory.setText(file.getPresentableUrl());
}
}
});
}
}
);
}
示例14: actionPerformed
import com.intellij.openapi.fileChooser.FileChooserFactory; //导入依赖的package包/类
@Override
protected void actionPerformed(AnActionEvent event, Project project, Entity entity) {
String name = entity.getPropertyValue("name");
FileSaverDescriptor desc = new FileSaverDescriptor("Download Attachment", "Download attachment to the local filesystem.");
final VirtualFileWrapper file = FileChooserFactory.getInstance().createSaveFileDialog(desc, project).save(lastDir, name.replaceFirst("\\.agmlink$", ""));
if(file != null) {
VirtualFile vf = file.getVirtualFile(true);
if(vf == null) {
Messages.showErrorDialog("Invalid file specified", "Error");
return;
}
lastDir = vf.getParent();
if (!name.endsWith(".agmlink") || file.getFile().getName().endsWith(".agmlink")) {
// either regular file or we explicitly ask for .agmlink file
ProgressManager.getInstance().run(new AttachmentDownloadTask(project, file.getFile(), name, Integer.valueOf(entity.getPropertyValue("file-size")), new EntityRef(entity.getPropertyValue("parent-type"), Integer.valueOf(entity.getPropertyValue("parent-id"))), null));
} else {
// download referenced content instead
ProgressManager.getInstance().run(new AttachmentAgmLinkDownloadTask(project, file.getFile(), name, Integer.valueOf(entity.getPropertyValue("file-size")), new EntityRef(entity.getPropertyValue("parent-type"), Integer.valueOf(entity.getPropertyValue("parent-id"))), null));
}
}
}
示例15: createOutputPathPanel
import com.intellij.openapi.fileChooser.FileChooserFactory; //导入依赖的package包/类
private CommitableFieldPanel createOutputPathPanel(final String title, final CommitPathRunnable commitPathRunnable) {
final JTextField textField = new JTextField();
final FileChooserDescriptor outputPathsChooserDescriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
outputPathsChooserDescriptor.setHideIgnored(false);
InsertPathAction.addTo(textField, outputPathsChooserDescriptor);
FileChooserFactory.getInstance().installFileCompletion(textField, outputPathsChooserDescriptor, true, null);
CommitableFieldPanel commitableFieldPanel =
new CommitableFieldPanel(textField, null, null, new BrowseFilesListener(textField, title, "", outputPathsChooserDescriptor), null);
commitableFieldPanel.myCommitRunnable = new Runnable() {
@Override
public void run() {
if (!getModel().isWritable()) {
return;
}
String url = commitableFieldPanel.getUrl();
commitPathRunnable.saveUrl(url);
}
};
return commitableFieldPanel;
}