replaced all printStackTrace statements with Logger statements

This commit is contained in:
Reinhard Pointner 2008-02-23 21:33:09 +00:00
parent 68247ea3ad
commit bc9eb0a267
18 changed files with 97 additions and 84 deletions

View File

@ -18,7 +18,8 @@ public class Main {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
e.printStackTrace();
// should not happen
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
}
SwingUtilities.invokeLater(new Runnable() {

View File

@ -8,6 +8,8 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
@ -132,7 +134,8 @@ public class FileBotList extends JPanel implements Saveable, TransferablePolicyS
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
// should not happen
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
}
}

View File

@ -11,6 +11,8 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractAction;
import javax.swing.JMenuItem;
@ -101,7 +103,7 @@ public class FileBotTree extends JTree implements TransferablePolicySupport {
Object userObject = node.getUserObject();
if (userObject != null && userObject instanceof File) {
if ((userObject != null) && (userObject instanceof File)) {
File file = (File) node.getUserObject();
return file.getName();
}
@ -186,12 +188,12 @@ public class FileBotTree extends JTree implements TransferablePolicySupport {
}
public void actionPerformed(ActionEvent e) {
public void actionPerformed(ActionEvent event) {
try {
Desktop.getDesktop().open(file);
} catch (Exception ex) {
MessageManager.showWarning(ex.getMessage());
ex.printStackTrace();
} catch (Exception e) {
MessageManager.showWarning(e.getMessage());
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
}
}
}

View File

@ -3,6 +3,8 @@ package net.sourceforge.filebot.ui;
import java.awt.datatransfer.DataFlavor;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.Action;
import javax.swing.JComponent;
@ -42,10 +44,19 @@ public class FileBotUtil {
return new DataFlavor("text/uri-list;class=java.lang.String");
} catch (ClassNotFoundException e) {
// will never happen
e.printStackTrace();
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
}
return null;
}
public static Throwable getRootCause(Throwable t) {
while (t.getCause() != null) {
t = t.getCause();
}
return t;
}
}

View File

@ -110,15 +110,6 @@ public class FileTree extends FileBotTree {
}
/**
* This method will not be used
*/
@Override
protected boolean load(File file) {
return false;
}
public void propertyChange(PropertyChangeEvent evt) {
Boolean loading = (Boolean) evt.getNewValue();

View File

@ -7,6 +7,8 @@ import java.awt.Color;
import java.awt.Dimension;
import java.io.File;
import java.util.Collection;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.BorderFactory;
import javax.swing.Box;
@ -180,7 +182,8 @@ public class SplitPanel extends ToolPanel implements ChangeListener {
tree.setModel(model);
} catch (Exception e) {
e.printStackTrace();
// should not happen
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
}
SplitPanel.this.firePropertyChange(LOADING_PROPERTY, null, false);

View File

@ -8,6 +8,8 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.TreeMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.BorderFactory;
import javax.swing.JScrollPane;
@ -128,7 +130,8 @@ public class TypePanel extends ToolPanel {
tree.setModel(model);
} catch (Exception e) {
e.printStackTrace();
// should not happen
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
}
TypePanel.this.firePropertyChange(LOADING_PROPERTY, null, false);

View File

@ -4,6 +4,8 @@ package net.sourceforge.filebot.ui.panel.list;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.sourceforge.filebot.torrent.Torrent;
import net.sourceforge.filebot.ui.FileFormat;
@ -33,7 +35,7 @@ public class FileListTransferablePolicy extends FileTransferablePolicy {
@Override
protected boolean load(File file) {
protected void load(File file) {
if (file.isDirectory()) {
list.setTitle(file.getName());
@ -49,12 +51,11 @@ public class FileListTransferablePolicy extends FileTransferablePolicy {
list.getModel().addElement(FileFormat.getNameWithoutSuffix(entry.getName()));
}
} catch (IOException e) {
e.printStackTrace();
// should not happen
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
}
}
}
return true;
}

View File

@ -34,17 +34,16 @@ public class FilesRenameListTransferablePolicy extends FileTransferablePolicy {
@Override
protected boolean load(File file) {
protected void load(File file) {
if (file.isDirectory()) {
File subfiles[] = file.listFiles();
Arrays.sort(subfiles);
for (File f : subfiles)
listModel.addElement(new FileEntry(f));
} else
} else {
listModel.addElement(new FileEntry(file));
return true;
}
}

View File

@ -6,6 +6,8 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
@ -49,7 +51,7 @@ public class NamesRenameListTransferablePolicy extends MultiTransferablePolicy {
@Override
protected boolean load(File file) {
protected void load(File file) {
try {
if (FileFormat.getSuffix(file).equalsIgnoreCase("torrent")) {
Torrent torrent = new Torrent(file);
@ -68,13 +70,10 @@ public class NamesRenameListTransferablePolicy extends MultiTransferablePolicy {
in.close();
}
return true;
} catch (Exception e) {
e.printStackTrace();
// should not happen
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
}
return false;
}

View File

@ -10,6 +10,8 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JLabel;
@ -31,11 +33,12 @@ public class HyperlinkLabel extends JLabel {
private MouseListener linker = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
public void mouseClicked(MouseEvent event) {
try {
Desktop.getDesktop().browse(url.toURI());
} catch (Exception ex) {
ex.printStackTrace();
} catch (Exception e) {
// should not happen
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
}
}

View File

@ -14,6 +14,8 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
@ -323,14 +325,8 @@ public class SearchPanel extends FileBotPanel {
} catch (Exception e) {
tabbedPane.remove(episodeList);
Throwable t = e;
while (t.getCause() != null) {
t = t.getCause();
}
MessageManager.showWarning(t.toString());
t.printStackTrace();
MessageManager.showWarning(FileBotUtil.getRootCause(e).getMessage());
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
return;
}
@ -348,8 +344,9 @@ public class SearchPanel extends FileBotPanel {
select.setIconImage(episodeList.getIcon().getImage());
select.setVisible(true);
showname = select.getSelectedValue();
} else
} else {
MessageManager.showWarning("\"" + task.getSearchTerm() + "\" has not been found.");
}
if (showname == null) {
tabbedPane.remove(episodeList);
@ -409,16 +406,8 @@ public class SearchPanel extends FileBotPanel {
} catch (Exception e) {
tabbedPane.remove(episodeList);
Throwable t = e;
// find root cause
while (t.getCause() != null) {
t = t.getCause();
}
MessageManager.showWarning(t.toString());
t.printStackTrace();
MessageManager.showWarning(FileBotUtil.getRootCause(e).getMessage());
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
}
}

View File

@ -6,6 +6,8 @@ import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.sourceforge.tuned.ui.SwingWorkerPropertyChangeAdapter;
@ -132,8 +134,9 @@ public class Checksum {
setChecksum(computationTask.get());
}
} catch (Exception e) {
// might happen if file system is corrupt (e.g. CRC errors)
setChecksumError(e);
e.printStackTrace();
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.WARNING, e.getMessage());
}
}
}

View File

@ -10,6 +10,8 @@ import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
@ -162,7 +164,8 @@ public class SfvTable extends JTable implements TransferablePolicySupport, Savea
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
// should not happen
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
}
}

