svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / fframes / ListViewModel.java @ 324
History | View | Annotate | Download (3.88 KB)
1 | 5 | jldominguez | /* 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 | 93 | jldominguez | import org.gvsig.app.project.documents.Document; |
32 | import org.gvsig.app.project.documents.layout.FLayoutUtilities; |
||
33 | 5 | jldominguez | import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
34 | 93 | jldominguez | import org.gvsig.app.project.documents.view.ViewDocument; |
35 | 5 | jldominguez | import org.gvsig.app.project.documents.view.ViewManager; |
36 | 93 | jldominguez | import org.gvsig.fmap.mapcontext.layers.FLayer; |
37 | import org.gvsig.fmap.mapcontext.layers.FLayers; |
||
38 | import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
||
39 | 213 | cmartinez | import org.gvsig.gui.beans.Messages; |
40 | 5 | jldominguez | |
41 | /**
|
||
42 | * Modelo de la Lista de vistas a seleccionar.
|
||
43 | *
|
||
44 | * @author Vicente Caballero Navarro
|
||
45 | */
|
||
46 | public class ListViewModel extends AbstractListModel { |
||
47 | |||
48 | /**
|
||
49 | *
|
||
50 | */
|
||
51 | private static final long serialVersionUID = -2062563925205197480L; |
||
52 | protected List<Object> views = new ArrayList<Object>(); |
||
53 | 213 | cmartinez | |
54 | public static final String CREATE_NEW_VIEW_OBJECT = "["+Messages.getText("Create_new_view")+"]"; |
||
55 | 5 | jldominguez | |
56 | /**
|
||
57 | 93 | jldominguez | * Adds project's views to its list. Returns true if some
|
58 | * views where excluded because they have layers in editing mode
|
||
59 | *
|
||
60 | * @return
|
||
61 | 5 | jldominguez | */
|
62 | 93 | jldominguez | public boolean addViews() { |
63 | 5 | jldominguez | ProjectExtension projectextension = |
64 | (ProjectExtension) PluginServices |
||
65 | .getExtension(org.gvsig.app.extension.ProjectExtension.class); |
||
66 | 93 | jldominguez | |
67 | List<Document> list = |
||
68 | projectextension.getProject().getDocuments(ViewManager.TYPENAME); |
||
69 | |||
70 | int before = list.size();
|
||
71 | list = FLayoutUtilities.removeEditing(list); |
||
72 | int after = list.size();
|
||
73 | |||
74 | views.addAll(list); |
||
75 | |||
76 | return (before > after);
|
||
77 | 5 | jldominguez | } |
78 | 213 | cmartinez | |
79 | /**
|
||
80 | * Adds an special "Create new view" element to the list of available
|
||
81 | * views. This special element flags the creation of a new view
|
||
82 | *
|
||
83 | */
|
||
84 | public void addCreateNewViewObj() { |
||
85 | if (!views.contains(CREATE_NEW_VIEW_OBJECT)) {
|
||
86 | views.add(CREATE_NEW_VIEW_OBJECT); |
||
87 | } |
||
88 | } |
||
89 | 5 | jldominguez | |
90 | /**
|
||
91 | * Add all fframeviews into a list.
|
||
92 | *
|
||
93 | * @param l
|
||
94 | * Layout.
|
||
95 | */
|
||
96 | public void addViews(LayoutPanel l) { |
||
97 | int num = 0; |
||
98 | l.getLayoutContext().updateFFrames(); |
||
99 | IFFrame[] fframes = l.getLayoutContext().getFFrames();
|
||
100 | for (int i = 0; i < fframes.length; i++) { |
||
101 | IFFrame f = fframes[i]; |
||
102 | |||
103 | if (f instanceof FFrameView) { |
||
104 | views.add(f); |
||
105 | ((FFrameView) f).setNum(num); |
||
106 | num++; |
||
107 | } |
||
108 | } |
||
109 | } |
||
110 | |||
111 | /**
|
||
112 | * @see javax.swing.ListModel#getSize()
|
||
113 | */
|
||
114 | public int getSize() { |
||
115 | return views.size();
|
||
116 | } |
||
117 | |||
118 | /**
|
||
119 | * @see javax.swing.ListModel#getElementAt(int)
|
||
120 | */
|
||
121 | public Object getElementAt(int index) { |
||
122 | return views.get(index);
|
||
123 | } |
||
124 | 69 | jldominguez | |
125 | public boolean removeFrameView(FFrameView v) { |
||
126 | return views.remove(v);
|
||
127 | } |
||
128 | 5 | jldominguez | } |