Просмотр исходного кода

Added Documentation to Property Sheets, context menu action to switch between documentation and expression

Andreas Mülder 13 лет назад
Родитель
Сommit
f7c737c70f
17 измененных файлов с 519 добавлено и 60 удалено
  1. 31 0
      plugins/org.yakindu.sct.ui.editor/plugin.xml
  2. 3 11
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/commands/CreateTransitionCommand.java
  3. 15 1
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/commands/SetDeepHistoryEntryKindCommand.java
  4. 15 1
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/commands/SetEntryKindCommand.java
  5. 15 1
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/commands/SetInitialEntryKindCommand.java
  6. 15 1
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/commands/SetShallowHistoryEntryKindCommand.java
  7. 89 0
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/commands/ToggleShowDocumentationCommand.java
  8. 15 1
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/commands/ToggleSubRegionLayoutCommand.java
  9. 26 9
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editparts/PlugableExternalXtextLabelEditPart.java
  10. 25 9
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editparts/PlugableXtextLabelEditPart.java
  11. 54 2
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editparts/StateTextCompartmentExpressionEditPart.java
  12. 54 2
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editparts/StatechartTextExpressionEditPart.java
  13. 75 1
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editparts/TransitionExpressionEditPart.java
  14. 1 1
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/propertysheets/AbstractTwoColumnEditorPropertySection.java
  15. 35 12
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/propertysheets/StatePropertySection.java
  16. 32 8
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/propertysheets/StatechartPropertySection.java
  17. 19 0
      plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/propertysheets/TransitionPropertySection.java

+ 31 - 0
plugins/org.yakindu.sct.ui.editor/plugin.xml

@@ -810,6 +810,11 @@
        id="org.yakindu.sct.ui.editor.commands.ToggleSubRegionLayoutCommand"
        name="Toggle Subregion Layout">
  	</command>
+ 	<command
+       defaultHandler="org.yakindu.sct.ui.editor.commands.ToggleShowDocumentationCommand"
+       id="org.yakindu.sct.ui.editor.commands.ToggleShowDocumentation"
+       name="Toggle Documentation">
+ 	</command>
 </extension>
 
 <extension
@@ -872,6 +877,32 @@
              </with>
           </visibleWhen>
        </command>
+       <command
+             commandId="org.yakindu.sct.ui.editor.commands.ToggleShowDocumentation"
+             label="Toggle Documentation"
+             style="push">
+          <visibleWhen
+                checkEnabled="false">
+             <with
+                   variable="selection">
+                <iterate
+                      ifEmpty="false"
+                      operator="and">
+                   <or>
+                      <instanceof
+                            value="org.yakindu.sct.ui.editor.editparts.TransitionEditPart">
+                      </instanceof>
+                      <instanceof
+                            value="org.yakindu.sct.ui.editor.editparts.StateEditPart">
+                      </instanceof>
+                      <instanceof
+                            value="org.yakindu.sct.ui.editor.editparts.StatechartTextEditPart">
+                      </instanceof>
+                   </or>
+                </iterate>
+             </with>
+          </visibleWhen>
+       </command>
     </menuContribution>
  </extension>
  

+ 3 - 11
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/commands/CreateTransitionCommand.java

@@ -30,11 +30,11 @@ import org.yakindu.sct.model.sgraph.Vertex;
  * 
  */
 public class CreateTransitionCommand extends EditElementCommand {
-	
+
 	public CreateTransitionCommand(CreateRelationshipRequest request) {
 		super(request.getLabel(), null, request);
 	}
-	
+
 	@Override
 	protected CreateRelationshipRequest getRequest() {
 		return (CreateRelationshipRequest) super.getRequest();
@@ -44,7 +44,7 @@ public class CreateTransitionCommand extends EditElementCommand {
 	public boolean canExecute() {
 		EObject source = getRequest().getSource();
 		EObject target = getRequest().getTarget();
-		
+
 		if (source == null && target == null) {
 			return false;
 		}
@@ -58,16 +58,8 @@ public class CreateTransitionCommand extends EditElementCommand {
 	@Override
 	protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
 			IAdaptable info) throws ExecutionException {
-
-		// This class casts should be save because they are validated in
-		// canExecute() method which is called by the framework before
-		// execution.
 		Vertex source = (Vertex) getRequest().getSource();
 		Vertex target = (Vertex) getRequest().getTarget();
-//		if (!canExecute()) {
-//			throw new ExecutionException(
-//					"Invalid arguments in create link command");
-//		}
 		if (source != null && target != null) {
 			Transition transition = SGraphFactory.eINSTANCE.createTransition();
 			source.getOutgoingTransitions().add(transition);

+ 15 - 1
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/commands/SetDeepHistoryEntryKindCommand.java

@@ -1,7 +1,21 @@
+/**
+ * Copyright (c) 2012 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
 package org.yakindu.sct.ui.editor.commands;
 
 import org.yakindu.sct.model.sgraph.EntryKind;
-
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
 public class SetDeepHistoryEntryKindCommand extends SetEntryKindCommand {
 
 	public EntryKind getEntryKind() {

+ 15 - 1
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/commands/SetEntryKindCommand.java

@@ -1,3 +1,13 @@
+/**
+ * Copyright (c) 2012 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
 package org.yakindu.sct.ui.editor.commands;
 
 import org.eclipse.core.commands.AbstractHandler;
@@ -16,7 +26,11 @@ import org.yakindu.sct.model.sgraph.Entry;
 import org.yakindu.sct.model.sgraph.EntryKind;
 import org.yakindu.sct.model.sgraph.SGraphPackage;
 import org.yakindu.sct.ui.editor.editparts.EntryEditPart;
-
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
 public abstract class SetEntryKindCommand extends AbstractHandler {
 
 	private Entry entry;

+ 15 - 1
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/commands/SetInitialEntryKindCommand.java

@@ -1,7 +1,21 @@
+/**
+ * Copyright (c) 2012 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
 package org.yakindu.sct.ui.editor.commands;
 
 import org.yakindu.sct.model.sgraph.EntryKind;
-
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
 public class SetInitialEntryKindCommand extends SetEntryKindCommand {
 
 	public EntryKind getEntryKind() {

+ 15 - 1
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/commands/SetShallowHistoryEntryKindCommand.java

@@ -1,7 +1,21 @@
+/**
+ * Copyright (c) 2012 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
 package org.yakindu.sct.ui.editor.commands;
 
 import org.yakindu.sct.model.sgraph.EntryKind;
-
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
 public class SetShallowHistoryEntryKindCommand extends SetEntryKindCommand {
 
 	@Override

+ 89 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/commands/ToggleShowDocumentationCommand.java

@@ -0,0 +1,89 @@
+/**
+ * Copyright (c) 2013 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation (http://www.statecharts.org)
+ * 
+ */
+package org.yakindu.sct.ui.editor.commands;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.operations.OperationHistoryFactory;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
+import org.eclipse.gmf.runtime.emf.type.core.commands.SetValueCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.SetRequest;
+import org.eclipse.gmf.runtime.notation.NotationFactory;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.StringValueStyle;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.yakindu.base.base.BasePackage;
+import org.yakindu.sct.model.sgraph.SGraphPackage;
+
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
+public class ToggleShowDocumentationCommand extends AbstractHandler {
+
+	public static final String FEATURE_TO_SHOW = "featureToShow";
+
+	public Object execute(ExecutionEvent event) throws ExecutionException {
+		View view = unwrap(HandlerUtil.getCurrentSelection(event));
+		StringValueStyle style = (StringValueStyle) view.getNamedStyle(
+				NotationPackage.Literals.STRING_VALUE_STYLE, FEATURE_TO_SHOW);
+		if (style == null) {
+			style = createInitialStyle(view);
+		}
+		String featureName = style.getStringValue().equals(
+				SGraphPackage.Literals.SPECIFICATION_ELEMENT__SPECIFICATION
+						.getName()) ? BasePackage.Literals.DOCUMENTED_ELEMENT__DOCUMENTATION
+				.getName()
+				: SGraphPackage.Literals.SPECIFICATION_ELEMENT__SPECIFICATION
+						.getName();
+		SetValueCommand cmd = new SetValueCommand(new SetRequest(style,
+				NotationPackage.Literals.STRING_VALUE_STYLE__STRING_VALUE,
+				featureName));
+		executeCommand(cmd);
+		return null;
+
+	}
+
+	protected StringValueStyle createInitialStyle(View view) {
+		StringValueStyle style = NotationFactory.eINSTANCE
+				.createStringValueStyle();
+		style.setName(FEATURE_TO_SHOW);
+		style.setStringValue(SGraphPackage.Literals.SPECIFICATION_ELEMENT__SPECIFICATION
+				.getName());
+		SetValueCommand cmd = new SetValueCommand(new SetRequest(view,
+				NotationPackage.Literals.VIEW__STYLES, style));
+		executeCommand(cmd);
+		return style;
+	}
+
+	protected void executeCommand(SetValueCommand setcommand) {
+		try {
+			OperationHistoryFactory.getOperationHistory().execute(setcommand,
+					new NullProgressMonitor(), null);
+		} catch (ExecutionException e) {
+			e.printStackTrace();
+		}
+	}
+
+	protected View unwrap(ISelection selection) {
+		IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+		Object firstElement = structuredSelection.getFirstElement();
+		if (firstElement == null)
+			return null;
+		return ((IGraphicalEditPart) firstElement).getNotationView();
+	}
+}

+ 15 - 1
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/commands/ToggleSubRegionLayoutCommand.java

@@ -1,3 +1,13 @@
+/**
+ * Copyright (c) 2012 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * Contributors:
+ * 	committers of YAKINDU - initial API and implementation
+ * 
+ */
 package org.yakindu.sct.ui.editor.commands;
 
 import java.util.ArrayList;
@@ -24,7 +34,11 @@ import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.ui.handlers.HandlerUtil;
 import org.yakindu.sct.ui.editor.editparts.StateEditPart;
-
+/**
+ * 
+ * @author andreas muelder - Initial contribution and API
+ * 
+ */
 public class ToggleSubRegionLayoutCommand extends AbstractHandler {
 
 	private View view;

+ 26 - 9
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editparts/PlugableExternalXtextLabelEditPart.java

@@ -10,6 +10,7 @@
  */
 package org.yakindu.sct.ui.editor.editparts;
 
+import org.eclipse.draw2d.Label;
 import org.eclipse.emf.common.notify.Notification;
 import org.eclipse.emf.ecore.EAttribute;
 import org.eclipse.emf.ecore.EObject;
@@ -24,6 +25,7 @@ import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
 import org.eclipse.gmf.runtime.notation.View;
 import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
 import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.yakindu.base.base.BasePackage;
 import org.yakindu.sct.model.sgraph.SGraphPackage;
 import org.yakindu.sct.model.sgraph.SpecificationElement;
 import org.yakindu.sct.ui.editor.DiagramActivator;
@@ -98,15 +100,6 @@ public abstract class PlugableExternalXtextLabelEditPart extends
 		return super.resolveSemanticElement();
 	}
 
-	@Override
-	protected void handleNotificationEvent(Notification notification) {
-		if (notification.getFeature() == getFeature()) {
-			refreshVisuals();
-		} else {
-			super.handleNotificationEvent(notification);
-		}
-	}
-
 	private EAttribute getFeature() {
 		return SGraphPackage.Literals.SPECIFICATION_ELEMENT__SPECIFICATION;
 	}
@@ -136,4 +129,28 @@ public abstract class PlugableExternalXtextLabelEditPart extends
 		return null;
 	}
 
+	@Override
+	protected void refreshVisuals() {
+		super.refreshVisuals();
+		updateTooltipText();
+
+	}
+
+	protected void updateTooltipText() {
+		Label tooltip = new Label((String) resolveSemanticElement().eGet(
+				BasePackage.Literals.DOCUMENTED_ELEMENT__DOCUMENTATION));
+		getFigure().setToolTip(tooltip);
+	}
+
+	@Override
+	protected void handleNotificationEvent(Notification notification) {
+		if (notification.getFeature() == getFeature()) {
+			refreshVisuals();
+		} else if (notification.getFeature() == BasePackage.Literals.DOCUMENTED_ELEMENT__DOCUMENTATION) {
+			refreshVisuals();
+		} else {
+		}
+		super.handleNotificationEvent(notification);
+	}
+
 }

+ 25 - 9
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editparts/PlugableXtextLabelEditPart.java

@@ -10,6 +10,7 @@
  */
 package org.yakindu.sct.ui.editor.editparts;
 
+import org.eclipse.draw2d.Label;
 import org.eclipse.emf.common.notify.Notification;
 import org.eclipse.emf.ecore.EAttribute;
 import org.eclipse.emf.ecore.EObject;
@@ -24,6 +25,7 @@ import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
 import org.eclipse.gmf.runtime.notation.View;
 import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
 import org.eclipse.jface.viewers.ICellEditorValidator;
+import org.yakindu.base.base.BasePackage;
 import org.yakindu.sct.model.sgraph.SGraphPackage;
 import org.yakindu.sct.model.sgraph.SpecificationElement;
 import org.yakindu.sct.ui.editor.DiagramActivator;
@@ -97,15 +99,6 @@ public abstract class PlugableXtextLabelEditPart extends XtextLabelEditPart
 		return resolveSemanticElement();
 	}
 
-	@Override
-	protected void handleNotificationEvent(Notification notification) {
-		if (notification.getFeature() == getFeature()) {
-			refreshVisuals();
-		} else {
-			super.handleNotificationEvent(notification);
-		}
-	}
-
 	protected EAttribute getFeature() {
 		return SGraphPackage.Literals.SPECIFICATION_ELEMENT__SPECIFICATION;
 	}
@@ -135,4 +128,27 @@ public abstract class PlugableXtextLabelEditPart extends XtextLabelEditPart
 		return null;
 	}
 
+	@Override
+	protected void refreshVisuals() {
+		super.refreshVisuals();
+		updateTooltipText();
+
+	}
+
+	protected void updateTooltipText() {
+		Label tooltip = new Label((String) resolveSemanticElement().eGet(
+				BasePackage.Literals.DOCUMENTED_ELEMENT__DOCUMENTATION));
+		getFigure().setToolTip(tooltip);
+	}
+
+	@Override
+	protected void handleNotificationEvent(Notification notification) {
+		if (notification.getFeature() == getFeature()) {
+			refreshVisuals();
+		} else if (notification.getFeature() == BasePackage.Literals.DOCUMENTED_ELEMENT__DOCUMENTATION) {
+			refreshVisuals();
+		} else {
+		}
+		super.handleNotificationEvent(notification);
+	}
 }

+ 54 - 2
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editparts/StateTextCompartmentExpressionEditPart.java

@@ -10,9 +10,16 @@
  */
 package org.yakindu.sct.ui.editor.editparts;
 
+import org.eclipse.draw2d.Label;
+import org.eclipse.emf.common.notify.Notification;
 import org.eclipse.gef.EditPolicy;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.StringValueStyle;
 import org.eclipse.gmf.runtime.notation.View;
 import org.eclipse.swt.SWT;
+import org.yakindu.base.base.BasePackage;
+import org.yakindu.sct.model.sgraph.State;
+import org.yakindu.sct.ui.editor.commands.ToggleShowDocumentationCommand;
 import org.yakindu.sct.ui.editor.extensions.ExpressionLanguageProviderExtensions.SemanticTarget;
 import org.yakindu.sct.ui.editor.policies.ContextSensitiveHelpPolicy;
 import org.yakindu.sct.ui.editor.utils.HelpContextIds;
@@ -53,8 +60,7 @@ public class StateTextCompartmentExpressionEditPart extends
 	protected void createDefaultEditPolicies() {
 		super.createDefaultEditPolicies();
 		removeEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
-		installEditPolicy(
-				EditPolicy.SELECTION_FEEDBACK_ROLE,
+		installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE,
 				new ContextSensitiveHelpPolicy(
 						HelpContextIds.SC_PROPERTIES_STATE_EXPRESSION));
 	}
@@ -70,4 +76,50 @@ public class StateTextCompartmentExpressionEditPart extends
 	protected int getEditorStyles() {
 		return SWT.MULTI;
 	}
+
+	@Override
+	public State resolveSemanticElement() {
+		return (State) super.resolveSemanticElement();
+	}
+
+	@Override
+	protected void updateTooltipText() {
+		StringValueStyle style = getFeatureToShowStyle();
+		if (style != null
+				&& style.getStringValue().equals(
+						BasePackage.Literals.DOCUMENTED_ELEMENT__DOCUMENTATION
+								.getName())) {
+			Label tooltip = new Label((String) resolveSemanticElement()
+					.getSpecification());
+			getFigure().setToolTip(tooltip);
+		} else
+			super.updateTooltipText();
+	}
+
+	@Override
+	protected void updateLabelText() {
+		StringValueStyle style = getFeatureToShowStyle();
+		if (style != null
+				&& style.getStringValue().equals(
+						BasePackage.Literals.DOCUMENTED_ELEMENT__DOCUMENTATION
+								.getName())) {
+			getFigure().setText(resolveSemanticElement().getDocumentation());
+		} else
+			super.updateLabelText();
+	}
+
+	private StringValueStyle getFeatureToShowStyle() {
+		StringValueStyle style = (StringValueStyle) getParentStateView()
+				.getNamedStyle(NotationPackage.Literals.STRING_VALUE_STYLE,
+						ToggleShowDocumentationCommand.FEATURE_TO_SHOW);
+		return style;
+	}
+
+	@Override
+	protected void handleNotificationEvent(Notification notification) {
+		if (notification.getFeature() == NotationPackage.Literals.STRING_VALUE_STYLE__STRING_VALUE) {
+			refreshVisuals();
+		}
+		super.handleNotificationEvent(notification);
+	}
 }

+ 54 - 2
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editparts/StatechartTextExpressionEditPart.java

@@ -10,11 +10,18 @@
  */
 package org.yakindu.sct.ui.editor.editparts;
 
+import org.eclipse.draw2d.Label;
+import org.eclipse.emf.common.notify.Notification;
 import org.eclipse.gef.EditPolicy;
 import org.eclipse.gef.editpolicies.RootComponentEditPolicy;
 import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.StringValueStyle;
 import org.eclipse.gmf.runtime.notation.View;
 import org.eclipse.swt.SWT;
+import org.yakindu.base.base.BasePackage;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.ui.editor.commands.ToggleShowDocumentationCommand;
 import org.yakindu.sct.ui.editor.extensions.ExpressionLanguageProviderExtensions.SemanticTarget;
 import org.yakindu.sct.ui.editor.policies.ContextSensitiveHelpPolicy;
 import org.yakindu.sct.ui.editor.utils.HelpContextIds;
@@ -56,8 +63,7 @@ public class StatechartTextExpressionEditPart extends
 		installEditPolicy(EditPolicy.COMPONENT_ROLE,
 				new RootComponentEditPolicy());
 		removeEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
-		installEditPolicy(
-				EditPolicy.SELECTION_FEEDBACK_ROLE,
+		installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE,
 				new ContextSensitiveHelpPolicy(
 						HelpContextIds.SC_PROPERTIES_STATECHART_EXPRESSION));
 		removeEditPolicy(EditPolicyRoles.CONNECTION_HANDLES_ROLE);
