Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
OpenBlueSky - NetBeans Platform Enhancements Copyright (C) 2006-2011 by Tidalwave s.a.s. (http://www.tidalwave.it) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. WWW: http://openbluesky.kenai.com SCM: https://bitbucket.org/tidalwave/openbluesky-src /
 
 package it.tidalwave.hierarchy.spi.simple;
 
 import  javax.annotation.CheckForNull;
 import  javax.annotation.Nonnull;
 import java.util.List;
 import java.util.Map;
 import  org.openide.util.Lookup;
 import  org.openide.util.NbBundle;
 import  org.openide.util.lookup.Lookups;
 import  it.tidalwave.util.Id;
 import  it.tidalwave.role.spi.DefaultDisplayable;

Author(s):
Fabrizio Giudici
Version:
$Id$ /
 
 public class SimpleHViewManager extends AsSupport implements HViewManager
   {
     private final List<HViewviews = new ArrayList<HView>();
     private final Map<Id, SimpleHViewviewMapById = new HashMap<Id, SimpleHView>();
 
     @CheckForNull
     private Lookup lookup;
 
     private final Resettable resetter = new Resettable()
       {
         @Override
         public void reset()
           {
             .clear();
             .clear();
           }
       };
 
     @Override @Nonnull
     public Builder<HViewcreateView()
       {
         return new SimpleBuilder<HView>()
           {
             @Override @Nonnull
             public HView build()
               {
                 return createView(this);
               }
           };
       }
 
     @Override @Nonnull
     public Builder<HViewfindOrCreateView()
       {
         return new SimpleBuilder<HView>()
           {
             @Override @Nonnull
             public HView build()
               {
                 if (.containsKey())
                   {
                     return .get();
                   }
 
                 return createView(this);
               }
           };
       }
 
     @Override @Nonnull
    public Finder<HViewfindViews()
      {
        return new HFinderSupport<HView>("findViews()")
          {
            @Override @Nonnull
            protected List<HViewcomputeResults()
              {
                if ( != null)
                  {
                    final SimpleHView view = .get();
                    return (view != null) ? Collections.<HView>singletonList(view) : Collections.<HView>emptyList();
                  }
                else
                  {
                    return new ArrayList<HView>();
                  }
              }      
          };
      }
    @Override @Nonnull
    public Finder<HViewfindItems()
      {
        throw new UnsupportedOperationException("Not supported yet.");
      }
    @Nonnull
    private HView createView (final @Nonnull SimpleBuilder<HViewbuilder)
      {
        final SimpleHView view = new SimpleHView(builderthis);
        .add(view);
        .put(view.getId(), view);
        return view;
      }
    @Override @Nonnull
    public synchronized Lookup getLookup()
      {
        if ( == null)
          {
            final String displayName = NbBundle.getMessage(SimpleHViewManager.class"HViewManager.displayName");
            final DefaultDisplayable displayable = new DefaultDisplayable(displayName"SimpleHViewManager");
             = LookupFactory.createLookup(this, Lookups.fixed(displayable));
          }
        return ;
      }
  }
New to GrepCode? Check out our FAQ X