Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
AbstractDataResultViewer.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obt ain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.corecomponents;
20 
21 import java.awt.Component;
22 import java.beans.PropertyVetoException;
23 import java.util.logging.Level;
24 import javax.swing.JPanel;
25 import org.openide.explorer.ExplorerManager;
26 import org.openide.explorer.ExplorerManager.Provider;
27 import org.openide.nodes.Node;
28 import org.openide.util.Lookup;
32 
39  abstract class AbstractDataResultViewer extends JPanel implements DataResultViewer, Provider {
40 
41  private static final Logger logger = Logger.getLogger(AbstractDataResultViewer.class.getName());
42  protected transient ExplorerManager em;
47  protected DataContent contentViewer;
48 
57  public AbstractDataResultViewer(ExplorerManager explorerManager) {
58  this.em = explorerManager;
59  initialize();
60  }
61 
67  public AbstractDataResultViewer() {
68  em = new ExplorerManager();
69  initialize();
70  }
71 
72  private void initialize() {
73  //DataContent is designed to return only the default viewer from lookup
74  //use the default one unless set otherwise
75  contentViewer = Lookup.getDefault().lookup(DataContent.class);
76  }
77 
78  @Override
79  public void clearComponent() {
80  }
81 
82  public Node getSelectedNode() {
83  Node result = null;
84  Node[] selectedNodes = this.getExplorerManager().getSelectedNodes();
85  if (selectedNodes.length > 0) {
86  result = selectedNodes[0];
87  }
88  return result;
89  }
90 
91  @Override
92  public void expandNode(Node n) {
93  }
94 
95  @Override
96  public void resetComponent() {
97  }
98 
99  @Override
100  public Component getComponent() {
101  return this;
102  }
103 
104  @Override
105  public ExplorerManager getExplorerManager() {
106  return this.em;
107  }
108 
109  @Override
110  public void setSelectedNodes(Node[] selected) {
111  try {
112  this.em.setSelectedNodes(selected);
113  } catch (PropertyVetoException ex) {
114  logger.log(Level.WARNING, "Couldn't set selected nodes.", ex); //NON-NLS
115  }
116  }
117 
118  @Override
119  public void setContentViewer(DataContent contentViewer) {
120  this.contentViewer = contentViewer;
121  }
122 }
static Logger getLogger(String name)
Definition: Logger.java:131

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.