Search in sources :

Example 96 with ViewerFilter

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

the class MetadatasPropertiesEditionPartForm method createMetadataTableComposition.

/**
 * @param container
 */
protected Composite createMetadataTableComposition(FormToolkit widgetFactory, Composite container) {
    Composite tableContainer = widgetFactory.createComposite(container, SWT.NONE);
    GridLayout tableContainerLayout = new GridLayout();
    GridData tableContainerData = new GridData(GridData.FILL_BOTH);
    tableContainerData.horizontalSpan = 3;
    tableContainer.setLayoutData(tableContainerData);
    tableContainerLayout.numColumns = 2;
    tableContainer.setLayout(tableContainerLayout);
    org.eclipse.swt.widgets.Table tableMetadata = widgetFactory.createTable(tableContainer, SWT.FULL_SELECTION | SWT.BORDER);
    tableMetadata.setHeaderVisible(true);
    GridData gdMetadata = new GridData();
    gdMetadata.grabExcessHorizontalSpace = true;
    gdMetadata.horizontalAlignment = GridData.FILL;
    gdMetadata.grabExcessVerticalSpace = true;
    gdMetadata.verticalAlignment = GridData.FILL;
    tableMetadata.setLayoutData(gdMetadata);
    tableMetadata.setLinesVisible(true);
    // Start of user code for columns definition for Metadata
    TableColumn title = new TableColumn(tableMetadata, SWT.NONE);
    title.setWidth(120);
    // $NON-NLS-1$
    title.setText("title");
    TableColumn body = new TableColumn(tableMetadata, SWT.NONE);
    body.setWidth(300);
    // $NON-NLS-1$
    body.setText("body");
    // End of user code
    metadata = new TableViewer(tableMetadata);
    metadata.setContentProvider(new ArrayContentProvider());
    metadata.setLabelProvider(new ITableLabelProvider() {

        // Start of user code for label provider definition for Metadata
        public String getColumnText(Object object, int columnIndex) {
            if (object instanceof Annotation) {
                Annotation annot = (Annotation) object;
                switch(columnIndex) {
                    case 0:
                        return annot.getTitle();
                    case 1:
                        return annot.getBody();
                }
            }
            // $NON-NLS-1$
            return "";
        }

        public Image getColumnImage(Object element, int columnIndex) {
            return null;
        }

        // End of user code
        public void addListener(ILabelProviderListener listener) {
        }

        public void dispose() {
        }

        public boolean isLabelProperty(Object element, String property) {
            return false;
        }

        public void removeListener(ILabelProviderListener listener) {
        }
    });
    metadata.getTable().addListener(SWT.MouseDoubleClick, new Listener() {

        public void handleEvent(Event event) {
            if (metadata.getSelection() instanceof IStructuredSelection) {
                IStructuredSelection selection = (IStructuredSelection) metadata.getSelection();
                if (selection.getFirstElement() instanceof EObject) {
                    propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(MetadatasPropertiesEditionPartForm.this, EnvironmentViewsRepository.Metadatas.Properties.metadata, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.EDIT, null, selection.getFirstElement()));
                    metadata.refresh();
                }
            }
        }
    });
    GridData metadataData = new GridData(GridData.FILL_HORIZONTAL);
    metadataData.minimumHeight = 120;
    metadataData.heightHint = 120;
    metadata.getTable().setLayoutData(metadataData);
    for (ViewerFilter filter : this.metadataFilters) {
        metadata.addFilter(filter);
    }
    EditingUtils.setID(metadata.getTable(), EnvironmentViewsRepository.Metadatas.Properties.metadata);
    // $NON-NLS-1$
    EditingUtils.setEEFtype(metadata.getTable(), "eef::TableComposition::field");
    createMetadataPanel(widgetFactory, tableContainer);
    // End of user code
    return container;
}
Also used : Listener(org.eclipse.swt.widgets.Listener) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) Composite(org.eclipse.swt.widgets.Composite) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) IPropertiesEditionEvent(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent) PropertiesEditionEvent(org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Image(org.eclipse.swt.graphics.Image) TableColumn(org.eclipse.swt.widgets.TableColumn) Annotation(org.obeonetwork.dsl.environment.Annotation) GridLayout(org.eclipse.swt.layout.GridLayout) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) EObject(org.eclipse.emf.ecore.EObject) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) Event(org.eclipse.swt.widgets.Event) IPropertiesEditionEvent(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent) PropertiesEditionEvent(org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) EObject(org.eclipse.emf.ecore.EObject) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 97 with ViewerFilter

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

the class MetadatasPropertiesEditionPartImpl method createMetadataTableComposition.

/**
 * @param container
 */
