use of com.intellij.ide.util.PropertiesComponent 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);
}
}
}
}
});
}
use of com.intellij.ide.util.PropertiesComponent in project android by JetBrains.
the class NewVectorAssetStep method loadAssetPath.
private void loadAssetPath() {
Project project = myFacet.getModule().getProject();
PropertiesComponent properties = PropertiesComponent.getInstance(project);
String lastPath = properties.getValue(VECTOR_ASSET_PATH_PROPERTY);
if (lastPath != null) {
String defaultPath = FileUtil.toSystemDependentName(lastPath);
myBrowser.getAsset().path().set(new File(defaultPath));
} else {
String projectPath = project.getBasePath();
if (projectPath != null) {
String defaultPath = FileUtil.toSystemDependentName(projectPath);
myBrowser.getAsset().path().set(new File(defaultPath));
}
}
}
use of com.intellij.ide.util.PropertiesComponent in project android by JetBrains.
the class ProjectStructureConfigurable method disposeUIResources.
@Override
public void disposeUIResources() {
if (!myUiInitialized) {
return;
}
PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(myProject);
propertiesComponent.setValue(LAST_EDITED_PROPERTY, myUiState.lastEditedConfigurable);
propertiesComponent.setValue(PROPORTION_PROPERTY, String.valueOf(myUiState.proportion));
propertiesComponent.setValue(SIDE_PROPORTION_PROPERTY, String.valueOf(myUiState.sideProportion));
myUiState.proportion = mySplitter.getProportion();
saveSideProportion();
myConfigurables.forEach(Configurable::disposeUIResources);
myConfigurables.clear();
Disposer.dispose(myErrorsComponent);
Disposer.dispose(myDisposable);
myUiInitialized = false;
}
use of com.intellij.ide.util.PropertiesComponent in project intellij-plugins by JetBrains.
the class DartPubBuildDialog method reset.
private void reset() {
final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(myProject);
final String mode = propertiesComponent.getValue(DART_PUB_BUILD_MODE_KEY, DEFAULT_MODE);
if (mode.equals(RELEASE_MODE)) {
myReleaseRadioButton.setSelected(true);
} else if (mode.equals(DEBUG_MODE)) {
myDebugRadioButton.setSelected(true);
} else {
myOtherRadioButton.setSelected(true);
}
myOtherModeTextField.setText(propertiesComponent.getValue(DART_PUB_CUSTOM_BUILD_MODE_KEY, ""));
myOutputFolderField.setText(propertiesComponent.getValue(DART_PUB_BUILD_OUTPUT_KEY, DEFAULT_OUTPUT_FOLDER));
updateControls();
}
use of com.intellij.ide.util.PropertiesComponent in project intellij-plugins by JetBrains.
the class DartPubBuildDialog method saveDialogState.
private void saveDialogState() {
final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(myProject);
final String mode = myReleaseRadioButton.isSelected() ? RELEASE_MODE : myDebugRadioButton.isSelected() ? DEBUG_MODE : OTHER_MODE;
propertiesComponent.setValue(DART_PUB_BUILD_MODE_KEY, mode, DEFAULT_MODE);
if (myOtherRadioButton.isSelected()) {
propertiesComponent.setValue(DART_PUB_CUSTOM_BUILD_MODE_KEY, myOtherModeTextField.getText().trim());
}
final String outputPath = StringUtil.nullize(myOutputFolderField.getText().trim());
propertiesComponent.setValue(DART_PUB_BUILD_OUTPUT_KEY, outputPath, DEFAULT_OUTPUT_FOLDER);
}
Aggregations