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 // nothing to do
43 }
44
45 /**
46 * Add listener.
47 *
48 * @param list Add this listener.
49 */
50 public final void addListener(final SelectionListener list) {
51 listeners.add(list);
52 }
53
54 /**
55 * Remove listener.
56 *
57 * @param list Remove this listener.
58 */
59 public final void removeListener(final SelectionListener list) {
60 listeners.remove(list);
61 }
62
63 public void selectError(final int number, final SourceFileException sf) {
64 for (int i = 0; i < listeners.size(); i++) {
65 try { // we don't know if the ModuleEventListener is free of programming errors...
66 ((SelectionListener) listeners.get(i)).selectError(number, sf);
67 } catch (RuntimeException e) {
68 Trace.fatal(CLASS, this, "selectError",
69 "SelectionListener throwed RuntimeException", e);
70 }
71 }
72 }
73
74 public void selectWarning(final int number, final SourceFileException sf) {
75 for (int i = 0; i < listeners.size(); i++) {
76 try { // we don't know if the ModuleEventListener is free of programming errors...
77 ((SelectionListener) listeners.get(i)).selectWarning(number, sf);
78 } catch (RuntimeException e) {
79 Trace.fatal(CLASS, this, "selectWarning",
80 "SelectionListener throwed RuntimeException", e);
81 }
82 }
83 }
84 }
|