@@ -75,4 +81,50 @@ public class StatechartTextExpressionEditPart extends
 		return SWT.MULTI | SWT.V_SCROLL;
 	}
 
+	@Override
+	public Statechart resolveSemanticElement() {
+		return (Statechart) super.resolveSemanticElement();
+	}
+
+	@Override
+	protected void updateTooltipText() {
+		StringValueStyle style = getFeatureToShowStyle();
+		if (style != null
+				&& style.getStringValue().equals(
+						BasePackage.Literals.DOCUMENTED_ELEMENT__DOCUMENTATION
+								.getName())) {
+			Label tooltip = new Label((String) resolveSemanticElement()
+					.getSpecification());
+			getFigure().setToolTip(tooltip);
+		} else
+			super.updateTooltipText();
+	}
+
+	@Override
+	protected void updateLabelText() {
+		StringValueStyle style = getFeatureToShowStyle();
+		if (style != null
+				&& style.getStringValue().equals(
+						BasePackage.Literals.DOCUMENTED_ELEMENT__DOCUMENTATION
+								.getName())) {
+			getFigure().setText(resolveSemanticElement().getDocumentation());
+		} else
+			super.updateLabelText();
+	}
+
+	private StringValueStyle getFeatureToShowStyle() {
+		StringValueStyle style = (StringValueStyle) getParentStateView()
+				.getNamedStyle(NotationPackage.Literals.STRING_VALUE_STYLE,
+						ToggleShowDocumentationCommand.FEATURE_TO_SHOW);
+		return style;
+	}
+
+	@Override
+	protected void handleNotificationEvent(Notification notification) {
+		if (notification.getFeature() == NotationPackage.Literals.STRING_VALUE_STYLE__STRING_VALUE) {
+			refreshVisuals();
+		}
+		super.handleNotificationEvent(notification);
+	}
+
 }

