浏览代码

SLF4J some more Logging statements in the Swing UI.

pull/423/head
Greg Holmes 9 年前
父节点
当前提交
2d8979719d

+ 8
- 5
ui_swing/src/com/dmdirc/addons/ui_swing/Apple.java 查看文件

26
 import com.dmdirc.DMDircMBassador;
26
 import com.dmdirc.DMDircMBassador;
27
 import com.dmdirc.addons.ui_swing.components.menubar.MenuBar;
27
 import com.dmdirc.addons.ui_swing.components.menubar.MenuBar;
28
 import com.dmdirc.events.ClientOpenedEvent;
28
 import com.dmdirc.events.ClientOpenedEvent;
29
-import com.dmdirc.events.UserErrorEvent;
30
 import com.dmdirc.interfaces.ConnectionManager;
29
 import com.dmdirc.interfaces.ConnectionManager;
31
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
30
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
32
-import com.dmdirc.logger.ErrorLevel;
33
 import com.dmdirc.util.InvalidURIException;
31
 import com.dmdirc.util.InvalidURIException;
34
 import com.dmdirc.util.URIParser;
32
 import com.dmdirc.util.URIParser;
35
 
33
 
53
 import javax.swing.JMenuItem;
51
 import javax.swing.JMenuItem;
54
 import javax.swing.UIManager;
52
 import javax.swing.UIManager;
55
 
53
 
54
+import org.slf4j.Logger;
55
+import org.slf4j.LoggerFactory;
56
+
56
 import net.engio.mbassy.listener.Handler;
57
 import net.engio.mbassy.listener.Handler;
57
 
58
 
59
+import static com.dmdirc.util.LogUtils.USER_ERROR;
60
+
58
 /**
61
 /**
59
  * Integrate DMDirc with OS X better.
62
  * Integrate DMDirc with OS X better.
60
  */
63
  */
61
 @Singleton
64
 @Singleton
62
 public class Apple implements InvocationHandler {
65
 public class Apple implements InvocationHandler {
63
 
66
 
67
+    private static final Logger LOG = LoggerFactory.getLogger(Apple.class);
64
     /** Store any addresses that are opened before CLIENT_OPENED. */
68
     /** Store any addresses that are opened before CLIENT_OPENED. */
65
     private final Collection<URI> addresses = new ArrayList<>();
69
     private final Collection<URI> addresses = new ArrayList<>();
66
     /** Config manager used to read settings. */
70
     /** Config manager used to read settings. */
105
                 registerOpenURLCallback();
109
                 registerOpenURLCallback();
106
                 eventBus.subscribe(this);
110
                 eventBus.subscribe(this);
107
             } catch (UnsatisfiedLinkError ule) {
111
             } catch (UnsatisfiedLinkError ule) {
108
-                eventBus.publishAsync(new UserErrorEvent(ErrorLevel.MEDIUM,
109
-                        ule, "Unable to load JNI library", ""));
112
+                LOG.warn(USER_ERROR, "Unable to load JNI library", ule);
110
             }
113
             }
111
         }
114
         }
112
     }
115
     }
137
                     : classes);
140
                     : classes);
138
             return method.invoke(obj, objects == null ? new Object[0] : objects);
141
             return method.invoke(obj, objects == null ? new Object[0] : objects);
139
         } catch (ReflectiveOperationException ex) {
142
         } catch (ReflectiveOperationException ex) {
140
-            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, ex, "Unable to find OS X classes.", ""));
143
+            LOG.info(USER_ERROR, "Unable to find OS X classes.", ex);
141
         }
144
         }
142
 
145
 
143
         return null;
146
         return null;

+ 8
- 10
ui_swing/src/com/dmdirc/addons/ui_swing/RedoAction.java 查看文件

22
 
22
 
23
 package com.dmdirc.addons.ui_swing;
23
 package com.dmdirc.addons.ui_swing;
24
 
24
 
25
-import com.dmdirc.DMDircMBassador;
26
-import com.dmdirc.events.UserErrorEvent;
27
-import com.dmdirc.logger.ErrorLevel;
28
-
29
 import java.awt.event.ActionEvent;
25
 import java.awt.event.ActionEvent;
30
 
26
 
31
 import javax.swing.AbstractAction;
27
 import javax.swing.AbstractAction;
32
 import javax.swing.undo.CannotUndoException;
28
 import javax.swing.undo.CannotUndoException;
33
 import javax.swing.undo.UndoManager;
29
 import javax.swing.undo.UndoManager;
34
 
30
 
31
+import org.slf4j.Logger;
32
+import org.slf4j.LoggerFactory;
33
+
34
+import static com.dmdirc.util.LogUtils.USER_ERROR;
35
+
35
 /**
36
 /**
36
  * Handles redo's on text components.
37
  * Handles redo's on text components.
37
  */
38
  */
