Merge Installers in Core module using an Installer wrapper.

Check in missing file.
This commit is contained in:
adam-m 2012-09-25 18:41:05 -04:00
parent 779613bde2
commit 63e65d768a
6 changed files with 210 additions and 1 deletions

View File

@ -5,5 +5,5 @@ OpenIDE-Module-Layer: org/sleuthkit/autopsy/core/layer.xml
OpenIDE-Module-Implementation-Version: 1
OpenIDE-Module-Requires: org.openide.windows.WindowManager, org.netbeans.api.javahelp.Help
AutoUpdate-Show-In-Client: true
OpenIDE-Module-Install: org/sleuthkit/autopsy/corecomponents/Installer.class
OpenIDE-Module-Install: org/sleuthkit/autopsy/core/Installer.class

View File

@ -0,0 +1,106 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.core;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.openide.modules.ModuleInstall;
/**
* Wrapper over Installers in packages in Core module This is the main
* registered installer in the MANIFEST.MF
*/
public class Installer extends ModuleInstall {
private List<ModuleInstall> packageInstallers;
private static final Logger logger = Logger.getLogger(Installer.class.getName());
public Installer() {
packageInstallers = new ArrayList<ModuleInstall>();
packageInstallers.add(new org.sleuthkit.autopsy.coreutils.Installer());
packageInstallers.add(new org.sleuthkit.autopsy.corecomponents.Installer());
packageInstallers.add(new org.sleuthkit.autopsy.datamodel.Installer());
packageInstallers.add(new org.sleuthkit.autopsy.ingest.Installer());
}
@Override
public void restored() {
super.restored();
logger.log(Level.INFO, "restored()");
for (ModuleInstall mi : packageInstallers) {
logger.log(Level.INFO, mi.getClass().getName() + " restored()");
try {
mi.restored();
} catch (Exception e) {
logger.log(Level.WARNING, "", e);
}
}
}
@Override
public void validate() throws IllegalStateException {
super.validate();
logger.log(Level.INFO, "validate()");
for (ModuleInstall mi : packageInstallers) {
logger.log(Level.INFO, mi.getClass().getName() + " validate()");
try {
mi.validate();
} catch (Exception e) {
logger.log(Level.WARNING, "", e);
}
}
}
@Override
public void uninstalled() {
super.uninstalled();
logger.log(Level.INFO, "uninstalled()");
for (ModuleInstall mi : packageInstallers) {
logger.log(Level.INFO, mi.getClass().getName() + " uninstalled()");
try {
mi.uninstalled();
} catch (Exception e) {
logger.log(Level.WARNING, "", e);
}
}
}
@Override
public void close() {
super.close();
logger.log(Level.INFO, "close()");
for (ModuleInstall mi : packageInstallers) {
logger.log(Level.INFO, mi.getClass().getName() + " close()");
try {
mi.close();
} catch (Exception e) {
logger.log(Level.WARNING, "", e);
}
}
}
}

View File

@ -0,0 +1,87 @@
/*
* Autopsy Forensic Browser
*
* Copyright 2011 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sleuthkit.autopsy.corecomponentinterfaces;
import java.util.Collection;
import java.util.Iterator;
import java.util.logging.Level;
import org.sleuthkit.autopsy.coreutils.Logger;
import org.openide.util.Lookup;
import org.openide.windows.Mode;
import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;
/**
* Responsible for opening and closing the core windows when a case is opened and closed.
*
* @author jantonius
*/
public class CoreComponentControl {
private static final Logger logger = Logger.getLogger(CoreComponentControl.class.getName());
/**
* Opens all TopComponent windows that are needed ({@link DataExplorer}, {@link DataResult}, and
* {@link DataContent})
*/
public static void openCoreWindows() {
// TODO: there has to be a better way to do this.
// find the data explorer top components
Collection<? extends DataExplorer> dataExplorers = Lookup.getDefault().lookupAll(DataExplorer.class);
for (DataExplorer de : dataExplorers) {
TopComponent explorerWin = de.getTopComponent();
Mode m = WindowManager.getDefault().findMode("explorer");
if (m != null) {
m.dockInto(explorerWin); // redock into the explorer mode
} else {
logger.log(Level.WARNING, "Could not find explorer mode and dock explorer window");
}
explorerWin.open(); // open that top component
}
// find the data content top component
DataContent dc = Lookup.getDefault().lookup(DataContent.class);
TopComponent contentWin = dc.getTopComponent();
Mode m = WindowManager.getDefault().findMode("output");
if (m != null) {
m.dockInto(contentWin); // redock into the output mode
} else {
logger.log(Level.WARNING, "Could not find output mode and dock content window");
}
contentWin.open(); // open that top component
}
/**
* Closes all TopComponent windows that needed ({@link DataExplorer}, {@link DataResult}, and
* {@link DataContent})
*/
public static void closeCoreWindows() {
WindowManager wm = WindowManager.getDefault();
Iterator<? extends Mode> iter = wm.getModes().iterator();
while (iter.hasNext()) {
Mode mode = iter.next();
for (TopComponent tc : mode.getTopComponents()) {
tc.close();
}
}
}
}

View File

@ -36,6 +36,12 @@ import org.sleuthkit.autopsy.casemodule.Case;
*/
public class Installer extends ModuleInstall {
public Installer() {
super();
}
@Override
public void restored() {

View File

@ -31,6 +31,11 @@ import org.sleuthkit.datamodel.SleuthkitJNI;
*/
public class Installer extends ModuleInstall {
public Installer() {
super();
}
@Override
public void validate() throws IllegalStateException {
/*

View File

@ -28,6 +28,11 @@ import org.openide.windows.WindowManager;
*/
public class Installer extends ModuleInstall {
public Installer() {
super();
}
@Override
public void restored() {