Autopsy  4.7.0
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 
45  public ChangeViewAction(String title, int viewType, Node node) {
46  super(title);
47  this.type = viewType;
48  this.node = node;
49  }
50 
59  @Override
60  public void actionPerformed(ActionEvent e) {
61  DataContentTopComponent dctc = DataContentTopComponent.findInstance();
62  int totalTabs = dctc.getTabPanels().getTabCount();
63 
64  // change the output view to hex view
65  if (type == 1) {
66  // find the hex view top component
67 // TopComponent hexWin = WindowManager.getDefault().findTopComponent("HexViewTopComponent"); // Note: HexViewTopComponent = the preffered ID of that top component
68 // hexWin.requestActive(); // set it to become the active top component
69 
70  for (int i = 0; i < totalTabs; i++) {
71  if (dctc.getTabPanels().getComponentAt(i) instanceof DataContentViewerHex) {
72  dctc.getTabPanels().setSelectedIndex(i);
73  }
74  }
75  }
76  // change the output view to string view
77  if (type == 2) {
78  // find the string view top component
79 // TopComponent stringWin = WindowManager.getDefault().findTopComponent("StringViewTopComponent"); // Note: StringViewTopComponent = the preffered ID of that top component
80 // stringWin.requestActive(); // set it to become the active top component
81 
82  for (int i = 0; i < totalTabs; i++) {
83  if (dctc.getTabPanels().getComponentAt(i) instanceof DataContentViewerString) {
84  dctc.getTabPanels().setSelectedIndex(i);
85  }
86  }
87  }
88  // else do nothing
89  }
90 
96  @Override
97  public JMenuItem getPopupPresenter() {
98  JMenu item = new JMenu(NbBundle.getMessage(this.getClass(), "ChangeViewAction.menuItem.view"));
99  item.add(new ChangeViewAction(NbBundle.getMessage(this.getClass(), "ChangeViewAction.menuItem.view.hex"), 1, node));
100  item.add(new ChangeViewAction(NbBundle.getMessage(this.getClass(), "ChangeViewAction.menuItem.view.string"), 2, node));
101  return item;
102  }
103 }

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