38
 public final class RedoAction extends AbstractAction {
39
 public final class RedoAction extends AbstractAction {
39
 
40
 
41
+    private static final Logger LOG = LoggerFactory.getLogger(RedoAction.class);
40
     /** A version number for this class. */
42
     /** A version number for this class. */
41
     private static final long serialVersionUID = 1;
43
     private static final long serialVersionUID = 1;
42
     /** Undo manager. */
44
     /** Undo manager. */
43
     private final UndoManager undoManager;
45
     private final UndoManager undoManager;
44
-    /** The event bus to post errors to. */
45
-    private final DMDircMBassador eventBus;
46
 
46
 
47
     /**
47
     /**
48
      * Creates a new instance of RedoAction.
48
      * Creates a new instance of RedoAction.
49
      *
49
      *
50
-     * @param eventBus    The event bus to post errors to
51
      * @param undoManager UndoManager to use for this redo action
50
      * @param undoManager UndoManager to use for this redo action
52
      */
51
      */
53
-    public RedoAction(final DMDircMBassador eventBus, final UndoManager undoManager) {
52
+    public RedoAction(final UndoManager undoManager) {
54
         super("Undo");
53
         super("Undo");
55
 
54
 
56
         this.undoManager = undoManager;
55
         this.undoManager = undoManager;
57
-        this.eventBus = eventBus;
58
     }
56
     }
59
 
57
 
60
     @Override
58
     @Override
64
                 undoManager.redo();
62
                 undoManager.redo();
65
             }
63
             }
66
         } catch (CannotUndoException ex) {
64
         } catch (CannotUndoException ex) {
67
-            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, ex, "Unable to redo", ""));
65
+            LOG.info(USER_ERROR, "Unable to redo", ex);
68
         }
66
         }
69
     }
67
     }
70
 
68
 

+ 7
- 8
ui_swing/src/com/dmdirc/addons/ui_swing/SwingUIInitialiser.java 查看文件

24
 
24
 
25
 import com.dmdirc.ClientModule.AddonConfig;
25
 import com.dmdirc.ClientModule.AddonConfig;
26
 import com.dmdirc.ClientModule.GlobalConfig;
26
 import com.dmdirc.ClientModule.GlobalConfig;
27
-import com.dmdirc.DMDircMBassador;
28
 import com.dmdirc.addons.ui_swing.dialogs.DialogKeyListener;
27
 import com.dmdirc.addons.ui_swing.dialogs.DialogKeyListener;
29
-import com.dmdirc.events.UserErrorEvent;
30
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
28
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
31
 import com.dmdirc.interfaces.config.ConfigProvider;
29
 import com.dmdirc.interfaces.config.ConfigProvider;
32
-import com.dmdirc.logger.ErrorLevel;
30
+import com.dmdirc.util.LogUtils;
33
 
31
 
34
 import java.awt.Font;
32
 import java.awt.Font;
35
 import java.awt.KeyboardFocusManager;
33
 import java.awt.KeyboardFocusManager;
41
 
39
 
42
 import net.miginfocom.layout.PlatformDefaults;
40
 import net.miginfocom.layout.PlatformDefaults;
43
 
41
 
42
+import org.slf4j.Logger;
43
+import org.slf4j.LoggerFactory;
44
+
44
 /**
45
 /**
45
  * Initialises swing and system UI settings.
46
  * Initialises swing and system UI settings.
46
  */
47
  */
47
 public class SwingUIInitialiser {
48
 public class SwingUIInitialiser {
48
 
49
 
50
+    private static final Logger LOG = LoggerFactory.getLogger(SwingUIInitialiser.class);
49
     private final Apple apple;
51
     private final Apple apple;
50
     private final AggregateConfigProvider globalConfig;
52
     private final AggregateConfigProvider globalConfig;
51
     private final ConfigProvider addonConfig;
53
     private final ConfigProvider addonConfig;
52
     private final DialogKeyListener dialogKeyListener;
54
     private final DialogKeyListener dialogKeyListener;
53
     private final DMDircEventQueue eventQueue;
55
     private final DMDircEventQueue eventQueue;
54
-    private final DMDircMBassador eventBus;
55
 
56
 
56
     @Inject
57
     @Inject
57
-    public SwingUIInitialiser(final DMDircMBassador eventBus, final Apple apple,
58
+    public SwingUIInitialiser(final Apple apple,
58
             @GlobalConfig final AggregateConfigProvider globalConfig,
59
             @GlobalConfig final AggregateConfigProvider globalConfig,
59
             @AddonConfig final ConfigProvider addonConfig,
60
             @AddonConfig final ConfigProvider addonConfig,
60
             final DialogKeyListener dialogKeyListener,
61
             final DialogKeyListener dialogKeyListener,
61
             final DMDircEventQueue eventQueue) {
62
             final DMDircEventQueue eventQueue) {
62
-        this.eventBus = eventBus;
63
         this.apple = apple;
63
         this.apple = apple;
64
         this.globalConfig = globalConfig;
64
         this.globalConfig = globalConfig;
65
         this.addonConfig = addonConfig;
65
         this.addonConfig = addonConfig;
122
                         Font.PLAIN, 12));
122
                         Font.PLAIN, 12));
123
             } catch (UnsupportedOperationException | UnsupportedLookAndFeelException |
123
             } catch (UnsupportedOperationException | UnsupportedLookAndFeelException |
124
                     IllegalAccessException | InstantiationException | ClassNotFoundException ex) {
124
                     IllegalAccessException | InstantiationException | ClassNotFoundException ex) {
125
-                eventBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, ex,
126
-                        "Unable to set UI Settings", ""));
125
+                LOG.info(LogUtils.USER_ERROR, "Unable to set UI settings", ex);
127
             }
