Search in sources :

Example 36 with IFigure

use of org.eclipse.draw2d.IFigure in project tdi-studio-se by Talend.

the class TalendGroupEditPart method createFigure.

@Override
public IFigure createFigure() {
    Figure figure = new Figure();
    figure.setOpaque(true);
    // figure.setBackgroundColor(ColorConstants.blue);
    figure.setBackgroundColor(PaletteColorUtil.WIDGET_LIST_BACKGROUND);
    return figure;
}
Also used : Figure(org.eclipse.draw2d.Figure) IFigure(org.eclipse.draw2d.IFigure)

Example 37 with IFigure

use of org.eclipse.draw2d.IFigure in project tdi-studio-se by Talend.

the class FindAssignmentAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
protected void doRun() {
    RepositoryNode repositoryNode = (RepositoryNode) getFirstSelectedObject();
    IEditorPart activeEditor = getActiveEditor();
    // remove frames draw last time
    for (BusinessItemShapeFigure shapFigure : repaintedFigures) {
        shapFigure.setDrawFrame(false);
        shapFigure.revalidate();
        shapFigure.repaint();
    }
    if (activeEditor instanceof BusinessDiagramEditor) {
        BusinessDiagramEditor businessDiagramEditor = (BusinessDiagramEditor) activeEditor;
        Diagram diagram = (Diagram) businessDiagramEditor.getDiagramEditPart().getModel();
        BusinessProcess businessProcess = (BusinessProcess) diagram.getElement();
        // PTODO mhelleboid use OCL or using a visitor
        List list = new ArrayList();
        for (Iterator iter = businessProcess.getBusinessItems().iterator(); iter.hasNext(); ) {
            BusinessItem businessItem = (BusinessItem) iter.next();
            for (Iterator iterator = businessItem.getAssignments().iterator(); iterator.hasNext(); ) {
                BusinessAssignment businessAssignment = (BusinessAssignment) iterator.next();
                TalendItem talendItem = businessAssignment.getTalendItem();
                IRepositoryViewObject obj = repositoryNode.getObject();
                if (talendItem.getId().equals(repositoryNode.getId())) {
                    list.add(businessItem);
                } else if (talendItem instanceof SQLPattern || talendItem instanceof Routine || talendItem instanceof TableMetadata || talendItem instanceof Query || talendItem instanceof SapFunctionMetadata) {
                    if (talendItem.getLabel().equals(repositoryNode.getProperties(EProperties.LABEL))) {
                        list.add(businessItem);
                    }
                }
            }
        }
        IDiagramGraphicalViewer diagramGraphicalViewer = businessDiagramEditor.getDiagramGraphicalViewer();
        List editParts = new ArrayList();
        for (Iterator iter = list.iterator(); iter.hasNext(); ) {
            BusinessItem businessItem = (BusinessItem) iter.next();
            editParts.addAll(diagramGraphicalViewer.findEditPartsForElement(EMFCoreUtil.getProxyID(businessItem), BaseBusinessItemRelationShipEditPart.class));
            editParts.addAll(diagramGraphicalViewer.findEditPartsForElement(EMFCoreUtil.getProxyID(businessItem), BusinessItemShapeEditPart.class));
        }
        diagramGraphicalViewer.deselectAll();
        // add a frame when use findAassignment
        for (Iterator iter = editParts.iterator(); iter.hasNext(); ) {
            EditPart editPart = (EditPart) iter.next();
            if (editPart instanceof BusinessItemShapeEditPart) {
                BusinessItemShapeEditPart shapEditPart = (BusinessItemShapeEditPart) editPart;
                IFigure figure = shapEditPart.getFigure();
                for (Object child : figure.getChildren()) {
                    if (child instanceof BusinessItemShapeFigure) {
                        BusinessItemShapeFigure shapFigure = (BusinessItemShapeFigure) child;
                        shapFigure.setDrawFrame(true);
                        shapFigure.revalidate();
                        shapFigure.repaint();
                        repaintedFigures.add(shapFigure);
                    }
                }
            }
            diagramGraphicalViewer.getSelectionManager().appendSelection(editPart);
        }
        ZoomManager zoomManager = (ZoomManager) businessDiagramEditor.getAdapter(ZoomManager.class);
        zoomFitSelection(zoomManager, editParts, businessDiagramEditor.getDiagramEditPart(), true);
    }
}
Also used : IDiagramGraphicalViewer(org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer) SapFunctionMetadata(org.talend.designer.business.model.business.SapFunctionMetadata) BusinessDiagramEditor(org.talend.designer.business.model.business.diagram.part.BusinessDiagramEditor) BusinessAssignment(org.talend.designer.business.model.business.BusinessAssignment) Query(org.talend.designer.business.model.business.Query) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) TalendItem(org.talend.designer.business.model.business.TalendItem) IFigure(org.eclipse.draw2d.IFigure) TableMetadata(org.talend.designer.business.model.business.TableMetadata) SQLPattern(org.talend.designer.business.model.business.SQLPattern) BusinessItemShapeEditPart(org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart) DiagramEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) BaseBusinessItemRelationShipEditPart(org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart) IEditorPart(org.eclipse.ui.IEditorPart) Routine(org.talend.designer.business.model.business.Routine) RepositoryNode(org.talend.repository.model.RepositoryNode) BaseBusinessItemRelationShipEditPart(org.talend.designer.business.diagram.custom.edit.parts.BaseBusinessItemRelationShipEditPart) Diagram(org.eclipse.gmf.runtime.notation.Diagram) BusinessItemShapeEditPart(org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart) ZoomManager(org.eclipse.gef.editparts.ZoomManager) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) BusinessItemShapeFigure(org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure) BusinessItem(org.talend.designer.business.model.business.BusinessItem) BusinessProcess(org.talend.designer.business.model.business.BusinessProcess)

