org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest Java Examples
The following examples show how to use
org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest.
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: ScriptedTaskScriptedTaskOutputVariablesCompartmentEditPart.java From scava with Eclipse Public License 2.0 | 6 votes |
/** * @generated */ public EditPart getTargetEditPart(Request request) { if (request instanceof CreateViewAndElementRequest) { CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor() .getCreateElementRequestAdapter(); IElementType type = (IElementType) adapter.getAdapter(IElementType.class); if (type == CrossflowElementTypes.Field_3003) { return this; } return getParent().getTargetEditPart(request); } if (request instanceof CreateUnspecifiedTypeConnectionRequest) { return getParent().getTargetEditPart(request); } return super.getTargetEditPart(request); }
Example #2
Source File: TypeTypeFieldsCompartmentEditPart.java From scava with Eclipse Public License 2.0 | 6 votes |
/** * @generated */ public EditPart getTargetEditPart(Request request) { if (request instanceof CreateViewAndElementRequest) { CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor() .getCreateElementRequestAdapter(); IElementType type = (IElementType) adapter.getAdapter(IElementType.class); if (type == CrossflowElementTypes.Field_3001) { return this; } return getParent().getTargetEditPart(request); } if (request instanceof CreateUnspecifiedTypeConnectionRequest) { return getParent().getTargetEditPart(request); } return super.getTargetEditPart(request); }
Example #3
Source File: LanguageLanguageParametersCompartmentEditPart.java From scava with Eclipse Public License 2.0 | 6 votes |
/** * @generated */ public EditPart getTargetEditPart(Request request) { if (request instanceof CreateViewAndElementRequest) { CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor() .getCreateElementRequestAdapter(); IElementType type = (IElementType) adapter.getAdapter(IElementType.class); if (type == CrossflowElementTypes.Parameter_3002) { return this; } return getParent().getTargetEditPart(request); } if (request instanceof CreateUnspecifiedTypeConnectionRequest) { return getParent().getTargetEditPart(request); } return super.getTargetEditPart(request); }
Example #4
Source File: TreeLayoutEditPolicy.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override protected Command getCreateCommand(CreateRequest request) { final CompoundCommand cmd = new CompoundCommand(); cmd.add(super.getCreateCommand(request)); if (request instanceof CreateViewAndElementRequest) { final CreateViewAndElementRequest req = (CreateViewAndElementRequest) request; if (shouldUpdateAnnotationsOnCreation(req)) { cmd.add(new ICommandProxy( new UpdateAnnotationsOnCreationCommand(getHost() .getEditingDomain(), req))); } } return cmd; }
Example #5
Source File: ProcBuilder.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private CreateViewAndElementRequest createCreationRequest(final Point location, final Dimension size, final ViewAndElementDescriptor viewDescriptor) { final CreateViewAndElementRequest createRequest = new CreateViewAndElementRequest(viewDescriptor); if (location != null) { createRequest.setLocation(location); } if (size != null) { createRequest.setSize(size); } return createRequest; }
Example #6
Source File: ProcBuilder.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public void addPool(String id, final String name, final String version, final Point location, final Dimension size) throws ProcBuilderException { if (diagramPart == null) { throw new ProcBuilderException("Impossible to add Pool outside a diagram"); } id = NamingUtils.convertToId(id); final ViewAndElementDescriptor viewDescriptor = new ViewAndElementDescriptor(new CreateElementRequestAdapter(new CreateElementRequest( ProcessElementTypes.Pool_2007)), Node.class, ((IHintedType) ProcessElementTypes.Pool_2007).getSemanticHint(), diagramPart.getDiagramPreferencesHint()); final CreateViewAndElementRequest createRequest = createCreationRequest( location, size, viewDescriptor); diagramPart.getDiagramEditDomain().getDiagramCommandStack().execute(diagramPart.getCommand(createRequest)); final Node newNode = (Node) viewDescriptor.getAdapter(Node.class); final Pool pool = (Pool) newNode.getElement(); commandStack.append(SetCommand.create(editingDomain, pool, ProcessPackage.eINSTANCE.getElement_Name(), name)); commandStack.append(SetCommand.create(editingDomain, pool, ProcessPackage.eINSTANCE.getAbstractProcess_Version(), version)); if (size != null) { commandStack.append(SetCommand.create(editingDomain, newNode.getLayoutConstraint(), NotationPackage.eINSTANCE.getSize_Width(), size.width)); commandStack.append(SetCommand.create(editingDomain, newNode.getLayoutConstraint(), NotationPackage.eINSTANCE.getSize_Height(), size.height)); } commandStack.append(SetCommand.create(editingDomain, newNode.getStyle(NotationPackage.eINSTANCE.getLineStyle()), NotationPackage.eINSTANCE.getLineStyle_LineColor(), FigureUtilities.colorToInteger(ColorConstants.lightGray))); processIds.put(pool, id); processes.put(id, pool); currentContainer = pool; currentStep = pool; currentElement = pool; currentView = newNode; execute(); }
Example #7
Source File: ExtractAsCallActivityTransactionalCommand.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected DeferredSetValueCommand createSetCommand(final CreateViewAndElementRequest req, EStructuralFeature feature, Object value, EObject anEObjectInSameDomain) { return new DeferredSetValueCommand(new SetRequest( anEObjectInSameDomain, feature, value)) { @Override public EObject getElementToEdit() { return (EObject) req.getViewAndElementDescriptor().getElementAdapter().getAdapter(EObject.class); } }; }
Example #8
Source File: MoveItemsAndCopyDataCommand.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @param req * @param subprocessDescriptor * @param parts */ public MoveItemsAndCopyDataCommand(final TransactionalEditingDomain domain, final CreateViewAndElementRequest req, final ViewAndElementDescriptor subprocessDescriptor, final List<IGraphicalEditPart> parts) { super(domain, "Move items", getWorkspaceFiles(parts.get(0).resolveSemanticElement())); this.req = req; this.parts = parts; this.subprocessDescriptor = subprocessDescriptor; }
Example #9
Source File: ScriptedTaskEditPart.java From scava with Eclipse Public License 2.0 | 5 votes |
/** * @generated */ public EditPart getTargetEditPart(Request request) { if (request instanceof CreateViewAndElementRequest) { CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor() .getCreateElementRequestAdapter(); IElementType type = (IElementType) adapter.getAdapter(IElementType.class); if (type == CrossflowElementTypes.Field_3003) { return getChildBySemanticHint(CrossflowVisualIDRegistry .getType(ScriptedTaskScriptedTaskOutputVariablesCompartmentEditPart.VISUAL_ID)); } } return super.getTargetEditPart(request); }
Example #10
Source File: CompartmentCreationEditPolicy.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override protected Command getCreateElementAndViewCommand( CreateViewAndElementRequest request) { String semanticHint = request.getViewAndElementDescriptor() .getSemanticHint(); if (fixedSizeElements.contains(semanticHint)) request.setSize(new Dimension(-1, -1)); return super.getCreateElementAndViewCommand(request); }
Example #11
Source File: StateEditPart.java From statecharts with Eclipse Public License 1.0 | 5 votes |
/** * Delegates all {@link CreateViewAndElementRequest}s to the figure compartment. */ @Override public EditPart getTargetEditPart(Request request) { if (request instanceof CreateViewAndElementRequest) { return figureCompartmentEditPart; } if (request instanceof GroupRequest && request.getType() == RequestConstants.REQ_DROP) { GroupRequest req = (GroupRequest) request; if (areInsertableChildren(req.getEditParts())) { return figureCompartmentEditPart; } } return super.getTargetEditPart(request); }
Example #12
Source File: LanguageEditPart.java From scava with Eclipse Public License 2.0 | 5 votes |
/** * @generated */ public EditPart getTargetEditPart(Request request) { if (request instanceof CreateViewAndElementRequest) { CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor() .getCreateElementRequestAdapter(); IElementType type = (IElementType) adapter.getAdapter(IElementType.class); if (type == CrossflowElementTypes.Parameter_3002) { return getChildBySemanticHint( CrossflowVisualIDRegistry.getType(LanguageLanguageParametersCompartmentEditPart.VISUAL_ID)); } } return super.getTargetEditPart(request); }
Example #13
Source File: TypeEditPart.java From scava with Eclipse Public License 2.0 | 5 votes |
/** * @generated */ public EditPart getTargetEditPart(Request request) { if (request instanceof CreateViewAndElementRequest) { CreateElementRequestAdapter adapter = ((CreateViewAndElementRequest) request).getViewAndElementDescriptor() .getCreateElementRequestAdapter(); IElementType type = (IElementType) adapter.getAdapter(IElementType.class); if (type == CrossflowElementTypes.Field_3001) { return getChildBySemanticHint( CrossflowVisualIDRegistry.getType(TypeTypeFieldsCompartmentEditPart.VISUAL_ID)); } } return super.getTargetEditPart(request); }
Example #14
Source File: UpdateAnnotationsOnCreationCommand.java From statecharts with Eclipse Public License 1.0 | 4 votes |
public UpdateAnnotationsOnCreationCommand( TransactionalEditingDomain domain, CreateViewAndElementRequest request) { super(domain, "Update Annotations On Creation", null); this.request = request; }
Example #15
Source File: CompartmentLayoutEditPolicy.java From statecharts with Eclipse Public License 1.0 | 4 votes |
@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; }
Example #16
Source File: TreeLayoutEditPolicy.java From statecharts with Eclipse Public License 1.0 | 4 votes |
protected boolean shouldUpdateAnnotationsOnCreation( CreateViewAndElementRequest request) { return true; }
Example #17
Source File: SequenceFlowCreationEditPolicy.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override protected Command getCreateElementAndViewCommand( CreateViewAndElementRequest request) { return containerEp.getCommand(request); }
Example #18
Source File: ProcBuilder.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override public void addLane(String id, final String name, final Dimension size) throws ProcBuilderException { id = NamingUtils.convertToId(id); if (currentContainer instanceof Lane) { currentContainer = currentContainer.eContainer(); } final EReference containmentFeature = ProcessPackage.Literals.CONTAINER__ELEMENTS; final ViewAndElementDescriptor descriptor = new ViewAndElementDescriptor(new CreateElementRequestAdapter( new CreateElementRequest( editingDomain, currentContainer, ProcessElementTypes.Lane_3007, containmentFeature) ), Node.class, ((IHintedType) ProcessElementTypes.Lane_3007).getSemanticHint(), diagramPart.getDiagramPreferencesHint()); final CreateViewAndElementRequest request = new CreateViewAndElementRequest(descriptor); if (size != null) { request.setSize(size); } diagramPart.refresh(); final IGraphicalEditPart parentEditPart = GMFTools.findEditPart(diagramPart, currentContainer); final IGraphicalEditPart compartment = retrieveCompartmentEditPartFor(parentEditPart); diagramPart.getDiagramEditDomain().getDiagramCommandStack().execute(compartment.getCommand(request)); compartment.refresh(); final Node newNode = (Node) descriptor.getAdapter(Node.class); final Lane lane = (Lane) newNode.getElement(); commandStack.append(SetCommand.create(editingDomain, lane, ProcessPackage.eINSTANCE.getElement_Name(), name)); if (size != null) { commandStack.append(SetCommand.create(editingDomain, newNode.getLayoutConstraint(), NotationPackage.eINSTANCE.getSize_Width(), size.width)); commandStack.append(SetCommand.create(editingDomain, newNode.getLayoutConstraint(), NotationPackage.eINSTANCE.getSize_Height(), size.height)); } commandStack.append(SetCommand.create(editingDomain, newNode.getStyle(NotationPackage.eINSTANCE.getLineStyle()), NotationPackage.eINSTANCE.getLineStyle_LineColor(), FigureUtilities.colorToInteger(ColorConstants.lightGray))); lanes.put(id, lane); currentContainer = lane; currentStep = lane; currentElement = lane; currentAssignable = lane; currentView = newNode; execute(); }
Example #19
Source File: ProcBuilder.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
private Element createShape(final String id, final EObject container, final Point location, final Dimension size, final IElementType type, final boolean isCollapsed) throws ProcBuilderException { diagramPart.refresh(); final IGraphicalEditPart parentEditPart = GMFTools.findEditPart(diagramPart, container); final IGraphicalEditPart compartment = retrieveCompartmentEditPartFor(parentEditPart); if (compartment instanceof LaneLaneCompartmentEditPart) { int laneHeightOffset = 0; final PoolPoolCompartmentEditPart poolCompartment = (PoolPoolCompartmentEditPart) compartment.getParent().getParent(); final int currentLaneIndex = ((Container) currentContainer.eContainer()).getElements().indexOf(currentContainer); if (currentLaneIndex > 0) { for (final Object object : poolCompartment.getChildren()) { if (object instanceof LaneEditPart) { final EObject semanticElement = ((LaneEditPart) object).resolveSemanticElement(); final int laneIndex = ((Container) currentContainer.eContainer()).getElements().indexOf(semanticElement); if (laneIndex < currentLaneIndex) { laneHeightOffset = laneHeightOffset + ((LaneEditPart) object).getFigure().getSize().height; } } } } if (laneHeightOffset != 0 && laneHeightOffset + 80 > location.y) { location.y = location.y + laneHeightOffset + 20; } } final PreferencesHint hint = diagramPart.getDiagramPreferencesHint(); final PreferenceStore store = (PreferenceStore) hint.getPreferenceStore(); store.setValue("isCollapsed", isCollapsed); final ViewAndElementDescriptor viewDescriptor = new ViewAndElementDescriptor(new CreateElementRequestAdapter(new CreateElementRequest(type)), Node.class, ((IHintedType) type).getSemanticHint(), hint); final CreateViewAndElementRequest createRequest = createCreationRequest(location, size, viewDescriptor); if (container == null || !(container instanceof Element)) { throw new ProcBuilderException("Impossible to find the parent EditPart"); } diagramPart.getDiagramEditDomain().getDiagramCommandStack().execute(compartment.getCommand(createRequest)); compartment.refresh(); final Node newNode = (Node) viewDescriptor.getAdapter(Node.class); if (newNode == null) { throw new ProcBuilderException("New element not created"); } currentView = newNode; final Element createdElement = (Element) newNode.getElement(); final ShapeNodeEditPart nodeEditPart = (ShapeNodeEditPart) GMFTools.findEditPart(diagramPart, createdElement); if (nodeEditPart == null) { throw new ProcBuilderException("New edit part not created"); } editParts.put(id, nodeEditPart); return createdElement; }
Example #20
Source File: ProcBuilder.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override public void addAnnotation(final String text, final Point location, final Dimension size, final String sourceId) throws ProcBuilderException { final ViewAndElementDescriptor viewDescriptor = new ViewAndElementDescriptor(new CreateElementRequestAdapter(new CreateElementRequest( ProcessElementTypes.TextAnnotation_3015)), Node.class, ((IHintedType) ProcessElementTypes.TextAnnotation_3015).getSemanticHint(), diagramPart.getDiagramPreferencesHint()); final CreateViewAndElementRequest createRequest = createCreationRequest( location, size, viewDescriptor); IGraphicalEditPart parentEditPart = null; boolean sourceCanBeProcessed = false; if (sourceId != null) { Element sourceElement = (Element) steps.get(NamingUtils.convertToId(sourceId)); if (sourceElement == null) { if (currentContainer == null || !(currentContainer instanceof Element)) { throw new ProcBuilderException("Impossible to find the parent EditPart"); } diagramPart.refresh(); parentEditPart = GMFTools.findEditPart(diagramPart, currentContainer); } else { while (sourceElement != null && !(sourceElement instanceof Container)) { sourceElement = (Element) sourceElement.eContainer(); } sourceCanBeProcessed = true; parentEditPart = GMFTools.findEditPart(diagramPart, sourceElement); } } else { if (currentContainer == null || !(currentContainer instanceof Element)) { throw new ProcBuilderException("Impossible to find the parent EditPart"); } diagramPart.refresh(); parentEditPart = GMFTools.findEditPart(diagramPart, currentContainer); } final IGraphicalEditPart compartment = retrieveCompartmentEditPartFor(parentEditPart); diagramPart.getDiagramEditDomain().getDiagramCommandStack().execute(compartment.getCommand(createRequest)); compartment.refresh(); final Node newNode = (Node) viewDescriptor.getAdapter(Node.class); if (newNode == null) { throw new ProcBuilderException("New elment not created"); } currentView = newNode; final TextAnnotation createdElement = (TextAnnotation) newNode.getElement(); commandStack.append(SetCommand.create(editingDomain, createdElement, ProcessPackage.eINSTANCE.getTextAnnotation_Text(), text)); if (sourceId != null && sourceCanBeProcessed) { createLinkBetweenTextAnnotationAndSourceEditPart(sourceId, createdElement); } execute(); }