Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
ChangeViewAction.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2014 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.directorytree;
20 
21 import java.awt.event.ActionEvent;
22 import javax.swing.AbstractAction;
23 import javax.swing.JMenu;
24 import javax.swing.JMenuItem;
25 import org.openide.nodes.Node;
26 import org.openide.util.NbBundle;
27 import org.openide.util.actions.Presenter;
31 
37  class ChangeViewAction extends AbstractAction implements Presenter.Popup {
38 
39  private int type; // type 1 = hex view, 2 = string view
40  private Node node;
41 
43  public ChangeViewAction(String title, int viewType, Node node) {
44  super(title);
45  this.type = viewType;
46  this.node = node;
47  }
48 
57  @Override
58  public void actionPerformed(ActionEvent e) {
60  int totalTabs = dctc.getTabPanels().getTabCount();
61 
62  // change the output view to hex view
63  if (type == 1) {
64  // find the hex view top component
65 // TopComponent hexWin = WindowManager.getDefault().findTopComponent("HexViewTopComponent"); // Note: HexViewTopComponent = the preffered ID of that top component
66 // hexWin.requestActive(); // set it to become the active top component
67 
68  for (int i = 0; i < totalTabs; i++) {
69  if (dctc.getTabPanels().getComponentAt(i) instanceof DataContentViewerHex) {
70  dctc.getTabPanels().setSelectedIndex(i);
71  }
72  }
73  }
74  // change the output view to string view
75  if (type == 2) {
76  // find the string view top component
77 // TopComponent stringWin = WindowManager.getDefault().findTopComponent("StringViewTopComponent"); // Note: StringViewTopComponent = the preffered ID of that top component
78 // stringWin.requestActive(); // set it to become the active top component
79 
80  for (int i = 0; i < totalTabs; i++) {
81  if (dctc.getTabPanels().getComponentAt(i) instanceof DataContentViewerString) {
82  dctc.getTabPanels().setSelectedIndex(i);
83  }
84  }
85  }
86  // else do nothing
87  }
88 
94  @Override
95  public JMenuItem getPopupPresenter() {
96  JMenu item = new JMenu(NbBundle.getMessage(this.getClass(), "ChangeViewAction.menuItem.view"));
97  item.add(new ChangeViewAction(NbBundle.getMessage(this.getClass(), "ChangeViewAction.menuItem.view.hex"), 1, node));
98  item.add(new ChangeViewAction(NbBundle.getMessage(this.getClass(), "ChangeViewAction.menuItem.view.string"), 2, node));
99  return item;
100  }
101 }

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.