org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer Java Examples

The following examples show how to use org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CrossflowDiagramEditorUtil.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
private static int findElementsInDiagramByID(DiagramEditPart diagramPart, EObject element,
		List<EditPart> editPartCollector) {
	IDiagramGraphicalViewer viewer = (IDiagramGraphicalViewer) diagramPart.getViewer();
	final int intialNumOfEditParts = editPartCollector.size();

	if (element instanceof View) { // support notation element lookup
		EditPart editPart = (EditPart) viewer.getEditPartRegistry().get(element);
		if (editPart != null) {
			editPartCollector.add(editPart);
			return 1;
		}
	}

	String elementID = EMFCoreUtil.getProxyID(element);
	@SuppressWarnings("unchecked")
	List<EditPart> associatedParts = viewer.findEditPartsForElement(elementID, IGraphicalEditPart.class);
	// perform the possible hierarchy disjoint -> take the top-most parts only
	for (EditPart nextPart : associatedParts) {
		EditPart parentPart = nextPart.getParent();
		while (parentPart != null && !associatedParts.contains(parentPart)) {
			parentPart = parentPart.getParent();
		}
		if (parentPart == null) {
			editPartCollector.add(nextPart);
		}
	}

	if (intialNumOfEditParts == editPartCollector.size()) {
		if (!associatedParts.isEmpty()) {
			editPartCollector.add(associatedParts.get(0));
		} else {
			if (element.eContainer() != null) {
				return findElementsInDiagramByID(diagramPart, element.eContainer(), editPartCollector);
			}
		}
	}
	return editPartCollector.size() - intialNumOfEditParts;
}
 
Example #2
Source File: ExtractSubdiagramRefactoring.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected Rectangle getActualBounds(Node child) {
	IEditorPart lastActiveEditor = ActiveEditorTracker.getLastActiveEditor();
	if (lastActiveEditor instanceof StatechartDiagramEditor) {
		IDiagramGraphicalViewer viewer = ((StatechartDiagramEditor) lastActiveEditor).getDiagramGraphicalViewer();
		IGraphicalEditPart editPart = (IGraphicalEditPart) viewer.getEditPartRegistry().get(child);
		return editPart.getFigure().getBounds();
	}
	return Rectangle.SINGLETON;
}
 
Example #3
Source File: MultipleShapesHorizontalMoveTool.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the current location without the zoom.
 */
protected int getCurrentPositionZoomed() {
	Point pt = getLocation();
	((IGraphicalEditPart) ((IDiagramGraphicalViewer) 
			getCurrentViewer()).getRootEditPart().
			getChildren().get(0)).getFigure().translateToRelative(pt);
	return  pt.x;
}
 
Example #4
Source File: MultipleShapesVerticalMoveTool.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @return the current location without the zoom.
 */
protected int getCurrentPositionZoomed() {
	Point pt = getLocation();
	((IGraphicalEditPart) ((IDiagramGraphicalViewer) 
			getCurrentViewer()).getRootEditPart().
			getChildren().get(0)).getFigure().translateToRelative(pt);
	return  pt.y;
}
 
Example #5
Source File: ProcessDiagramEditorUtil.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
private static int findElementsInDiagramByID(DiagramEditPart diagramPart, EObject element,
		List<EditPart> editPartCollector) {
	IDiagramGraphicalViewer viewer = (IDiagramGraphicalViewer) diagramPart.getViewer();
	final int intialNumOfEditParts = editPartCollector.size();

	if (element instanceof View) { // support notation element lookup
		EditPart editPart = (EditPart) viewer.getEditPartRegistry().get(element);
		if (editPart != null) {
			editPartCollector.add(editPart);
			return 1;
		}
	}

	String elementID = EMFCoreUtil.getProxyID(element);
	@SuppressWarnings("unchecked")
	List<EditPart> associatedParts = viewer.findEditPartsForElement(elementID, IGraphicalEditPart.class);
	// perform the possible hierarchy disjoint -> take the top-most parts only
	for (EditPart nextPart : associatedParts) {
		EditPart parentPart = nextPart.getParent();
		while (parentPart != null && !associatedParts.contains(parentPart)) {
			parentPart = parentPart.getParent();
		}
		if (parentPart == null) {
			editPartCollector.add(nextPart);
		}
	}

	if (intialNumOfEditParts == editPartCollector.size()) {
		if (!associatedParts.isEmpty()) {
			editPartCollector.add(associatedParts.get(0));
		} else {
			if (element.eContainer() != null) {
				return findElementsInDiagramByID(diagramPart, element.eContainer(), editPartCollector);
			}
		}
	}
	return editPartCollector.size() - intialNumOfEditParts;
}
 
Example #6
Source File: TabbedPropertySynchronizerListener.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private void updateDiagramSelection(final DiagramEditor diagramEditor, final IGraphicalEditPart editPart) {
    final IDiagramGraphicalViewer diagramGraphicalViewer = diagramEditor.getDiagramGraphicalViewer();
    diagramGraphicalViewer.select(editPart);
    diagramGraphicalViewer.reveal(editPart);
    diagramGraphicalViewer.getControl().getDisplay().asyncExec(new RefreshPropertyViewsSelection(diagramEditor, new StructuredSelection(editPart)));
}