use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.
the class VcsProjectSetProcessor method getDirectory.
private static boolean getDirectory(@NotNull Context context) {
if (context.directory != null)
return true;
FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, false, false, false);
descriptor.setTitle("Select Destination Folder");
descriptor.setDescription("");
VirtualFile[] files = FileChooser.chooseFiles(descriptor, null, null);
context.directory = files.length == 0 ? null : files[0];
return context.directory != null;
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.
the class SelectLocationStep method init.
protected void init() {
final DefaultActionGroup fileSystemActionGroup = createFileSystemActionGroup();
myFileSystemToolBar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, fileSystemActionGroup, true);
final JTree tree = myFileSystemTree.getTree();
tree.getSelectionModel().addTreeSelectionListener(myTreeSelectionListener);
tree.setCellRenderer(new NodeRenderer());
tree.addMouseListener(new PopupHandler() {
public void invokePopup(Component comp, int x, int y) {
final ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UPDATE_POPUP, fileSystemActionGroup);
popupMenu.getComponent().show(comp, x, y);
}
});
tree.addSelectionPath(tree.getPathForRow(0));
new FileDrop(tree, new FileDrop.Target() {
public FileChooserDescriptor getDescriptor() {
return myChooserDescriptor;
}
public boolean isHiddenShown() {
return myFileSystemTree.areHiddensShown();
}
public void dropFiles(final List<VirtualFile> files) {
if (files.size() > 0) {
selectInTree(files.toArray(new VirtualFile[files.size()]));
}
}
});
super.init();
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.
the class InjectionsSettingsUI method doImportAction.
private void doImportAction(final DataContext dataContext) {
final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, true, false, true, false) {
@Override
public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
return super.isFileVisible(file, showHiddenFiles) && (file.isDirectory() || "xml".equals(file.getExtension()) || file.getFileType() == FileTypes.ARCHIVE);
}
@Override
public boolean isFileSelectable(VirtualFile file) {
return file.getFileType() == StdFileTypes.XML;
}
};
descriptor.setDescription("Please select the configuration file (usually named IntelliLang.xml) to import.");
descriptor.setTitle("Import Configuration");
descriptor.putUserData(LangDataKeys.MODULE_CONTEXT, LangDataKeys.MODULE.getData(dataContext));
final SplitterProportionsData splitterData = new SplitterProportionsDataImpl();
splitterData.externalizeFromDimensionService("IntelliLang.ImportSettingsKey.SplitterProportions");
final VirtualFile file = FileChooser.chooseFile(descriptor, myProject, null);
if (file == null)
return;
try {
final Configuration cfg = Configuration.load(file.getInputStream());
if (cfg == null) {
Messages.showWarningDialog(myProject, "The selected file does not contain any importable configuration.", "Nothing to Import");
return;
}
final CfgInfo info = getDefaultCfgInfo();
final Map<String, Set<InjInfo>> currentMap = ContainerUtil.classify(info.injectionInfos.iterator(), new Convertor<InjInfo, String>() {
public String convert(final InjInfo o) {
return o.injection.getSupportId();
}
});
final List<BaseInjection> originalInjections = new ArrayList<>();
final List<BaseInjection> newInjections = new ArrayList<>();
for (String supportId : InjectorUtils.getActiveInjectionSupportIds()) {
ArrayList<InjInfo> list = new ArrayList<>(ObjectUtils.notNull(currentMap.get(supportId), Collections.<InjInfo>emptyList()));
final List<BaseInjection> currentInjections = getInjectionList(list);
final List<BaseInjection> importingInjections = cfg.getInjections(supportId);
if (currentInjections == null) {
newInjections.addAll(importingInjections);
} else {
Configuration.importInjections(currentInjections, importingInjections, originalInjections, newInjections);
}
}
info.replace(originalInjections, newInjections);
myInjectionsTable.getListTableModel().setItems(getInjInfoList(myInfos));
final int n = newInjections.size();
if (n > 1) {
Messages.showInfoMessage(myProject, n + " entries have been successfully imported", "Import Successful");
} else if (n == 1) {
Messages.showInfoMessage(myProject, "One entry has been successfully imported", "Import Successful");
} else {
Messages.showInfoMessage(myProject, "No new entries have been imported", "Import");
}
} catch (Exception ex) {
Configuration.LOG.error(ex);
final String msg = ex.getLocalizedMessage();
Messages.showErrorDialog(myProject, msg != null && msg.length() > 0 ? msg : ex.toString(), "Import Failed");
}
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.
the class LibraryRootsComponentDescriptor method createAttachFilesChooserDescriptor.
/**
* @return descriptor for the file chooser which will be shown when 'Attach Files' button is pressed
* @param libraryName
*/
@NotNull
public FileChooserDescriptor createAttachFilesChooserDescriptor(@Nullable String libraryName) {
final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createMultipleJavaPathDescriptor();
descriptor.setTitle(StringUtil.isEmpty(libraryName) ? ProjectBundle.message("library.attach.files.action") : ProjectBundle.message("library.attach.files.to.library.action", libraryName));
descriptor.setDescription(ProjectBundle.message("library.attach.files.description"));
return descriptor;
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.
the class SdkConfigurationUtil method createSdk.
public static void createSdk(@Nullable final Project project, final Sdk[] existingSdks, final NullableConsumer<Sdk> onSdkCreatedCallBack, final boolean createIfExists, final boolean followSymLinks, final SdkType... sdkTypes) {
if (sdkTypes.length == 0) {
onSdkCreatedCallBack.consume(null);
return;
}
FileChooserDescriptor descriptor = createCompositeDescriptor(sdkTypes);
// XXX: Workaround for PY-21787 since the native macOS dialog always follows symlinks
if (!followSymLinks) {
descriptor.setForcedToUseIdeaFileChooser(true);
}
VirtualFile suggestedDir = getSuggestedSdkRoot(sdkTypes[0]);
FileChooser.chooseFiles(descriptor, project, suggestedDir, new FileChooser.FileChooserConsumer() {
@Override
public void consume(List<VirtualFile> selectedFiles) {
for (SdkType sdkType : sdkTypes) {
final String path = selectedFiles.get(0).getPath();
if (sdkType.isValidSdkHome(path)) {
Sdk newSdk = null;
if (!createIfExists) {
for (Sdk sdk : existingSdks) {
if (path.equals(sdk.getHomePath())) {
newSdk = sdk;
break;
}
}
}
if (newSdk == null) {
newSdk = setupSdk(existingSdks, selectedFiles.get(0), sdkType, false, null, null);
}
onSdkCreatedCallBack.consume(newSdk);
return;
}
}
onSdkCreatedCallBack.consume(null);
}
@Override
public void cancelled() {
onSdkCreatedCallBack.consume(null);
}
});
}
Aggregations