use of org.obeonetwork.dsl.database.IndexElement in project InformationSystem by ObeoNetwork.
the class IndexElementItemProvider method getText.
/**
* This returns the label text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
@Override
public String getText(Object object) {
IndexElement indexElement = (IndexElement) object;
String label = "";
if (indexElement.getColumn() != null) {
label += indexElement.getColumn().getName();
}
label += " ";
if (indexElement.isAsc() == true) {
label += getString("_UI_IndexElement_ASC");
} else {
label += getString("_UI_IndexElement_DESC");
}
return label == null || label.length() == 0 ? getString("_UI_IndexElement_type") : label;
}
use of org.obeonetwork.dsl.database.IndexElement in project InformationSystem by ObeoNetwork.
the class ColumnSpec method addToUniqueIndex.
@Override
public void addToUniqueIndex() {
if (isUnique() == false && getOwner() != null && getOwner() instanceof Table) {
Table table = (Table) getOwner();
// Check if there is a unique index defined on the table
Index uniqueIndex = null;
for (Index index : table.getIndexes()) {
if (index.isUnique()) {
uniqueIndex = index;
break;
}
}
if (uniqueIndex == null) {
// Create a new unique index
uniqueIndex = DatabaseFactory.eINSTANCE.createIndex();
uniqueIndex.setName(table.getName() + "_UNIQUE_INDEX");
uniqueIndex.setUnique(true);
table.getIndexes().add(uniqueIndex);
}
// We are sure we have a unique index here
IndexElement indexElt = DatabaseFactory.eINSTANCE.createIndexElement();
uniqueIndex.getElements().add(indexElt);
indexElt.setAsc(true);
indexElt.setColumn(this);
}
}
use of org.obeonetwork.dsl.database.IndexElement in project InformationSystem by ObeoNetwork.
the class IndexPropertiesEditionComponent method updateSemanticModel.
/**
* {@inheritDoc}
* @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#updateSemanticModel(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)
*/
public void updateSemanticModel(final IPropertiesEditionEvent event) {
Index index = (Index) semanticObject;
if (DatabaseViewsRepository.Index.Properties.name == event.getAffectedEditor()) {
index.setName((java.lang.String) EEFConverterUtil.createFromString(EcorePackage.Literals.ESTRING, (String) event.getNewValue()));
}
if (DatabaseViewsRepository.Index.Properties.qualifier == event.getAffectedEditor()) {
index.setQualifier((java.lang.String) EEFConverterUtil.createFromString(EcorePackage.Literals.ESTRING, (String) event.getNewValue()));
}
if (DatabaseViewsRepository.Index.Properties.unique == event.getAffectedEditor()) {
index.setUnique((Boolean) event.getNewValue());
}
if (DatabaseViewsRepository.Index.Properties.cardinality == event.getAffectedEditor()) {
index.setCardinality((EEFConverterUtil.createIntFromString(EcorePackage.Literals.EINT, (String) event.getNewValue())));
}
if (DatabaseViewsRepository.Index.Properties.indexType == event.getAffectedEditor()) {
index.setIndexType((java.lang.String) EEFConverterUtil.createFromString(EcorePackage.Literals.ESTRING, (String) event.getNewValue()));
}
if (DatabaseViewsRepository.Index.Properties.comments == event.getAffectedEditor()) {
index.setComments((java.lang.String) EEFConverterUtil.createFromString(EcorePackage.Literals.ESTRING, (String) event.getNewValue()));
}
if (DatabaseViewsRepository.Index.Properties.elements == event.getAffectedEditor()) {
if (event.getKind() == PropertiesEditionEvent.ADD) {
EReferencePropertiesEditionContext context = new EReferencePropertiesEditionContext(editingContext, this, elementsSettings, editingContext.getAdapterFactory());
PropertiesEditingProvider provider = (PropertiesEditingProvider) editingContext.getAdapterFactory().adapt(semanticObject, PropertiesEditingProvider.class);
if (provider != null) {
PropertiesEditingPolicy policy = provider.getPolicy(context);
if (policy instanceof CreateEditingPolicy) {
policy.execute();
}
}
} else if (event.getKind() == PropertiesEditionEvent.EDIT) {
EObjectPropertiesEditionContext context = new EObjectPropertiesEditionContext(editingContext, this, (EObject) event.getNewValue(), editingContext.getAdapterFactory());
PropertiesEditingProvider provider = (PropertiesEditingProvider) editingContext.getAdapterFactory().adapt((EObject) event.getNewValue(), PropertiesEditingProvider.class);
if (provider != null) {
PropertiesEditingPolicy editionPolicy = provider.getPolicy(context);
if (editionPolicy != null) {
editionPolicy.execute();
}
}
} else if (event.getKind() == PropertiesEditionEvent.REMOVE) {
elementsSettings.removeFromReference((EObject) event.getNewValue());
} else if (event.getKind() == PropertiesEditionEvent.MOVE) {
elementsSettings.move(event.getNewIndex(), (IndexElement) event.getNewValue());
}
}
}
use of org.obeonetwork.dsl.database.IndexElement in project InformationSystem by ObeoNetwork.
the class CreationUtils method createIndexElement.
public static IndexElement createIndexElement(Index index) {
IndexElement indexElement = DatabaseFactory.eINSTANCE.createIndexElement();
index.getElements().add(indexElement);
return indexElement;
}
Aggregations