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(); } }
@Override public IReason updateNeeded(IUpdateContext context) { if (isDecoratorChanged(context, getFeatureProvider())) { return Reason.createTrueReason("Decorator changed"); } else { return Reason.createFalseReason(); } }
@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(); }