Search in sources :

Example 6 with Node

use of org.eclipse.gmf.runtime.notation.Node in project statecharts by Yakindu.

the class CreateSubdiagramCommand method isEnabled.

@Override
public boolean isEnabled() {
    IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (activeWorkbenchWindow == null)
        return false;
    ISelection selection = activeWorkbenchWindow.getActivePage().getSelection();
    if (selection == null)
        return false;
    Node unwrap = unwrap(selection);
    if (unwrap == null) {
        return false;
    }
    State state = (State) unwrap.getElement();
    if (state == null || state.isComposite())
        return false;
    BooleanValueStyle inlineStyle = DiagramPartitioningUtil.getInlineStyle(unwrap);
    if (inlineStyle != null && !inlineStyle.isBooleanValue())
        return false;
    return super.isEnabled();
}
Also used : BooleanValueStyle(org.eclipse.gmf.runtime.notation.BooleanValueStyle) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) State(org.yakindu.sct.model.sgraph.State) Node(org.eclipse.gmf.runtime.notation.Node) ISelection(org.eclipse.jface.viewers.ISelection)

Example 7 with Node

use of org.eclipse.gmf.runtime.notation.Node in project statecharts by Yakindu.

the class StatechartTextFactory method decorateView.

@Override
protected void decorateView(View containerView, View view, IAdaptable semanticAdapter, String semanticHint, int index, boolean persisted) {
    super.decorateView(containerView, view, semanticAdapter, semanticHint, index, persisted);
    IAdaptable eObjectAdapter = null;
    EObject eObject = (EObject) semanticAdapter.getAdapter(EObject.class);
    if (eObject != null) {
        eObjectAdapter = new EObjectAdapter(eObject);
    }
    // Create the statechart name label
    FactoryUtils.createLabel(view, STATECHART_NAME);
    // create the expressions compartment
    Node textCompartment = getViewService().createNode(eObjectAdapter, view, STATECHART_TEXT_EXPRESSION, ViewUtil.APPEND, true, getPreferencesHint());
    Assert.isNotNull(textCompartment);
    ShapeStyle style = (ShapeStyle) view.getStyle(NotationPackage.eINSTANCE.getShapeStyle());
    style.setFillColor(FigureUtilities.RGBToInteger(ColorConstants.white.getRGB()));
}
Also used : IAdaptable(org.eclipse.core.runtime.IAdaptable) EObject(org.eclipse.emf.ecore.EObject) Node(org.eclipse.gmf.runtime.notation.Node) ShapeStyle(org.eclipse.gmf.runtime.notation.ShapeStyle) EObjectAdapter(org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter)

Example 8 with Node

use of org.eclipse.gmf.runtime.notation.Node in project statecharts by Yakindu.

the class GroupStatesIntoCompositeRefactoring method doGraphicalRefactoring.

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());
}
Also used : Node(org.eclipse.gmf.runtime.notation.Node) View(org.eclipse.gmf.runtime.notation.View)

Example 9 with Node

use of org.eclipse.gmf.runtime.notation.Node in project statecharts by Yakindu.

the class GroupStatesIntoCompositeRefactoring method moveSelectedStateNodesTo.

protected void moveSelectedStateNodesTo(View containerView, Bounds compositeBounds) {
    for (GraphicalEditPart editPart : getContextObjects()) {
        Node stateNode = (Node) editPart.getNotationView();
        ViewUtil.insertChildView(containerView, stateNode, ViewUtil.APPEND, true);
        Bounds newBounds = NotationFactory.eINSTANCE.createBounds();
        Bounds oldBounds = (Bounds) stateNode.getLayoutConstraint();
        // FIXME use bounds of region view
        newBounds.setX(oldBounds.getX() - compositeBounds.getX() - 7);
        // FIXME use bounds of region view
        newBounds.setY(oldBounds.getY() - compositeBounds.getY() - 34);
        ((Node) editPart.getNotationView()).setLayoutConstraint(newBounds);
    }
}
Also used : Node(org.eclipse.gmf.runtime.notation.Node) Bounds(org.eclipse.gmf.runtime.notation.Bounds) GraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)

Example 10 with Node

use of org.eclipse.gmf.runtime.notation.Node in project tdi-studio-se by Talend.

the class BusinessItemShapeEditPart method refreshVisuals.

