Search in sources :

Example 81 with Rectangle

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;
}
Also used : Insets(org.eclipse.draw2d.geometry.Insets) Rectangle(org.eclipse.draw2d.geometry.Rectangle)

Example 82 with Rectangle

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;
}
Also used : NodeList(org.eclipse.draw2d.graph.NodeList) Rectangle(org.eclipse.draw2d.geometry.Rectangle) Iterator(java.util.Iterator)

Example 83 with Rectangle

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);
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) Point(org.eclipse.draw2d.geometry.Point)

Example 84 with Rectangle

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();
}
Also used : Rectangle(org.eclipse.draw2d.geometry.Rectangle) ERException(com.cubrid.common.ui.er.ERException) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo) ERWinSchemaInfo(com.cubrid.common.ui.cubrid.database.erwin.model.ERWinSchemaInfo)

Example 85 with Rectangle

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

Aggregations

Rectangle (org.eclipse.draw2d.geometry.Rectangle)347 Point (org.eclipse.draw2d.geometry.Point)107 Dimension (org.eclipse.draw2d.geometry.Dimension)80 IFigure (org.eclipse.draw2d.IFigure)43 List (java.util.List)24 AbstractWidgetModel (org.csstudio.opibuilder.model.AbstractWidgetModel)18 DoubleRectangle (edu.cmu.cs.hcii.cogtool.model.DoubleRectangle)17 PointList (org.eclipse.draw2d.geometry.PointList)16 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)15 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)14 ArrayList (java.util.ArrayList)11 Iterator (java.util.Iterator)11 PrecisionRectangle (org.eclipse.draw2d.geometry.PrecisionRectangle)11 NodeContainer (org.talend.designer.core.ui.editor.nodecontainer.NodeContainer)11 AbstractContainerModel (org.csstudio.opibuilder.model.AbstractContainerModel)10 AbstractGraphicalEditPart (org.eclipse.gef.editparts.AbstractGraphicalEditPart)10 TableFigure (com.cubrid.common.ui.er.figures.TableFigure)8 Viewport (org.eclipse.draw2d.Viewport)8 Node (org.talend.designer.core.ui.editor.nodes.Node)8 Image (org.eclipse.swt.graphics.Image)7