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));
}
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);
}
}
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;
}
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);
}
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;
}
Aggregations