use of org.eclipse.gmf.runtime.notation.Node in project tdi-studio-se by Talend.
the class BidirectionalBusinessItemRelationshipNameViewFactory method createView.
/**
* @generated
*/
public View createView(IAdaptable semanticAdapter, View containerView, String semanticHint, int index, boolean persisted, PreferencesHint preferencesHint) {
Node view = (Node) super.createView(semanticAdapter, containerView, semanticHint, index, persisted, preferencesHint);
Location location = (Location) view.getLayoutConstraint();
IMapMode mapMode = MeasurementUnitHelper.getMapMode(containerView.getDiagram().getMeasurementUnit());
location.setX(mapMode.DPtoLP(0));
location.setY(mapMode.DPtoLP(40));
return view;
}
use of org.eclipse.gmf.runtime.notation.Node in project statecharts by Yakindu.
the class FactoryUtils method createStatechartModel.
/**
* Creates a Statechart with an initial Region and an initial State
*
* @return instanceof {@link Statechart}
*/
public static void createStatechartModel(Resource resource, PreferencesHint preferencesHint) {
// Create a statechart
Statechart statechart = SGraphFactory.eINSTANCE.createStatechart();
String lastSegment = resource.getURI().lastSegment();
String statechartName = lastSegment.substring(0, lastSegment.indexOf('.'));
statechart.setName(statechartName);
statechart.setSpecification(INITIAL_SPECIFICATION);
Diagram diagram = ViewService.createDiagram(statechart, StatechartDiagramEditor.ID, preferencesHint);
diagram.setElement(statechart);
// Add to resource
resource.getContents().add(statechart);
resource.getContents().add(diagram);
// Create an initial region
Region region = SGraphFactory.eINSTANCE.createRegion();
region.setName(INITIAL_REGION_NAME);
statechart.getRegions().add(region);
Node regionView = ViewService.createNode(diagram, region, SemanticHints.REGION, preferencesHint);
setRegionViewLayoutConstraint(regionView);
// // Create an initial state
Entry initialState = SGraphFactory.eINSTANCE.createEntry();
initialState.setKind(EntryKind.INITIAL);
region.getVertices().add(initialState);
Node initialStateView = ViewService.createNode(getRegionCompartmentView(regionView), initialState, SemanticHints.ENTRY, preferencesHint);
setInitialStateViewLayoutConstraint(initialStateView);
// Create the first state
State state = SGraphFactory.eINSTANCE.createState();
state.setName("StateA");
region.getVertices().add(state);
Node stateNode = ViewService.createNode(getRegionCompartmentView(regionView), state, SemanticHints.STATE, preferencesHint);
setStateViewLayoutConstraint(stateNode);
// Create the transition from Initial State to State
Transition transition = SGraphFactory.eINSTANCE.createTransition();
transition.setSource(initialState);
transition.setTarget(state);
initialState.getOutgoingTransitions().add(transition);
ViewService.createEdge(initialStateView, stateNode, transition, SemanticHints.TRANSITION, preferencesHint);
// Create the textcompartment for events / variables
Node textCompartment = ViewService.createNode(diagram, statechart, SemanticHints.STATECHART_TEXT, preferencesHint);
setTextCompartmentLayoutConstraint(textCompartment);
}
use of org.eclipse.gmf.runtime.notation.Node in project statecharts by Yakindu.
the class TransitionViewFactory method decorateView.
@SuppressWarnings("unchecked")
@Override
protected void decorateView(View containerView, View view, IAdaptable element, String semanticHint, int index, boolean persisted) {
FontStyle fontStyle = NotationFactory.eINSTANCE.createFontStyle();
view.getStyles().add(fontStyle);
super.decorateView(containerView, view, element, semanticHint, index, persisted);
Node label = FactoryUtils.createLabel(view, SemanticHints.TRANSITION_EXPRESSION);
Location location = (Location) label.getLayoutConstraint();
location.setX(0);
location.setY(10);
}
use of org.eclipse.gmf.runtime.notation.Node in project statecharts by Yakindu.
the class StateTemplatesModification method execute.
@SuppressWarnings("unchecked")
@Override
protected void execute(EObject semanticObject, View view) {
State state = (State) semanticObject;
Resource resource = loadTemplateResource(getTemplatePath());
Diagram diagram = (Diagram) getObjectByType(resource.getContents(), NotationPackage.Literals.DIAGRAM);
EList<View> children = diagram.getChildren();
List<Node> regions = new ArrayList<Node>();
for (View child : children) {
if (child.getType().equals(SemanticHints.REGION)) {
regions.add((Node) child);
}
}
View figureCompartment = ViewUtil.getChildBySemanticHint(view, SemanticHints.STATE_FIGURE_COMPARTMENT);
while (regions.size() > 0) {
Node child = regions.get(0);
regions.remove(child);
setPreferredSize(child);
figureCompartment.insertChild(child);
state.getRegions().add((Region) child.getElement());
}
EList<Edge> edges = diagram.getEdges();
while (edges.size() > 0) {
view.getDiagram().insertEdge(edges.get(0));
}
setPreferredSize(view);
}
use of org.eclipse.gmf.runtime.notation.Node in project InformationSystem by ObeoNetwork.
the class EditPolicyProvider method provides.
public boolean provides(IOperation operation) {
if (operation instanceof CreateEditPoliciesOperation) {
EditPart editPart = ((CreateEditPoliciesOperation) operation).getEditPart();
Object model = editPart.getModel();
if (model instanceof Node) {
Node node = (Node) model;
// check DNode, DNodeContainer
if (node.getElement() instanceof DDiagramElement) {
DDiagramElement dElement = (DDiagramElement) node.getElement();
EObject target = dElement.getTarget();
// if(target instanceof NamedElement){
if (target instanceof EObject) {
return true;
}
}
}
;
}
return false;
}
Aggregations