PageRenderTime 54ms CodeModel.GetById 13ms app.highlight 34ms RepoModel.GetById 1ms app.codeStats 0ms

/v3.2/nimbits-tds/src/com/nimbits/client/panels/NavigationEventProvider.java

http://nimbits-server.googlecode.com/
Java | 178 lines | 119 code | 41 blank | 18 comment | 9 complexity | fa8ee30089a9de29410e339475daafe8 MD5 | raw file
  1/*
  2 * Copyright (c) 2010 Tonic Solutions LLC.
  3 *
  4 * http://www.nimbits.com
  5 *
  6 *
  7 * Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
  8 *
  9 * http://www.gnu.org/licenses/gpl.html
 10 *
 11 * Unless required by applicable law or agreed to in writing, software distributed under the license is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 12 */
 13
 14package com.nimbits.client.panels;
 15
 16import com.extjs.gxt.ui.client.widget.LayoutContainer;
 17import com.nimbits.client.exception.NimbitsException;
 18import com.nimbits.client.model.category.Category;
 19import com.nimbits.client.model.diagram.Diagram;
 20import com.nimbits.client.model.point.Point;
 21import com.nimbits.client.model.value.Value;
 22
 23import java.util.ArrayList;
 24import java.util.List;
 25
 26public abstract class NavigationEventProvider extends LayoutContainer {
 27    private final List<CategoryClickedListener> categoryClickedListeners = new ArrayList<CategoryClickedListener>();
 28    private final List<PointDeletedListener> pointDeletedListeners = new ArrayList<PointDeletedListener>();
 29    private final List<PointClickedListener> pointClickedListeners = new ArrayList<PointClickedListener>();
 30    private final List<DiagramClickedListener> diagramClickedListeners = new ArrayList<DiagramClickedListener>();
 31    private final List<UrlClickedListener> urlClickedListeners = new ArrayList<UrlClickedListener>();
 32    private final List<DiagramDeletedListener> diagramDeletedListeners = new ArrayList<DiagramDeletedListener>();
 33    private final List<ValueEnteredListener> valueEnteredListeners = new ArrayList<ValueEnteredListener>();
 34    private final List<ChartRemovedListener> chartRemovedListeners = new ArrayList<ChartRemovedListener>();
 35    private final List<DiagramRemovedListener> diagramRemovedListeners = new ArrayList<DiagramRemovedListener>();
 36
 37    // Category Click Handlers
 38    public interface CategoryClickedListener {
 39        void onCategoryClicked(final Category c, final boolean readOnly) throws NimbitsException;
 40    }
 41
 42    public void addCategoryClickedListeners(final CategoryClickedListener listener) {
 43        categoryClickedListeners.add(listener);
 44    }
 45
 46    void notifyCategoryClickedListener(final Category c, final boolean readOnly) throws NimbitsException {
 47        for (CategoryClickedListener categoryClickedListener : categoryClickedListeners) {
 48            categoryClickedListener.onCategoryClicked(c, readOnly);
 49        }
 50    }
 51
 52    // ChartRemoved Click Handlers
 53    public interface ChartRemovedListener {
 54        void onChartRemovedClicked(final String chartName);
 55    }
 56
 57    void addChartRemovedClickedListeners(final ChartRemovedListener listener) {
 58        chartRemovedListeners.add(listener);
 59    }
 60
 61    void notifyChartRemovedListener(final String chartName) {
 62        for (ChartRemovedListener ChartRemovedClickedListener : chartRemovedListeners) {
 63            ChartRemovedClickedListener.onChartRemovedClicked(chartName);
 64        }
 65    }
 66
 67    // Value entered Handlers
 68    public interface ValueEnteredListener {
 69        void onValueEntered(final Point point, final Value value);
 70
 71    }
 72
 73    void addValueEnteredListeners(final ValueEnteredListener listener) {
 74        valueEnteredListeners.add(listener);
 75    }
 76
 77    void notifyValueEnteredListener(final Point point, final Value value) {
 78        for (final ValueEnteredListener valueEnteredListener : valueEnteredListeners) {
 79            valueEnteredListener.onValueEntered(point, value);
 80        }
 81    }
 82
 83    // Point Click Handlers
 84    public interface PointClickedListener {
 85        void onPointClicked(final Point c);
 86
 87    }
 88
 89    public void addPointClickedListeners(final PointClickedListener listener) {
 90        pointClickedListeners.add(listener);
 91    }
 92
 93    void notifyPointClickedListener(final Point c) {
 94
 95        for (PointClickedListener pointClickedListener : pointClickedListeners) {
 96            pointClickedListener.onPointClicked(c);
 97        }
 98    }
 99
100    // Diagram Click Handlers
101    public interface DiagramClickedListener {
102        void onDiagramClicked(final Diagram d);
103
104    }
105
106    public void addDiagramClickedListeners(final DiagramClickedListener listener) {
107        diagramClickedListeners.add(listener);
108    }
109
110    void notifyDiagramClickedListener(final Diagram d) {
111        for (DiagramClickedListener diagramClickedListener : diagramClickedListeners) {
112            diagramClickedListener.onDiagramClicked(d);
113        }
114    }
115
116    // Diagram Click Handlers
117    public interface UrlClickedListener {
118        void onUrlClicked(final String url, final String target);
119
120    }
121
122    public void addUrlClickedListeners(final UrlClickedListener listener) {
123        urlClickedListeners.add(listener);
124    }
125
126    void notifyUrlClickedListener(final String url, final String target) {
127        for (UrlClickedListener urlClickedListener : urlClickedListeners) {
128            urlClickedListener.onUrlClicked(url, target);
129        }
130    }
131
132    public interface DiagramDeletedListener {
133        void onDiagramDeleted(final Diagram c, final boolean readOnly) throws NimbitsException;
134
135    }
136
137    void addDiagramDeletedListeners(final DiagramDeletedListener listener) {
138        diagramDeletedListeners.add(listener);
139    }
140
141    void notifyDiagramDeletedListener(final Diagram c, final boolean readOnly) throws NimbitsException {
142        for (DiagramDeletedListener diagramDeletedListener : diagramDeletedListeners) {
143            diagramDeletedListener.onDiagramDeleted(c, readOnly);
144        }
145    }
146
147    public interface DiagramRemovedListener {
148        void onDiagramRemovedClicked(final Diagram diagram);
149    }
150
151    void addDiagramRemovedClickedListeners(final DiagramRemovedListener listener) {
152        diagramRemovedListeners.add(listener);
153    }
154
155    void notifyDiagramRemovedListener(final Diagram diagram) {
156        for (DiagramRemovedListener diagramRemovedClickedListener : diagramRemovedListeners) {
157            diagramRemovedClickedListener.onDiagramRemovedClicked(diagram);
158        }
159    }
160
161
162    public interface PointDeletedListener {
163        void onPointDeleted(Point c) throws NimbitsException;
164
165    }
166
167    void addPointDeletedListeners(PointDeletedListener listener) {
168        pointDeletedListeners.add(listener);
169    }
170
171    void notifyPointDeletedListener(Point c) throws NimbitsException {
172        for (PointDeletedListener pointDeletedListener : pointDeletedListeners) {
173            pointDeletedListener.onPointDeleted(c);
174        }
175    }
176
177
178}