Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,8 @@ fabric.properties
/use-assembly/target

**/.DS_Store

# ArchUnit generated failure reports (the directory is kept via its README,
# the report files are regenerated on every test run)
/docs/archunit-results/*
!/docs/archunit-results/README
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Please see the file `README' for a description of how to report bugs.

** Changes between version 7.1.0 and X.X.X
* USE now supports data types
* [GUI] The class diagram option "Group multiplicities / role names" is now
saved in the layout file and is enabled by default for class diagrams (#16)

** Changes between version 5.2.0 and 6.0.0
* New OCL complexity plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public abstract class DiagramOptions {
/**
* The current version number of the layout information
*/
public static int XML_LAYOUT_VERSION = 13;
public static int XML_LAYOUT_VERSION = 14;

protected boolean fDoAutoLayout = false;
protected boolean fSaveDefaultLayout = true;
Expand Down Expand Up @@ -295,6 +295,7 @@ public void saveOptions(PersistHelper helper, Element parent) {
helper.appendChild(parent, LayoutTags.SHOWOPERATIONS, String.valueOf(isShowOperations()));
helper.appendChild(parent, LayoutTags.SHOWROLENAMES, String.valueOf(isShowRolenames()));
helper.appendChild(parent, LayoutTags.SHOWGRID, String.valueOf(showGrid()));
helper.appendChild(parent, LayoutTags.GROUPMR, String.valueOf(isGroupMR()));
}
/**
* @param rootElement
Expand All @@ -310,6 +311,9 @@ public void loadOptions(PersistHelper helper, int version) {
if (version > 1) {
setShowGrid(helper.getElementBooleanValue(LayoutTags.SHOWGRID));
}
if (version > 13) {
setGroupMR(helper.getElementBooleanValue(LayoutTags.GROUPMR));
}
}

public void addOptionChangedListener(DiagramOptionChangedListener listener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1070,13 +1070,18 @@ public void loadLayoutFromString(String layoutString) {
version = Integer.valueOf(helper.getAttributeValue("version"));

if (beforeRestorePlacementInfos(version)) {
helper.toFirstChild("diagramOptions");
this.getOptions().loadOptions(helper, version);
helper.toParent();

helper.setAllNodes(this.collectAllNodes());
this.restorePlacementInfos(helper, version);
this.invalidateContent(false);
this.getOptions().setIsLoadingLayout(true);
try {
helper.toFirstChild("diagramOptions");
this.getOptions().loadOptions(helper, version);
helper.toParent();

helper.setAllNodes(this.collectAllNodes());
this.restorePlacementInfos(helper, version);
this.invalidateContent(false);
} finally {
this.getOptions().setIsLoadingLayout(false);
}
}

this.repaint();
Expand All @@ -1095,15 +1100,20 @@ public void loadLayout(Path layoutFile) {
version = Integer.valueOf(helper.getAttributeValue("version"));

if (beforeRestorePlacementInfos(version)) {
helper.toFirstChild("diagramOptions");
this.getOptions().loadOptions(helper, version);
helper.toParent();
this.getOptions().setIsLoadingLayout(true);
try {
helper.toFirstChild("diagramOptions");
this.getOptions().loadOptions(helper, version);
helper.toParent();

helper.setAllNodes(this.collectAllNodes());
this.restorePlacementInfos(helper, version);
this.invalidateContent(false);
helper.setAllNodes(this.collectAllNodes());
this.restorePlacementInfos(helper, version);
this.invalidateContent(false);

afterLoadLayout(layoutFile);
afterLoadLayout(layoutFile);
} finally {
this.getOptions().setIsLoadingLayout(false);
}
}

this.repaint();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public String toString() {
}

public ClassDiagramOptions() {
// In class diagrams, group multiplicities and role names by default
// (issue #16) so that their positions can be adjusted together. The
// value is persisted with the layout, so an explicit user choice
// overrides this default when a layout is loaded.
this.fGroupMR = true;
}

protected ShowCoverage fShowCoverage = ShowCoverage.DONT_SHOW;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public final class MultiplicityRolenameWrapper implements

PositionChangedListener position_changed_listener = null;

private final DiagramOptions options;

private boolean do_group = false;

double offset = 0;
Expand All @@ -51,6 +53,7 @@ public MultiplicityRolenameWrapper(Multiplicity multiplicity_client,
Rolename rolename_client, PropertyOwner end, DiagramOptions options) {
this.multiplicity_client = multiplicity_client;
this.rolename_client = rolename_client;
this.options = options;

// this.end = end;

Expand All @@ -64,18 +67,35 @@ public MultiplicityRolenameWrapper(Multiplicity multiplicity_client,
// Let this wrapper listen to position changes of either multiplicity or
// role name nodes.
instantiatePositionChangedListener();

// Reflect the current grouping option (which may have been restored
// from a layout file or set to its default) right from the start.
do_group = options.isGroupMR();
if (do_group) {
attach_listener();
}
}

@Override
public void optionChanged(String optionname) {
if (optionname.equals("GROUPMR"))
do_group = !do_group;

if (do_group)
if (!optionname.equals("GROUPMR")) {
return;
}

// Mirror the actual option value instead of blindly toggling. This
// keeps the grouping state in sync with the option even when the value
// is set explicitly, e.g. while loading a persisted layout.
boolean group = options.isGroupMR();
if (group == do_group) {
return;
}

do_group = group;
if (do_group) {
attach_listener();
else
} else {
detach_listener();

}
}

protected void determine_offset() {
Expand All @@ -91,6 +111,14 @@ protected void instantiatePositionChangedListener() {
public void positionChanged(Object source, Point2D currentPosition,
double deltaX, double deltaY) {

// While a layout is being restored, the stored positions are
// applied directly. Grouping must not drag the partner node
// during restore, otherwise the persisted positions of
// multiplicities / role names would be overwritten.
if (options.isLoadingLayout()) {
return;
}

detach_listener();

if (source instanceof Multiplicity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class LayoutTags {
public static final String SHOWATTRIBUTES = "showattributes";
public static final String SHOWOPERATIONS = "showoperations";
public static final String SHOWGRID = "showgrid";
public static final String GROUPMR = "groupmultiplicityrolenames";

// node and edge tags
public static final String NAME = "name";
Expand Down
Loading