Search in sources :

Example 16 with PropertiesComponent

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();
}
Also used : EditorColorsScheme(com.intellij.openapi.editor.colors.EditorColorsScheme) EditorColorsManager(com.intellij.openapi.editor.colors.EditorColorsManager) PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 17 with PropertiesComponent

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();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileSaverDescriptor(com.intellij.openapi.fileChooser.FileSaverDescriptor) FileSaverDialog(com.intellij.openapi.fileChooser.FileSaverDialog) IOException(java.io.IOException) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) VirtualFileWrapper(com.intellij.openapi.vfs.VirtualFileWrapper)

Example 18 with PropertiesComponent

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;
}
Also used : SdkPaths.validateAndroidSdk(com.android.tools.idea.sdk.SdkPaths.validateAndroidSdk) File(java.io.File) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) Nullable(org.jetbrains.annotations.Nullable)

Example 19 with PropertiesComponent

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;
        }
    }
}
Also used : ModuleRootModificationUtil.setModuleSdk(com.intellij.openapi.roots.ModuleRootModificationUtil.setModuleSdk) Sdk(com.intellij.openapi.projectRoots.Sdk) PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 20 with PropertiesComponent

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());
}
Also used : CommitStepException(com.intellij.ide.wizard.CommitStepException) ArrayList(java.util.ArrayList) TIntArrayList(gnu.trove.TIntArrayList) File(java.io.File) PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Aggregations

PropertiesComponent (com.intellij.ide.util.PropertiesComponent)53 File (java.io.File)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 Project (com.intellij.openapi.project.Project)5 IOException (java.io.IOException)5 NotNull (org.jetbrains.annotations.NotNull)5 ArrayList (java.util.ArrayList)4 SdkPaths.validateAndroidSdk (com.android.tools.idea.sdk.SdkPaths.validateAndroidSdk)2 CommitStepException (com.intellij.ide.wizard.CommitStepException)2 Notification (com.intellij.notification.Notification)2 NotificationListener (com.intellij.notification.NotificationListener)2 TIntArrayList (gnu.trove.TIntArrayList)2 List (java.util.List)2 JDOMException (org.jdom.JDOMException)2 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)2 Nullable (org.jetbrains.annotations.Nullable)2 Variant (com.android.builder.model.Variant)1 IDevice (com.android.ddmlib.IDevice)1 GradleVersion (com.android.ide.common.repository.GradleVersion)1 IdDisplay (com.android.sdklib.repository.IdDisplay)1