126
             }
128
 
127
 
129
             if ("Metal".equals(UIManager.getLookAndFeel().getName())
128
             if ("Metal".equals(UIManager.getLookAndFeel().getName())

+ 7
- 10
ui_swing/src/com/dmdirc/addons/ui_swing/SwingWindowFactory.java 查看文件

22
 
22
 
23
 package com.dmdirc.addons.ui_swing;
23
 package com.dmdirc.addons.ui_swing;
24
 
24
 
25
-import com.dmdirc.DMDircMBassador;
26
 import com.dmdirc.addons.ui_swing.components.frames.ChannelFrameFactory;
25
 import com.dmdirc.addons.ui_swing.components.frames.ChannelFrameFactory;
27
 import com.dmdirc.addons.ui_swing.components.frames.CustomFrameFactory;
26
 import com.dmdirc.addons.ui_swing.components.frames.CustomFrameFactory;
28
 import com.dmdirc.addons.ui_swing.components.frames.CustomInputFrameFactory;
27
 import com.dmdirc.addons.ui_swing.components.frames.CustomInputFrameFactory;
32
 import com.dmdirc.addons.ui_swing.events.SwingEventBus;
31
 import com.dmdirc.addons.ui_swing.events.SwingEventBus;
33
 import com.dmdirc.addons.ui_swing.events.SwingWindowAddedEvent;
32
 import com.dmdirc.addons.ui_swing.events.SwingWindowAddedEvent;
34
 import com.dmdirc.addons.ui_swing.events.SwingWindowDeletedEvent;
33
 import com.dmdirc.addons.ui_swing.events.SwingWindowDeletedEvent;
35
-import com.dmdirc.events.UserErrorEvent;
36
 import com.dmdirc.interfaces.WindowModel;
34
 import com.dmdirc.interfaces.WindowModel;
37
 import com.dmdirc.interfaces.ui.FrameListener;
35
 import com.dmdirc.interfaces.ui.FrameListener;
38
-import com.dmdirc.logger.ErrorLevel;
39
 
36
 
40
 import java.util.Collection;
37
 import java.util.Collection;
41
 import java.util.HashMap;
38
 import java.util.HashMap;
47
 import javax.inject.Inject;
44
 import javax.inject.Inject;
48
 import javax.inject.Singleton;
45
 import javax.inject.Singleton;
49
 
46
 
47
+import org.slf4j.Logger;
48
+import org.slf4j.LoggerFactory;
49
+
50
+import static com.dmdirc.util.LogUtils.USER_ERROR;
51
+
50
 /**
52
 /**
51
  * Handles creation of windows in the Swing UI.
53
  * Handles creation of windows in the Swing UI.
52
  *
54
  *
55
 @Singleton
57
 @Singleton
56
 public class SwingWindowFactory implements FrameListener {
58
 public class SwingWindowFactory implements FrameListener {
57
 
59
 
60
+    private static final Logger LOG = LoggerFactory.getLogger(SwingWindowFactory.class);
58
     /** A map of known implementations of window interfaces. */
61
     /** A map of known implementations of window interfaces. */
59
     private final Map<Collection<String>, WindowProvider> implementations = new HashMap<>();
62
     private final Map<Collection<String>, WindowProvider> implementations = new HashMap<>();
60
     /** A map of frame containers to their Swing windows. */
63
     /** A map of frame containers to their Swing windows. */
61
     private final Map<WindowModel, TextFrame> windows = new HashMap<>();
64
     private final Map<WindowModel, TextFrame> windows = new HashMap<>();
62
-    /** The event bus to post errors to. */
63
-    private final DMDircMBassador eventBus;
64
     /** The swing event bus. */
65
     /** The swing event bus. */
65
     private final SwingEventBus swingEventBus;
66
     private final SwingEventBus swingEventBus;
66
 
67
 
71
      * @param customInputFrameFactory The factory to use to produce custom input frames.
72
      * @param customInputFrameFactory The factory to use to produce custom input frames.
72
      * @param serverFrameFactory      The factory to use to produce server frames.
73
      * @param serverFrameFactory      The factory to use to produce server frames.
73
      * @param channelFrameFactory     The factory to use to produce channel frames.
74
      * @param channelFrameFactory     The factory to use to produce channel frames.
74
-     * @param eventBus                The event bus to post errors to
75
      * @param swingEventBus           The swing event bus;
75
      * @param swingEventBus           The swing event bus;
76
      */
76
      */
77
     @Inject
77
     @Inject
80
             final CustomInputFrameFactory customInputFrameFactory,
80
             final CustomInputFrameFactory customInputFrameFactory,
81
             final ServerFrameFactory serverFrameFactory,
81
             final ServerFrameFactory serverFrameFactory,
82
             final ChannelFrameFactory channelFrameFactory,
82
             final ChannelFrameFactory channelFrameFactory,
83
-            final DMDircMBassador eventBus,
84
             final SwingEventBus swingEventBus) {
83
             final SwingEventBus swingEventBus) {
85
-        this.eventBus = eventBus;
86
         this.swingEventBus = swingEventBus;
84
         this.swingEventBus = swingEventBus;
87
 
85
 
88
         registerImplementation(customFrameFactory);
86
         registerImplementation(customFrameFactory);
137
      */
135
      */
138
     protected TextFrame doAddWindow(final WindowModel window) {
136
     protected TextFrame doAddWindow(final WindowModel window) {
139
         if (!implementations.containsKey(window.getComponents())) {
137
         if (!implementations.containsKey(window.getComponents())) {
140
-            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.HIGH, null,
141
-                    "Unable to create window: Unknown type.", ""));
138
+            LOG.error(USER_ERROR, "Unable to create window: Unknown type.");
142
             return null;
139
             return null;
143
         }
140
         }
144
 
141
 

+ 8
- 10
ui_swing/src/com/dmdirc/addons/ui_swing/UndoAction.java 查看文件

22
 
22
 
23
 package com.dmdirc.addons.ui_swing;
23
 package com.dmdirc.addons.ui_swing;
24
 
24
 
25
-import com.dmdirc.DMDircMBassador;
26
-import com.dmdirc.events.UserErrorEvent;
27
-import com.dmdirc.logger.ErrorLevel;
28
-
29
 import java.awt.event.ActionEvent;
25
 import java.awt.event.ActionEvent;
30
 
26
 
31
 import javax.swing.AbstractAction;
27
 import javax.swing.AbstractAction;
32
 import javax.swing.undo.CannotUndoException;
28
 import javax.swing.undo.CannotUndoException;
33
 import javax.swing.undo.UndoManager;
29
 import javax.swing.undo.UndoManager;
34
 
30
 
31
+import org.slf4j.Logger;
32
+import org.slf4j.LoggerFactory;
33
+
34
+import static com.dmdirc.util.LogUtils.USER_ERROR;
35
+
35
 /**
36
 /**
36
  * Handles undo's on text components.
37
  * Handles undo's on text components.
37
  */
38
  */
38
 public final class UndoAction extends AbstractAction {
39
 public final class UndoAction extends AbstractAction {
39
 
40
 
41
+    private static final Logger LOG = LoggerFactory.getLogger(UndoAction.class);
40
     /** A version number for this class. */
42
     /** A version number for this class. */
41
     private static final long serialVersionUID = 1;
43
     private static final long serialVersionUID = 1;
42
     /** Undo manager. */
44
     /** Undo manager. */
43
     private final UndoManager undoManager;
45
     private final UndoManager undoManager;
44
-    /** The event bus to post errors to. */
45
-    private final DMDircMBassador eventBus;
46
 
46
 
47
     /**
47
     /**
48
      * Creates a new instance of UndoAction.
48
      * Creates a new instance of UndoAction.
49
      *
49
      *
50
-     * @param eventBus    The event bus to post errors to
51
      * @param undoManager UndoManager to use for this redo action
50
      * @param undoManager UndoManager to use for this redo action
52
      */
51
      */
53
-    public UndoAction(final DMDircMBassador eventBus, final UndoManager undoManager) {
52
+    public UndoAction(final UndoManager undoManager) {
54
         super("Undo");
53
         super("Undo");
55
 
54
 
56
         this.undoManager = undoManager;
55
         this.undoManager = undoManager;
57
-        this.eventBus = eventBus;
58
     }
56
     }
59
 
57
 
60
     @Override
58
     @Override
64
                 undoManager.undo();
62
                 undoManager.undo();
65
             }
63
             }
66
         } catch (CannotUndoException ex) {
64
         } catch (CannotUndoException ex) {
67
-            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, ex, "Unable to undo", ""));
65
+            LOG.info(USER_ERROR, "Unable to undo", ex);
68
         }