+ 75 - 1
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/editparts/TransitionExpressionEditPart.java

@@ -1,5 +1,5 @@
 /**
-* Copyright (c) 2011 committers of YAKINDU and others.
+ * Copyright (c) 2011 committers of YAKINDU and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -10,9 +10,16 @@
  */
 package org.yakindu.sct.ui.editor.editparts;
 
+import org.eclipse.draw2d.Label;
+import org.eclipse.emf.common.notify.Notification;
 import org.eclipse.gef.EditPolicy;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.StringValueStyle;
 import org.eclipse.gmf.runtime.notation.View;
 import org.eclipse.swt.SWT;
+import org.yakindu.base.base.BasePackage;
+import org.yakindu.sct.model.sgraph.Transition;
+import org.yakindu.sct.ui.editor.commands.ToggleShowDocumentationCommand;
 import org.yakindu.sct.ui.editor.extensions.ExpressionLanguageProviderExtensions.SemanticTarget;
 import org.yakindu.sct.ui.editor.policies.ContextSensitiveHelpPolicy;
 import org.yakindu.sct.ui.editor.policies.TransitionExpressionComponentEditPolicy;
@@ -32,6 +39,24 @@ public class TransitionExpressionEditPart extends
 		super(view, SemanticTarget.TransitionSpecification);
 	}
 
+	@Override
+	protected void addNotationalListeners() {
+		super.addNotationalListeners();
+		View parentStateView = getParentView();
+		if (parentStateView != null) {
+			addListenerFilter("parentView", this, parentStateView);
+		}
+	}
+
+	@Override
+	protected void removeNotationalListeners() {
+		View parentStateView = getParentView();
+		if (parentStateView != null) {
+			removeListenerFilter("parentView");
+		}
+		super.removeNotationalListeners();
+	}
+
 	@Override
 	protected void createDefaultEditPolicies() {
 		super.createDefaultEditPolicies();
@@ -47,4 +72,53 @@ public class TransitionExpressionEditPart extends
 		return SWT.MULTI;
 	}
 
