From e079515ba215b2b5490d63d58e4f10a3fcd74190 Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Tue, 7 Aug 2012 20:16:02 +0400 Subject: [PATCH] Change "default" property behaviour --- .../com/intellij/designer/model/Property.java | 18 +++++++++++---- .../designer/propertyTable/PropertyTable.java | 23 +++++++++++-------- .../propertyTable/CompoundProperty.java | 10 -------- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/designer/model/Property.java b/platform/platform-impl/src/com/intellij/designer/model/Property.java index 917fa64c1936..ba6b21a50b14 100644 --- a/platform/platform-impl/src/com/intellij/designer/model/Property.java +++ b/platform/platform-impl/src/com/intellij/designer/model/Property.java @@ -89,12 +89,18 @@ public abstract class Property { public void setValue(@NotNull T container, @Nullable Object value) throws Exception { } - public boolean isDefaultValue(@NotNull T container) throws Exception { - return false; + public final boolean isRecursiveDefault(@NotNull T container) throws Exception { + for (Property child : getChildren(container)) { + boolean isDefault = child.isRecursiveDefault(container); + if (!isDefault) { + return false; + } + } + return isDefaultValue(container); } - public boolean isDefaultValueWithDepth(@NotNull T container) throws Exception { - return isDefaultValue(container); + public boolean isDefaultValue(@NotNull T container) throws Exception { + return true; } public void setDefaultValue(@NotNull T container) throws Exception { @@ -148,6 +154,10 @@ public abstract class Property { myDeprecated = deprecated; } + public boolean showAsDefault(@NotNull T container) throws Exception { + return isRecursiveDefault(container); + } + @NotNull public abstract PropertyRenderer getRenderer(); diff --git a/platform/platform-impl/src/com/intellij/designer/propertyTable/PropertyTable.java b/platform/platform-impl/src/com/intellij/designer/propertyTable/PropertyTable.java index 4fdbe5db5a67..c9eb603e37c3 100644 --- a/platform/platform-impl/src/com/intellij/designer/propertyTable/PropertyTable.java +++ b/platform/platform-impl/src/com/intellij/designer/propertyTable/PropertyTable.java @@ -200,7 +200,7 @@ public abstract class PropertyTable extends JBTable { @Override public void run() throws Exception { for (PropertiesContainer component : myContainers) { - if (!property.isDefaultValue(component)) { + if (!property.isRecursiveDefault(component)) { property.setDefaultValue(component); } } @@ -427,16 +427,16 @@ public abstract class PropertyTable extends JBTable { } } - private void fillProperties(PropertiesContainer component, List properties) { - for (Property property : component.getProperties()) { - addProperty(component, property, properties); + private void fillProperties(PropertiesContainer container, List properties) { + for (Property property : container.getProperties()) { + addProperty(container, property, properties); } } - private void addProperty(PropertiesContainer component, Property property, List properties) { + private void addProperty(PropertiesContainer container, Property property, List properties) { if (property.isExpert() && !myShowExpertProperties) { try { - if (property.isDefaultValueWithDepth(component)) { + if (property.isRecursiveDefault(container)) { return; } } @@ -449,7 +449,7 @@ public abstract class PropertyTable extends JBTable { if (isExpanded(property)) { for (Property child : getChildren(property)) { - addProperty(component, child, properties); + addProperty(container, child, properties); } } } @@ -557,7 +557,7 @@ public abstract class PropertyTable extends JBTable { public boolean isDefault(Property property) throws Exception { for (PropertiesContainer component : myContainers) { - if (!property.isDefaultValue(component)) { + if (!property.isRecursiveDefault(component)) { return false; } } @@ -1142,7 +1142,12 @@ public abstract class PropertyTable extends JBTable { boolean isDefault = true; try { - isDefault = isDefault(property); + for (PropertiesContainer container : myContainers) { + if (!property.showAsDefault(container)) { + isDefault = false; + break; + } + } } catch (Exception e) { LOG.debug(e); diff --git a/plugins/android-designer/src/com/intellij/android/designer/propertyTable/CompoundProperty.java b/plugins/android-designer/src/com/intellij/android/designer/propertyTable/CompoundProperty.java index 6b52c3ee2ffd..6ba7956181e5 100644 --- a/plugins/android-designer/src/com/intellij/android/designer/propertyTable/CompoundProperty.java +++ b/plugins/android-designer/src/com/intellij/android/designer/propertyTable/CompoundProperty.java @@ -93,16 +93,6 @@ public class CompoundProperty extends Property implements IPro return value.toString(); } - @Override - public boolean isDefaultValue(@NotNull RadViewComponent component) throws Exception { - for (Property childProperty : myChildren) { - if (!childProperty.isDefaultValue(component)) { - return false; - } - } - return true; - } - @Override public void setDefaultValue(@NotNull RadViewComponent component) throws Exception { for (Property childProperty : myChildren) {