Search in sources :

Example 66 with IFigure

use of org.eclipse.draw2d.IFigure in project knime-core by knime.

the class AnnotationEditPart method getDragTracker.

/**
 * {@inheritDoc}
 * If dragging started on the "move" icon (top left corner) return the normal edit part dragger tool, otherwise
 * return the marquee selection tool.
 */
@Override
public DragTracker getDragTracker(final Request request) {
    Object object = request.getExtendedData().get(WorkflowSelectionTool.DRAG_START_LOCATION);
    IFigure f = getFigure();
    if (object instanceof Point && f instanceof WorkflowAnnotationFigure && getSelected() == SELECTED_NONE) {
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorSite();
        Rectangle iconBounds = ((WorkflowAnnotationFigure) f).getEditIconBounds().getCopy();
        if (!iconBounds.contains((Point) object)) {
            return new WorkflowMarqueeSelectionTool();
        }
    }
    // "normal" edit part dragging
    return new WorkflowSelectionDragEditPartsTracker(this);
}
Also used : WorkflowAnnotationFigure(org.knime.workbench.editor2.figures.WorkflowAnnotationFigure) WorkflowMarqueeSelectionTool(org.knime.workbench.editor2.WorkflowMarqueeSelectionTool) Rectangle(org.eclipse.draw2d.geometry.Rectangle) WorkflowSelectionDragEditPartsTracker(org.knime.workbench.editor2.WorkflowSelectionDragEditPartsTracker) Point(org.eclipse.draw2d.geometry.Point) IFigure(org.eclipse.draw2d.IFigure)

Example 67 with IFigure

use of org.eclipse.draw2d.IFigure in project knime-core by knime.

the class OutPortConnectionAnchor method getBox.

/**
 * @return The chop box for the out-port figure
 */
@Override
protected Rectangle getBox() {
    IFigure owner = getOwner();
    if (!(owner instanceof AbstractPortFigure)) {
        return super.getBox();
    }
    AbstractPortFigure port = (AbstractPortFigure) owner;
    return port.computePortShapeBounds(port.getBounds());
}
Also used : AbstractPortFigure(org.knime.workbench.editor2.figures.AbstractPortFigure) IFigure(org.eclipse.draw2d.IFigure)

Example 68 with IFigure

use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.

the class PatchedConnectionLayerClippingStrategy method getEdgeClippingRectangle.

@Override
protected Rectangle[] getEdgeClippingRectangle(Connection connection) {
    // start with clipping the connection at its original bounds
    Rectangle clipRect = getAbsoluteBoundsAsCopy(connection);
    // in case we cannot infer source and target of the connection (e.g.
    // if XYAnchors are used), returning the bounds is all we can do
    ConnectionAnchor sourceAnchor = connection.getSourceAnchor();
    ConnectionAnchor targetAnchor = connection.getTargetAnchor();
    if (sourceAnchor == null || sourceAnchor.getOwner() == null || targetAnchor == null || targetAnchor.getOwner() == null) {
        return new Rectangle[] { clipRect };
    }
    // source and target figure are known, see if there is common
    // viewport
    // the connection has to be clipped at.
    IFigure sourceFigure = sourceAnchor.getOwner();
    IFigure targetFigure = targetAnchor.getOwner();
    if (!sourceFigure.isShowing() || !targetFigure.isShowing())
        return new Rectangle[] {};
    return super.getEdgeClippingRectangle(connection);
}
Also used : ConnectionAnchor(org.eclipse.draw2d.ConnectionAnchor) Rectangle(org.eclipse.draw2d.geometry.Rectangle) IFigure(org.eclipse.draw2d.IFigure)

Example 69 with IFigure

use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.

the class RuntimePatchedSelectionTool method handleButtonUp.

/**
 * Intercept middle clicks and restore original cursor if it has changed.
 */
@Override
protected boolean handleButtonUp(int button) {
    if (button == 2) {
        EditPart editPart = getTargetEditPart();
        if (editPart instanceof AbstractPVWidgetEditPart) {
            AbstractPVWidgetEditPart apvwep = (AbstractPVWidgetEditPart) editPart;
            IFigure figure = apvwep.getFigure();
            if (cursorChanged) {
                figure.setCursor(oldCursor);
                oldCursor = null;
                cursorChanged = false;
            }
        }
        return true;
    } else {
        return super.handleButtonUp(button);
    }
}
Also used : AbstractPVWidgetEditPart(org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart) AbstractPVWidgetEditPart(org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart) EditPart(org.eclipse.gef.EditPart) IFigure(org.eclipse.draw2d.IFigure)

Example 70 with IFigure

use of org.eclipse.draw2d.IFigure in project yamcs-studio by yamcs.

the class RuntimePatchedSelectionTool method handleButtonDown.

/**
 * Intercept middle clicks and copy PV name to pastebuffer if available.
 * Change cursor to copy symbol.
 */
@Override
protected boolean handleButtonDown(int button) {
    if (button == 2) {
        EditPart editPart = getTargetEditPart();
        if (editPart instanceof AbstractPVWidgetEditPart) {
            AbstractPVWidgetEditPart apvwep = (AbstractPVWidgetEditPart) editPart;
            String pvName = ((AbstractPVWidgetModel) editPart.getModel()).getPVName();
            if (pvName != "" && pvName != null) {
                Display display = Display.getCurrent();
                Clipboard clipboard = new Clipboard(display);
                // Copies to middle button paste buffer,
                // to be pasted via another middle-button click
                clipboard.setContents(new Object[] { pvName }, new Transfer[] { TextTransfer.getInstance() }, DND.SELECTION_CLIPBOARD);
                // Copies to normal clipboard,
                // to be pasted via Ctrl-V or Edit/Paste
                clipboard.setContents(new String[] { pvName }, new Transfer[] { TextTransfer.getInstance() });
                clipboard.dispose();
                IFigure figure = apvwep.getFigure();
                oldCursor = figure.getCursor();
                figure.setCursor(ResourceUtil.getCopyPvCursor());
                cursorChanged = true;
            }
        }
        return true;
    } else {
        return super.handleButtonDown(button);
    }
}
Also used : AbstractPVWidgetEditPart(org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart) AbstractPVWidgetEditPart(org.csstudio.opibuilder.editparts.AbstractPVWidgetEditPart) EditPart(org.eclipse.gef.EditPart) AbstractPVWidgetModel(org.csstudio.opibuilder.model.AbstractPVWidgetModel) Clipboard(org.eclipse.swt.dnd.Clipboard) Display(org.eclipse.swt.widgets.Display) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

IFigure (org.eclipse.draw2d.IFigure)225 IWidgetPropertyChangeHandler (org.csstudio.opibuilder.properties.IWidgetPropertyChangeHandler)61 Rectangle (org.eclipse.draw2d.geometry.Rectangle)42 Point (org.eclipse.draw2d.geometry.Point)36 Dimension (org.eclipse.draw2d.geometry.Dimension)30 PropertyChangeEvent (java.beans.PropertyChangeEvent)25 PropertyChangeListener (java.beans.PropertyChangeListener)25 List (java.util.List)20 Figure (org.eclipse.draw2d.Figure)17 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)13 DefaultSizeNodeFigure (org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure)12 NodeFigure (org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure)12 StackLayout (org.eclipse.draw2d.StackLayout)11 Iterator (java.util.Iterator)10 VType (org.diirt.vtype.VType)10 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)9 OPIColor (org.csstudio.opibuilder.util.OPIColor)9 EditPart (org.eclipse.gef.EditPart)9 ArrayList (java.util.ArrayList)7 Label (org.eclipse.draw2d.Label)7