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()); }
protected void setValuesToConfig(Configuration config) { super.setValuesToConfig(config); final ReplaceConfiguration replaceConfiguration = (ReplaceConfiguration) config; final ReplaceOptions options = replaceConfiguration.getOptions(); options.setMatchOptions(replaceConfiguration.getMatchOptions()); options.setReplacement(replaceCriteriaEdit.getDocument().getText()); options.setToShortenFQN(shortenFQN.isSelected()); options.setToReformatAccordingToStyle(formatAccordingToStyle.isSelected()); options.setToUseStaticImport(useStaticImport.isSelected()); }
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()); } }
protected void buildOptions(JPanel searchOptions) { super.buildOptions(searchOptions); searchOptions.add( UIUtil.createOptionLine( shortenFQN = new JCheckBox(SSRBundle.message("shorten.fully.qualified.names.checkbox"), true))); searchOptions.add( UIUtil.createOptionLine( formatAccordingToStyle = new JCheckBox( CodeInsightBundle.message( "dialog.edit.template.checkbox.reformat.according.to.style"), true))); searchOptions.add( UIUtil.createOptionLine( useStaticImport = new JCheckBox( CodeInsightBundle.message("dialog.edit.template.checkbox.use.static.import"), true))); }
private void addTemplate(SearchDialogFactory searchDialogFactory) { SearchDialog dialog = createDialog(searchDialogFactory); dialog.show(); if (!dialog.isOK()) return; Configuration configuration = dialog.getConfiguration(); if (configuration.getName() == null || configuration.getName().equals(SearchDialog.USER_DEFINED)) { String name = dialog.showSaveTemplateAsDialog(); if (name != null) { name = ConfigurationManager.findAppropriateName(myConfigurations, name, dialog.getProject()); } if (name == null) return; configuration.setName(name); } myConfigurations.add(configuration); configurationsChanged(dialog.getSearchContext()); }
protected void addOrReplaceSelection(final String selection) { super.addOrReplaceSelection(selection); addOrReplaceSelectionForEditor(selection, replaceCriteriaEdit); }
public void show() { replaceCriteriaEdit.putUserData( SubstitutionShortInfoHandler.CURRENT_CONFIGURATION_KEY, model.getConfig()); super.show(); }
protected void disposeEditorContent() { mySavedEditorText = replaceCriteriaEdit.getDocument().getText(); EditorFactory.getInstance().releaseEditor(replaceCriteriaEdit); super.disposeEditorContent(); }