19 package org.sleuthkit.autopsy.keywordsearch;
21 import java.awt.ComponentOrientation;
22 import java.awt.EventQueue;
23 import java.awt.event.ActionEvent;
24 import java.awt.event.ActionListener;
25 import java.awt.event.ItemEvent;
26 import java.awt.event.ItemListener;
27 import java.util.ArrayList;
28 import java.util.List;
29 import java.util.concurrent.ExecutionException;
30 import java.util.logging.Level;
32 import org.openide.util.NbBundle;
34 import javax.swing.JMenuItem;
35 import javax.swing.JTextPane;
36 import javax.swing.SizeRequirements;
37 import javax.swing.SwingWorker;
38 import javax.swing.text.Element;
39 import javax.swing.text.View;
40 import javax.swing.text.ViewFactory;
41 import javax.swing.text.html.InlineView;
42 import javax.swing.text.html.ParagraphView;
43 import javax.swing.text.html.HTMLEditorKit;
44 import javax.swing.text.html.HTMLEditorKit.HTMLFactory;
45 import javax.swing.text.html.StyleSheet;
46 import org.netbeans.api.progress.ProgressHandle;
47 import org.netbeans.api.progress.ProgressHandleFactory;
55 class ExtractedContentPanel
extends javax.swing.JPanel {
57 private static Logger logger = Logger.getLogger(ExtractedContentPanel.class.getName());
59 ExtractedContentPanel() {
64 customizeComponents();
68 private void customizeComponents() {
70 HTMLEditorKit editorKit =
new HTMLEditorKit() {
72 public ViewFactory getViewFactory() {
74 return new HTMLFactory() {
76 public View create(Element e) {
77 View v = super.create(e);
78 if (v instanceof InlineView) {
79 return new InlineView(e) {
81 public int getBreakWeight(
int axis,
float pos,
float len) {
82 return GoodBreakWeight;
86 public View breakView(
int axis,
int p0,
float pos,
float len) {
87 if (axis == View.X_AXIS) {
89 int p1 = getGlyphPainter().getBoundedPosition(
this, p0, pos, len);
90 if (p0 == getStartOffset() && p1 == getEndOffset()) {
93 return createFragment(p0, p1);
98 }
else if (v instanceof ParagraphView) {
99 return new ParagraphView(e) {
101 protected SizeRequirements calculateMinorAxisRequirements(
int axis, SizeRequirements r) {
103 r =
new SizeRequirements();
105 float pref = layoutPool.getPreferredSpan(axis);
106 float min = layoutPool.getMinimumSpan(axis);
108 r.minimum = (int) min;
109 r.preferred = Math.max(r.minimum, (
int) pref);
110 r.maximum = Integer.MAX_VALUE;
124 StyleSheet ss = editorKit.getStyleSheet();
125 ss.addRule(
"body {font-size: 8.5px;}");
127 extractedTextPane.setEditorKit(editorKit);
129 sourceComboBox.addItemListener(
new ItemListener() {
131 public void itemStateChanged(ItemEvent e) {
132 if (e.getStateChange() == ItemEvent.SELECTED) {
133 IndexedText source = (IndexedText) e.getItem();
139 setSources(
new ArrayList<IndexedText>());
141 extractedTextPane.setComponentPopupMenu(rightClickMenu);
142 ActionListener actList =
new ActionListener() {
144 public void actionPerformed(ActionEvent e) {
145 JMenuItem jmi = (JMenuItem) e.getSource();
146 if (jmi.equals(copyMenuItem)) {
147 extractedTextPane.copy();
148 }
else if (jmi.equals(selectAllMenuItem)) {
149 extractedTextPane.selectAll();
153 copyMenuItem.addActionListener(actList);
154 selectAllMenuItem.addActionListener(actList);
162 @SuppressWarnings(
"unchecked")
164 private
void initComponents() {
166 rightClickMenu =
new javax.swing.JPopupMenu();
167 copyMenuItem =
new javax.swing.JMenuItem();
168 selectAllMenuItem =
new javax.swing.JMenuItem();
169 jScrollPane1 =
new javax.swing.JScrollPane();
170 extractedTextPane =
new JTextPane(){
171 public boolean getScrollableTracksViewportWidth() {
172 return (getSize().width < 400);
174 sourceComboBox =
new javax.swing.JComboBox<>();
175 hitLabel =
new javax.swing.JLabel();
176 hitCountLabel =
new javax.swing.JLabel();
177 hitOfLabel =
new javax.swing.JLabel();
178 hitTotalLabel =
new javax.swing.JLabel();
179 hitButtonsLabel =
new javax.swing.JLabel();
180 hitPreviousButton =
new javax.swing.JButton();
181 hitNextButton =
new javax.swing.JButton();
182 pageButtonsLabel =
new javax.swing.JLabel();
183 pagePreviousButton =
new javax.swing.JButton();
184 pageNextButton =
new javax.swing.JButton();
185 pagesLabel =
new javax.swing.JLabel();
186 pageCurLabel =
new javax.swing.JLabel();
187 pageOfLabel =
new javax.swing.JLabel();
188 pageTotalLabel =
new javax.swing.JLabel();
190 copyMenuItem.setText(
org.openide.util.NbBundle.getMessage(ExtractedContentPanel.class,
"ExtractedContentPanel.copyMenuItem.text"));
191 rightClickMenu.add(copyMenuItem);
193 selectAllMenuItem.setText(
org.openide.util.NbBundle.getMessage(ExtractedContentPanel.class,
"ExtractedContentPanel.selectAllMenuItem.text"));
194 rightClickMenu.add(selectAllMenuItem);
196 setPreferredSize(
new java.awt.Dimension(700, 400));
198 jScrollPane1.setBackground(
new java.awt.Color(255, 255, 255));
199 jScrollPane1.setPreferredSize(
new java.awt.Dimension(700, 400));
201 extractedTextPane.setEditable(
false);
202 extractedTextPane.setAutoscrolls(
false);
203 extractedTextPane.setMaximumSize(
new java.awt.Dimension(2000, 2000));
204 extractedTextPane.setPreferredSize(
new java.awt.Dimension(700, 400));
205 jScrollPane1.setViewportView(extractedTextPane);
207 sourceComboBox.setModel(
new javax.swing.DefaultComboBoxModel<IndexedText>());
209 hitLabel.setText(
org.openide.util.NbBundle.getMessage(ExtractedContentPanel.class,
"ExtractedContentPanel.hitLabel.text"));
210 hitLabel.setToolTipText(
org.openide.util.NbBundle.getMessage(ExtractedContentPanel.class,
"ExtractedContentPanel.hitLabel.toolTipText"));
212 hitCountLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
213 hitCountLabel.setText(
org.openide.util.NbBundle.getMessage(ExtractedContentPanel.class,
"ExtractedContentPanel.hitCountLabel.text"));
214 hitCountLabel.setMaximumSize(
new java.awt.Dimension(18, 14));
215 hitCountLabel.setMinimumSize(
new java.awt.Dimension(18, 14));
216 hitCountLabel.setPreferredSize(
new java.awt.Dimension(18, 14));
218 hitOfLabel.setText(
org.openide.util.NbBundle.getMessage(ExtractedContentPanel.class,
"ExtractedContentPanel.hitOfLabel.text"));
220 hitTotalLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
221 hitTotalLabel.setText(
org.openide.util.NbBundle.getMessage(ExtractedContentPanel.class,
"ExtractedContentPanel.hitTotalLabel.text"));
222 hitTotalLabel.setMaximumSize(
new java.awt.Dimension(18, 14));
223 hitTotalLabel.setMinimumSize(
new java.awt.Dimension(18, 14));
224 hitTotalLabel.setPreferredSize(
new java.awt.Dimension(18, 14));
226 hitButtonsLabel.setText(
org.openide.util.NbBundle.getMessage(ExtractedContentPanel.class,
"ExtractedContentPanel.hitButtonsLabel.text"));
228 hitPreviousButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/btn_step_back.png")));
229 hitPreviousButton.setText(
org.openide.util.NbBundle.getMessage(ExtractedContentPanel.class,
"ExtractedContentPanel.hitPreviousButton.text"));
230 hitPreviousButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
231 hitPreviousButton.setBorderPainted(
false);
232 hitPreviousButton.setContentAreaFilled(
false);
233 hitPreviousButton.setDisabledIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/btn_step_back_disabled.png")));
234 hitPreviousButton.setMargin(
new java.awt.Insets(2, 0, 2, 0));
235 hitPreviousButton.setPreferredSize(
new java.awt.Dimension(23, 23));
236 hitPreviousButton.setRolloverIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/btn_step_back_hover.png")));
238 hitNextButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/btn_step_forward.png")));
239 hitNextButton.setText(
org.openide.util.NbBundle.getMessage(ExtractedContentPanel.class,
"ExtractedContentPanel.hitNextButton.text"));
240 hitNextButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
241 hitNextButton.setBorderPainted(
false);
242 hitNextButton.setContentAreaFilled(
false);
243 hitNextButton.setDisabledIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/btn_step_forward_disabled.png")));
244 hitNextButton.setMargin(
new java.awt.Insets(2, 0, 2, 0));
245 hitNextButton.setPreferredSize(
new java.awt.Dimension(23, 23));
246 hitNextButton.setRolloverIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/btn_step_forward_hover.png")));
248 pageButtonsLabel.setText(
org.openide.util.NbBundle.getMessage(ExtractedContentPanel.class,
"ExtractedContentPanel.pageButtonsLabel.text"));
250 pagePreviousButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/btn_step_back.png")));
251 pagePreviousButton.setText(
org.openide.util.NbBundle.getMessage(ExtractedContentPanel.class,
"ExtractedContentPanel.pagePreviousButton.text"));
252 pagePreviousButton.setActionCommand(
org.openide.util.NbBundle.getMessage(ExtractedContentPanel.class,
"ExtractedContentPanel.pagePreviousButton.actionCommand"));
253 pagePreviousButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
254 pagePreviousButton.setBorderPainted(
false);
255 pagePreviousButton.setContentAreaFilled(
false);
256 pagePreviousButton.setDisabledIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/btn_step_back_disabled.png")));
257 pagePreviousButton.setMargin(
new java.awt.Insets(2, 0, 2, 0));
259 pageNextButton.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/btn_step_forward.png")));
260 pageNextButton.setText(
org.openide.util.NbBundle.getMessage(ExtractedContentPanel.class,
"ExtractedContentPanel.pageNextButton.text"));
261 pageNextButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
262 pageNextButton.setBorderPainted(
false);
263 pageNextButton.setContentAreaFilled(
false);
264 pageNextButton.setDisabledIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/keywordsearch/btn_step_forward_disabled.png")));
265 pageNextButton.setMargin(
new java.awt.Insets(2, 0, 2, 0));
266 pageNextButton.setPreferredSize(
new java.awt.Dimension(23, 23));
268 pagesLabel.setText(
org.openide.util.NbBundle.getMessage(ExtractedContentPanel.class,
"ExtractedContentPanel.pagesLabel.text"));
270 pageCurLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
271 pageCurLabel.setText(
org.openide.util.NbBundle.getMessage(ExtractedContentPanel.class,
"ExtractedContentPanel.pageCurLabel.text"));
273 pageOfLabel.setText(
org.openide.util.NbBundle.getMessage(ExtractedContentPanel.class,
"ExtractedContentPanel.pageOfLabel.text"));
275 pageTotalLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
276 pageTotalLabel.setText(
org.openide.util.NbBundle.getMessage(ExtractedContentPanel.class,
"ExtractedContentPanel.pageTotalLabel.text"));
278 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
279 this.setLayout(layout);
280 layout.setHorizontalGroup(
281 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
282 .addGroup(layout.createSequentialGroup()
284 .addComponent(hitLabel)
285 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
286 .addComponent(hitCountLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
287 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
288 .addComponent(hitOfLabel)
289 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
290 .addComponent(hitTotalLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
291 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
292 .addComponent(hitButtonsLabel)
293 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
294 .addComponent(hitPreviousButton, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
296 .addComponent(hitNextButton, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
297 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
298 .addComponent(pagesLabel)
299 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
300 .addComponent(pageCurLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
301 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
302 .addComponent(pageOfLabel)
303 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
304 .addComponent(pageTotalLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
306 .addComponent(pageButtonsLabel)
307 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
308 .addComponent(pagePreviousButton)
310 .addComponent(pageNextButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
311 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
312 .addComponent(sourceComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
313 .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
315 layout.setVerticalGroup(
316 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
317 .addGroup(layout.createSequentialGroup()
318 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
319 .addComponent(sourceComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
320 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
321 .addComponent(hitCountLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
322 .addComponent(hitOfLabel)
323 .addComponent(hitTotalLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
324 .addComponent(hitLabel)
325 .addComponent(hitButtonsLabel))
326 .addComponent(hitPreviousButton, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
327 .addComponent(hitNextButton, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
328 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
329 .addComponent(pageButtonsLabel)
330 .addComponent(pageTotalLabel)
331 .addComponent(pagesLabel)
332 .addComponent(pageCurLabel)
333 .addComponent(pageOfLabel))
334 .addComponent(pageNextButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
335 .addComponent(pagePreviousButton, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
337 .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 377, Short.MAX_VALUE))
341 private javax.swing.JMenuItem copyMenuItem;
342 private javax.swing.JTextPane extractedTextPane;
343 private javax.swing.JLabel hitButtonsLabel;
344 private javax.swing.JLabel hitCountLabel;
345 private javax.swing.JLabel hitLabel;
346 private javax.swing.JButton hitNextButton;
347 private javax.swing.JLabel hitOfLabel;
348 private javax.swing.JButton hitPreviousButton;
349 private javax.swing.JLabel hitTotalLabel;
350 private javax.swing.JScrollPane jScrollPane1;
351 private javax.swing.JLabel pageButtonsLabel;
352 private javax.swing.JLabel pageCurLabel;
353 private javax.swing.JButton pageNextButton;
354 private javax.swing.JLabel pageOfLabel;
355 private javax.swing.JButton pagePreviousButton;
356 private javax.swing.JLabel pageTotalLabel;
357 private javax.swing.JLabel pagesLabel;
358 private javax.swing.JPopupMenu rightClickMenu;
359 private javax.swing.JMenuItem selectAllMenuItem;
360 private javax.swing.JComboBox<IndexedText> sourceComboBox;
363 void refreshCurrentMarkup() {
364 IndexedText ms = (IndexedText) sourceComboBox.getSelectedItem();
374 void setSources(List<IndexedText> sources) {
375 sourceComboBox.removeAllItems();
376 setPanelText(null,
false);
378 for (IndexedText ms : sources) {
379 sourceComboBox.addItem(ms);
382 if (!sources.isEmpty()) {
383 sourceComboBox.setSelectedIndex(0);
393 public List<IndexedText> getSources() {
394 ArrayList<IndexedText> sources =
new ArrayList<>();
395 for (
int i = 0; i < sourceComboBox.getItemCount(); ++i) {
396 sources.add(sourceComboBox.getItemAt(i));
406 public IndexedText getSelectedSource() {
407 return (IndexedText) sourceComboBox.getSelectedItem();
410 private void setPanelText(String text,
boolean detectDirection) {
415 if (detectDirection) {
418 final int len = text.length();
419 final int prefixLen =
"<pre>".length();
420 if (len > prefixLen) {
421 final int maxOrientChars = Math.min(len, 1024);
422 final String orientDetectText = EscapeUtil.unEscapeHtml(text.substring(prefixLen, maxOrientChars));
423 ComponentOrientation direction = TextUtil.getTextDirection(orientDetectText);
425 extractedTextPane.applyComponentOrientation(direction);
427 extractedTextPane.applyComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
430 extractedTextPane.applyComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
433 extractedTextPane.setText(text);
434 extractedTextPane.setCaretPosition(0);
437 private void initControls() {
438 hitPreviousButton.setEnabled(
false);
439 hitNextButton.setEnabled(
false);
442 void scrollToAnchor(String anchor) {
443 extractedTextPane.scrollToReference(anchor);
450 void updateCurrentMatchDisplay(
int current) {
452 hitCountLabel.setText(
"-");
454 hitCountLabel.setText(Integer.toString(current));
462 void updateTotaMatcheslDisplay(
int total) {
464 hitTotalLabel.setText(
"-");
466 hitTotalLabel.setText(Integer.toString(total));
474 void updateCurrentPageDisplay(
int current) {
475 pageCurLabel.setText(Integer.toString(current));
482 void updateTotalPageslDisplay(
int total) {
483 pageTotalLabel.setText(Integer.toString(total));
486 void resetDisplay() {
494 void resetHitDisplay() {
495 hitTotalLabel.setText(
"-");
496 hitCountLabel.setText(
"-");
502 void resetPagesDisplay() {
503 pageCurLabel.setText(
"-");
504 pageTotalLabel.setText(
"-");
512 void enablePrevMatchControl(
boolean enable) {
513 hitPreviousButton.setEnabled(enable);
521 void enableNextMatchControl(
boolean enable) {
522 hitNextButton.setEnabled(enable);
525 void addPrevMatchControlListener(ActionListener l) {
526 hitPreviousButton.addActionListener(l);
529 void addNextMatchControlListener(ActionListener l) {
530 hitNextButton.addActionListener(l);
538 void enablePrevPageControl(
boolean enable) {
539 pagePreviousButton.setEnabled(enable);
547 void enableNextPageControl(
boolean enable) {
548 pageNextButton.setEnabled(enable);
551 void addPrevPageControlListener(ActionListener l) {
552 pagePreviousButton.addActionListener(l);
555 void addNextPageControlListener(ActionListener l) {
556 pageNextButton.addActionListener(l);
559 void addSourceComboControlListener(ActionListener l) {
560 sourceComboBox.addActionListener(l);
568 void updateControls(IndexedText source) {
569 updatePageControls(source);
570 updateSearchControls(source);
578 void updatePageControls(IndexedText source) {
579 if (source == null) {
580 enableNextPageControl(
false);
581 enablePrevPageControl(
false);
582 updateCurrentPageDisplay(0);
583 updateTotalPageslDisplay(0);
587 updateCurrentPageDisplay(source.getCurrentPage());
588 int totalPages = source.getNumberPages();
589 updateTotalPageslDisplay(totalPages);
591 if (totalPages == 1) {
592 enableNextPageControl(
false);
593 enablePrevPageControl(
false);
595 if (source.hasNextPage()) {
596 enableNextPageControl(
true);
598 enableNextPageControl(
false);
601 if (source.hasPreviousPage()) {
602 enablePrevPageControl(
true);
604 enablePrevPageControl(
false);
615 void updateSearchControls(IndexedText source) {
617 if (source != null && source.isSearchable()) {
619 updateCurrentMatchDisplay(source.currentItem());
620 updateTotaMatcheslDisplay(source.getNumberHits());
622 if (source.hasNextItem() || source.hasNextPage()) {
623 enableNextMatchControl(
true);
625 enableNextMatchControl(
false);
628 if (source.hasPreviousItem() || source.hasPreviousPage()) {
629 enablePrevMatchControl(
true);
631 enablePrevMatchControl(
false);
635 enableNextMatchControl(
false);
636 enablePrevMatchControl(
false);
637 updateCurrentMatchDisplay(0);
638 updateTotaMatcheslDisplay(0);
647 private void scrollToCurrentHit(
final IndexedText source) {
648 if (source == null || !source.isSearchable()) {
653 EventQueue.invokeLater(
new Runnable() {
656 scrollToAnchor(source.getAnchorPrefix() + Integer.toString(source.currentItem()));
667 private void setMarkup(IndexedText source) {
668 setPanelText(NbBundle.getMessage(
this.getClass(),
"ExtractedContentPanel.setMarkup.panelTxt"),
false);
669 new SetMarkupWorker(source).execute();
689 progress = ProgressHandleFactory.createHandle(
690 NbBundle.getMessage(
this.getClass(),
"ExtractedContentPanel.SetMarkup.progress.loading"));
691 progress.setDisplayName(
692 NbBundle.getMessage(
this.getClass(),
"ExtractedContentPanel.SetMarkup.progress.displayName"));
694 progress.switchToIndeterminate();
696 markup = source.getText();
709 }
catch (InterruptedException | ExecutionException ex) {
710 logger.log(Level.SEVERE,
"Error getting marked up text");
712 catch (java.util.concurrent.CancellationException ex) {
715 if (markup != null) {
716 setPanelText(markup,
true);
718 setPanelText(
"",
false);
720 updateControls(source);
722 scrollToCurrentHit(source);