public class SynchronizationDecorator implements ILightweightLabelDecorator {

  private static final ImageDescriptor SYNC_OVERLAY =
      CorePlugin.getImageDescriptor("warning_co.gif");
  public static final String ID =
      "org.xtuml.bp.ui.explorer.synchronizationDecorator"; //$NON-NLS-1$

  @Override
  public void decorate(Object element, IDecoration decoration) {
    // rather than check the class for the isSynchronizedMethod through
    // reflection, only consider the known classes
    if (!isSynchronized(element)) {
      decoration.addOverlay(SYNC_OVERLAY, IDecoration.BOTTOM_LEFT);
    }
  }

  private boolean isSynchronized(Object element) {
    if (element instanceof NonRootModelElement) {
      NonRootModelElement nrme = (NonRootModelElement) element;
      if (nrme.Issynchronized()) {
        // check children as well
        return childrenAreSynchronized(nrme);
      } else {
        return false;
      }
    }
    return true;
  }

  private boolean childrenAreSynchronized(NonRootModelElement element) {
    boolean result = true;
    result = element.Issynchronized();
    if (result) {
      List<?> children = new ArrayList<Object>();
      element.Collectreferencesforsynchronization(children, Synchronizationtype_c.Pull);
      for (Object child : children) {
        if (((NonRootModelElement) child).getModelRoot() instanceof Ooaofooa) {
          result = childrenAreSynchronized((NonRootModelElement) child);
          if (!result) {
            return result;
          }
        }
      }
    }
    return result;
  }

  @Override
  public void addListener(ILabelProviderListener listener) {
    // not required
  }

  @Override
  public void dispose() {
    // not required
  }

  @Override
  public boolean isLabelProperty(Object element, String property) {
    // not required
    return false;
  }

  @Override
  public void removeListener(ILabelProviderListener listener) {
    // not required
  }
}