svn commit: r16435 - trunk/src/argouml-app/src/org/argouml: kernel notation persistence uml/diagram
Tom Morris <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: tfmorris
Date: 2008-12-23 11:24:35-0800
New Revision: 16435
Modified:
trunk/src/argouml-app/src/org/argouml/kernel/ProjectSettings.java
trunk/src/argouml-app/src/org/argouml/notation/NotationSettings.java
trunk/src/argouml-app/src/org/argouml/persistence/ArgoParser.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramSettings.java
Log:
showStereotype setting is for the explorer (ie project-wide). move it back to the ProjectSettings and undeprecate the related methods.
Modified: trunk/src/argouml-app/src/org/argouml/kernel/ProjectSettings.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/kernel/ProjectSettings.java?view=diff&pathrev=16435&r1=16434&r2=16435
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/kernel/ProjectSettings.java (original)
+++ trunk/src/argouml-app/src/org/argouml/kernel/ProjectSettings.java 2008-12-23 11:24:35-0800
@@ -63,6 +63,9 @@
// Default notation settings
private NotationSettings npSettings;
+ /** Setting to control whether stereotypes are shown in explorer view */
+ private boolean showExplorerStereotypes;
+
/* Generation preferences: */
private String headerComment =
"Your copyright and other header comments";
@@ -118,8 +121,8 @@
diaDefault.setShowBidirectionalArrows(!Configuration.getBoolean(
Notation.KEY_HIDE_BIDIRECTIONAL_ARROWS, true));
- npSettings.setShowStereotypes(Configuration.getBoolean(
- Notation.KEY_SHOW_STEREOTYPES));
+ showExplorerStereotypes = Configuration.getBoolean(
+ Notation.KEY_SHOW_STEREOTYPES);
/*
* The next one defaults to TRUE, despite that this is
* NOT compatible with older ArgoUML versions
@@ -731,10 +734,8 @@
/**
* Used by "argo.tee".
*
- * @return Returns "true" if we show stereotypes.
- * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}.
+ * @return Returns "true" if we show stereotypes in the explorer.
*/
- @Deprecated
public String getShowStereotypes() {
return Boolean.toString(getShowStereotypesValue());
}
@@ -743,30 +744,26 @@
* TODO: Is this used in places other than on Diagrams? If so, it needs to
* stay in ProjectSettings (as well as being a DiagramSetting).
*
- * @return Returns <code>true</code> if we show stereotypes.
- * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}.
+ * @return Returns <code>true</code> if we show stereotypes in the explorer
*/
- @Deprecated
public boolean getShowStereotypesValue() {
- return npSettings.isShowStereotypes();
+ return showExplorerStereotypes;
}
/**
- * @param showem <code>true</code> if stereotypes are to be shown.
- * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}.
+ * @param showem <code>true</code> if stereotypes are to be shown in the
+ * explorer.
*/
- @Deprecated
public void setShowStereotypes(String showem) {
setShowStereotypes(Boolean.valueOf(showem).booleanValue());
}
/**
- * @param showem <code>true</code> if stereotypes are to be shown.
- * @deprecated for 0.27.2 by tfmorris. Use {@link NotationSettings}.
+ * @param showem <code>true</code> if stereotypes are to be shown in the
+ * explorer view.
*/
- @Deprecated
public void setShowStereotypes(final boolean showem) {
- if (npSettings.isShowStereotypes() == showem) {
+ if (showExplorerStereotypes == showem) {
return;
}
@@ -774,12 +771,12 @@
private final ConfigurationKey key = Notation.KEY_SHOW_STEREOTYPES;
public void redo() {
- npSettings.setShowStereotypes(showem);
+ showExplorerStereotypes = showem;
fireNotationEvent(key, !showem, showem);
}
public void undo() {
- npSettings.setShowStereotypes(!showem);
+ showExplorerStereotypes = !showem;
fireNotationEvent(key, showem, !showem);
}
};
Modified: trunk/src/argouml-app/src/org/argouml/notation/NotationSettings.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/notation/NotationSettings.java?view=diff&pathrev=16435&r1=16434&r2=16435
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/notation/NotationSettings.java (original)
+++ trunk/src/argouml-app/src/org/argouml/notation/NotationSettings.java 2008-12-23 11:24:35-0800
@@ -27,48 +27,105 @@
import org.tigris.gef.undo.Memento;
/**
- * Notation settings value object. Stores settings which control how text is
+ * Notation settings value object. Stores settings which control how text is
* rendered on diagrams.
+ * <p>
+ * TODO: This needs to go on a diet. It's used everywhere, so is performance
+ * sensitive. The current set of settings is the union of all those found in the
+ * legacy code, but it's not clear that all of them are actually used.
*
* @author Tom Morris <[email protected]>
*/
public class NotationSettings {
-
- // TODO: This needs more complete initialization. Everything defaults to
- // false for now.
+
private static final NotationSettings DEFAULT_SETTINGS =
- new NotationSettings();
+ initializeDefaultSettings();
- // TODO: If we want to support a hierarchy of inherited settings, we'll
- // need a link to the parent, but not clear this is needed right now
- // private NotationSettings parent;
+ private NotationSettings parent;
private String notationLanguage;
- private boolean showAssociationNames;
+ // No valid field for above notationLanguage. It's valid if not null.
+ private boolean showAssociationNames;
+
+ private boolean showAssociationNamesSet = false;
+
private boolean showVisibilities;
-
+
+ private boolean showVisibilitiesSet = false;
+
private boolean showPaths;
-
+
+ private boolean showPathsSet = false;
+
private boolean fullyHandleStereotypes;
- private boolean showStereotypes = true;
-
+ private boolean fullyHandleStereotypesSet = false;
+
private boolean useGuillemets;
-
+
+ private boolean useGuillemetsSet = false;
+
private boolean showMultiplicities;
-
+
+ private boolean showMultiplicitiesSet = false;
+
private boolean showSingularMultiplicities;
+ private boolean showSingularMultiplicitiesSet = false;
+
// TODO: Do we need to control separately for attributes and operations?
private boolean showTypes;
-
+
+ private boolean showTypesSet = false;
+
private boolean showProperties;
-
+
+ private boolean showPropertiesSet = false;
+
private boolean showInitialValues;
-
-
+
+ private boolean showInitialValuesSet = false;
+
+ /**
+ * Create a notation settings value object with all default values.
+ * <p>
+ * TODO: This class only has partial Undo support (basically just those
+ * members that had it as part of a previous implementation).
+ */
+ public NotationSettings() {
+ super();
+ parent = getDefaultSettings();
+ }
+
+ /**
+ * Create a notation settings object which uses the given settings as its
+ * default values. Note that there can be multiple levels of settings in
+ * the hierarchy.
+ */
+ public NotationSettings(NotationSettings parentSettings) {
+ this();
+ parent = parentSettings;
+ }
+
+ // TODO: These defaults need to be checked against historical ones
+ private static NotationSettings initializeDefaultSettings() {
+ NotationSettings settings = new NotationSettings();
+ settings.parent = null;
+ settings.setNotationLanguage(Notation.DEFAULT_NOTATION);
+ settings.setFullyHandleStereotypes(false);
+ settings.setShowAssociationNames(false);
+ settings.setShowInitialValues(false);
+ settings.setShowMultiplicities(true);
+ settings.setShowPaths(false);
+ settings.setShowProperties(false);
+ settings.setShowSingularMultiplicities(false);
+ settings.setShowTypes(true);
+ settings.setShowVisibilities(false);
+ settings.setUseGuillemets(true);
+ return settings;
+ }
/**
* @return the default settings
@@ -82,11 +139,11 @@
*/
public String getNotationLanguage() {
if (notationLanguage == null) {
-// if (parent != null) {
-// return parent.getNotationLanguage();
-// } else {
- return "UML 1.4";
-// }
+ if (parent != null) {
+ return parent.getNotationLanguage();
+ } else {
+ return Notation.DEFAULT_NOTATION;
+ }
}
return notationLanguage;
}
@@ -129,41 +186,63 @@
/**
- * @return Returns the fullyHandleStereotypes.
+ * @return Returns the fullyHandleStereotypes setting. If true, it will
+ * cause notation providers to include the names of the stereotypes
+ * for an element in the editable string presented to the user.
*/
public boolean isFullyHandleStereotypes() {
- return fullyHandleStereotypes;
+ if (fullyHandleStereotypesSet) {
+ return fullyHandleStereotypes;
+ } else {
+ if (parent != null) {
+ return parent.fullyHandleStereotypes;
+ } else {
+ return getDefaultSettings().isFullyHandleStereotypes();
+ }
+ }
}
/**
- * @param fullyHandleStereotypes The fullyHandleStereotypes to set.
+ * @param newValue The fullyHandleStereotypes to set. If true, it will cause
+ * notation providers to include the names of the stereotypes for
+ * an element in the editable string presented to the user.
*/
- public void setFullyHandleStereotypes(boolean fullyHandleStereotypes) {
- this.fullyHandleStereotypes = fullyHandleStereotypes;
+ public void setFullyHandleStereotypes(boolean newValue) {
+ fullyHandleStereotypes = newValue;
+ fullyHandleStereotypesSet = true;
}
/**
* @return Returns the showSingularMultiplicities.
*/
public boolean isShowSingularMultiplicities() {
- return showSingularMultiplicities;
+ if (showSingularMultiplicitiesSet) {
+ return showSingularMultiplicities;
+ } else if (parent != null) {
+ return parent.isShowSingularMultiplicities();
+ }
+ return getDefaultSettings().isShowSingularMultiplicities();
}
/**
* @param showem <code>true</code> if "1" Multiplicities are to be shown.
*/
public void setShowSingularMultiplicities(final boolean showem) {
- if (showSingularMultiplicities == showem) {
+ if (showSingularMultiplicities == showem
+ && showSingularMultiplicitiesSet) {
return;
}
+ final boolean oldValid = showSingularMultiplicitiesSet;
Memento memento = new Memento() {
public void redo() {
showSingularMultiplicities = showem;
+ showSingularMultiplicitiesSet = true;
}
public void undo() {
showSingularMultiplicities = !showem;
+ showSingularMultiplicitiesSet = oldValid;
}
};
doUndoable(memento);
@@ -173,24 +252,33 @@
* @return Returns the useGuillemets.
*/
public boolean isUseGuillemets() {
- return useGuillemets;
+ if (useGuillemetsSet) {
+ return useGuillemets;
+ } else if (parent != null) {
+ return parent.isUseGuillemets();
+ }
+ return getDefaultSettings().isUseGuillemets();
}
/**
* @param showem <code>true</code> if guillemets are to be shown.
*/
public void setUseGuillemets(final boolean showem) {
- if (useGuillemets == showem) {
+ if (useGuillemets == showem && useGuillemetsSet) {
return;
}
+ final boolean oldValid = useGuillemetsSet;
+
Memento memento = new Memento() {
public void redo() {
useGuillemets = showem;
+ useGuillemetsSet = true;
}
public void undo() {
useGuillemets = !showem;
+ useGuillemetsSet = oldValid;
}
};
doUndoable(memento);
@@ -200,7 +288,12 @@
* @return Returns the showTypes.
*/
public boolean isShowTypes() {
- return showTypes;
+ if (showTypesSet) {
+ return showTypes;
+ } else if (parent != null) {
+ return parent.isShowTypes();
+ }
+ return getDefaultSettings().isShowTypes();
}
@@ -208,17 +301,21 @@
* @param showem <code>true</code> if types are to be shown.
*/
public void setShowTypes(final boolean showem) {
- if (showTypes == showem) {
+ if (showTypes == showem && showTypesSet) {
return;
}
+ final boolean oldValid = showTypesSet;
+
Memento memento = new Memento() {
public void redo() {
showTypes = showem;
+ showTypesSet = true;
}
public void undo() {
showTypes = !showem;
+ showTypesSet = oldValid;
}
};
doUndoable(memento);
@@ -229,24 +326,33 @@
* @return Returns the showProperties.
*/
public boolean isShowProperties() {
- return showProperties;
+ if (showPropertiesSet) {
+ return showProperties;
+ } else if (parent != null) {
+ return parent.isShowProperties();
+ }
+ return getDefaultSettings().isShowProperties();
}
/**
* @param showem <code>true</code> if properties are to be shown.
*/
public void setShowProperties(final boolean showem) {
- if (showProperties == showem) {
+ if (showProperties == showem && showPropertiesSet) {
return;
}
+ final boolean oldValid = showPropertiesSet;
+
Memento memento = new Memento() {
public void redo() {
showProperties = showem;
+ showPropertiesSet = true;
}
public void undo() {
showProperties = !showem;
+ showPropertiesSet = oldValid;
}
};
doUndoable(memento);
@@ -257,7 +363,12 @@
* @return Returns the showInitialValues.
*/
public boolean isShowInitialValues() {
- return showInitialValues;
+ if (showInitialValuesSet) {
+ return showInitialValues;
+ } else if (parent != null) {
+ return parent.isShowInitialValues();
+ }
+ return getDefaultSettings().isShowInitialValues();
}
@@ -265,17 +376,21 @@
* @param showem <code>true</code> if initial values are to be shown.
*/
public void setShowInitialValues(final boolean showem) {
- if (showInitialValues == showem) {
+ if (showInitialValues == showem && showInitialValuesSet) {
return;
}
+ final boolean oldValid = showInitialValuesSet;
+
Memento memento = new Memento() {
public void redo() {
showInitialValues = showem;
+ showInitialValuesSet = true;
}
public void undo() {
showInitialValues = !showem;
+ showInitialValuesSet = oldValid;
}
};
doUndoable(memento);
@@ -286,24 +401,33 @@
* @return Returns the showMultiplicities.
*/
public boolean isShowMultiplicities() {
- return showMultiplicities;
+ if (showMultiplicitiesSet) {
+ return showMultiplicities;
+ } else if (parent != null) {
+ return parent.isShowMultiplicities();
+ }
+ return getDefaultSettings().isShowMultiplicities();
}
/**
* @param showem <code>true</code> if the multiplicity is to be shown.
*/
public void setShowMultiplicities(final boolean showem) {
- if (showMultiplicities == showem) {
+ if (showMultiplicities == showem && showMultiplicitiesSet) {
return;
}
+ final boolean oldValid = showMultiplicitiesSet;
+
Memento memento = new Memento() {
public void redo() {
showMultiplicities = showem;
+ showMultiplicitiesSet = true;
}
public void undo() {
showMultiplicities = !showem;
+ showMultiplicitiesSet = oldValid;
}
};
doUndoable(memento);
@@ -315,25 +439,34 @@
* @return Returns the showAssociationNames.
*/
public boolean isShowAssociationNames() {
- return showAssociationNames;
+ if (showAssociationNamesSet) {
+ return showAssociationNames;
+ } else if (parent != null) {
+ return parent.isShowAssociationNames();
+ }
+ return getDefaultSettings().isShowAssociationNames();
}
/**
* @param showem <code>true</code> if association names are to be shown.
*/
public void setShowAssociationNames(final boolean showem) {
- if (showAssociationNames == showem) {
+ if (showAssociationNames == showem && showAssociationNamesSet) {
return;
}
+ final boolean oldValid = showAssociationNamesSet;
+
Memento memento = new Memento() {
public void redo() {
showAssociationNames = showem;
+ showAssociationNamesSet = true;
}
public void undo() {
showAssociationNames = !showem;
+ showAssociationNamesSet = oldValid;
}
};
doUndoable(memento);
@@ -343,7 +476,12 @@
* @return Returns the showVisibilities.
*/
public boolean isShowVisibilities() {
- return showVisibilities;
+ if (showVisibilitiesSet) {
+ return showVisibilities;
+ } else if (parent != null) {
+ return parent.isShowVisibilities();
+ }
+ return getDefaultSettings().isShowVisibilities();
}
@@ -351,17 +489,22 @@
* @param showem <code>true</code> if visibilities are to be shown.
*/
public void setShowVisibilities(final boolean showem) {
- if (showVisibilities == showem) {
+
+ if (showVisibilities == showem && showVisibilitiesSet) {
return;
}
+ final boolean oldValid = showVisibilitiesSet;
+
Memento memento = new Memento() {
public void redo() {
showVisibilities = showem;
+ showVisibilitiesSet = true;
}
public void undo() {
showVisibilities = !showem;
+ showVisibilitiesSet = oldValid;
}
};
doUndoable(memento);
@@ -371,7 +514,12 @@
* @return Returns the showPaths.
*/
public boolean isShowPaths() {
- return showPaths;
+ if (showPathsSet) {
+ return showPaths;
+ } else if (parent != null) {
+ return parent.isShowPaths();
+ }
+ return getDefaultSettings().isShowPaths();
}
@@ -380,38 +528,10 @@
*/
public void setShowPaths(boolean showPaths) {
this.showPaths = showPaths;
+ showPathsSet = true;
}
-
- /**
- * @return Returns the showStereotypes.
- */
- public boolean isShowStereotypes() {
- return showStereotypes;
- }
-
-
- /**
- * @param showem <code>true</code> if stereotypes are to be shown.
- */
- public void setShowStereotypes(final boolean showem) {
- if (showStereotypes == showem) {
- return;
- }
-
- Memento memento = new Memento() {
- public void redo() {
- showStereotypes = showem;
- }
-
- public void undo() {
- showStereotypes = !showem;
- }
- };
- doUndoable(memento);
-
- }
-
+
private void doUndoable(Memento memento) {
// TODO: Undo should be managed externally or we should be given
Modified: trunk/src/argouml-app/src/org/argouml/persistence/ArgoParser.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/persistence/ArgoParser.java?view=diff&pathrev=16435&r1=16434&r2=16435
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/persistence/ArgoParser.java (original)
+++ trunk/src/argouml-app/src/org/argouml/persistence/ArgoParser.java 2008-12-23 11:24:35-0800
@@ -431,8 +431,7 @@
*/
protected void handleShowStereotypes(XMLElement e) {
String showStereotypes = e.getText().trim();
- notationSettings.setShowStereotypes(
- Boolean.parseBoolean(showStereotypes));
+ ps.setShowStereotypes(Boolean.parseBoolean(showStereotypes));
}
/**
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramSettings.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramSettings.java?view=diff&pathrev=16435&r1=16434&r2=16435
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramSettings.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramSettings.java 2008-12-23 11:24:35-0800
@@ -31,15 +31,26 @@
/**
* Diagram appearance settings. This includes basic things like colors and
- * fonts, but also settings that affect more complex things like whether or
- * not certain labels and text fields are displayed.
+ * fonts, as well as the {@link NotationSettings} which contain all the settings
+ * that control text formatting.
* <p>
- * The special value <code>null</code> is used internally to indicate that the
- * default value should be inherited from the next level of settings.
+ * The settings are designed to work in a hierarchical fashion with any settings
+ * that are defaulted at the current level inheriting from the next level in
+ * the hierarchy. A typical hierarchy would be Fig->StyleSheet->Project where
+ * a style sheet is a named set of attributes that can be applied as a set to
+ * a fig (perhaps in conjunction with a stereotype). The hierarchy which is
+ * currently used in ArgoUML is Fig->Diagram->Project, although there's no
+ * support for changing anything but the Project (and a few of the attributes
+ * managed directly by GEF).
*
* @author Tom Morris <[email protected]>
*/
public class DiagramSettings {
+
+ /*
+ * The special value <code>null</code> is used internally to indicate that
+ * the default value should be inherited from the next level of settings.
+ */
/**
* Enumeration representing different stereotype presentation styles
@@ -99,6 +110,10 @@
// StereotypeView.SMALL_ICON;
// }
+ /**
+ * Next level in the settings hierarchy to inherit from if the value
+ * isn't set (ie is <default>) at the current level.
+ */
private DiagramSettings parent;
private NotationSettings notationSettings;
@@ -124,7 +139,6 @@
private StereotypeStyle defaultStereotypeView;
-
/**
* Construct an empty project settings with no parent and all values
* defaulted. <p>
@@ -147,6 +161,8 @@
public DiagramSettings(DiagramSettings parentSettings) {
this();
parent = parentSettings;
+ // We just created one of these and now we're throwing it away, oh well
+ notationSettings = new NotationSettings(getNotationSettings());
}
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=990884
To unsubscribe from this discussion, e-mail: [[email protected]].