コード例 #1
0
  private List<NormalColumn> getSelectedReferencedColulmnList() {
    List<NormalColumn> referencedColulmnList = new ArrayList<NormalColumn>();

    TableViewEditPart parent = (TableViewEditPart) this.getParent();
    TableView tableView = (TableView) parent.getModel();

    for (Object object : parent.getSourceConnections()) {
      ConnectionEditPart connectionEditPart = (ConnectionEditPart) object;

      int selected = connectionEditPart.getSelected();

      if (selected == EditPart.SELECTED || selected == EditPart.SELECTED_PRIMARY) {
        ConnectionElement connectionElement = (ConnectionElement) connectionEditPart.getModel();

        if (connectionElement instanceof Relation) {
          Relation relation = (Relation) connectionElement;

          if (relation.isReferenceForPK()) {
            referencedColulmnList.addAll(((ERTable) tableView).getPrimaryKeys());

          } else if (relation.getReferencedComplexUniqueKey() != null) {
            referencedColulmnList.addAll(relation.getReferencedComplexUniqueKey().getColumnList());

          } else {
            referencedColulmnList.add(relation.getReferencedColumn());
          }
        }
      }
    }
    return referencedColulmnList;
  }