@Override public Element getState() { final Element component = new Element("component"); if (hasDefaultValues()) { return component; } try { DefaultJDOMExternalizer.writeExternal(this, component); } catch (WriteExternalException e) { LOG.error(e); } return component; }
private PsiTestData loadData(String dataName) throws Exception { PsiTestData data = createData(); Element documentElement = JDOMUtil.load(new File(myDataRoot + "/" + "data.xml")); final List nodes = documentElement.getChildren("data"); for (Object node1 : nodes) { Element node = (Element)node1; String value = node.getAttributeValue("name"); if (value.equals(dataName)) { DefaultJDOMExternalizer.readExternal(data, node); data.loadText(myDataRoot); return data; } } throw new IllegalArgumentException("Cannot find data chunk '" + dataName + "'"); }
@Override public Element getState() { @NonNls Element element = new Element("LogFilters"); try { for (LogFilter filter : myRegisteredLogFilters.keySet()) { Element filterElement = new Element(FILTER); filterElement.setAttribute(IS_ACTIVE, myRegisteredLogFilters.get(filter).toString()); filter.writeExternal(filterElement); element.addContent(filterElement); } DefaultJDOMExternalizer.writeExternal(this, element); } catch (WriteExternalException e) { LOG.error(e); } return element; }
@Override public void loadState(final Element object) { try { final List children = object.getChildren(FILTER); for (Object child : children) { Element filterElement = (Element)child; final LogFilter filter = new LogFilter(); filter.readExternal(filterElement); setFilterSelected(filter, Boolean.parseBoolean(filterElement.getAttributeValue(IS_ACTIVE))); } DefaultJDOMExternalizer.readExternal(this, object); } catch (InvalidDataException e) { LOG.error(e); } }
@Override public void readExternal(Element element) throws InvalidDataException { DefaultJDOMExternalizer.readExternal(this, element); PATH = FileUtil.toSystemIndependentName(PATH); mySchemeName = element.getAttributeValue(NAME_ATTRIBUTE); DATE = new Date(Long.parseLong(element.getAttributeValue(ATTRIBUTE_DATE))); myRecycled = Boolean.parseBoolean(element.getAttributeValue(ATTRIBUTE_RECYCLED_CHANGELIST)); //noinspection unchecked final List<Element> children = element.getChildren(ELEMENT_BINARY); myBinaryFiles = new ArrayList<ShelvedBinaryFile>(children.size()); for (Element child : children) { ShelvedBinaryFile binaryFile = new ShelvedBinaryFile(); binaryFile.readExternal(child); myBinaryFiles.add(binaryFile); } }
@Override public void writeSettings(@NotNull Element node) throws WriteExternalException { DefaultJDOMExternalizer.writeExternal(this, node, new DefaultJDOMExternalizer.JDOMFilter() { @Override public boolean isAccept(@NotNull Field field) { return !Comparing.equal(VARIABLES_NEW, field.getName()); } }); if (!m_ignoreAnnotatedVariablesNew) { final Element option = new Element("option"); option.setAttribute("name", VARIABLES_NEW); option.setAttribute("value", Boolean.toString(m_ignoreAnnotatedVariablesNew)); node.addContent(option); } }
@Override public void readExternal(Element element) throws InvalidDataException { PathMacroManager.getInstance(getProject()).expandPaths(element); super.readExternal(element); DefaultJDOMExternalizer.readExternal(this, element); readModule(element); EnvironmentVariablesComponent.readExternal(element, getEnvs()); // common config workingDirectory = JDOMExternalizerUtil.readField(element, "WORKING_DIRECTORY"); String parentEnvValue = JDOMExternalizerUtil.readField(element, "PARENT_ENVS"); if (parentEnvValue != null) { setPassParentEnvs(Boolean.parseBoolean(parentEnvValue)); } // run config scriptName = JDOMExternalizerUtil.readField(element, "SCRIPT_NAME"); setProgramParameters(JDOMExternalizerUtil.readField(element, "PARAMETERS")); }
@Override public void writeExternal(Element element) throws WriteExternalException { super.writeExternal(element); // common config JDOMExternalizerUtil.writeField(element, "WORKING_DIRECTORY", workingDirectory); JDOMExternalizerUtil.writeField(element, "PARENT_ENVS", Boolean.toString(isPassParentEnvs())); // run config JDOMExternalizerUtil.writeField(element, "SCRIPT_NAME", scriptName); JDOMExternalizerUtil.writeField(element, "PARAMETERS", getProgramParameters()); //JavaRunConfigurationExtensionManager.getInstance().writeExternal(this, element); DefaultJDOMExternalizer.writeExternal(this, element); writeModule(element); EnvironmentVariablesComponent.writeExternal(element, getEnvs()); PathMacroManager.getInstance(getProject()).collapsePathsRecursively(element); }
@SuppressWarnings({"HardCodedStringLiteral"}) public void readExternal(Element parentNode) throws InvalidDataException { DefaultJDOMExternalizer.readExternal(this, parentNode); List<ClassFilter> filtersList = new ArrayList<ClassFilter>(); for (final Object o : parentNode.getChildren("filter")) { Element filter = (Element)o; filtersList.add(DebuggerUtilsEx.create(filter)); } setSteppingFilters(filtersList.toArray(new ClassFilter[filtersList.size()])); filtersList.clear(); final List contents = parentNode.getChildren("content"); myContentStates.clear(); for (Object content : contents) { final ContentState state = new ContentState((Element)content); myContentStates.put(state.getType(), state); } }
@SuppressWarnings({"HardCodedStringLiteral"}) public void writeExternal(Element parentNode) throws WriteExternalException { DefaultJDOMExternalizer.writeExternal(this, parentNode); for (ClassFilter mySteppingFilter : mySteppingFilters) { Element element = new Element("filter"); parentNode.addContent(element); mySteppingFilter.writeExternal(element); } for (ContentState eachState : myContentStates.values()) { final Element content = new Element("content"); if (eachState.write(content)) { parentNode.addContent(content); } } }
private PsiTestData loadData(String dataName) throws Exception { Document document = JDOMUtil.loadDocument(new File(myDataRoot + "/" + "data.xml")); PsiTestData data = createData(); Element documentElement = document.getRootElement(); final List nodes = documentElement.getChildren("data"); for (Object node1 : nodes) { Element node = (Element)node1; String value = node.getAttributeValue("name"); if (value.equals(dataName)) { DefaultJDOMExternalizer.readExternal(data, node); data.loadText(myDataRoot); return data; } } throw new IllegalArgumentException("Cannot find data chunk '" + dataName + "'"); }
@Override public void readExternal(Element element) throws InvalidDataException { DefaultJDOMExternalizer.readExternal(this, element); final ProjectLevelVcsManagerImpl vcsManager = (ProjectLevelVcsManagerImpl)ProjectLevelVcsManagerEx.getInstanceEx(myModule.getProject()); if (!USE_PROJECT_VCS) { final VirtualFile[] roots = ModuleRootManager.getInstance(myModule).getContentRoots(); StartupManager.getInstance(myModule.getProject()).runWhenProjectIsInitialized(new Runnable() { @Override public void run() { for(VirtualFile file: roots) { vcsManager.setDirectoryMapping(file.getPath(), ACTIVE_VCS_NAME); } vcsManager.cleanupMappings(); } }); } }
@Override public void readExternal(Element element) throws InvalidDataException { DefaultJDOMExternalizer.readExternal(this, element); PATH = FileUtil.toSystemIndependentName(PATH); mySchemeName = element.getAttributeValue(NAME_ATTRIBUTE); DATE = new Date(Long.parseLong(element.getAttributeValue(ATTRIBUTE_DATE))); myRecycled = Boolean.parseBoolean(element.getAttributeValue(ATTRIBUTE_RECYCLED_CHANGELIST)); myToDelete = Boolean.parseBoolean(element.getAttributeValue(ATTRIBUTE_TOBE_DELETED_CHANGELIST)); //noinspection unchecked final List<Element> children = element.getChildren(ELEMENT_BINARY); myBinaryFiles = new ArrayList<>(children.size()); for (Element child : children) { ShelvedBinaryFile binaryFile = new ShelvedBinaryFile(); binaryFile.readExternal(child); myBinaryFiles.add(binaryFile); } }
@Override public void writeExternal(final Element parentNode) throws WriteExternalException { super.writeExternal(parentNode); DefaultJDOMExternalizer.writeExternal(this, parentNode); if(myAppletParameters != null) { for(int i = 0; i < myAppletParameters.length; i++) { final Element element = new Element(PARAMETER_ELEMENT_NAME); parentNode.addContent(element); element.setAttribute(NAME_ATTR, myAppletParameters[i].getName()); element.setAttribute(VALUE_ATTR, myAppletParameters[i].getValue()); } } }
protected void defaultWriteSettings(@NotNull Element node, final String... excludedProperties) throws WriteExternalException { DefaultJDOMExternalizer.writeExternal(this, node, new DefaultJDOMExternalizer.JDOMFilter() { @Override public boolean isAccept(@NotNull Field field) { final String name = field.getName(); for(String property : excludedProperties) { if(name.equals(property)) { return false; } } return true; } }); }
@SuppressWarnings("deprecation") @Override public Element getState() { final Element component = new Element("component"); if(hasDefaultValues()) { return component; } try { DefaultJDOMExternalizer.writeExternal(this, component); } catch(WriteExternalException e) { LOG.error(e); } return component; }
@SuppressWarnings("deprecation") @Override public void loadState(Element state) { try { DefaultJDOMExternalizer.readExternal(this, state); if(myNullables.isEmpty()) { Collections.addAll(myNullables, DEFAULT_NULLABLES); } if(myNotNulls.isEmpty()) { myNotNulls.addAll(getPredefinedNotNulls()); } } catch(InvalidDataException e) { LOG.error(e); } }
public void readExternal(Element element) throws InvalidDataException { super.readExternal(element); DefaultJDOMExternalizer.readExternal(this, element); TextWithImports childrenExpression = DebuggerUtils.getInstance().readTextWithImports(element, "CHILDREN_EXPRESSION"); if(childrenExpression != null) { setChildrenExpression(childrenExpression); } TextWithImports childrenExpandable = DebuggerUtils.getInstance().readTextWithImports(element, "CHILDREN_EXPANDABLE"); if(childrenExpandable != null) { myChildrenExpandable.setReferenceExpression(childrenExpandable); } }
@Override public void loadState(Element state) { try { DefaultJDOMExternalizer.readExternal(this, state); if (myNullables.isEmpty()) { Collections.addAll(myNullables, DEFAULT_NULLABLES); } if (myNotNulls.isEmpty()) { Collections.addAll(myNotNulls, DEFAULT_NOT_NULLS); } } catch (InvalidDataException e) { LOG.error(e); } }
public void readExternal(Element element) throws InvalidDataException { super.readExternal(element); DefaultJDOMExternalizer.readExternal(this, element); TextWithImports labelExpression = DebuggerUtils.getInstance().readTextWithImports(element, "LABEL_EXPRESSION"); if (labelExpression != null) { setLabelExpression(labelExpression); } }
@Override public void readExternal(final Element element) throws InvalidDataException { PathMacroManager.getInstance(getProject()).expandPaths(element); super.readExternal(element); JavaRunConfigurationExtensionManager.getInstance().readExternal(this, element); DefaultJDOMExternalizer.readExternal(this, element); readModule(element); EnvironmentVariablesComponent.readExternal(element, getEnvs()); }
@Override public void writeExternal(final Element element) throws WriteExternalException { super.writeExternal(element); JavaRunConfigurationExtensionManager.getInstance().writeExternal(this, element); DefaultJDOMExternalizer.writeExternal(this, element); writeModule(element); EnvironmentVariablesComponent.writeExternal(element, getEnvs()); }
@Override public void writeExternal(final Element element) throws WriteExternalException { super.writeExternal(element); final Module module = getConfigurationModule().getModule(); if (module != null) { // default value writeModule(element); } DefaultJDOMExternalizer.writeExternal(this, element); }
public void writeExternal(Element element) throws WriteExternalException { DefaultJDOMExternalizer.writeExternal(this, element, new DefaultJDOMExternalizer.JDOMFilter() { @Override public boolean isAccept(@NotNull Field field) { return !field.getName().equals("OPTION_LINK_TO_JDK_DOCS") || OPTION_LINK_TO_JDK_DOCS; } }); }
@NotNull public static AttributesFlyweight create(@NotNull Element element) throws InvalidDataException { Color FOREGROUND = DefaultJDOMExternalizer.toColor(JDOMExternalizerUtil.readField(element, "FOREGROUND")); Color BACKGROUND = DefaultJDOMExternalizer.toColor(JDOMExternalizerUtil.readField(element, "BACKGROUND")); Color EFFECT_COLOR = DefaultJDOMExternalizer.toColor(JDOMExternalizerUtil.readField(element, "EFFECT_COLOR")); Color ERROR_STRIPE_COLOR = DefaultJDOMExternalizer.toColor(JDOMExternalizerUtil.readField(element, "ERROR_STRIPE_COLOR")); int fontType = DefaultJDOMExternalizer.toInt(JDOMExternalizerUtil.readField(element, "FONT_TYPE", "0")); if (fontType < 0 || fontType > 3) { fontType = 0; } int FONT_TYPE = fontType; int EFFECT_TYPE = DefaultJDOMExternalizer.toInt(JDOMExternalizerUtil.readField(element, "EFFECT_TYPE", "0")); return create(FOREGROUND, BACKGROUND, FONT_TYPE, EFFECT_COLOR, toEffectType(EFFECT_TYPE), ERROR_STRIPE_COLOR); }
@Override public void readExternal(Element element) throws InvalidDataException { DefaultJDOMExternalizer.readExternal(this, element); if (!KEEP_ITN_PASSWORD) { ITN_PASSWORD_CRYPT = ""; } }
@Override public void writeExternal(Element element) throws WriteExternalException { String itnPassword = ITN_PASSWORD_CRYPT; if (!KEEP_ITN_PASSWORD) { ITN_PASSWORD_CRYPT = ""; } DefaultJDOMExternalizer.writeExternal(this, element); ITN_PASSWORD_CRYPT = itnPassword; }
public void writeExternal(Element parentElement, @NotNull final CustomCodeStyleSettings parentSettings) throws WriteExternalException { final Element childElement = new Element(myTagName); DefaultJDOMExternalizer.writeExternal(this, childElement, new DifferenceFilter<CustomCodeStyleSettings>(this, parentSettings)); if (!childElement.getContent().isEmpty()) { parentElement.addContent(childElement); } }
private static void writeExternal(@NotNull Element element, @NotNull ShelvedChangeList shelvedChangeList) throws WriteExternalException { DefaultJDOMExternalizer.writeExternal(shelvedChangeList, element); element.setAttribute(NAME_ATTRIBUTE, shelvedChangeList.getName()); element.setAttribute(ATTRIBUTE_DATE, Long.toString(shelvedChangeList.DATE.getTime())); element.setAttribute(ATTRIBUTE_RECYCLED_CHANGELIST, Boolean.toString(shelvedChangeList.isRecycled())); for (ShelvedBinaryFile file : shelvedChangeList.getBinaryFiles()) { Element child = new Element(ELEMENT_BINARY); file.writeExternal(child); element.addContent(child); } }
public void writeExternal(Element parentNode) throws WriteExternalException { DefaultJDOMExternalizer.writeExternal(this, parentNode); for (final AntBuildFile buildFile : AntConfiguration.getInstance(myProject).getBuildFiles()) { Element element = new Element(BUILD_FILE); element.setAttribute(URL, buildFile.getVirtualFile().getUrl()); ((AntBuildFileBase)buildFile).writeWorkspaceProperties(element); parentNode.addContent(element); } }
public void readExternal(Element element) throws InvalidDataException { DefaultJDOMExternalizer.readExternal(this, element); LOG.assertTrue(mySandboxRoot == null); myJavaSdkName = element.getAttributeValue(SDK); if (mySandboxHome != null) { mySandboxRoot = LocalFileSystem.getInstance().addRootToWatch(mySandboxHome, true); } }
public void writeExternal(Element element) throws WriteExternalException { DefaultJDOMExternalizer.writeExternal(this, element); final Sdk sdk = getJavaSdk(); if (sdk != null) { element.setAttribute(SDK, sdk.getName()); } }
@Override public void readExternal(Element element) throws InvalidDataException { PathMacroManager.getInstance(getProject()).expandPaths(element); super.readExternal(element); DefaultJDOMExternalizer.readExternal(this, element); readModule(element); EnvironmentVariablesComponent.readExternal(element, getEnvs()); interpreterOptions = JDOMExternalizerUtil.readField(element, "INTERPRETER_OPTIONS"); interpreterName = JDOMExternalizerUtil.readField(element, "INTERPRETER_NAME"); programName = JDOMExternalizerUtil.readField(element, "PROGRAM_NAME"); setProgramParameters(JDOMExternalizerUtil.readField(element, "PROGRAM_PARAMETERS")); }