/*
 * Autopsy Forensic Browser
 *
 * Copyright 2016 Basis Technology Corp.
 * Contact: carrier <at> sleuthkit <dot> org
 *
 * 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.
 */
package org.sleuthkit.autopsy.datamodel;

import java.util.List;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.ChildFactory;
import org.openide.nodes.Children;
import org.openide.nodes.Node;

/**
 * EmptyNode Class made for when you need to display a node with with text in the table view
 * but no children in the tree view.
 *
 */
public final class EmptyNode extends AbstractNode {

    /**
     * Creates an EmptyNode
     * 
     * @param displayedMessage the text you would like displayed in the table view, this will not appear as a child node. 
     */
    public EmptyNode(String displayedMessage) {
        super(Children.create(new EmptyNodeChildren(displayedMessage), true));

    }

    static class EmptyNodeChildren extends ChildFactory<String> {

        String fileIdMsg; //NON-NLS

        private EmptyNodeChildren(String displayedMessage) {
            fileIdMsg = displayedMessage;
        }

        @Override
        protected boolean createKeys(List<String> list) {
            list.add(fileIdMsg);
            return true;
        }

        @Override
        protected Node createNodeForKey(String key) {
            return new MessageNode(key);
        }

    }

    /**
     * MessageNode is is the info message that displays in the table view, by
     * also extending a DisplayableItemNode type, rather than an AbstractNode
     * type it doesn't throw an error when right clicked.
     */
    static class MessageNode extends DisplayableItemNode {

        MessageNode(String name) {
            super(Children.LEAF);
            super.setName(name);
            setName(name);
            setDisplayName(name);
        }

        @Override
        public boolean isLeafTypeNode() {
            return true;
        }

        @Override
        public <T> T accept(DisplayableItemNodeVisitor<T> v) {
            return v.visit(this);
        }

        @Override
        public String getItemType() {
            return getClass().getName();
        }
    }
}

@@ -40,16 +40,21 @@
 pyright 
+2011-
 2016 Bas
@@ -901,57 +901,91 @@
 %0A * 
-EmptyNode Class ma
+Provides a root no
 de for 
-when you need to
+the results views with a single child node that%0A *
  display
  a n
@@ -984,58 +984,153 @@
 play
+s
  a 
-node with with text in the table view%0A * but no
+message as the sole item in its property sheet, useful for%0A * displaying explanatory text in the result views when there is a node with no%0A *
  chi
@@ -1153,19 +1153,16 @@
 e view.%0A
- *%0A
  */%0Apubl
@@ -1229,58 +1229,95 @@
   * 
-Creates an EmptyNode%0A     * 
+Provides a root node for the results views with a single child node that
 %0A     *
- @param
  display
 edMe
@@ -1316,109 +1316,308 @@
 play
-edM
+s a m
 essage 
+as 
 the 
-text you would like displayed in the table view, this will not appear as a child
+sole item in its property sheet, useful for%0A     * displaying explanatory text in the result views when there is a node with%0A     * no children in the tree view.%0A     *%0A     * @param displayedMessage The text for the property sheet of the child%0A     *                        
  node.
- 
 %0A   
@@ -1748,17 +1748,16 @@
 true));%0A
-%0A
     %7D%0A%0A 
@@ -1841,28 +1841,25 @@
 ing 
-fileIdMsg; //NON-NLS
+displayedMessage;
 %0A%0A  
@@ -1929,25 +1929,37 @@
         
-fileIdMsg
+this.displayedMessage
  = displ
@@ -2050,20 +2050,20 @@
 String%3E 
-list
+keys
 ) %7B%0A    
@@ -2074,26 +2074,33 @@
     
-list
+keys
 .add(
-fileIdMsg
+displayedMessage
 );%0A 
@@ -2284,213 +2284,129 @@
   * 
-MessageNode is is the info message that displays in the table view, by%0A     * also extending a DisplayableItemNode type, rather than an AbstractNode%0A     * type it doesn't throw an error when right clicked
+The single child node of an EmptyNode, responsible for displaying a%0A     * message as the sole item in its property sheet
 .%0A  

Tidy up EmptyNode class