Search in sources :

Example 1 with ChromeSettings

use of com.intellij.ide.browsers.chrome.ChromeSettings in project intellij-plugins by JetBrains.

the class DartiumUtil method resetDartiumFlags.

public static void resetDartiumFlags() {
    final WebBrowser dartium = getDartiumBrowser();
    final BrowserSpecificSettings browserSpecificSettings = dartium == null ? null : dartium.getSpecificSettings();
    if (!(browserSpecificSettings instanceof ChromeSettings))
        return;
    final Map<String, String> envVars = browserSpecificSettings.getEnvironmentVariables();
    setDartFlagState(envVars, ENABLE_ASYNC_OPTION, false);
    setDartFlagState(envVars, CHECKED_MODE_OPTION, true);
}
Also used : ChromeSettings(com.intellij.ide.browsers.chrome.ChromeSettings) WebBrowser(com.intellij.ide.browsers.WebBrowser) BrowserSpecificSettings(com.intellij.ide.browsers.BrowserSpecificSettings)

Example 2 with ChromeSettings

use of com.intellij.ide.browsers.chrome.ChromeSettings in project intellij-plugins by JetBrains.

the class DartConfigurable method initDartSdkAndDartiumControls.

private void initDartSdkAndDartiumControls() {
    final Computable<ChromeSettings> currentDartiumSettingsRetriever = () -> myDartiumSettingsCurrent;
    final Computable<Boolean> isResettingControlsComputable = () -> myInReset;
    DartSdkUtil.initDartSdkAndDartiumControls(myProject, mySdkPathComboWithBrowse, myVersionLabel, myDartiumPathComboWithBrowse, currentDartiumSettingsRetriever, myDartiumSettingsButton, isResettingControlsComputable);
    final JTextComponent sdkEditor = (JTextComponent) mySdkPathComboWithBrowse.getComboBox().getEditor().getEditorComponent();
    sdkEditor.getDocument().addDocumentListener(new DocumentAdapter() {

        protected void textChanged(final DocumentEvent e) {
            final String sdkHomePath = getTextFromCombo(mySdkPathComboWithBrowse);
            if (!sdkHomePath.isEmpty()) {
                final String version = DartSdkUtil.getSdkVersion(sdkHomePath);
                if (version != null && (version.contains("-dev.") || version.contains("-edge."))) {
                    mySdkUpdateChannelCombo.setSelectedItem(DartSdkUpdateOption.StableAndDev);
                }
            }
            updateControlsEnabledState();
            updateErrorLabel();
        }
    });
    final JTextComponent dartiumEditor = (JTextComponent) myDartiumPathComboWithBrowse.getComboBox().getEditor().getEditorComponent();
    dartiumEditor.getDocument().addDocumentListener(new DocumentAdapter() {

        protected void textChanged(final DocumentEvent e) {
            updateErrorLabel();
        }
    });
    myCheckSdkUpdateCheckBox.addActionListener(e -> {
        final boolean enabled = myCheckSdkUpdateCheckBox.isSelected() && myCheckSdkUpdateCheckBox.isEnabled();
        mySdkUpdateChannelCombo.setEnabled(enabled);
        myCheckSdkUpdateButton.setEnabled(enabled);
        if (enabled) {
            IdeFocusManager.getInstance(myProject).requestFocus(mySdkUpdateChannelCombo, true);
        }
    });
    mySdkUpdateChannelCombo.setModel(new DefaultComboBoxModel(DartSdkUpdateOption.OPTIONS_TO_SHOW_IN_COMBO));
    mySdkUpdateChannelCombo.setRenderer(new ListCellRendererWrapper<DartSdkUpdateOption>() {

        @Override
        public void customize(JList list, DartSdkUpdateOption value, int index, boolean selected, boolean hasFocus) {
            setText(value.getPresentableName());
        }
    });
    myCheckSdkUpdateButton.addActionListener(e -> {
        final Runnable runnable = this::checkSdkUpdate;
        ApplicationManagerEx.getApplicationEx().runProcessWithProgressSynchronously(runnable, DartBundle.message("checking.dart.sdk.update"), true, myProject, myMainPanel);
    });
}
Also used : JTextComponent(javax.swing.text.JTextComponent) DocumentEvent(javax.swing.event.DocumentEvent) ChromeSettings(com.intellij.ide.browsers.chrome.ChromeSettings)

