use of org.eclipse.draw2d.geometry.Rectangle in project cubrid-manager by CUBRID.
the class EditableLabel method getSelectionRectangle.
private Rectangle getSelectionRectangle() {
Rectangle bounds = getTextBounds().getCopy();
bounds.expand(new Insets(2, 2, 0, 0));
translateToParent(bounds);
bounds.intersect(getBounds());
return bounds;
}
use of org.eclipse.draw2d.geometry.Rectangle in project cubrid-manager by CUBRID.
the class ERMinJoinDirectedGraphLayout method getLayoutedRec.
public Rectangle getLayoutedRec() {
NodeList nodes = joinDirectedGraph.getNodes();
Rectangle fullRec = new Rectangle(0, 0, 0, 0);
Iterator it = nodes.iterator();
while (it.hasNext()) {
ERTableNode node = (ERTableNode) it.next();
LayoutUtil.unionAndExpand(fullRec, node.getRectangle());
}
return fullRec;
}
use of org.eclipse.draw2d.geometry.Rectangle in project cubrid-manager by CUBRID.
the class ERMinJoinDirectedGraphLayout method adjust.
private void adjust() {
Rectangle fullRec = getLayoutedRec();
int adjustX = DEFAULT_SPACE_LEFT + Math.abs(fullRec.x);
int adjustY = DEFAULT_SPACE_UP + Math.abs(fullRec.y);
adjust(adjustX, adjustY);
}
use of org.eclipse.draw2d.geometry.Rectangle in project cubrid-manager by CUBRID.
the class CubridTableParser method buildERTables.
/**
* Build the ER tables node information and its relationship. If its
* relationship tables are not added, donot build these relationship for
* efficiency. <br>
* This method only build and add , donot fire listener for UI updating
*
* @param schemaInfos Collection<schemaInfo> should be built and added
* tables
* @param successTables be built successfully
* @param startX startX > 0. if it is less than 0, the param will be
* omitted.
* @param startY
* @param isPartitionLayout if it is true, omit the startX and startY. These
* table will be arranged at the bottom of the canvas.
* @throws Exception If throw exception, then all of input table donot be
* built
*/
public void buildERTables(Collection<SchemaInfo> schemaInfos, int startX, int startY, boolean isPartitionLayout) {
if (schemaInfos == null || schemaInfos.size() == 0) {
return;
}
for (SchemaInfo schemaInfo : schemaInfos) {
if (erSchema.getTable(schemaInfo.getClassname()) != null) {
existedTableNames.add(schemaInfo.getClassname());
continue;
}
this.schemaInfos.put(schemaInfo.getClassname(), schemaInfo);
}
Set<String> tables = this.schemaInfos.keySet();
for (String name : tables) {
SchemaInfo schemaInfo = this.schemaInfos.get(name);
ERTable erTable = null;
try {
if (erSchema.getTable(schemaInfo.getClassname()) != null) {
// the table has been built by referenced table
erTable = erSchema.getTable(schemaInfo.getClassname());
} else {
erTable = new ERTable(schemaInfo, erSchema);
boolean success = erSchema.addTable(erTable);
if (success && !successTables.contains(erTable)) {
successTables.add(erTable);
}
buildERTable(erTable, schemaInfo);
}
if (isPartitionLayout) {
erTable.setNeedPartitionLayout(true);
} else if (startX > -1 && startY > -1) {
erTable.setBounds(new Rectangle(startX, startY, erTable.getMinWidth(), erTable.getMinHeight()));
startY += erTable.getMinHeight() + DEFAULT_VERTICAL_DISTANCE;
}
} catch (Exception e) {
failedTables.put(name, e);
erSchema.deleteTableAndFire(erTable);
successTables.remove(erTable);
LOGGER.warn(e.getMessage());
}
}
this.schemaInfos.clear();
}
use of org.eclipse.draw2d.geometry.Rectangle 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;
}
Aggregations