private void update(ConfigurationData data) {
    data.setBasePackage(basePackageField.getText());
    data.setFsc(myFSCRadioButton.isSelected());
    data.setCompilerLibraryName(getCompilerLibraryName());
    data.setCompilerLibraryLevel(getCompilerLibraryLevel());

    try {
      data.setMaximumHeapSize(Integer.parseInt(myMaximumHeapSize.getText().trim()));
    } catch (NumberFormatException e) {
      data.setMaximumHeapSize(myData.getMaximumHeapSize());
    }

    data.setVmOptions(myVmParameters.getText().trim());

    data.setWarnings(myEnableWarnings.isSelected());
    data.setDeprecationWarnings(myDeprecationWarnings.isSelected());
    data.setUncheckedWarnings(myUncheckedWarnings.isSelected());
    data.setOptimiseBytecode(myOptimiseBytecode.isSelected());
    data.setExplainTypeErrors(myExplainTypeErrors.isSelected());
    data.setContinuations(myEnableContinuations.isSelected());

    data.setDebuggingInfoLevel((DebuggingInfoLevel) myDebuggingInfoLevel.getSelectedItem());
    data.setCompilerOptions(myCompilerOptions.getText().trim());

    data.setPluginPaths(CompilerPlugin.toPaths(myPlugins));

    updateCheckboxesState();
  }
  public void reset() {
    basePackageField.setText(myData.getBasePackage());
    myFSCRadioButton.setSelected(myData.getFsc());
    myRunSeparateCompilerRadioButton.setSelected(!myData.getFsc());
    updateLibrariesList();
    setCompilerLibraryById(
        new LibraryId(myData.getCompilerLibraryName(), myData.getCompilerLibraryLevel()));
    myMaximumHeapSize.setText(Integer.toString(myData.getMaximumHeapSize()));
    myVmParameters.setText(myData.getVmOptions());

    myEnableWarnings.setSelected(myData.getWarnings());
    myDeprecationWarnings.setSelected(myData.getDeprecationWarnings());
    myUncheckedWarnings.setSelected(myData.getUncheckedWarnings());
    myOptimiseBytecode.setSelected(myData.getOptimiseBytecode());
    myExplainTypeErrors.setSelected(myData.getExplainTypeErrors());
    myEnableContinuations.setSelected(myData.getContinuations());

    myDebuggingInfoLevel.setSelectedItem(myData.getDebuggingInfoLevel());
    myCompilerOptions.setText(myData.getCompilerOptions());

    myPlugins =
        new ArrayList(
            CompilerPlugin.fromPaths(myData.getPluginPaths(), myEditorContext.getModule()));
    getPluginsModel().setItems(myPlugins);
  }
 @Override
 protected void resetEditorFrom(GoApplicationConfiguration configuration) {
   applicationName.setText(configuration.scriptName);
   appArguments.setText(configuration.scriptArguments);
   builderArguments.setText(configuration.builderArguments);
   buildBeforeRunCheckBox.setSelected(configuration.goBuildBeforeRun);
   buildDirectoryPathBrowser.setText(configuration.goOutputDir);
   workingDirectoryBrowser.setText(configuration.workingDir);
 }
 /** If we're using ghc-mod >= 5.4, ghc-modi will be configured as `ghc-mod legacy-interactive` */
 private void ghcModLegacyInteractivePreSaveHook() {
   // If ghc-mod is not configured or is not >= 5.4, we can't infer legacy-interactive.
   if (ghcModPath.getText().isEmpty() || !isGhcMod5_4(ghcModPath.getText())) return;
   // If ghc-modi is configured and it is not >= 5.4, leave it alone.
   if (!ghcModiPath.getText().isEmpty() && !isGhcMod5_4(ghcModiPath.getText())) return;
   // If all is good, configure ghc-modi as legacy-interactive.
   ghcModiPath.setText(ghcModPath.getText());
   // If the current ghc-modi flags contains the `legacy-interactive` command, do not add it back.
   if (!ghcModiFlags.getText().contains("legacy-interactive")) {
     ghcModiFlags.setText(ghcModiFlags.getText() + " legacy-interactive");
   }
 }
  @Override
  protected void applyEditorTo(GoApplicationConfiguration configuration)
      throws ConfigurationException {
    if (applicationName.getText().length() == 0)
      throw new ConfigurationException("Please select the file to run.");
    if (buildBeforeRunCheckBox.isSelected() && buildDirectoryPathBrowser.getText().equals("")) {
      throw new ConfigurationException("Please select the directory for the executable.");
    }

    configuration.scriptName = applicationName.getText();
    configuration.scriptArguments = appArguments.getText();
    configuration.builderArguments = builderArguments.getText();
    configuration.goBuildBeforeRun = buildBeforeRunCheckBox.isSelected();
    configuration.goOutputDir = buildDirectoryPathBrowser.getText();
    configuration.workingDir = workingDirectoryBrowser.getText();
  }
 @Override
 protected void applyEditorTo(@NotNull ErlangConsoleRunConfiguration config)
     throws ConfigurationException {
   config.setModule((Module) myModuleComboBox.getSelectedItem());
   config.setWorkingDirPath(myWorkingDirPathField.getText());
   config.setConsoleArgs(myConsoleArgsEditor.getText());
 }
  @Override
  public void apply() throws ConfigurationException {
    commonCompilerArguments.suppressWarnings = generateNoWarningsCheckBox.isSelected();
    compilerSettings.setAdditionalArguments(additionalArgsOptionsField.getText());
    compilerSettings.setScriptTemplates(scriptTemplatesField.getText());
    compilerSettings.setScriptTemplatesClasspath(scriptTemplatesClasspathField.getText());
    compilerSettings.setCopyJsLibraryFiles(copyRuntimeFilesCheckBox.isSelected());
    compilerSettings.setOutputDirectoryForJsLibraryFiles(outputDirectory.getText());

    if (compilerWorkspaceSettings != null) {
      compilerWorkspaceSettings.setPreciseIncrementalEnabled(
          enablePreciseIncrementalCheckBox.isSelected());

      boolean oldEnableDaemon = compilerWorkspaceSettings.getEnableDaemon();
      compilerWorkspaceSettings.setEnableDaemon(keepAliveCheckBox.isSelected());
      if (keepAliveCheckBox.isSelected() != oldEnableDaemon) {
        PluginStartupComponent.getInstance().resetAliveFlag();
      }
    }

    k2jsCompilerArguments.sourceMap = generateSourceMapsCheckBox.isSelected();
    k2jsCompilerArguments.outputPrefix = StringUtil.nullize(outputPrefixFile.getText(), true);
    k2jsCompilerArguments.outputPostfix = StringUtil.nullize(outputPostfixFile.getText(), true);
    k2jsCompilerArguments.moduleKind = getSelectedModuleKind();

    BuildManager.getInstance().clearState(project);
  }
  @Override
  public void apply(@NotNull HttpConfigurable settings) {
    if (!isValid()) {
      return;
    }

    if (isModified(settings)) {
      settings.AUTHENTICATION_CANCELLED = false;
    }

    settings.USE_PROXY_PAC = myAutoDetectProxyRb.isSelected();
    settings.USE_PAC_URL = myPacUrlCheckBox.isSelected();
    settings.PAC_URL = getText(myPacUrlTextField);
    settings.USE_HTTP_PROXY = myUseHTTPProxyRb.isSelected();
    settings.PROXY_TYPE_IS_SOCKS = mySocks.isSelected();
    settings.PROXY_AUTHENTICATION = myProxyAuthCheckBox.isSelected();
    settings.KEEP_PROXY_PASSWORD = myRememberProxyPasswordCheckBox.isSelected();

    settings.setProxyLogin(getText(myProxyLoginTextField));
    settings.setPlainProxyPassword(new String(myProxyPasswordTextField.getPassword()));
    settings.PROXY_EXCEPTIONS = StringUtil.nullize(myProxyExceptions.getText(), true);

    settings.PROXY_PORT = myProxyPortTextField.getNumber();
    settings.PROXY_HOST = getText(myProxyHostTextField);
  }
  @Override
  public void reset(@NotNull HttpConfigurable settings) {
    myNoProxyRb.setSelected(true); // default
    myAutoDetectProxyRb.setSelected(settings.USE_PROXY_PAC);
    myPacUrlCheckBox.setSelected(settings.USE_PAC_URL);
    myPacUrlTextField.setText(settings.PAC_URL);
    myUseHTTPProxyRb.setSelected(settings.USE_HTTP_PROXY);
    myProxyAuthCheckBox.setSelected(settings.PROXY_AUTHENTICATION);

    enableProxy(settings.USE_HTTP_PROXY);

    myProxyLoginTextField.setText(settings.getProxyLogin());
    myProxyPasswordTextField.setText(settings.getPlainProxyPassword());

    myProxyPortTextField.setNumber(settings.PROXY_PORT);
    myProxyHostTextField.setText(settings.PROXY_HOST);
    myProxyExceptions.setText(StringUtil.notNullize(settings.PROXY_EXCEPTIONS));

    myRememberProxyPasswordCheckBox.setSelected(settings.KEEP_PROXY_PASSWORD);
    mySocks.setSelected(settings.PROXY_TYPE_IS_SOCKS);
    myHTTP.setSelected(!settings.PROXY_TYPE_IS_SOCKS);

    boolean showError = !StringUtil.isEmptyOrSpaces(settings.LAST_ERROR);
    myErrorLabel.setVisible(showError);
    myErrorLabel.setText(showError ? errorText(settings.LAST_ERROR) : null);

    final String oldStyleText =
        CommonProxy.getMessageFromProps(CommonProxy.getOldStyleProperties());
    myOtherWarning.setVisible(oldStyleText != null);
    if (oldStyleText != null) {
      myOtherWarning.setText(oldStyleText);
      myOtherWarning.setIcon(Messages.getWarningIcon());
    }
  }
 public void saveState() {
   if (isModified() && publisher != null) {
     publisher.onSettingsChanged(new ToolSettings(pathField.getText(), flagsField.getText()));
   }
   for (PropertyField propertyField : propertyFields) {
     propertyField.saveState();
   }
 }
 private void updateCompilerSection() {
   boolean b = !myFSCRadioButton.isSelected();
   myCompilerLibraryLabel.setEnabled(b);
   myCompilerLibrary.setEnabled(b);
   myMaximumHeapSizeLabel.setEnabled(b);
   myMaximumHeapSize.setEnabled(b);
   myVmParametersLabel.setEnabled(b);
   myVmParameters.setEnabled(b);
 }
  public void reset() {
    myEnableCompileServer.setSelected(mySettings.COMPILE_SERVER_ENABLED);
    myCompilationServerPort.setText(mySettings.COMPILE_SERVER_PORT);

    Sdk sdk =
        mySettings.COMPILE_SERVER_SDK == null
            ? null
            : ProjectJdkTable.getInstance().findJdk(mySettings.COMPILE_SERVER_SDK);
    myCompilationServerSdk.setSelectedJdk(sdk);

    myCompilationServerMaximumHeapSize.setText(mySettings.COMPILE_SERVER_MAXIMUM_HEAP_SIZE);
    myCompilationServerJvmParameters.setText(mySettings.COMPILE_SERVER_JVM_PARAMETERS);
    showTypeInfoOnCheckBox.setSelected(mySettings.SHOW_TYPE_TOOLTIP_ON_MOUSE_HOVER);
    delaySpinner.setValue(mySettings.SHOW_TYPE_TOOLTIP_DELAY);
  }
  @Override
  protected void resetEditorFrom(@NotNull ErlangConsoleRunConfiguration config) {
    myModuleComboBox.removeAllItems();
    for (final Module module : config.getValidModules()) {
      if (ModuleType.get(module) == ErlangModuleType.getInstance()) {
        myModuleComboBox.addItem(module);
      }
    }
    myModuleComboBox.setSelectedItem(myInitialModule);
    //noinspection unchecked
    myModuleComboBox.setRenderer(getListCellRendererWrapper());

    myWorkingDirPathField.setText(config.getWorkingDirPath());
    myModuleComboBox.setSelectedItem(config.getConfigurationModule().getModule());
    myConsoleArgsEditor.setText(config.getConsoleArgs());
  }
 private void onTextChange() {
   if (!myIsInUpdate) {
     myUpdateAlarm.cancelAllRequests();
     myTextChanged = true;
     final String text = myPatternField.getText();
     myCurrentScope = new InvalidPackageSet(text);
     try {
       if (!StringUtil.isEmpty(text)) {
         myCurrentScope = PackageSetFactory.getInstance().compile(text);
       }
       myErrorMessage = null;
     } catch (Exception e) {
       myErrorMessage = e.getMessage();
       showErrorMessage();
     }
     rebuild(false);
   } else if (!invalidScopeInside(myCurrentScope)) {
     myErrorMessage = null;
   }
 }
  @Override
  public boolean isModified(@NotNull HttpConfigurable settings) {
    if (!isValid()) {
      return false;
    }

    return !Comparing.strEqual(myProxyExceptions.getText().trim(), settings.PROXY_EXCEPTIONS)
        || settings.USE_PROXY_PAC != myAutoDetectProxyRb.isSelected()
        || settings.USE_PAC_URL != myPacUrlCheckBox.isSelected()
        || !Comparing.strEqual(settings.PAC_URL, myPacUrlTextField.getText())
        || settings.USE_HTTP_PROXY != myUseHTTPProxyRb.isSelected()
        || settings.PROXY_AUTHENTICATION != myProxyAuthCheckBox.isSelected()
        || settings.KEEP_PROXY_PASSWORD != myRememberProxyPasswordCheckBox.isSelected()
        || settings.PROXY_TYPE_IS_SOCKS != mySocks.isSelected()
        || !Comparing.strEqual(settings.getProxyLogin(), myProxyLoginTextField.getText())
        || !Comparing.strEqual(
            settings.getPlainProxyPassword(), new String(myProxyPasswordTextField.getPassword()))
        || settings.PROXY_PORT != myProxyPortTextField.getNumber()
        || !Comparing.strEqual(settings.PROXY_HOST, myProxyHostTextField.getText());
  }
  private void enableProxy(boolean enabled) {
    myHostNameLabel.setEnabled(enabled);
    myPortNumberLabel.setEnabled(enabled);
    myProxyHostTextField.setEnabled(enabled);
    myProxyPortTextField.setEnabled(enabled);
    mySocks.setEnabled(enabled);
    myHTTP.setEnabled(enabled);
    myProxyExceptions.setEnabled(enabled);
    myProxyExceptionsLabel.setEnabled(enabled);
    myNoProxyForLabel.setEnabled(enabled);

    myProxyAuthCheckBox.setEnabled(enabled);
    enableProxyAuthentication(enabled && myProxyAuthCheckBox.isSelected());
    myCheckButton.setEnabled(canEnableConnectionCheck());

    final boolean autoDetectProxy = myAutoDetectProxyRb.isSelected();
    myPacUrlCheckBox.setEnabled(autoDetectProxy);
    myClearPasswordsButton.setEnabled(autoDetectProxy);
    myPacUrlTextField.setEnabled(autoDetectProxy && myPacUrlCheckBox.isSelected());
  }
  public boolean isModified() {
    Sdk sdk = myCompilationServerSdk.getSelectedJdk();
    String sdkName = sdk == null ? null : sdk.getName();

    if (showTypeInfoOnCheckBox.isSelected() != mySettings.SHOW_TYPE_TOOLTIP_ON_MOUSE_HOVER)
      return true;
    if (!delaySpinner.getValue().equals(mySettings.SHOW_TYPE_TOOLTIP_DELAY)) return true;

    return !(myEnableCompileServer.isSelected() == mySettings.COMPILE_SERVER_ENABLED
        && myCompilationServerPort.getText().equals(mySettings.COMPILE_SERVER_PORT)
        && ComparatorUtil.equalsNullable(sdkName, mySettings.COMPILE_SERVER_SDK)
        && myCompilationServerMaximumHeapSize
            .getText()
            .equals(mySettings.COMPILE_SERVER_MAXIMUM_HEAP_SIZE)
        && myCompilationServerJvmParameters
            .getText()
            .equals(mySettings.COMPILE_SERVER_JVM_PARAMETERS)
        && myIncrementalTypeCmb.getModel().getSelectedItem().equals(mySettings.INCREMENTAL_TYPE)
        && myCompileOrderCmb.getModel().getSelectedItem().equals(mySettings.COMPILE_ORDER));
  }
  @Override
  public void reset() {
    generateNoWarningsCheckBox.setSelected(commonCompilerArguments.suppressWarnings);
    additionalArgsOptionsField.setText(compilerSettings.getAdditionalArguments());
    scriptTemplatesField.setText(compilerSettings.getScriptTemplates());
    scriptTemplatesClasspathField.setText(compilerSettings.getScriptTemplatesClasspath());
    copyRuntimeFilesCheckBox.setSelected(compilerSettings.getCopyJsLibraryFiles());
    outputDirectory.setText(compilerSettings.getOutputDirectoryForJsLibraryFiles());

    if (compilerWorkspaceSettings != null) {
      enablePreciseIncrementalCheckBox.setSelected(
          compilerWorkspaceSettings.getPreciseIncrementalEnabled());
      keepAliveCheckBox.setSelected(compilerWorkspaceSettings.getEnableDaemon());
    }

    generateSourceMapsCheckBox.setSelected(k2jsCompilerArguments.sourceMap);
    outputPrefixFile.setText(k2jsCompilerArguments.outputPrefix);
    outputPostfixFile.setText(k2jsCompilerArguments.outputPostfix);

    moduleKindComboBox.setSelectedItem(getModuleKindOrDefault(k2jsCompilerArguments.moduleKind));
  }
  public KotlinCompilerConfigurableTab(
      Project project,
      CommonCompilerArguments commonCompilerArguments,
      K2JSCompilerArguments k2jsCompilerArguments,
      CompilerSettings compilerSettings,
      @Nullable KotlinCompilerWorkspaceSettings compilerWorkspaceSettings) {
    this.project = project;
    this.commonCompilerArguments = commonCompilerArguments;
    this.k2jsCompilerArguments = k2jsCompilerArguments;
    this.compilerSettings = compilerSettings;
    this.compilerWorkspaceSettings = compilerWorkspaceSettings;

    additionalArgsOptionsField.attachLabel(additionalArgsLabel);

    setupFileChooser(
        labelForOutputPrefixFile,
        outputPrefixFile,
        KotlinBundle.message("kotlin.compiler.js.option.output.prefix.browse.title"));
    setupFileChooser(
        labelForOutputPostfixFile,
        outputPostfixFile,
        KotlinBundle.message("kotlin.compiler.js.option.output.postfix.browse.title"));

    labelForOutputDirectory.setLabelFor(outputDirectory);
    copyRuntimeFilesCheckBox.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(@NotNull ChangeEvent e) {
            outputDirectory.setEnabled(copyRuntimeFilesCheckBox.isSelected());
            labelForOutputDirectory.setEnabled(copyRuntimeFilesCheckBox.isSelected());
          }
        });

    fillModuleKindList();

    if (compilerWorkspaceSettings == null) {
      keepAliveCheckBox.setVisible(false);
      k2jvmPanel.setVisible(false);
    }
  }
  public void apply() throws ConfigurationException {
    mySettings.INCREMENTAL_TYPE = (String) myIncrementalTypeCmb.getModel().getSelectedItem();
    mySettings.COMPILE_ORDER = (String) myCompileOrderCmb.getModel().getSelectedItem();
    mySettings.COMPILE_SERVER_ENABLED = myEnableCompileServer.isSelected();
    mySettings.COMPILE_SERVER_PORT = myCompilationServerPort.getText();

    Sdk sdk = myCompilationServerSdk.getSelectedJdk();
    mySettings.COMPILE_SERVER_SDK = sdk == null ? null : sdk.getName();

    mySettings.COMPILE_SERVER_MAXIMUM_HEAP_SIZE = myCompilationServerMaximumHeapSize.getText();
    mySettings.COMPILE_SERVER_JVM_PARAMETERS = myCompilationServerJvmParameters.getText();
    mySettings.SHOW_TYPE_TOOLTIP_ON_MOUSE_HOVER = showTypeInfoOnCheckBox.isSelected();
    mySettings.SHOW_TYPE_TOOLTIP_DELAY = (Integer) delaySpinner.getValue();

    // TODO
    //    boolean externalCompiler =
    // CompilerWorkspaceConfiguration.getInstance(myProject).USE_COMPILE_SERVER;
    //
    //    if (!externalCompiler || !myEnableCompileServer.isSelected()) {
    //      myProject.getComponent(CompileServerLauncher.class).stop();
    //    }
    //    myProject.getComponent(CompileServerManager.class).configureWidget();
  }
  public ScopeEditorPanel(Project project, final NamedScopesHolder holder) {
    myProject = project;
    myHolder = holder;

    myPackageTree = new Tree(new RootNode(project));

    myButtonsPanel.add(createActionsPanel());

    myTreePanel.setLayout(new BorderLayout());
    myTreePanel.add(ScrollPaneFactory.createScrollPane(myPackageTree), BorderLayout.CENTER);

    myTreeToolbar.setLayout(new BorderLayout());
    myTreeToolbar.add(createTreeToolbar(), BorderLayout.WEST);

    myTreeExpansionMonitor = PackageTreeExpansionMonitor.install(myPackageTree, myProject);

    myTreeMarker =
        new Marker() {
          public boolean isMarked(VirtualFile file) {
            return myCurrentScope != null
                && (myCurrentScope instanceof PackageSetBase
                    ? ((PackageSetBase) myCurrentScope).contains(file, myHolder)
                    : myCurrentScope.contains(PackageSetBase.getPsiFile(file, myHolder), myHolder));
          }
        };

    myPatternField.setDialogCaption("Pattern");
    myPatternField
        .getDocument()
        .addDocumentListener(
            new DocumentAdapter() {
              public void textChanged(DocumentEvent event) {
                onTextChange();
              }
            });

    myPatternField
        .getTextField()
        .addCaretListener(
            new CaretListener() {
              public void caretUpdate(CaretEvent e) {
                myCaretPosition = e.getDot();
                updateCaretPositionText();
              }
            });

    myPatternField
        .getTextField()
        .addFocusListener(
            new FocusListener() {
              public void focusGained(FocusEvent e) {
                if (myErrorMessage != null) {
                  myPositionPanel.setVisible(true);
                  myPanel.revalidate();
                }
              }

              public void focusLost(FocusEvent e) {
                myPositionPanel.setVisible(false);
                myPanel.revalidate();
              }
            });

    initTree(myPackageTree);
    new UiNotifyConnector(
        myPanel,
        new Activatable() {
          @Override
          public void showNotify() {}

          @Override
          public void hideNotify() {
            cancelCurrentProgress();
          }
        });
    myPartiallyIncluded.setBackground(MyTreeCellRenderer.PARTIAL_INCLUDED);
    myRecursivelyIncluded.setBackground(MyTreeCellRenderer.WHOLE_INCLUDED);
  }
 public void reset(PackageSet packageSet, @Nullable Runnable runnable) {
   myCurrentScope = packageSet;
   myPatternField.setText(myCurrentScope == null ? "" : myCurrentScope.getText());
   rebuild(false, runnable, false, 0);
 }
 public String getPatternText() {
   return myPatternField.getText();
 }