Search in sources :

Example 1 with FilterAction

use of eu.esdihumboldt.hale.ui.util.viewer.FilterAction in project hale by halestudio.

the class TypeEntityDialog method addToolBarActions.

/**
 * @see eu.esdihumboldt.hale.ui.function.common.EntityDialog#addToolBarActions(org.eclipse.jface.action.ToolBarManager)
 */
@Override
protected void addToolBarActions(ToolBarManager manager) {
    // filter to only show mapped types
    manager.add(new FilterAction("Hide unmapped types", "Show unmapped types", HALEUIPlugin.getImageDescriptor("icons/empty.gif"), getViewer(), new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
            Alignment alignment = as.getAlignment();
            if (element instanceof TreePath)
                element = ((TreePath) element).getLastSegment();
            return isMapped((ITreeContentProvider) ((TreeViewer) viewer).getContentProvider(), element, alignment);
        }

        private boolean isMapped(ITreeContentProvider cp, Object element, Alignment align) {
            if (element instanceof EntityDefinition) {
                boolean mapped = AlignmentUtil.entityOrChildMapped((EntityDefinition) element, align);
                if (mapped)
                    return true;
            }
            // recursively check children
            Object[] children = cp.getChildren(element);
            if (children != null)
                for (Object child : children) if (isMapped(cp, child, align))
                    return true;
            return false;
        }
    }, true, true));
    // do not add choice if only mapping relevant types should be selected
    if (onlyMappingRelevant)
        return;
    manager.add(new Separator());
    // MappingRelevant types only, flat
    manager.add(new ContentProviderAction("Mapping relevant types as list", HALEUIPlugin.getImageDescriptor("icons/flat_relevant.png"), getViewer(), flatRelevantProvider, false));
    // MappingRelevant types only, hierarchical
    manager.add(new ContentProviderAction("Mapping relevant types hierarchical", HALEUIPlugin.getImageDescriptor("icons/hierarchical_relevant.png"), getViewer(), hierarchicalRelevantProvider, false));
    // Mappable types, flat
    manager.add(new ContentProviderAction("All types as list", HALEUIPlugin.getImageDescriptor("icons/flat_all.png"), getViewer(), flatAllProvider, true));
    // Mappable types, hierarchical
    manager.add(new ContentProviderAction("All types hierarchical", HALEUIPlugin.getImageDescriptor("icons/hierarchical_all.png"), getViewer(), hierarchicalAllProvider, false));
}
Also used : ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ContentProviderAction(eu.esdihumboldt.hale.ui.service.entity.util.ContentProviderAction) Viewer(org.eclipse.jface.viewers.Viewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) Alignment(eu.esdihumboldt.hale.common.align.model.Alignment) TreePath(org.eclipse.jface.viewers.TreePath) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) FilterAction(eu.esdihumboldt.hale.ui.util.viewer.FilterAction) Separator(org.eclipse.jface.action.Separator)

Example 2 with FilterAction

use of eu.esdihumboldt.hale.ui.util.viewer.FilterAction in project hale by halestudio.

the class EntitySchemaExplorer method prependToolbarActions.

/**
 * @see SchemaExplorer#prependToolbarActions(ToolBarManager)
 */
@Override
protected void prependToolbarActions(ToolBarManager manager) {
    // structure
    manager.add(new ContentProviderAction("Types as list", SchemasViewPlugin.getImageDescriptor("icons/flat_hierarchy.png"), getTreeViewer(), listProvider, true));
    manager.add(new ContentProviderAction("Type hierarchy", SchemasViewPlugin.getImageDescriptor("icons/inheritance_hierarchy.png"), getTreeViewer(), hierarchyProvider, false));
    manager.add(new Separator());
    // type filters
    ViewerFilter typeUnpopulated = new UnpopulatedTypesFilter();
    manager.add(new FilterAction("Hide unpopulated types", "Show unpopulated types", SchemasViewPlugin.getImageDescriptor("icons/type_empty.gif"), getTreeViewer(), typeUnpopulated, true, true));
    manager.add(new Separator());
    // properties filters
    ViewerFilter unpopulated = new UnpopulatedPropertiesFilter();
    manager.add(new FilterAction("Hide unpopulated properties", "Show unpopulated properties", SchemasViewPlugin.getImageDescriptor("icons/empty.gif"), getTreeViewer(), unpopulated, true, true));
    ViewerFilter inherited = new InheritedPropertiesFilter();
    manager.add(new FilterAction("Hide inherited properties", "Show inherited properties", SchemasViewPlugin.getImageDescriptor("icons/inherited.gif"), getTreeViewer(), inherited, true, true));
    ViewerFilter optional = new OptionalPropertiesFilter();
    manager.add(new FilterAction("Hide optional properties", "Show optional properties", SchemasViewPlugin.getImageDescriptor("icons/mandatory.gif"), getTreeViewer(), optional, true, true));
    manager.add(new Separator());
}
Also used : InheritedPropertiesFilter(eu.esdihumboldt.hale.ui.common.definition.viewer.InheritedPropertiesFilter) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) ContentProviderAction(eu.esdihumboldt.hale.ui.service.entity.util.ContentProviderAction) UnpopulatedTypesFilter(eu.esdihumboldt.hale.ui.service.population.UnpopulatedTypesFilter) Separator(org.eclipse.jface.action.Separator) FilterAction(eu.esdihumboldt.hale.ui.util.viewer.FilterAction) UnpopulatedPropertiesFilter(eu.esdihumboldt.hale.ui.service.population.UnpopulatedPropertiesFilter) OptionalPropertiesFilter(eu.esdihumboldt.hale.ui.common.definition.viewer.OptionalPropertiesFilter)

Aggregations

ContentProviderAction (eu.esdihumboldt.hale.ui.service.entity.util.ContentProviderAction)2 FilterAction (eu.esdihumboldt.hale.ui.util.viewer.FilterAction)2 Separator (org.eclipse.jface.action.Separator)2 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)2 Alignment (eu.esdihumboldt.hale.common.align.model.Alignment)1 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)1 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)1 InheritedPropertiesFilter (eu.esdihumboldt.hale.ui.common.definition.viewer.InheritedPropertiesFilter)1 OptionalPropertiesFilter (eu.esdihumboldt.hale.ui.common.definition.viewer.OptionalPropertiesFilter)1 AlignmentService (eu.esdihumboldt.hale.ui.service.align.AlignmentService)1 UnpopulatedPropertiesFilter (eu.esdihumboldt.hale.ui.service.population.UnpopulatedPropertiesFilter)1 UnpopulatedTypesFilter (eu.esdihumboldt.hale.ui.service.population.UnpopulatedTypesFilter)1 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)1 TreePath (org.eclipse.jface.viewers.TreePath)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1