Example 3 with ChromeSettings

use of com.intellij.ide.browsers.chrome.ChromeSettings in project intellij-plugins by JetBrains.

the class DartConfigurable method reset.

@Override
public void reset() {
    myInReset = true;
    // remember initial state
    mySdkInitial = DartSdk.getDartSdk(myProject);
    myModulesWithDartSdkLibAttachedInitial.clear();
    if (mySdkInitial != null) {
        myModulesWithDartSdkLibAttachedInitial.addAll(DartSdkLibUtil.getModulesWithDartSdkEnabled(myProject));
    }
    myDartSupportEnabledInitial = !myModulesWithDartSdkLibAttachedInitial.isEmpty();
    myDartiumInitial = DartiumUtil.getDartiumBrowser();
    myDartiumSettingsCurrent = new ChromeSettings();
    if (myDartiumInitial != null) {
        final BrowserSpecificSettings browserSpecificSettings = myDartiumInitial.getSpecificSettings();
        if (browserSpecificSettings instanceof ChromeSettings) {
            myDartiumSettingsCurrent = (ChromeSettings) browserSpecificSettings.clone();
        }
    }
    // reset UI
    myEnableDartSupportCheckBox.setSelected(myDartSupportEnabledInitial);
    final String sdkInitialPath = mySdkInitial == null ? "" : FileUtilRt.toSystemDependentName(mySdkInitial.getHomePath());
    mySdkPathComboWithBrowse.getComboBox().getEditor().setItem(sdkInitialPath);
    if (!sdkInitialPath.isEmpty()) {
        ensureComboModelContainsCurrentItem(mySdkPathComboWithBrowse.getComboBox());
    }
    final DartSdkUpdateOption sdkUpdateOption = DartSdkUpdateOption.getDartSdkUpdateOption();
    myCheckSdkUpdateCheckBox.setSelected(sdkUpdateOption != DartSdkUpdateOption.DoNotCheck);
    mySdkUpdateChannelCombo.setSelectedItem(sdkUpdateOption);
    final String dartiumInitialPath = myDartiumInitial == null ? "" : FileUtilRt.toSystemDependentName(StringUtil.notNullize(myDartiumInitial.getPath()));
    myDartiumPathComboWithBrowse.getComboBox().getEditor().setItem(dartiumInitialPath);
    if (!dartiumInitialPath.isEmpty()) {
        ensureComboModelContainsCurrentItem(myDartiumPathComboWithBrowse.getComboBox());
    }
    // we decided to save one line in settings and always use Dartium in checked mode
    myCheckedModeCheckBox.setVisible(false);
    DartiumUtil.setCheckedMode(myDartiumSettingsCurrent.getEnvironmentVariables(), true);
    if (DartSdkLibUtil.isIdeWithMultipleModuleSupport()) {
        final CheckedTreeNode rootNode = (CheckedTreeNode) myModulesCheckboxTreeTable.getTree().getModel().getRoot();
        rootNode.setChecked(false);
        final Enumeration children = rootNode.children();
        while (children.hasMoreElements()) {
            final CheckedTreeNode node = (CheckedTreeNode) children.nextElement();
            node.setChecked(myModulesWithDartSdkLibAttachedInitial.contains((Module) node.getUserObject()));
        }
    }
    updateControlsEnabledState();
    updateErrorLabel();
    myInReset = false;
}
Also used : ChromeSettings(com.intellij.ide.browsers.chrome.ChromeSettings) BrowserSpecificSettings(com.intellij.ide.browsers.BrowserSpecificSettings) Module(com.intellij.openapi.module.Module)

Aggregations

ChromeSettings (com.intellij.ide.browsers.chrome.ChromeSettings)3 BrowserSpecificSettings (com.intellij.ide.browsers.BrowserSpecificSettings)2 WebBrowser (com.intellij.ide.browsers.WebBrowser)1 Module (com.intellij.openapi.module.Module)1 DocumentEvent (javax.swing.event.DocumentEvent)1 JTextComponent (javax.swing.text.JTextComponent)1