All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.tidalwave.metadata.persistence.node.impl.MetadataRootNode Maven / Gradle / Ivy

/*******************************************************************************
 *
 * blueMarine - open source photo workflow
 * =======================================
 *
 * Copyright (C) 2003-2009 by Fabrizio Giudici
 * Project home page: http://bluemarine.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. 
 *
 *******************************************************************************
 *
 * $Id: MetadataRootNode.java,v b4402600a8db 2010/02/17 15:36:39 fabrizio $
 *
 ******************************************************************************/
package it.tidalwave.metadata.persistence.node.impl;

import javax.annotation.Nonnull;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.text.Collator;
import it.tidalwave.util.logging.Logger;
import org.openide.util.NbBundle;
import it.tidalwave.metadata.persistence.MetadataComposite;
import it.tidalwave.metadata.persistence.MetadataPersistence;
import it.tidalwave.metadata.persistence.MetadataPropertySet;

/*******************************************************************************
 * 
 * @author  Fabrizio Giudici
 * @version $Id: MetadataRootNode.java,v b4402600a8db 2010/02/17 15:36:39 fabrizio $
 *
 ******************************************************************************/
public class MetadataRootNode extends MetadataCompositeNode
  {
    private final static String CLASS = MetadataRootNode.class.getName();
    private final static Logger logger = Logger.getLogger(CLASS);
    
    /***************************************************************************
     *
     *
     **************************************************************************/
    protected static class MetadataTagChildFactory extends MetadataCompositeNode.MetadataCompositeChildFactory
      {
        public MetadataTagChildFactory()
          {
            super(null);
          }
        
        @Override
        @Nonnull
        @edu.umd.cs.findbugs.annotations.SuppressWarnings(value={"SIC_INNER_SHOULD_BE_STATIC_ANON"})
        protected List findProperties()
          {
            final MetadataPersistence metadataPersistence = MetadataPersistence.Locator.findPersistence();
            final List properties = metadataPersistence.getPropertySets();            
            final Collator collator = Collator.getInstance();

            Collections.sort(properties, new Comparator() 
              {
                public int compare (final MetadataPropertySet p1, final MetadataPropertySet p2)
                  {
                    return collator.compare(p1.getItemClass().getName(), p2.getItemClass().getName()); // FIXME: use item getDisplayName?
                  }
              });
              
            return properties;
          }
        
        @Override
        @Nonnull
        protected List findValues()
          {
            return Collections.emptyList();
          }
      }

    /***************************************************************************
     *
     *
     **************************************************************************/
    public MetadataRootNode()
      {
        super(new MetadataTagChildFactory()); 
      }
    
    /***************************************************************************
     *
     *
     **************************************************************************/
    @Override
    protected void refreshAttributes() 
      {
        setName(NbBundle.getMessage(MetadataRootNode.class, "FN_AllMetadata"));
      }
    
// FIXME: complete transition to EnhancedNode, using capabilities 
    @Override
    public boolean canCopy()
      {
        return false;
      }
    
    @Override
    public boolean canCut()
      {
        return false;
      }
    
    @Override
    public boolean canDestroy()
      {
        return false;
      }
  }