Search in sources :

Example 1 with RelationshipPart

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);
    }
}
Also used : RelationshipPart(com.cubrid.common.ui.er.part.RelationshipPart) TablePart(com.cubrid.common.ui.er.part.TablePart) List(java.util.List) Edge(org.eclipse.draw2d.graph.Edge)

Example 2 with RelationshipPart

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);
    }
}
Also used : RelationshipPart(com.cubrid.common.ui.er.part.RelationshipPart) TablePart(com.cubrid.common.ui.er.part.TablePart) List(java.util.List) Edge(org.eclipse.draw2d.graph.Edge)

Example 3 with RelationshipPart

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);
    }
}
Also used : TableFigure(com.cubrid.common.ui.er.figures.TableFigure) RelationshipPart(com.cubrid.common.ui.er.part.RelationshipPart) Node(org.eclipse.draw2d.graph.Node) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 4 with RelationshipPart

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);
    }
}
Also used : RelationshipPart(com.cubrid.common.ui.er.part.RelationshipPart) TablePart(com.cubrid.common.ui.er.part.TablePart) EditPartViewer(org.eclipse.gef.EditPartViewer) ColumnPart(com.cubrid.common.ui.er.part.ColumnPart) List(java.util.List)

Example 5 with RelationshipPart

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));
    }
}
Also used : EditPart(org.eclipse.gef.EditPart) TablePart(com.cubrid.common.ui.er.part.TablePart) LinkedList(java.util.LinkedList) RelationshipPart(com.cubrid.common.ui.er.part.RelationshipPart) ColumnPart(com.cubrid.common.ui.er.part.ColumnPart) List(java.util.List) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Aggregations

RelationshipPart (com.cubrid.common.ui.er.part.RelationshipPart)5 TablePart (com.cubrid.common.ui.er.part.TablePart)4 List (java.util.List)4 ColumnPart (com.cubrid.common.ui.er.part.ColumnPart)2 Edge (org.eclipse.draw2d.graph.Edge)2 TableFigure (com.cubrid.common.ui.er.figures.TableFigure)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 Node (org.eclipse.draw2d.graph.Node)1 EditPart (org.eclipse.gef.EditPart)1 EditPartViewer (org.eclipse.gef.EditPartViewer)1