Search in sources :

Example 6 with ProjectService

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

the class UserFallbackEntityResolver method resetSkip.

/**
 * Reset the project setting that will skip all properties.
 */
public static void resetSkip() {
    ProjectService ps = HaleUI.getServiceProvider().getService(ProjectService.class);
    ps.setTemporaryProperty(RESOLVE_SKIP_PROPERTY, Value.of(false));
}
Also used : ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService)

Example 7 with ProjectService

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

the class UserFallbackEntityResolver method resolveProperty.

/**
 * Ask the user to select a replacement for a property.
 *
 * @param original the original entity
 * @param candidate a candidate for the replacement
 * @param schemaSpace the schema space
 * @return the resolved property (may be the original)
 */
public static Property resolveProperty(PropertyEntityDefinition original, @Nullable EntityDefinition candidate, SchemaSpaceID schemaSpace) {
    ResolveCache cache = getCache();
    PropertyEntityDefinition replacement = cache.getReplacement(original);
    if (replacement != null) {
        // use cached replacement
        return new DefaultProperty(replacement);
    }
    ProjectService ps = HaleUI.getServiceProvider().getService(ProjectService.class);
    final AtomicBoolean canceled;
    final AtomicBoolean skipped = new AtomicBoolean(false);
    if (ps.getTemporaryProperty(RESOLVE_SKIP_PROPERTY, Value.of(false)).as(Boolean.class)) {
        canceled = new AtomicBoolean(true);
    } else {
        canceled = new AtomicBoolean(false);
    }
    final AtomicReference<EntityDefinition> result = new AtomicReference<>();
    if (!canceled.get()) {
        PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {

            @Override
            public void run() {
                PropertyEntityResolverDialog dlg = new PropertyEntityResolverDialog(Display.getCurrent().getActiveShell(), schemaSpace, null, "Cell entity could not be resolved", candidate) {

                    @Override
                    public void create() {
                        super.create();
                        openTray(new ViewerEntityTray(original));
                    }
                };
                switch(dlg.open()) {
                    case Window.OK:
                        result.set(dlg.getObject());
                        break;
                    case Window.CANCEL:
                        // Don't try to resolve further entities
                        ps.setTemporaryProperty(RESOLVE_SKIP_PROPERTY, Value.of(true));
                        canceled.set(true);
                        break;
                    case PropertyEntityResolverDialog.SKIP:
                        // skip this entity
                        skipped.set(true);
                        break;
                    default:
                        canceled.set(true);
                }
            }
        });
    }
    EntityDefinition def = result.get();
    if (canceled.get() || skipped.get()) {
        // return the original so the cell is not lost
        return new DefaultProperty(original);
    } else if (def == null) {
        // caller must take care about this
        return null;
    } else {
        PropertyEntityDefinition propDef = (PropertyEntityDefinition) def;
        cache.put(original, propDef);
        return new DefaultProperty(propDef);
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) 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) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) ResolveCache(eu.esdihumboldt.hale.ui.service.align.resolver.internal.ResolveCache) ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService) PropertyEntityResolverDialog(eu.esdihumboldt.hale.ui.service.align.resolver.internal.PropertyEntityResolverDialog) ViewerEntityTray(eu.esdihumboldt.hale.ui.service.align.resolver.internal.ViewerEntityTray) AtomicReference(java.util.concurrent.atomic.AtomicReference) DefaultProperty(eu.esdihumboldt.hale.common.align.model.impl.DefaultProperty)

Example 8 with ProjectService

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

the class ReloadDataHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
    ps.reloadSourceData();
    return null;
}
Also used : ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService)

Example 9 with ProjectService

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

the class ExportConfigurationServiceSource method dispose.

/**
 * @see org.eclipse.ui.ISourceProvider#dispose()
 */
@Override
public void dispose() {
    ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
    ps.removeListener(projectListener);
}
Also used : ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService)

Example 10 with ProjectService

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

the class InstanceViewPreferencePage method createContents.

@Override
protected Control createContents(Composite parent) {
    ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
    Composite page = new Composite(parent, SWT.NONE);
    GridLayoutFactory.swtDefaults().numColumns(1).applyTo(page);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(page);
    // current sampler settings
    samplerSettings.clear();
    for (Entry<String, Sampler> entry : InstanceViewPreferences.SAMPLERS.entrySet()) {
        Value settings = ps.getConfigurationService().getProperty(InstanceViewPreferences.KEY_SETTINGS_PREFIX + entry.getKey());
        if (settings.isEmpty()) {
            settings = entry.getValue().getDefaultSettings();
        }
        samplerSettings.put(entry.getKey(), settings);
    }
    // sampler group
    samplerGroup = new Group(page, SWT.NONE);
    samplerGroup.setText("Instance sampling");
    GridDataFactory.fillDefaults().grab(true, false).applyTo(samplerGroup);
    GridLayoutFactory.swtDefaults().applyTo(samplerGroup);
    // enabled button
    enabled = new Button(samplerGroup, SWT.CHECK);
    enabled.setText("Use a sub-set of the imported source data as specified below:");
    enabled.setSelection(ps.getConfigurationService().getBoolean(InstanceViewPreferences.KEY_ENABLED, InstanceViewPreferences.ENABLED_DEFAULT));
    enabled.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            changed = true;
        }
    });
    // sampler selector
    samplers = new ComboViewer(samplerGroup);
    samplers.setContentProvider(ArrayContentProvider.getInstance());
    samplers.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof Sampler) {
                return ((Sampler) element).getDisplayName(Value.NULL);
            }
            return super.getText(element);
        }
    });
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false);
    samplers.setInput(InstanceViewPreferences.SAMPLERS.values());
    samplers.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection.isEmpty()) {
                updateEditor(null);
            } else {
                if (selection instanceof IStructuredSelection) {
                    updateEditor((Sampler) ((IStructuredSelection) selection).getFirstElement());
                }
            }
            changed = true;
        }
    });
    // restore the selected sampler
    String samplerId = ps.getConfigurationService().get(InstanceViewPreferences.KEY_SAMPLER, InstanceViewPreferences.SAMPLER_FIRST);
    Sampler selectedSampler = InstanceViewPreferences.SAMPLERS.get(samplerId);
    if (selectedSampler != null) {
        samplers.setSelection(new StructuredSelection(selectedSampler));
        changed = false;
    }
    // occurring values group
    Group ovGroup = new Group(page, SWT.NONE);
    ovGroup.setText("Occurring values");
    GridDataFactory.fillDefaults().grab(true, false).applyTo(ovGroup);
    GridLayoutFactory.swtDefaults().applyTo(ovGroup);
    // occurring values button
    occurringValuesComplete = new Button(ovGroup, SWT.CHECK);
    occurringValuesComplete.setText("Always use complete source data to determine occurring values (ignore sampling)");
    occurringValuesComplete.setSelection(ps.getConfigurationService().getBoolean(InstanceViewPreferences.KEY_OCCURRING_VALUES_USE_EXTERNAL, InstanceViewPreferences.OCCURRING_VALUES_EXTERNAL_DEFAULT));
    occurringValuesComplete.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ov_changed = true;
        }
    });
    return page;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Button(org.eclipse.swt.widgets.Button) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Sampler(eu.esdihumboldt.hale.ui.service.instance.sample.Sampler) Value(eu.esdihumboldt.hale.common.core.io.Value) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ISelection(org.eclipse.jface.viewers.ISelection) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

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