Search in sources :

Example 31 with PropertiesComponent

use of com.intellij.ide.util.PropertiesComponent in project adb-idea by pbreault.

the class ModuleChooserDialogHelper method saveModuleName.

private static void saveModuleName(Project project, String moduleName) {
    final PropertiesComponent properties = PropertiesComponent.getInstance(project);
    properties.setValue(SELECTED_MODULE_PROPERTY, moduleName);
}
Also used : PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 32 with PropertiesComponent

use of com.intellij.ide.util.PropertiesComponent in project intellij-community by JetBrains.

the class GenerateAntBuildDialog method saveSettings.

private void saveSettings() {
    final PropertiesComponent properties = PropertiesComponent.getInstance(myProject);
    properties.setValue(SINGLE_FILE_PROPERTY, myRbGenerateSingleFileBuild.isSelected());
    properties.setValue(UI_FORM_PROPERTY, myCbEnableUIFormsCompilation.isSelected());
    properties.setValue(FORCE_TARGET_JDK_PROPERTY, myCbForceTargetJdk.isSelected());
    properties.setValue(BACKUP_FILES_PROPERTY, myRbBackupFiles.isSelected());
    properties.setValue(INLINE_RUNTIME_CLASSPATH_PROPERTY, myCbInlineRuntimeClasspath.isSelected());
    properties.setValue(GENERATE_IDEA_HOME_PROPERTY, myGenerateIdeaHomeProperty.isSelected());
    properties.setValue(OUTPUT_FILE_NAME_PROPERTY, StringUtil.nullize(getOutputFileName()));
}
Also used : PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 33 with PropertiesComponent

use of com.intellij.ide.util.PropertiesComponent in project android by JetBrains.

the class AndroidTestCaseHelper method removeExistingAndroidSdks.

public static void removeExistingAndroidSdks() {
    ProjectJdkTable table = ProjectJdkTable.getInstance();
    invokeAndWaitIfNeeded((Runnable) () -> ApplicationManager.getApplication().runWriteAction(() -> {
        for (Sdk sdk : table.getAllJdks()) {
            table.removeJdk(sdk);
        }
        PropertiesComponent component = PropertiesComponent.getInstance(ProjectManager.getInstance().getDefaultProject());
        component.setValue("android.sdk.path", null);
    }));
}
Also used : ProjectJdkTable(com.intellij.openapi.projectRoots.ProjectJdkTable) Sdk(com.intellij.openapi.projectRoots.Sdk) PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 34 with PropertiesComponent

use of com.intellij.ide.util.PropertiesComponent in project android by JetBrains.

the class NewVectorAssetStep method saveAssetPath.

private void saveAssetPath() {
    PropertiesComponent properties = PropertiesComponent.getInstance(myFacet.getModule().getProject());
    File path = myBrowser.getAsset().path().get();
    properties.setValue(VECTOR_ASSET_PATH_PROPERTY, path.getParent());
}
Also used : PropertiesComponent(com.intellij.ide.util.PropertiesComponent) File(java.io.File)

Example 35 with PropertiesComponent

use of com.intellij.ide.util.PropertiesComponent in project android by JetBrains.

the class IdeSdks method setAndroidSdkPath.

/**
   * Sets the path of Android Studio's Android SDK. This method should be called in a write action. It is assumed that the given path has
   * been validated by {@link #isValidAndroidSdkPath(File)}. This method will fail silently if the given path is not valid.
   *
   * @param path the path of the Android SDK.
   * @see com.intellij.openapi.application.Application#runWriteAction(Runnable)
   */
@NotNull
public List<Sdk> setAndroidSdkPath(@NotNull File path, @Nullable Sdk javaSdk, @Nullable Project currentProject) {
    if (isValidAndroidSdkPath(path)) {
        ApplicationManager.getApplication().assertWriteAccessAllowed();
        // given path as well in order to be able to fallback to it later if there is still no android sdk configured within the ide.
        if (currentProject != null && !currentProject.isDisposed()) {
            String sdkPath = toCanonicalPath(path.getAbsolutePath());
            PropertiesComponent.getInstance(currentProject).setValue(ANDROID_SDK_PATH_KEY, sdkPath);
            if (!currentProject.isDefault()) {
                // Store default sdk path for default project as well in order to be able to re-use it for another ide projects if necessary.
                PropertiesComponent component = PropertiesComponent.getInstance(ProjectManager.getInstance().getDefaultProject());
                component.setValue(ANDROID_SDK_PATH_KEY, sdkPath);
            }
        }
        // Since removing SDKs is *not* asynchronous, we force an update of the SDK Manager.
        // If we don't force this update, AndroidSdks will still use the old SDK until all SDKs are properly deleted.
        AndroidSdkData oldSdkData = getSdkData(path);
        myAndroidSdks.setSdkData(oldSdkData);
        // Set up a list of SDKs we don't need any more. At the end we'll delete them.
        List<Sdk> sdksToDelete = new ArrayList<>();
        File resolved = resolvePath(path);
        // Parse out the new SDK. We'll need its targets to set up IntelliJ SDKs for each.
        AndroidSdkData sdkData = getSdkData(resolved, true);
        if (sdkData != null) {
            // Iterate over all current existing IJ Android SDKs
            for (Sdk sdk : myAndroidSdks.getAllAndroidSdks()) {
                if (sdk.getName().startsWith(SDK_NAME_PREFIX)) {
                    sdksToDelete.add(sdk);
                }
            }
        }
        for (Sdk sdk : sdksToDelete) {
            ProjectJdkTable.getInstance().removeJdk(sdk);
        }
        // If there are any API targets that we haven't created IntelliJ SDKs for yet, fill those in.
        List<Sdk> sdks = createAndroidSdkPerAndroidTarget(resolved, javaSdk);
        afterAndroidSdkPathUpdate(resolved);
        return sdks;
    }
    return Collections.emptyList();
}
Also used : AndroidSdkData(org.jetbrains.android.sdk.AndroidSdkData) ArrayList(java.util.ArrayList) SdkPaths.validateAndroidSdk(com.android.tools.idea.sdk.SdkPaths.validateAndroidSdk) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

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