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