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;
46 private final List<UpdateWrapper>
viewers =
new ArrayList<>();;
64 Collection<? extends DataContentViewer> dcvs = Lookup.getDefault().lookupAll(
DataContentViewer.class);
81 for (
int tab = 0; tab < numTabs; ++tab) {
106 @SuppressWarnings(
"unchecked")
112 setMinimumSize(
new java.awt.Dimension(5, 5));
114 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
115 this.setLayout(layout);
116 layout.setHorizontalGroup(
117 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
118 .addComponent(
jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
120 layout.setVerticalGroup(
121 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
122 .addComponent(
jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
132 this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
138 if (selectedNode == null) {
139 setName(defaultName);
142 if (content != null) {
144 String path = defaultName;
148 logger.log(Level.SEVERE,
"Exception while calling Content.getUniquePath() for {0}", content);
152 setName(defaultName);
156 currentNode = selectedNode;
160 this.setCursor(null);
173 if (listeningToTabbedPane ==
false) {
175 listeningToTabbedPane =
true;
180 int maxPreferred = 0;
181 int preferredViewerIndex = 0;
182 for (
int i = 0; i < totalTabs; ++i) {
184 dcv.resetComponent();
187 if ((selectedNode == null) || (dcv.isSupported(selectedNode) ==
false)) {
193 int currentPreferred = dcv.isPreferred(selectedNode);
194 if (currentPreferred > maxPreferred) {
195 preferredViewerIndex = i;
196 maxPreferred = currentPreferred;
207 dcv.resetComponent();
210 dcv.setNode(selectedNode);
223 JTabbedPane pane = (JTabbedPane) evt.getSource();
226 int currentTab = pane.getSelectedIndex();
227 if (currentTab != -1) {
229 if (dcv.isOutdated()) {
231 this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
233 dcv.setNode(currentNode);
235 this.setCursor(null);
248 this.outdated =
true;
251 void setNode(Node selectedNode) {
252 this.wrapped.
setNode(selectedNode);
253 this.outdated =
false;
256 void resetComponent() {
258 this.outdated =
true;
261 boolean isOutdated() {
265 boolean isSupported(Node node) {
269 int isPreferred(Node node) {
final List< UpdateWrapper > viewers
boolean listeningToTabbedPane
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()
static DataContentPanel createInstance()
void propertyChange(PropertyChangeEvent evt)
int isPreferred(Node node)
DataContentViewer wrapped
static Logger getLogger(String name)
DataContentViewer createInstance()