use of eu.esdihumboldt.hale.ui.service.instance.InstanceService in project hale by halestudio.
the class InstanceValidationStatusAction method createListeners.
/**
* Registers needed listeners.
*/
private void createListeners() {
InstanceService is = PlatformUI.getWorkbench().getService(InstanceService.class);
is.addListener(new InstanceServiceAdapter() {
@Override
public void datasetAboutToChange(DataSet type) {
report = null;
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
updateStatus();
}
});
}
});
final InstanceValidationService ivs = PlatformUI.getWorkbench().getService(InstanceValidationService.class);
ivs.addListener(new InstanceValidationListener() {
@Override
public void instancesValidated(InstanceValidationReport report) {
InstanceValidationStatusAction.this.report = report;
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
updateStatus();
}
});
}
@Override
public void validationEnabledChange() {
// don't care
}
});
}
use of eu.esdihumboldt.hale.ui.service.instance.InstanceService in project hale by halestudio.
the class InstanceTestValues method getInstance.
/**
* Get an instance that may hold a value for the given property.
*
* @param entity the property
* @return an instance or <code>null</code>
*/
protected Instance getInstance(EntityDefinition entity) {
// TODO cache instance?
InstanceService is = PlatformUI.getWorkbench().getService(InstanceService.class);
InstanceCollection instances = is.getInstances(DataSet.SOURCE).select(new TypeFilter(entity.getType()));
if (entity.getFilter() != null) {
instances = instances.select(entity.getFilter());
}
ResourceIterator<Instance> it = instances.iterator();
try {
// TODO use a random instance?
if (it.hasNext()) {
return it.next();
}
} finally {
it.close();
}
return null;
}
use of eu.esdihumboldt.hale.ui.service.instance.InstanceService in project hale by halestudio.
the class StyledInstanceMarker method honorRules.
/**
* Checks if there is a rule for the certain Instance
*
* @param context the context
* @return a certain style rule for the instance, else-rule if nothing found
* or null if there is no else-rule
*/
private Rule honorRules(InstanceWaypoint context) {
Style style = getStyle(context);
Rule[] rules = SLD.rules(style);
if (rules == null || rules.length == 0) {
return null;
}
// sort the elserules at the end
if (rules.length > 1) {
rules = sortRules(rules);
}
// if rule exists
InstanceReference ir = context.getValue();
InstanceService is = PlatformUI.getWorkbench().getService(InstanceService.class);
boolean instanceInitialized = false;
// instance variable - only initialize if needed
Instance inst = null;
for (int i = 0; i < rules.length; i++) {
if (rules[i].getFilter() != null) {
if (!instanceInitialized) {
// initialize instance (as it is needed for the filter)
inst = is.getInstance(ir);
instanceInitialized = true;
}
if (rules[i].getFilter().evaluate(inst)) {
return rules[i];
}
} else // if a rule exist without a filter and without being an
// else-filter,
// the found rule applies to all types
{
if (!rules[i].isElseFilter()) {
return rules[i];
}
}
}
// if there is no appropriate rule, check if there is an else-rule
for (int i = 0; i < rules.length; i++) {
if (rules[i].isElseFilter()) {
return rules[i];
}
}
// return null if no rule was found
return null;
}
use of eu.esdihumboldt.hale.ui.service.instance.InstanceService in project hale by halestudio.
the class StyledMapExtra method partOpened.
/**
* @see IPartListener2#partOpened(org.eclipse.ui.IWorkbenchPartReference)
*/
@Override
public void partOpened(IWorkbenchPartReference partRef) {
if (partRef.getPart(false) == mapView) {
mapView.restoreState();
// get services
ISelectionService selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService();
InstanceService instances = PlatformUI.getWorkbench().getService(InstanceService.class);
StyleService styles = PlatformUI.getWorkbench().getService(StyleService.class);
GeometrySchemaService geometries = PlatformUI.getWorkbench().getService(GeometrySchemaService.class);
// update
updateScenePainters(selection);
// add listeners
enableScenePainterListeners(selection, instances, styles, geometries);
layoutController.enable();
}
}
use of eu.esdihumboldt.hale.ui.service.instance.InstanceService in project hale by halestudio.
the class StyledMapUtil method getReference.
private static InstanceReference getReference(Object element) {
if (element instanceof InstanceReference) {
return (InstanceReference) element;
}
if (element instanceof Instance) {
InstanceService is = PlatformUI.getWorkbench().getService(InstanceService.class);
is.getReference((Instance) element);
}
return null;
}
Aggregations