View File

@ -5,8 +5,11 @@ package net.sourceforge.filebot.ui.panel.sfv;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -64,7 +67,7 @@ public class SfvTransferablePolicy extends MultiTransferablePolicy {
@Override
protected boolean load(File sfvFile) {
protected void load(File sfvFile) {
try {
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(sfvFile)));
@ -95,12 +98,10 @@ public class SfvTransferablePolicy extends MultiTransferablePolicy {
}
in.close();
} catch (Exception e) {
e.printStackTrace();
return false;
} catch (IOException e) {
// should not happen
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
}
return true;
}
@ -169,15 +170,6 @@ public class SfvTransferablePolicy extends MultiTransferablePolicy {
}
/**
* this method will not be used
*/
@Override
protected boolean load(File file) {
return false;
}
@Override
public String getDescription() {
return "files and folders";

View File

@ -7,6 +7,8 @@ import java.awt.datatransfer.Transferable;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComponent;
import javax.swing.TransferHandler;
@ -37,7 +39,8 @@ public class SaveableExportHandler implements ExportHandler {
file.deleteOnExit();
}
} catch (Exception e) {
e.printStackTrace();
// should not happen
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
}
}
@ -60,7 +63,8 @@ public class SaveableExportHandler implements ExportHandler {
saveable.save(temporaryFile);
return new FileTransferable(temporaryFile);
} catch (IOException e) {
e.printStackTrace();
// should not happen
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
}
return null;

View File

@ -4,9 +4,7 @@ package net.sourceforge.filebot.ui.transferablepolicies;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
@ -63,10 +61,9 @@ public abstract class FileTransferablePolicy extends TransferablePolicy {
return files;
}
} catch (UnsupportedFlavorException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
// should not happen
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
}
return null;
@ -105,12 +102,18 @@ public abstract class FileTransferablePolicy extends TransferablePolicy {
}
protected abstract boolean accept(File file);
protected boolean accept(File file) {
return false;
}
protected abstract void clear();
protected void clear() {
}
protected abstract boolean load(File file);
protected void load(File file) {
}
}

View File

@ -4,6 +4,8 @@ package net.sourceforge.filebot.ui.transferablepolicies;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.util.logging.Level;
import java.util.logging.Logger;
public abstract class TextTransferablePolicy extends TransferablePolicy {
@ -28,7 +30,8 @@ public abstract class TextTransferablePolicy extends TransferablePolicy {
load(string);
} catch (Exception e) {
e.printStackTrace();
// should not happen
Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).log(Level.SEVERE, e.getMessage(), e);
}
}