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

The following examples show how to use org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart. 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 6 votes vote down vote up
/**
* @generated
*/
public static void selectElementsInDiagram(IDiagramWorkbenchPart diagramPart, List<EditPart> editParts) {
	diagramPart.getDiagramGraphicalViewer().deselectAll();

	EditPart firstPrimary = null;
	for (EditPart nextPart : editParts) {
		diagramPart.getDiagramGraphicalViewer().appendSelection(nextPart);
		if (firstPrimary == null && nextPart instanceof IPrimaryEditPart) {
			firstPrimary = nextPart;
		}
	}

	if (!editParts.isEmpty()) {
		diagramPart.getDiagramGraphicalViewer()
				.reveal(firstPrimary != null ? firstPrimary : (EditPart) editParts.get(0));
	}
}
 
Example #2
Source File: ValidateAction.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
public void run() {
	IWorkbenchPart workbenchPart = page.getActivePart();
	if (workbenchPart instanceof IDiagramWorkbenchPart) {
		final IDiagramWorkbenchPart part = (IDiagramWorkbenchPart) workbenchPart;
		try {
			new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() {

				public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
					runValidation(part.getDiagramEditPart(), part.getDiagram());
				}
			}).run(new NullProgressMonitor());
		} catch (Exception e) {
			CrossflowDiagramEditorPlugin.getInstance().logError("Validation action failed", e); //$NON-NLS-1$
		}
	}
}
 
Example #3
Source File: ValidateAction.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
public static void runValidation(View view) {
	try {
		if (CrossflowDiagramEditorUtil.openDiagram(view.eResource())) {
			IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
					.getActiveEditor();
			if (editorPart instanceof IDiagramWorkbenchPart) {
				runValidation(((IDiagramWorkbenchPart) editorPart).getDiagramEditPart(), view);
			} else {
				runNonUIValidation(view);
			}
		}
	} catch (Exception e) {
		CrossflowDiagramEditorPlugin.getInstance().logError("Validation action failed", e); //$NON-NLS-1$
	}
}
 
Example #4
Source File: DiagramPartitioningUtil.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
public static void selectElementsInDiagram(IDiagramWorkbenchPart diagramPart, List<EditPart> editParts) {
	diagramPart.getDiagramGraphicalViewer().deselectAll();

	EditPart firstPrimary = null;
	for (Iterator<EditPart> it = editParts.iterator(); it.hasNext();) {
		EditPart nextPart = it.next();
		if (nextPart.isSelectable()) {
			diagramPart.getDiagramGraphicalViewer().appendSelection(nextPart);
		}
		if (firstPrimary == null && nextPart instanceof IPrimaryEditPart) {
			firstPrimary = nextPart;
		}
	}
	if (!editParts.isEmpty()) {
		diagramPart.getDiagramGraphicalViewer()
				.reveal(firstPrimary != null ? firstPrimary : (EditPart) editParts.get(0));
	}
}
 
Example #5
Source File: CustomClipboardSupportGlobalActionHandler.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean canHandle(final IGlobalActionContext cntxt) {

	/* Check if the active part is a IDiagramWorkbenchPart */
	final IWorkbenchPart part = cntxt.getActivePart();
	if (!(part instanceof IDiagramWorkbenchPart)) {
		return false;
	}

	/* Check if the selection is a structured selection */
	if (!(cntxt.getSelection() instanceof IStructuredSelection)) {
		return false;
	}

	/* Check the action id */
	final String actionId = cntxt.getActionId();
	if (actionId.equals(GlobalActionId.COPY)) {
		return canCopy(cntxt);
	} else if (actionId.equals(GlobalActionId.CUT)) {
		return canCut(cntxt);
	} else if (actionId.equals(GlobalActionId.PASTE)) {
		return canPaste(cntxt);
       } else {
           return super.canHandle(cntxt);
       }
}
 
Example #6
Source File: ValidateAction.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @generated
*/
public void run() {
	IWorkbenchPart workbenchPart = page.getActivePart();
	if (workbenchPart instanceof IDiagramWorkbenchPart) {
		final IDiagramWorkbenchPart part = (IDiagramWorkbenchPart) workbenchPart;
		try {
			new WorkspaceModifyDelegatingOperation(new IRunnableWithProgress() {

				public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
					runValidation(part.getDiagramEditPart(), part.getDiagram());
				}
			}).run(new NullProgressMonitor());
		} catch (Exception e) {
			ProcessDiagramEditorPlugin.getInstance().logError("Validation action failed", e); //$NON-NLS-1$
		}
	}
}
 
