use of org.jkiss.dbeaver.ui.editors.object.struct.EditConstraintPage in project dbeaver by dbeaver.
the class ResultSetViewer method editEntityIdentifier.
boolean editEntityIdentifier(DBRProgressMonitor monitor) throws DBException {
DBDRowIdentifier virtualEntityIdentifier = getVirtualEntityIdentifier();
if (virtualEntityIdentifier == null) {
log.warn("No virtual identifier");
return false;
}
DBVEntityConstraint constraint = (DBVEntityConstraint) virtualEntityIdentifier.getUniqueKey();
EditConstraintPage page = new EditConstraintPage("Define virtual unique identifier", constraint);
if (!page.edit()) {
return false;
}
Collection<DBSEntityAttribute> uniqueAttrs = page.getSelectedAttributes();
constraint.setAttributes(uniqueAttrs);
virtualEntityIdentifier = getVirtualEntityIdentifier();
if (virtualEntityIdentifier == null) {
log.warn("No virtual identifier defined");
return false;
}
virtualEntityIdentifier.reloadAttributes(monitor, model.getAttributes());
persistConfig();
return true;
}
use of org.jkiss.dbeaver.ui.editors.object.struct.EditConstraintPage in project dbeaver by serge-rider.
the class EditVirtualEntityDialog method createUniqueKeysPage.
private void createUniqueKeysPage(TabFolder tabFolder) {
uniqueConstraint = vEntity.getBestIdentifier();
if (uniqueConstraint == null) {
return;
}
TabItem ukItem = new TabItem(tabFolder, SWT.NONE);
ukItem.setText("Virtual Unique Key");
ukItem.setImage(DBeaverIcons.getImage(DBIcon.TREE_UNIQUE_KEY));
ukItem.setData(InitPage.UNIQUE_KEY);
editUniqueKeyPage = new EditConstraintPage("Define unique identifier", uniqueConstraint);
editUniqueKeyPage.createControl(tabFolder);
ukItem.setControl(editUniqueKeyPage.getControl());
}
use of org.jkiss.dbeaver.ui.editors.object.struct.EditConstraintPage in project dbeaver by serge-rider.
the class OracleConstraintConfigurator method configureObject.
@Override
public OracleTableConstraint configureObject(DBRProgressMonitor monitor, Object parent, OracleTableConstraint constraint) {
return UITask.run(() -> {
EditConstraintPage editPage = new EditConstraintPage(OracleUIMessages.edit_oracle_constraint_manager_dialog_title, constraint, new DBSEntityConstraintType[] { DBSEntityConstraintType.PRIMARY_KEY, DBSEntityConstraintType.UNIQUE_KEY, DBSEntityConstraintType.CHECK });
if (!editPage.edit()) {
return null;
}
constraint.setName(editPage.getConstraintName());
constraint.setConstraintType(editPage.getConstraintType());
constraint.setSearchCondition(editPage.getConstraintExpression());
int colIndex = 1;
for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
constraint.addColumn(new OracleTableConstraintColumn(constraint, (OracleTableColumn) tableColumn, colIndex++));
}
return constraint;
});
}
use of org.jkiss.dbeaver.ui.editors.object.struct.EditConstraintPage in project dbeaver by serge-rider.
the class MySQLConstraintConfigurator method configureObject.
@Override
public MySQLTableConstraint configureObject(DBRProgressMonitor monitor, Object parent, MySQLTableConstraint constraint) {
MySQLDataSource dataSource = constraint.getDataSource();
return UITask.run(() -> {
EditConstraintPage editPage;
if (dataSource.supportsCheckConstraints()) {
editPage = new EditConstraintPage(MySQLUIMessages.edit_constraint_manager_title, constraint, new DBSEntityConstraintType[] { DBSEntityConstraintType.PRIMARY_KEY, DBSEntityConstraintType.UNIQUE_KEY, DBSEntityConstraintType.CHECK });
} else {
editPage = new EditConstraintPage(MySQLUIMessages.edit_constraint_manager_title, constraint, new DBSEntityConstraintType[] { DBSEntityConstraintType.PRIMARY_KEY, DBSEntityConstraintType.UNIQUE_KEY });
}
if (!editPage.edit()) {
return null;
}
constraint.setName(editPage.getConstraintName());
constraint.setConstraintType(editPage.getConstraintType());
if (editPage.getConstraintType() == DBSEntityConstraintType.CHECK && dataSource.supportsCheckConstraints()) {
constraint.setCheckClause(editPage.getConstraintExpression());
} else {
int colIndex = 1;
for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
constraint.addColumn(new MySQLTableConstraintColumn(constraint, (MySQLTableColumn) tableColumn, colIndex++));
}
}
return constraint;
});
}
use of org.jkiss.dbeaver.ui.editors.object.struct.EditConstraintPage in project dbeaver by dbeaver.
the class MySQLConstraintConfigurator method configureObject.
@Override
public MySQLTableConstraint configureObject(DBRProgressMonitor monitor, Object parent, MySQLTableConstraint constraint) {
MySQLDataSource dataSource = constraint.getDataSource();
return UITask.run(() -> {
EditConstraintPage editPage;
if (dataSource.supportsCheckConstraints()) {
editPage = new EditConstraintPage(MySQLUIMessages.edit_constraint_manager_title, constraint, new DBSEntityConstraintType[] { DBSEntityConstraintType.PRIMARY_KEY, DBSEntityConstraintType.UNIQUE_KEY, DBSEntityConstraintType.CHECK });
} else {
editPage = new EditConstraintPage(MySQLUIMessages.edit_constraint_manager_title, constraint, new DBSEntityConstraintType[] { DBSEntityConstraintType.PRIMARY_KEY, DBSEntityConstraintType.UNIQUE_KEY });
}
if (!editPage.edit()) {
return null;
}
constraint.setName(editPage.getConstraintName());
constraint.setConstraintType(editPage.getConstraintType());
if (editPage.getConstraintType() == DBSEntityConstraintType.CHECK && dataSource.supportsCheckConstraints()) {
constraint.setCheckClause(editPage.getConstraintExpression());
} else {
int colIndex = 1;
for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
constraint.addColumn(new MySQLTableConstraintColumn(constraint, (MySQLTableColumn) tableColumn, colIndex++));
}
}
return constraint;
});
}
Aggregations