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;
}
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);
}
}
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();
}
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;
}
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);
}
}
Aggregations