コード例 #1
0
  private void performEditAction() {
    final Configuration configuration = (Configuration) myTemplatesList.getSelectedValue();
    if (configuration == null) return;

    SearchDialog dialog =
        createDialog(
            new SearchDialogFactory() {
              public SearchDialog createDialog(SearchContext searchContext) {
                if (configuration instanceof SearchConfiguration) {
                  return new SearchDialog(searchContext, false, false) {
                    public Configuration createConfiguration() {
                      SearchConfiguration newConfiguration = new SearchConfiguration();
                      copyConfiguration(configuration, newConfiguration);
                      return newConfiguration;
                    }
                  };
                } else {
                  return new ReplaceDialog(searchContext, false, false) {
                    public Configuration createConfiguration() {
                      ReplaceConfiguration newConfiguration = new ReplaceConfiguration();
                      copyConfiguration(configuration, newConfiguration);
                      return newConfiguration;
                    }
                  };
                }
              }
            });
    dialog.setValuesFromConfig(configuration);
    dialog.setUseLastConfiguration(true);
    dialog.show();
    if (!dialog.isOK()) return;
    Configuration newConfiguration = dialog.getConfiguration();
    copyConfiguration(newConfiguration, configuration);
    configurationsChanged(dialog.getSearchContext());
  }
コード例 #2
0
  public void setValuesFromConfig(Configuration configuration) {
    // replaceCriteriaEdit.putUserData(SubstitutionShortInfoHandler.CURRENT_CONFIGURATION_KEY,
    // configuration);

    if (configuration instanceof ReplaceConfiguration) {
      final ReplaceConfiguration config = (ReplaceConfiguration) configuration;
      final ReplaceOptions options = config.getOptions();
      super.setValuesFromConfig(config);

      UIUtil.setContent(
          replaceCriteriaEdit,
          config.getOptions().getReplacement(),
          0,
          replaceCriteriaEdit.getDocument().getTextLength(),
          searchContext.getProject());

      shortenFQN.setSelected(options.isToShortenFQN());
      formatAccordingToStyle.setSelected(options.isToReformatAccordingToStyle());
      useStaticImport.setSelected(options.isToUseStaticImport());

      ReplaceOptions newReplaceOptions = ((ReplaceConfiguration) model.getConfig()).getOptions();
      newReplaceOptions.clearVariableDefinitions();

      for (ReplacementVariableDefinition def : options.getReplacementVariableDefinitions()) {
        newReplaceOptions.addVariableDefinition((ReplacementVariableDefinition) def.clone());
      }
    } else {
      super.setValuesFromConfig(configuration);

      UIUtil.setContent(
          replaceCriteriaEdit,
          configuration.getMatchOptions().getSearchPattern(),
          0,
          replaceCriteriaEdit.getDocument().getTextLength(),
          searchContext.getProject());
    }
  }