Search in sources :

Example 31 with ProjectService

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

the class NewRelationWizard method performFinish.

/**
 * @see MultiWizard#performFinish()
 */
@Override
public boolean performFinish() {
    // performFinish of the function wizard was called first
    FunctionWizard functionWizard = getSelectionPage().getFunctionWizard();
    if (functionWizard == null) {
        return false;
    }
    MutableCell cell = functionWizard.getResult();
    if (cell != null) {
        AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
        as.addCell(cell);
    }
    createdCell = cell;
    // save page configuration
    ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
    getSelectionPage().store(ps.getConfigurationService());
    return true;
}
Also used : MutableCell(eu.esdihumboldt.hale.common.align.model.MutableCell) AlignmentService(eu.esdihumboldt.hale.ui.service.align.AlignmentService) ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService) FunctionWizard(eu.esdihumboldt.hale.ui.function.FunctionWizard)

Example 32 with ProjectService

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

the class RemoveResourceHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
        Object element = ((IStructuredSelection) selection).getFirstElement();
        if (element instanceof Resource) {
            Resource resource = (Resource) element;
            // retrieve action UI advisor
            ActionUI actionUI = ActionUIExtension.getInstance().findActionUI(resource.getActionId());
            if (actionUI != null) {
                IOAction action = IOActionExtension.getInstance().get(resource.getActionId());
                ActionUIAdvisor<?> advisor = actionUI.getUIAdvisor();
                if (advisor != null && advisor.supportsRemoval()) {
                    String name = null;
                    if (resource.getSource() != null) {
                        String location = resource.getSource().toString();
                        int index = location.lastIndexOf('/');
                        if (index > 0 && index < location.length()) {
                            name = location.substring(index + 1);
                        }
                    }
                    String resourceType = null;
                    if (action != null) {
                        resourceType = action.getResourceName();
                    }
                    if (resourceType == null) {
                        resourceType = "resource";
                    }
                    String message;
                    if (name == null) {
                        message = MessageFormat.format("Do you really want to remove this {0}?", resourceType);
                    } else {
                        message = MessageFormat.format("Do you really want to remove the {0} {1}?", resourceType, name);
                    }
                    if (MessageDialog.openQuestion(HandlerUtil.getActiveShell(event), "Remove resource", message)) {
                        // do the actual removal
                        String id = resource.getResourceId();
                        if (advisor.removeResource(id)) {
                            // removal succeeded, so remove from project as
                            // well
                            ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
                            ps.removeResource(id);
                        }
                    }
                } else {
                    log.userError("Removing this resource is not supported.");
                }
            }
        }
    }
    return null;
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) Resource(eu.esdihumboldt.hale.common.core.io.project.model.Resource) ActionUI(eu.esdihumboldt.hale.ui.io.action.ActionUI) ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService) IOAction(eu.esdihumboldt.hale.common.core.io.IOAction) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 33 with ProjectService

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

the class AlignmentImportAdvisor method prepareProvider.

/**
 * @see AbstractIOAdvisor#prepareProvider(IOProvider)
 */
@Override
public void prepareProvider(AlignmentReader provider) {
    super.prepareProvider(provider);
    SchemaService ss = getService(SchemaService.class);
    provider.setSourceSchema(ss.getSchemas(SchemaSpaceID.SOURCE));
    provider.setTargetSchema(ss.getSchemas(SchemaSpaceID.TARGET));
    ProjectService ps = getService(ProjectService.class);
    // XXX uses the same path updater as the project
    // If someone edited the project file and referenced an alignment file,
    // which isn't in the project directory this won't work.
    provider.setPathUpdater(ps.getLocationUpdater());
}
Also used : SchemaService(eu.esdihumboldt.hale.ui.service.schema.SchemaService) ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService)

Example 34 with ProjectService

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

the class BaseAlignmentImportAdvisor method prepareProvider.

/**
 * @see eu.esdihumboldt.hale.common.core.io.impl.DefaultIOAdvisor#prepareProvider(eu.esdihumboldt.hale.common.core.io.IOProvider)
 */
@Override
public void prepareProvider(BaseAlignmentReader provider) {
    super.prepareProvider(provider);
    // XXX reader still needs MutableAlignment!
    SchemaService ss = getService(SchemaService.class);
    provider.setSourceSchema(ss.getSchemas(SchemaSpaceID.SOURCE));
    provider.setTargetSchema(ss.getSchemas(SchemaSpaceID.TARGET));
    ProjectService ps = getService(ProjectService.class);
    provider.setProjectLocation(ps.getLoadLocation());
}
Also used : SchemaService(eu.esdihumboldt.hale.ui.service.schema.SchemaService) ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService)

Example 35 with ProjectService

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

the class SaveConfigurationInstanceExportPage method update.

/**
 * Update the page state.
 */
protected void update() {
    if (fileFormats.getSelection().isEmpty()) {
        setErrorMessage("Please select a format");
        setPageComplete(false);
        return;
    }
    String confName = name.getText();
    if (confName == null || confName.isEmpty()) {
        setErrorMessage("Please provide a name for the preset to easily identify it");
        setPageComplete(false);
        return;
    }
    setErrorMessage(null);
    // configuration with that name already present?
    ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
    IOConfiguration conf = ps.getExportConfiguration(confName);
    if (conf == null) {
        setMessage(null);
    } else {
        setMessage("Overrides an existing configuration with the same name", DialogPage.WARNING);
    }
    setPageComplete(true);
}
Also used : IOConfiguration(eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration) 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