svn-gvsig-desktop / tags / v2_0_0_Build_2061 / applications / appgvSIG / src / org / gvsig / app / project / documents / view / ViewManager.java @ 39427
History | View | Annotate | Download (7.44 KB)
1 | 29598 | jpiera | package org.gvsig.app.project.documents.view; |
---|---|---|---|
2 | 7343 | caballero | |
3 | 7738 | jaume | import javax.swing.ImageIcon; |
4 | |||
5 | 38564 | jjdelcerro | import org.gvsig.andami.IconThemeHelper; |
6 | 29598 | jpiera | import org.gvsig.andami.PluginServices; |
7 | 31496 | jjdelcerro | import org.gvsig.andami.ui.mdiManager.IWindow; |
8 | import org.gvsig.app.project.ProjectManager; |
||
9 | import org.gvsig.app.project.documents.AbstractDocument; |
||
10 | import org.gvsig.app.project.documents.AbstractDocumentManager; |
||
11 | 33659 | fdiaz | import org.gvsig.app.project.documents.Document; |
12 | 31496 | jjdelcerro | import org.gvsig.app.project.documents.actions.CopyDocumentAction; |
13 | import org.gvsig.app.project.documents.actions.CutDocumentAction; |
||
14 | import org.gvsig.app.project.documents.actions.PasteDocumentAction; |
||
15 | 35193 | jjdelcerro | import org.gvsig.app.project.documents.gui.IDocumentWindow; |
16 | 31496 | jjdelcerro | import org.gvsig.app.project.documents.gui.WindowLayout; |
17 | import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
||
18 | import org.gvsig.app.project.documents.view.gui.ViewProperties; |
||
19 | 33659 | fdiaz | import org.gvsig.fmap.mapcontext.MapContext; |
20 | 38564 | jjdelcerro | import org.gvsig.fmap.mapcontext.MapContextLocator; |
21 | import org.gvsig.fmap.mapcontext.MapContextManager; |
||
22 | 33659 | fdiaz | import org.gvsig.tools.ToolsLocator; |
23 | import org.gvsig.tools.dynobject.DynStruct; |
||
24 | import org.gvsig.tools.persistence.PersistenceManager; |
||
25 | 38564 | jjdelcerro | import org.slf4j.Logger; |
26 | import org.slf4j.LoggerFactory; |
||
27 | 20994 | jmvivo | |
28 | 7343 | caballero | /**
|
29 | * Factory of View.
|
||
30 | *
|
||
31 | 31496 | jjdelcerro | * @author 2005- Vicente Caballero
|
32 | * @author 2009- Joaquin del Cerro
|
||
33 | *
|
||
34 | 7343 | caballero | */
|
35 | 31496 | jjdelcerro | public class ViewManager extends AbstractDocumentManager { |
36 | 35193 | jjdelcerro | private static final Logger logger = LoggerFactory.getLogger(ViewManager.class); |
37 | |||
38 | 33659 | fdiaz | private static final String PERSISTENCE_VIEW_DOCUMENT_DEFINITION_NAME = |
39 | "DefaultViewDocument";
|
||
40 | 31496 | jjdelcerro | public static String TYPENAME = "project.document.view2d"; |
41 | 33659 | fdiaz | private DynStruct persistenceDefinition;
|
42 | 31496 | jjdelcerro | |
43 | public ViewManager() {
|
||
44 | // Do nothing
|
||
45 | } |
||
46 | |||
47 | public int getPriority() { |
||
48 | return 0; |
||
49 | } |
||
50 | 7343 | caballero | |
51 | 31496 | jjdelcerro | public ImageIcon getIcon() { |
52 | 15945 | jmvivo | return PluginServices.getIconTheme().get("document-view-icon"); |
53 | 7343 | caballero | } |
54 | |||
55 | 31496 | jjdelcerro | public ImageIcon getIconSelected() { |
56 | 15945 | jmvivo | return PluginServices.getIconTheme().get("document-view-icon-sel"); |
57 | 7343 | caballero | } |
58 | |||
59 | 31496 | jjdelcerro | public String getTitle() { |
60 | return PluginServices.getText(this, "Vista"); |
||
61 | } |
||
62 | 7343 | caballero | |
63 | 31496 | jjdelcerro | public String getTypeName() { |
64 | return TYPENAME;
|
||
65 | 7343 | caballero | } |
66 | 35193 | jjdelcerro | |
67 | public Class getMainWindowClass() { |
||
68 | return DefaultViewPanel.class;
|
||
69 | } |
||
70 | |||
71 | 31496 | jjdelcerro | public AbstractDocument createDocument() { |
72 | return new DefaultViewDocument(this); |
||
73 | 7343 | caballero | } |
74 | |||
75 | 31496 | jjdelcerro | public IWindow getMainWindow(Document doc, WindowLayout layout) { |
76 | 35193 | jjdelcerro | IDocumentWindow view; |
77 | |||
78 | view = (IDocumentWindow) PluginServices.getMDIManager().getSingletonWindow(getMainWindowClass(), doc); |
||
79 | if( view != null ) { |
||
80 | // The view window document is already created, return it.
|
||
81 | return view;
|
||
82 | } |
||
83 | view = this.createDocumentWindow(doc);
|
||
84 | if ( layout != null && view != null ) { |
||
85 | 31496 | jjdelcerro | view.setWindowLayout(layout); |
86 | } |
||
87 | ((AbstractDocument) doc).raiseEventCreateWindow(view);
|
||
88 | return view;
|
||
89 | } |
||
90 | 7343 | caballero | |
91 | 31496 | jjdelcerro | public IWindow getPropertiesWindow(Document doc) { |
92 | return new ViewProperties((DefaultViewDocument) doc); |
||
93 | } |
||
94 | 7343 | caballero | |
95 | /**
|
||
96 | * Registers in the points of extension the Factory with alias.
|
||
97 | *
|
||
98 | */
|
||
99 | public static void register() { |
||
100 | 33659 | fdiaz | ViewManager factory = new ViewManager();
|
101 | ProjectManager.getInstance().registerDocumentFactory(factory); |
||
102 | |||
103 | PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
||
104 | manager.registerFactory(factory); |
||
105 | 7787 | jaume | |
106 | 33659 | fdiaz | |
107 | 31496 | jjdelcerro | ProjectManager.getInstance().registerDocumentAction(TYPENAME,new CopyDocumentAction());
|
108 | ProjectManager.getInstance().registerDocumentAction(TYPENAME,new CutDocumentAction());
|
||
109 | ProjectManager.getInstance().registerDocumentAction(TYPENAME,new PasteDocumentAction());
|
||
110 | 14821 | jmvivo | |
111 | 38564 | jjdelcerro | IconThemeHelper.registerIcon("document", "document-view-icon", ViewManager.class); |
112 | IconThemeHelper.registerIcon("document", "document-view-icon-sel", ViewManager.class); |
||
113 | |||
114 | IconThemeHelper.registerIcon("cursor", "cursor-crux", ViewManager.class); |
||
115 | IconThemeHelper.registerIcon("cursor", "cursor-info-by-point", ViewManager.class); |
||
116 | IconThemeHelper.registerIcon("cursor", "cursor-pan", ViewManager.class); |
||
117 | IconThemeHelper.registerIcon("cursor", "cursor-query-area", ViewManager.class); |
||
118 | IconThemeHelper.registerIcon("cursor", "cursor-select-by-point", ViewManager.class); |
||
119 | IconThemeHelper.registerIcon("cursor", "cursor-select-by-polygon", ViewManager.class); |
||
120 | IconThemeHelper.registerIcon("cursor", "cursor-zoom-in", ViewManager.class); |
||
121 | IconThemeHelper.registerIcon("cursor", "cursor-zoom-out", ViewManager.class); |
||
122 | 14821 | jmvivo | |
123 | 38564 | jjdelcerro | IconThemeHelper.registerIcon("layer", "layer-icon", ViewManager.class); |
124 | IconThemeHelper.registerIcon("layer", "layer-icon-group", ViewManager.class); |
||
125 | IconThemeHelper.registerIcon("layer", "layer-icon-vectorial", ViewManager.class); |
||
126 | IconThemeHelper.registerIcon("layer", "layer-icon-dgn", ViewManager.class); |
||
127 | IconThemeHelper.registerIcon("layer", "layer-icon-dxf", ViewManager.class); |
||
128 | 38640 | jldominguez | IconThemeHelper.registerIcon("layer", "layer-icon-postgresql", ViewManager.class); |
129 | 38564 | jjdelcerro | IconThemeHelper.registerIcon("layer", "layer-icon-mysql", ViewManager.class); |
130 | IconThemeHelper.registerIcon("layer", "layer-icon-jdbc", ViewManager.class); |
||
131 | 38989 | nbrodin | IconThemeHelper.registerIcon("layer", "layer-icon-unavailable", ViewManager.class); |
132 | 14821 | jmvivo | |
133 | 38564 | jjdelcerro | IconThemeHelper.registerIcon("legend", "legend-overview-single-symbol", ViewManager.class); |
134 | IconThemeHelper.registerIcon("legend", "legend-overview-vectorial-interval", ViewManager.class); |
||
135 | IconThemeHelper.registerIcon("legend", "legend-overview-vectorial-unique-value", ViewManager.class); |
||
136 | 20334 | vcaballero | |
137 | 38564 | jjdelcerro | MapContextManager mapContextMgr = MapContextLocator.getMapContextManager(); |
138 | mapContextMgr.registerIconLayer("DGN", "layer-icon-dgn"); |
||
139 | 39094 | jldominguez | mapContextMgr.registerIconLayer("DXF", "layer-icon-dxf"); |
140 | 38564 | jjdelcerro | mapContextMgr.registerIconLayer("jdbc", "layer-icon-jdbc"); |
141 | mapContextMgr.registerIconLayer("PostgreSQL", "layer-icon-postgresql"); |
||
142 | mapContextMgr.registerIconLayer("MySQL", "layer-icon-mysql"); |
||
143 | |||
144 | 33659 | fdiaz | if (factory.persistenceDefinition == null){ |
145 | factory.persistenceDefinition = manager.addDefinition( |
||
146 | ViewDocument.class, |
||
147 | PERSISTENCE_VIEW_DOCUMENT_DEFINITION_NAME, |
||
148 | "Default view document persistence definition",
|
||
149 | null,
|
||
150 | null
|
||
151 | ); |
||
152 | factory.persistenceDefinition.extend(manager.getDefinition(AbstractDocument.PERSISTENCE_DEFINITION_NAME));
|
||
153 | 14821 | jmvivo | |
154 | 33659 | fdiaz | factory.persistenceDefinition.addDynFieldBoolean("useMapOverview").setMandatory(true); |
155 | factory.persistenceDefinition.addDynFieldObject("mainMapContext").setClassOfValue(MapContext.class).setMandatory(true); |
||
156 | factory.persistenceDefinition.addDynFieldObject("overviewMapContext").setClassOfValue(MapContext.class).setMandatory(false); |
||
157 | 7343 | caballero | |
158 | 33659 | fdiaz | } |
159 | 7758 | jmvivo | |
160 | 7787 | jaume | |
161 | 33659 | fdiaz | } |
162 | 7787 | jaume | |
163 | 33659 | fdiaz | @SuppressWarnings("rawtypes") |
164 | public DynStruct getDefinition(String className) { |
||
165 | 7758 | jmvivo | |
166 | 33659 | fdiaz | if( this.persistenceDefinition.getName().equalsIgnoreCase(className)) { |
167 | return this.persistenceDefinition; |
||
168 | } |
||
169 | if( this.persistenceDefinition.getFullName().equalsIgnoreCase(className)) { |
||
170 | return this.persistenceDefinition; |
||
171 | } |
||
172 | if( this.getDocumentClass().getName().equals(className) ) { |
||
173 | return this.persistenceDefinition; |
||
174 | } |
||
175 | 7787 | jaume | |
176 | 33659 | fdiaz | return null; |
177 | } |
||
178 | |||
179 | @SuppressWarnings("rawtypes") |
||
180 | protected Class getDocumentClass() { |
||
181 | return DefaultViewDocument.class;
|
||
182 | } |
||
183 | |||
184 | 36443 | cordinyana | public boolean manages(Object object) { |
185 | return object instanceof ViewDocument; |
||
186 | } |
||
187 | 7343 | caballero | } |