Revision: 6637 http://sourceforge.net/p/jump-pilot/code/6637 Author: ma15569 Date: 2020-11-23 13:33:01 +0000 (Mon, 23 Nov 2020) Log Message: ----------- added check to avoid to overwrite input raster layer
Modified Paths: -------------- core/trunk/src/org/openjump/core/ui/plugin/raster/CropWarpPlugIn.java Modified: core/trunk/src/org/openjump/core/ui/plugin/raster/CropWarpPlugIn.java =================================================================== --- core/trunk/src/org/openjump/core/ui/plugin/raster/CropWarpPlugIn.java 2020-11-23 13:25:58 UTC (rev 6636) +++ core/trunk/src/org/openjump/core/ui/plugin/raster/CropWarpPlugIn.java 2020-11-23 13:33:01 UTC (rev 6637) @@ -1,7 +1,5 @@ package org.openjump.core.ui.plugin.raster; -import it.betastudio.adbtoolbox.libs.FileOperations; - import java.awt.Dimension; import java.awt.GridBagLayout; import java.awt.event.ActionEvent; @@ -60,6 +58,7 @@ import com.vividsolutions.jump.workbench.ui.images.IconLoader; import de.latlon.deejump.wfs.jump.WFSLayer; +import it.betastudio.adbtoolbox.libs.FileOperations; public class CropWarpPlugIn extends ThreadedBasePlugIn { @@ -112,6 +111,8 @@ .get("ui.plugin.raster.CropWarpPlugIn.no-intersection"); private final String CHECK = RasterMenuNames.Check_field; + private final String NO_OVERWRITE = I18N + .get("ui.GenericNames.cannot-overwrite"); private final String ACTION_LABEL = RasterMenuNames.Choose_an_action; private void updateGUI1(ActionEvent evt, MultiInputDialog dialog) { @@ -163,7 +164,7 @@ private void setDialogValues(PlugInContext context) throws IOException { dialog.setSideBarDescription(CROP_RASTER_TIP); List<RasterImageLayer> imageLayers = context.getLayerManager().getRasterImageLayers(); - RasterImageLayer rLayer; + if (imageLayers.contains(rLayerName)) { rLayer = imageLayers.get(imageLayers.indexOf(rLayerName)); } @@ -214,19 +215,22 @@ private final EnableCheck[] saveCheck = new EnableCheck[] { new EnableCheck() { @Override public String check(JComponent component) { - return jTextField_RasterOut.getText().isEmpty() ? CHECK - .concat(OUTPUT_FILE) : null; + rLayer = (RasterImageLayer) dialog.getLayerable(CLAYER); + return jTextField_RasterOut.getText().equals(rLayer.getImageFileName()) ? + "Cannot overwrite the input file" : null; } - } }; - - private final EnableCheck[] cropCheck = new EnableCheck[] { new EnableCheck() { + }, new EnableCheck() { @Override public String check(JComponent component) { - return fix.isNull() ? NO_INTERSECTION : null; + return jTextField_RasterOut.getText().isEmpty() ? CHECK + .concat(OUTPUT_FILE) : null; } } }; + + private RasterImageLayer rLayer; private void getDialogValues(MultiInputDialog dialog) { + rLayer = (RasterImageLayer) dialog.getLayerable(CLAYER); rLayerName = dialog.getLayerable(CLAYER).getName(); ACTION = dialog.getText(ACTION_LABEL); CROP = cropComboBox.getSelectedItem().toString(); @@ -261,7 +265,6 @@ monitor.report(PROCESSING); reportNothingToUndoYet(context); final File outFile = FileUtil.addExtensionIfNone(new File(path), "tif"); - RasterImageLayer rLayer = (RasterImageLayer) dialog.getLayerable(CLAYER); GenericRasterAlgorithm IO = new GenericRasterAlgorithm(); if (ACTION.equals(CROP_RASTER)) { _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel