Go to the documentation of this file.
19package org.sleuthkit.autopsy.guiutils;
21import com.google.common.util.concurrent.ThreadFactoryBuilder;
22import java.awt.Cursor;
23import java.util.concurrent.Callable;
24import java.util.concurrent.ExecutionException;
25import java.util.concurrent.ExecutorService;
26import java.util.concurrent.Executors;
27import java.util.concurrent.FutureTask;
28import java.util.logging.Level;
29import java.util.logging.Logger;
30import javax.swing.JFileChooser;
31import org.openide.windows.WindowManager;
32import org.sleuthkit.autopsy.coreutils.ThreadConfined;
85 String threadName =
"JFileChooser-background-thread";
87 if (callerName !=
null) {
88 threadName +=
"-" + callerName;
91 executor = Executors.newSingleThreadExecutor(
new ThreadFactoryBuilder().setNameFormat(threadName).build());
102 StackTraceElement[] stElements = Thread.currentThread().getStackTrace();
103 for (
int i=1; i<stElements.length; i++) {
104 StackTraceElement ste = stElements[i];
107 if (!ste.getClassName().equals(
JFileChooserFactory.class.getName())&& ste.getClassName().indexOf(
"java.lang.Thread")!=0) {
108 String resultClassName = ste.getClassName();
109 if (resultClassName.contains(
".")) {
111 int index = resultClassName.lastIndexOf(
".") + 1;
112 if (index < resultClassName.length()) {
113 resultClassName = resultClassName.substring(index);
116 return resultClassName;
135 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
140 }
catch (InterruptedException | ExecutionException ex) {
144 logger.log(Level.WARNING,
"Failed to initialize JFileChooser in background thread.");
148 WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
163 private class ChooserCallable
implements Callable<JFileChooser> {
165 private final Class<? extends JFileChooser>
type;
172 ChooserCallable(Class<? extends JFileChooser>
type) {
177 public JFileChooser
call() throws Exception {
178 return type.newInstance();
synchronized static Logger getLogger(String name)
final Class<? extends JFileChooser > type
JFileChooserFactory(Class<? extends JFileChooser > cls)
static String getCallerClassName()
static final Logger logger
JFileChooser getChooser()
final ExecutorService executor
final FutureTask< JFileChooser > futureFileChooser
Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 United States License.