Search in sources :

Example 36 with PropertiesComponent

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

the class AndroidProcessChooserDialog method doOKAction.

@Override
protected void doOKAction() {
    final PropertiesComponent properties = PropertiesComponent.getInstance(myProject);
    final IDevice selectedDevice = getSelectedDevice();
    if (selectedDevice == null) {
        return;
    }
    mySelectedClient = getSelectedClient();
    if (mySelectedClient == null) {
        return;
    }
    myAndroidDebugger = (AndroidDebugger) myDebuggerTypeCombo.getSelectedItem();
    properties.setValue(DEBUGGABLE_DEVICE_PROPERTY, getPersistableName(selectedDevice));
    properties.setValue(DEBUGGABLE_PROCESS_PROPERTY, getPersistableName(mySelectedClient));
    properties.setValue(SHOW_ALL_PROCESSES_PROPERTY, Boolean.toString(myShowAllProcessesCheckBox.isSelected()));
    if (myAndroidDebugger != null) {
        properties.setValue(DEBUGGER_ID_PROPERTY, myAndroidDebugger.getId());
    }
    super.doOKAction();
}
Also used : IDevice(com.android.ddmlib.IDevice) PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 37 with PropertiesComponent

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

the class ApkStep method _commit.

@Override
public void _commit(boolean finishChosen) throws CommitStepException {
    final String apkPath = myApkPathField.getText().trim();
    if (apkPath.length() == 0) {
        throw new CommitStepException(AndroidBundle.message("android.extract.package.specify.apk.path.error"));
    }
    AndroidFacet facet = myWizard.getFacet();
    PropertiesComponent properties = PropertiesComponent.getInstance(myWizard.getProject());
    properties.setValue(ChooseModuleStep.MODULE_PROPERTY, facet != null ? facet.getModule().getName() : "");
    properties.setValue(getApkPathPropertyName(), apkPath);
    File folder = new File(apkPath).getParentFile();
    if (folder == null) {
        throw new CommitStepException(AndroidBundle.message("android.cannot.create.file.error", apkPath));
    }
    try {
        if (!folder.exists()) {
            folder.mkdirs();
        }
    } catch (Exception e) {
        throw new CommitStepException(e.getMessage());
    }
    final CompileScope compileScope = CompilerManager.getInstance(myWizard.getProject()).createModuleCompileScope(facet.getModule(), true);
    AndroidCompileUtil.setReleaseBuild(compileScope);
    properties.setValue(RUN_PROGUARD_PROPERTY, Boolean.toString(myProguardCheckBox.isSelected()));
    if (myProguardCheckBox.isSelected()) {
        final List<String> proguardOsCfgPaths = myProGuardConfigFilesPanel.getOsPaths();
        if (proguardOsCfgPaths.isEmpty()) {
            throw new CommitStepException(AndroidBundle.message("android.extract.package.specify.proguard.cfg.path.error"));
        }
        final String proguardPathsStr = mergeProguardCfgPathsToOneString(proguardOsCfgPaths);
        properties.setValue(PROGUARD_CFG_PATHS_PROPERTY, proguardPathsStr);
        for (String path : proguardOsCfgPaths) {
            if (!new File(path).isFile()) {
                throw new CommitStepException("Cannot find file " + path);
            }
        }
        compileScope.putUserData(AndroidCompileUtil.PROGUARD_CFG_PATHS_KEY, proguardPathsStr);
    }
    myWizard.setCompileScope(compileScope);
    myWizard.setApkPath(apkPath);
}
Also used : CommitStepException(com.intellij.ide.wizard.CommitStepException) CompileScope(com.intellij.openapi.compiler.CompileScope) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) CommitStepException(com.intellij.ide.wizard.CommitStepException)

Example 38 with PropertiesComponent

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

the class ApkStep method _init.

@Override
public void _init() {
    if (myInited)
        return;
    final AndroidFacet facet = myWizard.getFacet();
    Module module = facet.getModule();
    PropertiesComponent properties = PropertiesComponent.getInstance(module.getProject());
    String lastModule = properties.getValue(ChooseModuleStep.MODULE_PROPERTY);
    String lastApkPath = properties.getValue(getApkPathPropertyName());
    if (lastApkPath != null && module.getName().equals(lastModule)) {
        myApkPathField.setText(FileUtil.toSystemDependentName(lastApkPath));
    } else {
        String contentRootPath = getContentRootPath(module);
        if (contentRootPath != null) {
            String defaultPath = FileUtil.toSystemDependentName(contentRootPath + "/" + module.getName() + ".apk");
            myApkPathField.setText(defaultPath);
        }
    }
    final String runProguardPropValue = properties.getValue(RUN_PROGUARD_PROPERTY);
    boolean selected;
    if (runProguardPropValue != null) {
        selected = Boolean.parseBoolean(runProguardPropValue);
    } else {
        selected = facet.getProperties().RUN_PROGUARD;
    }
    myProguardCheckBox.setSelected(selected);
    myProGuardConfigFilesPanel.setEnabled(selected);
    final String proguardCfgPathsStr = properties.getValue(PROGUARD_CFG_PATHS_PROPERTY);
    final String[] proguardCfgPaths = proguardCfgPathsStr != null ? parseAndCheckProguardCfgPaths(proguardCfgPathsStr) : null;
    if (proguardCfgPaths != null && proguardCfgPaths.length > 0) {
        myProGuardConfigFilesPanel.setOsPaths(Arrays.asList(proguardCfgPaths));
    } else {
        final AndroidFacetConfiguration configuration = facet.getConfiguration();
        if (configuration.getState().RUN_PROGUARD) {
            myProGuardConfigFilesPanel.setUrls(facet.getProperties().myProGuardCfgFiles);
        } else {
            final List<String> urls = new ArrayList<String>();
            urls.add(AndroidCommonUtils.PROGUARD_SYSTEM_CFG_FILE_URL);
            final Pair<VirtualFile, Boolean> pair = AndroidCompileUtil.getDefaultProguardConfigFile(facet);
            if (pair != null) {
                urls.add(pair.getFirst().getUrl());
            }
            myProGuardConfigFilesPanel.setUrls(urls);
        }
    }
    myInited = true;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AndroidFacetConfiguration(org.jetbrains.android.facet.AndroidFacetConfiguration) Module(com.intellij.openapi.module.Module) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Example 39 with PropertiesComponent

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

the class ScreenshotViewer method loadScreenshotPath.

private VirtualFile loadScreenshotPath() {
    PropertiesComponent properties = PropertiesComponent.getInstance(myProject);
    String lastPath = properties.getValue(SCREENSHOT_SAVE_PATH_KEY);
    if (lastPath != null) {
        return LocalFileSystem.getInstance().findFileByPath(lastPath);
    } else {
        return myProject.getBaseDir();
    }
}
Also used : PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 40 with PropertiesComponent

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

the class LaunchEmulatorDialog method doOKAction.

@Override
protected void doOKAction() {
    final PropertiesComponent properties = PropertiesComponent.getInstance(myFacet.getModule().getProject());
    final IdDisplay selectedAvd = (IdDisplay) myAvdCombo.getComboBox().getSelectedItem();
    if (selectedAvd != null) {
        properties.setValue(SELECTED_AVD_PROPERTY, selectedAvd.getId());
    } else {
        properties.unsetValue(SELECTED_AVD_PROPERTY);
    }
    super.doOKAction();
}
Also used : IdDisplay(com.android.sdklib.repository.IdDisplay) 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