Search in sources :

Example 46 with ProjectService

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

the class NewProjectHandler method execute.

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

Example 47 with ProjectService

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

the class AbstractRemoveResourcesOperation method execute.

@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
    ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
    removedResources = ps.removeResources(actionId);
    return Status.OK_STATUS;
}
Also used : ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService)

Example 48 with ProjectService

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

the class ProjectVariablesPreferencePage method createContents.

@Override
protected Control createContents(Composite parent) {
    ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
    Value value = ps.getConfigurationService().getProperty(ProjectVariables.PROJECT_PROPERTY_VARIABLES);
    variables = value.as(ValueProperties.class);
    if (variables == null) {
        variables = new ValueProperties();
        if (value.getValue() != null) {
            log.error("Unknown representation of project variables encountered");
        }
    }
    sc = new DynamicScrolledComposite(parent, SWT.V_SCROLL);
    sc.setExpandHorizontal(true);
    sc.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 200).create());
    page = new Composite(sc, SWT.NONE);
    GridLayoutFactory.swtDefaults().numColumns(1).applyTo(page);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(page);
    varList = new Composite(page, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(3).equalWidth(false).applyTo(varList);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(varList);
    Map<String, Value> sorted = new TreeMap<>(variables);
    for (String varName : sorted.keySet()) {
        addEditor(varName, false);
    }
    // add Add button
    Button add = new Button(page, SWT.PUSH);
    GridDataFactory.swtDefaults().align(SWT.END, SWT.BEGINNING).applyTo(add);
    add.setImage(CommonSharedImages.getImageRegistry().get(CommonSharedImagesConstants.IMG_ADD));
    add.setToolTipText("Add variable");
    add.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            final Display display = Display.getCurrent();
            InputDialog dialog = new InputDialog(display.getActiveShell(), "Add new variable", "Please enter the name of the variable to add", "", new IInputValidator() {

                @Override
                public String isValid(String newText) {
                    if (newText == null || newText.isEmpty()) {
                        return "Variable name must not be empty";
                    } else if (variables.containsKey(newText)) {
                        return "Variable already exists";
                    }
                    return null;
                }
            });
            if (dialog.open() == InputDialog.OK) {
                String varName = dialog.getValue();
                if (varName != null) {
                    variables.put(varName, Value.of(""));
                    addEditor(varName, true);
                    changed = true;
                }
            }
        }
    });
    sc.setContent(page);
    return page;
}
Also used : DynamicScrolledComposite(eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite) InputDialog(org.eclipse.jface.dialogs.InputDialog) Composite(org.eclipse.swt.widgets.Composite) DynamicScrolledComposite(eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService) TreeMap(java.util.TreeMap) ValueProperties(eu.esdihumboldt.hale.common.core.io.ValueProperties) Button(org.eclipse.swt.widgets.Button) Value(eu.esdihumboldt.hale.common.core.io.Value) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Display(org.eclipse.swt.widgets.Display) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Example 49 with ProjectService

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

the class OccurringValuesServiceImpl method updateOccuringValues.

/**
 * Update the occurring values for the given property entity.
 *
 * @param property the property entity definition
 * @param values the map containing the current occurring values
 * @return <code>true</code> if the task to update the information has been
 *         started, <code>false</code> if the information was up-to-date
 */
private boolean updateOccuringValues(PropertyEntityDefinition property, Map<PropertyEntityDefinition, OccurringValuesImpl> values) {
    synchronized (values) {
        OccurringValues ov = values.get(property);
        if (ov != null && ov.isUpToDate()) {
            return false;
        }
    }
    // determine occurring values
    // determine data set
    DataSet dataSet;
    switch(property.getSchemaSpace()) {
        case TARGET:
            dataSet = DataSet.TRANSFORMED;
            break;
        default:
            dataSet = DataSet.SOURCE;
    }
    // determine if external data should be used
    boolean useExternalData = false;
    if (dataSet.equals(DataSet.SOURCE)) {
        ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
        useExternalData = InstanceViewPreferences.occurringValuesUseExternalData(ps.getConfigurationService());
    }
    InstanceCollection collection;
    if (!useExternalData) {
        collection = instances.getInstances(dataSet);
    } else {
        // use complete project data sources
        final AtomicReference<InstanceCollection> source = new AtomicReference<>();
        IRunnableWithProgress op = new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
                List<InstanceCollection> sources = new ArrayList<>();
                for (Resource resource : ps.getResources()) {
                    if (InstanceIO.ACTION_LOAD_SOURCE_DATA.equals(resource.getActionId())) {
                        // resource is source data
                        IOConfiguration conf = resource.copyConfiguration(true);
                        TransformDataImportAdvisor advisor = new TransformDataImportAdvisor();
                        ProjectResourcesUtil.executeConfiguration(conf, advisor, false, null);
                        if (advisor.getInstances() != null) {
                            sources.add(advisor.getInstances());
                        }
                    }
                }
                source.set(new MultiInstanceCollection(sources));
            }
        };
        try {
            ThreadProgressMonitor.runWithProgressDialog(op, false);
            collection = source.get();
        } catch (Exception e) {
            log.error("Error initializing data sources", e);
            return true;
        }
    }
    // go through instances to determine occurring values
    Job job = new OccurringValuesJob(property, values, collection);
    job.schedule();
    return true;
}
Also used : DataSet(eu.esdihumboldt.hale.common.instance.model.DataSet) IOConfiguration(eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration) MultiInstanceCollection(eu.esdihumboldt.hale.common.instance.model.impl.MultiInstanceCollection) InstanceCollection(eu.esdihumboldt.hale.common.instance.model.InstanceCollection) ArrayList(java.util.ArrayList) Resource(eu.esdihumboldt.hale.common.core.io.project.model.Resource) ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService) AtomicReference(java.util.concurrent.atomic.AtomicReference) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) MultiInstanceCollection(eu.esdihumboldt.hale.common.instance.model.impl.MultiInstanceCollection) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TransformDataImportAdvisor(eu.esdihumboldt.hale.ui.transformation.TransformDataImportAdvisor) OccurringValues(eu.esdihumboldt.hale.ui.service.values.OccurringValues) Job(org.eclipse.core.runtime.jobs.Job)

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