Search in sources :

Example 36 with ViewerFilter

use of org.eclipse.jface.viewers.ViewerFilter in project InformationSystem by ObeoNetwork.

the class ForeignKeyPropertiesEditionPartForm method createElementsTableComposition.

/**
 * @param container
 */
protected Composite createElementsTableComposition(FormToolkit widgetFactory, Composite parent) {
    this.elements = new ReferencesTable(getDescription(DatabaseViewsRepository.ForeignKey.Properties.elements, DatabaseMessages.ForeignKeyPropertiesEditionPart_ElementsLabel), new ReferencesTableListener() {

        public void handleAdd() {
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ForeignKeyPropertiesEditionPartForm.this, DatabaseViewsRepository.ForeignKey.Properties.elements, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, null));
            elements.refresh();
        }

        public void handleEdit(EObject element) {
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ForeignKeyPropertiesEditionPartForm.this, DatabaseViewsRepository.ForeignKey.Properties.elements, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.EDIT, null, element));
            elements.refresh();
        }

        public void handleMove(EObject element, int oldIndex, int newIndex) {
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ForeignKeyPropertiesEditionPartForm.this, DatabaseViewsRepository.ForeignKey.Properties.elements, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.MOVE, element, newIndex));
            elements.refresh();
        }

        public void handleRemove(EObject element) {
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ForeignKeyPropertiesEditionPartForm.this, DatabaseViewsRepository.ForeignKey.Properties.elements, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.REMOVE, null, element));
            elements.refresh();
        }

        public void navigateTo(EObject element) {
        }
    });
    for (ViewerFilter filter : this.elementsFilters) {
        this.elements.addFilter(filter);
    }
    this.elements.setHelpText(propertiesEditionComponent.getHelpContent(DatabaseViewsRepository.ForeignKey.Properties.elements, DatabaseViewsRepository.FORM_KIND));
    this.elements.createControls(parent, widgetFactory);
    this.elements.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (e.item != null && e.item.getData() instanceof EObject) {
                propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ForeignKeyPropertiesEditionPartForm.this, DatabaseViewsRepository.ForeignKey.Properties.elements, PropertiesEditionEvent.CHANGE, PropertiesEditionEvent.SELECTION_CHANGED, null, e.item.getData()));
            }
        }
    });
    GridData elementsData = new GridData(GridData.FILL_HORIZONTAL);
    elementsData.horizontalSpan = 3;
    this.elements.setLayoutData(elementsData);
    this.elements.setLowerBound(0);
    this.elements.setUpperBound(-1);
    elements.setID(DatabaseViewsRepository.ForeignKey.Properties.elements);
    // $NON-NLS-1$
    elements.setEEFType("eef::AdvancedTableComposition");
    // End of user code
    return parent;
}
Also used : ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) ReferencesTable(org.eclipse.emf.eef.runtime.ui.widgets.ReferencesTable) EObject(org.eclipse.emf.ecore.EObject) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) IPropertiesEditionEvent(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent) PropertiesEditionEvent(org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent) ReferencesTableListener(org.eclipse.emf.eef.runtime.ui.widgets.ReferencesTable.ReferencesTableListener)

Example 37 with ViewerFilter

use of org.eclipse.jface.viewers.ViewerFilter in project InformationSystem by ObeoNetwork.

the class ForeignKeysPropertiesEditionPartForm method createForeignKeysTableComposition.

/**
 * @param container
 */
