Search in sources :

Example 46 with GraphicalEditPart

use of org.eclipse.gef.GraphicalEditPart in project tdi-studio-se by Talend.

the class EllipseBusinessItemNameEditPart method createDefaultEditPolicies.

/**
     * @generated
     */
protected void createDefaultEditPolicies() {
    super.createDefaultEditPolicies();
    installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new LabelDirectEditPolicy());
    installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new NonResizableEditPolicy() {

        protected List createSelectionHandles() {
            List handles = new ArrayList();
            NonResizableHandleKit.addMoveHandle((GraphicalEditPart) getHost(), handles);
            return handles;
        }

        public Command getCommand(Request request) {
            return null;
        }

        public boolean understandsRequest(Request request) {
            return false;
        }
    });
}
Also used : LabelDirectEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy) Command(org.eclipse.gef.commands.Command) ArrayList(java.util.ArrayList) Request(org.eclipse.gef.Request) DirectEditRequest(org.eclipse.gef.requests.DirectEditRequest) List(java.util.List) ArrayList(java.util.ArrayList) NonResizableEditPolicy(org.eclipse.gef.editpolicies.NonResizableEditPolicy) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) IGraphicalEditPart(org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)

Example 47 with GraphicalEditPart

use of org.eclipse.gef.GraphicalEditPart in project Palladio-Editors-Sirius by PalladioSimulator.

the class AbstractRotatableImageEditPart method createNodeShape.

/**
 * @generated
 */
protected IFigure createNodeShape() {
    CustomStyle imageStyle = (CustomStyle) resolveSemanticElement();
    NodeImageExtension imageExtension = ExtensionActivator.getDefault().getBestImageExtension(imageStyle.getId());
    primaryShape = new RotatableSVGWorkspaceImageFigure(imageExtension.getMode(), imageExtension.getTopImage(), imageExtension.getLeftImage(), imageExtension.getBottomImage(), imageExtension.getRightImage());
    listener = new RotatableEditPartListener(this);
    primaryShape.addFigureListener(listener);
    EditPart parentEditPart = getParent();
    if (parentEditPart instanceof GraphicalEditPart) {
        GraphicalEditPart parentGraphicalEditPart = (GraphicalEditPart) parentEditPart;
        NodeListener dEdgeEditPartListener = new PropagateFigureListenerAtConnectionFigure(listener);
        parentGraphicalEditPart.addNodeListener(dEdgeEditPartListener);
    }
    return primaryShape;
}
Also used : PropagateFigureListenerAtConnectionFigure(org.palladiosimulator.editors.sirius.custom.style.rotatable.editPart.listener.PropagateFigureListenerAtConnectionFigure) RotatableSVGWorkspaceImageFigure(org.palladiosimulator.editors.sirius.custom.style.rotatable.figure.RotatableSVGWorkspaceImageFigure) NodeListener(org.eclipse.gef.NodeListener) AbstractNotSelectableShapeNodeEditPart(org.eclipse.sirius.diagram.ui.edit.api.part.AbstractNotSelectableShapeNodeEditPart) IStyleEditPart(org.eclipse.sirius.diagram.ui.edit.api.part.IStyleEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) EditPart(org.eclipse.gef.EditPart) NodeImageExtension(org.palladiosimulator.editors.sirius.custom.style.rotatable.NodeImageExtension) CustomStyle(org.eclipse.sirius.diagram.CustomStyle) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) RotatableEditPartListener(org.palladiosimulator.editors.sirius.custom.style.rotatable.figure.listener.RotatableEditPartListener)

Example 48 with GraphicalEditPart

use of org.eclipse.gef.GraphicalEditPart in project knime-core by knime.

the class AnnotationEditManager method initCellEditor.

/**
 * Initializes the cell editor.
 *
 * @see org.eclipse.gef.tools.DirectEditManager#initCellEditor()
 */
