Search in sources :

Example 21 with PropertiesComponent

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 "&nbsp;" part so set the text here.
    mySignatureHelpLabel.setText("<html><a href=\"\">Signature&nbsp;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);
                    }
                }
            }
        }
    });
}
Also used : MouseEvent(java.awt.event.MouseEvent) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) MouseAdapter(java.awt.event.MouseAdapter) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) URI(java.net.URI) TIntArrayList(gnu.trove.TIntArrayList) Variant(com.android.builder.model.Variant) GradleVersion(com.android.ide.common.repository.GradleVersion) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) File(java.io.File)

Example 22 with PropertiesComponent

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));
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) File(java.io.File)

Example 23 with PropertiesComponent

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;
}
Also used : IdeSdksConfigurable(com.android.tools.idea.gradle.structure.IdeSdksConfigurable) PropertiesComponent(com.intellij.ide.util.PropertiesComponent)

Example 24 with PropertiesComponent

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

Example 25 with PropertiesComponent

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);
}
Also used : 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