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;
}
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;
}
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);
}
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);
}
}
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();
}
}
Aggregations