+	@Override
+	public Transition resolveSemanticElement() {
+		return (Transition) super.resolveSemanticElement();
+	}
+
+	private View getParentView() {
+		return ((TransitionEditPart) getParent()).getNotationView();
+	}
+
+	@Override
+	protected void updateTooltipText() {
+		StringValueStyle style = getFeatureToShowStyle();
+		if (style != null
+				&& style.getStringValue().equals(
+						BasePackage.Literals.DOCUMENTED_ELEMENT__DOCUMENTATION
+								.getName())) {
+			Label tooltip = new Label((String) resolveSemanticElement()
+					.getSpecification());
+			getFigure().setToolTip(tooltip);
+		} else
+			super.updateTooltipText();
+	}
+
+	@Override
+	protected void updateLabelText() {
+		StringValueStyle style = getFeatureToShowStyle();
+		if (style != null
+				&& style.getStringValue().equals(
+						BasePackage.Literals.DOCUMENTED_ELEMENT__DOCUMENTATION
+								.getName())) {
+			getFigure().setText(resolveSemanticElement().getDocumentation());
+		} else
+			super.updateLabelText();
+	}
+
+	private StringValueStyle getFeatureToShowStyle() {
+		StringValueStyle style = (StringValueStyle) getParentView()
+				.getNamedStyle(NotationPackage.Literals.STRING_VALUE_STYLE,
+						ToggleShowDocumentationCommand.FEATURE_TO_SHOW);
+		return style;
+	}
+
+	@Override
+	protected void handleNotificationEvent(Notification notification) {
+		if (notification.getFeature() == NotationPackage.Literals.STRING_VALUE_STYLE__STRING_VALUE) {
+			refreshVisuals();
+		}
+		super.handleNotificationEvent(notification);
+	}
 }

+ 1 - 1
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/propertysheets/AbstractTwoColumnEditorPropertySection.java

@@ -40,7 +40,7 @@ public abstract class AbstractTwoColumnEditorPropertySection extends
 		leftColumn.setLayout(createLeftColumnLayout());
 		Composite rightColumn = getToolkit().createComposite(sashForm);
 		rightColumn.setLayout(createRightColumnLayout());
-		sashForm.setWeights(new int[] { 2, 3 });
+		sashForm.setWeights(new int[] { 1, 1 });
 		createLeftColumnControls(leftColumn);
 		createRightColumnControls(rightColumn);
 	}

+ 35 - 12
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/propertysheets/StatePropertySection.java

@@ -40,6 +40,7 @@ import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Layout;
 import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Text;
 import org.eclipse.xtext.naming.QualifiedName;
 import org.yakindu.base.base.BasePackage;
 import org.yakindu.sct.model.sgraph.SGraphPackage;
@@ -62,6 +63,7 @@ public class StatePropertySection extends
 	private Label lblSubmachine;
 	private Control txtSpecification;
 	private Control txtName;
+	private Text txtDoc;
 
 	private UpdateLabelAdapter updateLabelAdapter = new UpdateLabelAdapter();
 	private OrderElementControl orderElementControl;
@@ -73,24 +75,34 @@ public class StatePropertySection extends
 
 	@Override
 	protected void createLeftColumnControls(Composite leftColumn) {
+		createNameControl(leftColumn);
 		createSpecificationControl(leftColumn);
 	}
 
 	@Override
 	protected void createRightColumnControls(Composite rightColumn) {
-		createNameControl(rightColumn);
-		createSubmachineControl(rightColumn);
+		createDocumentationControl(rightColumn);
 		createTransitionsControl(rightColumn);
+		createSubmachineControl(rightColumn);
 	}
 
