private void checkUsageAndDeleteDataObjectProperty(
      final ObjectProperty objectProperty, final int index) {

    final String className = dataObject.getClassName();
    final String fieldName = objectProperty.getName();

    if (getContext() != null) {

      final Path currentPath =
          getContext().getEditorModelContent() != null
              ? getContext().getEditorModelContent().getPath()
              : null;

      modelerService
          .call(
              new RemoteCallback<List<Path>>() {

                @Override
                public void callback(List<Path> paths) {

                  if (paths != null && paths.size() > 0) {
                    // If usages for this field were detected in project assets
                    // show the confirmation message to the user.

                    ShowUsagesPopup showUsagesPopup =
                        ShowUsagesPopup.newUsagesPopupForDeletion(
                            Constants.INSTANCE.modelEditor_confirm_deletion_of_used_field(
                                objectProperty.getName()),
                            paths,
                            new Command() {
                              @Override
                              public void execute() {
                                deleteDataObjectProperty(objectProperty, index);
                              }
                            },
                            new Command() {
                              @Override
                              public void execute() {
                                // do nothing.
                              }
                            });

                    showUsagesPopup.setClosable(false);
                    showUsagesPopup.show();

                  } else {
                    // no usages, just proceed with the deletion.
                    deleteDataObjectProperty(objectProperty, index);
                  }
                }
              })
          .findFieldUsages(currentPath, className, fieldName);
    }
  }
  public String resolveConstructor(
      DataObject dataObject, List<ObjectProperty> properties, String indent) {

    StringBuilder head = new StringBuilder();
    StringBuilder body = new StringBuilder();

    head.append(indent + "public " + dataObject.getName() + "(");

    if (properties != null && properties.size() > 0) {
      boolean isFirst = true;
      String propertyName;
      for (ObjectProperty property : properties) {
        if (!isFirst) {
          head.append(", ");
          body.append(EOL);
        }
        propertyName = toJavaVar(property.getName());
        head.append(resolveAttributeType(property));
        head.append(" ");
        head.append(propertyName);

        body.append(indent);
        body.append(indent);
        body.append("this.");
        body.append(propertyName);
        body.append(" = ");
        body.append(propertyName);
        body.append(";");

        isFirst = false;
      }
      body.append(EOL);
    }

    head.append(") {" + EOL);
    head.append(body);
    head.append(indent + "}");

    return head.toString();
  }