Search in sources :

Example 1 with DataBasePropertiesEditionPart

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

the class DataBasePropertiesEditionComponent 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);
        final DataBase dataBase = (DataBase) elt;
        final DataBasePropertiesEditionPart dataBasePart = (DataBasePropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(DatabaseViewsRepository.DataBase_.Properties.name))
            dataBasePart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, dataBase.getName()));
        if (isAccessible(DatabaseViewsRepository.DataBase_.Properties.url))
            dataBasePart.setUrl(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, dataBase.getUrl()));
        if (isAccessible(DatabaseViewsRepository.DataBase_.Properties.comments))
            dataBasePart.setComments(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, dataBase.getComments()));
        if (isAccessible(DatabaseViewsRepository.DataBase_.Properties.usedLibraries)) {
            usedLibrariesSettings = new ReferencesTableSettings(dataBase, TypesLibraryPackage.eINSTANCE.getTypesLibraryUser_UsedLibraries());
            dataBasePart.initUsedLibraries(usedLibrariesSettings);
        }
        if (isAccessible(DatabaseViewsRepository.DataBase_.Properties.usedLibraries)) {
            dataBasePart.addFilterToUsedLibraries(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) {
                    if (element instanceof EObject)
                        return (!dataBasePart.isContainedInUsedLibrariesTable((EObject) element));
                    return element instanceof String && element.equals("");
                }
            });
            dataBasePart.addFilterToUsedLibraries(new EObjectStrictFilter(TypesLibraryPackage.Literals.TYPES_LIBRARY));
        // Start of user code for additional businessfilters for usedLibraries
        // End of user code
        }
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : EObjectStrictFilter(org.eclipse.emf.eef.runtime.impl.filters.EObjectStrictFilter) ReferencesTableSettings(org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) EObject(org.eclipse.emf.ecore.EObject) Viewer(org.eclipse.jface.viewers.Viewer) EObject(org.eclipse.emf.ecore.EObject) DataBasePropertiesEditionPart(org.obeonetwork.dsl.database.parts.DataBasePropertiesEditionPart) DataBase(org.obeonetwork.dsl.database.DataBase)

Aggregations

EObject (org.eclipse.emf.ecore.EObject)1 EObjectStrictFilter (org.eclipse.emf.eef.runtime.impl.filters.EObjectStrictFilter)1 ReferencesTableSettings (org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)1 DataBase (org.obeonetwork.dsl.database.DataBase)1 DataBasePropertiesEditionPart (org.obeonetwork.dsl.database.parts.DataBasePropertiesEditionPart)1