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;
  }
  /** {@inheritDoc} */
  @Override
  protected void refreshOutlineVisuals() {
    Relation model = (Relation) this.getModel();

    ERDiagram diagram = (ERDiagram) this.getRoot().getContents().getModel();

    int viewMode = diagram.getDiagramContents().getSettings().getOutlineViewMode();

    boolean first = true;
    StringBuilder sb = new StringBuilder();

    for (NormalColumn foreignKeyColumn : model.getForeignKeyColumns()) {
      if (first) {
        first = false;
      } else {
        sb.append(", ");
      }

      if (viewMode == Settings.VIEW_MODE_PHYSICAL) {
        sb.append(Format.null2blank(foreignKeyColumn.getPhysicalName()));

      } else if (viewMode == Settings.VIEW_MODE_LOGICAL) {
        sb.append(Format.null2blank(foreignKeyColumn.getLogicalName()));

      } else {
        sb.append(Format.null2blank(foreignKeyColumn.getLogicalName()));
        sb.append("/");
        sb.append(Format.null2blank(foreignKeyColumn.getPhysicalName()));
      }
    }

    this.setWidgetText(sb.toString());
    this.setWidgetImage(Activator.getImage(ImageKey.FOREIGN_KEY));
  }
  /** {@inheritDoc} */
  @Override
  public void performRequest(Request request) {
    Relation relation = (Relation) this.getModel();

    if (request.getType().equals(RequestConstants.REQ_OPEN)) {
      Relation copy = relation.copy();

      RelationDialog dialog =
          new RelationDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), copy);

      if (dialog.open() == IDialogConstants.OK_ID) {
        ChangeRelationPropertyCommand command = new ChangeRelationPropertyCommand(relation, copy);
        this.execute(command);
      }
    }

    super.performRequest(request);
  }
  private List<NormalColumn> getSelectedForeignKeyColulmnList() {
    List<NormalColumn> foreignKeyColulmnList = new ArrayList<NormalColumn>();

    TableViewEditPart parent = (TableViewEditPart) this.getParent();

    for (Object object : parent.getTargetConnections()) {
      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;

          foreignKeyColulmnList.addAll(relation.getForeignKeyColumns());
        }
      }
    }

    return foreignKeyColulmnList;
  }