66
         }
69
     }
67
     }
70
 
68
 

+ 9
- 14
ui_swing/src/com/dmdirc/addons/ui_swing/actions/ReplacePasteAction.java 查看文件

22
 
22
 
23
 package com.dmdirc.addons.ui_swing.actions;
23
 package com.dmdirc.addons.ui_swing.actions;
24
 
24
 
25
-import com.dmdirc.DMDircMBassador;
26
-import com.dmdirc.events.UserErrorEvent;
27
-import com.dmdirc.logger.ErrorLevel;
25
+import com.dmdirc.util.LogUtils;
28
 
26
 
29
 import java.awt.datatransfer.Clipboard;
27
 import java.awt.datatransfer.Clipboard;
30
 import java.awt.datatransfer.DataFlavor;
28
 import java.awt.datatransfer.DataFlavor;
35
 import javax.swing.AbstractAction;
33
 import javax.swing.AbstractAction;
36
 import javax.swing.text.JTextComponent;
34
 import javax.swing.text.JTextComponent;
37
 
35
 
36
+import org.slf4j.Logger;
37
+import org.slf4j.LoggerFactory;
38
+
38
 /**
39
 /**
39
  * Paste action that replaces matching regexes.
40
  * Paste action that replaces matching regexes.
40
  */
41
  */
