Search in sources :

Example 11 with NodeFigure

use of org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure in project tdi-studio-se by Talend.

the class DataBusinessItemEditPart method createNodeFigure.

/**
     * Creates figure for this edit part.
     * 
     * Body of this method does not depend on settings in generation model so you may safely remove <i>generated</i> tag
     * and modify it.
     * 
     * @generated
     */
protected NodeFigure createNodeFigure() {
    NodeFigure figure = createNodePlate();
    figure.setLayoutManager(new StackLayout());
    IFigure shape = createNodeShape();
    figure.add(shape);
    contentPane = setupContentPane(shape);
    return figure;
}
Also used : DefaultSizeNodeFigure(org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure) NodeFigure(org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure) StackLayout(org.eclipse.draw2d.StackLayout) IFigure(org.eclipse.draw2d.IFigure)

Example 12 with NodeFigure

use of org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure 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

NodeFigure (org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure)12 IFigure (org.eclipse.draw2d.IFigure)11 StackLayout (org.eclipse.draw2d.StackLayout)11 DefaultSizeNodeFigure (org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure)11 MouseEvent (org.eclipse.draw2d.MouseEvent)1 MouseMotionListener (org.eclipse.draw2d.MouseMotionListener)1 EObject (org.eclipse.emf.ecore.EObject)1 Node (org.eclipse.gmf.runtime.notation.Node)1 BusinessItemNameFigure (org.talend.designer.business.diagram.custom.figures.BusinessItemNameFigure)1 BusinessItemShapeFigure (org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure)1 BusinessItem (org.talend.designer.business.model.business.BusinessItem)1