Package org.locationtech.udig.project.internal

Examples of org.locationtech.udig.project.internal.EditManager


     * @param toRemove layers being removed
     * @param indexOfSelectedLayer
     * @return true if the selected layer has been changed
     */
    static boolean selectNewLayer( Map map, Collection<? extends ILayer> toRemove) {
        EditManager editManager = map.getEditManagerInternal();
        List<Layer> layers = map.getLayersInternal();
        Layer selectedLayer = editManager.getSelectedLayer();
        if( !toRemove.contains(selectedLayer ) )
            // nothing to be done since it is not going to be removed
            return false;
       
        // try to select bottom layer above the selected layer that is not being deleted.  If
        // not possible then select top layer below the selected layer
        for( int i=layers.indexOf(selectedLayer)+1; i<layers.size() ; i++ ){
            Layer layer=layers.get(i);
            if( !toRemove.contains(layer) ){
                editManager.setSelectedLayer(layer);
                return true;
            }
        }
        for( int i=layers.indexOf(selectedLayer)-1; i>=0 ; i-- ){
            Layer layer=layers.get(i);
            if( !toRemove.contains(layer) ){
                editManager.setSelectedLayer(layer);
                return true;
            }
        }
       
        editManager.setSelectedLayer(null);
        return true;
    }
