Search in sources :

Example 86 with EntityDefinition

use of eu.esdihumboldt.hale.common.align.model.EntityDefinition in project hale by halestudio.

the class ClassificationFilter method select.

/**
 * @see ViewerFilter#select(Viewer, Object, Object)
 */
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
    if (element instanceof TreePath) {
        element = ((TreePath) element).getLastSegment();
    }
    if (element instanceof EntityDefinition) {
        element = ((EntityDefinition) element).getDefinition();
    }
    if (hidden.isEmpty() || !(element instanceof Definition<?>)) {
        // fast exit
        return true;
    }
    Definition<?> def = (Definition<?>) element;
    Classification clazz = Classification.getClassification(def);
    return !hidden.contains(clazz);
}
Also used : EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) TreePath(org.eclipse.jface.viewers.TreePath) Classification(eu.esdihumboldt.hale.common.schema.Classification) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) Definition(eu.esdihumboldt.hale.common.schema.model.Definition)

Example 87 with EntityDefinition

use of eu.esdihumboldt.hale.common.align.model.EntityDefinition in project hale by halestudio.

the class SchemaExplorerLabelProvider method getBackground.

/**
 * @see IColorProvider#getBackground(Object)
 */
@Override
public Color getBackground(Object element) {
    if (element instanceof EntityDefinition) {
        AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
        Alignment alignment = as.getAlignment();
        EntityDefinition entityDef = (EntityDefinition) element;
        return getEntityBackground(entityDef, alignment, entityDef.getPropertyPath().isEmpty());
    }
    return null;
}
Also used : EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) Alignment(eu.esdihumboldt.hale.common.align.model.Alignment) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService)

Example 88 with EntityDefinition

use of eu.esdihumboldt.hale.common.align.model.EntityDefinition in project hale by halestudio.

the class TypeHierarchyView method update.

/**
 * Update the hierarchy view with the given selection
 *
 * @param selection the selection
 */
protected void update(ISelection selection) {
    if (selection instanceof IStructuredSelection) {
        Object element = ((IStructuredSelection) selection).getFirstElement();
        if (element instanceof ParentPath) {
            element = ((ParentPath) element).getHead();
        }
        if (element instanceof Entity) {
            element = ((Entity) element).getDefinition();
        }
        if (element instanceof EntityDefinition) {
            element = ((EntityDefinition) element).getDefinition();
        }
        viewer.setInput(element);
        ParentPath path = TypeHierarchyContentProvider.createPath(element);
        viewer.expandAll();
        if (path != null) {
            viewer.setSelection(new StructuredSelection(path.getMainPath()));
        }
    } else {
        viewer.setInput(null);
    }
}
Also used : Entity(eu.esdihumboldt.hale.common.align.model.Entity) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) ParentPath(eu.esdihumboldt.hale.ui.views.typehierarchy.TypeHierarchyContentProvider.ParentPath) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 89 with EntityDefinition

use of eu.esdihumboldt.hale.common.align.model.EntityDefinition in project hale by halestudio.

the class EntityDialog method createViewer.

/**
 * @see AbstractViewerSelectionDialog#createViewer(Composite)
 */
