use of org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage in project dbeaver by dbeaver.
the class ExasolIndexConfigurator method configureObject.
@Override
public ExasolTableIndex configureObject(DBRProgressMonitor monitor, Object container, ExasolTableIndex index) {
return UITask.run(() -> {
EditIndexPage editPage = new EditIndexPage("create index", index, Arrays.asList(new DBSIndexType("LOCAL", "LOCAL"), new DBSIndexType("GLOBAL", "GLOBAL")), false);
if (!editPage.edit()) {
return null;
}
index.setIndexType(editPage.getIndexType());
int colIndex = 1;
for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
index.addColumn(new ExasolTableIndexColumn(index, (ExasolTableColumn) tableColumn, colIndex++));
}
index.setName(index.getIndexType().getName() + " INDEX " + index.getSimpleColumnString());
return index;
});
}
use of org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage in project dbeaver by serge-rider.
the class DB2IndexConfigurator method configureObject.
@Override
public DB2Index configureObject(DBRProgressMonitor monitor, Object container, DB2Index index) {
return UITask.run(() -> {
DB2TableBase table = (DB2TableBase) container;
EditIndexPage editPage = new EditIndexPage(DB2Messages.edit_db2_index_manager_dialog_title, index, IX_TYPES);
if (!editPage.edit()) {
return null;
}
String tableName = CommonUtils.escapeIdentifier(table.getName());
String colName = CommonUtils.escapeIdentifier(editPage.getSelectedAttributes().iterator().next().getName());
String indexBaseName = String.format(CONS_IX_NAME, tableName, colName);
String indexName = DBObjectNameCaseTransformer.transformName(table.getDataSource(), indexBaseName);
index.setName(indexName);
index.setIndexType(editPage.getIndexType());
index.setUniqueRule(editPage.isUnique() ? DB2UniqueRule.U : DB2UniqueRule.D);
int colIndex = 1;
for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
index.addColumn(new DB2IndexColumn(index, (DB2TableColumn) tableColumn, colIndex++, !Boolean.TRUE.equals(editPage.getAttributeProperty(tableColumn, EditIndexPage.PROP_DESC))));
}
return index;
});
}
use of org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage in project dbeaver by serge-rider.
the class GenericTableIndexConfigurator method configureObject.
@Override
public GenericTableIndex configureObject(DBRProgressMonitor monitor, Object table, GenericTableIndex index) {
GenericTableBase tableBase = (GenericTableBase) table;
boolean supportUniqueIndexes = tableBase.supportUniqueIndexes();
Collection<DBSIndexType> tableIndexTypes = tableBase.getTableIndexTypes();
return new UITask<GenericTableIndex>() {
@Override
protected GenericTableIndex runTask() {
EditIndexPage editPage = new EditIndexPage("Create index", index, tableIndexTypes, supportUniqueIndexes);
if (!editPage.edit()) {
return null;
}
index.setIndexType(editPage.getIndexType());
StringBuilder idxName = new StringBuilder(64);
idxName.append(CommonUtils.escapeIdentifier(index.getTable().getName()));
int colIndex = 1;
for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
if (colIndex == 1) {
idxName.append("_").append(CommonUtils.escapeIdentifier(tableColumn.getName()));
}
index.addColumn(new GenericTableIndexColumn(index, (GenericTableColumn) tableColumn, colIndex++, !Boolean.TRUE.equals(editPage.getAttributeProperty(tableColumn, EditIndexPage.PROP_DESC))));
}
idxName.append("_IDX");
index.setName(DBObjectNameCaseTransformer.transformObjectName(index, idxName.toString()));
index.setUnique(editPage.isUnique());
return index;
}
}.execute();
}
use of org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage in project dbeaver by serge-rider.
the class OracleIndexConfigurator method configureObject.
@Override
public OracleTableIndex configureObject(DBRProgressMonitor monitor, Object container, OracleTableIndex index) {
return UITask.run(() -> {
EditIndexPage editPage = new EditIndexPage(OracleUIMessages.edit_oracle_index_manager_dialog_title, index, Collections.singletonList(DBSIndexType.OTHER));
if (!editPage.edit()) {
return null;
}
StringBuilder idxName = new StringBuilder(64);
// $NON-NLS-1$
idxName.append(CommonUtils.escapeIdentifier(index.getTable().getName())).append("_").append(CommonUtils.escapeIdentifier(editPage.getSelectedAttributes().iterator().next().getName())).append(// $NON-NLS-1$
"_IDX");
index.setName(DBObjectNameCaseTransformer.transformName(index.getDataSource(), idxName.toString()));
index.setUnique(editPage.isUnique());
index.setIndexType(editPage.getIndexType());
int colIndex = 1;
for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
index.addColumn(new OracleTableIndexColumn(index, (OracleTableColumn) tableColumn, colIndex++, !Boolean.TRUE.equals(editPage.getAttributeProperty(tableColumn, EditIndexPage.PROP_DESC)), null));
}
return index;
});
}
use of org.jkiss.dbeaver.ui.editors.object.struct.EditIndexPage in project dbeaver by dbeaver.
the class SQLServerIndexConfigurator method configureObject.
@Override
public SQLServerTableIndex configureObject(DBRProgressMonitor monitor, Object container, SQLServerTableIndex index) {
return UITask.run(() -> {
EditIndexPage editPage = new EditIndexPage("Create index", index, Arrays.asList(SQLSERVER_INDEX_TYPES));
if (!editPage.edit()) {
return null;
}
index.setUnique(editPage.isUnique());
index.setIndexType(editPage.getIndexType());
index.setDescription(editPage.getDescription());
StringBuilder idxName = new StringBuilder(64);
idxName.append(CommonUtils.escapeIdentifier(index.getTable().getName()));
int colIndex = 1;
for (DBSEntityAttribute tableColumn : editPage.getSelectedAttributes()) {
if (colIndex == 1) {
idxName.append("_").append(CommonUtils.escapeIdentifier(tableColumn.getName()));
}
index.addColumn(new SQLServerTableIndexColumn(index, 0, (SQLServerTableColumn) tableColumn, colIndex++, !Boolean.TRUE.equals(editPage.getAttributeProperty(tableColumn, EditIndexPage.PROP_DESC))));
}
idxName.append("_IDX");
index.setName(DBObjectNameCaseTransformer.transformObjectName(index, idxName.toString()));
return index;
});
}
Aggregations