Search in sources :

Example 1 with ColumnPropertiesEditionPart

use of org.obeonetwork.dsl.database.parts.ColumnPropertiesEditionPart in project InformationSystem by ObeoNetwork.

the class CustomColumnPropertiesEditionComponent method initPart.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 */
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
    super.initPart(key, kind, elt, allResource);
    setInitializing(true);
    if (editingPart != null && key == partKey) {
        final ColumnPropertiesEditionPart basePart = (ColumnPropertiesEditionPart) editingPart;
        updateTypeFieldsVisibility((Column) elt, basePart);
    }
    setInitializing(false);
}
Also used : ColumnPropertiesEditionPart(org.obeonetwork.dsl.database.parts.ColumnPropertiesEditionPart)

Example 2 with ColumnPropertiesEditionPart

use of org.obeonetwork.dsl.database.parts.ColumnPropertiesEditionPart in project InformationSystem by ObeoNetwork.

the class ColumnPropertiesEditionComponent method initPart.

/**
 * {@inheritDoc}
 *
 * @see org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent#initPart(java.lang.Object, int, org.eclipse.emf.ecore.EObject,
 *      org.eclipse.emf.ecore.resource.ResourceSet)
 */
public void initPart(Object key, int kind, EObject elt, ResourceSet allResource) {
    setInitializing(true);
    if (editingPart != null && key == partKey) {
        editingPart.setContext(elt, allResource);
        if (editingPart instanceof CompositePropertiesEditionPart) {
            ((CompositePropertiesEditionPart) editingPart).getSettings().add(typeSettings);
            ((CompositePropertiesEditionPart) editingPart).getSettings().add(lengthSettings);
            ((CompositePropertiesEditionPart) editingPart).getSettings().add(precisionSettings);
            ((CompositePropertiesEditionPart) editingPart).getSettings().add(literalsSettings);
        }
        final Column column = (Column) elt;
        final ColumnPropertiesEditionPart columnPart = (ColumnPropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(DatabaseViewsRepository.Column.Properties.name))
            columnPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, column.getName()));
        if (isAccessible(DatabaseViewsRepository.Column.Properties.NullablePkAndUnique.nullable)) {
            columnPart.setNullable(column.isNullable());
        }
        if (isAccessible(DatabaseViewsRepository.Column.Properties.NullablePkAndUnique.primaryKey)) {
            columnPart.setPrimaryKey(column.isInPrimaryKey());
        }
        if (isAccessible(DatabaseViewsRepository.Column.Properties.NullablePkAndUnique.unique)) {
            columnPart.setUnique(column.isUnique());
        }
        if (isAccessible(DatabaseViewsRepository.Column.Properties.Sequence.autoincrement)) {
            columnPart.setAutoincrement(column.isAutoincrement());
        }
        if (isAccessible(DatabaseViewsRepository.Column.Properties.Sequence.sequence_)) {
            // init part
            sequenceSettings = new EObjectFlatComboSettings(column, DatabasePackage.eINSTANCE.getColumn_Sequence());
            columnPart.initSequence(sequenceSettings);
            // set the button mode
            columnPart.setSequenceButtonMode(ButtonsModeEnum.BROWSE);
        }
        if (isAccessible(DatabaseViewsRepository.Column.Properties.defaultValue))
            columnPart.setDefaultValue(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, column.getDefaultValue()));
        if (isAccessible(DatabaseViewsRepository.Column.Properties.comments))
            columnPart.setComments(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, column.getComments()));
        if (typeSettings.getSignificantObject() != null && isAccessible(DatabaseViewsRepository.Column.Properties.type)) {
            columnPart.initType(EEFUtils.choiceOfValues(typeSettings.getSignificantObject(), TypesLibraryPackage.eINSTANCE.getTypeInstance_NativeType()), typeSettings.getValue());
        }
        if (lengthSettings.getValue() != null && isAccessible(DatabaseViewsRepository.Column.Properties.TypeAttributes.length))
            columnPart.setLength(EEFConverterUtil.convertToString(EcorePackage.Literals.EINTEGER_OBJECT, lengthSettings.getValue()));
        if (precisionSettings.getValue() != null && isAccessible(DatabaseViewsRepository.Column.Properties.TypeAttributes.precision))
            columnPart.setPrecision(EEFConverterUtil.convertToString(EcorePackage.Literals.EINTEGER_OBJECT, precisionSettings.getValue()));
        if (literalsSettings.getSignificantObject() != null && isAccessible(DatabaseViewsRepository.Column.Properties.literals)) {
            columnPart.setLiterals((EList<?>) literalsSettings.getValue());
        }
        if (isAccessible(DatabaseViewsRepository.Column.Properties.Sequence.sequence_)) {
            columnPart.addFilterToSequence(new ViewerFilter() {

                /**
                 * {@inheritDoc}
                 *
                 * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
                 */
                public boolean select(Viewer viewer, Object parentElement, Object element) {
                    // $NON-NLS-1$
                    return (element instanceof String && element.equals("")) || (element instanceof Sequence);
                }
            });
        // Start of user code for additional businessfilters for sequence
        // End of user code
        }
    // Start of user code for additional businessfilters for type
    // End of user code
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Column(org.obeonetwork.dsl.database.Column) CompositePropertiesEditionPart(org.eclipse.emf.eef.runtime.impl.parts.CompositePropertiesEditionPart) Viewer(org.eclipse.jface.viewers.Viewer) EObject(org.eclipse.emf.ecore.EObject) EObjectFlatComboSettings(org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings) Sequence(org.obeonetwork.dsl.database.Sequence) ColumnPropertiesEditionPart(org.obeonetwork.dsl.database.parts.ColumnPropertiesEditionPart)

Aggregations

ColumnPropertiesEditionPart (org.obeonetwork.dsl.database.parts.ColumnPropertiesEditionPart)2 EObject (org.eclipse.emf.ecore.EObject)1 CompositePropertiesEditionPart (org.eclipse.emf.eef.runtime.impl.parts.CompositePropertiesEditionPart)1 EObjectFlatComboSettings (org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)1 Column (org.obeonetwork.dsl.database.Column)1 Sequence (org.obeonetwork.dsl.database.Sequence)1