本文整理匯總了Java中com.intellij.openapi.fileChooser.FileChooserDescriptor.putUserData方法的典型用法代碼示例。如果您正苦於以下問題:Java FileChooserDescriptor.putUserData方法的具體用法?Java FileChooserDescriptor.putUserData怎麽用?Java FileChooserDescriptor.putUserData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.openapi.fileChooser.FileChooserDescriptor
的用法示例。
在下文中一共展示了FileChooserDescriptor.putUserData方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getHomeChooserDescriptor
import com.intellij.openapi.fileChooser.FileChooserDescriptor; //導入方法依賴的package包/類
@Override
public FileChooserDescriptor getHomeChooserDescriptor() {
final FileChooserDescriptor baseDescriptor = super.getHomeChooserDescriptor();
final FileChooserDescriptor descriptor = new FileChooserDescriptor(baseDescriptor) {
@Override
public void validateSelectedFiles(VirtualFile[] files) throws Exception {
if (files.length > 0 && !JrtFileSystem.isSupported()) {
String path = files[0].getPath();
if (JrtFileSystem.isModularJdk(path) || JrtFileSystem.isModularJdk(adjustSelectedSdkHome(path))) {
throw new Exception(LangBundle.message("jrt.not.available.message"));
}
}
baseDescriptor.validateSelectedFiles(files);
}
};
descriptor.putUserData(KEY, Boolean.TRUE);
return descriptor;
}
示例2: actionPerformed
import com.intellij.openapi.fileChooser.FileChooserDescriptor; //導入方法依賴的package包/類
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
final Project project = e.getProject();
final boolean showFiles = project != null || PlatformProjectOpenProcessor.getInstanceIfItExists() != null;
final FileChooserDescriptor descriptor = showFiles ? new ProjectOrFileChooserDescriptor() : new ProjectOnlyFileChooserDescriptor();
descriptor.putUserData(PathChooserDialog.PREFER_LAST_OVER_EXPLICIT, showFiles);
FileChooser.chooseFiles(descriptor, project, VfsUtil.getUserHomeDir(), new Consumer<List<VirtualFile>>() {
@Override
public void consume(final List<VirtualFile> files) {
for (VirtualFile file : files) {
if (!descriptor.isFileSelectable(file)) {
String message = IdeBundle.message("error.dir.contains.no.project", file.getPresentableUrl());
Messages.showInfoMessage(project, message, IdeBundle.message("title.cannot.open.project"));
return;
}
}
doOpenFile(project, files);
}
});
}
示例3: actionPerformed
import com.intellij.openapi.fileChooser.FileChooserDescriptor; //導入方法依賴的package包/類
@Override
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
final boolean showFiles = project != null || PlatformProjectOpenProcessor.getInstanceIfItExists() != null;
final FileChooserDescriptor descriptor = showFiles ? new ProjectOrFileChooserDescriptor() : new ProjectOnlyFileChooserDescriptor();
descriptor.putUserData(PathChooserDialog.PREFER_LAST_OVER_EXPLICIT, showFiles);
chooseFiles(descriptor, project, getUserHomeDir(), new Consumer<List<VirtualFile>>() {
@Override
public void consume(final List<VirtualFile> files) {
for (VirtualFile file : files) {
if (!descriptor.isFileSelectable(file)) {
String message = IdeBundle.message("error.dir.contains.no.project", file.getPresentableUrl());
Messages.showInfoMessage(project, message, IdeBundle.message("title.cannot.open.project"));
return;
}
}
doOpenFile(project, files);
}
});
}
示例4: selectRoots
import com.intellij.openapi.fileChooser.FileChooserDescriptor; //導入方法依賴的package包/類
@Override
protected List<OrderRoot> selectRoots(@Nullable VirtualFile initialSelection) {
final String name = getLibraryEditor().getName();
final FileChooserDescriptor chooserDescriptor = myDescriptor.createAttachFilesChooserDescriptor(name);
if (myContextModule != null) {
chooserDescriptor.putUserData(LangDataKeys.MODULE_CONTEXT, myContextModule);
}
final VirtualFile[] files = FileChooser.chooseFiles(chooserDescriptor, myPanel, myProject, initialSelection);
if (files.length == 0) return Collections.emptyList();
return RootDetectionUtil.detectRoots(Arrays.asList(files), myPanel, myProject, myDescriptor);
}
示例5: selectFiles
import com.intellij.openapi.fileChooser.FileChooserDescriptor; //導入方法依賴的package包/類
@Override
public VirtualFile[] selectFiles(final @NotNull JComponent parent, @Nullable VirtualFile initialSelection,
final @Nullable Module contextModule, @NotNull LibraryEditor libraryEditor) {
final FileChooserDescriptor chooserDescriptor = createChooserDescriptor();
chooserDescriptor.setTitle(getChooserTitle(libraryEditor.getName()));
chooserDescriptor.setDescription(getChooserDescription());
if (contextModule != null) {
chooserDescriptor.putUserData(LangDataKeys.MODULE_CONTEXT, contextModule);
}
return FileChooser.chooseFiles(chooserDescriptor, parent, contextModule != null ? contextModule.getProject() : null, initialSelection);
}
示例6: AddContentEntryAction
import com.intellij.openapi.fileChooser.FileChooserDescriptor; //導入方法依賴的package包/類
public AddContentEntryAction() {
super(ProjectBundle.message("module.paths.add.content.action"),
ProjectBundle.message("module.paths.add.content.action.description"), AllIcons.Modules.AddContentEntry);
myDescriptor = new FileChooserDescriptor(false, true, true, false, true, true) {
@Override
public void validateSelectedFiles(VirtualFile[] files) throws Exception {
validateContentEntriesCandidates(files);
}
};
myDescriptor.putUserData(LangDataKeys.MODULE_CONTEXT, getModule());
myDescriptor.setTitle(ProjectBundle.message("module.paths.add.content.title"));
myDescriptor.setDescription(ProjectBundle.message("module.paths.add.content.prompt"));
myDescriptor.putUserData(FileChooserKeys.DELETE_ACTION_AVAILABLE, false);
}