Search in sources :

Example 21 with GraphicalEditPart

use of org.eclipse.gef.GraphicalEditPart in project cubrid-manager by CUBRID.

the class AbstractBasicPart method propertyChange.

public void propertyChange(PropertyChangeEvent evt) {
    String property = evt.getPropertyName();
    if (PropertyChangeProvider.CHILD_CHANGE.equals(property)) {
        handleChildChange(evt);
    } else if (PropertyChangeProvider.REORDER_CHANGE.equals(property)) {
        handleReorderChange(evt);
    } else if (PropertyChangeProvider.OUTPUT_CHANGE.equals(property)) {
        handleOutputChange(evt);
    } else if (PropertyChangeProvider.INPUT_CHANGE.equals(property)) {
        handleInputChange(evt);
    } else if (PropertyChangeProvider.TEXT_CHANGE.equals(property)) {
        handleLabelChange(evt);
    } else if (PropertyChangeProvider.BOUNDS_CHANGE.equals(property)) {
        handleBoundsChange(evt);
    } else if (PropertyChangeProvider.LAYOUT_CHANGE.equals(property)) {
        handleLayoutChange(evt);
    } else if (PropertyChangeProvider.AUTO_LAYOUT_TEMP.equals(property)) {
        handleTmpAutoLayout(evt);
    } else if (PropertyChangeProvider.VIEW_MODEL_CHANGE.equals(property)) {
        handleViewModelChange(evt);
    } else if (PropertyChangeProvider.RELATION_MAP_CHANGE.equals(property)) {
        handleRelationMapChange(evt);
    }
    if (PropertyChangeProvider.TEXT_CHANGE.equals(property)) {
        GraphicalEditPart graphicalEditPart = (GraphicalEditPart) (getViewer().getContents());
        IFigure partFigure = graphicalEditPart.getFigure();
        partFigure.getUpdateManager().performUpdate();
    }
    postSchemaDataChanged(evt);
}
Also used : AbstractGraphicalEditPart(org.eclipse.gef.editparts.AbstractGraphicalEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) IFigure(org.eclipse.draw2d.IFigure)

Example 22 with GraphicalEditPart

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

the class AbstractRotatableImageEditPart method refreshVisuals.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeEditPart#refreshVisuals()
 */
protected void refreshVisuals() {
    super.refreshVisuals();
    RotatableSVGWorkspaceImageFigure figure = this.getPrimaryShape();
    getSourceConnections();
    EObject element = this.resolveSemanticElement();
    if (element instanceof CustomStyle) {
        CustomStyle imageStyle = (CustomStyle) element;
        figure.refreshFigure(imageStyle);
        ((GraphicalEditPart) this.getParent()).setLayoutConstraint(this, this.getFigure(), new Rectangle(0, 0, figure.getPreferredSize().width, figure.getPreferredSize().height));
    }
}
Also used : RotatableSVGWorkspaceImageFigure(org.palladiosimulator.editors.sirius.custom.style.rotatable.figure.RotatableSVGWorkspaceImageFigure) EObject(org.eclipse.emf.ecore.EObject) Rectangle(org.eclipse.draw2d.geometry.Rectangle) CustomStyle(org.eclipse.sirius.diagram.CustomStyle) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart)

Example 23 with GraphicalEditPart

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

the class WorkflowMarqueeSelectionTool method performMarqueeSelect.

private void performMarqueeSelect() {
    EditPartViewer viewer = getCurrentViewer();
    Collection<GraphicalEditPart> newSelections = new LinkedHashSet<GraphicalEditPart>(), deselections = new HashSet<GraphicalEditPart>();
    calculateNewSelection(newSelections, deselections);
    if (getSelectionMode() != DEFAULT_MODE) {
        newSelections.addAll(viewer.getSelectedEditParts());
        newSelections.removeAll(deselections);
    }
    viewer.setSelection(new StructuredSelection(newSelections.toArray()));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) EditPartViewer(org.eclipse.gef.EditPartViewer) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 24 with GraphicalEditPart

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

the class WorkflowMarqueeSelectionTool method calculateConnections.

