use of com.cubrid.cubridmanager.core.cubrid.table.model.SchemaChangeLog in project cubrid-manager by CUBRID.
the class EditVirtualTableDialog method openEditIndexDialog.
/**
* Open the index edit dialog with the constraint object
*
* @param editedIndex Constraint
*/
private void openEditIndexDialog(Constraint editedIndex) {
boolean isNewConstraint = true;
for (int i = 0, len = originalConstraints.size(); i < len; i++) {
if (originalConstraints.get(i) == editedIndex) {
isNewConstraint = false;
}
}
SchemaInfo newSchemaInfo = getNewSchemaInfo();
AddIndexDialog dlg = new AddIndexDialog(getShell(), newSchemaInfo, database, editedIndex, isNewConstraint);
int returnCode = dlg.open();
if (returnCode == AddIndexDialog.OK) {
Constraint newIndex = dlg.getIndexConstraint();
if (newIndex == null) {
return;
}
newSchemaInfo.removeConstraintByName(editedIndex.getName(), editedIndex.getType());
newSchemaInfo.addConstraint(newIndex);
// For bug TOOLS-2394 Unique index can't be added again
if (Constraint.ConstraintType.UNIQUE.getText().equals(newIndex.getType()) && newIndex.getAttributes().size() == 1) {
DBAttribute attr = newSchemaInfo.getDBAttributeByName(newIndex.getAttributes().get(0), false);
attr.setUnique(true);
loadColumnData();
}
boolean modifiedUK = Constraint.ConstraintType.UNIQUE.getText().equals(editedIndex.getType()) && editedIndex.getAttributes().size() == 1;
boolean noNewUK = !Constraint.ConstraintType.UNIQUE.getText().equals(newIndex.getType()) || newIndex.getAttributes().size() != 1;
if (modifiedUK && noNewUK) {
String attrName = editedIndex.getAttributes().get(0);
DBAttribute attr = newSchemaInfo.getDBAttributeByName(attrName, false);
if (attr != null) {
attr.setUnique(false);
loadColumnData();
}
}
String key1 = editedIndex.getDefaultName(newSchemaInfo.getClassname()) + "$" + editedIndex.getName();
String key2 = newIndex.getDefaultName(newSchemaInfo.getClassname()) + "$" + newIndex.getName();
SchemaChangeLog changeLog = new SchemaChangeLog(key1, key2, SchemeInnerType.TYPE_INDEX);
schemaChangeMgr.addSchemeChangeLog(changeLog);
indexTableView.setInput(newSchemaInfo);
}
}
Aggregations