Search in sources :

Example 1 with TableFigure

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

use of com.cubrid.common.ui.er.figures.TableFigure in project cubrid-manager by CUBRID.

the class TablePart method setGrayBackground.

/**
	 * If "set" is true, set the table figure to be disable state
	 * 
	 * @param set
	 */
public void setGrayBackground(boolean set) {
    if (set) {
        TableFigure tableFigure = (TableFigure) getFigure();
        tableFigure.setBackgroundColor(TableFigure.disableBackgroundColor);
    } else {
        TableFigure tableFigure = (TableFigure) getFigure();
        tableFigure.setBackgroundColor(TableFigure.defaultBackgroundColor);
    }
}
Also used : TableFigure(com.cubrid.common.ui.er.figures.TableFigure)

Example 3 with TableFigure

use of com.cubrid.common.ui.er.figures.TableFigure in project cubrid-manager by CUBRID.

the class TablePart method setName.

private void setName(String name) {
    TableFigure tableFigure = (TableFigure) getFigure();
    EditableLabel label = tableFigure.getNameLabel();
    label.setText(name);
    label.setVisible(true);
}
Also used : TableFigure(com.cubrid.common.ui.er.figures.TableFigure) EditableLabel(com.cubrid.common.ui.er.figures.EditableLabel)

Example 4 with TableFigure

use of com.cubrid.common.ui.er.figures.TableFigure in project cubrid-manager by CUBRID.

the class TablePart method setFocus.

@Override
public void setFocus(boolean hasFocus) {
    TableFigure tableFigure = (TableFigure) getFigure();
    LineBorder lineBorder = (LineBorder) tableFigure.getBorder();
    if (hasFocus) {
        lineBorder.setWidth(2);
    } else {
        lineBorder.setWidth(1);
    }
}
Also used : TableFigure(com.cubrid.common.ui.er.figures.TableFigure) LineBorder(org.eclipse.draw2d.LineBorder)

Example 5 with TableFigure

use of com.cubrid.common.ui.er.figures.TableFigure in project cubrid-manager by CUBRID.

the class TablePart method createFigure.

protected IFigure createFigure() {
    ERTable erTable = getTable();
    EditableLabel label = new EditableLabel(erTable.getShownName());
    TableFigure tableFigure = new TableFigure(label);
    Rectangle rec = erTable.getBounds();
    if (rec != null) {
        tableFigure.setBounds(rec);
    }
    return tableFigure;
}
Also used : EditableLabel(com.cubrid.common.ui.er.figures.EditableLabel) TableFigure(com.cubrid.common.ui.er.figures.TableFigure) Rectangle(org.eclipse.draw2d.geometry.Rectangle) ERTable(com.cubrid.common.ui.er.model.ERTable)

Aggregations

TableFigure (com.cubrid.common.ui.er.figures.TableFigure)18 Rectangle (org.eclipse.draw2d.geometry.Rectangle)8 EditableLabel (com.cubrid.common.ui.er.figures.EditableLabel)6 ERTable (com.cubrid.common.ui.er.model.ERTable)6 Iterator (java.util.Iterator)4 List (java.util.List)4 EventObject (java.util.EventObject)3 LinkedList (java.util.LinkedList)3 TablePart (com.cubrid.common.ui.er.part.TablePart)2 Point (org.eclipse.draw2d.geometry.Point)2 ValidationGraphicalViewer (com.cubrid.common.ui.er.ValidationGraphicalViewer)1 ValidationMessageHandler (com.cubrid.common.ui.er.ValidationMessageHandler)1 MoveTableCommand (com.cubrid.common.ui.er.commands.MoveTableCommand)1 ERDirectEditManager (com.cubrid.common.ui.er.directedit.ERDirectEditManager)1 LabelCellEditorLocator (com.cubrid.common.ui.er.directedit.LabelCellEditorLocator)1 TableNameCellEditorValidator (com.cubrid.common.ui.er.directedit.TableNameCellEditorValidator)1 TableNameCellEditor (com.cubrid.common.ui.er.editor.TableNameCellEditor)1 ConnectionFigure (com.cubrid.common.ui.er.figures.ConnectionFigure)1 RelationshipPart (com.cubrid.common.ui.er.part.RelationshipPart)1 SchemaDiagramPart (com.cubrid.common.ui.er.part.SchemaDiagramPart)1