@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; } }
@Override public void setSelected(int value) { final EditPart parent = this.getParent(); final NormalColumnFigure figure = (NormalColumnFigure) this.getFigure(); Color backgroundColor = null; Color foregroundColor = null; boolean isSelected = false; if (value != 0 && parent != null && parent.getParent() != null) { List selectedEditParts = this.getViewer().getSelectedEditParts(); if (selectedEditParts == null || selectedEditParts.size() != 1) { return; } backgroundColor = ColorConstants.titleBackground; foregroundColor = ColorConstants.titleForeground; isSelected = true; } final NormalColumn normalColumn = (NormalColumn) this.getModel(); final ColumnHolder columnHolder = normalColumn.getColumnHolder(); if (columnHolder instanceof ColumnGroup) { if (parent != null) { for (Object child : parent.getChildren()) { final GraphicalEditPart childEditPart = (GraphicalEditPart) child; if (childEditPart.getModel() instanceof NormalColumn) { final NormalColumn column = (NormalColumn) childEditPart.getModel(); if (column.getColumnHolder() == columnHolder) { setGroupColumnFigureColor( (TableViewEditPart) parent, (ColumnGroup) columnHolder, isSelected); } } } } } else { figure.setBackgroundColor(backgroundColor); figure.setForegroundColor(foregroundColor); selected = isSelected; } super.setSelected(value); }