protected Composite createForeignKeysTableComposition(FormToolkit widgetFactory, Composite parent) {
    this.foreignKeys = new ReferencesTable(getDescription(DatabaseViewsRepository.ForeignKeys.Properties.foreignKeys_, DatabaseMessages.ForeignKeysPropertiesEditionPart_ForeignKeysLabel), new ReferencesTableListener() {

        public void handleAdd() {
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ForeignKeysPropertiesEditionPartForm.this, DatabaseViewsRepository.ForeignKeys.Properties.foreignKeys_, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, null));
            foreignKeys.refresh();
        }

        public void handleEdit(EObject element) {
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ForeignKeysPropertiesEditionPartForm.this, DatabaseViewsRepository.ForeignKeys.Properties.foreignKeys_, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.EDIT, null, element));
            foreignKeys.refresh();
        }

        public void handleMove(EObject element, int oldIndex, int newIndex) {
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ForeignKeysPropertiesEditionPartForm.this, DatabaseViewsRepository.ForeignKeys.Properties.foreignKeys_, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.MOVE, element, newIndex));
            foreignKeys.refresh();
        }

        public void handleRemove(EObject element) {
            propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ForeignKeysPropertiesEditionPartForm.this, DatabaseViewsRepository.ForeignKeys.Properties.foreignKeys_, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.REMOVE, null, element));
            foreignKeys.refresh();
        }

        public void navigateTo(EObject element) {
        }
    });
    for (ViewerFilter filter : this.foreignKeysFilters) {
        this.foreignKeys.addFilter(filter);
    }
    this.foreignKeys.setHelpText(propertiesEditionComponent.getHelpContent(DatabaseViewsRepository.ForeignKeys.Properties.foreignKeys_, DatabaseViewsRepository.FORM_KIND));
    this.foreignKeys.createControls(parent, widgetFactory);
    this.foreignKeys.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            if (e.item != null && e.item.getData() instanceof EObject) {
                propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(ForeignKeysPropertiesEditionPartForm.this, DatabaseViewsRepository.ForeignKeys.Properties.foreignKeys_, PropertiesEditionEvent.CHANGE, PropertiesEditionEvent.SELECTION_CHANGED, null, e.item.getData()));
            }
        }
    });
    GridData foreignKeysData = new GridData(GridData.FILL_HORIZONTAL);
    foreignKeysData.horizontalSpan = 3;
    this.foreignKeys.setLayoutData(foreignKeysData);
    this.foreignKeys.setLowerBound(0);
    this.foreignKeys.setUpperBound(-1);
    foreignKeys.setID(DatabaseViewsRepository.ForeignKeys.Properties.foreignKeys_);
    // $NON-NLS-1$
    foreignKeys.setEEFType("eef::AdvancedTableComposition");
    // End of user code
    return parent;
}
Also used : ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) ReferencesTable(org.eclipse.emf.eef.runtime.ui.widgets.ReferencesTable) EObject(org.eclipse.emf.ecore.EObject) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) GridData(org.eclipse.swt.layout.GridData) IPropertiesEditionEvent(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent) PropertiesEditionEvent(org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent) ReferencesTableListener(org.eclipse.emf.eef.runtime.ui.widgets.ReferencesTable.ReferencesTableListener)

Example 38 with ViewerFilter

use of org.eclipse.jface.viewers.ViewerFilter 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)

Example 39 with ViewerFilter

use of org.eclipse.jface.viewers.ViewerFilter in project InformationSystem by ObeoNetwork.

the class IndexElementPropertiesEditionComponent 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 IndexElement indexElement = (IndexElement) elt;
        final IndexElementPropertiesEditionPart indexElementPart = (IndexElementPropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(DatabaseViewsRepository.IndexElement.Properties.column)) {
            // init part
            columnSettings = new EObjectFlatComboSettings(indexElement, DatabasePackage.eINSTANCE.getIndexElement_Column());
            indexElementPart.initColumn(columnSettings);
            // set the button mode
            indexElementPart.setColumnButtonMode(ButtonsModeEnum.BROWSE);
        }
        if (isAccessible(DatabaseViewsRepository.IndexElement.Properties.asc)) {
            indexElementPart.setAsc(indexElement.isAsc());
        }
        if (isAccessible(DatabaseViewsRepository.IndexElement.Properties.comments))
            indexElementPart.setComments(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, indexElement.getComments()));
        // init filters
        if (isAccessible(DatabaseViewsRepository.IndexElement.Properties.column)) {
            indexElementPart.addFilterToColumn(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 Column);
                }
            });
        // Start of user code for additional businessfilters for column
        // End of user code
        }
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : IndexElementPropertiesEditionPart(org.obeonetwork.dsl.database.parts.IndexElementPropertiesEditionPart) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Column(org.obeonetwork.dsl.database.Column) Viewer(org.eclipse.jface.viewers.Viewer) EObject(org.eclipse.emf.ecore.EObject) EObjectFlatComboSettings(org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings) IndexElement(org.obeonetwork.dsl.database.IndexElement)