@Override
public void refreshVisuals() {
    super.refreshVisuals();
    NodeFigure nodeFigure = getNodeFigure();
    for (Object obj : nodeFigure.getChildren()) {
        if (obj instanceof BusinessItemShapeFigure) {
            BusinessItemShapeFigure shapFigure = (BusinessItemShapeFigure) obj;
            for (Object figure : shapFigure.getChildren()) {
                if (figure instanceof BusinessItemNameFigure) {
                    BusinessItemNameFigure nameFigure = (BusinessItemNameFigure) figure;
                    nameFigure.addMouseMotionListener(new MouseMotionListener() {

                        @Override
                        public void mouseMoved(MouseEvent me) {
                        // TODO Auto-generated method stub
                        }

                        @Override
                        public void mouseHover(MouseEvent me) {
                        // TODO Auto-generated method stub
                        }

                        @Override
                        public void mouseExited(MouseEvent me) {
                        // TODO Auto-generated method stub
                        }

                        @Override
                        public void mouseEntered(MouseEvent me) {
                            elementHelper.updateTooltipFigure(getNodeFigure(), tooltipFigure, editPart);
                        }

                        @Override
                        public void mouseDragged(MouseEvent me) {
                        // TODO Auto-generated method stub
                        }
                    });
                    EObject object = ((Node) getModel()).getElement();
                    if (object instanceof BusinessItem) {
                        BusinessItem item = (BusinessItem) object;
                        String hAlignment = item.getHAlignment();
                        if (hAlignment == null) {
                            hAlignment = BusinessAlignment.LEFT.toString();
                        }
                        String vAlignment = item.getVAlignment();
                        if (vAlignment == null) {
                            vAlignment = BusinessAlignment.TOP.toString();
                        }
                        if (BusinessAlignment.HCENTRE.toString().equals(hAlignment)) {
                            if (BusinessAlignment.TOP.toString().equals(vAlignment)) {
                                nameFigure.setAlignment(PositionConstants.TOP);
                            } else if (BusinessAlignment.BOTTOM.toString().equals(vAlignment)) {
                                nameFigure.setAlignment(PositionConstants.BOTTOM);
                            } else {
                                nameFigure.setAlignment(PositionConstants.CENTER);
                            }
                        } else if (BusinessAlignment.VCENTRE.toString().equals(vAlignment)) {
                            if (BusinessAlignment.LEFT.toString().equals(hAlignment)) {
                                nameFigure.setAlignment(PositionConstants.LEFT);
                            } else if (BusinessAlignment.RIGHT.toString().equals(hAlignment)) {
                                nameFigure.setAlignment(PositionConstants.RIGHT);
                            } else {
                                nameFigure.setAlignment(PositionConstants.CENTER);
                            }
                        } else {
                            nameFigure.setAlignment(getPosition(hAlignment, BusinessAlignment.HORIZONTAL, item) | getPosition(vAlignment, BusinessAlignment.VERTICAL, item));
                        }
                    }
                }
            }
        }
    }
    elementHelper.updateTooltipFigure(getNodeFigure(), tooltipFigure, this);
}
Also used : MouseEvent(org.eclipse.draw2d.MouseEvent) NodeFigure(org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure) BusinessItemNameFigure(org.talend.designer.business.diagram.custom.figures.BusinessItemNameFigure) EObject(org.eclipse.emf.ecore.EObject) Node(org.eclipse.gmf.runtime.notation.Node) EObject(org.eclipse.emf.ecore.EObject) MouseMotionListener(org.eclipse.draw2d.MouseMotionListener) BusinessItemShapeFigure(org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure) BusinessItem(org.talend.designer.business.model.business.BusinessItem)

Aggregations

Node (org.eclipse.gmf.runtime.notation.Node)24 EObject (org.eclipse.emf.ecore.EObject)6 Location (org.eclipse.gmf.runtime.notation.Location)6 View (org.eclipse.gmf.runtime.notation.View)6 State (org.yakindu.sct.model.sgraph.State)4 IMapMode (org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode)3 Bounds (org.eclipse.gmf.runtime.notation.Bounds)3 Diagram (org.eclipse.gmf.runtime.notation.Diagram)3 Edge (org.eclipse.gmf.runtime.notation.Edge)3 Region (org.yakindu.sct.model.sgraph.Region)3 Transition (org.yakindu.sct.model.sgraph.Transition)3 IAdaptable (org.eclipse.core.runtime.IAdaptable)2 Point (org.eclipse.draw2d.geometry.Point)2 LayoutConstraint (org.eclipse.gmf.runtime.notation.LayoutConstraint)2 ShapeStyle (org.eclipse.gmf.runtime.notation.ShapeStyle)2 Entry (org.yakindu.sct.model.sgraph.Entry)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Entry (java.util.Map.Entry)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1