private void setDataObject(DataObject dataObject) {
    this.dataObject = dataObject;
    refreshObjectSelector(dataObject);

    // We create a new selection model due to a bug found in GWT when we change e.g. from one data
    // object with 9 rows
    // to one with 3 rows and the table was sorted.
    // Several tests has been done and the final workaround (not too bad) we found is to
    // 1) sort the table again
    // 2) create a new selection model
    // 3) populate the table with new items
    // 3) select the first row
    SingleSelectionModel selectionModel2 = new SingleSelectionModel<ObjectProperty>();
    dataObjectPropertiesTable.setSelectionModel(selectionModel2);

    selectionModel2.addSelectionChangeHandler(
        new SelectionChangeEvent.Handler() {

          @Override
          public void onSelectionChange(SelectionChangeEvent event) {
            ObjectProperty selectedProperty =
                ((SingleSelectionModel<ObjectProperty>)
                        dataObjectPropertiesTable.getSelectionModel())
                    .getSelectedObject();
            notifyFieldSelected(selectedProperty);
          }
        });

    List<ObjectProperty> dataObjectProperties =
        (dataObject != null)
            ? DataModelerUtils.getManagedProperties(dataObject)
            : Collections.<ObjectProperty>emptyList();

    ArrayList<ObjectProperty> sortBuffer = new ArrayList<ObjectProperty>();
    if (dataObject != null) {
      sortBuffer.addAll(dataObjectProperties);
    }
    Collections.sort(sortBuffer, new ObjectPropertyComparator("name"));

    dataObjectPropertiesProvider.getList().clear();
    dataObjectPropertiesProvider.getList().addAll(sortBuffer);
    dataObjectPropertiesProvider.flush();
    dataObjectPropertiesProvider.refresh();

    dataObjectPropertiesTable
        .getColumnSortList()
        .push(new ColumnSortList.ColumnSortInfo(dataObjectPropertiesTable.getColumn(2), true));

    if (dataObjectProperties.size() > 0) {
      dataObjectPropertiesTable.setKeyboardSelectedRow(0);
      selectionModel2.setSelected(sortBuffer.get(0), true);
    }

    // set the first row selected again. Sounds crazy, but's part of the workaround, don't remove
    // this line.
    if (dataObjectProperties.size() > 0) {
      dataObjectPropertiesTable.setKeyboardSelectedRow(0);
    }
  }
  private String propertyTypeDisplay(ObjectProperty property) {
    String displayName = property.getClassName();

    if (property.isBaseType()) {
      displayName = DataModelerUtils.extractClassName(displayName);
    } else {
      String label = getContext().getHelper().getObjectLabelByClassName(displayName);
      if (label != null && !"".equals(label)) {
        displayName = label;
      }
    }

    if (property.isMultiple()) {
      displayName += " [" + Constants.INSTANCE.objectBrowser_typeLabelMultiple() + "]";
    }
    return displayName;
  }
 public void isValidPackageIdentifier(String identifier, final ValidatorCallback callback) {
   String[] packageTerms = DataModelerUtils.getInstance().getPackageTerms(identifier);
   validationService
       .call(
           new RemoteCallback<Map<String, Boolean>>() {
             @Override
             public void callback(Map<String, Boolean> evaluatedTerms) {
               // TODO the service is prepared for term-based evaluation, but for now the callback
               // doesn't support returning params
               boolean nok = evaluatedTerms.containsValue(Boolean.FALSE);
               if (nok) {
                 callback.onFailure();
               } else {
                 callback.onSuccess();
               }
             }
           },
           new DataModelerErrorCallback("An error occurred during the server validation process"))
       .evaluateIdentifiers(packageTerms);
 }
 private void refreshObjectSelector(DataObject dataObject) {
   if (dataObject != null) {
     objectButton.setText(DataModelerUtils.getDataObjectFullLabel(dataObject, false));
     objectButton.setTitle(dataObject.getClassName());
   }
 }
  private void saveFile(final JavaTypeInfo newTypeInfo) {

    String currentFileName =
        DataModelerUtils.extractSimpleFileName(versionRecordManager.getPathToLatest());

    if (hasPackageNameChanged(newTypeInfo)) {

      YesNoCancelPopup yesNoCancelPopup =
          YesNoCancelPopup.newYesNoCancelPopup(
              CommonConstants.INSTANCE.Information(),
              Constants.INSTANCE.modelEditor_confirm_file_package_refactoring(
                  newTypeInfo.getPackageName()),
              new Command() {
                @Override
                public void execute() {
                  saveOperationService.save(
                      versionRecordManager.getPathToLatest(),
                      getSaveCommand(newTypeInfo, versionRecordManager.getPathToLatest()));
                }
              },
              Constants.INSTANCE.modelEditor_action_yes_refactor_directory(),
              ButtonType.PRIMARY,
              new Command() {
                @Override
                public void execute() {
                  saveOperationService.save(
                      versionRecordManager.getPathToLatest(),
                      getSaveCommand(null, versionRecordManager.getPathToLatest()));
                }
              },
              Constants.INSTANCE.modelEditor_action_no_dont_refactor_directory(),
              ButtonType.DANGER,
              new Command() {
                @Override
                public void execute() {
                  // do nothing
                }
              },
              null,
              null);

      yesNoCancelPopup.setClosable(false);
      yesNoCancelPopup.show();

    } else if (hasFileNameChanged(newTypeInfo, currentFileName)) {

      YesNoCancelPopup yesNoCancelPopup =
          YesNoCancelPopup.newYesNoCancelPopup(
              CommonConstants.INSTANCE.Information(),
              Constants.INSTANCE.modelEditor_confirm_file_name_refactoring(newTypeInfo.getName()),
              new Command() {
                @Override
                public void execute() {
                  saveOperationService.save(
                      versionRecordManager.getPathToLatest(),
                      getSaveCommand(newTypeInfo, versionRecordManager.getPathToLatest()));
                }
              },
              Constants.INSTANCE.modelEditor_action_yes_refactor_file_name(),
              ButtonType.PRIMARY,
              new Command() {
                @Override
                public void execute() {
                  saveOperationService.save(
                      versionRecordManager.getPathToLatest(),
                      getSaveCommand(null, versionRecordManager.getPathToLatest()));
                }
              },
              Constants.INSTANCE.modelEditor_action_no_dont_refactor_file_name(),
              ButtonType.DANGER,
              new Command() {
                @Override
                public void execute() {
                  // do nothing
                }
              },
              null,
              null);

      yesNoCancelPopup.setClosable(false);
      yesNoCancelPopup.show();

    } else {
      new SaveOperationService()
          .save(
              versionRecordManager.getPathToLatest(),
              getSaveCommand(null, versionRecordManager.getPathToLatest()));
    }
  }