Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
DataContentViewerString.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.corecomponents;
20 
21 import java.awt.*;
22 import java.awt.event.ActionEvent;
23 import java.awt.event.ActionListener;
24 import java.util.List;
25 import java.util.logging.Level;
26 
27 import org.openide.util.NbBundle;
29 import javax.swing.JMenuItem;
30 import javax.swing.JOptionPane;
31 import javax.swing.JTextPane;
32 import org.openide.nodes.Node;
33 import org.openide.util.Lookup;
34 import org.openide.util.lookup.ServiceProvider;
42 
46 @ServiceProvider(service = DataContentViewer.class, position = 2)
47 public class DataContentViewerString extends javax.swing.JPanel implements DataContentViewer {
48 
49  private static long currentOffset = 0;
50  private static final long pageLength = 16384;
51  private final byte[] data = new byte[(int) pageLength];
52  private static int currentPage = 1;
54  //string extract utility
55  private final StringExtract stringExtract = new StringExtract();
56  private static final Logger logger = Logger.getLogger(DataContentViewerString.class.getName());
57 
62  initComponents();
63  customizeComponents();
64  this.resetComponent();
65  logger.log(Level.INFO, "Created StringView instance: " + this); //NON-NLS
66  }
67 
68  private void customizeComponents() {
69  outputViewPane.setComponentPopupMenu(rightClickMenu);
70  ActionListener actList = new ActionListener() {
71  @Override
72  public void actionPerformed(ActionEvent e) {
73  JMenuItem jmi = (JMenuItem) e.getSource();
74  if (jmi.equals(copyMenuItem)) {
75  outputViewPane.copy();
76  } else if (jmi.equals(selectAllMenuItem)) {
77  outputViewPane.selectAll();
78  }
79  }
80  };
81  copyMenuItem.addActionListener(actList);
82  selectAllMenuItem.addActionListener(actList);
83 
84  List<SCRIPT> supportedScripts = StringExtract.getSupportedScripts();
85  for (SCRIPT s : supportedScripts) {
86  languageCombo.addItem(s);
87  }
88 
89  }
90 
96  @SuppressWarnings("unchecked")
97  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
98  private void initComponents() {
99 
100  rightClickMenu = new javax.swing.JPopupMenu();
101  copyMenuItem = new javax.swing.JMenuItem();
102  selectAllMenuItem = new javax.swing.JMenuItem();
103  jPanel1 = new javax.swing.JPanel();
104  jScrollPane1 = new javax.swing.JScrollPane();
105  outputViewPane = new JTextPane(){
106  public boolean getScrollableTracksViewportWidth() {
107  return (getSize().width < 400);
108  }};
109  totalPageLabel = new javax.swing.JLabel();
110  ofLabel = new javax.swing.JLabel();
111  currentPageLabel = new javax.swing.JLabel();
112  pageLabel = new javax.swing.JLabel();
113  nextPageButton = new javax.swing.JButton();
114  pageLabel2 = new javax.swing.JLabel();
115  prevPageButton = new javax.swing.JButton();
116  goToPageLabel = new javax.swing.JLabel();
117  goToPageTextField = new javax.swing.JTextField();
118  languageCombo = new javax.swing.JComboBox<>();
119  languageLabel = new javax.swing.JLabel();
120 
121  copyMenuItem.setText(org.openide.util.NbBundle.getMessage(DataContentViewerString.class, "DataContentViewerString.copyMenuItem.text")); // NOI18N
122  rightClickMenu.add(copyMenuItem);
123 
124  selectAllMenuItem.setText(org.openide.util.NbBundle.getMessage(DataContentViewerString.class, "DataContentViewerString.selectAllMenuItem.text")); // NOI18N
125  rightClickMenu.add(selectAllMenuItem);
126 
127  setMinimumSize(new java.awt.Dimension(5, 5));
128 
129  jPanel1.setPreferredSize(new java.awt.Dimension(502, 424));
130 
131  outputViewPane.setEditable(false);
132  outputViewPane.setFont(new Font("monospaced", Font.PLAIN, 11)); // NOI18N NON-NLS
133  outputViewPane.setPreferredSize(new java.awt.Dimension(700, 400));
134  jScrollPane1.setViewportView(outputViewPane);
135 
136  totalPageLabel.setText(org.openide.util.NbBundle.getMessage(DataContentViewerString.class, "DataContentViewerString.totalPageLabel.text_1")); // NOI18N
137 
138  ofLabel.setText(org.openide.util.NbBundle.getMessage(DataContentViewerString.class, "DataContentViewerString.ofLabel.text_1")); // NOI18N
139 
140  currentPageLabel.setText(org.openide.util.NbBundle.getMessage(DataContentViewerString.class, "DataContentViewerString.currentPageLabel.text_1")); // NOI18N
141  currentPageLabel.setMaximumSize(new java.awt.Dimension(18, 14));
142  currentPageLabel.setMinimumSize(new java.awt.Dimension(18, 14));
143  currentPageLabel.setPreferredSize(new java.awt.Dimension(18, 14));
144 
145  pageLabel.setText(org.openide.util.NbBundle.getMessage(DataContentViewerString.class, "DataContentViewerString.pageLabel.text_1")); // NOI18N
146  pageLabel.setMaximumSize(new java.awt.Dimension(33, 14));
147  pageLabel.setMinimumSize(new java.awt.Dimension(33, 14));
148  pageLabel.setPreferredSize(new java.awt.Dimension(33, 14));
149 
150  nextPageButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/corecomponents/btn_step_forward.png"))); // NOI18N NON-NLS
151  nextPageButton.setText(org.openide.util.NbBundle.getMessage(DataContentViewerString.class, "DataContentViewerString.nextPageButton.text")); // NOI18N
152  nextPageButton.setBorderPainted(false);
153  nextPageButton.setContentAreaFilled(false);
154  nextPageButton.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/corecomponents/btn_step_forward_disabled.png"))); // NOI18N NON-NLS
155  nextPageButton.setMargin(new java.awt.Insets(2, 0, 2, 0));
156  nextPageButton.setPreferredSize(new java.awt.Dimension(55, 23));
157  nextPageButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/corecomponents/btn_step_forward_hover.png"))); // NOI18N NON-NLS
158  nextPageButton.addActionListener(new java.awt.event.ActionListener() {
159  public void actionPerformed(java.awt.event.ActionEvent evt) {
160  nextPageButtonActionPerformed(evt);
161  }
162  });
163 
164  pageLabel2.setText(org.openide.util.NbBundle.getMessage(DataContentViewerString.class, "DataContentViewerString.pageLabel2.text")); // NOI18N
165  pageLabel2.setMaximumSize(new java.awt.Dimension(29, 14));
166  pageLabel2.setMinimumSize(new java.awt.Dimension(29, 14));
167  pageLabel2.setPreferredSize(new java.awt.Dimension(29, 14));
168 
169  prevPageButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/corecomponents/btn_step_back.png"))); // NOI18N NON-NLS
170  prevPageButton.setText(org.openide.util.NbBundle.getMessage(DataContentViewerString.class, "DataContentViewerString.prevPageButton.text")); // NOI18N
171  prevPageButton.setBorderPainted(false);
172  prevPageButton.setContentAreaFilled(false);
173  prevPageButton.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/corecomponents/btn_step_back_disabled.png"))); // NOI18N NON-NLS
174  prevPageButton.setMargin(new java.awt.Insets(2, 0, 2, 0));
175  prevPageButton.setPreferredSize(new java.awt.Dimension(55, 23));
176  prevPageButton.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/corecomponents/btn_step_back_hover.png"))); // NOI18N NON-NLS
177  prevPageButton.addActionListener(new java.awt.event.ActionListener() {
178  public void actionPerformed(java.awt.event.ActionEvent evt) {
179  prevPageButtonActionPerformed(evt);
180  }
181  });
182 
183  goToPageLabel.setText(org.openide.util.NbBundle.getMessage(DataContentViewerString.class, "DataContentViewerString.goToPageLabel.text")); // NOI18N
184 
185  goToPageTextField.setText(org.openide.util.NbBundle.getMessage(DataContentViewerString.class, "DataContentViewerString.goToPageTextField.text")); // NOI18N
186  goToPageTextField.addActionListener(new java.awt.event.ActionListener() {
187  public void actionPerformed(java.awt.event.ActionEvent evt) {
188  goToPageTextFieldActionPerformed(evt);
189  }
190  });
191 
192  languageCombo.setToolTipText(org.openide.util.NbBundle.getMessage(DataContentViewerString.class, "DataContentViewerString.languageCombo.toolTipText")); // NOI18N
193  languageCombo.addActionListener(new java.awt.event.ActionListener() {
194  public void actionPerformed(java.awt.event.ActionEvent evt) {
195  languageComboActionPerformed(evt);
196  }
197  });
198 
199  languageLabel.setText(org.openide.util.NbBundle.getMessage(DataContentViewerString.class, "DataContentViewerString.languageLabel.text")); // NOI18N
200  languageLabel.setToolTipText(org.openide.util.NbBundle.getMessage(DataContentViewerString.class, "DataContentViewerString.languageLabel.toolTipText")); // NOI18N
201 
202  javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
203  jPanel1.setLayout(jPanel1Layout);
204  jPanel1Layout.setHorizontalGroup(
205  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
206  .addGroup(jPanel1Layout.createSequentialGroup()
207  .addContainerGap()
208  .addComponent(pageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
209  .addGap(18, 18, 18)
210  .addComponent(currentPageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
211  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
212  .addComponent(ofLabel)
213  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
214  .addComponent(totalPageLabel)
215  .addGap(50, 50, 50)
216  .addComponent(pageLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
217  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
218  .addComponent(prevPageButton, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
219  .addGap(0, 0, 0)
220  .addComponent(nextPageButton, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
221  .addGap(18, 18, 18)
222  .addComponent(goToPageLabel)
223  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
224  .addComponent(goToPageTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
225  .addGap(33, 33, 33)
226  .addComponent(languageLabel)
227  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
228  .addComponent(languageCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE))
229  .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
230  );
231  jPanel1Layout.setVerticalGroup(
232  jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
233  .addGroup(jPanel1Layout.createSequentialGroup()
234  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
235  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
236  .addComponent(pageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
237  .addComponent(currentPageLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
238  .addComponent(ofLabel)
239  .addComponent(totalPageLabel))
240  .addComponent(pageLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
241  .addComponent(nextPageButton, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
242  .addComponent(prevPageButton, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
243  .addComponent(goToPageLabel)
244  .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
245  .addComponent(goToPageTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
246  .addComponent(languageCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
247  .addComponent(languageLabel)))
248  .addGap(0, 0, 0)
249  .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 401, Short.MAX_VALUE))
250  );
251 
252  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
253  this.setLayout(layout);
254  layout.setHorizontalGroup(
255  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
256  .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 640, Short.MAX_VALUE)
257  );
258  layout.setVerticalGroup(
259  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
260  .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
261  );
262  }// </editor-fold>//GEN-END:initComponents
263 
264  private void prevPageButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_prevPageButtonActionPerformed
265  //@@@ this is part of the code dealing with the data viewer. could be copied/removed to implement the scrollbar
266  currentOffset -= pageLength;
267  currentPage = currentPage - 1;
268  currentPageLabel.setText(Integer.toString(currentPage));
269  setDataView(dataSource, currentOffset);
270  }//GEN-LAST:event_prevPageButtonActionPerformed
271 
272  private void nextPageButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nextPageButtonActionPerformed
273  //@@@ this is part of the code dealing with the data viewer. could be copied/removed to implement the scrollbar
274  currentOffset += pageLength;
275  currentPage = currentPage + 1;
276  currentPageLabel.setText(Integer.toString(currentPage));
277  setDataView(dataSource, currentOffset);
278  }//GEN-LAST:event_nextPageButtonActionPerformed
279 
280  private void goToPageTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_goToPageTextFieldActionPerformed
281  String pageNumberStr = goToPageTextField.getText();
282  int pageNumber;
283  int maxPage = Math.round((dataSource.getSize() - 1) / pageLength) + 1;
284  try {
285  pageNumber = Integer.parseInt(pageNumberStr);
286  } catch (NumberFormatException ex) {
287  pageNumber = maxPage + 1;
288  }
289  if (pageNumber > maxPage || pageNumber < 1) {
290  JOptionPane.showMessageDialog(this,
291  NbBundle.getMessage(this.getClass(),
292  "DataContentViewerString.goToPageTextField.msgDlg",
293  maxPage),
294  NbBundle.getMessage(this.getClass(),
295  "DataContentViewerString.goToPageTextField.err"),
296  JOptionPane.WARNING_MESSAGE);
297  return;
298  }
299  currentOffset = (pageNumber - 1) * pageLength;
300  currentPage = pageNumber;
301  currentPageLabel.setText(Integer.toString(currentPage));
302  setDataView(dataSource, currentOffset);
303  }//GEN-LAST:event_goToPageTextFieldActionPerformed
304 
305  private void languageComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_languageComboActionPerformed
306 
307  if (dataSource != null) {
308  setDataView(dataSource, currentOffset);
309  }
310  }//GEN-LAST:event_languageComboActionPerformed
311  // Variables declaration - do not modify//GEN-BEGIN:variables
312  private javax.swing.JMenuItem copyMenuItem;
313  private javax.swing.JLabel currentPageLabel;
314  private javax.swing.JLabel goToPageLabel;
315  private javax.swing.JTextField goToPageTextField;
316  private javax.swing.JPanel jPanel1;
317  private javax.swing.JScrollPane jScrollPane1;
318  private javax.swing.JComboBox<SCRIPT> languageCombo;
319  private javax.swing.JLabel languageLabel;
320  private javax.swing.JButton nextPageButton;
321  private javax.swing.JLabel ofLabel;
322  private javax.swing.JTextPane outputViewPane;
323  private javax.swing.JLabel pageLabel;
324  private javax.swing.JLabel pageLabel2;
325  private javax.swing.JButton prevPageButton;
326  private javax.swing.JPopupMenu rightClickMenu;
327  private javax.swing.JMenuItem selectAllMenuItem;
328  private javax.swing.JLabel totalPageLabel;
329  // End of variables declaration//GEN-END:variables
330 
337  private void setDataView(Content dataSource, long offset) {
338  if (dataSource == null) {
339  return;
340  }
341 
342  // change the cursor to "waiting cursor" for this operation
343  this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
344 
345  this.dataSource = dataSource;
346 
347  int bytesRead = 0;
348  // set the data on the bottom and show it
349  String text = "";
350  if (dataSource.getSize() > 0) {
351  try {
352  bytesRead = dataSource.read(data, offset, pageLength); // read the data
353  } catch (TskException ex) {
354  text = NbBundle.getMessage(this.getClass(),
355  "DataContentViewerString.setDataView.errorText", currentOffset,
356  currentOffset + pageLength);
357  logger.log(Level.WARNING, "Error while trying to show the String content.", ex); //NON-NLS
358  }
359  }
360 
361  if (bytesRead > 0) {
362  //text = DataConversion.getString(data, bytesRead, 4);
363  final SCRIPT selScript = (SCRIPT) languageCombo.getSelectedItem();
364  stringExtract.setEnabledScript(selScript);
365  StringExtractResult res = stringExtract.extract(data, bytesRead, 0);
366  text = res.getText();
367  if (text.trim().isEmpty()) {
368  text = NbBundle.getMessage(this.getClass(),
369  "DataContentViewerString.setDataView.errorNoText", currentOffset,
370  currentOffset + pageLength);
371  }
372  } else {
373  text = NbBundle.getMessage(this.getClass(), "DataContentViewerString.setDataView.errorText", currentOffset,
374  currentOffset + pageLength);
375  }
376 
377  // disable or enable the next button
378  if (offset + pageLength < dataSource.getSize()) {
379  nextPageButton.setEnabled(true);
380  } else {
381  nextPageButton.setEnabled(false);
382  }
383 
384  if (offset == 0) {
385  prevPageButton.setEnabled(false);
386  currentPage = 1; // reset the page number
387  } else {
388  prevPageButton.setEnabled(true);
389  }
390 
391  int totalPage = Math.round((dataSource.getSize() - 1) / pageLength) + 1;
392  totalPageLabel.setText(Integer.toString(totalPage));
393  currentPageLabel.setText(Integer.toString(currentPage));
394  outputViewPane.setText(text); // set the output view
395  setComponentsVisibility(true); // shows the components that not needed
396  outputViewPane.moveCaretPosition(0);
397 
398  this.setCursor(null);
399  }
400 
401  private void setDataView(StringContent dataSource) {
402  this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
403  try {
404  this.dataSource = null;
405 
406  // set the data on the bottom and show it
407  String text = dataSource.getString();
408 
409  nextPageButton.setEnabled(false);
410 
411  prevPageButton.setEnabled(false);
412  currentPage = 1;
413 
414  int totalPage = 1;
415  totalPageLabel.setText(Integer.toString(totalPage));
416  currentPageLabel.setText(Integer.toString(currentPage));
417  outputViewPane.setText(text); // set the output view
418  setComponentsVisibility(true); // shows the components that not needed
419  outputViewPane.moveCaretPosition(0);
420  } finally {
421  this.setCursor(null);
422  }
423  }
424 
430  private void setComponentsVisibility(boolean isVisible) {
431  currentPageLabel.setVisible(isVisible);
432  totalPageLabel.setVisible(isVisible);
433  ofLabel.setVisible(isVisible);
434  prevPageButton.setVisible(isVisible);
435  nextPageButton.setVisible(isVisible);
436  pageLabel.setVisible(isVisible);
437  pageLabel2.setVisible(isVisible);
438  goToPageTextField.setVisible(isVisible);
439  goToPageLabel.setVisible(isVisible);
440  languageCombo.setVisible(isVisible);
441  languageLabel.setVisible(isVisible);
442  }
443 
444  @Override
445  public void setNode(Node selectedNode) {
446  if ((selectedNode == null) || (!isSupported(selectedNode))) {
447  resetComponent();
448  return;
449  }
450 
451  Lookup lookup = selectedNode.getLookup();
452  Content content = lookup.lookup(Content.class);
453  if (content != null) {
454  this.setDataView(content, 0);
455  return;
456  } else {
457  StringContent scontent = selectedNode.getLookup().lookup(StringContent.class);
458  if (scontent != null) {
459  this.setDataView(scontent);
460  return;
461  }
462  }
463  resetComponent();
464  }
465 
466  @Override
467  public String getTitle() {
468  return NbBundle.getMessage(this.getClass(), "DataContentViewerString.title");
469  }
470 
471  @Override
472  public String getToolTip() {
473  return NbBundle.getMessage(this.getClass(), "DataContentViewerString.toolTip");
474  }
475 
476  @Override
477  public DataContentViewer createInstance() {
478  return new DataContentViewerString();
479  }
480 
481  @Override
482  public void resetComponent() {
483  // clear / reset the fields
484  currentPage = 1;
485  currentOffset = 0;
486  this.dataSource = null;
487  currentPageLabel.setText("");
488  totalPageLabel.setText("");
489  prevPageButton.setEnabled(false);
490  nextPageButton.setEnabled(false);
491  outputViewPane.setText(""); // reset the output view
492  setComponentsVisibility(false); // hides the components that not needed
493  }
494 
495  @Override
496  public boolean isSupported(Node node) {
497  if (node == null) {
498  return false;
499  }
500  Content content = node.getLookup().lookup(Content.class);
501  if (content != null && content.getSize() > 0) {
502  return true;
503  }
504 
505  return false;
506  }
507 
508  @Override
509  public int isPreferred(Node node) {
510  return 1;
511  }
512 
513  @Override
514  public Component getComponent() {
515  return this;
516  }
517 
518 
519  /*
520  * Show the right click menu only if evt is the correct mouse event
521  */
522  private void maybeShowPopup(java.awt.event.MouseEvent evt) {
523  if (evt.isPopupTrigger()) {
524  rightClickMenu.setLocation(evt.getLocationOnScreen());
525  rightClickMenu.setVisible(true);
526  copyMenuItem.setEnabled(outputViewPane.getSelectedText() != null);
527  } else {
528  rightClickMenu.setVisible(false);
529  }
530  }
531 }
StringExtractResult extract(byte[] buff, int len, int offset)
int read(byte[] buf, long offset, long len)
synchronized static Logger getLogger(String name)
Definition: Logger.java:161

Copyright © 2012-2016 Basis Technology. Generated on: Mon Apr 24 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.