@Override
protected TreeViewer createViewer(Composite parent) {
    // create viewer
    SchemaPatternFilter patternFilter = new SchemaPatternFilter() {

        @Override
        protected boolean matches(Viewer viewer, Object element) {
            boolean superMatches = super.matches(viewer, element);
            if (!superMatches)
                return false;
            return acceptObject(viewer, getFilters(), ((TreePath) element).getLastSegment());
        }
    };
    patternFilter.setUseEarlyReturnIfMatcherIsNull(false);
    patternFilter.setIncludeLeadingWildcard(true);
    FilteredTree tree = new TreePathFilteredTree(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, patternFilter, true);
    tree.getViewer().setComparator(new DefinitionComparator());
    // create context menu
    MenuManager menuManager = new MenuManager();
    menuManager.setRemoveAllWhenShown(true);
    menuManager.addMenuListener(this);
    Menu targetMenu = menuManager.createContextMenu(tree.getViewer().getControl());
    tree.getViewer().getControl().setMenu(targetMenu);
    if (SchemaSpaceID.SOURCE.equals(ssid)) {
        // condition contexts only supported for source schema
        // ensure viewer is updated on context changes
        final EntityDefinitionService eds = PlatformUI.getWorkbench().getService(EntityDefinitionService.class);
        eds.addListener(entityDefinitionListener = new EntityDefinitionServiceListener() {

            @Override
            public void contextsAdded(Iterable<EntityDefinition> contextEntities) {
                getViewer().refresh();
            }

            @Override
            public void contextRemoved(EntityDefinition contextEntity) {
                getViewer().refresh();
            }

            @Override
            public void contextAdded(EntityDefinition contextEntity) {
                getViewer().refresh();
            }
        });
        // remove listener from entity def service
        tree.getViewer().getControl().addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                if (entityDefinitionListener != null) {
                    eds.removeListener(entityDefinitionListener);
                }
            }
        });
    }
    return tree.getViewer();
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) TreePathFilteredTree(eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathFilteredTree) DefinitionComparator(eu.esdihumboldt.hale.ui.common.definition.viewer.DefinitionComparator) Viewer(org.eclipse.jface.viewers.Viewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) FilteredTree(org.eclipse.ui.dialogs.FilteredTree) TreePathFilteredTree(eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathFilteredTree) DisposeEvent(org.eclipse.swt.events.DisposeEvent) EntityDefinitionService(eu.esdihumboldt.hale.ui.service.entity.EntityDefinitionService) SchemaPatternFilter(eu.esdihumboldt.hale.ui.common.definition.viewer.SchemaPatternFilter) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) EntityDefinitionServiceListener(eu.esdihumboldt.hale.ui.service.entity.EntityDefinitionServiceListener) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu)

Example 90 with EntityDefinition

use of eu.esdihumboldt.hale.common.align.model.EntityDefinition in project hale by halestudio.

the class PropertyEntityDialog method getObjectFromSelection.

/**
 * @see EntityDialog#getObjectFromSelection(ISelection)
 */
@Override
protected EntityDefinition getObjectFromSelection(ISelection selection) {
    if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
        Object element = ((IStructuredSelection) selection).getFirstElement();
        if (element instanceof EntityDefinition) {
            return (EntityDefinition) element;
        }
    }
    if (!selection.isEmpty() && selection instanceof ITreeSelection) {
        // create property definition w/ default contexts
        TreePath path = ((ITreeSelection) selection).getPaths()[0];
        // get parent type
        TypeDefinition type = ((PropertyDefinition) path.getFirstSegment()).getParentType();
        // determine definition path
        List<ChildContext> defPath = new ArrayList<ChildContext>();
        for (int i = 0; i < path.getSegmentCount(); i++) {
            defPath.add(new ChildContext((ChildDefinition<?>) path.getSegment(i)));
        }
        // TODO check if property entity definition is applicable?
        return new PropertyEntityDefinition(type, defPath, ssid, parentType.getFilter());
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) ChildDefinition(eu.esdihumboldt.hale.common.schema.model.ChildDefinition) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PropertyDefinition(eu.esdihumboldt.hale.common.schema.model.PropertyDefinition) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) TreePath(org.eclipse.jface.viewers.TreePath) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) ChildContext(eu.esdihumboldt.hale.common.align.model.ChildContext)

Aggregations

EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)99 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)39 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)37 ChildContext (eu.esdihumboldt.hale.common.align.model.ChildContext)23 ArrayList (java.util.ArrayList)22 Entity (eu.esdihumboldt.hale.common.align.model.Entity)21 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)20 Cell (eu.esdihumboldt.hale.common.align.model.Cell)18 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)13 PropertyDefinition (eu.esdihumboldt.hale.common.schema.model.PropertyDefinition)11 MutableCell (eu.esdihumboldt.hale.common.align.model.MutableCell)10 HashSet (java.util.HashSet)10 QName (javax.xml.namespace.QName)10 HashMap (java.util.HashMap)9 Condition (eu.esdihumboldt.hale.common.align.model.Condition)8 SimpleLog (eu.esdihumboldt.hale.common.core.report.SimpleLog)7 ISelection (org.eclipse.jface.viewers.ISelection)7 List (java.util.List)6 TreePath (org.eclipse.jface.viewers.TreePath)6 AlignmentMigration (eu.esdihumboldt.hale.common.align.migrate.AlignmentMigration)5