public void setContext(DataModelerContext context) {
   this.context = context;
   if (context != null) {
     setDataObject(context.getDataObject());
     setReadonly(context.isReadonly());
   } else {
     setReadonly(true);
   }
 }
 // Event notifications
 private void notifyFieldSelected(ObjectProperty selectedProperty) {
   if (!skipNextFieldNotification && selectedProperty != null) {
     context.setObjectProperty(selectedProperty);
     dataModelerWBContextEvent.fire(new DataModelerWorkbenchContextChangeEvent());
   }
   skipNextFieldNotification = false;
 }
  private void onDataObjectChange(@Observes DataObjectChangeEvent event) {
    if (event.isFromContext(context != null ? context.getContextId() : null)) {
      if (event.getChangeType() == ChangeType.CLASS_NAME_CHANGE
          || event.getChangeType() == ChangeType.PACKAGE_NAME_CHANGE
          || event.getChangeType() == ChangeType.OBJECT_NAME_CHANGE
          || MainDomainAnnotations.LABEL_ANNOTATION.equals(event.getAnnotationClassName())) {

        refreshObjectSelector(dataObject);

        // For self references: in case name or package changes redraw properties table
        skipNextFieldNotification = true;
        dataObjectPropertiesProvider.refresh();
        dataObjectPropertiesTable.redraw();

        Scheduler.get()
            .scheduleDeferred(
                new Scheduler.ScheduledCommand() {
                  @Override
                  public void execute() {
                    selectCurrentObject(false);
                  }
                });
      }
    }
  }
 public void canDeleteDataObject(
     DataModelerContext context,
     DataObjectTO object,
     DataModelTO model,
     ValidatorCallback callback) {
   if (!context.getHelper().isDataObjectReferenced(object.getClassName())) {
     callback.onSuccess();
   } else {
     callback.onFailure();
   }
 }
 public void canExtend(
     DataModelerContext context,
     String siblingCandidateName,
     String parentCandidateName,
     ValidatorCallback callback) {
   if (context.getHelper().isAssignableFrom(siblingCandidateName, parentCandidateName)) {
     callback.onSuccess();
   } else {
     callback.onFailure();
   }
 }
  private void onDataObjectPropertyChange(@Observes DataObjectFieldChangeEvent event) {
    if (event.isFromContext(context != null ? context.getContextId() : null)) {

      if (event.getChangeType() == ChangeType.FIELD_NAME_CHANGE
          || event.getChangeType() == ChangeType.FIELD_TYPE_CHANGE
          || event.getChangeType() == ChangeType.FIELD_ANNOTATION_VALUE_CHANGE
          || event.getChangeType() == ChangeType.FIELD_ANNOTATION_ADD_CHANGE
          || event.getChangeType() == ChangeType.FIELD_ANNOTATION_REMOVE_CHANGE) {
        // TODO add filtering for the Label annotation class name.

        // use the annotationClassName
        List<ObjectProperty> props = dataObjectPropertiesProvider.getList();
        for (int i = 0; i < props.size(); i++) {
          if (event.getCurrentField() == props.get(i)) {
            dataObjectPropertiesTable.redrawRow(i);
            break;
          }
        }
      }
    }
  }
  private void deleteDataObjectProperty(final ObjectProperty objectProperty, final int index) {
    if (dataObject != null) {
      dataObject.getProperties().remove(objectProperty);

      dataObjectPropertiesProvider.getList().remove(index);
      dataObjectPropertiesProvider.flush();
      dataObjectPropertiesProvider.refresh();

      getContext()
          .getHelper()
          .dataObjectUnReferenced(objectProperty.getClassName(), dataObject.getClassName());
      notifyFieldDeleted(objectProperty);
      if (dataObjectPropertiesProvider.getList().size() == 0) {
        context.setObjectProperty(null);
        dataModelerWBContextEvent.fire(new DataModelerWorkbenchContextChangeEvent());
      } else if (dataObjectPropertiesProvider.getList().size() == 1) {
        // BZ-1255449 tricky bug. Considerable time was spent, and it was no direct to find an
        // optimal/better solution.
        // Since in this use case the Data Object will have just one field, it's acceptable to
        // reload the list.
        setDataObject(dataObject);
      }
    }
  }
 private void notifyObjectSelected() {
   context.setObjectProperty(null);
   dataModelerWBContextEvent.fire(new DataModelerWorkbenchContextChangeEvent());
 }