public Rectangle getBounds() { View view = this.getNotationView(); int width = ((Integer) getStructuralFeatureValue(view, NotationPackage.eINSTANCE.getSize_Width())) .intValue(); int height = ((Integer) getStructuralFeatureValue(view, NotationPackage.eINSTANCE.getSize_Height())) .intValue(); int x = ((Integer) getStructuralFeatureValue(view, NotationPackage.eINSTANCE.getLocation_X())) .intValue(); int y = ((Integer) getStructuralFeatureValue(view, NotationPackage.eINSTANCE.getLocation_Y())) .intValue(); String prefElementId = ViewUtil.resolveSemanticElement(view).eClass().getName(); IPreferenceStore store = UMLDiagramEditorPlugin.getInstance().getPreferenceStore(); String preferenceConstantWitdh = PreferenceInitializerForElementHelper.getpreferenceKey( view, prefElementId, PreferencesConstantsHelper.WIDTH); String preferenceConstantHeight = PreferenceInitializerForElementHelper.getpreferenceKey( view, prefElementId, PreferencesConstantsHelper.HEIGHT); if (width <= 0) { width = store.getInt(preferenceConstantWitdh); } if (height <= 0) { height = store.getInt(preferenceConstantHeight); } return new Rectangle(x, y, width, height); }
/** @generated */ protected Command getSemanticCommand(IEditCommandRequest request) { IEditCommandRequest completedRequest = completeRequest(request); Object editHelperContext = completedRequest.getEditHelperContext(); if (editHelperContext instanceof View || (editHelperContext instanceof IEditHelperContext && ((IEditHelperContext) editHelperContext).getEObject() instanceof View)) { // no semantic commands are provided for pure design elements return null; } if (editHelperContext == null) { editHelperContext = ViewUtil.resolveSemanticElement((View) getHost().getModel()); } IElementType elementType = ElementTypeRegistry.getInstance().getElementType(editHelperContext); if (elementType == ElementTypeRegistry.getInstance() .getType("org.eclipse.gmf.runtime.emf.type.core.default")) { // $NON-NLS-1$ elementType = null; } Command semanticCommand = getSemanticCommandSwitch(completedRequest); if (elementType != null) { if (semanticCommand != null) { ICommand command = semanticCommand instanceof ICommandProxy ? ((ICommandProxy) semanticCommand).getICommand() : new CommandProxy(semanticCommand); completedRequest.setParameter( FlowDesigner.diagram.edit.helpers.FlowDesignerBaseEditHelper.EDIT_POLICY_COMMAND, command); } ICommand command = elementType.getEditCommand(completedRequest); if (command != null) { if (!(command instanceof CompositeTransactionalCommand)) { TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); command = new CompositeTransactionalCommand(editingDomain, command.getLabel()).compose(command); } semanticCommand = new ICommandProxy(command); } } boolean shouldProceed = true; if (completedRequest instanceof DestroyRequest) { shouldProceed = shouldProceed((DestroyRequest) completedRequest); } if (shouldProceed) { if (completedRequest instanceof DestroyRequest) { TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain(); Command deleteViewCommand = new ICommandProxy(new DeleteCommand(editingDomain, (View) getHost().getModel())); semanticCommand = semanticCommand == null ? deleteViewCommand : semanticCommand.chain(deleteViewCommand); } return semanticCommand; } return null; }
public int getViewChildrenSize() { int count = 0; Lifeline lifeline = ((Lifeline) getParentEditPart().getNotationView().getElement()); EList children = getParentEditPart().getNotationView().getChildren(); for (Object object : children) { View view = (View) object; if (lifeline != ViewUtil.resolveSemanticElement(view)) { count++; } } return count; }
private Float getPosition(InteractionFragment fragment) { if (fragment == null) { return null; } View view = getGraphicalView(fragment); if (view == null) { return null; } Float[] preferPosition = cachePositions != null ? cachePositions.get(view) : null; EObject hostElement = ViewUtil.resolveSemanticElement(view); EditPart editPart = DiagramEditPartsUtil.getEditPartFromView(view, fragmentRootEditPart); if (fragment instanceof MessageOccurrenceSpecification && hostElement instanceof Message && editPart instanceof ConnectionNodeEditPart) { boolean isStart = fragment == ((Message) hostElement).getSendEvent(); Point location = getAbsoluteEdgeExtremity((ConnectionNodeEditPart) editPart, isStart, preferPosition); if (location != null) { return isStart ? location.y - HALF_UNIT : location.y + HALF_UNIT; } } else if (fragment instanceof ExecutionOccurrenceSpecification && hostElement instanceof ExecutionSpecification && editPart instanceof IGraphicalEditPart) { Rectangle bounds = getAbsoluteBounds((IGraphicalEditPart) editPart, preferPosition); if (bounds != null) { if (bounds.height <= 0) { bounds.height = 50; // LifelineXYLayoutEditPolicy.EXECUTION_INIT_HEIGHT; } if (fragment == ((ExecutionSpecification) hostElement).getStart()) { return bounds.y - HALF_UNIT; } else { return bounds.bottom() + HALF_UNIT; } } } else if (view instanceof Shape && editPart instanceof IGraphicalEditPart) { Rectangle bounds = getAbsoluteBounds((IGraphicalEditPart) editPart, preferPosition); if (bounds != null) { return bounds.y * CONVERT_UNIT; } } return null; }
/** @generated */ protected EObject getSemanticElement() { return ViewUtil.resolveSemanticElement((View) getHost().getModel()); }