Package org.locationtech.udig.project

Examples of org.locationtech.udig.project.IEditManager


    private void removeCurrentMapListeners() {
       
        if (this.currentMap != null) {
       
            // Remove edit manager listener
            IEditManager editManager = this.currentMap.getEditManager();
            if (editManager.containsListener(editManagerListener)) {
                editManager.removeListener(editManagerListener);
                editManagerListener = null;
            }

            // Remove deep listener
            this.currentMap.removeDeepAdapter(mapDeepListener);
View Full Code Here


     *
     * @param editManager
     * @see #disableEditManagerListener()
     */
    static synchronized void enableEditManagerListener( EditToolHandler handler ) {
        IEditManager editManager=handler.getContext().getEditManager();
       
        // add listener if editManager is not null and map blackboard indicates that a listener has not be previously added
        if ( getRegisteredListener(editManager)==null ) {
            EditManagerListener editManagerListener = new EditManagerListener(editManager,handler);
            editManager.addListener(editManagerListener);
            editManager.getMap().getBlackboard().put(EDITING_EDIT_MANAGER_LISTENER, editManagerListener);
        }else{
            getRegisteredListener(editManager).handler=handler;
        }
    }
View Full Code Here

                layer.eSetDeliver(false);
                events=layer.getFeatureChanges().size();
            }
        fs.removeFeatures(filter);
       
        IEditManager editManager = getMap().getEditManager();
        SimpleFeature editFeature = editManager.getEditFeature();
        if (editFeature!=null && editManager.getEditLayer()==ilayer && filter.evaluate(editFeature))
            getMap().getEditManagerInternal().setEditFeature(null, null);
        }finally{
            fireFeatureChangeEvent(layer, events);
        }
    }
View Full Code Here

    /*
     * Test method for 'org.locationtech.udig.tools.edit.behaviour.SetGeomCommand.run(IProgressMonitor)'
     */
    @Test
    public void testRun() throws Exception {
        IEditManager editManager = handler.getContext().getEditManager();
       
        assertEquals("Does the ID match",feature.getID(), editManager.getEditFeature().getID());
    assertEquals("Is the feature equal",feature.getDefaultGeometry(), editManager.getEditFeature().getDefaultGeometry());
        assertEquals("Is the layer equal",layer, editManager.getEditLayer());
       
        SelectFeatureAsEditFeatureCommand command = new SelectFeatureAsEditFeatureCommand(handler, feature2, layer, Point.valueOf(10,10));
              
        handler.getContext().sendSyncCommand(command);
        assertEquals(handler.getEditBlackboard().getGeoms().get(0), handler.getCurrentGeom());
        assertEquals(handler.getEditBlackboard().getGeoms().get(0).getShell(), handler.getCurrentShape());
        assertEquals(EditState.MODIFYING, handler.getCurrentState());
        assertFalse(bb.getGeoms().contains(editGeom));
        assertFalse(bb.getGeoms().contains(editGeom2));
        assertEquals(feature2.getDefaultGeometry(), editManager.getEditFeature().getDefaultGeometry());
        assertEquals( feature2.getID(), handler.getCurrentGeom().getFeatureIDRef().get());

        ((CommandManager)((Map)handler.getContext().getMap()).getCommandStack()).undo(false);
        command.rollback(new NullProgressMonitor());
        assertEquals(editGeom2.getShell().getPoint(0), handler.getCurrentGeom().getShell().getPoint(0));
        assertEquals(editGeom2.getShell().getPoint(1), handler.getCurrentGeom().getShell().getPoint(1));
        assertEquals(hole.getPoint(0), handler.getCurrentShape().getPoint(0));
        assertEquals(hole.getPoint(1), handler.getCurrentShape().getPoint(1));
        assertTrue(handler.getCurrentGeom().getHoles().contains(handler.getCurrentShape()));
        assertEquals(EditState.CREATING, handler.getCurrentState());
        assertEquals(2, bb.getGeoms().size());
        assertEquals( editGeom2.getFeatureIDRef().get(), handler.getCurrentGeom().getFeatureIDRef().get());

        assertEquals(feature.getDefaultGeometry(), editManager.getEditFeature().getDefaultGeometry());
        assertEquals(layer, editManager.getEditLayer());
    }
