use of com.intellij.structuralsearch.ReplacementVariableDefinition in project intellij-community by JetBrains.
the class ReplaceDialog method setValuesFromConfig.
@Override
public void setValuesFromConfig(Configuration 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());
}
}
use of com.intellij.structuralsearch.ReplacementVariableDefinition in project intellij-community by JetBrains.
the class ReplaceOptions method writeExternal.
public void writeExternal(Element element) {
matchOptions.writeExternal(element);
element.setAttribute(REFORMAT_ATTR_NAME, String.valueOf(myToReformatAccordingToStyle));
element.setAttribute(SHORTEN_FQN_ATTR_NAME, String.valueOf(toShortenFQN));
if (isToUseStaticImport()) {
element.setAttribute(USE_STATIC_IMPORT_ATTR_NAME, String.valueOf(isToUseStaticImport()));
}
element.setAttribute(REPLACEMENT_ATTR_NAME, replacement);
if (variableDefs != null) {
for (final ReplacementVariableDefinition variableDefinition : variableDefs.values()) {
final Element infoElement = new Element(VARIABLE_DEFINITION_TAG_NAME);
element.addContent(infoElement);
variableDefinition.writeExternal(infoElement);
}
}
}
use of com.intellij.structuralsearch.ReplacementVariableDefinition in project intellij-community by JetBrains.
the class ReplaceOptions method readExternal.
public void readExternal(Element element) {
matchOptions.readExternal(element);
Attribute attribute = element.getAttribute(REFORMAT_ATTR_NAME);
try {
myToReformatAccordingToStyle = attribute.getBooleanValue();
} catch (DataConversionException ex) {
}
attribute = element.getAttribute(SHORTEN_FQN_ATTR_NAME);
try {
toShortenFQN = attribute.getBooleanValue();
} catch (DataConversionException ex) {
}
attribute = element.getAttribute(USE_STATIC_IMPORT_ATTR_NAME);
if (attribute != null) {
// old saved configurations without this attribute present
try {
myToUseStaticImport = attribute.getBooleanValue();
} catch (DataConversionException ignore) {
}
}
replacement = element.getAttributeValue(REPLACEMENT_ATTR_NAME);
List<Element> elements = element.getChildren(VARIABLE_DEFINITION_TAG_NAME);
if (elements != null && elements.size() > 0) {
for (final Element element1 : elements) {
final ReplacementVariableDefinition variableDefinition = new ReplacementVariableDefinition();
variableDefinition.readExternal(element1);
addVariableDefinition(variableDefinition);
}
}
}
Aggregations