1 /*
2
3 dsh-piccolo-identify Piccolo2D nodes for identifiable beans.
4 Copyright (c) 2007-2011 held jointly by the individual authors.
5
6 This library is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation; either version 3 of the License, or (at
9 your option) any later version.
10
11 This library is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; with out even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this library; if not, write to the Free Software Foundation,
18 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19
20 > http://www.fsf.org/licensing/licenses/lgpl.html
21 > http://www.opensource.org/licenses/lgpl-license.php
22
23 */
24 package org.dishevelled.piccolo.identify;
25
26 import ca.odell.glazedlists.EventList;
27 import ca.odell.glazedlists.ListSelection;
28
29 /**
30 * List view.
31 *
32 * @author Michael Heuer
33 * @version $Revision$ $Date$
34 */
35 public interface ListView<E, V>
36 {
37 // model
38 EventList<E> getModel();
39 void setModel(EventList<E> model);
40
41 // view <--> view mapping
42 //ViewToModel<E, V> getViewToModel();
43 //void setViewToModel(ViewToModel<E, V> viewToModel);
44 //ModelToView<E, V> getModelToView();
45 //void setModelToView(ModelToView<E, V> modelToView);
46
47 // indexed model <--> view mapping
48 IndexedViewToModel<E, V> getViewToModel();
49 void setViewToModel(IndexedViewToModel<E, V> viewToModel);
50 IndexedModelToView<E, V> getModelToView();
51 void setModelToView(IndexedModelToView<E, V> modelToView);
52
53 // selection model
54 ListSelection<E> getSelectionModel();
55 void setSelectionModel(ListSelection<E> selectionModel);
56
57 // view decorator
58 ViewDecorator<V> getViewDecorator();
59 void setViewDecorator(ViewDecorator<V> viewDecorator);
60
61
62 interface ViewToModel<E, V>
63 {
64 E get(V view);
65 }
66
67 interface ModelToView<E, V>
68 {
69 V get(E model);
70 }
71
72 // find the index of the model element mapped to a view
73 interface IndexedViewToModel<E, V>
74 {
75 int get(V view);
76 }
77
78 // find the view mapped to the index of a model element
79 interface IndexedModelToView<E, V>
80 {
81 V get(int index);
82 // todo should probably distinguish between different event types
83 //V added(int index);
84 //void removed(int index);
85 //V reordered(int oldIndex, int newIndex);
86 }
87
88 // decorate specified views per the specified state transitions
89 interface ViewDecorator<V>
90 {
91 void enable(V view);
92 void disable(V view);
93
94 void mousePressed(V view);
95 void mouseReleased(V view);
96
97 void mouseEntered(V view);
98 void mouseExited(V view);
99
100 void startDrag(V view);
101 void endDrag(V view);
102
103 void select(V view);
104 void deselect(V view);
105
106 // void anchor, lead selection
107
108 void gainFocus(V view);
109 void loseFocus(V view);
110
111 //void hide/show
112 }
113 }