Search in sources :

Example 6 with ERSchema

use of com.cubrid.common.ui.er.model.ERSchema in project cubrid-manager by CUBRID.

the class ERSchemaEditor method setInput.

protected void setInput(IEditorInput input) {
    super.setInput(input);
    if (input instanceof SchemaEditorInput) {
        database = ((SchemaEditorInput) input).getDatabase();
    }
    tableNodesLoader = new ERSchemaTableNodesLoader(database);
    erSchema = new ERSchema(database.getName(), (SchemaEditorInput) input);
    erSchema.setLayoutManualDesiredAndFire(true);
    initCollections(database.getDatabaseInfo());
}
Also used : ERSchemaTableNodesLoader(com.cubrid.common.ui.er.loader.ERSchemaTableNodesLoader) SchemaEditorInput(com.cubrid.common.ui.er.SchemaEditorInput) ERSchema(com.cubrid.common.ui.er.model.ERSchema)

Example 7 with ERSchema

use of com.cubrid.common.ui.er.model.ERSchema 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)

Example 8 with ERSchema

use of com.cubrid.common.ui.er.model.ERSchema in project cubrid-manager by CUBRID.

the class TableEditPolicy method createDeleteCommand.

@Override
protected Command createDeleteCommand(GroupRequest request) {
    TablePart tablePart = (TablePart) getHost();
    Rectangle bounds = tablePart.getFigure().getBounds().getCopy();
    ERSchema parent = (ERSchema) (tablePart.getParent().getModel());
    DeleteTableCommand deleteCmd = new DeleteTableCommand();
    deleteCmd.setSchema(parent);
    deleteCmd.setTable((ERTable) (tablePart.getModel()));
    deleteCmd.setOriginalBounds(bounds);
    return deleteCmd;
}
Also used : TablePart(com.cubrid.common.ui.er.part.TablePart) Rectangle(org.eclipse.draw2d.geometry.Rectangle) ERSchema(com.cubrid.common.ui.er.model.ERSchema) DeleteTableCommand(com.cubrid.common.ui.er.commands.DeleteTableCommand)

Example 9 with ERSchema

use of com.cubrid.common.ui.er.model.ERSchema in project cubrid-manager by CUBRID.

the class PartFactory method createEditPart.

public EditPart createEditPart(EditPart context, Object model) {
    EditPart part = null;
    if (model instanceof ERSchema) {
        part = new SchemaDiagramPart();
    } else if (model instanceof ERTable) {
        part = new TablePart();
    } else if (model instanceof Relationship) {
        part = new RelationshipPart();
    } else if (model instanceof ERTableColumn) {
        part = new ColumnPart();
    }
    if (null == part) {
        LOGGER.error("Part is null :" + context + "," + model);
    }
    part.setModel(model);
    return part;
}
Also used : Relationship(com.cubrid.common.ui.er.model.Relationship) ERTableColumn(com.cubrid.common.ui.er.model.ERTableColumn) EditPart(org.eclipse.gef.EditPart) ERSchema(com.cubrid.common.ui.er.model.ERSchema) ERTable(com.cubrid.common.ui.er.model.ERTable)

Example 10 with ERSchema

use of com.cubrid.common.ui.er.model.ERSchema in project cubrid-manager by CUBRID.

the class ERSchemaToolBar method createAutoLayoutComp.

/**
	 * Create auto layout button
	 *
	 * @return comp composite
	 */
private Composite createAutoLayoutComp() {
    Composite comp = new Composite(this, SWT.NONE);
    final GridLayout gdLayout = new GridLayout(1, false);
    gdLayout.marginHeight = 0;
    final GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    comp.setLayout(gdLayout);
    comp.setLayoutData(gridData);
    final Button autoLayoutButton = new Button(comp, SWT.PUSH | SWT.CENTER | SWT.FILL);
    autoLayoutButton.setLayoutData(gridData);
    autoLayoutButton.setText(Messages.btnAutoLayout);
    autoLayoutButton.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            ERSchema er = erSchemaEditor.getERSchema();
            er.setTmpAutoLayoutAndFire();
        }
    });
    return comp;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ERSchema(com.cubrid.common.ui.er.model.ERSchema) Event(org.eclipse.swt.widgets.Event) KeyEvent(org.eclipse.swt.events.KeyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

ERSchema (com.cubrid.common.ui.er.model.ERSchema)16 SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)6 ERTable (com.cubrid.common.ui.er.model.ERTable)5 Constraint (com.cubrid.common.core.common.model.Constraint)3 ERSchemaEditor (com.cubrid.common.ui.er.editor.ERSchemaEditor)3 CubridTableParser (com.cubrid.common.ui.er.model.CubridTableParser)3 ERTableColumn (com.cubrid.common.ui.er.model.ERTableColumn)3 List (java.util.List)3 ArrayList (java.util.ArrayList)2 Rectangle (org.eclipse.draw2d.geometry.Rectangle)2 DBAttribute (com.cubrid.common.core.common.model.DBAttribute)1 SerialInfo (com.cubrid.common.core.common.model.SerialInfo)1 AddFKDialog (com.cubrid.common.ui.cubrid.table.dialog.AddFKDialog)1 ERException (com.cubrid.common.ui.er.ERException)1 SchemaEditorInput (com.cubrid.common.ui.er.SchemaEditorInput)1 AddTableCommand (com.cubrid.common.ui.er.commands.AddTableCommand)1 DeleteTableCommand (com.cubrid.common.ui.er.commands.DeleteTableCommand)1 ERSchemaTableNodesLoader (com.cubrid.common.ui.er.loader.ERSchemaTableNodesLoader)1 PhysicalLogicRelation (com.cubrid.common.ui.er.logic.PhysicalLogicRelation)1 Relationship (com.cubrid.common.ui.er.model.Relationship)1