Example 40 with ViewerFilter

use of org.eclipse.jface.viewers.ViewerFilter in project InformationSystem by ObeoNetwork.

the class IndexPropertiesEditionComponent 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 Index index = (Index) elt;
        final IndexPropertiesEditionPart indexPart = (IndexPropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(DatabaseViewsRepository.Index.Properties.name))
            indexPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, index.getName()));
        if (isAccessible(DatabaseViewsRepository.Index.Properties.qualifier))
            indexPart.setQualifier(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, index.getQualifier()));
        if (isAccessible(DatabaseViewsRepository.Index.Properties.unique)) {
            indexPart.setUnique(index.isUnique());
        }
        if (isAccessible(DatabaseViewsRepository.Index.Properties.cardinality)) {
            indexPart.setCardinality(EEFConverterUtil.convertToString(EcorePackage.Literals.EINT, index.getCardinality()));
        }
        if (isAccessible(DatabaseViewsRepository.Index.Properties.indexType))
            indexPart.setIndexType(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, index.getIndexType()));
        if (isAccessible(DatabaseViewsRepository.Index.Properties.comments))
            indexPart.setComments(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, index.getComments()));
        if (isAccessible(DatabaseViewsRepository.Index.Properties.elements)) {
            elementsSettings = new ReferencesTableSettings(index, DatabasePackage.eINSTANCE.getIndex_Elements());
            indexPart.initElements(elementsSettings);
        }
        if (isAccessible(DatabaseViewsRepository.Index.Properties.elements)) {
            indexPart.addFilterToElements(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 IndexElement);
                }
            });
        // Start of user code for additional businessfilters for elements
        // End of user code
        }
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : IndexPropertiesEditionPart(org.obeonetwork.dsl.database.parts.IndexPropertiesEditionPart) ReferencesTableSettings(org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Index(org.obeonetwork.dsl.database.Index) Viewer(org.eclipse.jface.viewers.Viewer) EObject(org.eclipse.emf.ecore.EObject) IndexElement(org.obeonetwork.dsl.database.IndexElement)

Aggregations

ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)266 EObject (org.eclipse.emf.ecore.EObject)144 Viewer (org.eclipse.jface.viewers.Viewer)130 GridData (org.eclipse.swt.layout.GridData)124 SelectionEvent (org.eclipse.swt.events.SelectionEvent)107 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)101 IPropertiesEditionEvent (org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)86 PropertiesEditionEvent (org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent)86 ReferencesTable (org.eclipse.emf.eef.runtime.ui.widgets.ReferencesTable)84 ReferencesTableListener (org.eclipse.emf.eef.runtime.ui.widgets.ReferencesTable.ReferencesTableListener)84 ReferencesTableSettings (org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings)38 Composite (org.eclipse.swt.widgets.Composite)38 GridLayout (org.eclipse.swt.layout.GridLayout)33 TreeViewer (org.eclipse.jface.viewers.TreeViewer)28 IFile (org.eclipse.core.resources.IFile)24 EObjectFlatComboSettings (org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings)22 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)21 Label (org.eclipse.swt.widgets.Label)21 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)20 TableViewer (org.eclipse.jface.viewers.TableViewer)20