use of org.eclipse.draw2d.PolylineConnection in project cubrid-manager by CUBRID.
the class ERGraphLayoutVisitor method setFigureConstraint.
private void setFigureConstraint(RelationshipPart relationshipPart) {
Edge edge = (Edge) partNodesMap.get(relationshipPart);
if (edge == null) {
return;
}
PolylineConnection conn = (PolylineConnection) relationshipPart.getConnectionFigure();
conn.setRoutingConstraint(Collections.EMPTY_LIST);
}
use of org.eclipse.draw2d.PolylineConnection in project cubrid-manager by CUBRID.
the class BrokerConnectionPart method refreshVisuals.
/**
* refresh Visuals
*/
protected void refreshVisuals() {
PolylineConnection conn = (PolylineConnection) getFigure();
HANodeConnection model = (HANodeConnection) getModel();
//BrokerDBListNode linewith should be 1.
if (model.getTarget() instanceof BrokerDBListNode) {
conn.setLineWidth(1);
}
BrokerNode broker = null;
if (model.getSource() instanceof BrokerNode) {
broker = (BrokerNode) model.getSource();
} else if (model.getTarget() instanceof BrokerNode) {
broker = (BrokerNode) model.getTarget();
}
if (broker != null) {
if (broker.getParent().isConnected()) {
conn.setForegroundColor(CONNECTION_DEFAULT_COLOR);
} else {
conn.setForegroundColor(AbstractMonitorFigure.DISABLED_COLOR);
}
}
super.refreshVisuals();
}
use of org.eclipse.draw2d.PolylineConnection in project cubrid-manager by CUBRID.
the class BrokerConnectionPart method createFigure.
/**
* create figure used by edit part.
*
* @return IFigure connectin figure
*/
protected IFigure createFigure() {
PolylineConnection conn = new PolylineConnection();
conn.setTargetDecoration(new PolygonDecoration());
conn.setConnectionRouter(new ManhattanConnectionRouter());
conn.setForegroundColor(CONNECTION_DEFAULT_COLOR);
conn.setLineWidth(3);
return conn;
}
use of org.eclipse.draw2d.PolylineConnection in project cubrid-manager by CUBRID.
the class ConnectionPart method createFigure.
/**
* @see org.eclipse.gef.editparts.AbstractConnectionEditPart#createFigure()
* @return conn
*/
protected IFigure createFigure() {
PolylineConnection conn = new PolylineConnection();
conn.setTargetDecoration(new PolygonDecoration());
conn.setConnectionRouter(new BendpointConnectionRouter());
return conn;
}
use of org.eclipse.draw2d.PolylineConnection in project tdi-studio-se by Talend.
the class ComponentChooseDialog method dragOver.
@Override
public void dragOver(DropTargetEvent event) {
// multi-drag for job,context, sqlPattern.
IStructuredSelection selection = getSelection();
if (selection.size() > 1) {
boolean allowed = true;
Item temItem = null;
Iterator iter = selection.iterator();
while (iter.hasNext()) {
Object next = iter.next();
if (next instanceof RepositoryNode) {
RepositoryNode sourceNode = (RepositoryNode) next;
IRepositoryViewObject object = sourceNode.getObject();
if (object != null) {
Item selectItem = object.getProperty().getItem();
if (temItem == null) {
temItem = selectItem;
continue;
}
if (selectItem instanceof ProcessItem && !(temItem instanceof ProcessItem)) {
allowed = false;
} else if (selectItem instanceof ContextItem && !(temItem instanceof ContextItem)) {
allowed = false;
} else if (selectItem instanceof SQLPatternItem && !(temItem instanceof SQLPatternItem)) {
allowed = false;
}
}
}
}
if (!allowed) {
event.detail = DND.DROP_NONE;
}
} else {
CreateRequest req = ((CreateRequest) getTargetRequest());
Object o = null;
try {
o = req.getNewObject();
} catch (Exception e) {
return;
}
if (!(o instanceof Node)) {
return;
}
RootEditPart rep = editor.getViewer().getRootEditPart().getRoot();
Point viewOriginalPosition = new Point();
if (rep instanceof ScalableFreeformRootEditPart) {
ScalableFreeformRootEditPart root = (ScalableFreeformRootEditPart) rep;
Viewport viewport = (Viewport) root.getFigure();
viewOriginalPosition = viewport.getViewLocation();
}
org.eclipse.swt.graphics.Point swtLocation = new org.eclipse.swt.graphics.Point(event.x + viewOriginalPosition.x, event.y + viewOriginalPosition.y);
Canvas canvas = (Canvas) editor.getViewer().getControl();
swtLocation = canvas.toControl(swtLocation);
// System.out.println("topLeft:" + topLeftpoint + " / event:" + swtLocation);
org.eclipse.draw2d.geometry.Point draw2dPosition = new org.eclipse.draw2d.geometry.Point(swtLocation.x, swtLocation.y);
double zoom = 1.0;
if (editor.getViewer().getRootEditPart() instanceof TalendScalableFreeformRootEditPart) {
ZoomManager zoomManager = ((TalendScalableFreeformRootEditPart) editor.getViewer().getRootEditPart()).getZoomManager();
zoom = zoomManager.getZoom();
}
List<ConnectionPart> connectionParts = CreateComponentOnLinkHelper.getConnectionParts(editor.getProcessPart(), draw2dPosition, (Node) o);
double minDistance = 1000000000;
for (ConnectionPart part : connectionParts) {
if (part.getFigure() instanceof PolylineConnection) {
PolylineConnection connection = (PolylineConnection) part.getFigure();
double distance = CreateComponentOnLinkHelper.getDistanceOrthogonal(draw2dPosition.x, draw2dPosition.y, connection, zoom);
if (distance < minDistance) {
selectedConnectionPart = part;
minDistance = Math.min(distance, minDistance);
}
}
}
if (selectedConnectionPart != null && minDistance < 15) {
for (Object child : editor.getProcessPart().getChildren()) {
if (child instanceof SubjobContainerPart) {
CreateComponentOnLinkHelper.unselectAllConnections((SubjobContainerPart) child);
}
}
CreateComponentOnLinkHelper.selectConnection(selectedConnectionPart);
} else {
if (selectedConnectionPart != null) {
CreateComponentOnLinkHelper.unselectConnection(selectedConnectionPart);
}
selectedConnectionPart = null;
}
}
}
Aggregations