use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-plugins by JetBrains.
the class OsmorcFacetJAREditorTab method onAddAdditionalJarContent.
private void onAddAdditionalJarContent() {
Project project = myEditorContext.getProject();
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createAllButJarContentsDescriptor().withTitle(OsmorcBundle.message("facet.editor.select.source.title"));
VirtualFile rootFolder = null;
VirtualFile[] contentRoots = ModuleRootManager.getInstance(myEditorContext.getModule()).getContentRoots();
if (contentRoots.length > 0) {
rootFolder = contentRoots[0];
} else if (project.getBaseDir() != null) {
rootFolder = project.getBaseDir();
}
VirtualFile[] files = FileChooser.chooseFiles(descriptor, project, rootFolder);
for (VirtualFile file : files) {
String destFile = determineMostLikelyLocationInJar(file);
int row = myAdditionalJARContentsTableModel.addAdditionalJARContent(file.getPath(), destFile);
myAdditionalJARContentsTable.editCellAt(row, 1);
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
IdeFocusManager.getGlobalInstance().requestFocus(myAdditionalJARContentsTable.getEditorComponent(), true);
});
}
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-plugins by JetBrains.
the class ConfigFileRunSettingsSection method createComponent.
@NotNull
@Override
protected JComponent createComponent(@NotNull CreationContext creationContext) {
JPanel panel = new JPanel(new GridBagLayout());
{
GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(UIUtil.DEFAULT_VGAP, 0, 0, UIUtil.DEFAULT_HGAP), 0, 0);
myLabel.setDisplayedMnemonic('C');
myLabel.setHorizontalAlignment(SwingConstants.RIGHT);
myLabel.setLabelFor(myConfigFileTextFieldWithBrowseButton.getTextField());
panel.add(myLabel, c);
}
{
GridBagConstraints c = new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(UIUtil.DEFAULT_VGAP, 0, 0, 0), 0, 0);
final Project project = creationContext.getProject();
final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, false, false) {
@Override
public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
boolean visible = super.isFileVisible(file, showHiddenFiles);
if (visible && !file.isDirectory() && !showHiddenFiles) {
visible = JstdConfigFileUtils.isJstdConfigFile(file);
}
return visible;
}
};
final JTextField configFileTextField = myConfigFileTextFieldWithBrowseButton.getTextField();
FileChooserFactory.getInstance().installFileCompletion(configFileTextField, descriptor, false, null);
myConfigFileTextFieldWithBrowseButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
PsiFile initialPsiFile = getConfigFile(project);
TreeFileChooserDialog fileChooser = new TreeFileChooserDialog(project, "Select JsTestDriver configuration file", initialPsiFile, JstdConfigFileType.INSTANCE, new TreeFileChooser.PsiFileFilter() {
@Override
public boolean accept(PsiFile psiFile) {
return true;
}
}, false, false);
boolean jstdConfigFilesExists = JstdSettingsUtil.areJstdConfigFilesInProject(project);
if (jstdConfigFilesExists) {
fileChooser.selectSearchByNameTab();
}
fileChooser.showDialog();
PsiFile psiFile = fileChooser.getSelectedFile();
if (psiFile != null) {
VirtualFile vFile = psiFile.getVirtualFile();
if (vFile != null) {
String path = FileUtil.toSystemDependentName(vFile.getPath());
configFileTextField.setText(path);
}
}
}
});
panel.add(myConfigFileTextFieldWithBrowseButton, c);
}
SwingUtils.addGreedyBottomRow(panel);
return panel;
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-plugins by JetBrains.
the class JsFileRunSettingsSection method createComponent.
@NotNull
@Override
public JComponent createComponent(@NotNull CreationContext creationContext) {
JPanel panel = new JPanel(new GridBagLayout());
{
GridBagConstraints c = new GridBagConstraints(0, 0, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0);
JComponent configComponent = myConfigFileRunSettingsSection.getComponent(creationContext);
panel.add(configComponent, c);
}
{
myLabel.setHorizontalAlignment(SwingConstants.RIGHT);
myLabel.setDisplayedMnemonic('J');
myLabel.setLabelFor(myJsTestFileTextFieldWithBrowseButton.getTextField());
GridBagConstraints c = new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(UIUtil.DEFAULT_VGAP, 0, 0, UIUtil.DEFAULT_HGAP), 0, 0);
panel.add(myLabel, c);
}
{
GridBagConstraints c = new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(UIUtil.DEFAULT_VGAP, 0, 0, 0), 0, 0);
FileChooserDescriptor jsFileChooserDescriptor = new FileTypeDescriptor("Select JavaScript test file", ".js");
myJsTestFileTextFieldWithBrowseButton.addBrowseFolderListener(null, null, creationContext.getProject(), jsFileChooserDescriptor);
panel.add(myJsTestFileTextFieldWithBrowseButton, c);
myLabel.setLabelFor(myJsTestFileTextFieldWithBrowseButton);
}
SwingUtils.addGreedyBottomRow(panel);
return panel;
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project intellij-plugins by JetBrains.
the class FlexLauncherDialog method initControls.
private void initControls(final LauncherParameters launcherParameters) {
final LauncherParameters.LauncherType launcherType = launcherParameters.getLauncherType();
myDefaultOSApplicationRadioButton.setSelected(launcherType == LauncherParameters.LauncherType.OSDefault);
myBrowserRadioButton.setSelected(launcherType == LauncherParameters.LauncherType.Browser);
myPlayerRadioButton.setSelected(launcherType == LauncherParameters.LauncherType.Player);
myBrowserSelector.setSelected(launcherParameters.getBrowser());
myPlayerTextWithBrowse.setText(FileUtil.toSystemDependentName(launcherParameters.getPlayerPath()));
myPlayerTextWithBrowse.addBrowseFolderListener(null, null, myProject, new FileChooserDescriptor(true, true, false, false, false, false) {
@Override
public boolean isFileSelectable(final VirtualFile file) {
return SystemInfo.isMac && file.isDirectory() && "app".equalsIgnoreCase(file.getExtension()) || !file.isDirectory();
}
});
myNewPlayerInstanceCheckBox.setVisible(SystemInfo.isMac);
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project android by JetBrains.
the class ApkEditor method selectApkAndCompare.
@Override
public void selectApkAndCompare() {
FileChooserDescriptor desc = new FileChooserDescriptor(true, false, false, false, false, false);
desc.withFileFilter(file -> ApkFileSystem.EXTENSIONS.contains(file.getExtension()));
VirtualFile file = FileChooser.chooseFile(desc, myProject, null);
if (file == null) {
// user canceled
return;
}
VirtualFile newApk = ApkFileSystem.getInstance().getRootByLocal(file);
assert newApk != null;
DialogBuilder builder = new DialogBuilder(myProject);
builder.setTitle(myRoot.getName() + " vs " + newApk.getName());
ApkDiffParser parser = new ApkDiffParser(myRoot, newApk);
ApkDiffPanel panel = new ApkDiffPanel(parser);
builder.setCenterPanel(panel.getContainer());
builder.setPreferredFocusComponent(panel.getPreferredFocusedComponent());
builder.show();
}
Aggregations