-	private void createNameControl(final Composite parent) {
+	protected void createNameControl(final Composite parent) {
 		Label lblName = getToolkit().createLabel(parent, "State Name: ");
 		txtName = getToolkit().createText(parent, "");
-		GridDataFactory.fillDefaults().applyTo(lblName);
-		GridDataFactory.fillDefaults().applyTo(txtName);
+		GridDataFactory.fillDefaults().span(2, 1).applyTo(lblName);
+		new Label(parent, SWT.NONE);
+		GridDataFactory.fillDefaults().grab(true, false).applyTo(txtName);
+	}
+
+	protected void createDocumentationControl(Composite rightColumn) {
+		Label lblDocumentation = getToolkit().createLabel(rightColumn,
+				"Documentation: ");
+		txtDoc = getToolkit().createText(rightColumn, "", SWT.MULTI);
+		GridDataFactory.fillDefaults().applyTo(lblDocumentation);
+		GridDataFactory.fillDefaults().grab(true, true).applyTo(txtDoc);
 	}
 
-	private void createSpecificationControl(final Composite parent) {
+	protected void createSpecificationControl(final Composite parent) {
 		Injector injector = getInjector(SemanticTarget.StateSpecification);
 		if (injector != null) {
 			txtSpecification = new StyledText(parent, SWT.MULTI | SWT.BORDER
@@ -106,7 +118,7 @@ public class StatePropertySection extends
 				.applyTo(txtSpecification);
 	}
 
-	private void createSubmachineControl(final Composite parent) {
+	protected void createSubmachineControl(final Composite parent) {
 		Label label = getToolkit().createLabel(parent, "State Submachine:");
 		Composite composite = new Composite(parent, SWT.NONE);
 		composite.setBackground(ColorConstants.white);
@@ -125,7 +137,7 @@ public class StatePropertySection extends
 				.applyTo(openDialog);
 	}
 
-	private void createTransitionsControl(Composite parent) {
+	protected void createTransitionsControl(Composite parent) {
 		Label label = getToolkit().createLabel(parent, "Transition Priority:");
 		GridDataFactory.fillDefaults().applyTo(label);
 		orderElementControl = new OrderElementControl(parent,
@@ -142,11 +154,22 @@ public class StatePropertySection extends
 	public void bindModel(EMFDataBindingContext context) {
 		bindNameControl(context);
 		bindSpecificationControl(context);
+		bindDocumentationControl(context);
 		orderElementControl.refreshInput();
 		updateLabel();
 	}
 
-	private void bindSpecificationControl(EMFDataBindingContext context) {
+	private void bindDocumentationControl(EMFDataBindingContext context) {
+		IEMFValueProperty property = EMFEditProperties.value(
+				TransactionUtil.getEditingDomain(eObject),
+				BasePackage.Literals.DOCUMENTED_ELEMENT__DOCUMENTATION);
+		ISWTObservableValue observe = WidgetProperties.text(
+				new int[] { SWT.FocusOut, SWT.DefaultSelection }).observe(
+				txtDoc);
+		context.bindValue(observe, property.observe(eObject));
+	}
+
+	protected void bindSpecificationControl(EMFDataBindingContext context) {
 		IEMFValueProperty specificationProperty = EMFEditProperties.value(
 				TransactionUtil.getEditingDomain(eObject),
 				SGraphPackage.Literals.SPECIFICATION_ELEMENT__SPECIFICATION);
@@ -166,7 +189,7 @@ public class StatePropertySection extends
 				});
 	}
 
-	private void bindNameControl(EMFDataBindingContext context) {
+	protected void bindNameControl(EMFDataBindingContext context) {
 		IEMFValueProperty nameProperty = EMFEditProperties.value(
 				TransactionUtil.getEditingDomain(eObject),
 				BasePackage.Literals.NAMED_ELEMENT__NAME);
@@ -206,7 +229,7 @@ public class StatePropertySection extends
 		return super.getEObject();
 	}
 
-	private final class OpenDialogHandler implements Listener {
+	protected final class OpenDialogHandler implements Listener {
 		private final Composite parent;
 
 		private OpenDialogHandler(Composite parent) {
@@ -238,7 +261,7 @@ public class StatePropertySection extends
 		}
 	}
 
-	private final class UpdateLabelAdapter extends AdapterImpl {
+	protected final class UpdateLabelAdapter extends AdapterImpl {
 		@Override
 		public void notifyChanged(Notification msg) {
 			if (msg.getFeature() == SGraphPackage.Literals.STATE__SUBSTATECHART_ID) {

+ 32 - 8
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/propertysheets/StatechartPropertySection.java

@@ -49,6 +49,7 @@ public class StatechartPropertySection extends
 	private Control textControl;
 	private Text txtName;
 	private OrderElementControl orderElementControl;
+	private Text documentation;
 
 	@Override
 	protected Layout createLeftColumnLayout() {
@@ -57,24 +58,26 @@ public class StatechartPropertySection extends
 
 	@Override
 	protected void createLeftColumnControls(Composite leftColumn) {
+		createNameControl(leftColumn);
 		createSpecificationControl(leftColumn);
 	}
 
 	@Override
 	protected void createRightColumnControls(Composite rightColumn) {
-		createNameControl(rightColumn);
+		createDocumentationControl(rightColumn);
 		createRegionsControl(rightColumn);
 
 	}
 
-	private void createNameControl(Composite parent) {
+	protected void createNameControl(Composite parent) {
 		Label lblName = getToolkit().createLabel(parent, "Statechart Name: ");
 		txtName = getToolkit().createText(parent, "");
-		GridDataFactory.fillDefaults().applyTo(txtName);
-		GridDataFactory.fillDefaults().applyTo(lblName);
+		GridDataFactory.fillDefaults().span(2,1).applyTo(lblName);
+		new Label(parent, SWT.NONE);
+		GridDataFactory.fillDefaults().grab(true, false).applyTo(txtName);
 	}
 
-	private void createRegionsControl(Composite rightColumn) {
+	protected void createRegionsControl(Composite rightColumn) {
 		Label label = getToolkit().createLabel(rightColumn, "Region Priority:");
 		GridDataFactory.fillDefaults().applyTo(label);
 		orderElementControl = new OrderElementControl(rightColumn,
@@ -83,7 +86,17 @@ public class StatechartPropertySection extends
 				.applyTo(orderElementControl);
 	}
 
-	private void createSpecificationControl(final Composite parent) {
+	protected void createDocumentationControl(Composite rightColumn) {
+		Label lblDocumentation = getToolkit().createLabel(rightColumn,
+				"Documentation: ");
+		documentation = getToolkit().createText(rightColumn, "", SWT.MULTI);
+		GridDataFactory.fillDefaults().applyTo(lblDocumentation);
+		GridDataFactory.fillDefaults().grab(true, true).applyTo(documentation);
+
+	}
+
+	protected void createSpecificationControl(final Composite parent) {
+		
 		Injector injector = getInjector(SemanticTarget.StatechartSpecification);
 		if (injector != null) {
 			textControl = new StyledText(parent, SWT.MULTI | SWT.BORDER
@@ -103,10 +116,21 @@ public class StatechartPropertySection extends
 	public void bindModel(EMFDataBindingContext context) {
 		bindNameControl(context);
 		bindSpecificationControl(context);
+		bindDocumentationControl(context);
 		orderElementControl.refreshInput();
 	}
 
-	private void bindSpecificationControl(EMFDataBindingContext context) {
+	private void bindDocumentationControl(EMFDataBindingContext context) {
+		IEMFValueProperty property = EMFEditProperties.value(
+				TransactionUtil.getEditingDomain(eObject),
+				BasePackage.Literals.DOCUMENTED_ELEMENT__DOCUMENTATION);
+		ISWTObservableValue observe = WidgetProperties.text(
+				new int[] { SWT.FocusOut, SWT.DefaultSelection }).observe(
+				documentation);
+		context.bindValue(observe, property.observe(eObject));
+	}
+
+	protected void bindSpecificationControl(EMFDataBindingContext context) {
 		IEMFValueProperty modelProperty = EMFEditProperties.value(
 				TransactionUtil.getEditingDomain(eObject),
 				SGraphPackage.Literals.SPECIFICATION_ELEMENT__SPECIFICATION);
@@ -126,7 +150,7 @@ public class StatechartPropertySection extends
 
 	}
 
-	private void bindNameControl(EMFDataBindingContext context) {
+	protected void bindNameControl(EMFDataBindingContext context) {
 		IEMFValueProperty property = EMFEditProperties.value(
 				TransactionUtil.getEditingDomain(eObject),
 				BasePackage.Literals.NAMED_ELEMENT__NAME);

+ 19 - 0
plugins/org.yakindu.sct.ui.editor/src/org/yakindu/sct/ui/editor/propertysheets/TransitionPropertySection.java

@@ -26,7 +26,10 @@ import org.eclipse.swt.custom.StyledText;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Layout;
+import org.eclipse.swt.widgets.Text;
+import org.yakindu.base.base.BasePackage;
 import org.yakindu.sct.model.sgraph.SGraphPackage;
 import org.yakindu.sct.ui.editor.extensions.ExpressionLanguageProviderExtensions.SemanticTarget;
 import org.yakindu.sct.ui.editor.utils.HelpContextIds;
@@ -41,6 +44,7 @@ import com.google.inject.Injector;
 public class TransitionPropertySection extends AbstractEditorPropertySection {
 
 	private Control textControl;
+	private Text txtDoc;
 
 	@Override
 	protected Layout createBodyLayout() {
@@ -63,6 +67,12 @@ public class TransitionPropertySection extends AbstractEditorPropertySection {
 		GridDataFactory.fillDefaults().grab(true, true).hint(parent.getSize())
 				.applyTo(textControl);
 
+		Label lblDocumentation = getToolkit().createLabel(parent,
+				"Documentation: ");
+		txtDoc = getToolkit().createText(parent, "", SWT.MULTI);
+		GridDataFactory.fillDefaults().span(2,1).applyTo(lblDocumentation);
+		GridDataFactory.fillDefaults().grab(true,true).applyTo(txtDoc);
+
 	}
 
 	@Override
@@ -83,6 +93,15 @@ public class TransitionPropertySection extends AbstractEditorPropertySection {
 						return Status.OK_STATUS;
 					}
 				});
+
+		IEMFValueProperty property = EMFEditProperties.value(
+				TransactionUtil.getEditingDomain(eObject),
+				BasePackage.Literals.DOCUMENTED_ELEMENT__DOCUMENTATION);
+		ISWTObservableValue observe = WidgetProperties.text(
+				new int[] { SWT.FocusOut, SWT.DefaultSelection }).observe(
+				txtDoc);
+		context.bindValue(observe, property.observe(eObject));
+
 	}
 
 }