Search in sources :

Example 26 with IGraphicalEditPart

use of org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart in project tdi-studio-se by Talend.

the class BusinessGraphicalNodeEditPolicy method getConnectionWithReorientedViewCompleteCommand.

/**
     * @generated
     */
protected Command getConnectionWithReorientedViewCompleteCommand(CreateConnectionRequest request) {
    ICommandProxy c = (ICommandProxy) super.getConnectionCompleteCommand(request);
    CompositeCommand cc = (CompositeCommand) c.getICommand();
    TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
    BusinessReorientConnectionViewCommand rcvCommand = new BusinessReorientConnectionViewCommand(editingDomain, null);
    rcvCommand.setEdgeAdaptor(getViewAdapter());
    cc.compose(rcvCommand);
    return c;
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) ICommandProxy(org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) BusinessReorientConnectionViewCommand(org.talend.designer.business.model.business.diagram.edit.commands.BusinessReorientConnectionViewCommand) CompositeCommand(org.eclipse.gmf.runtime.common.core.command.CompositeCommand)

Example 27 with IGraphicalEditPart

use of org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart in project tdi-studio-se by Talend.

the class BusinessModelingAssistantProvider method getRelTypesOnSource.

public List getRelTypesOnSource(IAdaptable source) {
    IGraphicalEditPart editPart = (IGraphicalEditPart) source.getAdapter(IGraphicalEditPart.class);
    if (editPart instanceof BusinessItemShapeEditPart) {
        List types = new ArrayList();
        types.add(BusinessElementTypes.BusinessItemRelationship_3001);
        types.add(BusinessElementTypes.DirectionalBusinessItemRelationship_3002);
        types.add(BusinessElementTypes.BidirectionalBusinessItemRelationship_3003);
        return types;
    }
    return Collections.EMPTY_LIST;
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) BusinessItemShapeEditPart(org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List)

Example 28 with IGraphicalEditPart

use of org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart in project statecharts by Yakindu.

the class UpdateAnnotationsOnMoveCommand method doExecuteWithResult.

@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
    final View parentView = TreeLayoutUtil.getTreeNodeParentView(editPart.getNotationView());
    if (parentView != null) {
        final IGraphicalEditPart parentEditPart = (IGraphicalEditPart) editPart.findEditPart(editPart.getParent(), parentView.getElement());
        if (parentEditPart != null) {
            final List<IGraphicalEditPart> treeChildren = new ArrayList<IGraphicalEditPart>(TreeLayoutUtil.getOrderedTreeChildren(parentEditPart));
            if (!treeChildren.isEmpty()) {
                final int oldPos = treeChildren.indexOf(editPart);
                final int newPos = layoutConstraint.getTreeInnerRankIndex();
                if (newPos != -1) {
                    if (oldPos != newPos) {
                        final IGraphicalEditPart element = treeChildren.get(oldPos);
                        treeChildren.remove(oldPos);
                        treeChildren.add(newPos, element);
                        TreeLayoutUtil.setTreeNodesPositionAnnotation(TreeLayoutUtil.getViews(treeChildren));
                    }
                }
                return CommandResult.newOKCommandResult();
            }
        }
    }
    return CommandResult.newErrorCommandResult("Parent view or parent edit part not found!");
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) ArrayList(java.util.ArrayList) View(org.eclipse.gmf.runtime.notation.View) TreeLayoutConstraint(org.yakindu.base.gmf.runtime.treelayout.TreeLayoutConstraint)

Example 29 with IGraphicalEditPart

use of org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart in project statecharts by Yakindu.

the class TreeLayoutEditPolicy method showLayoutTargetFeedback.

