Search in sources :

Example 6 with InstanceService

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

the class StyledMapExtra method partClosed.

/**
 * @see IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference)
 */
@Override
public void partClosed(IWorkbenchPartReference partRef) {
    if (partRef.getPart(false) == mapView) {
        layoutController.disable();
        // 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);
        // remove listeners
        disableScenePainterListeners(selection, instances, styles, geometries);
    }
}
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 7 with InstanceService

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

the class StyledMapExtra method setMapView.

/**
 * @see MapViewExtension#setMapView(MapView)
 */
@Override
public void setMapView(MapView mapView) {
    this.mapView = mapView;
    layoutController = new PainterLayoutController(mapView.getMapKit());
    /*
		 * Listen for activated/deactivated instance painters
		 * 
		 * - remove listeners for deactivated painters and clear the waypoints -
		 * update activated listeners and add the corresponding listeners
		 */
    ITileOverlayService overlayService = PlatformUI.getWorkbench().getService(ITileOverlayService.class);
    overlayService.addListener(new SelectiveExtensionListener<TileOverlayPainter, TileOverlayFactory>() {

        @Override
        public void deactivated(TileOverlayPainter object, TileOverlayFactory definition) {
            if (object instanceof AbstractInstancePainter) {
                AbstractInstancePainter painter = (AbstractInstancePainter) object;
                // 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);
                // remove listeners
                selection.removeSelectionListener(painter);
                instances.removeListener(painter);
                styles.removeListener(painter.getStyleListener());
                geometries.removeListener(painter.getGeometryListener());
                // clear way-points
                painter.clearWaypoints();
            }
        }

        @Override
        public void activated(TileOverlayPainter object, TileOverlayFactory definition) {
            if (object instanceof AbstractInstancePainter) {
                AbstractInstancePainter painter = (AbstractInstancePainter) object;
                // 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
                painter.update(selection.getSelection());
                // add listeners
                selection.addSelectionListener(painter);
                instances.addListener(painter);
                styles.addListener(painter.getStyleListener());
                geometries.addListener(painter.getGeometryListener());
            }
        }
    });
    IPartService partService = mapView.getSite().getService(IPartService.class);
    partService.addPartListener(this);
    // map tips
    mapView.getMapTips().addMapTip(new InstanceMapTip(mapView.getMapKit()), 5);
}
Also used : PainterLayoutController(eu.esdihumboldt.hale.ui.views.styledmap.clip.layout.extension.PainterLayoutController) AbstractInstancePainter(eu.esdihumboldt.hale.ui.views.styledmap.painter.AbstractInstancePainter) StyleService(eu.esdihumboldt.hale.ui.common.service.style.StyleService) IPartService(org.eclipse.ui.IPartService) TileOverlayFactory(de.fhg.igd.mapviewer.view.overlay.TileOverlayFactory) GeometrySchemaService(eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService) ITileOverlayService(de.fhg.igd.mapviewer.view.overlay.ITileOverlayService) ISelectionService(org.eclipse.ui.ISelectionService) InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService) TileOverlayPainter(org.jdesktop.swingx.mapviewer.TileOverlayPainter)

Example 8 with InstanceService

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

the class GeoJSONConfigurationPage method createContent.

/**
 * @see HaleWizardPage#createContent(Composite)
 */
@Override
protected void createContent(final Composite page) {
    page.setLayout(new GridLayout(1, false));
    Label explanation = new Label(page, SWT.NONE);
    explanation.setText("If a geometry is set to \"none\", instances will still be included as GeoJSON features,\nbut without default geometries.");
    final DynamicScrolledComposite sc = new DynamicScrolledComposite(page, SWT.V_SCROLL);
    sc.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    Composite parent = new Composite(sc, SWT.NONE);
    sc.setExpandHorizontal(true);
    GridLayoutFactory.swtDefaults().numColumns(2).equalWidth(false).spacing(6, 12).applyTo(parent);
    InstanceService is = PlatformUI.getWorkbench().getService(InstanceService.class);
    GeometrySchemaService gss = PlatformUI.getWorkbench().getService(GeometrySchemaService.class);
    Set<TypeDefinition> types = is.getInstanceTypes(DataSet.TRANSFORMED);
    for (final TypeDefinition type : types) {
        Label label = new Label(parent, SWT.NONE);
        label.setText(type.getDisplayName() + ":");
        PropertyCondition condition = new PropertyOrChildrenTypeCondition(new GeometryCondition());
        PropertyParameterDefinition param = new PropertyParameter("", 0, 1, "Geometry", null, Collections.singletonList(condition), false);
        PropertyEntitySelector selector = new PropertyEntitySelector(SchemaSpaceID.TARGET, param, parent, new TypeEntityDefinition(type, SchemaSpaceID.TARGET, null));
        selector.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                if (!event.getSelection().isEmpty() && event.getSelection() instanceof IStructuredSelection) {
                    IStructuredSelection selection = (IStructuredSelection) event.getSelection();
                    PropertyEntityDefinition property = (PropertyEntityDefinition) selection.getFirstElement();
                    config.addDefaultGeometry(type, property);
                } else {
                    config.addDefaultGeometry(type, null);
                }
            }
        });
        selector.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
        // initial selection
        List<QName> path = gss.getDefaultGeometry(type);
        if (path != null) {
            EntityDefinition entityDef = new TypeEntityDefinition(type, SchemaSpaceID.TARGET, null);
            for (QName child : path) entityDef = AlignmentUtil.getChild(entityDef, child);
            selector.setSelection(new StructuredSelection(entityDef));
        }
    }
    sc.setContent(parent);
}
Also used : Label(org.eclipse.swt.widgets.Label) PropertyEntitySelector(eu.esdihumboldt.hale.ui.function.common.PropertyEntitySelector) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) PropertyParameterDefinition(eu.esdihumboldt.hale.common.align.extension.function.PropertyParameterDefinition) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GeometrySchemaService(eu.esdihumboldt.hale.ui.geometry.service.GeometrySchemaService) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition) GridLayout(org.eclipse.swt.layout.GridLayout) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) PropertyCondition(eu.esdihumboldt.hale.common.align.model.condition.PropertyCondition) PropertyOrChildrenTypeCondition(eu.esdihumboldt.hale.common.align.model.condition.PropertyOrChildrenTypeCondition) DynamicScrolledComposite(eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite) Composite(org.eclipse.swt.widgets.Composite) DynamicScrolledComposite(eu.esdihumboldt.hale.ui.util.components.DynamicScrolledComposite) QName(javax.xml.namespace.QName) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) EntityDefinition(eu.esdihumboldt.hale.common.align.model.EntityDefinition) PropertyEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.PropertyEntityDefinition) GridData(org.eclipse.swt.layout.GridData) InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService) GeometryCondition(eu.esdihumboldt.hale.common.align.model.condition.impl.GeometryCondition) PropertyParameter(eu.esdihumboldt.hale.common.align.extension.function.PropertyParameter)

