01 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
02 *
03 * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
04 *
05 * "Hilbert II" is free software; you can redistribute
06 * it and/or modify it under the terms of the GNU General Public
07 * License as published by the Free Software Foundation; either
08 * version 2 of the License, or (at your option) any later version.
09 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16 package org.qedeq.gui.se.control;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.qedeq.base.trace.Trace;
22 import org.qedeq.kernel.se.common.SourceFileException;
23
24
25 /**
26 * This class organizes the listening to error and warning selection events.
27 *
28 * @author Michael Meyling
29 */
30 public final class SelectionListenerList implements SelectionListener {
31
32 /** This class. */
33 private static final Class CLASS = SelectionListenerList.class;
34
35 /** The loggers. */
36 private List listeners = new ArrayList();
37
38 /**
39 * Constructor.
40 */
41 public SelectionListenerList() {
42 }
43
44 /**
45 * Add listener.
46 *
47 * @param list Add this listener.
48 */
49 public final void addListener(final SelectionListener list) {
50 listeners.add(list);
51 }
52
53 /**
54 * Remove listener.
55 *
56 * @param list Remove this listener.
57 */
58 public final void removeListener(final SelectionListener list) {
59 listeners.remove(list);
60 }
61
62 public void selectError(final int number, final SourceFileException sf) {
63 for (int i = 0; i < listeners.size(); i++) {
64 try { // we don't know if the ModuleEventListener is free of programming errors...
65 ((SelectionListener) listeners.get(i)).selectError(number, sf);
66 } catch (RuntimeException e) {
67 Trace.fatal(CLASS, this, "selectError",
68 "SelectionListener throwed RuntimeException", e);
69 }
70 }
71 }
72
73 public void selectWarning(final int number, final SourceFileException sf) {
74 for (int i = 0; i < listeners.size(); i++) {
75 try { // we don't know if the ModuleEventListener is free of programming errors...
76 ((SelectionListener) listeners.get(i)).selectWarning(number, sf);
77 } catch (RuntimeException e) {
78 Trace.fatal(CLASS, this, "selectWarning",
79 "SelectionListener throwed RuntimeException", e);
80 }
81 }
82 }
83 }
|