ok Peppe,

i see what you did there. but before we add a method for each layer type, how 
about a more generic method
  createAtLeastNLayerablesOfTypeMustExistCheck(final int n, Class type)
that can be reused?

you may use LayerManager.getLayerables(Class<T> layerableClass) for that.

..ede

On 04.06.2018 15:02, Giuseppe Aruta wrote:
> No.
> How does it work in my case: checking if sextante raster layers are loaded 
> into OJ?
> I added the following code to the class:
> 
> 
>  public EnableCheck createAtLeastNRasterImageLayersMustExistCheck(final int 
> n) {
>         return new EnableCheck() {
>             @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")
>                             + " ("
>                             + 
> get("org.openjump.core.rasterimage.AddRasterImageLayerWizard.Sextante-Raster-Image")
>                             + ")";
>                 } else {
>                     msg = getMessage(
>                             
> "com.vividsolutions.jump.workbench.plugin.At-least-n-layerables-must-exist",
>                             new Object[] { n })
>                             + " ("
>                             + 
> get("org.openjump.core.rasterimage.AddRasterImageLayerWizard.Sextante-Raster-Image")
>                             + ")";
>                     ;
>                 }
>                 return (layerManager == null || n > layerManager
>                         .getRasterImageLayers().size()) ? msg : null;
>             }
>         };
>     }
> 
> 
> Peppe
> 
> 2018-06-04 14:49 GMT+02:00 <edgar.sol...@web.de <mailto:edgar.sol...@web.de>>:
> 
>     hey Peppe,
> 
>     On 04.06.2018 14:41, jump-pilot-svn--- via Jump-pilot-devel wrote:
>     > -    public static EnableCheckFactory getInstance(){
>     > -      if (instance==null)
>     > -        instance = new 
> EnableCheckFactory(JUMPWorkbench.getInstance().getContext());
>     > -      return instance;
>     > +    public static EnableCheckFactory getInstance() {
>     > +        if (instance == null) {
>     > +            instance = new 
> EnableCheckFactory(JUMPWorkbench.getInstance()
>     > +                    .getContext());
>     > +        }
>     > +        return instance;
>     >      }
> 
>     are you aware of EnableCheckFactory.getInstance() which does exactly the 
> above but on the level the whole OJ? ..ede
> 
>     
> ------------------------------------------------------------------------------
>     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 
> <mailto:Jump-pilot-devel@lists.sourceforge.net>
>     https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel 
> <https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel>
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> 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
> 


------------------------------------------------------------------------------
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

Reply via email to