Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
CreateLogicalImagerAction.java
Go to the documentation of this file.
1/*
2 * Autopsy
3 *
4 * Copyright 2019 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 */
19package org.sleuthkit.autopsy.logicalimager.configuration;
20
21import java.awt.Component;
22import java.awt.Dialog;
23import java.io.File;
24import java.nio.file.Path;
25import java.nio.file.Paths;
26import java.text.MessageFormat;
27import java.util.ArrayList;
28import java.util.List;
29import javax.swing.JComponent;
30import org.openide.DialogDisplayer;
31import org.openide.WizardDescriptor;
32import org.openide.awt.ActionID;
33import org.openide.awt.ActionReference;
34import org.openide.awt.ActionRegistration;
35import org.openide.modules.InstalledFileLocator;
36import org.openide.util.HelpCtx;
37import org.openide.util.NbBundle;
38import org.openide.util.NbBundle.Messages;
39import org.openide.util.actions.CallableSystemAction;
40
44@ActionID(category = "Tools", id = "org.sleuthkit.autopsy.logicalimager.configuration.CreateLogicalImagerAction")
45@ActionRegistration(displayName = "#CTL_CreateLogicalImagerAction", lazy = false)
46@ActionReference(path = "Menu/Tools", position = 2000, separatorBefore = 1999)
47@Messages("CTL_CreateLogicalImagerAction=Create Logical Imager")
48public final class CreateLogicalImagerAction extends CallableSystemAction {
49
50 private static final long serialVersionUID = 1L;
51 private static final String LOGICAL_IMAGER_DIR = "tsk_logical_imager"; // NON-NLS
52 private static final String LOGICAL_IMAGER_EXE = "tsk_logical_imager.exe"; // NON-NLS
53 private static final Path LOGICAL_IMAGER_EXE_PATH = Paths.get(LOGICAL_IMAGER_DIR, LOGICAL_IMAGER_EXE);
54
60 static File getLogicalImagerExe() {
61 return InstalledFileLocator.getDefault().locate(LOGICAL_IMAGER_EXE_PATH.toString(), CreateLogicalImagerAction.class.getPackage().getName(), false);
62 }
63
64 @NbBundle.Messages({
65 "CreateLogicalImagerAction.title=Create Logical Imager"
66 })
67 @Override
68 public void performAction() {
69 List<WizardDescriptor.Panel<WizardDescriptor>> panels = new ArrayList<>();
70 panels.add(new ConfigWizardPanel1());
71 panels.add(new ConfigWizardPanel2());
72 panels.add(new ConfigWizardPanel3());
73 String[] steps = new String[panels.size()];
74 for (int i = 0; i < panels.size(); i++) {
75 Component c = panels.get(i).getComponent();
76 // Default step name to component name of panel.
77 steps[i] = c.getName();
78 if (c instanceof JComponent) { // assume Swing components
79 JComponent jc = (JComponent) c;
80 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
81 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
82 jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, true);
83 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, true);
84 jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, true);
85 }
86 }
87 WizardDescriptor wiz = new WizardDescriptor(new WizardDescriptor.ArrayIterator<>(panels));
88 // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
89 wiz.setTitleFormat(new MessageFormat("{0}")); // NON-NLS
90 wiz.setTitle(Bundle.CreateLogicalImagerAction_title());
91 Dialog dialog = DialogDisplayer.getDefault().createDialog(wiz);
92 dialog.setVisible(true);
93 }
94
95 @Override
96 public String getName() {
97 return Bundle.CTL_CreateLogicalImagerAction();
98 }
99
100 @Override
101 public HelpCtx getHelpCtx() {
102 return HelpCtx.DEFAULT_HELP;
103 }
104
105 @Override
106 public boolean isEnabled() {
107 File logicalImagerExe = getLogicalImagerExe();
108 return logicalImagerExe != null && logicalImagerExe.exists();
109 }
110
111}

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.