Revision: 5838 http://sourceforge.net/p/jump-pilot/code/5838 Author: edso Date: 2018-06-05 09:44:23 +0000 (Tue, 05 Jun 2018) Log Message: ----------- rename to a more speaking name remove warning suppressions check before fetching strings limit class parameter to layerable implementations
Modified Paths: -------------- core/trunk/src/com/vividsolutions/jump/workbench/plugin/EnableCheckFactory.java Modified: core/trunk/src/com/vividsolutions/jump/workbench/plugin/EnableCheckFactory.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/workbench/plugin/EnableCheckFactory.java 2018-06-05 08:54:24 UTC (rev 5837) +++ core/trunk/src/com/vividsolutions/jump/workbench/plugin/EnableCheckFactory.java 2018-06-05 09:44:23 UTC (rev 5838) @@ -812,39 +812,35 @@ } /** - * Check that at least n Layerables of a type (Layer.class, + * Check that at least n layerables of a type (Layer.class, * RasterImageLayer.class, WMSLayer.class, etc) have been loaded * * @param number - * of layerables + * of needed layerables * @param type - * of layerable class (RasterImageLayer.class, Layer.class, - * WMSLayer.class, etc) + * implementation of {@link Layerable} (RasterImageLayer.class, Layer.class, + * WMSLayer.class, etc) * @return error message or null */ - public EnableCheck createAtLeastNLayerablesMustExistCheck(final int n, - @SuppressWarnings("rawtypes") Class layerableClass) { - return new EnableCheck() { - @SuppressWarnings("unchecked") - @Override - public String check(JComponent component) { - final LayerManager layerManager = workbenchContext - .getLayerManager(); - String msg; - if (n == 1) { - msg = get("com.vividsolutions.jump.workbench.plugin.At-least-one-layerables-must-exist") - + ": " + layerableClass.getSimpleName(); - } else { - msg = getMessage( - "com.vividsolutions.jump.workbench.plugin.At-least-n-layerables-must-exist", - new Object[] { n }) - + ": " + layerableClass.getSimpleName(); - ; - } - return (layerManager == null || n > layerManager.getLayerables( - layerableClass).size()) ? msg : null; - } - }; + public EnableCheck createAtLeastNLayerablesOfTypeMustExistCheck(final int n, final Class<? extends Layerable> type) { + return new EnableCheck() { + public String check(JComponent component) { + // all is well + if ( workbenchContext.getLayerManager().getLayerables(type).size() >= n ) + return null; + + // or not. tell the user + String msg; + if (n == 1) { + msg = get("com.vividsolutions.jump.workbench.plugin.At-least-one-layerables-must-exist") + ": " + + type.getSimpleName(); + } else { + msg = getMessage("com.vividsolutions.jump.workbench.plugin.At-least-n-layerables-must-exist", + new Object[] { n }) + ": " + type.getSimpleName(); + } + return msg; + } + }; } } ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel