svn-document-layout / trunk / org.gvsig.app.document.layout.app / org.gvsig.app.document.layout.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / fframes / ListViewModel.java @ 5
History | View | Annotate | Download (3.21 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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 2
|
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 |
*/
|
22 |
package org.gvsig.app.project.documents.layout.fframes; |
23 |
|
24 |
import java.util.ArrayList; |
25 |
import java.util.List; |
26 |
|
27 |
import javax.swing.AbstractListModel; |
28 |
|
29 |
import org.gvsig.andami.PluginServices; |
30 |
import org.gvsig.app.extension.ProjectExtension; |
31 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
32 |
import org.gvsig.app.project.documents.view.ViewManager; |
33 |
|
34 |
/**
|
35 |
* Modelo de la Lista de vistas a seleccionar.
|
36 |
*
|
37 |
* @author Vicente Caballero Navarro
|
38 |
*/
|
39 |
public class ListViewModel extends AbstractListModel { |
40 |
|
41 |
/**
|
42 |
*
|
43 |
*/
|
44 |
private static final long serialVersionUID = -2062563925205197480L; |
45 |
protected List<Object> views = new ArrayList<Object>(); |
46 |
|
47 |
/**
|
48 |
* A?ade las vistas que tiene el proyecto a la lista.
|
49 |
*/
|
50 |
public void addViews() { |
51 |
ProjectExtension projectextension = |
52 |
(ProjectExtension) PluginServices |
53 |
.getExtension(org.gvsig.app.extension.ProjectExtension.class); |
54 |
views = new ArrayList<Object>(); |
55 |
views.addAll(projectextension.getProject().getDocuments( |
56 |
ViewManager.TYPENAME)); |
57 |
} |
58 |
|
59 |
/**
|
60 |
* Add all fframeviews into a list.
|
61 |
*
|
62 |
* @param l
|
63 |
* Layout.
|
64 |
*/
|
65 |
public void addViews(LayoutPanel l) { |
66 |
int num = 0; |
67 |
l.getLayoutContext().updateFFrames(); |
68 |
IFFrame[] fframes = l.getLayoutContext().getFFrames();
|
69 |
for (int i = 0; i < fframes.length; i++) { |
70 |
IFFrame f = fframes[i]; |
71 |
|
72 |
if (f instanceof FFrameView) { |
73 |
// ((FFrameView)f).getView().setName("FFrameView "+num+((FFrameView)f).getName());
|
74 |
views.add(f); |
75 |
((FFrameView) f).setNum(num); |
76 |
num++; |
77 |
} |
78 |
} |
79 |
|
80 |
// ProjectExtension projectextension
|
81 |
// =(ProjectExtension)App.instance.getPc().getExtension(com.iver.cit.gvsig.ProjectExtension.class);
|
82 |
// views=projectextension.getProject().getViews();
|
83 |
} |
84 |
|
85 |
/**
|
86 |
* Devuelve el ArrayList con las FFrameView.
|
87 |
*
|
88 |
* @return DOCUMENT ME!
|
89 |
*/
|
90 |
// public ArrayList getViews() {
|
91 |
// return views;
|
92 |
// }
|
93 |
|
94 |
/**
|
95 |
* @see javax.swing.ListModel#getSize()
|
96 |
*/
|
97 |
public int getSize() { |
98 |
return views.size();
|
99 |
} |
100 |
|
101 |
/**
|
102 |
* @see javax.swing.ListModel#getElementAt(int)
|
103 |
*/
|
104 |
public Object getElementAt(int index) { |
105 |
return views.get(index);
|
106 |
} |
107 |
} |