Search in sources :

Example 1 with DefinitionLabelProvider

use of eu.esdihumboldt.hale.ui.common.definition.viewer.DefinitionLabelProvider in project hale by halestudio.

the class DataSetTypeSelectionDialog method setupViewer.

@Override
protected void setupViewer(TreeViewer viewer, Pair<TypeDefinition, DataSet> initialSelection) {
    viewer.setLabelProvider(new DefinitionLabelProvider(viewer) {

        @Override
        public String getText(Object element) {
            if (element instanceof DataSet) {
                switch((DataSet) element) {
                    case TRANSFORMED:
                        return "Transformed";
                    case SOURCE:
                    default:
                        return "Source";
                }
            }
            if (element instanceof Pair) {
                element = ((Pair<?, ?>) element).getFirst();
            }
            return super.getText(element);
        }

        @Override
        public Image getImage(Object element) {
            if (element instanceof DataSet) {
                return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
            }
            if (element instanceof Pair) {
                element = ((Pair<?, ?>) element).getFirst();
            }
            return super.getImage(element);
        }
    });
    viewer.setContentProvider(new TypeIndexContentProvider(viewer) {

        @Override
        public Object[] getElements(Object inputElement) {
            return types.keySet().toArray();
        }

        @Override
        public Object[] getChildren(Object parentElement) {
            if (parentElement instanceof DataSet) {
                DataSet dataSet = (DataSet) parentElement;
                List<Pair<TypeDefinition, DataSet>> typeList = new ArrayList<Pair<TypeDefinition, DataSet>>();
                for (TypeDefinition type : types.get(dataSet)) {
                    typeList.add(new Pair<TypeDefinition, DataSet>(type, dataSet));
                }
                return typeList.toArray();
            }
            return new Object[] {};
        }

        @Override
        public boolean hasChildren(Object parentElement) {
            return parentElement instanceof DataSet && !types.get((DataSet) parentElement).isEmpty();
        }
    });
    viewer.setAutoExpandLevel(2);
    viewer.setInput(types);
    if (initialSelection != null) {
        viewer.setSelection(new StructuredSelection(initialSelection));
    }
}
Also used : DefinitionLabelProvider(eu.esdihumboldt.hale.ui.common.definition.viewer.DefinitionLabelProvider) DataSet(eu.esdihumboldt.hale.common.instance.model.DataSet) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TypeIndexContentProvider(eu.esdihumboldt.hale.ui.common.definition.viewer.TypeIndexContentProvider) ArrayList(java.util.ArrayList) List(java.util.List) Image(org.eclipse.swt.graphics.Image) Pair(eu.esdihumboldt.util.Pair) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 2 with DefinitionLabelProvider

use of eu.esdihumboldt.hale.ui.common.definition.viewer.DefinitionLabelProvider in project hale by halestudio.

the class PropertyDefinitionDialog method setupViewer.

@Override
protected void setupViewer(TreeViewer viewer, EntityDefinition initialSelection) {
    viewer.setLabelProvider(new DefinitionLabelProvider(viewer));
    viewer.setContentProvider(new TreePathProviderAdapter(new TypePropertyContentProvider(viewer)));
    viewer.setInput(parentType);
    if (initialSelection != null) {
        viewer.setSelection(new StructuredSelection(initialSelection));
    }
}
Also used : DefinitionLabelProvider(eu.esdihumboldt.hale.ui.common.definition.viewer.DefinitionLabelProvider) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TreePathProviderAdapter(eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathProviderAdapter) TypePropertyContentProvider(eu.esdihumboldt.hale.ui.common.definition.viewer.TypePropertyContentProvider)

Example 3 with DefinitionLabelProvider

use of eu.esdihumboldt.hale.ui.common.definition.viewer.DefinitionLabelProvider in project hale by halestudio.

the class TypeDefinitionDialog method setupViewer.

@Override
protected void setupViewer(TreeViewer viewer, TypeDefinition initialSelection) {
    viewer.setLabelProvider(new DefinitionLabelProvider(viewer));
    viewer.setContentProvider(new TypesContentProvider(viewer));
    viewer.setInput(types);
    if (initialSelection != null) {
        viewer.setSelection(new StructuredSelection(initialSelection));
    }
}
Also used : DefinitionLabelProvider(eu.esdihumboldt.hale.ui.common.definition.viewer.DefinitionLabelProvider) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TypesContentProvider(eu.esdihumboldt.hale.ui.common.definition.viewer.TypesContentProvider)

Aggregations

DefinitionLabelProvider (eu.esdihumboldt.hale.ui.common.definition.viewer.DefinitionLabelProvider)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)3 DataSet (eu.esdihumboldt.hale.common.instance.model.DataSet)1 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)1 TypeIndexContentProvider (eu.esdihumboldt.hale.ui.common.definition.viewer.TypeIndexContentProvider)1 TypePropertyContentProvider (eu.esdihumboldt.hale.ui.common.definition.viewer.TypePropertyContentProvider)1 TypesContentProvider (eu.esdihumboldt.hale.ui.common.definition.viewer.TypesContentProvider)1 TreePathProviderAdapter (eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathProviderAdapter)1 Pair (eu.esdihumboldt.util.Pair)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Image (org.eclipse.swt.graphics.Image)1