Search in sources :

Example 11 with InstanceService

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
        }
    });
}
Also used : InstanceValidationReport(eu.esdihumboldt.hale.common.instance.extension.validation.report.InstanceValidationReport) DataSet(eu.esdihumboldt.hale.common.instance.model.DataSet) InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService) InstanceServiceAdapter(eu.esdihumboldt.hale.ui.service.instance.InstanceServiceAdapter) InstanceValidationService(eu.esdihumboldt.hale.ui.service.instance.validation.InstanceValidationService) InstanceValidationListener(eu.esdihumboldt.hale.ui.service.instance.validation.InstanceValidationListener)

Example 12 with InstanceService

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;
}
Also used : Instance(eu.esdihumboldt.hale.common.instance.model.Instance) InstanceCollection(eu.esdihumboldt.hale.common.instance.model.InstanceCollection) InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService) TypeFilter(eu.esdihumboldt.hale.common.instance.model.TypeFilter)

Example 13 with InstanceService

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;
}
Also used : Instance(eu.esdihumboldt.hale.common.instance.model.Instance) InstanceReference(eu.esdihumboldt.hale.common.instance.model.InstanceReference) Style(org.geotools.styling.Style) InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService) Rule(org.geotools.styling.Rule) SelectableWaypoint(de.fhg.igd.mapviewer.waypoints.SelectableWaypoint) Point(com.vividsolutions.jts.geom.Point) MultiPoint(com.vividsolutions.jts.geom.MultiPoint)

Example 14 with InstanceService

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();
    }
}
Also used : StyleService(eu.esdihumboldt.hale.ui.common.service.style.StyleService) ISelectionService(org.eclipse.ui.ISelectionService) InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService) GeometrySchemaService(eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService)

Example 15 with InstanceService

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;
}
Also used : Instance(eu.esdihumboldt.hale.common.instance.model.Instance) InstanceReference(eu.esdihumboldt.hale.common.instance.model.InstanceReference) InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService)

Aggregations

InstanceService (eu.esdihumboldt.hale.ui.service.instance.InstanceService)21 Instance (eu.esdihumboldt.hale.common.instance.model.Instance)6 InstanceReference (eu.esdihumboldt.hale.common.instance.model.InstanceReference)5 GeometrySchemaService (eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService)5 InstanceCollection (eu.esdihumboldt.hale.common.instance.model.InstanceCollection)4 DataSet (eu.esdihumboldt.hale.common.instance.model.DataSet)3 StyleService (eu.esdihumboldt.hale.ui.common.service.style.StyleService)3 ProjectService (eu.esdihumboldt.hale.ui.service.project.ProjectService)3 SchemaService (eu.esdihumboldt.hale.ui.service.schema.SchemaService)3 EntityDefinition (eu.esdihumboldt.hale.common.align.model.EntityDefinition)2 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)2 InstanceServiceAdapter (eu.esdihumboldt.hale.ui.service.instance.InstanceServiceAdapter)2 ISelectionService (org.eclipse.ui.ISelectionService)2 MultiPoint (com.vividsolutions.jts.geom.MultiPoint)1 Point (com.vividsolutions.jts.geom.Point)1 ITileOverlayService (de.fhg.igd.mapviewer.view.overlay.ITileOverlayService)1 TileOverlayFactory (de.fhg.igd.mapviewer.view.overlay.TileOverlayFactory)1 SelectableWaypoint (de.fhg.igd.mapviewer.waypoints.SelectableWaypoint)1 PropertyParameter (eu.esdihumboldt.hale.common.align.extension.function.PropertyParameter)1 PropertyParameterDefinition (eu.esdihumboldt.hale.common.align.extension.function.PropertyParameterDefinition)1