19 package org.sleuthkit.autopsy.corecomponents;
21 import java.awt.Cursor;
22 import java.beans.PropertyChangeEvent;
23 import java.util.ArrayList;
24 import java.util.Collection;
25 import java.util.List;
26 import java.util.logging.Level;
27 import javax.swing.JTabbedPane;
28 import javax.swing.event.ChangeEvent;
29 import javax.swing.event.ChangeListener;
30 import org.openide.nodes.Node;
31 import org.openide.util.Lookup;
32 import org.openide.util.NbBundle;
43 @SuppressWarnings(
"PMD.SingularField")
47 private final List<UpdateWrapper> viewers =
new ArrayList<>();
51 private boolean listeningToTabbedPane =
false;
67 Collection<? extends DataContentViewer> dcvs = Lookup.getDefault().lookupAll(
DataContentViewer.class);
77 javax.swing.JScrollPane scrollTab =
new javax.swing.JScrollPane(dcv.
getComponent());
78 scrollTab.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_NEVER);
79 jTabbedPane1.addTab(dcv.
getTitle(), null,
84 int numTabs = jTabbedPane1.getTabCount();
85 for (
int tab = 0; tab < numTabs; ++tab) {
86 jTabbedPane1.setEnabledAt(tab,
false);
109 @SuppressWarnings(
"unchecked")
111 private
void initComponents() {
113 jTabbedPane1 =
new javax.swing.JTabbedPane();
115 setMinimumSize(
new java.awt.Dimension(5, 5));
117 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
118 this.setLayout(layout);
119 layout.setHorizontalGroup(
120 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
121 .addComponent(jTabbedPane1)
123 layout.setVerticalGroup(
124 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
125 .addComponent(jTabbedPane1)
135 this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
140 if (selectedNode == null) {
141 setName(defaultName);
143 Content content = selectedNode.getLookup().lookup(Content.class);
144 if (content != null) {
146 String path = defaultName;
148 path = content.getUniquePath();
149 }
catch (TskCoreException ex) {
150 logger.log(Level.SEVERE,
"Exception while calling Content.getUniquePath() for {0}", content);
154 setName(defaultName);
158 currentNode = selectedNode;
160 setupTabs(selectedNode);
162 this.setCursor(null);
175 if (listeningToTabbedPane ==
false) {
176 jTabbedPane1.addChangeListener(
this);
177 listeningToTabbedPane =
true;
180 int currTabIndex = jTabbedPane1.getSelectedIndex();
181 int totalTabs = jTabbedPane1.getTabCount();
182 int maxPreferred = 0;
183 int preferredViewerIndex = 0;
184 for (
int i = 0; i < totalTabs; ++i) {
186 dcv.resetComponent();
189 if ((selectedNode == null) || (dcv.isSupported(selectedNode) ==
false)) {
190 jTabbedPane1.setEnabledAt(i,
false);
192 jTabbedPane1.setEnabledAt(i,
true);
195 int currentPreferred = dcv.isPreferred(selectedNode);
196 if (currentPreferred > maxPreferred) {
197 preferredViewerIndex = i;
198 maxPreferred = currentPreferred;
208 if (jTabbedPane1.isEnabledAt(tabIndex) ==
false) {
209 dcv.resetComponent();
211 dcv.setNode(selectedNode);
215 jTabbedPane1.setSelectedIndex(tabIndex);
216 jTabbedPane1.getSelectedComponent().repaint();
225 JTabbedPane pane = (JTabbedPane) evt.getSource();
228 int currentTab = pane.getSelectedIndex();
229 if (currentTab != -1) {
231 if (dcv.isOutdated()) {
233 this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
235 dcv.setNode(currentNode);
237 this.setCursor(null);
249 this.wrapped = wrapped;
250 this.outdated =
true;
253 void setNode(Node selectedNode) {
254 this.wrapped.
setNode(selectedNode);
255 this.outdated =
false;
258 void resetComponent() {
260 this.outdated =
true;
263 boolean isOutdated() {
264 return this.outdated;
267 boolean isSupported(Node node) {
271 int isPreferred(Node node) {
boolean isSupported(Node node)
void setNode(Node selectedNode)
void setupTabs(Node selectedNode)
void setNode(Node selectedNode)
void stateChanged(ChangeEvent evt)
javax.swing.JTabbedPane jTabbedPane1
static boolean keepPreferredContentViewer()
JTabbedPane getTabPanels()
final DataContentViewer wrapped
static DataContentPanel createInstance()
void propertyChange(PropertyChangeEvent evt)
synchronized static Logger getLogger(String name)
int isPreferred(Node node)
DataContentViewer createInstance()