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