Example #7
Source File: ValidateAction.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @generated
*/
public static void runValidation(View view) {
	try {
		if (ProcessDiagramEditorUtil.openDiagram(view.eResource())) {
			IEditorPart editorPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
					.getActiveEditor();
			if (editorPart instanceof IDiagramWorkbenchPart) {
				runValidation(((IDiagramWorkbenchPart) editorPart).getDiagramEditPart(), view);
			} else {
				runNonUIValidation(view);
			}
		}
	} catch (Exception e) {
		ProcessDiagramEditorPlugin.getInstance().logError("Validation action failed", e); //$NON-NLS-1$
	}
}
 
Example #8
Source File: ProcessDiagramEditorUtil.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @generated
*/
public static void selectElementsInDiagram(IDiagramWorkbenchPart diagramPart, List<EditPart> editParts) {
	diagramPart.getDiagramGraphicalViewer().deselectAll();

	EditPart firstPrimary = null;
	for (EditPart nextPart : editParts) {
		diagramPart.getDiagramGraphicalViewer().appendSelection(nextPart);
		if (firstPrimary == null && nextPart instanceof IPrimaryEditPart) {
			firstPrimary = nextPart;
		}
	}

	if (!editParts.isEmpty()) {
		diagramPart.getDiagramGraphicalViewer()
				.reveal(firstPrimary != null ? firstPrimary : (EditPart) editParts.get(0));
	}
}
 
Example #9
Source File: DiagramElementsModifierTest.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @return The Active {@link DiagramEditPart}
 */
protected DiagramEditPart getDiagramEditPart() {
	IEditorPart ied = editor.getActiveEditor();
	DiagramEditPart diagEp = ((IDiagramWorkbenchPart) ied)
			.getDiagramEditPart();
	return diagEp;

}
 
Example #10
Source File: PapyrusModifier.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the active Edit Part
 * @return The active DiagramEditPart 
 */
public DiagramEditPart getActiveDiagramEditPart(){
	IEditorPart ied = editor.getActiveEditor();
	if(ied instanceof IDiagramWorkbenchPart){
		return ((IDiagramWorkbenchPart) ied).getDiagramEditPart();
	}else{
		return null;
	}
}
 
Example #11
Source File: BonitaRulerGridPropertySection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initializes the preferenceStore property change
 * listener.
 */
private void initWorkspacePropertyListener() {
	IDiagramWorkbenchPart editor = (IDiagramWorkbenchPart) getPart();
	if (editor == null) return;
	DiagramGraphicalViewer viewer = (DiagramGraphicalViewer) editor.getDiagramGraphicalViewer();
	workspaceViewerProperties = viewer.getWorkspaceViewerPreferenceStore();
	workspaceViewerProperties.addPropertyChangeListener(propertyListener);
}
 
Example #12
Source File: HighlightingSupportAdapter.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
public HighlightingSupportAdapter(IDiagramWorkbenchPart diagramWorkbenchPart) {
	this.diagramWorkbenchPart = diagramWorkbenchPart;
}
 
Example #13
Source File: CustomClipboardSupportGlobalActionHandler.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected org.eclipse.gmf.runtime.common.core.command.ICommand getCopyCommand(final IGlobalActionContext cntxt,
		final IDiagramWorkbenchPart diagramPart, final boolean isUndoable) {

	return new CustomCopyCommand("Copy", getSelectedEditParts(cntxt));
}
 
Example #14
Source File: CustomClipboardSupportGlobalActionHandler.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
   protected org.eclipse.gmf.runtime.common.core.command.ICommand getCutCommand(final IGlobalActionContext cntxt,
		final IDiagramWorkbenchPart diagramPart) {
	return new CustomCutCommand("Cut", getSelectedEditParts(cntxt));
}
 
Example #15
Source File: BonitaRulerGridPropertySection.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private IPreferenceStore getPreferenceStore() {
	IPreferenceStore preferenceStore =
		(IPreferenceStore) ((IDiagramWorkbenchPart) getPart()).getDiagramEditPart().getDiagramPreferencesHint().getPreferenceStore();
	return preferenceStore;
}
 
Example #16
Source File: CustomClipboardSupportGlobalActionHandler.java    From bonita-studio with GNU General Public License v2.0 2 votes vote down vote up
private org.eclipse.gmf.runtime.common.core.command.ICommand getPasteCommand(final IGlobalActionContext cntxt, final IDiagramWorkbenchPart diagramPart) {
	return new CustomPasteCommand("Paste", getSelectedEditParts(cntxt).get(0));

}