Search in sources :

Example 1 with AddFKDialog

use of com.cubrid.common.ui.cubrid.table.dialog.AddFKDialog in project cubrid-manager by CUBRID.

the class CreateRelationshipCommand method execute.

@Override
public void execute() {
    if (!check()) {
        return;
    }
    ERSchema erSchema = foreignTable.getERSchema();
    SchemaInfo fkSchemaInfo = erSchema.getSchemaInfo(foreignTable.getName());
    AddFKDialog dlg = new AddFKDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), erSchema.getCubridDatabase(), fkSchemaInfo, null, false, erSchema.getAllSchemaInfo());
    dlg.setDefaultTableName(primaryTable.getName());
    int returnCode = dlg.open();
    if (returnCode == AddFKDialog.OK) {
        Constraint fk = dlg.getRetFK();
        if (fk == null) {
            return;
        }
        CubridTableParser parser = new CubridTableParser(erSchema);
        try {
            parser.addFKShip(foreignTable, fkSchemaInfo, fk);
            fkSchemaInfo.addConstraint(fk);
        } catch (Exception e) {
            CommonUITool.openErrorBox(e.getMessage());
        }
    }
}
Also used : Constraint(com.cubrid.common.core.common.model.Constraint) ERSchema(com.cubrid.common.ui.er.model.ERSchema) CubridTableParser(com.cubrid.common.ui.er.model.CubridTableParser) Constraint(com.cubrid.common.core.common.model.Constraint) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo) AddFKDialog(com.cubrid.common.ui.cubrid.table.dialog.AddFKDialog)

Aggregations

Constraint (com.cubrid.common.core.common.model.Constraint)1 SchemaInfo (com.cubrid.common.core.common.model.SchemaInfo)1 AddFKDialog (com.cubrid.common.ui.cubrid.table.dialog.AddFKDialog)1 CubridTableParser (com.cubrid.common.ui.er.model.CubridTableParser)1 ERSchema (com.cubrid.common.ui.er.model.ERSchema)1