コード例 #1
0
 public boolean isEnabled() {
   boolean isEnabled = false;
   MapEditorPlugIn mapEditor = null;
   if ((mapEditor = getPlugInContext().getMapEditor()) != null) {
     MapContext map = (MapContext) mapEditor.getElement().getObject();
     ILayer activeLayer = map.getActiveLayer();
     if (activeLayer != null && activeLayer.getSelection().length > 0) isEnabled = true;
   }
   btn.setEnabled(isEnabled);
   return isEnabled;
 }
コード例 #2
0
 public boolean execute(PlugInContext context) throws Exception {
   IEditor editor = getPlugInContext().getActiveEditor();
   MapContext map = (MapContext) editor.getElement().getObject();
   ILayer activeLayer = map.getActiveLayer();
   int[] sel = activeLayer.getSelection().clone();
   Arrays.sort(sel);
   DataSource dataSource = activeLayer.getDataSource();
   try {
     dataSource.setDispatchingMode(DataSource.STORE);
     for (int i = sel.length - 1; i >= 0; i--) {
       dataSource.deleteRow(sel[i]);
     }
     dataSource.setDispatchingMode(DataSource.DISPATCH);
   } catch (DriverException e) {
     ErrorMessages.error(ErrorMessages.CannotDeleteSelectedRow, e);
   }
   return true;
 }
コード例 #3
0
ファイル: PolygonTool.java プロジェクト: albacore-xx/orbisgis
  @Override
  protected void polygonDone(com.vividsolutions.jts.geom.Polygon pol, MapContext mc, ToolManager tm)
      throws TransitionException {
    Geometry g = pol;
    if (ToolUtilities.geometryTypeIs(mc, GeometryConstraint.MULTI_POLYGON)) {
      g = ToolManager.toolsGeometryFactory.createMultiPolygon(new Polygon[] {pol});
    }

    SpatialDataSourceDecorator sds = mc.getActiveLayer().getDataSource();
    try {
      Value[] row = new Value[sds.getMetadata().getFieldCount()];
      row[sds.getSpatialFieldIndex()] = ValueFactory.createValue(g);
      row = ToolUtilities.populateNotNullFields(sds, row);
      sds.insertFilledRow(row);
    } catch (DriverException e) {
      throw new TransitionException("Cannot insert polygon", e);
    }
  }