コード例 #1
0
  /**
   * Set the current entity that we are browsing and whether the user should be warned or not
   *
   * @param entity
   * @param type
   * @param silent
   */
  private void setEntity(ITridas entity, Class<? extends ITridas> type, Boolean silent) {
    if (!silent) {
      if (!warnLosingChanges()) {
        return;
      }
    }

    hasChanged = false;

    currentEntityType = type;
    currentEntity = entity;

    // Swapping entities so disable editing
    this.enableEditing(false);

    // derive a property list
    List<TridasEntityProperty> properties = TridasEntityDeriver.buildDerivationList(type);
    Property[] propArray = properties.toArray(new Property[properties.size()]);

    // set properties and load from entity
    propertiesPanel.setProperties(propArray);
    propertiesTable.expandAllBranches(true);

    // Add data to table from entity
    if (entity != null) {
      propertiesPanel.readFromObject(entity);
      propertiesPanel.setEnabled(true);
      editEntity.setVisible(true);
    } else {
      propertiesPanel.setEnabled(false);
      editEntity.setVisible(false);
    }
  }