Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/parsers/TransitionPropertiesParser.java117
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/preferences/CustomTransitionPreferencePage.java181
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/preferences/PreferenceConstants.java21
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/plugin.xml11
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/preferences/DiagramPreferenceInitializer.java3
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/OpaqueBehaviorUtil.java2
6 files changed, 315 insertions, 20 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/parsers/TransitionPropertiesParser.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/parsers/TransitionPropertiesParser.java
index 51710d366b0..3ce6eb50608 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/parsers/TransitionPropertiesParser.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/parsers/TransitionPropertiesParser.java
@@ -35,10 +35,14 @@ import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand;
import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.util.SafeRunnable;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.emf.utils.ServiceUtilsForEObject;
+import org.eclipse.papyrus.uml.diagram.statemachine.custom.preferences.PreferenceConstants;
+import org.eclipse.papyrus.uml.diagram.statemachine.part.UMLDiagramEditorPlugin;
+import org.eclipse.papyrus.uml.tools.utils.OpaqueBehaviorUtil;
import org.eclipse.papyrus.uml.tools.utils.OpaqueExpressionUtil;
import org.eclipse.papyrus.uml.tools.utils.ValueSpecificationUtil;
import org.eclipse.uml2.uml.Behavior;
@@ -50,6 +54,8 @@ import org.eclipse.uml2.uml.Event;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.OpaqueBehavior;
import org.eclipse.uml2.uml.OpaqueExpression;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.Signal;
import org.eclipse.uml2.uml.SignalEvent;
import org.eclipse.uml2.uml.TimeEvent;
import org.eclipse.uml2.uml.TimeExpression;
@@ -60,11 +66,15 @@ import org.eclipse.uml2.uml.ValueSpecification;
public class TransitionPropertiesParser implements IParser, ISemanticParser {
- private static final String ONE_SPACE_STRING = " "; //$NON-NLS-1$
+ public static final String ONE_SPACE_STRING = " "; //$NON-NLS-1$
- protected Constraint guardConstraint = null;
+ public static final String EMPTY_STRING = ""; //$NON-NLS-1$
+
+ public static final String DOTS = "..."; //$NON-NLS-1$
- private static String EMPTY_STRING = ""; //$NON-NLS-1$
+ public static final String PARAM_DOTS = "(...)"; //$NON-NLS-1$
+
+ protected Constraint guardConstraint = null;
public IContentAssistProcessor getCompletionProcessor(IAdaptable element) {
return null;
@@ -160,12 +170,18 @@ public class TransitionPropertiesParser implements IParser, ISemanticParser {
StringBuilder result = new StringBuilder();
String textForTrigger = getTextForTrigger(trans);
if(textForTrigger != null && !EMPTY_STRING.equals(textForTrigger)) {
- result.append(textForTrigger).append(ONE_SPACE_STRING);
+ result.append(textForTrigger);
}
result.append(getTextForGuard(trans));
String textForEffect = getTextForEffect(trans);
if(textForEffect != null && !EMPTY_STRING.equals(textForEffect)) {
- result.append("/\n").append(textForEffect); //$NON-NLS-1$
+ if(textForEffect != null && !EMPTY_STRING.equals(textForEffect)) {
+ result.append("/"); //$NON-NLS-1$
+ if (lineBreakBeforeEffect()) {
+ result.append("\n"); //$NON-NLS-1$
+ }
+ result.append(textForEffect);
+ }
}
return result.toString();
}
@@ -204,7 +220,7 @@ public class TransitionPropertiesParser implements IParser, ISemanticParser {
OpaqueBehavior ob = (OpaqueBehavior)effect;
if(ob.getBodies().size() > 0) {
// return body of behavior (only handle case of a single body)
- result.append(ob.getBodies().get(0));
+ result.append(retrieveBody(ob));
return result.toString();
}
}
@@ -233,15 +249,23 @@ public class TransitionPropertiesParser implements IParser, ISemanticParser {
}
Event e = t.getEvent();
if(e instanceof CallEvent) {
- if(((CallEvent)e).getOperation() != null) {
- result.append(((CallEvent)e).getOperation().getName());
+ Operation op = ((CallEvent)e).getOperation();
+ if(op != null) {
+ result.append(op.getName());
+ if ((op.getOwnedParameters().size() > 0) && displayParamDots()) {
+ result.append(PARAM_DOTS);
+ }
} else {
result.append(((CallEvent)e).getName());
}
} else if(e instanceof SignalEvent) {
- if(((SignalEvent)e).getSignal() != null) {
- result.append(((SignalEvent)e).getSignal().getName());
+ Signal signal = ((SignalEvent)e).getSignal();
+ if(signal != null) {
+ result.append(signal.getName());
+ if ((signal.getAttributes().size() > 0) && displayParamDots()) {
+ result.append(PARAM_DOTS);
+ }
} else {
result.append(((SignalEvent)e).getName());
}
@@ -249,7 +273,7 @@ public class TransitionPropertiesParser implements IParser, ISemanticParser {
ValueSpecification vs = ((ChangeEvent) e).getChangeExpression();
String value;
if (vs instanceof OpaqueExpression) {
- value = "\"" + retrieveBody((OpaqueExpression) vs) + "\""; //$NON-NLS-1$ //$NON-NLS-2$
+ value = retrieveBody((OpaqueExpression) vs);
}
else {
value = vs.stringValue();
@@ -265,7 +289,7 @@ public class TransitionPropertiesParser implements IParser, ISemanticParser {
if (te != null) {
ValueSpecification vs = te.getExpr();
if (vs instanceof OpaqueExpression) {
- value = "\"" + retrieveBody((OpaqueExpression) vs) + "\""; //$NON-NLS-1$ //$NON-NLS-2$
+ value = retrieveBody((OpaqueExpression) vs);
}
else {
value = vs.stringValue();
@@ -342,11 +366,76 @@ public class TransitionPropertiesParser implements IParser, ISemanticParser {
* @param exp an opaque expression
* @return the associated body
*/
- private static String retrieveBody(OpaqueExpression exp) {
+ public static String retrieveBody(OpaqueExpression exp) {
String body = OpaqueExpressionUtil.getBodyForLanguage(exp, "Natural Language"); //$NON-NLS-1$
if (body.equals(EMPTY_STRING)) {
body = OpaqueExpressionUtil.getBodyForLanguage(exp, null);
}
- return body;
+ return cutBodyString(body);
+ }
+
+ /**
+ * Return the body of an opaque behavior. Retrieve the "Natural Language" body with priority,
+ * i.e. return this body if it exists, otherwise return the first body.
+ *
+ * @param exp an opaque expression
+ * @return the associated body
+ */
+ public static String retrieveBody(OpaqueBehavior ob) {
+ String body = OpaqueBehaviorUtil.getBody(ob, "Natural Language"); //$NON-NLS-1$
+ if (body.equals(EMPTY_STRING) && ob.getBodies().size() > 0) {
+ body = ob.getBodies().get(0);
+ }
+ return cutBodyString(body);
+ }
+
+ /**
+ * Cut a body string after a predefined number of lines (taken from preference store).
+ *
+ * @param body the body string
+ * @return
+ */
+ public static String cutBodyString(String body) {
+ IPreferenceStore preferenceStore = UMLDiagramEditorPlugin.getInstance().getPreferenceStore();
+ int cutLength = preferenceStore.getInt(PreferenceConstants.BODY_CUT_LENGTH);
+
+ if (cutLength == 0) {
+ return DOTS;
+ }
+ else {
+ int start = 0;
+ while (cutLength > 0) {
+ int newStart = body.indexOf(System.lineSeparator(), start);
+ if (newStart > 0) {
+ cutLength--;
+ start = newStart + 1;
+ }
+ else {
+ return body;
+ }
+ }
+ if (start > 0) {
+ return body.substring(0, start - 1) + DOTS;
+ }
+ return body;
+ }
+ }
+
+ /**
+ *
+ * @return true, if the presence of parameters should be indicated by (...)
+ */
+ public static boolean displayParamDots() {
+ IPreferenceStore preferenceStore = UMLDiagramEditorPlugin.getInstance().getPreferenceStore();
+ return preferenceStore.getBoolean(PreferenceConstants.INDICATE_PARAMETERS);
+ }
+
+ /**
+ *
+ * @return true, if the presence of parameters should be indicated by (...)
+ */
+ public static boolean lineBreakBeforeEffect() {
+ IPreferenceStore preferenceStore = UMLDiagramEditorPlugin.getInstance().getPreferenceStore();
+ return preferenceStore.getBoolean(PreferenceConstants.LINEBREAK_BEFORE_EFFECT);
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/preferences/CustomTransitionPreferencePage.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/preferences/CustomTransitionPreferencePage.java
new file mode 100644
index 00000000000..1034eea9b31
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/preferences/CustomTransitionPreferencePage.java
@@ -0,0 +1,181 @@
+package org.eclipse.papyrus.uml.diagram.statemachine.custom.preferences;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.uml.diagram.statemachine.preferences.TransitionPreferencePage;
+import org.eclipse.papyrus.uml.tools.utils.ICustomAppearence;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+public class CustomTransitionPreferencePage extends TransitionPreferencePage {
+
+ /**
+ * Button: if selected, indicate signals/call events with parameters by means of (...)
+ */
+ Button bIndicateParameters;
+
+ /**
+ * Button: if selected, add a line/break before a non-empty effect
+ */
+ Button bLineBreakBeforeEffector;
+
+ /**
+ * Cut text of opaque bodies after certain length
+ */
+ Text tBodyCutLength;
+
+ /**
+ * initialize the preferences
+ * @param store the preference store associated with the state machine diagram.
+ */
+ public static void initDefaults(IPreferenceStore store) {
+ int cutLength = 1;
+ if(cutLength != store.getInt(PreferenceConstants.BODY_CUT_LENGTH)) {
+ store.setValue(PreferenceConstants.BODY_CUT_LENGTH, cutLength);
+ }
+
+ boolean indicateParams = true;
+ if(indicateParams != store.getBoolean(PreferenceConstants.INDICATE_PARAMETERS)) {
+ store.setValue(PreferenceConstants.INDICATE_PARAMETERS, indicateParams);
+ }
+ TransitionPreferencePage.initDefaults(store);
+
+ boolean lineBreakBeforeEffect = true;
+ if(lineBreakBeforeEffect != store.getBoolean(PreferenceConstants.LINEBREAK_BEFORE_EFFECT)) {
+ store.setValue(PreferenceConstants.LINEBREAK_BEFORE_EFFECT, lineBreakBeforeEffect);
+ }
+ TransitionPreferencePage.initDefaults(store);
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void createPageContents(Composite parent) {
+ super.createPageContents(parent);
+ // adds the label preferences checkboxes
+ createTransitionPreferencesButtons(parent);
+ // refreshButtons();
+ }
+
+ /**
+ * Creates the group and check boxes to choose the kind of display
+ *
+ * @param parent
+ * the parent composite that holds the group
+ */
+ protected void createTransitionPreferencesButtons(Composite parent) {
+ IPreferenceStore store = getPreferenceStore();
+
+ // create group that host the buttons
+ Group group = new Group(parent, SWT.SHADOW_NONE);
+ group.setText("Transition Display");
+ group.setLayout(new FormLayout());
+ // group.setLayout(new GridLayout(1, false));
+
+ FormData data;
+
+ bIndicateParameters = createCheckButton(group, "Indicate parameters", ICustomAppearence.DISP_VISIBILITY);
+ bIndicateParameters.setSelection(store.getBoolean(PreferenceConstants.INDICATE_PARAMETERS));
+ data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.top = new FormAttachment(0, 0);
+ bIndicateParameters.setLayoutData(data);
+
+ bLineBreakBeforeEffector = createCheckButton(group, "Line break before effect label", ICustomAppearence.DISP_VISIBILITY);
+ bLineBreakBeforeEffector.setSelection(store.getBoolean(PreferenceConstants.LINEBREAK_BEFORE_EFFECT));
+ data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.top = new FormAttachment(bIndicateParameters, 0);
+ bLineBreakBeforeEffector.setLayoutData(data);
+
+ Composite maxLengthComposite = new Composite(group, SWT.NONE);
+ maxLengthComposite.setLayout(new GridLayout(2, false));
+ data = new FormData();
+ data.left = new FormAttachment(0, 0);
+ data.top = new FormAttachment(bLineBreakBeforeEffector, 0);
+ maxLengthComposite.setLayoutData(data);
+ Label l = new Label(maxLengthComposite, SWT.NONE);
+ l.setText("Shown number of lines for opaque expressions/behaviors: ");
+ tBodyCutLength = new Text(maxLengthComposite, SWT.NONE);
+ tBodyCutLength.setText(store.getInt(PreferenceConstants.BODY_CUT_LENGTH) + ""); // $NON-NLS-1$
+ final GridData gridData = new GridData();
+ gridData.widthHint = 50; // minimal width to assure entering larger numbers
+ tBodyCutLength.setLayoutData(gridData);
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void performDefaults() {
+ IPreferenceStore store = getPreferenceStore();
+ initDefaults(store);
+
+ bIndicateParameters.setSelection(store.getBoolean(PreferenceConstants.INDICATE_PARAMETERS));
+ bLineBreakBeforeEffector.setSelection(store.getBoolean(PreferenceConstants.LINEBREAK_BEFORE_EFFECT));
+ tBodyCutLength.setText("" + store.getInt(PreferenceConstants.BODY_CUT_LENGTH));
+
+ super.performDefaults();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean performOk() {
+ storePreferences();
+ return super.performOk();
+ }
+
+
+ /**
+ * Creates a button with the {@link SWT#CHECK} style.
+ *
+ * @param parent
+ * the parent of the button
+ * @param label
+ * the label of the button
+ * @param mask
+ * the value controlled by the button
+ * @return the button created
+ */
+ protected Button createCheckButton(Composite parent, String label, int mask) {
+ Button button = new Button(parent, SWT.CHECK);
+ button.setText(label);
+ return button;
+ }
+
+ /**
+ * Stores the values of the fields contained in this page into the preference store.
+ */
+ protected void storePreferences() {
+ IPreferenceStore store = getPreferenceStore();
+ // checks the stored value and the actual one, so does not refresh diagram if it is not
+ // needed
+ boolean lineBreakBeforeEffect = bLineBreakBeforeEffector.getSelection();
+ if(lineBreakBeforeEffect != store.getBoolean(PreferenceConstants.LINEBREAK_BEFORE_EFFECT)) {
+ store.setValue(PreferenceConstants.LINEBREAK_BEFORE_EFFECT, lineBreakBeforeEffect);
+ }
+
+ int cutLength = new Integer(tBodyCutLength.getText().trim());
+ if(cutLength != store.getInt(PreferenceConstants.BODY_CUT_LENGTH)) {
+ store.setValue(PreferenceConstants.BODY_CUT_LENGTH, cutLength);
+ }
+
+ boolean indicateParams = bIndicateParameters.getSelection();
+ if(indicateParams != store.getBoolean(PreferenceConstants.INDICATE_PARAMETERS)) {
+ store.setValue(PreferenceConstants.INDICATE_PARAMETERS, indicateParams);
+ }
+ }
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/preferences/PreferenceConstants.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/preferences/PreferenceConstants.java
new file mode 100644
index 00000000000..27bfd56cdf7
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/custom-src/org/eclipse/papyrus/uml/diagram/statemachine/custom/preferences/PreferenceConstants.java
@@ -0,0 +1,21 @@
+package org.eclipse.papyrus.uml.diagram.statemachine.custom.preferences;
+
+/**
+ *
+ */
+public class PreferenceConstants {
+ /**
+ * integer: Maximum length of displayed bodies.
+ */
+ public final static String BODY_CUT_LENGTH = "bodyCutLength";
+
+ /**
+ * Boolean: if true, indicate presence of parameters (attributes) by adding (...) to call or signal event.
+ */
+ public final static String INDICATE_PARAMETERS = "indicateParameters";
+
+ /**
+ * Boolean: if true, add a line-break to the transition label before the effect
+ */
+ public final static String LINEBREAK_BEFORE_EFFECT = "lineBreakBeforeEffect";
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/plugin.xml b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/plugin.xml
index c53d546ea9f..c278866437e 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/plugin.xml
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/plugin.xml
@@ -909,17 +909,20 @@
name="Generalization Link" />
-
- <?gmfgen generated="true"?>
+<!-- changed by Ansgar Radermacher -->
+ <?gmfgen generated="false"?>
<page category="org.eclipse.papyrus.infra.gmfdiag.preferences.diagrams.PapyrusUMLStateMachineDiagram"
- class="org.eclipse.papyrus.uml.diagram.statemachine.preferences.TransitionPreferencePage"
- id="org.eclipse.papyrus.uml.diagram.statemachine.preferences.TransitionPreferencePage"
+ class="org.eclipse.papyrus.uml.diagram.statemachine.custom.preferences.CustomTransitionPreferencePage"
+ id="org.eclipse.papyrus.uml.diagram.statemachine.custom.preferences.TransitionPreferencePage"
name="Transition Link" />
</extension>
+
+
+
<extension
id="PapyrusUMLStateMachineDiagram.palettedefinition"
name="PapyrusUMLStateMachineDiagram Predefined Entries"
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/preferences/DiagramPreferenceInitializer.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/preferences/DiagramPreferenceInitializer.java
index 0378ac6ccfd..df722f1a987 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/preferences/DiagramPreferenceInitializer.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/preferences/DiagramPreferenceInitializer.java
@@ -2,6 +2,7 @@ package org.eclipse.papyrus.uml.diagram.statemachine.preferences;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.uml.diagram.statemachine.custom.preferences.CustomTransitionPreferencePage;
import org.eclipse.papyrus.uml.diagram.statemachine.part.UMLDiagramEditorPlugin;
/**
@@ -34,6 +35,6 @@ public class DiagramPreferenceInitializer extends AbstractPreferenceInitializer
StateMachinePreferencePage.initDefaults(store);
InternalTransitionPreferencePage.initDefaults(store);
GeneralizationPreferencePage.initDefaults(store);
- TransitionPreferencePage.initDefaults(store);
+ CustomTransitionPreferencePage.initDefaults(store);
}
}
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/OpaqueBehaviorUtil.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/OpaqueBehaviorUtil.java
index 802d4dae0ce..592bcf8a817 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/OpaqueBehaviorUtil.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools.utils/src/org/eclipse/papyrus/uml/tools/utils/OpaqueBehaviorUtil.java
@@ -57,7 +57,7 @@ public class OpaqueBehaviorUtil {
}
/**
- * Returns the index of the body for a given langauge.
+ * Returns the index of the body for a given language.
*
* @param language
* the language of the body to find

Back to the top