@Override
protected void showLayoutTargetFeedback(Request request) {
    if (request instanceof ChangeBoundsRequest) {
        final ChangeBoundsRequest changeBoundsRequest = (ChangeBoundsRequest) request;
        if (!changeBoundsRequest.getEditParts().isEmpty() && !(changeBoundsRequest.getEditParts().get(0) instanceof LabelEditPart)) {
            final IGraphicalEditPart editPart = (IGraphicalEditPart) changeBoundsRequest.getEditParts().get(0);
            final List<IGraphicalEditPart> siblingList = TreeLayoutUtil.getSiblings(editPart);
            if (!siblingList.isEmpty()) {
                final int newTreePosition = TreeLayoutUtil.getNewTreeNodePosition(changeBoundsRequest.getLocation(), TreeLayoutUtil.getSiblings(editPart));
                Point point;
                if (newTreePosition == 0) {
                    // top end
                    point = getFeedBackFigurePoint(editPart.getFigure(), siblingList, 0, 0);
                } else if (newTreePosition == siblingList.size()) {
                    // Bottom end
                    point = getFeedBackFigurePoint(editPart.getFigure(), siblingList, siblingList.size(), siblingList.size());
                } else {
                    // Between siblings
                    point = getFeedBackFigurePoint(editPart.getFigure(), siblingList, newTreePosition - 1, newTreePosition);
                }
                final Rectangle bounds = getFeedbackFigureBounds();
                siblingList.get(0).getFigure().translateToAbsolute(bounds);
                bounds.setLocation(point);
                getFeedbackFigure().setBounds(bounds);
                getFeedbackFigure().translateToRelative(getFeedbackFigure().getBounds());
                getFeedbackLayer().add(getFeedbackFigure());
                getFeedbackLayer().repaint();
            }
        }
    }
}
Also used : ChangeBoundsRequest(org.eclipse.gef.requests.ChangeBoundsRequest) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) LabelEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.LabelEditPart) Rectangle(org.eclipse.draw2d.geometry.Rectangle) RoundedRectangle(org.eclipse.draw2d.RoundedRectangle) Point(org.eclipse.draw2d.geometry.Point) TreeLayoutConstraint(org.yakindu.base.gmf.runtime.treelayout.TreeLayoutConstraint) Point(org.eclipse.draw2d.geometry.Point)

Example 30 with IGraphicalEditPart

use of org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart in project statecharts by Yakindu.

the class AdjustIdentityAnchorCommand method adjustAnchors.

@SuppressWarnings("unchecked")
protected void adjustAnchors(IGraphicalEditPart editPart) {
    if (editPart instanceof IGraphicalEditPart) {
        View view = ((IGraphicalEditPart) editPart).getNotationView();
        List<Edge> targetEdges = view.getTargetEdges();
        for (Edge edge : targetEdges) {
            handleEdge(edge, editPart, false);
        }
        List<Edge> sourceEdges = view.getSourceEdges();
        for (Edge edge : sourceEdges) {
            handleEdge(edge, editPart, true);
        }
    }
}
Also used : IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart) View(org.eclipse.gmf.runtime.notation.View) Edge(org.eclipse.gmf.runtime.notation.Edge)

Aggregations

IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)43 ArrayList (java.util.ArrayList)10 EObject (org.eclipse.emf.ecore.EObject)10 View (org.eclipse.gmf.runtime.notation.View)10 List (java.util.List)8 Point (org.eclipse.draw2d.geometry.Point)8 Rectangle (org.eclipse.draw2d.geometry.Rectangle)7 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)7 ICommandProxy (org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy)7 IFigure (org.eclipse.draw2d.IFigure)6 BusinessItemShapeEditPart (org.talend.designer.business.diagram.custom.edit.parts.BusinessItemShapeEditPart)5 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)4 Command (org.eclipse.gef.commands.Command)4 CompositeTransactionalCommand (org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand)3 EObjectAdapter (org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter)3 IElementType (org.eclipse.gmf.runtime.emf.type.core.IElementType)3 Iterator (java.util.Iterator)2 Connection (org.eclipse.draw2d.Connection)2 RoundedRectangle (org.eclipse.draw2d.RoundedRectangle)2 Dimension (org.eclipse.draw2d.geometry.Dimension)2