@Override public boolean canUpdate(IUpdateContext context) { // return true, if linked business object is a Reference PictogramElement pe = context.getPictogramElement(); Object bo = getBusinessObjectForPictogramElement(pe); return bo instanceof Reference && pe instanceof ContainerShape; }
public IReason updateNeeded(IUpdateContext context) { // retrieve name from pictogram model String pictogramName = null; PictogramElement pictogramElement = context.getPictogramElement(); if (pictogramElement instanceof ContainerShape) { ContainerShape cs = (ContainerShape) pictogramElement; for (Shape shape : cs.getChildren()) { if (shape.getGraphicsAlgorithm() instanceof Text) { Text text = (Text) shape.getGraphicsAlgorithm(); pictogramName = text.getValue(); } } } // retrieve name from business model String businessName = null; Object bo = getBusinessObjectForPictogramElement(pictogramElement); if (bo instanceof EClass) { EClass eClass = (EClass) bo; businessName = eClass.getName(); } // update needed, if names are different boolean updateNameNeeded = ((pictogramName == null && businessName != null) || (pictogramName != null && !pictogramName.equals(businessName))); if (updateNameNeeded) { return Reason.createTrueReason("Name is out of date"); } else { return Reason.createFalseReason(); } }
private boolean isDecoratorChanged(IUpdateContext context, IFeatureProvider featureProvider) { PictogramElement pictogramElement = context.getPictogramElement(); IFeatureContainer decorator = DecoratorUtil.getMatchingFeatureContainer(getFeatureProvider(), context); return !DecoratorUtil.isElementDecorator(pictogramElement, decorator); }
@Override public boolean canUpdate(IUpdateContext context) { PictogramElement pictogramElement = context.getPictogramElement(); // TODO: Label property not correctly set if (LabelUtil.isLabel(pictogramElement) || BusinessObjectUtil.getFirstElementOfType(pictogramElement, BPMNShape.class) == null) { return false; } Object businessObject = getBusinessObjectForPictogramElement(pictogramElement); return businessObject != null; }
@Override public IReason updateNeeded(IUpdateContext context) { if (!canUpdate(context)) { return Reason.createFalseReason(); } ContainerShape cs = (ContainerShape) context.getPictogramElement(); Reference reference = (Reference) getBusinessObjectForPictogramElement(cs); // make sure the component still exists in the model if (!GraphitiInternal.getEmfService().isObjectAlive(reference)) { return Reason.createTrueReason( String.format("Reference {0} has been removed.", reference.getName())); } // retrieve name from pictogram model String pictogramName = null; Text foundText = GraphitiUtil.findChildGA(cs.getGraphicsAlgorithm(), Text.class); if (foundText != null) { pictogramName = foundText.getValue(); } // update needed, if names are different String businessName = reference.getName(); boolean updateNameNeeded = ((pictogramName == null && businessName != null) || (pictogramName != null && !pictogramName.contentEquals(businessName))); if (updateNameNeeded) { return Reason.createTrueReason("Reference name is out of date"); } // check the wiring final Set<Contract> existingConnections = getExistingConnections(cs); for (ComponentReference promotedReference : reference.getPromote()) { if (promotedReference != null && !existingConnections.remove(promotedReference)) { return Reason.createTrueReason("Update connections."); } } if (existingConnections.size() > 0) { return Reason.createTrueReason("Update connections."); } return Reason.createFalseReason(); }
public boolean update(IUpdateContext context) { // retrieve name from business model String businessName = null; PictogramElement pictogramElement = context.getPictogramElement(); Object bo = getBusinessObjectForPictogramElement(pictogramElement); if (bo instanceof EClass) { EClass eClass = (EClass) bo; businessName = eClass.getName(); } // Set name in pictogram model if (pictogramElement instanceof ContainerShape) { ContainerShape cs = (ContainerShape) pictogramElement; for (Shape shape : cs.getChildren()) { if (shape.getGraphicsAlgorithm() instanceof Text) { Text text = (Text) shape.getGraphicsAlgorithm(); text.setValue(businessName); return true; } } } return false; }
@Override public boolean update(IUpdateContext context) { _hasDoneChanges = false; // retrieve name from business model ContainerShape cs = (ContainerShape) context.getPictogramElement(); Reference reference = (Reference) getBusinessObjectForPictogramElement(cs); // remove it if it's gone if (!GraphitiInternal.getEmfService().isObjectAlive(reference)) { IRemoveContext removeContext = new RemoveContext(context.getPictogramElement()); final IRemoveFeature removeFeature = getFeatureProvider().getRemoveFeature(removeContext); if (removeFeature != null && removeFeature.canRemove(removeContext)) { removeFeature.remove(removeContext); _hasDoneChanges = removeFeature.hasDoneChanges(); return true; } } // Set name in pictogram model String pictogramName = null; Text foundText = GraphitiUtil.findChildGA(cs.getGraphicsAlgorithm(), Text.class); if (foundText != null) { pictogramName = foundText.getValue(); } String businessName = reference.getName(); boolean updateNameNeeded = ((pictogramName == null && businessName != null) || (pictogramName != null && !pictogramName.contentEquals(businessName))); if (updateNameNeeded) { foundText.setValue(businessName); _hasDoneChanges = true; } // update the wires final Set<Contract> existingConnections = getExistingConnections(cs); final Anchor anchor = cs.getAnchors().get(0); for (ComponentReference promotedReference : reference.getPromote()) { if (promotedReference != null && !existingConnections.remove(promotedReference)) { for (PictogramElement pe : getFeatureProvider().getAllPictogramElementsForBusinessObject(promotedReference)) { if (pe instanceof Anchor) { AddConnectionContext addContext = new AddConnectionContext((Anchor) pe, anchor); addContext.setNewObject(reference); updatePictogramElement(getFeatureProvider().addIfPossible(addContext)); _hasDoneChanges = true; break; } } } } for (Connection connection : new ArrayList<Connection>(anchor.getIncomingConnections())) { Object bo = getBusinessObjectForPictogramElement(connection.getStart()); if (bo == null || existingConnections.remove(bo)) { RemoveContext removeContext = new RemoveContext(connection); IRemoveFeature removeFeature = getFeatureProvider().getRemoveFeature(removeContext); if (removeFeature.canExecute(removeContext)) { removeFeature.execute(removeContext); _hasDoneChanges = _hasDoneChanges || removeFeature.hasDoneChanges(); } } } return _hasDoneChanges; }
public boolean canUpdate(IUpdateContext context) { // return true, if linked business object is a EClass Object bo = getBusinessObjectForPictogramElement(context.getPictogramElement()); return (bo instanceof EClass); }
@Override public boolean update(IUpdateContext context) { DecoratorUtil.decorate(context.getPictogramElement(), getFeatureProvider()); return true; }