41
 public final class ReplacePasteAction extends AbstractAction {
42
 public final class ReplacePasteAction extends AbstractAction {
42
 
43
 
44
+    private static final Logger LOG = LoggerFactory.getLogger(ReplacePasteAction.class);
43
     /** A version number for this class. */
45
     /** A version number for this class. */
44
     private static final long serialVersionUID = 1;
46
     private static final long serialVersionUID = 1;
45
     /** Clipboard to handle pasting. */
47
     /** Clipboard to handle pasting. */
48
     private final String replacementRegex;
50
     private final String replacementRegex;
49
     /** Replacement string. */
51
     /** Replacement string. */
50
     private final String replacementString;
52
     private final String replacementString;
51
-    /** The event bus to post errors to. */
52
-    private final DMDircMBassador eventBus;
53
 
53
 
54
     /**
54
     /**
55
      * Creates a new instance of regex replacement paste action.
55
      * Creates a new instance of regex replacement paste action.
56
      *
56
      *
57
-     * @param eventBus          The event bus to post errors to
58
      * @param clipboard         Clipboard to handle pasting
57
      * @param clipboard         Clipboard to handle pasting
59
      * @param replacementRegex  Regex to match for replacement
58
      * @param replacementRegex  Regex to match for replacement
60
      * @param replacementString Replacement string
59
      * @param replacementString Replacement string
61
      */
60
      */
62
-    public ReplacePasteAction(final DMDircMBassador eventBus, final Clipboard clipboard,
61
+    public ReplacePasteAction(final Clipboard clipboard,
63
             final String replacementRegex, final String replacementString) {
62
             final String replacementRegex, final String replacementString) {
64
         super("NoSpacesPasteAction");
63
         super("NoSpacesPasteAction");
65
 
64
 
66
-        this.eventBus = eventBus;
67
         this.clipboard = clipboard;
65
         this.clipboard = clipboard;
68
         this.replacementRegex = replacementRegex;
66
         this.replacementRegex = replacementRegex;
69
         this.replacementString = replacementString;
67
         this.replacementString = replacementString;
83
             ((JTextComponent) e.getSource()).replaceSelection(
81
             ((JTextComponent) e.getSource()).replaceSelection(
84
                     ((String) clipboard.getData(DataFlavor.stringFlavor))
82
                     ((String) clipboard.getData(DataFlavor.stringFlavor))
85
                             .replaceAll(replacementRegex, replacementString));
83
                             .replaceAll(replacementRegex, replacementString));
86
-        } catch (IOException ex) {
87
-            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, ex,
88
-                    "Unable to get clipboard contents: " + ex.getMessage(), ""));
89
-        } catch (UnsupportedFlavorException ex) {
90
-            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, ex,
91
-                    "Unable to get clipboard contents", ""));
84
+        } catch (IOException | UnsupportedFlavorException ex) {
85
+            LOG.info(LogUtils.USER_ERROR, "Unable to get clipboard contents: {}",
86
+                    ex.getMessage(), ex);
92
         }
87
         }
93
     }
88
     }
94
 
89
 

+ 11
- 8
ui_swing/src/com/dmdirc/addons/ui_swing/components/frames/InputTextFramePasteAction.java 查看文件

25
 import com.dmdirc.DMDircMBassador;
25
 import com.dmdirc.DMDircMBassador;
26
 import com.dmdirc.addons.ui_swing.components.inputfields.SwingInputField;
26
 import com.dmdirc.addons.ui_swing.components.inputfields.SwingInputField;
27
 import com.dmdirc.addons.ui_swing.dialogs.paste.PasteDialogFactory;
27
 import com.dmdirc.addons.ui_swing.dialogs.paste.PasteDialogFactory;
28
-import com.dmdirc.events.UserErrorEvent;
29
 import com.dmdirc.interfaces.WindowModel;
28
 import com.dmdirc.interfaces.WindowModel;
30
-import com.dmdirc.logger.ErrorLevel;
31
 
29
 
32
 import java.awt.Toolkit;
30
 import java.awt.Toolkit;
33
 import java.awt.Window;
31
 import java.awt.Window;
39
 
37
 
40
 import javax.swing.AbstractAction;
38
 import javax.swing.AbstractAction;
41
 
39
 
40
+import org.slf4j.Logger;
41
+import org.slf4j.LoggerFactory;
42
+
43
+import static com.dmdirc.util.LogUtils.USER_ERROR;
44
+
42
 /**
45
 /**
43
  * Paste action for input frames.
46
  * Paste action for input frames.
44
  */
47
  */
45
 public final class InputTextFramePasteAction extends AbstractAction {
48
 public final class InputTextFramePasteAction extends AbstractAction {
46
 
49
 
50
+    private static final Logger LOG = LoggerFactory.getLogger(InputTextFramePasteAction.class);
47
     /** A version number for this class. */
51
     /** A version number for this class. */
48
     private static final long serialVersionUID = 1;
52
     private static final long serialVersionUID = 1;
49
     /** Clipboard to paste from. */
53
     /** Clipboard to paste from. */
94
                 return;
98
                 return;
95
             }
99
             }
96
         } catch (final IllegalStateException ex) {
100
         } catch (final IllegalStateException ex) {
97
-            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, ex,
98
-                    "Unable to paste from clipboard.", ""));
101
+            LOG.info(USER_ERROR, "Unable to paste from clipboard.", ex);
99
             return;
102
             return;
100
         }
103
         }
101
 