Example 9 with InstanceService

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

the class InstanceIndexUpdateServiceImpl method reindex.

private void reindex() {
    getIndexService().clearIndexedValues();
    InstanceService is = serviceProvider.getService(InstanceService.class);
    InstanceCollection source = is.getInstances(DataSet.SOURCE);
    try (ResourceIterator<Instance> it = source.iterator()) {
        while (it.hasNext()) {
            Instance i = it.next();
            InstanceReference ref = source.getReference(i);
            if (Identifiable.is(ref)) {
                ref = new IdentifiableInstanceReference(ref, Identifiable.getId(ref));
            }
            ResolvableInstanceReference rir = new ResolvableInstanceReference(ref, source);
            getIndexService().add(i, rir);
        }
    }
}
Also used : Instance(eu.esdihumboldt.hale.common.instance.model.Instance) ResolvableInstanceReference(eu.esdihumboldt.hale.common.instance.model.ResolvableInstanceReference) InstanceReference(eu.esdihumboldt.hale.common.instance.model.InstanceReference) IdentifiableInstanceReference(eu.esdihumboldt.hale.common.instance.model.IdentifiableInstanceReference) InstanceCollection(eu.esdihumboldt.hale.common.instance.model.InstanceCollection) IdentifiableInstanceReference(eu.esdihumboldt.hale.common.instance.model.IdentifiableInstanceReference) InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService) ResolvableInstanceReference(eu.esdihumboldt.hale.common.instance.model.ResolvableInstanceReference)

Example 10 with InstanceService

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

the class InstanceValidationReportDetailsPage method getValidSelection.

/**
 * Returns a valid instance selection for the current selection of the tree
 * viewer. Returns <code>null</code> if there is none.
 *
 * @return a valid instance selection for the current selection of the tree
 *         viewer or <code>null</code>
 */
private InstanceSelection getValidSelection() {
    ISelection viewerSelection = treeViewer.getSelection();
    if (!(viewerSelection instanceof ITreeSelection) || viewerSelection.isEmpty())
        return null;
    ITreeSelection treeSelection = (ITreeSelection) treeViewer.getSelection();
    // XXX use all paths
    TreePath firstPath = treeSelection.getPaths()[0];
    // instead of first
    // only?
    InstanceValidationMessage firstMessage;
    Iterator<InstanceValidationMessage> restIter;
    if (firstPath.getLastSegment() instanceof InstanceValidationMessage) {
        firstMessage = (InstanceValidationMessage) firstPath.getLastSegment();
        restIter = Iterators.emptyIterator();
    } else {
        Collection<InstanceValidationMessage> messages = contentProvider.getMessages(treeSelection.getPaths()[0]);
        if (messages.isEmpty())
            // shouldn't happen, but doesn't really matter
            return null;
        restIter = messages.iterator();
        firstMessage = restIter.next();
    }
    InstanceService is = PlatformUI.getWorkbench().getService(InstanceService.class);
    // check first message for valid instance reference
    if (firstMessage.getInstanceReference() == null || is.getInstance(firstMessage.getInstanceReference()) == null)
        return null;
    Set<InstanceReference> references = new HashSet<InstanceReference>();
    references.add(firstMessage.getInstanceReference());
    while (restIter.hasNext()) references.add(restIter.next().getInstanceReference());
    return new DefaultInstanceSelection(references.toArray());
}
Also used : ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) TreePath(org.eclipse.jface.viewers.TreePath) InstanceReference(eu.esdihumboldt.hale.common.instance.model.InstanceReference) ISelection(org.eclipse.jface.viewers.ISelection) InstanceValidationMessage(eu.esdihumboldt.hale.common.instance.extension.validation.report.InstanceValidationMessage) DefaultInstanceValidationMessage(eu.esdihumboldt.hale.common.instance.extension.validation.report.impl.DefaultInstanceValidationMessage) InstanceService(eu.esdihumboldt.hale.ui.service.instance.InstanceService) HashSet(java.util.HashSet) DefaultInstanceSelection(eu.esdihumboldt.hale.ui.selection.impl.DefaultInstanceSelection)

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