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<>();
50 private boolean listeningToTabbedPane =
false;
66 Collection<? extends DataContentViewer> dcvs = Lookup.getDefault().lookupAll(
DataContentViewer.class);
76 javax.swing.JScrollPane scrollTab =
new javax.swing.JScrollPane(dcv.
getComponent());
77 scrollTab.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_NEVER);
78 jTabbedPane1.addTab(dcv.
getTitle(), null,
83 int numTabs = jTabbedPane1.getTabCount();
84 for (
int tab = 0; tab < numTabs; ++tab) {
85 jTabbedPane1.setEnabledAt(tab,
false);
108 @SuppressWarnings(
"unchecked")
110 private
void initComponents() {
112 jTabbedPane1 =
new javax.swing.JTabbedPane();
114 setMinimumSize(
new java.awt.Dimension(5, 5));
116 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
117 this.setLayout(layout);
118 layout.setHorizontalGroup(
119 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
120 .addComponent(jTabbedPane1)
122 layout.setVerticalGroup(
123 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
124 .addComponent(jTabbedPane1)
134 this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
139 if (selectedNode == null) {
140 setName(defaultName);
142 Content content = selectedNode.getLookup().lookup(Content.class);
143 if (content != null) {
145 String path = defaultName;
147 path = content.getUniquePath();
148 }
catch (TskCoreException ex) {
149 logger.log(Level.SEVERE,
"Exception while calling Content.getUniquePath() for {0}", content);
153 setName(defaultName);
157 currentNode = selectedNode;
159 setupTabs(selectedNode);
161 this.setCursor(null);
174 if (listeningToTabbedPane ==
false) {
175 jTabbedPane1.addChangeListener(
this);
176 listeningToTabbedPane =
true;
179 int currTabIndex = jTabbedPane1.getSelectedIndex();
180 int totalTabs = jTabbedPane1.getTabCount();
181 int maxPreferred = 0;
182 int preferredViewerIndex = 0;
183 for (
int i = 0; i < totalTabs; ++i) {
185 dcv.resetComponent();
188 if ((selectedNode == null) || (dcv.isSupported(selectedNode) ==
false)) {
189 jTabbedPane1.setEnabledAt(i,
false);
191 jTabbedPane1.setEnabledAt(i,
true);
194 int currentPreferred = dcv.isPreferred(selectedNode);
195 if (currentPreferred > maxPreferred) {
196 preferredViewerIndex = i;
197 maxPreferred = currentPreferred;
207 if (jTabbedPane1.isEnabledAt(tabIndex) ==
false) {
208 dcv.resetComponent();
210 dcv.setNode(selectedNode);
214 jTabbedPane1.setSelectedIndex(tabIndex);
215 jTabbedPane1.getSelectedComponent().repaint();
224 JTabbedPane pane = (JTabbedPane) evt.getSource();
227 int currentTab = pane.getSelectedIndex();
228 if (currentTab != -1) {
230 if (dcv.isOutdated()) {
232 this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
234 dcv.setNode(currentNode);
236 this.setCursor(null);
248 this.wrapped = wrapped;
249 this.outdated =
true;
252 void setNode(Node selectedNode) {
253 this.wrapped.
setNode(selectedNode);
254 this.outdated =
false;
257 void resetComponent() {
259 this.outdated =
true;
262 boolean isOutdated() {
263 return this.outdated;
266 boolean isSupported(Node node) {
270 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()