use of org.eclipse.draw2d.Viewport in project tdi-studio-se by Talend.
the class SearchZoneMapper method moveScrollBarZoneAtSelectedTableItem.
public void moveScrollBarZoneAtSelectedTableItem(Figure entry) {
if (entry != null) {
Rectangle bounds = entry.getBounds();
int selection = bounds.y - 100;
if (entry instanceof XmlmapTreeNodeFigure) {
XmlmapTreeNodeFigure xmlMapTreeNodeFigure = (XmlmapTreeNodeFigure) entry;
TreeNode treeNode = xmlMapTreeNodeFigure.getTreeNode();
if (treeNode != null) {
for (Adapter adapter : treeNode.eAdapters()) {
TreeNodeEditPart part = (TreeNodeEditPart) adapter;
XmlMapDataEditPart xmlMapDataEditPart = part.getMapDataEditPart();
if (adapter instanceof OutputTreeNodeEditPart) {
Viewport viewport = xmlMapDataEditPart.getOutputScroll().getViewport();
viewport.setViewLocation(viewport.getViewLocation().translate(bounds.x, selection));
} else if (adapter instanceof TreeNodeEditPart) {
Viewport viewport = xmlMapDataEditPart.getInputScroll().getViewport();
viewport.setViewLocation(viewport.getViewLocation().translate(bounds.x, selection));
}
}
}
} else if (entry instanceof VarNodeFigure) {
VarNodeFigure varNodeFigure = (VarNodeFigure) entry;
VarNode varNode = varNodeFigure.getVarNode();
if (varNode != null) {
for (Adapter adapter : varNode.eAdapters()) {
VarNodeEditPart part = (VarNodeEditPart) adapter;
XmlMapDataEditPart xmlMapDataEditPart = part.getMapDataEditPart();
Viewport viewport = xmlMapDataEditPart.getVarScroll().getViewport();
viewport.setViewLocation(viewport.getViewLocation().translate(bounds.x, selection));
}
}
}
}
}
use of org.eclipse.draw2d.Viewport in project tdi-studio-se by Talend.
the class TableTreeEntityFigure method collapse.
public void collapse() {
if (!expanded) {
return;
}
IFigure root = this;
Viewport port = null;
Point viewportStart = null;
while (root.getParent() != null) {
if (root instanceof Viewport) {
port = ((Viewport) root);
}
root = root.getParent();
if (port != null) {
break;
}
}
viewportStart = port.getViewLocation();
Point elementStart = getElement().getBounds().getLocation();
setExpanded(false);
root.validate();
setExpanded(true);
animationReset(getElementBounds());
TreeAnimation.mark(getElement());
TreeAnimation.captureLayout(getRoot());
TreeAnimation.swap();
TreeAnimation.trackLocation = elementStart;
// root.validate();
port.setViewLocation(viewportStart);
while (TreeAnimation.step()) {
getUpdateManager().performUpdate();
}
TreeAnimation.end();
setExpanded(false);
}
use of org.eclipse.draw2d.Viewport in project dbeaver by dbeaver.
the class ERDOutlinePage method createControl.
/* (non-Javadoc)
* @see org.eclipse.ui.part.IPage#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createControl(Composite parent) {
// create canvas and lws
overview = new Canvas(parent, SWT.NONE);
LightweightSystem lws = new LightweightSystem(overview);
// create thumbnail
thumbnail = new ScrollableThumbnail((Viewport) rootEditPart.getFigure());
thumbnail.setBorder(new MarginBorder(3));
thumbnail.setSource(rootEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS));
lws.setContents(thumbnail);
}
use of org.eclipse.draw2d.Viewport in project knime-core by knime.
the class WorkflowEditor method getViewportCenterLocation.
/**
* @return a location in the middle of the visible part of the editor. These
* are relative coordinates (to the current scrolling position)
*/
private Point getViewportCenterLocation() {
FigureCanvas ctrl = ((FigureCanvas) getViewer().getControl());
Viewport viewPort = ctrl.getViewport();
Dimension viewSize = viewPort.getSize();
int relX = viewSize.width / 2;
int relY = viewSize.height / 2;
Point nodeLoc = new Point(relX, relY);
// make sure we have a free spot
int stepX = getEditorSnapToGrid() ? getEditorGridXOffset(10) : 10;
int stepY = getEditorSnapToGrid() ? getEditorGridYOffset(10) : 10;
while (isNodeAtRel(nodeLoc)) {
// move it a bit
nodeLoc.x += stepX;
nodeLoc.y += stepY;
}
return nodeLoc;
}
use of org.eclipse.draw2d.Viewport in project knime-core by knime.
the class AddMetaNodeWizard method createMetaNodeFromPorts.
private void createMetaNodeFromPorts(final PortType[] inPorts, final PortType[] outPorts, final String name) {
Viewport viewPort = ((ScalableFreeformRootEditPart) m_wfEditor.getViewer().getRootEditPart()).getZoomManager().getViewport();
// get the currently visible area
Rectangle rect = viewPort.getClientArea();
// translate it to absolute coordinates (with respect to the scrolled
// editor viewer)
viewPort.translateToAbsolute(rect.getLocation());
// now we have an absolute point for the new metanode location
org.eclipse.draw2d.geometry.Point location = new org.eclipse.draw2d.geometry.Point(rect.x + (rect.width / 2), rect.y + (rect.height / 2));
// in order to get a local (relative position we have to substract the
// invisible offset
Point adaptedLoc = new Point(location.x - rect.x, location.y - rect.y);
EditPart ep;
// iterate until we have found a free place on the editor
do {
// we have to use the adaptedLoc (which is the relative position)
ep = m_wfEditor.getViewer().findObjectAt(adaptedLoc);
if (ep instanceof NodeContainerEditPart) {
// offset the absolute location
location.x += ((NodeContainerEditPart) ep).getFigure().getBounds().width;
location.y += ((NodeContainerEditPart) ep).getFigure().getBounds().height;
// offset the relative position
adaptedLoc.x += ((NodeContainerEditPart) ep).getFigure().getBounds().width;
adaptedLoc.y += ((NodeContainerEditPart) ep).getFigure().getBounds().height;
}
} while (ep instanceof NodeContainerEditPart);
AddNewMetaNodeCommand cmd = new AddNewMetaNodeCommand(m_wfEditor.getWorkflowManager().get(), inPorts, outPorts, name, location);
m_wfEditor.getViewer().getEditDomain().getCommandStack().execute(cmd);
}
Aggregations