use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project android by JetBrains.
the class AndroidImportProjectAction method createFileChooserDescriptor.
@NotNull
protected FileChooserDescriptor createFileChooserDescriptor() {
FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, true, true, false, false) {
FileChooserDescriptor myDelegate = new OpenProjectFileChooserDescriptor(true);
@Override
public Icon getIcon(VirtualFile file) {
Icon icon = myDelegate.getIcon(file);
return icon == null ? super.getIcon(file) : icon;
}
};
descriptor.setHideIgnored(false);
descriptor.setTitle(WIZARD_TITLE);
descriptor.setDescription(WIZARD_DESCRIPTION);
return descriptor;
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project android by JetBrains.
the class SelectNdkDialog method configureNdkTextField.
private void configureNdkTextField() {
myNdkTextFieldWithButton.setTextFieldPreferredWidth(50);
FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, false, false, false) {
@Override
public void validateSelectedFiles(VirtualFile[] files) throws Exception {
for (VirtualFile virtualFile : files) {
File file = virtualToIoFile(virtualFile);
ValidationResult validationResult = validateAndroidNdk(file, false);
if (!validationResult.success) {
String msg = validationResult.message;
if (isEmpty(msg)) {
msg = "Please choose a valid Android NDK directory.";
}
throw new IllegalArgumentException(msg);
}
}
}
};
if (SystemInfo.isMac) {
descriptor.withShowHiddenFiles(true);
}
descriptor.setTitle("Choose Android NDK Location");
myNdkTextFieldWithButton.addActionListener(new ComponentWithBrowseButton.BrowseFolderActionListener<JTextField>("Select Android NDK Home", null, myNdkTextFieldWithButton, null, descriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT));
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project android by JetBrains.
the class ImportDevicesAction method actionPerformed.
@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();
}
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project android by JetBrains.
the class IdeSdksConfigurable method createTextFieldWithBrowseButton.
@NotNull
private TextFieldWithBrowseButton createTextFieldWithBrowseButton(@NotNull String title, @NotNull String errorMessage, @NotNull Function<File, ValidationResult> validation) {
FileChooserDescriptor descriptor = createSingleFolderDescriptor(title, file -> {
ValidationResult validationResult = validation.fun(file);
if (!validationResult.success) {
String msg = validationResult.message;
if (isEmpty(msg)) {
msg = errorMessage;
}
throw new IllegalArgumentException(msg);
}
return null;
});
JTextField textField = new JTextField(10);
return new TextFieldWithBrowseButton(textField, e -> {
VirtualFile suggestedDir = null;
File ndkLocation = getNdkLocation();
if (ndkLocation.isDirectory()) {
suggestedDir = findFileByIoFile(ndkLocation, false);
}
VirtualFile chosen = chooseFile(descriptor, null, suggestedDir);
if (chosen != null) {
File f = virtualToIoFile(chosen);
textField.setText(f.getPath());
}
});
}
use of com.intellij.openapi.fileChooser.FileChooserDescriptor in project android by JetBrains.
the class GradleSignStep method _init.
@Override
public void _init() {
myAndroidModel = AndroidModuleModel.get(myWizard.getFacet());
PropertiesComponent properties = PropertiesComponent.getInstance(myWizard.getProject());
String lastSelectedBuildType = properties.getValue(PROPERTY_BUILD_TYPE);
myBuildTypeComboModel.removeAllElements();
Set<String> buildTypes = myAndroidModel == null ? Collections.<String>emptySet() : myAndroidModel.getBuildTypes();
for (String buildType : buildTypes) {
myBuildTypeComboModel.addElement(buildType);
if ((lastSelectedBuildType == null && buildType.equals("release")) || buildType.equals(lastSelectedBuildType)) {
myBuildTypeComboModel.setSelectedItem(buildType);
}
}
myFlavorsListModel.clear();
List<String> productFlavors;
if (myAndroidModel == null || myAndroidModel.getProductFlavors().isEmpty()) {
productFlavors = Collections.emptyList();
} else {
// if there are multiple flavors, we want the merged flavor list
Set<String> mergedFlavors = Sets.newHashSet();
for (Variant v : myAndroidModel.getAndroidProject().getVariants()) {
mergedFlavors.add(ExportSignedPackageWizard.getMergedFlavorName(v));
}
productFlavors = Lists.newArrayList(mergedFlavors);
Collections.sort(productFlavors);
}
TIntArrayList lastSelectedIndices = new TIntArrayList(productFlavors.size());
String[] flavors = properties.getValues(PROPERTY_FLAVORS);
Set<String> lastSelectedFlavors = flavors == null ? Collections.<String>emptySet() : Sets.newHashSet(flavors);
for (int i = 0; i < productFlavors.size(); i++) {
String flavor = productFlavors.get(i);
myFlavorsListModel.addElement(flavor);
if (lastSelectedFlavors.contains(flavor)) {
lastSelectedIndices.add(i);
}
}
myFlavorsList.setSelectedIndices(lastSelectedIndices.toNativeArray());
String lastApkFolderPath = properties.getValue(PROPERTY_APK_PATH);
File lastApkFolder;
if (lastApkFolderPath != null) {
lastApkFolder = new File(lastApkFolderPath);
} else {
if (myAndroidModel == null) {
lastApkFolder = VfsUtilCore.virtualToIoFile(myWizard.getProject().getBaseDir());
} else {
lastApkFolder = myAndroidModel.getRootDirPath();
}
}
myApkPathField.setText(lastApkFolder.getAbsolutePath());
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
myApkPathField.addBrowseFolderListener("Select APK Destination Folder", null, myWizard.getProject(), descriptor);
GradleVersion modelVersion = null;
if (myAndroidModel != null) {
modelVersion = myAndroidModel.getModelVersion();
}
boolean enabled = modelVersion != null && modelVersion.compareIgnoringQualifiers(MIN_SIGNATURE_SELECTION_VERSION) >= 0;
myV1JarSignatureCheckBox.setEnabled(enabled);
myV1JarSignatureCheckBox.setSelected(properties.getBoolean(PROPERTY_V1_SIGN));
myV2FullAPKSignatureCheckBox.setEnabled(enabled);
myV2FullAPKSignatureCheckBox.setSelected(properties.getBoolean(PROPERTY_V2_SIGN));
// Set HTML label here; the visual editor does not like the " " part so set the text here.
mySignatureHelpLabel.setText("<html><a href=\"\">Signature Help</a></html>");
mySignatureHelpLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
mySignatureHelpLabel.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
if (desktop.isSupported(Desktop.Action.BROWSE)) {
URI uri;
try {
uri = new URI("http://developer.android.com/about/versions/nougat/android-7.0.html#apk_signature_v2");
} catch (URISyntaxException ex) {
throw new AssertionError(ex);
}
try {
desktop.browse(uri);
} catch (IOException ex) {
LOG.error("Failed to open URI '" + uri + "'", ex);
}
}
}
}
});
}
Aggregations