Search in sources :

Example 1 with ResourcesLabelProvider

use of eu.esdihumboldt.hale.ui.views.resources.internal.ResourcesLabelProvider in project hale by halestudio.

the class ResourcesView method createViewControl.

@Override
protected void createViewControl(Composite parent) {
    viewer = new TreeViewer(parent);
    viewer.setContentProvider(new ResourcesContentProvider());
    viewer.setLabelProvider(new ResourcesLabelProvider());
    ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
    ps.addListener(projectServiceListener = new ProjectServiceAdapter() {

        @Override
        public void resourceAdded(String actionId, Resource resource) {
            updateInDisplayThread();
        }

        @Override
        public void resourcesRemoved(String actionId, List<Resource> resources) {
            updateInDisplayThread();
        }

        @Override
        public void afterLoad(ProjectService projectService) {
            updateInDisplayThread();
        }

        @Override
        public void projectInfoChanged(ProjectInfo info) {
            PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

                @Override
                public void run() {
                    viewer.update(ProjectToken.TOKEN, null);
                    updateInDisplayThread();
                }
            });
        }
    });
    viewer.setUseHashlookup(true);
    viewer.setAutoExpandLevel(3);
    update();
    new ViewerMenu(getSite(), viewer);
    getSite().setSelectionProvider(viewer);
    // adding listener to refresh the resource view when any schema,
    // instance is added or cleared.
    SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
    ssListener = new SchemaServiceListener() {

        @Override
        public void schemaRemoved(SchemaSpaceID spaceID) {
            final Display display = PlatformUI.getWorkbench().getDisplay();
            display.syncExec(new Runnable() {

                @Override
                public void run() {
                    updateInDisplayThread();
                }
            });
        }

        @Override
        public void schemasCleared(final SchemaSpaceID spaceID) {
            final Display display = PlatformUI.getWorkbench().getDisplay();
            display.syncExec(new Runnable() {

                @Override
                public void run() {
                    updateInDisplayThread();
                }
            });
        }

        @Override
        public void schemaAdded(final SchemaSpaceID spaceID, Schema schema) {
            final Display display = PlatformUI.getWorkbench().getDisplay();
            display.syncExec(new Runnable() {

                @Override
                public void run() {
                    updateInDisplayThread();
                }
            });
        }

        @Override
        public void mappableTypesChanged(final SchemaSpaceID spaceID, Collection<? extends TypeDefinition> types) {
            final Display display = PlatformUI.getWorkbench().getDisplay();
            display.syncExec(new Runnable() {

                @Override
                public void run() {
                    updateInDisplayThread();
                }
            });
        }
    };
    ss.addSchemaServiceListener(ssListener);
    InstanceService is = PlatformUI.getWorkbench().getService(InstanceService.class);
    is.addListener(isa = new InstanceServiceAdapter() {

        @Override
        public void datasetChanged(DataSet type) {
            final Display display = PlatformUI.getWorkbench().getDisplay();
            display.syncExec(new Runnable() {

                @Override
                public void run() {
                    updateInDisplayThread();
                }
            });
        }
    });
}
Also used : ProjectServiceAdapter(eu.esdihumboldt.hale.ui.service.project.ProjectServiceAdapter) DataSet(eu.esdihumboldt.hale.common.instance.model.DataSet) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ResourcesLabelProvider(eu.esdihumboldt.hale.ui.views.resources.internal.ResourcesLabelProvider) Schema(eu.esdihumboldt.hale.common.schema.model.Schema) Resource(eu.esdihumboldt.hale.common.core.io.project.model.Resource) ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService) ResourcesContentProvider(eu.esdihumboldt.hale.ui.views.resources.internal.ResourcesContentProvider) SchemaSpaceID(eu.esdihumboldt.hale.common.schema.SchemaSpaceID) ViewerMenu(eu.esdihumboldt.hale.ui.util.viewer.ViewerMenu) SchemaService(eu.esdihumboldt.hale.ui.service.schema.SchemaService) ProjectInfo(eu.esdihumboldt.hale.common.core.io.project.ProjectInfo) InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService) List(java.util.List) InstanceServiceAdapter(eu.esdihumboldt.hale.ui.service.instance.InstanceServiceAdapter) SchemaServiceListener(eu.esdihumboldt.hale.ui.service.schema.SchemaServiceListener) Display(org.eclipse.swt.widgets.Display)

Aggregations

ProjectInfo (eu.esdihumboldt.hale.common.core.io.project.ProjectInfo)1 Resource (eu.esdihumboldt.hale.common.core.io.project.model.Resource)1 DataSet (eu.esdihumboldt.hale.common.instance.model.DataSet)1 SchemaSpaceID (eu.esdihumboldt.hale.common.schema.SchemaSpaceID)1 Schema (eu.esdihumboldt.hale.common.schema.model.Schema)1 InstanceService (eu.esdihumboldt.hale.ui.service.instance.InstanceService)1 InstanceServiceAdapter (eu.esdihumboldt.hale.ui.service.instance.InstanceServiceAdapter)1 ProjectService (eu.esdihumboldt.hale.ui.service.project.ProjectService)1 ProjectServiceAdapter (eu.esdihumboldt.hale.ui.service.project.ProjectServiceAdapter)1 SchemaService (eu.esdihumboldt.hale.ui.service.schema.SchemaService)1 SchemaServiceListener (eu.esdihumboldt.hale.ui.service.schema.SchemaServiceListener)1 ViewerMenu (eu.esdihumboldt.hale.ui.util.viewer.ViewerMenu)1 ResourcesContentProvider (eu.esdihumboldt.hale.ui.views.resources.internal.ResourcesContentProvider)1 ResourcesLabelProvider (eu.esdihumboldt.hale.ui.views.resources.internal.ResourcesLabelProvider)1 List (java.util.List)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 Display (org.eclipse.swt.widgets.Display)1