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;
  }
  @Override
  public void refreshTableColumns(UpdatedNodeElement updated) {
    ERDiagram diagram = this.getDiagram();

    NormalColumnFigure columnFigure = (NormalColumnFigure) this.getFigure();

    NormalColumn normalColumn = (NormalColumn) this.getModel();

    TableViewEditPart parent = (TableViewEditPart) this.getParent();
    parent.getContentPane().add(figure);

    int notationLevel = diagram.getDiagramContents().getSettings().getNotationLevel();

    if (notationLevel != Settings.NOTATION_LEVLE_TITLE) {
      TableFigure tableFigure = (TableFigure) parent.getFigure();

      List<NormalColumn> selectedReferencedColulmnList = this.getSelectedReferencedColulmnList();
      List<NormalColumn> selectedForeignKeyColulmnList = this.getSelectedForeignKeyColulmnList();

      boolean isSelectedReferenced = selectedReferencedColulmnList.contains(normalColumn);
      boolean isSelectedForeignKey = selectedForeignKeyColulmnList.contains(normalColumn);

      boolean isAdded = false;
      boolean isUpdated = false;
      if (updated != null) {
        isAdded = updated.isAdded(normalColumn);
        isUpdated = updated.isUpdated(normalColumn);
      }

      if ((notationLevel == Settings.NOTATION_LEVLE_KEY)
          && !normalColumn.isPrimaryKey()
          && !normalColumn.isForeignKey()
          && !normalColumn.isReferedStrictly()) {
        columnFigure.clearLabel();
        return;
      }

      addColumnFigure(
          diagram,
          tableFigure,
          columnFigure,
          normalColumn,
          isSelectedReferenced,
          isSelectedForeignKey,
          isAdded,
          isUpdated,
          false);

      if (selected) {
        columnFigure.setBackgroundColor(ColorConstants.titleBackground);
        columnFigure.setForegroundColor(ColorConstants.titleForeground);
      }

    } else {
      columnFigure.clearLabel();
      return;
    }
  }
  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;
  }
  private static void setGroupColumnFigureColor(
      TableViewEditPart parentEditPart, ColumnGroup columnGroup, boolean selected) {
    for (final NormalColumn column : columnGroup.getColumns()) {
      for (final Object editPart : parentEditPart.getChildren()) {
        final ColumnEditPart childEditPart = (ColumnEditPart) editPart;
        if (childEditPart.getModel() == column) {
          final IFigure columnFigure = childEditPart.getFigure();
          if (selected) {
            columnFigure.setBackgroundColor(ColorConstants.titleBackground);
            columnFigure.setForegroundColor(ColorConstants.titleForeground);

          } else {
            columnFigure.setBackgroundColor(null);
            columnFigure.setForegroundColor(null);
          }

          ((NormalColumnEditPart) childEditPart).selected = selected;
          break;
        }
      }
    }
  }