Search in sources :

Example 11 with TablePart

use of com.cubrid.common.ui.er.part.TablePart in project cubrid-manager by CUBRID.

the class GraphXYLayout method layoutPartitionNodes.

private void layoutPartitionNodes() {
    List<TablePart> tables = diagram.getNeedPartitionLayoutTables();
    if (tables.isEmpty()) {
        return;
    }
    Rectangle rec = diagram.getRectangle();
    layout(tables, 0, rec.y + rec.height);
    for (TablePart table : tables) {
        // set the bound constraints
        table.refreshVisuals();
    }
    List<TablePart> allTables = diagram.getAllTables();
    if (tables.size() == allTables.size()) {
        // all new tables, to focus to
        // (0,0) location
        diagram.moveTopLeftFocus();
    } else {
        diagram.moveLastTableLocationFocus();
    }
    diagram.clearNeedPartitionLayoutState();
}
Also used : TablePart(com.cubrid.common.ui.er.part.TablePart) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 12 with TablePart

use of com.cubrid.common.ui.er.part.TablePart in project cubrid-manager by CUBRID.

the class ERGraphLayoutVisitor method initGraph.

private void initGraph(SchemaDiagramPart schemaDiagram) {
    for (int i = 0; i < schemaDiagram.getChildren().size(); i++) {
        TablePart part = (TablePart) schemaDiagram.getChildren().get(i);
        ERTableNode node = buildNode(part);
        erGraph.addNode(node);
        partNodesMap.put(part, node);
    }
}
Also used : TablePart(com.cubrid.common.ui.er.part.TablePart)

Example 13 with TablePart

use of com.cubrid.common.ui.er.part.TablePart 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 14 with TablePart

use of com.cubrid.common.ui.er.part.TablePart 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 15 with TablePart

use of com.cubrid.common.ui.er.part.TablePart in project cubrid-manager by CUBRID.

the class SchemaXYLayoutPolicy method createChangeConstraintCommand.

@Override
protected Command createChangeConstraintCommand(EditPart child, Object constraint) {
    if (!(child instanceof TablePart) || !(constraint instanceof Rectangle)) {
        return null;
    }
    TablePart tablePart = (TablePart) child;
    ERTable erTable = tablePart.getTable();
    TableFigure figure = (TableFigure) tablePart.getFigure();
    Rectangle oldBounds = figure.getBounds();
    Rectangle newBounds = (Rectangle) constraint;
    if (oldBounds.width != newBounds.width && newBounds.width != -1) {
        return null;
    } else if (oldBounds.height != newBounds.height && newBounds.height != -1) {
        return null;
    }
    return new MoveTableCommand(erTable, oldBounds.getCopy(), newBounds.getCopy());
}
Also used : TableFigure(com.cubrid.common.ui.er.figures.TableFigure) TablePart(com.cubrid.common.ui.er.part.TablePart) Rectangle(org.eclipse.draw2d.geometry.Rectangle) ERTable(com.cubrid.common.ui.er.model.ERTable) MoveTableCommand(com.cubrid.common.ui.er.commands.MoveTableCommand)

Aggregations

TablePart (com.cubrid.common.ui.er.part.TablePart)21 List (java.util.List)7 ERTable (com.cubrid.common.ui.er.model.ERTable)5 RelationshipPart (com.cubrid.common.ui.er.part.RelationshipPart)4 ColumnPart (com.cubrid.common.ui.er.part.ColumnPart)3 SchemaDiagramPart (com.cubrid.common.ui.er.part.SchemaDiagramPart)3 ArrayList (java.util.ArrayList)3 EventObject (java.util.EventObject)3 Iterator (java.util.Iterator)3 Rectangle (org.eclipse.draw2d.geometry.Rectangle)3 CreateRelationshipCommand (com.cubrid.common.ui.er.commands.CreateRelationshipCommand)2 TableFigure (com.cubrid.common.ui.er.figures.TableFigure)2 ERTableColumn (com.cubrid.common.ui.er.model.ERTableColumn)2 Edge (org.eclipse.draw2d.graph.Edge)2 CreateColumnCommand (com.cubrid.common.ui.er.commands.CreateColumnCommand)1 DeleteTableCommand (com.cubrid.common.ui.er.commands.DeleteTableCommand)1 MoveTableCommand (com.cubrid.common.ui.er.commands.MoveTableCommand)1 ReconnectForeignKeyCommand (com.cubrid.common.ui.er.commands.ReconnectForeignKeyCommand)1 ReconnectPrimaryKeyCommand (com.cubrid.common.ui.er.commands.ReconnectPrimaryKeyCommand)1 TransferColumnCommand (com.cubrid.common.ui.er.commands.TransferColumnCommand)1