use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.
the class SetBackgroundImageDialog method setupComponents.
private void setupComponents() {
myAdjusting = true;
myPreviewPanel.setLayout(new CardLayout());
myPreviewPanel.add(myEditorPreview.getPanel(), "editor");
myPreviewPanel.add(myIdePreview, "ide");
((CardLayout) myPreviewPanel.getLayout()).show(myPreviewPanel, "editor");
myPathField.getComboBox().setEditable(true);
FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, true, false).withFileFilter(file -> ImageFileTypeManager.getInstance().isImage(file));
myPathField.addBrowseFolderListener(null, null, null, descriptor, TextComponentAccessor.STRING_COMBOBOX_WHOLE_TEXT);
JTextComponent textComponent = getComboEditor();
textComponent.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(DocumentEvent e) {
if (myAdjusting)
return;
imagePathChanged();
}
});
for (Enumeration<AbstractButton> e = getTargetRbGroup().getElements(); e.hasMoreElements(); ) {
AbstractButton button = e.nextElement();
button.setActionCommand(button.getText());
button.addItemListener(this::targetChanged);
}
for (Enumeration<AbstractButton> e = getFillRbGroup().getElements(); e.hasMoreElements(); ) {
AbstractButton button = e.nextElement();
button.setActionCommand(button.getText());
button.addItemListener(this::fillOrPlaceChanged);
}
for (Enumeration<AbstractButton> e = getPlaceRbGroup().getElements(); e.hasMoreElements(); ) {
AbstractButton button = e.nextElement();
button.setActionCommand(button.getText());
button.addItemListener(this::fillOrPlaceChanged);
}
ChangeListener opacitySync = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (myAdjusting)
return;
myAdjusting = true;
boolean b = e.getSource() == myOpacitySpinner;
if (b) {
int value = (Integer) myOpacitySpinner.getValue();
myOpacitySpinner.setValue(Math.min(Math.max(0, value), 100));
myOpacitySlider.setValue(value);
} else {
myOpacitySpinner.setValue(myOpacitySlider.getValue());
}
myAdjusting = false;
opacityChanged();
}
};
myOpacitySpinner.addChangeListener(opacitySync);
myOpacitySlider.addChangeListener(opacitySync);
myOpacitySlider.setValue(15);
myOpacitySpinner.setValue(15);
myScaleRb.setSelected(true);
myCenterRb.setSelected(true);
myEditorRb.setSelected(true);
boolean perProject = !Comparing.equal(getBackgroundSpec(myProject, getSystemProp(true)), getBackgroundSpec(null, getSystemProp(true)));
myThisProjectOnlyCb.setSelected(perProject);
myAdjusting = false;
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.
the class ValidationConfigurable method createExcludedConfigurable.
private static ExcludedEntriesConfigurable createExcludedConfigurable(final Project project) {
final ExcludesConfiguration configuration = ValidationConfiguration.getExcludedEntriesConfiguration(project);
final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, false, false, true) {
public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
return super.isFileVisible(file, showHiddenFiles) && (project.isDefault() || !index.isExcluded(file));
}
};
List<VirtualFile> allContentRoots = new ArrayList<>();
for (final Module module : ModuleManager.getInstance(project).getModules()) {
final VirtualFile[] moduleContentRoots = ModuleRootManager.getInstance(module).getContentRoots();
Collections.addAll(allContentRoots, moduleContentRoots);
}
descriptor.setRoots(allContentRoots);
return new ExcludedEntriesConfigurable(project, descriptor, configuration);
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.
the class ExtractedDirectoryElementType method chooseAndCreate.
@NotNull
public List<? extends PackagingElement<?>> chooseAndCreate(@NotNull ArtifactEditorContext context, @NotNull Artifact artifact, @NotNull CompositePackagingElement<?> parent) {
final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, true, false, true, true) {
@Override
public boolean isFileSelectable(VirtualFile file) {
if (file.isInLocalFileSystem() && file.isDirectory())
return false;
return super.isFileSelectable(file);
}
};
final VirtualFile[] files = FileChooser.chooseFiles(descriptor, context.getProject(), null);
final List<PackagingElement<?>> list = new ArrayList<>();
final PackagingElementFactory factory = PackagingElementFactory.getInstance();
for (VirtualFile file : files) {
list.add(factory.createExtractedDirectory(file));
}
return list;
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-community by JetBrains.
the class ManifestFileUtil method showDialogAndCreateManifest.
@Nullable
public static VirtualFile showDialogAndCreateManifest(final ArtifactEditorContext context, final CompositePackagingElement<?> element) {
FileChooserDescriptor descriptor = createDescriptorForManifestDirectory();
final VirtualFile directory = suggestManifestFileDirectory(element, context, context.getArtifactType());
final VirtualFile file = FileChooser.chooseFile(descriptor, context.getProject(), directory);
if (file == null) {
return null;
}
return createManifestFile(file, context.getProject());
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project azure-tools-for-java by Microsoft.
the class SparkLibraryDescription method getSparkSDKConfigurationFromLocalFile.
private NewLibraryConfiguration getSparkSDKConfigurationFromLocalFile() {
FileChooserDescriptor chooserDescriptor = new FileChooserDescriptor(false, false, true, false, true, false);
chooserDescriptor.setTitle("Select Spark SDK");
String pluginPath = PluginUtil.getPluginRootDirectory();
VirtualFile pluginVfs = LocalFileSystem.getInstance().findFileByPath(pluginPath);
VirtualFile chooseFile = FileChooser.chooseFile(chooserDescriptor, null, pluginVfs);
if (chooseFile == null) {
return null;
}
this.localPath = chooseFile.getPath();
final List<OrderRoot> roots = RootDetectionUtil.detectRoots(Arrays.asList(chooseFile), null, null, new DefaultLibraryRootsComponentDescriptor());
if (roots.isEmpty()) {
return null;
}
return new NewLibraryConfiguration(LibraryTypeServiceImpl.suggestLibraryName(roots), SparkLibraryType.getInstance(), new SparkLibraryProperties()) {
@Override
public void addRoots(@NotNull LibraryEditor libraryEditor) {
libraryEditor.addRoots(roots);
}
};
}
Aggregations