use of com.intellij.ide.util.PropertiesComponent in project intellij-community by JetBrains.
the class DarculaInstaller method performImpl.
private static void performImpl(boolean dark) {
JBColor.setDark(dark);
IconLoader.setUseDarkIcons(dark);
EditorColorsManager colorsManager = EditorColorsManager.getInstance();
EditorColorsScheme current = colorsManager.getGlobalScheme();
if (dark != ColorUtil.isDark(current.getDefaultBackground())) {
String targetScheme = dark ? DarculaLaf.NAME : EditorColorsScheme.DEFAULT_SCHEME_NAME;
PropertiesComponent properties = PropertiesComponent.getInstance();
String savedEditorThemeKey = dark ? DARCULA_EDITOR_THEME_KEY : DEFAULT_EDITOR_THEME_KEY;
String toSavedEditorThemeKey = dark ? DEFAULT_EDITOR_THEME_KEY : DARCULA_EDITOR_THEME_KEY;
String themeName = properties.getValue(savedEditorThemeKey);
if (themeName != null && colorsManager.getScheme(themeName) != null) {
targetScheme = themeName;
}
properties.setValue(toSavedEditorThemeKey, current.getName(), dark ? EditorColorsScheme.DEFAULT_SCHEME_NAME : DarculaLaf.NAME);
EditorColorsScheme scheme = colorsManager.getScheme(targetScheme);
if (scheme != null) {
colorsManager.setGlobalScheme(scheme);
}
}
update();
}
use of com.intellij.ide.util.PropertiesComponent in project android by JetBrains.
the class ScreenshotViewer method doOKAction.
@Override
protected void doOKAction() {
FileSaverDescriptor descriptor = new FileSaverDescriptor(AndroidBundle.message("android.ddms.screenshot.save.title"), "", SdkConstants.EXT_PNG);
FileSaverDialog saveFileDialog = FileChooserFactory.getInstance().createSaveFileDialog(descriptor, myProject);
VirtualFile baseDir = loadScreenshotPath();
VirtualFileWrapper fileWrapper = saveFileDialog.save(baseDir, getDefaultFileName());
if (fileWrapper == null) {
return;
}
myScreenshotFile = fileWrapper.getFile();
try {
ImageIO.write(myDisplayedImageRef.get(), SdkConstants.EXT_PNG, myScreenshotFile);
} catch (IOException e) {
Messages.showErrorDialog(myProject, AndroidBundle.message("android.ddms.screenshot.save.error", e), AndroidBundle.message("android.ddms.actions.screenshot"));
return;
}
VirtualFile virtualFile = fileWrapper.getVirtualFile();
if (virtualFile != null) {
PropertiesComponent properties = PropertiesComponent.getInstance(myProject);
properties.setValue(SCREENSHOT_SAVE_PATH_KEY, virtualFile.getParent().getPath());
}
super.doOKAction();
}
use of com.intellij.ide.util.PropertiesComponent in project android by JetBrains.
the class IdeSdks method getAndroidSdkPath.
/**
* @return what the IDE is using as the home path for the Android SDK for new projects.
*/
@Nullable
public File getAndroidSdkPath() {
// We assume that every time new android sdk path is applied, all existing ide android sdks are removed and replaced by newly
// created ide android sdks for the platforms downloaded for the new android sdk. So, we bring the first ide android sdk configured
// at the moment and deduce android sdk path from it.
String sdkHome = null;
Sdk sdk = getFirstAndroidSdk();
if (sdk != null) {
sdkHome = sdk.getHomePath();
}
if (sdkHome != null) {
File candidate = new File(toSystemDependentName(sdkHome));
// Check if the sdk home is still valid. See https://code.google.com/p/android/issues/detail?id=197401 for more details.
if (isValidAndroidSdkPath(candidate)) {
return candidate;
}
}
// There is a possible case that android sdk which path was applied previously (setAndroidSdkPath()) didn't have any
// platforms downloaded. Hence, no ide android sdk was created and we can't deduce android sdk location from it.
// Hence, we fallback to the explicitly stored android sdk path here.
PropertiesComponent component = PropertiesComponent.getInstance(ProjectManager.getInstance().getDefaultProject());
String sdkPath = component.getValue(ANDROID_SDK_PATH_KEY);
if (sdkPath != null) {
File candidate = new File(sdkPath);
if (isValidAndroidSdkPath(candidate)) {
return candidate;
}
}
return null;
}
use of com.intellij.ide.util.PropertiesComponent in project android by JetBrains.
the class AndroidSdkUtils method setupPlatform.
private static void setupPlatform(@NotNull Module module) {
String targetHashString = getTargetHashStringFromPropertyFile(module);
if (targetHashString != null && findAndSetSdkWithHashString(module, targetHashString)) {
return;
}
PropertiesComponent component = PropertiesComponent.getInstance();
if (component.isValueSet(DEFAULT_PLATFORM_NAME_PROPERTY)) {
String defaultPlatformName = component.getValue(DEFAULT_PLATFORM_NAME_PROPERTY);
Sdk defaultLib = ProjectJdkTable.getInstance().findJdk(defaultPlatformName, AndroidSdkType.getInstance().getName());
if (defaultLib != null && tryToSetAndroidPlatform(module, defaultLib)) {
return;
}
}
for (Sdk sdk : AndroidSdks.getInstance().getAllAndroidSdks()) {
AndroidPlatform platform = AndroidPlatform.getInstance(sdk);
if (platform != null && checkSdkRoots(sdk, platform.getTarget(), false) && tryToSetAndroidPlatform(module, sdk)) {
component.setValue(DEFAULT_PLATFORM_NAME_PROPERTY, sdk.getName());
return;
}
}
}
use of com.intellij.ide.util.PropertiesComponent in project android by JetBrains.
the class GradleSignStep method commitForNext.
@Override
protected void commitForNext() throws CommitStepException {
if (myAndroidModel == null) {
throw new CommitStepException(AndroidBundle.message("android.apk.sign.gradle.no.model"));
}
final String apkFolder = myApkPathField.getText().trim();
if (apkFolder.isEmpty()) {
throw new CommitStepException(AndroidBundle.message("android.apk.sign.gradle.missing.destination"));
}
File f = new File(apkFolder);
if (!f.isDirectory() || !f.canWrite()) {
throw new CommitStepException(AndroidBundle.message("android.apk.sign.gradle.invalid.destination"));
}
int[] selectedFlavorIndices = myFlavorsList.getSelectedIndices();
if (!myFlavorsListModel.isEmpty() && selectedFlavorIndices.length == 0) {
throw new CommitStepException(AndroidBundle.message("android.apk.sign.gradle.missing.flavors"));
}
Object[] selectedFlavors = myFlavorsList.getSelectedValues();
List<String> flavors = new ArrayList<String>(selectedFlavors.length);
for (int i = 0; i < selectedFlavors.length; i++) {
flavors.add((String) selectedFlavors[i]);
}
boolean isV1 = myV1JarSignatureCheckBox.isSelected();
boolean isV2 = myV2FullAPKSignatureCheckBox.isSelected();
if (myV1JarSignatureCheckBox.isEnabled() && !isV1 && !isV2) {
throw new CommitStepException(AndroidBundle.message("android.apk.sign.gradle.missing.signature-version"));
}
myWizard.setApkPath(apkFolder);
myWizard.setGradleOptions((String) myBuildTypeCombo.getSelectedItem(), flavors);
myWizard.setV1Signature(isV1);
myWizard.setV2Signature(isV2);
PropertiesComponent properties = PropertiesComponent.getInstance(myWizard.getProject());
properties.setValue(PROPERTY_APK_PATH, apkFolder);
properties.setValues(PROPERTY_FLAVORS, ArrayUtil.toStringArray(flavors));
properties.setValue(PROPERTY_BUILD_TYPE, (String) myBuildTypeCombo.getSelectedItem());
properties.setValue(PROPERTY_V1_SIGN, myV1JarSignatureCheckBox.isSelected());
properties.setValue(PROPERTY_V2_SIGN, myV2FullAPKSignatureCheckBox.isSelected());
}
Aggregations