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<>();
66 Collection<? extends DataContentViewer> dcvs = Lookup.getDefault().lookupAll(
DataContentViewer.class);
82 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));
137 if (selectedNode == null) {
138 setName(defaultName);
141 if (content != null) {
143 String path = defaultName;
147 logger.log(Level.SEVERE,
"Exception while calling Content.getUniquePath() for {0}", content);
151 setName(defaultName);
155 currentNode = selectedNode;
159 this.setCursor(null);
172 if (listeningToTabbedPane ==
false) {
174 listeningToTabbedPane =
true;
179 int maxPreferred = 0;
180 int preferredViewerIndex = 0;
181 for (
int i = 0; i < totalTabs; ++i) {
183 dcv.resetComponent();
186 if ((selectedNode == null) || (dcv.isSupported(selectedNode) ==
false)) {
192 int currentPreferred = dcv.isPreferred(selectedNode);
193 if (currentPreferred > maxPreferred) {
194 preferredViewerIndex = i;
195 maxPreferred = currentPreferred;
206 dcv.resetComponent();
208 dcv.setNode(selectedNode);
221 JTabbedPane pane = (JTabbedPane) evt.getSource();
224 int currentTab = pane.getSelectedIndex();
225 if (currentTab != -1) {
227 if (dcv.isOutdated()) {
229 this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
231 dcv.setNode(currentNode);
233 this.setCursor(null);
246 this.outdated =
true;
249 void setNode(Node selectedNode) {
250 this.wrapped.
setNode(selectedNode);
251 this.outdated =
false;
254 void resetComponent() {
256 this.outdated =
true;
259 boolean isOutdated() {
263 boolean isSupported(Node node) {
267 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)
synchronized static Logger getLogger(String name)
int isPreferred(Node node)
DataContentViewer wrapped
DataContentViewer createInstance()