use of org.jkiss.dbeaver.model.struct.DBSEntityAttribute in project dbeaver by serge-rider.
the class AttributesSelectorPage method fillAttributes.
private void fillAttributes(final DBSEntity entity) {
final List<DBSEntityAttribute> attrList = new ArrayList<>();
AbstractJob loadJob = new AbstractJob("Load entity attributes") {
@Override
protected IStatus run(DBRProgressMonitor monitor) {
monitor.beginTask("Load attributes", 1);
try {
for (DBSEntityAttribute attr : CommonUtils.safeCollection(entity.getAttributes(monitor))) {
if (isShowHiddenAttributes() || !DBUtils.isHiddenObject(attr) || DBUtils.isRowIdAttribute(attr)) {
attrList.add(attr);
}
}
} catch (DBException e) {
return GeneralUtils.makeErrorStatus("Error loading attributes", e);
} finally {
monitor.done();
}
return Status.OK_STATUS;
}
};
loadJob.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
UIUtils.syncExec(() -> {
for (DBSEntityAttribute attribute : attrList) {
TableItem columnItem = new TableItem(columnsTable, SWT.NONE);
AttributeInfo col = new AttributeInfo(attribute);
attributes.add(col);
DBNDatabaseNode attributeNode = DBWorkbench.getPlatform().getNavigatorModel().findNode(attribute);
if (attributeNode != null) {
columnItem.setImage(0, DBeaverIcons.getImage(attributeNode.getNodeIcon()));
}
fillAttributeColumns(attribute, col, columnItem);
columnItem.setData(col);
if (isColumnSelected(attribute)) {
columnItem.setChecked(true);
handleItemSelect(columnItem, false);
}
}
UIUtils.packColumns(columnsTable);
updateToggleButton();
});
}
});
loadJob.schedule();
}
use of org.jkiss.dbeaver.model.struct.DBSEntityAttribute 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.model.struct.DBSEntityAttribute 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.model.struct.DBSEntityAttribute in project dbeaver by serge-rider.
the class ComplexTypeAttributeTransformer method createNestedTypeBindings.
static void createNestedTypeBindings(DBCSession session, DBDAttributeBinding attribute, List<Object[]> rows, DBSEntity dataType) throws DBException {
List<DBDAttributeBinding> nestedBindings = new ArrayList<>();
for (DBSEntityAttribute nestedAttr : CommonUtils.safeCollection(dataType.getAttributes(session.getProgressMonitor()))) {
DBDAttributeBindingType nestedBinding = new DBDAttributeBindingType(attribute, nestedAttr, nestedBindings.size());
nestedBinding.lateBinding(session, rows);
nestedBindings.add(nestedBinding);
}
if (!nestedBindings.isEmpty()) {
attribute.setNestedBindings(nestedBindings);
}
}
use of org.jkiss.dbeaver.model.struct.DBSEntityAttribute 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;
});
}
Aggregations