protected Composite createMetadataTableComposition(Composite container) {
    Composite tableContainer = new Composite(container, SWT.NONE);
    GridLayout tableContainerLayout = new GridLayout();
    GridData tableContainerData = new GridData(GridData.FILL_BOTH);
    tableContainerData.horizontalSpan = 3;
    tableContainer.setLayoutData(tableContainerData);
    tableContainerLayout.numColumns = 2;
    tableContainer.setLayout(tableContainerLayout);
    org.eclipse.swt.widgets.Table tableMetadata = new org.eclipse.swt.widgets.Table(tableContainer, SWT.FULL_SELECTION);
    tableMetadata.setHeaderVisible(true);
    GridData gdMetadata = new GridData();
    gdMetadata.grabExcessHorizontalSpace = true;
    gdMetadata.horizontalAlignment = GridData.FILL;
    gdMetadata.grabExcessVerticalSpace = true;
    gdMetadata.verticalAlignment = GridData.FILL;
    tableMetadata.setLayoutData(gdMetadata);
    tableMetadata.setLinesVisible(true);
    // Start of user code for columns definition for Metadata
    TableColumn title = new TableColumn(tableMetadata, SWT.NONE);
    title.setWidth(120);
    // $NON-NLS-1$
    title.setText("title");
    TableColumn body = new TableColumn(tableMetadata, SWT.NONE);
    body.setWidth(300);
    // $NON-NLS-1$
    body.setText("body");
    // End of user code
    metadata = new TableViewer(tableMetadata);
    metadata.setContentProvider(new ArrayContentProvider());
    metadata.setLabelProvider(new ITableLabelProvider() {

        // Start of user code for label provider definition for Metadata
        public String getColumnText(Object object, int columnIndex) {
            if (object instanceof Annotation) {
                Annotation annot = (Annotation) object;
                switch(columnIndex) {
                    case 0:
                        return annot.getTitle();
                    case 1:
                        return annot.getBody();
                }
            }
            // $NON-NLS-1$
            return "";
        }

        public Image getColumnImage(Object element, int columnIndex) {
            return null;
        }

        // End of user code
        public void addListener(ILabelProviderListener listener) {
        }

        public void dispose() {
        }

        public boolean isLabelProperty(Object element, String property) {
            return false;
        }

        public void removeListener(ILabelProviderListener listener) {
        }
    });
    metadata.getTable().addListener(SWT.MouseDoubleClick, new Listener() {

        public void handleEvent(Event event) {
            if (metadata.getSelection() instanceof IStructuredSelection) {
                IStructuredSelection selection = (IStructuredSelection) metadata.getSelection();
                if (selection.getFirstElement() instanceof EObject) {
                    propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(MetadatasPropertiesEditionPartImpl.this, EnvironmentViewsRepository.Metadatas.Properties.metadata, PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.EDIT, null, selection.getFirstElement()));
                    metadata.refresh();
                }
            }
        }
    });
    GridData metadataData = new GridData(GridData.FILL_HORIZONTAL);
    metadataData.minimumHeight = 120;
    metadataData.heightHint = 120;
    metadata.getTable().setLayoutData(metadataData);
    for (ViewerFilter filter : this.metadataFilters) {
        metadata.addFilter(filter);
    }
    EditingUtils.setID(metadata.getTable(), EnvironmentViewsRepository.Metadatas.Properties.metadata);
    // $NON-NLS-1$
    EditingUtils.setEEFtype(metadata.getTable(), "eef::TableComposition::field");
    createMetadataPanel(tableContainer);
    // End of user code
    return container;
}
Also used : Listener(org.eclipse.swt.widgets.Listener) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Image(org.eclipse.swt.graphics.Image) GridLayout(org.eclipse.swt.layout.GridLayout) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) EObject(org.eclipse.emf.ecore.EObject) Composite(org.eclipse.swt.widgets.Composite) IPropertiesEditionEvent(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent) PropertiesEditionEvent(org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent) TableColumn(org.eclipse.swt.widgets.TableColumn) Annotation(org.obeonetwork.dsl.environment.Annotation) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) Event(org.eclipse.swt.widgets.Event) IPropertiesEditionEvent(org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent) PropertiesEditionEvent(org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) EObject(org.eclipse.emf.ecore.EObject) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 98 with ViewerFilter

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

the class MetadataCptPropertiesEditionComponent 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(metadataSettings);
        }
        final ObeoDSMObject obeoDSMObject = (ObeoDSMObject) elt;
        final MetadatasPropertiesEditionPart metadatasPart = (MetadatasPropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(EnvironmentViewsRepository.Metadatas.Properties.metadata)) {
            metadataSettings = new ReferencesTableSettings(obeoDSMObject, EnvironmentPackage.eINSTANCE.getObeoDSMObject_Metadatas(), EnvironmentPackage.eINSTANCE.getMetaDataContainer_Metadatas());
            metadatasPart.initMetadata(metadataSettings);
        }
        // init filters
        if (isAccessible(EnvironmentViewsRepository.Metadatas.Properties.metadata)) {
            metadatasPart.addFilterToMetadata(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 String)
                        // $NON-NLS-1$
                        return element.equals("");
                    if (element instanceof MetaData)
                        return true;
                    return element instanceof Resource;
                }
            });
        // Start of user code for additional businessfilters for metadata
        // End of user code
        }
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : ReferencesTableSettings(org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) MetadatasPropertiesEditionPart(org.obeonetwork.dsl.environment.parts.MetadatasPropertiesEditionPart) CompositePropertiesEditionPart(org.eclipse.emf.eef.runtime.impl.parts.CompositePropertiesEditionPart) MetaData(org.obeonetwork.dsl.environment.MetaData) ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject) Resource(org.eclipse.emf.ecore.resource.Resource) Viewer(org.eclipse.jface.viewers.Viewer) EObject(org.eclipse.emf.ecore.EObject) ObeoDSMObject(org.obeonetwork.dsl.environment.ObeoDSMObject)

