use of com.cubrid.common.ui.er.part.RelationshipPart in project cubrid-manager by CUBRID.
the class ERGraphLayoutVisitor method layout.
public void layout(Collection<TablePart> tables, int startX, int startY) {
if (tables == null || tables.isEmpty()) {
return;
}
for (TablePart table : tables) {
ERTableNode node = buildNode(table);
erGraph.addNode(node);
partNodesMap.put(table, node);
}
if (erGraph.getNodeCount() < 1) {
return;
}
for (TablePart table : tables) {
List conns = table.getSourceConnections();
for (int i = 0; i < conns.size(); i++) {
RelationshipPart relationshipPart = (RelationshipPart) table.getSourceConnections().get(i);
Edge edge = buildEdgeRelation(relationshipPart);
erGraph.addEdge(edge);
partNodesMap.put(relationshipPart, edge);
}
}
ERDirectedGraphLayout erLayoutor = new ERDirectedGraphLayout(erGraph);
erLayoutor.layout();
for (TablePart table : tables) {
setFigureBounds(table, startX, startY);
}
}
use of com.cubrid.common.ui.er.part.RelationshipPart in project cubrid-manager by CUBRID.
the class ERGraphLayoutVisitor method layout.
public void layout(SchemaDiagramPart schemaDiagram) {
initGraph(schemaDiagram);
if (erGraph.getNodeCount() > 0) {
for (int i = 0; i < schemaDiagram.getChildren().size(); i++) {
TablePart tablePart = (TablePart) schemaDiagram.getChildren().get(i);
List conns = tablePart.getSourceConnections();
for (int j = 0; j < conns.size(); j++) {
RelationshipPart relationshipPart = (RelationshipPart) tablePart.getSourceConnections().get(j);
Edge edge = buildEdgeRelation(relationshipPart);
erGraph.addEdge(edge);
partNodesMap.put(relationshipPart, edge);
}
}
ERDirectedGraphLayout gLayout = new ERDirectedGraphLayout(erGraph);
gLayout.layout();
setFiguresBound(schemaDiagram);
}
}
use of com.cubrid.common.ui.er.part.RelationshipPart in project cubrid-manager by CUBRID.
the class ERGraphLayoutVisitor method setFigureBounds.
private void setFigureBounds(TablePart tablePart, int absStartX, int absStartY) {
Node node = (Node) partNodesMap.get(tablePart);
TableFigure tableFigure = (TableFigure) tablePart.getFigure();
Rectangle bounds = new Rectangle(absStartX + node.x, absStartY + node.y, tableFigure.getPreferredSize().width, tableFigure.getPreferredSize().height);
tableFigure.setBounds(bounds);
for (int i = 0; i < tablePart.getSourceConnections().size(); i++) {
RelationshipPart relationship = (RelationshipPart) tablePart.getSourceConnections().get(i);
setFigureConstraint(relationship);
}
}
use of com.cubrid.common.ui.er.part.RelationshipPart in project cubrid-manager by CUBRID.
the class SchemaContextMenuProvider method buildContextMenu.
@Override
public void buildContextMenu(IMenuManager menu) {
if (!(menu instanceof SchemaContextMenuProvider)) {
return;
}
SchemaContextMenuProvider menuProvider = (SchemaContextMenuProvider) menu;
EditPartViewer viewer = menuProvider.getViewer();
if (viewer == null) {
return;
}
buildPublicMenuItems(menu);
List selectParts = viewer.getSelectedEditParts();
// blank right-click
if (selectParts == null || selectParts.size() == 0) {
return;
}
// multi-objects right-click
if (selectParts.size() > 1) {
buildMultiFiguresMenuItems(menu);
return;
}
// one object right-click
Object object = selectParts.get(0);
if (object instanceof TablePart) {
buildTableMenuItems(menu);
} else if (object instanceof ColumnPart) {
buildColumnMenuItems(menu);
} else if (object instanceof RelationshipPart) {
buildRelationshipLineMenuItems(menu);
}
}
use of com.cubrid.common.ui.er.part.RelationshipPart in project cubrid-manager by CUBRID.
the class DeleteAction method run.
/**
* 1. First, delete relationship connection line; <br>
* 2. Then, delete column; <br>
* 3. Delete table at last.
*/
public void run() {
List objects = getSelectedObjects();
if (objects.isEmpty()) {
return;
}
List<EditPart> lineParts = new LinkedList<EditPart>();
List<EditPart> columnParts = new LinkedList<EditPart>();
List<EditPart> tableParts = new LinkedList<EditPart>();
List<String> tableNames = new LinkedList<String>();
Set<String> columnNames = new HashSet<String>();
int lineCount = 0;
for (Object obj : objects) {
if (obj == null) {
continue;
}
if (obj instanceof RelationshipPart) {
lineParts.add((RelationshipPart) obj);
lineCount++;
} else if (obj instanceof ColumnPart) {
columnParts.add((ColumnPart) obj);
columnNames.add(((ColumnPart) obj).getName());
} else if (obj instanceof TablePart) {
tableParts.add((TablePart) obj);
tableNames.add(((TablePart) obj).getName());
}
}
List<EditPart> allParts = new LinkedList<EditPart>(lineParts);
allParts.addAll(columnParts);
allParts.addAll(tableParts);
StringBuilder msg = new StringBuilder(Messages.msgConfirmDelete);
if (!tableNames.isEmpty()) {
msg.append(StringUtil.NEWLINE).append(Messages.msgConfirmDeleteTableList).append(tableNames.toString());
}
if (!columnNames.isEmpty()) {
msg.append(StringUtil.NEWLINE).append(Messages.msgConfirmDeleteColumnList).append(columnNames.toString());
}
if (lineCount != 0) {
msg.append(StringUtil.NEWLINE).append(Messages.msgConfirmDeleteLineCount).append(lineCount);
}
boolean delete = CommonUITool.openConfirmBox(getWorkbenchPart().getSite().getShell(), msg.toString());
if (delete) {
execute(buildDeleteCommands(allParts));
}
}
Aggregations