Search in sources :

Example 1 with TablePart

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

the class ERSchemaEditor method searchAndLocate.

/**
	 * Set matched tables to be selected, and next(or first) finding table to be
	 * focused
	 * 
	 * @param keyWord
	 * @param isChangedKey
	 * @return
	 */
public boolean searchAndLocate(String keyWord, boolean isChangedKey) {
    SchemaDiagramPart schemaRootPart = getERSchemaRootPart();
    List allParts = schemaRootPart.getChildren();
    // set next focus table(focus circularly )
    if (!isChangedKey && graphicalViewer.getFocusEditPart() instanceof TablePart) {
        TablePart focusedTablePart = (TablePart) graphicalViewer.getFocusEditPart();
        int preFocusIndex = allParts.indexOf(focusedTablePart);
        int start = preFocusIndex + 1;
        for (; start < allParts.size(); start++) {
            Object table = allParts.get(start);
            if (table instanceof TablePart) {
                TablePart nexFocusTable = (TablePart) table;
                if (nexFocusTable.getTable().getShownName().contains(keyWord)) {
                    getViewPort().setViewLocation(nexFocusTable.getFigure().getBounds().x, nexFocusTable.getFigure().getBounds().y);
                    graphicalViewer.setFocus(nexFocusTable);
                    return true;
                }
            }
            if (start == allParts.size()) {
                start = 0;
            }
        }
    }
    // set first focus table and gray tables
    Iterator it = allParts.iterator();
    List matchedList = new ArrayList();
    boolean isFocus = false;
    while (it.hasNext()) {
        Object obj = it.next();
        if (!(obj instanceof TablePart)) {
            continue;
        }
        TablePart tablePart = (TablePart) obj;
        ERTable erTable = tablePart.getTable();
        if (erTable.getShownName().contains(keyWord)) {
            matchedList.add(tablePart);
            if (!isFocus) {
                getViewPort().setViewLocation(tablePart.getFigure().getBounds().x, tablePart.getFigure().getBounds().y);
                graphicalViewer.setFocus(tablePart);
                isFocus = true;
            }
        } else {
            TableFigure figure = (TableFigure) tablePart.getFigure();
            figure.setDisabled(true);
        }
    }
    StructuredSelection matchedTables = new StructuredSelection(matchedList);
    graphicalViewer.setSelection(matchedTables);
    return true;
}
Also used : TableFigure(com.cubrid.common.ui.er.figures.TableFigure) SchemaDiagramPart(com.cubrid.common.ui.er.part.SchemaDiagramPart) TablePart(com.cubrid.common.ui.er.part.TablePart) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ERTable(com.cubrid.common.ui.er.model.ERTable) ArrayList(java.util.ArrayList) List(java.util.List) EventObject(java.util.EventObject) Point(org.eclipse.draw2d.geometry.Point)

Example 2 with TablePart

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

the class ERGraphLayoutManager method tmpAutoLayout.

public void tmpAutoLayout() {
    new ERGraphLayoutVisitor().layout(schemaDiagram);
    for (int i = 0; i < schemaDiagram.getChildren().size(); i++) {
        TablePart tp = (TablePart) schemaDiagram.getChildren().get(i);
        tp.refreshVisuals();
    }
    schemaDiagram.setTableModelBounds();
}
Also used : TablePart(com.cubrid.common.ui.er.part.TablePart)

Example 3 with TablePart

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

the class ERGraphLayoutVisitor method setFiguresBound.

private void setFiguresBound(SchemaDiagramPart diagram) {
    for (int i = 0; i < diagram.getChildren().size(); i++) {
        TablePart tablePart = (TablePart) diagram.getChildren().get(i);
        setFigureBounds(tablePart, 0, 0);
    }
}
Also used : TablePart(com.cubrid.common.ui.er.part.TablePart)

Example 4 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(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 5 with TablePart

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

the class TableContainerEditPolicy method getCreateCommand.

@Override
protected Command getCreateCommand(CreateRequest request) {
    Object newObject = request.getNewObject();
    if (!(newObject instanceof ERTableColumn)) {
        return null;
    }
    TablePart tablePart = (TablePart) getHost();
    ERTable erTable = tablePart.getTable();
    ERTableColumn column = (ERTableColumn) newObject;
    CreateColumnCommand command = new CreateColumnCommand();
    command.setTable(erTable);
    command.setColumn(column);
    return command;
}
Also used : ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn) TablePart(com.cubrid.common.ui.er.part.TablePart) ERTable(com.cubrid.common.ui.er.model.ERTable) CreateColumnCommand(com.cubrid.common.ui.er.commands.CreateColumnCommand)

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