svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / view / gui / ExtentListSelectorModel.java @ 40558
History | View | Annotate | Download (2.58 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.app.project.documents.view.gui; |
25 |
|
26 |
import java.beans.PropertyChangeEvent; |
27 |
import java.beans.PropertyChangeListener; |
28 |
import java.util.ArrayList; |
29 |
import java.util.List; |
30 |
|
31 |
import javax.swing.ListModel; |
32 |
import javax.swing.event.ListDataEvent; |
33 |
import javax.swing.event.ListDataListener; |
34 |
|
35 |
import org.gvsig.app.project.Project; |
36 |
|
37 |
public class ExtentListSelectorModel implements ListModel, |
38 |
PropertyChangeListener {
|
39 |
|
40 |
private Project project;
|
41 |
private List<ListDataListener> listeners = |
42 |
new ArrayList<ListDataListener>(); |
43 |
|
44 |
public ExtentListSelectorModel(Project p) {
|
45 |
project = p; |
46 |
} |
47 |
|
48 |
public int getSize() { |
49 |
return project.getExtents().length;
|
50 |
} |
51 |
|
52 |
public Object getElementAt(int arg0) { |
53 |
return project.getExtents()[arg0];
|
54 |
} |
55 |
|
56 |
public void addListDataListener(ListDataListener arg0) { |
57 |
listeners.add(arg0); |
58 |
} |
59 |
|
60 |
public void removeListDataListener(ListDataListener arg0) { |
61 |
listeners.remove(arg0); |
62 |
} |
63 |
|
64 |
public void propertyChange(PropertyChangeEvent change) { |
65 |
if (change.getPropertyName().equals("addExtent")) { |
66 |
ListDataEvent event =
|
67 |
new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, 0, |
68 |
getSize()); |
69 |
for (int i = 0; i < listeners.size(); i++) { |
70 |
listeners.get(i).intervalAdded(event); |
71 |
} |
72 |
} else {
|
73 |
ListDataEvent event =
|
74 |
new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, 0, |
75 |
getSize()); |
76 |
for (int i = 0; i < listeners.size(); i++) { |
77 |
listeners.get(i).intervalRemoved(event); |
78 |
} |
79 |
} |
80 |
} |
81 |
|
82 |
} |