Example 99 with ViewerFilter

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

the class DtoDtoPropertiesEditionComponent 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 DTO dTO = (DTO) elt;
        final DtoPropertiesEditionPart dtoPart = (DtoPropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(EnvironmentViewsRepository.Dto.Properties.name))
            dtoPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, dTO.getName()));
        if (isAccessible(EnvironmentViewsRepository.Dto.Properties.supertype)) {
            // init part
            supertypeSettings = new EObjectFlatComboSettings(dTO, EnvironmentPackage.eINSTANCE.getStructuredType_Supertype());
            dtoPart.initSupertype(supertypeSettings);
            // set the button mode
            dtoPart.setSupertypeButtonMode(ButtonsModeEnum.BROWSE);
        }
        if (isAccessible(EnvironmentViewsRepository.Dto.Properties.description))
            dtoPart.setDescription(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, dTO.getDescription()));
        if (isAccessible(EnvironmentViewsRepository.Dto.Properties.associatedTypes)) {
            associatedTypesSettings = new ReferencesTableSettings(dTO, EnvironmentPackage.eINSTANCE.getStructuredType_AssociatedTypes());
            dtoPart.initAssociatedTypes(associatedTypesSettings);
        }
        if (isAccessible(EnvironmentViewsRepository.Dto.Properties.supertype)) {
            dtoPart.addFilterToSupertype(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 StructuredType);
                }
            });
        // Start of user code for additional businessfilters for supertype
        // End of user code
        }
        if (isAccessible(EnvironmentViewsRepository.Dto.Properties.associatedTypes)) {
            dtoPart.addFilterToAssociatedTypes(new EObjectFilter(EnvironmentPackage.Literals.STRUCTURED_TYPE));
        // Start of user code for additional businessfilters for associatedTypes
        // End of user code
        }
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : EObjectFilter(org.eclipse.emf.eef.runtime.impl.filters.EObjectFilter) ReferencesTableSettings(org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) DtoPropertiesEditionPart(org.obeonetwork.dsl.environment.parts.DtoPropertiesEditionPart) Viewer(org.eclipse.jface.viewers.Viewer) EObject(org.eclipse.emf.ecore.EObject) EObjectFlatComboSettings(org.eclipse.emf.eef.runtime.ui.widgets.eobjflatcombo.EObjectFlatComboSettings) DTO(org.obeonetwork.dsl.environment.DTO) StructuredType(org.obeonetwork.dsl.environment.StructuredType)

Example 100 with ViewerFilter

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

the class EnumerationEnumerationPropertiesEditionComponent 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 Enumeration enumeration = (Enumeration) elt;
        final EnumerationPropertiesEditionPart enumerationPart = (EnumerationPropertiesEditionPart) editingPart;
        // init values
        if (isAccessible(EnvironmentViewsRepository.Enumeration.Properties.name))
            enumerationPart.setName(EEFConverterUtil.convertToString(EcorePackage.Literals.ESTRING, enumeration.getName()));
        if (isAccessible(EnvironmentViewsRepository.Enumeration.Properties.literals)) {
            literalsSettings = new ReferencesTableSettings(enumeration, EnvironmentPackage.eINSTANCE.getEnumeration_Literals());
            enumerationPart.initLiterals(literalsSettings);
        }
        if (isAccessible(EnvironmentViewsRepository.Enumeration.Properties.description))
            enumerationPart.setDescription(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, enumeration.getDescription()));
        if (isAccessible(EnvironmentViewsRepository.Enumeration.Properties.literals)) {
            enumerationPart.addFilterToLiterals(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) {
                    return (element instanceof Literal);
                }
            });
        // Start of user code for additional businessfilters for literals
        // End of user code
        }
    // init values for referenced views
    // init filters for referenced views
    }
    setInitializing(false);
}
Also used : EnumerationPropertiesEditionPart(org.obeonetwork.dsl.environment.parts.EnumerationPropertiesEditionPart) Enumeration(org.obeonetwork.dsl.environment.Enumeration) ReferencesTableSettings(org.eclipse.emf.eef.runtime.ui.widgets.referencestable.ReferencesTableSettings) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) Literal(org.obeonetwork.dsl.environment.Literal) Viewer(org.eclipse.jface.viewers.Viewer) EObject(org.eclipse.emf.ecore.EObject)

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