Search in sources :

Example 6 with CompositePropertiesEditionPart

use of org.eclipse.emf.eef.runtime.impl.parts.CompositePropertiesEditionPart 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

CompositePropertiesEditionPart (org.eclipse.emf.eef.runtime.impl.parts.CompositePropertiesEditionPart)6 EObject (org.eclipse.emf.ecore.EObject)2 ReferencesTableSettings (org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings)2 Viewer (org.eclipse.jface.viewers.Viewer)2 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)2 Reference (org.obeonetwork.dsl.environment.Reference)2 OppositePropertiesEditionPart (org.obeonetwork.dsl.environment.parts.OppositePropertiesEditionPart)2 RiskPropertiesEditionPart (fr.gouv.mindef.safran.graalextensions.parts.RiskPropertiesEditionPart)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 EObjectStrictFilter (org.eclipse.emf.eef.runtime.impl.filters.EObjectStrictFilter)1 EObjectFlatComboSettings (org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings)1 Column (org.obeonetwork.dsl.database.Column)1 Sequence (org.obeonetwork.dsl.database.Sequence)1 Table (org.obeonetwork.dsl.database.Table)1 ColumnPropertiesEditionPart (org.obeonetwork.dsl.database.parts.ColumnPropertiesEditionPart)1 PrimaryKeyPropertiesEditionPart (org.obeonetwork.dsl.database.parts.PrimaryKeyPropertiesEditionPart)1 MetaData (org.obeonetwork.dsl.environment.MetaData)1 ObeoDSMObject (org.obeonetwork.dsl.environment.ObeoDSMObject)1 MetadatasPropertiesEditionPart (org.obeonetwork.dsl.environment.parts.MetadatasPropertiesEditionPart)1