Search in sources :

Example 1 with SchemaDiagramPart

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

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

the class SchemaContainerEditPolicy method getCreateCommand.

@Override
protected Command getCreateCommand(CreateRequest request) {
    Object newObject = request.getNewObject();
    if (!(newObject instanceof ERTable)) {
        return null;
    }
    Point location = request.getLocation();
    SchemaDiagramPart schemaPart = (SchemaDiagramPart) getHost();
    ERSchema erSchema = schemaPart.getSchema();
    ERTable erTable = (ERTable) newObject;
    ERSchemaEditor editor = schemaPart.getEditor();
    int offsetX = 0;
    int offsetY = 0;
    if (editor != null) {
        offsetX = editor.getHorizontalScrollWidth();
        offsetY = editor.getVerticalScrollHeight();
    }
    erTable.setBounds(new Rectangle(location.x + offsetX, location.y + offsetY, erTable.getMinWidth(), erTable.getMinHeight()));
    AddTableCommand addTableCommand = new AddTableCommand();
    addTableCommand.setSchema(erSchema);
    SchemaInfo schemaInfo = ERTable.createEmptySchemaInfo(erTable.getName(), erTable.getCubridDatabase().getName());
    addTableCommand.setTable(erTable, schemaInfo);
    return addTableCommand;
}
Also used : SchemaDiagramPart(com.cubrid.common.ui.er.part.SchemaDiagramPart) AddTableCommand(com.cubrid.common.ui.er.commands.AddTableCommand) ERSchemaEditor(com.cubrid.common.ui.er.editor.ERSchemaEditor) ERSchema(com.cubrid.common.ui.er.model.ERSchema) Rectangle(org.eclipse.draw2d.geometry.Rectangle) ERTable(com.cubrid.common.ui.er.model.ERTable) Point(org.eclipse.draw2d.geometry.Point) Point(org.eclipse.draw2d.geometry.Point) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Example 3 with SchemaDiagramPart

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

the class ERSchemaEditor method setAllTableSelected.

/**
	 * Set all tables to be selected.
	 */
public void setAllTableSelected() {
    graphicalViewer.setFocus(null);
    SchemaDiagramPart schemaRootPart = getERSchemaRootPart();
    List allParts = schemaRootPart.getChildren();
    StructuredSelection allTables = new StructuredSelection(allParts);
    graphicalViewer.setSelection(allTables);
}
Also used : SchemaDiagramPart(com.cubrid.common.ui.er.part.SchemaDiagramPart) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with SchemaDiagramPart

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

the class ERSchemaEditor method setAllFiguresOrigin.

/**
	 * When user click the empty space on the ERD canvas, then all the table
	 * should be unselected and background color should be reset to default.
	 */
public void setAllFiguresOrigin() {
    graphicalViewer.setFocus(null);
    graphicalViewer.deselectAll();
    SchemaDiagramPart schemaRootPart = getERSchemaRootPart();
    List allParts = schemaRootPart.getChildren();
    Iterator it = allParts.iterator();
    while (it.hasNext()) {
        Object obj = it.next();
        if (!(obj instanceof TablePart)) {
            continue;
        }
        TablePart tablePart = (TablePart) obj;
        tablePart.setSelected(TablePart.SELECTED_NONE);
        tablePart.getFigure().setBackgroundColor(TableFigure.defaultBackgroundColor);
    }
}
Also used : SchemaDiagramPart(com.cubrid.common.ui.er.part.SchemaDiagramPart) Iterator(java.util.Iterator) TablePart(com.cubrid.common.ui.er.part.TablePart) ArrayList(java.util.ArrayList) List(java.util.List) EventObject(java.util.EventObject)

Example 5 with SchemaDiagramPart

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

the class ERSchemaEditDomain method mouseDown.

/**
	 * the button in the para of mouseEvent, that was pressed or released; 1 for
	 * the left click, 2 for the double left-click, and 3 for the right click,
	 * etc.
	 */
public void mouseDown(MouseEvent mouseEvent, EditPartViewer viewer) {
    ERSchemaEditor erschemaEditor = (ERSchemaEditor) this.getEditorPart();
    Point location = new Point(mouseEvent.x, mouseEvent.y);
    EditPart part = erschemaEditor.getGraphicalViewer().findObjectAt(location);
    if (part != null && ((part instanceof SchemaDiagramPart) || (part instanceof FreeformGraphicalRootEditPart))) {
        if (getDefaultTool().equals(getActiveTool())) {
            setActiveTool(erDragTool);
        // when click on "FreeformGraphicalRootEditPart", its on the
        // extending space of "EXDefaultRangeModel"
        }
    }
    if (mouseEvent.button == 3 && !getDefaultTool().equals(getActiveTool())) {
        // mouseEvent.button == 3 : right click
        setActiveTool(getDefaultTool());
    }
    super.mouseDown(mouseEvent, viewer);
    if (part != null && part instanceof SchemaDiagramPart) {
        erschemaEditor.setAllFiguresOrigin();
    }
}
Also used : SchemaDiagramPart(com.cubrid.common.ui.er.part.SchemaDiagramPart) FreeformGraphicalRootEditPart(org.eclipse.gef.editparts.FreeformGraphicalRootEditPart) EditPart(org.eclipse.gef.EditPart) Point(org.eclipse.draw2d.geometry.Point) FreeformGraphicalRootEditPart(org.eclipse.gef.editparts.FreeformGraphicalRootEditPart)

Aggregations

SchemaDiagramPart (com.cubrid.common.ui.er.part.SchemaDiagramPart)6 ArrayList (java.util.ArrayList)4 List (java.util.List)4 ERTable (com.cubrid.common.ui.er.model.ERTable)3 TablePart (com.cubrid.common.ui.er.part.TablePart)3 EventObject (java.util.EventObject)3 Iterator (java.util.Iterator)3 Point (org.eclipse.draw2d.geometry.Point)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)1 AddTableCommand (com.cubrid.common.ui.er.commands.AddTableCommand)1 ERSchemaEditor (com.cubrid.common.ui.er.editor.ERSchemaEditor)1 TableFigure (com.cubrid.common.ui.er.figures.TableFigure)1 ERSchema (com.cubrid.common.ui.er.model.ERSchema)1 Rectangle (org.eclipse.draw2d.geometry.Rectangle)1 EditPart (org.eclipse.gef.EditPart)1 FreeformGraphicalRootEditPart (org.eclipse.gef.editparts.FreeformGraphicalRootEditPart)1