104
 
105
             doPaste((String) Toolkit.getDefaultToolkit()
108
             doPaste((String) Toolkit.getDefaultToolkit()
106
                     .getSystemClipboard().getData(DataFlavor.stringFlavor));
109
                     .getSystemClipboard().getData(DataFlavor.stringFlavor));
107
         } catch (final IOException ex) {
110
         } catch (final IOException ex) {
108
-            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, ex,
109
-                    "Unable to get clipboard contents: " + ex.getMessage(), ""));
111
+            LOG.info(USER_ERROR, "Unable to get clipboard contents: {}",
112
+                    ex.getMessage(), ex);
110
         } catch (final UnsupportedFlavorException ex) {
113
         } catch (final UnsupportedFlavorException ex) {
111
-            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, ex,
112
-                    "Unsupported clipboard type", ""));
114
+            LOG.info(USER_ERROR, "Unsupported clipboard type: {}",
115
+                    ex.getMessage(), ex);
113
         }
116
         }
114
     }
117
     }
115
 
118
 

+ 8
- 11
ui_swing/src/com/dmdirc/addons/ui_swing/dialogs/prefs/UpdateConfigPanel.java 查看文件

24
 
24
 
25
 import com.dmdirc.ClientModule.GlobalConfig;
25
 import com.dmdirc.ClientModule.GlobalConfig;
26
 import com.dmdirc.ClientModule.UserConfig;
26
 import com.dmdirc.ClientModule.UserConfig;
27
-import com.dmdirc.DMDircMBassador;
28
 import com.dmdirc.addons.ui_swing.components.GenericTableModel;
27
 import com.dmdirc.addons.ui_swing.components.GenericTableModel;
29
 import com.dmdirc.addons.ui_swing.components.PackingTable;
28
 import com.dmdirc.addons.ui_swing.components.PackingTable;
30
 import com.dmdirc.config.prefs.PreferencesInterface;
29
 import com.dmdirc.config.prefs.PreferencesInterface;
31
-import com.dmdirc.events.UserErrorEvent;
32
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
30
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
33
 import com.dmdirc.interfaces.config.ConfigChangeListener;
31
 import com.dmdirc.interfaces.config.ConfigChangeListener;
34
 import com.dmdirc.interfaces.config.ConfigProvider;
32
 import com.dmdirc.interfaces.config.ConfigProvider;
35
 import com.dmdirc.interfaces.config.IdentityController;
33
 import com.dmdirc.interfaces.config.IdentityController;
36
-import com.dmdirc.logger.ErrorLevel;
37
 import com.dmdirc.updater.UpdateChannel;
34
 import com.dmdirc.updater.UpdateChannel;
38
 import com.dmdirc.updater.UpdateChecker;
35
 import com.dmdirc.updater.UpdateChecker;
39
 import com.dmdirc.updater.UpdateComponent;
36
 import com.dmdirc.updater.UpdateComponent;
54
 
51
 
55
 import net.miginfocom.swing.MigLayout;
52
 import net.miginfocom.swing.MigLayout;
56
 
53
 
54
+import org.slf4j.Logger;
55
+import org.slf4j.LoggerFactory;
56
+
57
+import static com.dmdirc.util.LogUtils.USER_ERROR;
58
+
57
 /**
59
 /**
58
  * Updates configuration UI.
60
  * Updates configuration UI.
59
  */
61
  */
60
 public class UpdateConfigPanel extends JPanel implements ActionListener,
62
 public class UpdateConfigPanel extends JPanel implements ActionListener,
