mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ProjectView — do not write defaults (pane id)
This commit is contained in:
+12
-5
@@ -1,4 +1,6 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package com.intellij.ide.projectView.impl;
|
||||
|
||||
@@ -130,9 +132,14 @@ public abstract class AbstractProjectViewPane implements DataProvider, Disposabl
|
||||
}
|
||||
|
||||
public abstract String getTitle();
|
||||
|
||||
public abstract Icon getIcon();
|
||||
@NotNull public abstract String getId();
|
||||
@Nullable public final String getSubId(){
|
||||
|
||||
@NotNull
|
||||
public abstract String getId();
|
||||
|
||||
@Nullable
|
||||
public final String getSubId() {
|
||||
return mySubId;
|
||||
}
|
||||
|
||||
@@ -443,7 +450,7 @@ public abstract class AbstractProjectViewPane implements DataProvider, Disposabl
|
||||
return myTreeBuilder;
|
||||
}
|
||||
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
public void readExternal(@NotNull Element element) {
|
||||
List<Element> subPanes = element.getChildren(ELEMENT_SUBPANE);
|
||||
for (Element subPane : subPanes) {
|
||||
String subId = subPane.getAttributeValue(ATTRIBUTE_SUBID);
|
||||
@@ -454,7 +461,7 @@ public abstract class AbstractProjectViewPane implements DataProvider, Disposabl
|
||||
}
|
||||
}
|
||||
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
public void writeExternal(Element element) {
|
||||
saveExpandedPaths();
|
||||
for (String subId : myReadTreeState.keySet()) {
|
||||
TreeState treeState = myReadTreeState.get(subId);
|
||||
|
||||
@@ -176,7 +176,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
private final MyPanel myDataProvider;
|
||||
private final SplitterProportionsData splitterProportions = new SplitterProportionsDataImpl();
|
||||
private final MessageBusConnection myConnection;
|
||||
private final Map<String, Element> myUninitializedPaneState = new HashMap<>();
|
||||
private final Map<String, Element> myUninitializedPaneState = new THashMap<>();
|
||||
private final Map<String, SelectInTarget> mySelectInTargets = new LinkedHashMap<>();
|
||||
private ContentManager myContentManager;
|
||||
|
||||
@@ -1364,7 +1364,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
return;
|
||||
}
|
||||
for (Attribute attribute : node.getAttributes()) {
|
||||
options.put(attribute.getName(), Boolean.TRUE.toString().equals(attribute.getValue()) ? Boolean.TRUE : Boolean.FALSE);
|
||||
options.put(attribute.getName(), Boolean.parseBoolean(attribute.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1378,7 +1378,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
final String key = entry.getKey();
|
||||
//SCR48267
|
||||
if (key != null) {
|
||||
e.setAttribute(key, Boolean.toString(entry.getValue().booleanValue()));
|
||||
e.setAttribute(key, Boolean.toString(entry.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1395,6 +1395,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
mySavedPaneId = ProjectViewPane.ID;
|
||||
mySavedPaneSubId = null;
|
||||
}
|
||||
|
||||
readOption(navigatorElement.getChild(ELEMENT_FLATTEN_PACKAGES), myFlattenPackages);
|
||||
readOption(navigatorElement.getChild(ELEMENT_SHOW_MEMBERS), myShowMembers);
|
||||
readOption(navigatorElement.getChild(ELEMENT_SHOW_MODULES), myShowModules);
|
||||
@@ -1427,13 +1428,16 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
|
||||
for (Element paneElement : paneElements) {
|
||||
String paneId = paneElement.getAttributeValue(ATTRIBUTE_ID);
|
||||
if (StringUtil.isEmptyOrSpaces(paneId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final AbstractProjectViewPane pane = myId2Pane.get(paneId);
|
||||
if (pane != null) {
|
||||
try {
|
||||
pane.readExternal(paneElement);
|
||||
}
|
||||
catch (InvalidDataException e) {
|
||||
// ignore
|
||||
catch (InvalidDataException ignore) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1446,14 +1450,18 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
public Element getState() {
|
||||
Element parentNode = new Element("projectView");
|
||||
Element navigatorElement = new Element(ELEMENT_NAVIGATOR);
|
||||
|
||||
AbstractProjectViewPane currentPane = getCurrentProjectViewPane();
|
||||
if (currentPane != null) {
|
||||
navigatorElement.setAttribute(ATTRIBUTE_CURRENT_VIEW, currentPane.getId());
|
||||
String subId = currentPane.getSubId();
|
||||
if (subId != null) {
|
||||
navigatorElement.setAttribute(ATTRIBUTE_CURRENT_SUBVIEW, subId);
|
||||
if (subId != null || !currentPane.getId().equals(ProjectViewPane.ID)) {
|
||||
navigatorElement.setAttribute(ATTRIBUTE_CURRENT_VIEW, currentPane.getId());
|
||||
if (subId != null) {
|
||||
navigatorElement.setAttribute(ATTRIBUTE_CURRENT_SUBVIEW, subId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writeOption(navigatorElement, myFlattenPackages, ELEMENT_FLATTEN_PACKAGES);
|
||||
writeOption(navigatorElement, myShowMembers, ELEMENT_SHOW_MEMBERS);
|
||||
writeOption(navigatorElement, myShowModules, ELEMENT_SHOW_MODULES);
|
||||
@@ -1473,8 +1481,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
|
||||
try {
|
||||
splitterProportions.writeExternal(navigatorElement);
|
||||
}
|
||||
catch (WriteExternalException e) {
|
||||
// ignore
|
||||
catch (WriteExternalException ignored) {
|
||||
}
|
||||
|
||||
if (!JDOMUtil.isEmpty(navigatorElement)) {
|
||||
|
||||
@@ -1,17 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
*/
|
||||
|
||||
package com.intellij.ide.projectView.impl;
|
||||
@@ -37,9 +25,7 @@ import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.InvalidDataException;
|
||||
import com.intellij.openapi.util.JDOMExternalizerUtil;
|
||||
import com.intellij.openapi.util.WriteExternalException;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import org.jdom.Element;
|
||||
@@ -119,8 +105,9 @@ public class ProjectViewPane extends AbstractProjectViewPSIPane {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(Element element) throws InvalidDataException {
|
||||
public void readExternal(@NotNull Element element) {
|
||||
super.readExternal(element);
|
||||
|
||||
String showExcludedOption = JDOMExternalizerUtil.readField(element, SHOW_EXCLUDED_FILES_OPTION);
|
||||
myShowExcludedFiles = showExcludedOption == null || Boolean.parseBoolean(showExcludedOption);
|
||||
String useFileNestingRules = JDOMExternalizerUtil.readField(element, USE_FILE_NESTING_RULES);
|
||||
@@ -128,7 +115,7 @@ public class ProjectViewPane extends AbstractProjectViewPSIPane {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeExternal(Element element) throws WriteExternalException {
|
||||
public void writeExternal(Element element) {
|
||||
super.writeExternal(element);
|
||||
if (!myShowExcludedFiles) {
|
||||
JDOMExternalizerUtil.writeField(element, SHOW_EXCLUDED_FILES_OPTION, String.valueOf(false));
|
||||
@@ -233,7 +220,7 @@ public class ProjectViewPane extends AbstractProjectViewPSIPane {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
super.update(e);
|
||||
final Presentation presentation = e.getPresentation();
|
||||
final ProjectView projectView = ProjectView.getInstance(myProject);
|
||||
|
||||
Reference in New Issue
Block a user