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