Search in sources :

Example 26 with ProjectService

use of eu.esdihumboldt.hale.ui.service.project.ProjectService in project hale by halestudio.

the class LoadTemplateAction method run.

@Override
public void run() {
    super.run();
    ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
    try {
        ps.load(template.getLocation().getLocation());
    } catch (URISyntaxException e) {
        log.error("Invalid project template location", e);
    }
}
Also used : ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService) URISyntaxException(java.net.URISyntaxException)

Example 27 with ProjectService

use of eu.esdihumboldt.hale.ui.service.project.ProjectService in project hale by halestudio.

the class OpenWebTemplate method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final Display display = HandlerUtil.getActiveShell(event).getDisplay();
    ProgressMonitorDialog taskDlg = new ProgressMonitorDialog(HandlerUtil.getActiveShell(event));
    try {
        taskDlg.run(true, false, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask("Downloading template list", IProgressMonitor.UNKNOWN);
                // load templates
                final List<WebTemplate> templates;
                try {
                    templates = WebTemplateLoader.load();
                } catch (Exception e) {
                    log.userError("Failed to download template list", e);
                    return;
                } finally {
                    monitor.done();
                }
                if (templates != null) {
                    // launch dialog asynchronously in display thread
                    display.asyncExec(new Runnable() {

                        @Override
                        public void run() {
                            WebTemplatesDialog dlg = new WebTemplatesDialog(display.getActiveShell(), templates);
                            if (dlg.open() == WebTemplatesDialog.OK) {
                                WebTemplate template = dlg.getObject();
                                if (template != null) {
                                    ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
                                    ps.load(template.getProject());
                                }
                            }
                        }
                    });
                }
            }
        });
    } catch (InvocationTargetException | InterruptedException e) {
        log.userError("Failed to download template list", e);
    }
    return null;
}
Also used : ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) WebTemplatesDialog(eu.esdihumboldt.hale.ui.templates.webtemplates.WebTemplatesDialog) ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService) InvocationTargetException(java.lang.reflect.InvocationTargetException) ExecutionException(org.eclipse.core.commands.ExecutionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) WebTemplate(eu.esdihumboldt.hale.ui.templates.webtemplates.WebTemplate) List(java.util.List) Display(org.eclipse.swt.widgets.Display)

Example 28 with ProjectService

use of eu.esdihumboldt.hale.ui.service.project.ProjectService 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);
                }
            });
        }
    });
    viewer.setUseHashlookup(true);
    viewer.setAutoExpandLevel(3);
    update();
    new ViewerMenu(getSite(), viewer);
    getSite().setSelectionProvider(viewer);
}
Also used : ProjectServiceAdapter(eu.esdihumboldt.hale.ui.service.project.ProjectServiceAdapter) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ResourcesLabelProvider(eu.esdihumboldt.hale.ui.views.resources.internal.ResourcesLabelProvider) Resource(eu.esdihumboldt.hale.common.core.io.project.model.Resource) ProjectInfo(eu.esdihumboldt.hale.common.core.io.project.ProjectInfo) ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService) ResourcesContentProvider(eu.esdihumboldt.hale.ui.views.resources.internal.ResourcesContentProvider) List(java.util.List) ViewerMenu(eu.esdihumboldt.hale.ui.util.viewer.ViewerMenu)

Example 29 with ProjectService

use of eu.esdihumboldt.hale.ui.service.project.ProjectService in project hale by halestudio.

the class ResourcesView method dispose.

@Override
public void dispose() {
    ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
    if (projectServiceListener != null) {
        ps.removeListener(projectServiceListener);
    }
    super.dispose();
}
Also used : ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService)

Example 30 with ProjectService

use of eu.esdihumboldt.hale.ui.service.project.ProjectService in project hale by halestudio.

the class ProjectProperties method updateProject.

private void updateProject() {
    if (updateProject) {
        ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
        ps.updateProjectInfo(this);
    }
}
Also used : ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService)

Aggregations

ProjectService (eu.esdihumboldt.hale.ui.service.project.ProjectService)49 IOConfiguration (eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration)5 Resource (eu.esdihumboldt.hale.common.core.io.project.model.Resource)5 URI (java.net.URI)5 ArrayList (java.util.ArrayList)5 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)5 SelectionEvent (org.eclipse.swt.events.SelectionEvent)5 Button (org.eclipse.swt.widgets.Button)5 Value (eu.esdihumboldt.hale.common.core.io.Value)4 ResolveCache (eu.esdihumboldt.hale.ui.service.align.resolver.internal.ResolveCache)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)4 Project (eu.esdihumboldt.hale.common.core.io.project.model.Project)3 SchemaService (eu.esdihumboldt.hale.ui.service.schema.SchemaService)3 List (java.util.List)3 Composite (org.eclipse.swt.widgets.Composite)3 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)2 PropertyEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition)2 TypeEntityDefinition (eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition)2