@Override
protected void initCellEditor() {
    // de-select the underlying annotation to remove the selection handles
    final GraphicalEditPart editPart = getEditPart();
    editPart.getRoot().getViewer().deselectAll();
    editPart.getFigure().setVisible(false);
    StyledTextEditor stw = (StyledTextEditor) getCellEditor();
    Annotation anno = ((AnnotationEditPart) editPart).getModel();
    Font defaultFont;
    if (editPart instanceof NodeAnnotationEditPart) {
        defaultFont = AnnotationEditPart.getNodeAnnotationDefaultFont();
    } else if (anno.getVersion() < AnnotationData.VERSION_20151012) {
        defaultFont = FontStore.INSTANCE.getSystemDefaultFont();
    } else {
        defaultFont = AnnotationEditPart.getWorkflowAnnotationDefaultFont();
    }
    stw.setDefaultFont(defaultFont);
    stw.setValue(anno);
    // Hook the cell editor's copy/paste actions to the actionBars so that
    // they can
    // be invoked via keyboard shortcuts.
    m_actionBars = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorSite().getActionBars();
    saveCurrentActions(m_actionBars);
    m_actionHandler = new CellEditorActionHandler(m_actionBars);
    m_actionHandler.addCellEditor(getCellEditor());
    m_actionBars.updateActionBars();
}
Also used : AnnotationEditPart(org.knime.workbench.editor2.editparts.AnnotationEditPart) NodeAnnotationEditPart(org.knime.workbench.editor2.editparts.NodeAnnotationEditPart) CellEditorActionHandler(org.eclipse.ui.part.CellEditorActionHandler) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) Annotation(org.knime.core.node.workflow.Annotation) Font(org.eclipse.swt.graphics.Font) NodeAnnotationEditPart(org.knime.workbench.editor2.editparts.NodeAnnotationEditPart)

Example 49 with GraphicalEditPart

use of org.eclipse.gef.GraphicalEditPart in project knime-core by knime.

the class SnapIconToGrid method getReferencePart.

/**
 * Returns the part the request started on (the part that was dragged to move all selected nodes).
 * @param parts
 * @param mouseLoc
 * @param moveDelta
 * @return
 */
private EditPart getReferencePart(@SuppressWarnings("rawtypes") final List parts, final Point mouseLoc, final Point moveDelta) {
    int i = 0;
    Point loc = mouseLoc.getCopy().translate(moveDelta.getCopy().negate());
    makeRelative(m_container.getContentPane(), loc);
    while (i < parts.size()) {
        GraphicalEditPart result = (GraphicalEditPart) parts.get(i);
        if (result.getFigure().containsPoint(loc)) {
            return result;
        }
        if (result instanceof NodeContainerEditPart) {
            NodeAnnotationEditPart annoPart = ((NodeContainerEditPart) result).getNodeAnnotationEditPart();
            if (annoPart.getFigure().containsPoint(loc)) {
                return annoPart;
            }
        }
        i++;
    }
    return null;
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) Point(org.eclipse.draw2d.geometry.Point) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) Point(org.eclipse.draw2d.geometry.Point) NodeAnnotationEditPart(org.knime.workbench.editor2.editparts.NodeAnnotationEditPart)

Example 50 with GraphicalEditPart

use of org.eclipse.gef.GraphicalEditPart in project knime-core by knime.

the class SnapToPortGeometry method generateSnapPartsList.

/**
 * Generates a list of parts which should be snapped to. The list is the
 * original children, minus the given exclusions, minus and children whose
 * figures are not visible.
 *
 * @since 3.0
 * @param exclusions the children to exclude
 * @return a list of parts which should be snapped to
 */
protected List generateSnapPartsList(final List exclusions) {
    // Don't snap to any figure that is being dragged
    List<Object> children = new ArrayList<Object>(m_container.getChildren());
    children.removeAll(exclusions);
    // Don't snap to hidden figures
    List hiddenChildren = new ArrayList();
    for (Iterator iter = children.iterator(); iter.hasNext(); ) {
        GraphicalEditPart child = (GraphicalEditPart) iter.next();
        if (!child.getFigure().isVisible()) {
            hiddenChildren.add(child);
        }
    }
    children.removeAll(hiddenChildren);
    return children;
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) PointList(org.eclipse.draw2d.geometry.PointList) List(java.util.List) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart)

Aggregations

GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)53 ArrayList (java.util.ArrayList)17 List (java.util.List)16 Rectangle (org.eclipse.draw2d.geometry.Rectangle)15 Command (org.eclipse.gef.commands.Command)15 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)13 Point (org.eclipse.draw2d.geometry.Point)12 Request (org.eclipse.gef.Request)12 IFigure (org.eclipse.draw2d.IFigure)11 NonResizableEditPolicy (org.eclipse.gef.editpolicies.NonResizableEditPolicy)11 DirectEditRequest (org.eclipse.gef.requests.DirectEditRequest)11 IGraphicalEditPart (org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart)11 LabelDirectEditPolicy (org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy)11 EditPart (org.eclipse.gef.EditPart)7 Dimension (org.eclipse.draw2d.geometry.Dimension)6 ConnectionContainerEditPart (org.knime.workbench.editor2.editparts.ConnectionContainerEditPart)4 Iterator (java.util.Iterator)3 ConnectionEditPart (org.eclipse.gef.ConnectionEditPart)3 EditPartViewer (org.eclipse.gef.EditPartViewer)3 AbstractWorkflowPortBarEditPart (org.knime.workbench.editor2.editparts.AbstractWorkflowPortBarEditPart)3