View Full Code Here

        final TestHandler handler=new TestHandler();
       
        ILayer layer = handler.getContext().getMapLayers().get(0);
        FeatureSource<SimpleFeatureType, SimpleFeature> resource = layer.getResource(FeatureSource.class, null);
        SimpleFeature feature = resource.getFeatures().features().next();
        IEditManager editManager = handler.getContext().getEditManager();
    ((EditManager)editManager).setEditFeature(feature, (Layer) layer);
       
        EditBlackboard editBlackboard = handler.getEditBlackboard();
        PrimitiveShape shell = editBlackboard.getGeoms().get(0).getShell();
        editBlackboard.addPoint(100,100,shell);
        shell.getEditGeom().setShapeType(ShapeType.POINT);
        editBlackboard.newGeom("newone", null); //$NON-NLS-1$
       
        StartEditingBehaviour behav=new StartEditingBehaviour(ShapeType.POLYGON);

        handler.getBehaviours().add(behav);
       
        assertNotNull( editManager.getEditFeature());
       
        handler.setTesting(false);
        MapMouseEvent event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
        handler.handleEvent(event, EventType.RELEASED);
        try{
            PlatformGIS.wait(200, 200, WaitCondition.FALSE_CONDITION, null);
        }catch (Exception e) {
            // its expected
        }
        assertEquals(1, handler.getEditBlackboard().getGeoms().size());
       
        ((CommandManager)((Map)handler.getContext().getMap()).getCommandStack()).undo(false);
       
        assertEquals("Is the feature ID equal", feature.getID(), editManager.getEditFeature().getID());       
        assertEquals("Is the feature equal", feature, editManager.getEditFeature());
        assertFalse( handler.isLocked() );
        assertEquals(2, editBlackboard.getGeoms().size());
        assertEquals(ShapeType.POINT, editBlackboard.getGeoms().get(0).getShapeType());
        assertEquals(Point.valueOf(100,100), editBlackboard.getGeoms().get(0).getShell().getPoint(0));
       
View Full Code Here

        if (currentPart == part) {
            return;
        }
        if (currentPart != null) {
            if (currentMap != null) {
                IEditManager editManager = currentMap.getEditManager();
                editManager.removeListener(editListener);
            }
        }
        this.currentPart = part;

        StructuredSelection editSelection = null;
        if (currentPart != null) {
            if (currentMap != null) {
                IEditManager editManager = currentMap.getEditManager();
                editManager.addListener(editListener);
                editSelection = new StructuredSelection(editManager.getEditFeature());
            }
        }
        // pass the selection to the page
        IPage page = getCurrentPage(); // We are expecting a FeaturePanelPage
                                       // here
View Full Code Here

    private SimpleFeatureType getSchema(IWorkbenchPart part) {
        IMap map = (IMap) part.getAdapter(IMap.class);
        if (map == null) {
            return null;
        }
        IEditManager editManager = map.getEditManager();
        if (editManager == null) {
            return null;
        }
        ILayer selectedLayer = editManager.getSelectedLayer();
        if (selectedLayer == null) {
            return null;
        }
        return selectedLayer.getSchema();
    }
View Full Code Here

    IMap map = AppGISAdapter.getActiveMap();
    if (map == null)
      return null;

    IEditManager edit = map.getEditManager();
    if (edit == null)
      return null;

    ILayer layer = edit.getSelectedLayer();
    if (layer == null)
      return null;
    if (layer.getName() == null)
      return null;
View Full Code Here

    public String isEnabled( EditToolHandler handler, MapMouseEvent e, EventType eventType ) {
        if ((eventType!=EventType.MOVED  && eventType!=EventType.ENTERED) || lastLayer==handler.getEditLayer())
            return null;

        IEditManager editManager = handler.getContext().getEditManager();
        lastLayer=handler.getEditLayer();
        return detectCompatibility(handler, editManager);
    }
View Full Code Here

    @Override
    public void refresh() {
        SimpleFeature feature = null;
        IFeatureSite site = getSite();       
        if( site != null ){
            IEditManager editManager = site.getEditManager();
            if( editManager != null ){
                feature = editManager.getEditFeature();
            }
        }
       
        listen( false );
        String nameText = "";
View Full Code Here

TOP

Related Classes of org.locationtech.udig.project.IEditManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.