Example 38 with IFigure

use of org.eclipse.draw2d.IFigure in project tdi-studio-se by Talend.

the class BusinessItemShapeEditPart method unregisterVisuals.

@Override
protected void unregisterVisuals() {
    IFigure figure2 = getFigure();
    if (figure2 instanceof BusinessItemShapeFigure) {
        ((BusinessItemShapeFigure) figure2).disposeColors();
    }
    super.unregisterVisuals();
}
Also used : BusinessItemShapeFigure(org.talend.designer.business.diagram.custom.figures.BusinessItemShapeFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 39 with IFigure

use of org.eclipse.draw2d.IFigure in project tdi-studio-se by Talend.

the class BusinessTooltipFigure method computePreferedSize.

@SuppressWarnings("unchecked")
private Dimension computePreferedSize() {
    Dimension size = new Dimension();
    // Vertical path
    List<IFigure> children = getChildren();
    for (IFigure fv : children) {
        // Horizontal path
        Dimension sizeH = new Dimension();
        List<IFigure> childrenH = fv.getChildren();
        for (IFigure fh : childrenH) {
            sizeH.width += fh.getPreferredSize().width;
            sizeH.height = Math.max(sizeH.height, fh.getPreferredSize().height);
        }
        size.width = Math.max(size.width, sizeH.width);
        size.height += sizeH.height;
    }
    return size;
}
Also used : Dimension(org.eclipse.draw2d.geometry.Dimension) IFigure(org.eclipse.draw2d.IFigure)

Example 40 with IFigure

use of org.eclipse.draw2d.IFigure in project tdi-studio-se by Talend.

the class SVGImageExporter method export.

public static void export(GraphicalViewer viewer, OutputStream outputStream, List businessItems) {
    /*
         * 1. First get the figure whose visuals we want to save as image. So we would like to save the rooteditpart
         * which actually hosts all the printable layers.
         * 
         * NOTE: ScalableRootEditPart manages layers and is registered graphicalviewer's editpartregistry with the key
         * LayerManager.ID ... well that is because ScalableRootEditPart manages all layers that are hosted on a
         * FigureCanvas. Many layers exist for doing different things
         */
    SimpleRootEditPart rootEditPart = (SimpleRootEditPart) viewer.getEditPartRegistry().get(LayerManager.ID);
    // rootEditPart.
    IFigure rootFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.PRINTABLE_LAYERS);
    // getFigure();
    Rectangle bounds = rootFigure.getBounds();
    GraphicsSVG graphics = GraphicsSVG.getInstance(bounds.getTranslated(bounds.getLocation().negate()));
    TalendSVGIDGenerator generator = new TalendSVGIDGenerator(businessItems);
    graphics.getSVGGraphics2D().getGeneratorContext().setIDGenerator(generator);
    graphics.translate(bounds.getLocation().negate());
    rootFigure.paint(graphics);
    try {
        graphics.getSVGGraphics2D().stream(new BufferedWriter(new OutputStreamWriter(outputStream)));
    } catch (SVGGraphics2DIOException e) {
        ExceptionHandler.process(e);
    }
}
Also used : SimpleRootEditPart(org.eclipse.gef.editparts.SimpleRootEditPart) SVGGraphics2DIOException(org.apache.batik.svggen.SVGGraphics2DIOException) Rectangle(org.eclipse.draw2d.geometry.Rectangle) GraphicsSVG(org.eclipse.gmf.runtime.draw2d.ui.render.awt.internal.svg.export.GraphicsSVG) OutputStreamWriter(java.io.OutputStreamWriter) LayerManager(org.eclipse.gef.editparts.LayerManager) IFigure(org.eclipse.draw2d.IFigure) BufferedWriter(java.io.BufferedWriter)

Aggregations

IFigure (org.eclipse.draw2d.IFigure)440 Rectangle (org.eclipse.draw2d.geometry.Rectangle)120 Point (org.eclipse.draw2d.geometry.Point)77 Dimension (org.eclipse.draw2d.geometry.Dimension)56 Figure (org.eclipse.draw2d.Figure)38 List (java.util.List)37 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)35 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)32 Graphics (org.eclipse.draw2d.Graphics)17 Iterator (java.util.Iterator)15 ArrayList (java.util.ArrayList)14 EditPart (org.eclipse.gef.EditPart)13 StackLayout (org.eclipse.draw2d.StackLayout)12 DefaultSizeNodeFigure (org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure)12 NodeFigure (org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure)12 Insets (org.eclipse.draw2d.geometry.Insets)11 INodeFigure (org.whole.lang.ui.figures.INodeFigure)11 MarginBorder (org.eclipse.draw2d.MarginBorder)10 ToolbarLayout (org.eclipse.draw2d.ToolbarLayout)10 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)10