View Full Code Here


     
      private enum Result{NO_TEMP_LAYERS, EXPORT_WIZARD_RUNNING};
            public void run() {
                try{
                 
                    EditManager editManagerInternal = mapEditor.getMap().getEditManagerInternal();
         
                    SaveMapRunnable.Result result = saveTemporaryLayers();
                    if( result == Result.NO_TEMP_LAYERS ){
              editManagerInternal.commitTransaction();

              success[0] = true;
                    } else {
                      success[0] = false;
                    }
View Full Code Here

     
      private enum Result{NO_TEMP_LAYERS, EXPORT_WIZARD_RUNNING};
            public void run() {
                try{
                 
                    EditManager editManagerInternal = mapEditor.getMap().getEditManagerInternal();
         
                    SaveMapPaletteRunnable.Result result = saveTemporaryLayers();
                    if( result == Result.NO_TEMP_LAYERS ){
              editManagerInternal.commitTransaction();

              success[0] = true;
                    } else {
                      success[0] = false;
                    }
View Full Code Here

        ILayer layer = layer2;

        EditBlackboard editBlackBoard;
        blackboardLock.lock();
        try {
            EditManager editManager = ((EditManager) context.getEditManager());
            if (editManager.getEditLayer() != null && editManager.isEditLayerLocked()) {
                layer = context.getEditManager().getEditLayer();
            }

            editBlackBoard = getEditBlackBoardFromLayer(layer);
           
View Full Code Here

                        return;
                    }
                    if (event.getType() != LayerEvent.EventType.EDIT_EVENT)
                        return;

                    EditManager editManager = (EditManager) layer.getMap().getEditManager();
                    ILayer editlayer = editManager.getSelectedLayer();
                    if (editManager.getEditLayer() != null && editManager.isEditLayerLocked()) {
                        editlayer = editManager.getEditLayer();
                    }
                    EditState currentEditState=(EditState)layer.getMap().getBlackboard().get(EditToolHandler.EDITSTATE);
                    if (editlayer == layer
                            && (currentEditState == EditState.COMMITTING || EditManagerListener.committing==editManager) )
                        return;
View Full Code Here

        List<EditGeom> geoms = bb.getGeoms();
        monitor.beginTask(Messages.EditBlackboardUtil_updating_selected_features, geoms.size());

        PrimitiveShape shape = (PrimitiveShape) layer.getMap().getBlackboard().get(
                EditToolHandler.CURRENT_SHAPE);
        EditManager editManager = (EditManager) layer.getMap().getEditManager();

        FilterFactory factory = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
        Set<Identifier> ids = new HashSet<Identifier>();
        for( EditGeom geom : geoms ) {
          ids.add(factory.featureId(geom.getFeatureIDRef().get()));
        }
        Id fidFilter = factory.id(ids);
        Filter filter =factory.and(fidFilter, layer.createBBoxFilter(dirtyArea, new NullProgressMonitor()));
         
        try {
            FeatureSource<SimpleFeatureType, SimpleFeature> fs = layer.getResource(FeatureSource.class, monitor);
            FeatureCollection<SimpleFeatureType, SimpleFeature>  results = fs.getFeatures(filter);
            FeatureIterator<SimpleFeature> reader = results.features();
            try {
                int read = 0;
                boolean selectedFound = false;
                List<EditGeom> toRemove = new ArrayList<EditGeom>();
                while( reader.hasNext() ) {
                  int count = geoms.size() - read;
                    monitor.setTaskName(MessageFormat.format(Messages.EditBlackboardUtil_count_remaining, new Object[] {count}));
                    read++;
                    SimpleFeature feature = reader.next();

                    for( EditGeom geom : geoms ) {
                        if (feature.getID().equals(geom.getFeatureIDRef().get())) {
                            toRemove.add(geom);
                        }
                    }

                    Map<Geometry, EditGeom> mapping = bb.addGeometry((Geometry) feature.getDefaultGeometry(),
                            feature.getID());
                    if (feature.getID().equals(shape.getEditGeom().getFeatureIDRef().get())) {
                        editManager.setEditFeature(feature, (Layer) layer);
                        layer.getMap().getBlackboard().put(EditToolHandler.CURRENT_SHAPE,
                                mapping.values().iterator().next().getShell());
                        selectedFound = true;
                    }
                    monitor.worked(1);
                }
                if (!selectedFound) {
                    layer.getMap().getBlackboard().put(EditToolHandler.CURRENT_SHAPE, null);
                    editManager.setEditFeature(null, null);
                }
                bb.removeGeometries(toRemove);
            } finally {
                reader.close();
                monitor.done();
View Full Code Here

            IllegalStateException illegalStateException = new IllegalStateException( message );
            ProjectPlugin.log(message, illegalStateException);
            throw illegalStateException;
        }
        // grab the current map transaction
        EditManager editManager = (EditManager) layer.getMap().getEditManager();
        Transaction transaction = editManager.getTransaction();
       
        if (wrapped.getTransaction() == Transaction.AUTO_COMMIT) {
            // change over from autocommit to transactional
            wrapped.setTransaction(transaction);
        }
View Full Code Here

            IllegalStateException illegalStateException = new IllegalStateException( message );
            ProjectPlugin.log(message, illegalStateException);
            throw illegalStateException;
        }
        // grab the current map transaction
        EditManager editManager = (EditManager) layer.getMap().getEditManager();
        Transaction transaction = editManager.getTransaction();
       
        if (wrapped.getTransaction() == Transaction.AUTO_COMMIT) {
            // change over from autocommit to transactional
            wrapped.setTransaction(transaction);
        }
View Full Code Here

    public void run( IProgressMonitor monitor ) throws Exception {
        monitor.beginTask(Messages.SelectLayerCommand_selecting, 2);
        monitor.worked(1);
       
        EditManager editManagerInternal = getMap().getEditManagerInternal();
        old=editManagerInternal.getSelectedLayer();
        editManagerInternal.setSelectedLayer((Layer) layer);
        monitor.done();
    }
View Full Code Here

    public void rollback( IProgressMonitor monitor ) throws Exception {
        monitor.beginTask(Messages.SelectLayerCommand_undoing, 2);
        monitor.worked(1);
       
        EditManager editManagerInternal = getMap().getEditManagerInternal();
        editManagerInternal.setSelectedLayer(old);
        monitor.done();
    }
View Full Code Here

TOP

Related Classes of org.locationtech.udig.project.internal.EditManager

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.