use of org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart in project statecharts by Yakindu.
the class EditPartUtils method findEditPartForSemanticElement.
@SuppressWarnings("unchecked")
public static IGraphicalEditPart findEditPartForSemanticElement(EditPart editPart, EObject semanticElement) {
if (semanticElement == null) {
return null;
}
if (editPart instanceof IGraphicalEditPart) {
EObject resolveSemanticElement = ((IGraphicalEditPart) editPart).resolveSemanticElement();
if (resolveSemanticElement != null && EcoreUtil.getURI(resolveSemanticElement).equals(EcoreUtil.getURI(semanticElement))) {
return (IGraphicalEditPart) editPart;
}
}
for (Object child : editPart.getChildren()) {
IGraphicalEditPart recursiveEditPart = findEditPartForSemanticElement((EditPart) child, semanticElement);
if (recursiveEditPart != null) {
return recursiveEditPart;
}
}
if (editPart instanceof NodeEditPart) {
List<Connection> connections = new ArrayList<Connection>();
connections.addAll(((NodeEditPart) editPart).getSourceConnections());
connections.addAll(((NodeEditPart) editPart).getTargetConnections());
for (Object connection : connections) {
EObject resolveSemanticElement = ((IGraphicalEditPart) connection).resolveSemanticElement();
if (EcoreUtil.equals(resolveSemanticElement, semanticElement)) {
return (IGraphicalEditPart) connection;
}
}
}
return null;
}
use of org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart in project statecharts by Yakindu.
the class ExtractSubdiagramRefactoring method getActualBounds.
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;
}
use of org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart in project statecharts by Yakindu.
the class InlineSubdiagramHandler method setPreferredSize.
private Object setPreferredSize(ExecutionEvent event) {
IGraphicalEditPart editPart = (IGraphicalEditPart) getFirstElement(HandlerUtil.getCurrentSelection(event));
Command cmd = editPart.getCommand(new SetPreferredSizeRequest(editPart));
AbstractRefactoring.executeCommand(new CommandProxy(cmd), editPart.resolveSemanticElement().eResource());
return null;
}
use of org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart in project statecharts by Yakindu.
the class CompartmentLayoutEditPolicy method getCreateCommand.
@SuppressWarnings("unchecked")
@Override
protected Command getCreateCommand(CreateRequest request) {
if (request instanceof CreateViewAndElementRequest) {
TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
CompositeTransactionalCommand cc = new CompositeTransactionalCommand(editingDomain, DiagramUIMessages.AddCommand_Label);
Iterator<?> descriptors = ((CreateViewRequest) request).getViewDescriptors().iterator();
while (descriptors.hasNext()) {
CreateViewRequest.ViewDescriptor descriptor = (CreateViewRequest.ViewDescriptor) descriptors.next();
int feedBackIndex = getFeedbackIndexFor(request);
// obtain CreateElementRequest and add initial region feedback
// index to request map. This index is needed to add the
// semantic element at the correct listIndex
CreateElementRequest createElementRequest = (CreateElementRequest) ((CreateViewAndElementRequest) request).getViewAndElementDescriptor().getCreateElementRequestAdapter().getAdapter(CreateElementRequest.class);
if (createElementRequest != null) {
createElementRequest.getParameters().put(RequestParameterKeys.RegionFeedbackIndex, feedBackIndex);
}
CreateCommand createCommand = new CompartmentChildCreateCommand(editingDomain, descriptor, (View) (getHost().getModel()), feedBackIndex);
cc.compose(createCommand);
}
return new ICommandProxy(cc.reduce());
}
return null;
}
use of org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart in project statecharts by Yakindu.
the class CompartmentLayoutEditPolicy method createAddCommand.
@Override
protected Command createAddCommand(EditPart child, EditPart after) {
int index = getHost().getChildren().indexOf(after);
TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
AddCommand command = new CompartmentAddCommand(editingDomain, new EObjectAdapter((View) getHost().getModel()), new EObjectAdapter((View) child.getModel()), index);
return new ICommandProxy(command);
}
Aggregations