61
         PreferencesInterface, ConfigChangeListener {
63
         PreferencesInterface, ConfigChangeListener {
62
 
64
 
65
+    private static final Logger LOG = LoggerFactory.getLogger(UpdateConfigPanel.class);
63
     /** A version number for this class. */
66
     /** A version number for this class. */
64
     private static final long serialVersionUID = 1;
67
     private static final long serialVersionUID = 1;
65
     /** Global checkbox. */
68
     /** Global checkbox. */
80
     private final CachingUpdateManager updateManager;
83
     private final CachingUpdateManager updateManager;
81
     /** Controller to pass to the update checker. */
84
     /** Controller to pass to the update checker. */
82
     private final IdentityController identityController;
85
     private final IdentityController identityController;
83
-    /** The event bus to post errors to. */
84
-    private final DMDircMBassador eventBus;
85
 
86
 
86
     /**
87
     /**
87
      * Instantiates a new update config panel.
88
      * Instantiates a new update config panel.
90
      * @param globalConfig       The configuration to read global settings from.
91
      * @param globalConfig       The configuration to read global settings from.
91
      * @param updateManager      The manager to read update information from.
92
      * @param updateManager      The manager to read update information from.
92
      * @param identityController Controller to pass to the update checker.
93
      * @param identityController Controller to pass to the update checker.
93
-     * @param eventBus           The event bus to post the errors to
94
      */
94
      */
95
     @Inject
95
     @Inject
96
     public UpdateConfigPanel(
96
     public UpdateConfigPanel(
97
             @UserConfig final ConfigProvider userConfig,
97
             @UserConfig final ConfigProvider userConfig,
98
             @GlobalConfig final AggregateConfigProvider globalConfig,
98
             @GlobalConfig final AggregateConfigProvider globalConfig,
99
             final CachingUpdateManager updateManager,
99
             final CachingUpdateManager updateManager,
100
-            final IdentityController identityController,
101
-            final DMDircMBassador eventBus) {
100
+            final IdentityController identityController) {
102
         this.userConfig = userConfig;
101
         this.userConfig = userConfig;
103
         this.globalConfig = globalConfig;
102
         this.globalConfig = globalConfig;
104
         this.updateManager = updateManager;
103
         this.updateManager = updateManager;
105
         this.identityController = identityController;
104
         this.identityController = identityController;
106
-        this.eventBus = eventBus;
107
 
105
 
108
         initComponents();
106
         initComponents();
109
         loadModel();
107
         loadModel();
164
         try {
162
         try {
165
             channel = UpdateChannel.valueOf(globalConfig.getOption("updater", "channel"));
163
             channel = UpdateChannel.valueOf(globalConfig.getOption("updater", "channel"));
166
         } catch (IllegalArgumentException e) {
164
         } catch (IllegalArgumentException e) {
167
-            eventBus.publishAsync(new UserErrorEvent(ErrorLevel.LOW, e,
168
-                    "Invalid setting for update channel, defaulting to none.", ""));
165
+            LOG.info(USER_ERROR, "Invalid setting for update channel, defaulting to none.", e);
169
         }
166
         }
170
         updateChannel.setSelectedItem(channel);
167
         updateChannel.setSelectedItem(channel);
171
         scrollPane.setViewportView(table);
168
         scrollPane.setViewportView(table);

+ 7
- 10
ui_swing/src/com/dmdirc/addons/ui_swing/framemanager/ctrltab/CtrlTabWindowManager.java 查看文件

23
 package com.dmdirc.addons.ui_swing.framemanager.ctrltab;
23
 package com.dmdirc.addons.ui_swing.framemanager.ctrltab;
24
 
24
 
25
 import com.dmdirc.ClientModule.GlobalConfig;
25
 import com.dmdirc.ClientModule.GlobalConfig;
26
-import com.dmdirc.DMDircMBassador;
27
 import com.dmdirc.addons.ui_swing.EdtHandlerInvocation;
26
 import com.dmdirc.addons.ui_swing.EdtHandlerInvocation;
28
 import com.dmdirc.addons.ui_swing.MainFrame;
27
 import com.dmdirc.addons.ui_swing.MainFrame;
29
 import com.dmdirc.addons.ui_swing.UIUtilities;
28
 import com.dmdirc.addons.ui_swing.UIUtilities;
38
 import com.dmdirc.addons.ui_swing.events.SwingWindowSelectedEvent;
37
 import com.dmdirc.addons.ui_swing.events.SwingWindowSelectedEvent;
39
 import com.dmdirc.addons.ui_swing.framemanager.tree.TreeViewModel;
38
 import com.dmdirc.addons.ui_swing.framemanager.tree.TreeViewModel;
40
 import com.dmdirc.addons.ui_swing.framemanager.tree.TreeViewNode;
39
 import com.dmdirc.addons.ui_swing.framemanager.tree.TreeViewNode;
41
-import com.dmdirc.events.UserErrorEvent;
42
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
40
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
43
-import com.dmdirc.logger.ErrorLevel;
41
+import com.dmdirc.util.LogUtils;
44
 
42
 
45
 import java.awt.event.InputEvent;
43
 import java.awt.event.InputEvent;
46
 import java.awt.event.KeyEvent;
44
 import java.awt.event.KeyEvent;
58
 import javax.swing.tree.TreePath;
56
 import javax.swing.tree.TreePath;
59
 import javax.swing.tree.TreeSelectionModel;
57
 import javax.swing.tree.TreeSelectionModel;
60
 
58
 
59
+import org.slf4j.Logger;
60
+import org.slf4j.LoggerFactory;
61
+
61
 import net.engio.mbassy.listener.Handler;
62
 import net.engio.mbassy.listener.Handler;
62
 
63
 
63
 /**
64
 /**
66
 @Singleton
67
 @Singleton
67
 public class CtrlTabWindowManager {
68
 public class CtrlTabWindowManager {
68
 
69
 
70
+    private static final Logger LOG = LoggerFactory.getLogger(CtrlTabWindowManager.class);
69
     /** Node storage, used for adding and deleting nodes correctly. */
71
     /** Node storage, used for adding and deleting nodes correctly. */
70
     private final Map<TextFrame, TreeViewNode> nodes;
72
     private final Map<TextFrame, TreeViewNode> nodes;
71
     /** Data model. */
73
     /** Data model. */
74
     private final TreeScroller treeScroller;
76
     private final TreeScroller treeScroller;
75
     /** Selection model for the tree scroller. */
77
     /** Selection model for the tree scroller. */
76
     private final TreeSelectionModel selectionModel;
78
     private final TreeSelectionModel selectionModel;
77
-    /** The event bus to post errors to. */
78
-    private final DMDircMBassador eventBus;
79
 
79
 
80
     @Inject
80
     @Inject
81
     public CtrlTabWindowManager(
81
     public CtrlTabWindowManager(
82
             @GlobalConfig final AggregateConfigProvider globalConfig,
82
             @GlobalConfig final AggregateConfigProvider globalConfig,
83
             final MainFrame mainFrame,
83
             final MainFrame mainFrame,
84
-            final DMDircMBassador eventBus,
85
             final SwingEventBus swingEventBus) {
84
             final SwingEventBus swingEventBus) {
86
-        this.eventBus = eventBus;
87
         nodes = new HashMap<>();
85
         nodes = new HashMap<>();
88
         model = new TreeViewModel(globalConfig, new TreeViewNode(null, null));
86
         model = new TreeViewModel(globalConfig, new TreeViewNode(null, null));
89
         selectionModel = new DefaultTreeSelectionModel();
87
         selectionModel = new DefaultTreeSelectionModel();
146
             }
144
             }
147
             final TreeViewNode node = nodes.get(window);
145
             final TreeViewNode node = nodes.get(window);
148
             if (node.getLevel() == 0) {
146
             if (node.getLevel() == 0) {
149
-                eventBus.publishAsync(new UserErrorEvent(ErrorLevel.MEDIUM,
150
-                        new IllegalArgumentException(),
151
-                        "delServer triggered for root node" + node, ""));
147
+                LOG.warn(LogUtils.USER_ERROR, "delServer triggered for root node {}",
148
+                        node, new IllegalArgumentException());
152
             } else {
149
             } else {
153
                 model.removeNodeFromParent(nodes.get(window));
150
                 model.removeNodeFromParent(nodes.get(window));
154
             }
151
             }

+ 7
- 5
ui_swing/src/com/dmdirc/addons/ui_swing/framemanager/tree/TreeFrameManager.java 查看文件

39
 import com.dmdirc.addons.ui_swing.interfaces.ActiveFrameManager;
39
 import com.dmdirc.addons.ui_swing.interfaces.ActiveFrameManager;
40
 import com.dmdirc.events.FrameIconChangedEvent;
40
 import com.dmdirc.events.FrameIconChangedEvent;
41
 import com.dmdirc.events.UnreadStatusChangedEvent;
41
 import com.dmdirc.events.UnreadStatusChangedEvent;
42
-import com.dmdirc.events.UserErrorEvent;
43
 import com.dmdirc.interfaces.WindowModel;
42
 import com.dmdirc.interfaces.WindowModel;
44
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
43
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
45
 import com.dmdirc.interfaces.config.ConfigChangeListener;
44
 import com.dmdirc.interfaces.config.ConfigChangeListener;
46
 import com.dmdirc.interfaces.ui.Window;
45
 import com.dmdirc.interfaces.ui.Window;
47
-import com.dmdirc.logger.ErrorLevel;
48
 import com.dmdirc.plugins.PluginDomain;
46
 import com.dmdirc.plugins.PluginDomain;
49
 import com.dmdirc.ui.WindowManager;
47
 import com.dmdirc.ui.WindowManager;
50
 import com.dmdirc.ui.messages.ColourManager;
48
 import com.dmdirc.ui.messages.ColourManager;
49
+import com.dmdirc.util.LogUtils;
51
 
50
 
52
 import java.awt.Rectangle;
51
 import java.awt.Rectangle;
53
 import java.awt.event.MouseEvent;
52
 import java.awt.event.MouseEvent;
70
 
69
 
71
 import net.miginfocom.swing.MigLayout;
70
 import net.miginfocom.swing.MigLayout;
72
 
71
 
72
+import org.slf4j.Logger;
73
+import org.slf4j.LoggerFactory;
74
+
73
 import net.engio.mbassy.listener.Handler;
75
 import net.engio.mbassy.listener.Handler;
74
 import net.engio.mbassy.listener.Invoke;
76
 import net.engio.mbassy.listener.Invoke;
75
 
77
 
78
  */
80
  */
79
 public class TreeFrameManager implements FrameManager, Serializable, ConfigChangeListener {
81
 public class TreeFrameManager implements FrameManager, Serializable, ConfigChangeListener {
80
 
82
 
83
+    private static final Logger LOG = LoggerFactory.getLogger(TreeFrameManager.class);
81
     /** Serial version UID. */
84
     /** Serial version UID. */
82
     private static final long serialVersionUID = 5;
85
     private static final long serialVersionUID = 5;
83
     /** node storage, used for adding and deleting nodes correctly. */
86
     /** node storage, used for adding and deleting nodes correctly. */
195
             }
198
             }
196
             final DefaultMutableTreeNode node = nodes.get(window);
199
             final DefaultMutableTreeNode node = nodes.get(window);
197
             if (node.getLevel() == 0) {
200
             if (node.getLevel() == 0) {
198
-                eventBus.publishAsync(
199
-                        new UserErrorEvent(ErrorLevel.MEDIUM, new IllegalArgumentException(),
200
-                                "delServer triggered for root node" + node, ""));
201
+                LOG.warn(LogUtils.USER_ERROR, "delServer triggered for root node {}",
202
+                        node, new IllegalArgumentException());
201
             } else {
203
             } else {
202
                 model.removeNodeFromParent(nodes.get(window));
204
                 model.removeNodeFromParent(nodes.get(window));
203
             }
205
             }

正在加载...
取消
保存