Java Code Examples for org.eclipse.gmf.runtime.diagram.core.util.ViewUtil#getChildBySemanticHint()
The following examples show how to use
org.eclipse.gmf.runtime.diagram.core.util.ViewUtil#getChildBySemanticHint() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExtractSubdiagramRefactoring.java From statecharts with Eclipse Public License 1.0 | 6 votes |
protected void createEntryPoint(Edge edge, Diagram subdiagram) { Transition transition = (Transition) edge.getElement(); Region entryPointContainer = getEntryPointContainer(transition); Entry entryPoint = createSemanticEntryPoint(transition); // re-wire old transition to targeting the selected state transition.setTarget((State) subdiagram.getElement()); View oldTarget = edge.getTarget(); edge.setTarget(getContextObject()); // create node for entry point View entryPointContainerView = helper.getViewForSemanticElement(entryPointContainer, subdiagram); View entryPointRegionCompartment = ViewUtil.getChildBySemanticHint(entryPointContainerView, SemanticHints.REGION_COMPARTMENT); Node entryNode = ViewService.createNode(entryPointRegionCompartment, entryPoint, SemanticHints.ENTRY, preferencesHint); ViewService.createEdge(entryNode, oldTarget, entryPoint.getOutgoingTransitions().get(0), SemanticHints.TRANSITION, preferencesHint); addEntryPointSpec(transition, entryPoint); }
Example 2
Source File: InlineSubdiagramRefactoring.java From statecharts with Eclipse Public License 1.0 | 6 votes |
@SuppressWarnings("unchecked") @Override protected void internalExecute() { BooleanValueStyle inlineStyle = getInlineStyle(getContextObject()); if (inlineStyle == null) { inlineStyle = createInlineStyle(); getContextObject().getStyles().add(inlineStyle); } inlineStyle.setBooleanValue(true); View contextView = getContextObject(); State contextElement = (State) contextView.getElement(); Diagram diagramToInline = DiagramPartitioningUtil.getSubDiagram(contextElement); View containerView = ViewUtil.getChildBySemanticHint(contextView, SemanticHints.STATE_FIGURE_COMPARTMENT); while (diagramToInline.getChildren().size() > 0) { containerView.insertChild((View) diagramToInline.getChildren().get(0)); } while (diagramToInline.getEdges().size() > 0) { containerView.getDiagram().insertEdge((Edge) diagramToInline.getEdges().get(0)); } getResource().getContents().remove(diagramToInline); }
Example 3
Source File: ExtractSubdiagramRefactoring.java From statecharts with Eclipse Public License 1.0 | 5 votes |
protected void createExitPoint(Edge edge, Diagram subdiagram) { Transition transition = (Transition) edge.getElement(); // create semantic exit point Region exitPointContainer = getExitPointContainer(transition); Exit exitPoint = createSemanticExitPoint(transition); // create node for exit point View exitPointContainerView = helper.getViewForSemanticElement(exitPointContainer, subdiagram); View exitPointRegionCompartment = ViewUtil.getChildBySemanticHint(exitPointContainerView, SemanticHints.REGION_COMPARTMENT); Node exitNode = ViewService.createNode(exitPointRegionCompartment, exitPoint, SemanticHints.EXIT, preferencesHint); // re-wire existing transition to new exit point Vertex oldTransitionTarget = transition.getTarget(); transition.setTarget(exitPoint); View oldEdgeTarget = edge.getTarget(); edge.setTarget(exitNode); // create transition from selected state to former transition target Transition exitPointTransition = SGraphFactory.eINSTANCE.createTransition(); exitPointTransition.setSource((State) subdiagram.getElement()); exitPointTransition.setTarget(oldTransitionTarget); ViewService.createEdge(getContextObject(), oldEdgeTarget, exitPointTransition, SemanticHints.TRANSITION, preferencesHint); addExitPointSpec(exitPointTransition, exitPoint); }
Example 4
Source File: GroupStatesIntoCompositeRefactoring.java From statecharts with Eclipse Public License 1.0 | 5 votes |
protected void doGraphicalRefactoring() { Node compositeStateView = createNodeForCompositeState(compositeState); Node innerRegionNode = ViewService.createNode( getStateFigureCompartmentView(compositeStateView), innerRegion, SemanticHints.REGION, preferencesHint); View regionCompartment = ViewUtil.getChildBySemanticHint(innerRegionNode, SemanticHints.REGION_COMPARTMENT); moveSelectedStateNodesTo(regionCompartment, (Bounds)compositeStateView.getLayoutConstraint()); }
Example 5
Source File: StateEditPart.java From statecharts with Eclipse Public License 1.0 | 4 votes |
private Compartment getTextCompartment() { return (Compartment) ViewUtil.getChildBySemanticHint(getNotationView(), SemanticHints.STATE_TEXT_COMPARTMENT); }
Example 6
Source File: ExtractSubdiagramRefactoring.java From statecharts with Eclipse Public License 1.0 | 4 votes |
/** * Creates a new {@link Diagram} and copies child elements */ protected Diagram createSubdiagram() { View contextView = getContextObject(); State contextElement = (State) contextView.getElement(); Diagram subdiagram = ViewService.createDiagram(contextElement, StatechartDiagramEditor.ID, preferencesHint); View figureCompartment = ViewUtil.getChildBySemanticHint(contextView, SemanticHints.STATE_FIGURE_COMPARTMENT); getResource().getContents().add(subdiagram); boolean isHorizontal = isHorizontal(figureCompartment); int offset = 0; int subregions = figureCompartment.getChildren().size(); while (figureCompartment.getChildren().size() > 0) { Node child = (Node) figureCompartment.getChildren().get(0); if (subregions > 1) { Rectangle actualBounds = getActualBounds(child); if (actualBounds != Rectangle.SINGLETON) { Bounds modelBounds = (Bounds) child.getLayoutConstraint(); modelBounds.setWidth(actualBounds.width()); modelBounds.setHeight(actualBounds.height()); if (isHorizontal) { modelBounds.setX(offset); offset += actualBounds.width(); } else { modelBounds.setY(offset); offset += actualBounds.height(); } } } subdiagram.insertChild(child); } @SuppressWarnings("unchecked") List<Edge> edges = figureCompartment.getDiagram().getEdges(); List<Edge> moveEdges = edges.stream().filter( (edge) -> edge.getSource().getDiagram() == subdiagram && edge.getTarget().getDiagram() == subdiagram) .collect(Collectors.toList()); for (Edge edge2 : moveEdges) { subdiagram.insertEdge(edge2); } return subdiagram; }
Example 7
Source File: GroupStatesIntoCompositeRefactoring.java From statecharts with Eclipse Public License 1.0 | 4 votes |
protected View getStateFigureCompartmentView(Node compositeStateView) { return ViewUtil.getChildBySemanticHint(compositeStateView, SemanticHints.STATE_FIGURE_COMPARTMENT); }