use of com.intellij.openapi.util.WriteExternalException in project intellij-plugins by JetBrains.
the class CfmlUnitRunConfiguration method clone.
@SuppressWarnings({ "CloneDoesntDeclareCloneNotSupportedException", "CloneDoesntCallSuperClone" })
@Override
public CfmlUnitRunConfiguration clone() {
try {
Element element = new Element("tmp");
writeExternal(element);
CfmlUnitRunConfiguration clone = new CfmlUnitRunConfiguration(getProject(), getFactory(), getName());
clone.readExternal(element);
return clone;
} catch (WriteExternalException e) {
throw new RuntimeException(e);
}
}
use of com.intellij.openapi.util.WriteExternalException in project intellij-community by JetBrains.
the class PsiAwareTextEditorProvider method writeState.
@Override
public void writeState(@NotNull final FileEditorState _state, @NotNull final Project project, @NotNull final Element element) {
super.writeState(_state, project, element);
TextEditorState state = (TextEditorState) _state;
// Foldings
CodeFoldingState foldingState = state.getFoldingState();
if (foldingState != null) {
Element e = new Element(FOLDING_ELEMENT);
try {
CodeFoldingManager.getInstance(project).writeFoldingState(foldingState, e);
} catch (WriteExternalException e1) {
//ignore
}
element.addContent(e);
}
}
use of com.intellij.openapi.util.WriteExternalException in project intellij-community by JetBrains.
the class DeployToServerRunConfiguration method clone.
@Override
public RunConfiguration clone() {
Element element = new Element("tag");
try {
writeExternal(element);
} catch (WriteExternalException e) {
LOG.error(e);
}
DeployToServerRunConfiguration result = (DeployToServerRunConfiguration) super.clone();
try {
result.readExternal(element);
} catch (InvalidDataException e) {
LOG.error(e);
}
return result;
}
use of com.intellij.openapi.util.WriteExternalException in project intellij-community by JetBrains.
the class SystemFileProcessor method encodeFileText.
@Nullable
@Override
protected String encodeFileText(String content, VirtualFile file, Project project) throws IOException {
final String fileName = file.getName();
if (file.getParent().getName().equals(Project.DIRECTORY_STORE_FOLDER) && fileName.equals("workspace.xml")) {
List<Object> componentList = new ArrayList<>();
for (String componentName : COMPONENT_NAMES) {
Object component = project.getComponent(componentName);
if (component == null) {
try {
Class<?> aClass = Class.forName(componentName);
component = project.getComponent(aClass);
if (component == null) {
component = ServiceManager.getService(project, aClass);
}
} catch (ClassNotFoundException ignore) {
}
}
ContainerUtil.addIfNotNull(componentList, component);
}
if (!componentList.isEmpty()) {
final Element root = new Element("project");
for (final Object component : componentList) {
final Element element = new Element("component");
element.setAttribute("name", ComponentManagerImpl.getComponentName(component));
root.addContent(element);
ApplicationManager.getApplication().invokeAndWait(() -> {
if (component instanceof JDOMExternalizable) {
try {
((JDOMExternalizable) component).writeExternal(element);
} catch (WriteExternalException ignore) {
LOG.error(ignore);
}
} else if (component instanceof PersistentStateComponent) {
Object state = WriteAction.compute(() -> ((PersistentStateComponent) component).getState());
if (state == null) {
return;
}
Element element1 = state instanceof Element ? (Element) state : XmlSerializer.serialize(state);
element.addContent(element1.cloneContent());
element.setAttribute("name", StoreUtil.getStateSpec((PersistentStateComponent) component).name());
}
}, ModalityState.defaultModalityState());
}
PathMacroManager.getInstance(project).collapsePaths(root);
return JDOMUtil.writeElement(root);
}
}
return null;
}
use of com.intellij.openapi.util.WriteExternalException in project intellij-community by JetBrains.
the class ProjectFacetManagerImpl method setDefaultConfiguration.
@Override
public <C extends FacetConfiguration> void setDefaultConfiguration(@NotNull final FacetType<?, C> facetType, @NotNull final C configuration) {
Map<String, DefaultFacetConfigurationState> defaultConfigurations = myState.getDefaultConfigurations();
DefaultFacetConfigurationState state = defaultConfigurations.get(facetType.getStringId());
if (state == null) {
state = new DefaultFacetConfigurationState();
defaultConfigurations.put(facetType.getStringId(), state);
}
try {
Element element = FacetUtil.saveFacetConfiguration(configuration);
state.setDefaultConfiguration(element);
} catch (WriteExternalException e) {
LOG.info(e);
}
}
Aggregations