private void calculateConnections(final Collection<GraphicalEditPart> newSelections, final Collection<GraphicalEditPart> deselections) {
    // determine the currently selected nodes minus the ones that are to be
    // deselected
    Collection<EditPart> currentNodes = new HashSet<EditPart>();
    if (getSelectionMode() != DEFAULT_MODE) {
        // everything is deselected
        // in default mode
        Iterator<EditPart> iter = getCurrentViewer().getSelectedEditParts().iterator();
        while (iter.hasNext()) {
            EditPart selected = iter.next();
            if (!(selected instanceof ConnectionEditPart) && !deselections.contains(selected)) {
                currentNodes.add(selected);
            }
        }
    }
    // add new connections to be selected to newSelections
    Collection<ConnectionEditPart> connections = new ArrayList<ConnectionEditPart>();
    for (Iterator<GraphicalEditPart> nodes = newSelections.iterator(); nodes.hasNext(); ) {
        GraphicalEditPart node = nodes.next();
        for (Iterator<ConnectionEditPart> itr = node.getSourceConnections().iterator(); itr.hasNext(); ) {
            ConnectionEditPart sourceConn = itr.next();
            if (sourceConn.getSelected() == EditPart.SELECTED_NONE && (newSelections.contains(sourceConn.getTarget()) || currentNodes.contains(sourceConn.getTarget()))) {
                connections.add(sourceConn);
            }
        }
        for (Iterator<ConnectionEditPart> itr = node.getTargetConnections().iterator(); itr.hasNext(); ) {
            ConnectionEditPart targetConn = itr.next();
            if (targetConn.getSelected() == EditPart.SELECTED_NONE && (newSelections.contains(targetConn.getSource()) || currentNodes.contains(targetConn.getSource()))) {
                connections.add(targetConn);
            }
        }
    }
    newSelections.addAll(connections);
    // add currently selected connections that are to be deselected to
    // deselections
    connections = new HashSet<ConnectionEditPart>();
    for (Iterator<GraphicalEditPart> nodes = deselections.iterator(); nodes.hasNext(); ) {
        GraphicalEditPart node = nodes.next();
        for (Iterator<ConnectionEditPart> itr = node.getSourceConnections().iterator(); itr.hasNext(); ) {
            ConnectionEditPart sourceConn = itr.next();
            if (sourceConn.getSelected() != EditPart.SELECTED_NONE) {
                connections.add(sourceConn);
            }
        }
        for (Iterator<ConnectionEditPart> itr = node.getTargetConnections().iterator(); itr.hasNext(); ) {
            ConnectionEditPart targetConn = itr.next();
            if (targetConn.getSelected() != EditPart.SELECTED_NONE) {
                connections.add(targetConn);
            }
        }
    }
    deselections.addAll(connections);
}
Also used : ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) AnnotationEditPart(org.knime.workbench.editor2.editparts.AnnotationEditPart) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) AbstractWorkflowPortBarEditPart(org.knime.workbench.editor2.editparts.AbstractWorkflowPortBarEditPart) NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) ConnectionContainerEditPart(org.knime.workbench.editor2.editparts.ConnectionContainerEditPart) EditPart(org.eclipse.gef.EditPart) ArrayList(java.util.ArrayList) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 25 with GraphicalEditPart

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

the class WorkflowMarqueeSelectionTool method calculateNewSelection.

private void calculateNewSelection(final Collection<GraphicalEditPart> newSelections, final Collection<GraphicalEditPart> deselections) {
    Rectangle marqueeRect = getMarqueeSelectionRectangle();
    for (Iterator<GraphicalEditPart> itr = getAllChildren().iterator(); itr.hasNext(); ) {
        GraphicalEditPart child = itr.next();
        IFigure figure = child.getFigure();
        if (!child.isSelectable() || child.getTargetEditPart(MARQUEE_REQUEST) != child || !isFigureVisible(figure) || !figure.isShowing()) {
            continue;
        }
        if (!(child instanceof NodeContainerEditPart || child instanceof ConnectionContainerEditPart || child instanceof AbstractWorkflowPortBarEditPart || child instanceof AnnotationEditPart)) {
            continue;
        }
        Rectangle r = figure.getBounds().getCopy();
        figure.translateToAbsolute(r);
        boolean included = false;
        if (child instanceof ConnectionEditPart && marqueeRect.intersects(r)) {
            Rectangle relMarqueeRect = Rectangle.SINGLETON;
            figure.translateToRelative(relMarqueeRect.setBounds(marqueeRect));
            included = ((PolylineConnection) figure).getPoints().intersects(relMarqueeRect);
        } else if (child instanceof AnnotationEditPart) {
            // select WorkflowAnnotations only if they are fully included in the selection
            if (figure instanceof WorkflowAnnotationFigure) {
                included = marqueeRect.contains(r);
            }
        } else if (marqueeBehavior == BEHAVIOR_NODES_AND_CONNECTIONS_TOUCHED) {
            included = marqueeRect.intersects(r);
        } else {
            included = marqueeRect.contains(r);
        }
        if (included) {
            if (isToggle()) {
                if (wasSelected(child)) {
                    deselections.add(child);
                } else {
                    newSelections.add(child);
                }
            } else {
                newSelections.add(child);
            }
        } else if (isToggle()) {
            // readded if it was in the selection before
            if (wasSelected(child)) {
                newSelections.add(child);
            } else {
                deselections.add(child);
            }
        }
    }
    if (marqueeBehavior == BEHAVIOR_NODES_AND_CONNECTIONS_TOUCHED) {
        calculateConnections(newSelections, deselections);
    }
}
Also used : NodeContainerEditPart(org.knime.workbench.editor2.editparts.NodeContainerEditPart) ConnectionContainerEditPart(org.knime.workbench.editor2.editparts.ConnectionContainerEditPart) AnnotationEditPart(org.knime.workbench.editor2.editparts.AnnotationEditPart) WorkflowAnnotationFigure(org.knime.workbench.editor2.figures.WorkflowAnnotationFigure) AbstractWorkflowPortBarEditPart(org.knime.workbench.editor2.editparts.AbstractWorkflowPortBarEditPart) ConnectionEditPart(org.eclipse.gef.ConnectionEditPart) Rectangle(org.eclipse.draw2d.geometry.Rectangle) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart) IFigure(org.eclipse.draw2d.IFigure) PolylineConnection(org.eclipse.draw2d.PolylineConnection)

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