19 package org.sleuthkit.autopsy.keywordsearch;
21 import java.awt.Component;
22 import java.awt.Cursor;
23 import java.awt.event.ActionEvent;
24 import java.awt.event.ActionListener;
25 import java.util.ArrayList;
26 import java.util.Collection;
27 import java.util.List;
28 import java.util.logging.Level;
30 import org.openide.util.NbBundle;
32 import org.openide.nodes.Node;
33 import org.openide.util.lookup.ServiceProvider;
49 @ServiceProvider(service = DataContentViewer.class, position = 4)
53 private ExtractedContentPanel
panel;
54 private volatile Node currentNode = null;
55 private TextMarkup currentSource = null;
60 logger.log(Level.INFO,
"Created TextView instance: " +
this);
64 public void setNode(
final Node selectedNode) {
66 if (selectedNode == null) {
74 if (selectedNode == currentNode) {
78 currentNode = selectedNode;
86 final List<TextMarkup> sources =
new ArrayList<TextMarkup>();
90 sources.addAll(selectedNode.getLookup().lookupAll(TextMarkup.class));
95 if (content == null || content.
getSize() == 0) {
100 long objectId = getDocumentId(selectedNode);
101 boolean isDir = content.
accept(isDirVisitor);
103 if (!isDir && solrHasContent(objectId) ==
false) {
109 TextMarkup rawSource =
new RawTextMarkup(content, objectId);
111 currentSource = rawSource;
112 sources.add(rawSource);
115 int currentPage = currentSource.getCurrentPage();
116 if (currentPage == 0 && currentSource.hasNextPage()) {
117 currentSource.nextPage();
119 updatePageControls();
126 final TextMarkup source = panel.getSelectedSource();
127 if (source == null || !source.isSearchable()) {
131 panel.scrollToAnchor(source.getAnchorPrefix() + Integer.toString(source.currentItem()));
137 return NbBundle.getMessage(this.getClass(),
"ExtractedContentViewer.getTitle");
142 return NbBundle.getMessage(this.getClass(),
"ExtractedContentViewer.toolTip");
153 panel =
new ExtractedContentPanel();
157 panel.addNextPageControlListener(
new NextPageActionListener());
165 setPanel(
new ArrayList<TextMarkup>());
166 panel.resetDisplay();
168 currentSource = null;
179 Collection<? extends TextMarkup> sources = node.getLookup().lookupAll(TextMarkup.class);
180 if (sources.isEmpty() ==
false) {
190 return solrHasContent(getDocumentId(node));
214 panel.setSources(sources);
245 logger.log(Level.WARNING,
"Couldn't determine whether content is supported.", ex);
248 logger.log(Level.WARNING,
"Couldn't determine whether content is supported.", ex);
261 HighlightedTextMarkup markup = node.getLookup().lookup(HighlightedTextMarkup.class);
263 if (markup != null) {
264 return markup.getObjectId();
270 return content.
getId();
279 TextMarkup source = panel.getSelectedSource();
280 if (source == null) {
282 panel.updateControls(null);
285 final boolean hasNextItem = source.hasNextItem();
286 final boolean hasNextPage = source.hasNextPage();
288 if (hasNextItem || hasNextPage) {
292 indexVal = source.currentItem();
294 indexVal = source.nextItem();
298 panel.scrollToAnchor(source.getAnchorPrefix() + Integer.toString(indexVal));
301 panel.updateCurrentMatchDisplay(source.currentItem());
302 panel.updateTotaMatcheslDisplay(source.getNumberHits());
305 if (!source.hasNextItem() && !source.hasNextPage()) {
306 panel.enableNextMatchControl(
false);
308 if (source.hasPreviousItem() || source.hasPreviousPage()) {
309 panel.enablePrevMatchControl(
true);
319 TextMarkup source = panel.getSelectedSource();
320 final boolean hasPreviousItem = source.hasPreviousItem();
321 final boolean hasPreviousPage = source.hasPreviousPage();
323 if (hasPreviousItem || hasPreviousPage) {
324 if (!hasPreviousItem) {
327 indexVal = source.currentItem();
329 indexVal = source.previousItem();
333 panel.scrollToAnchor(source.getAnchorPrefix() + Integer.toString(indexVal));
336 panel.updateCurrentMatchDisplay(source.currentItem());
337 panel.updateTotaMatcheslDisplay(source.getNumberHits());
340 if (!source.hasPreviousItem() && !source.hasPreviousPage()) {
341 panel.enablePrevMatchControl(
false);
343 if (source.hasNextItem() || source.hasNextPage()) {
344 panel.enableNextMatchControl(
true);
355 currentSource = panel.getSelectedSource();
357 if (currentSource == null) {
362 updatePageControls();
363 updateSearchControls();
369 panel.updateSearchControls(currentSource);
373 panel.updateControls(currentSource);
378 if (currentSource == null) {
379 panel.updateControls(null);
383 if (currentSource.hasNextPage()) {
384 currentSource.nextPage();
387 panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
388 panel.refreshCurrentMarkup();
389 panel.setCursor(null);
392 panel.updateCurrentPageDisplay(currentSource.getCurrentPage());
398 if (!currentSource.hasNextPage()) {
399 panel.enableNextPageControl(
false);
401 if (currentSource.hasPreviousPage()) {
402 panel.enablePrevPageControl(
true);
405 updateSearchControls();
411 if (currentSource == null) {
412 panel.updateControls(null);
416 if (currentSource.hasPreviousPage()) {
417 currentSource.previousPage();
420 panel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
421 panel.refreshCurrentMarkup();
422 panel.setCursor(null);
425 panel.updateCurrentPageDisplay(currentSource.getCurrentPage());
431 if (!currentSource.hasPreviousPage()) {
432 panel.enablePrevPageControl(
false);
434 if (currentSource.hasNextPage()) {
435 panel.enableNextPageControl(
true);
438 updateSearchControls();
444 class NextPageActionListener
implements ActionListener {
447 public void actionPerformed(ActionEvent e) {
static synchronized Server getServer()
boolean queryIsIndexed(long contentID)
public< T > T accept(ContentVisitor< T > v)
static Logger getLogger(String name)