root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / TableManageFields.java @ 6877
History | View | Annotate | Download (3.75 KB)
1 |
/*
|
---|---|
2 |
* Created on 02-mar-2004
|
3 |
*
|
4 |
* To change the template for this generated file go to
|
5 |
* Window>Preferences>Java>Code Generation>Code and Comments
|
6 |
*/
|
7 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
8 |
*
|
9 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
10 |
*
|
11 |
* This program is free software; you can redistribute it and/or
|
12 |
* modify it under the terms of the GNU General Public License
|
13 |
* as published by the Free Software Foundation; either version 2
|
14 |
* of the License, or (at your option) any later version.
|
15 |
*
|
16 |
* This program is distributed in the hope that it will be useful,
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
* GNU General Public License for more details.
|
20 |
*
|
21 |
* You should have received a copy of the GNU General Public License
|
22 |
* along with this program; if not, write to the Free Software
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
24 |
*
|
25 |
* For more information, contact:
|
26 |
*
|
27 |
* Generalitat Valenciana
|
28 |
* Conselleria d'Infraestructures i Transport
|
29 |
* Av. Blasco Ib??ez, 50
|
30 |
* 46010 VALENCIA
|
31 |
* SPAIN
|
32 |
*
|
33 |
* +34 963862235
|
34 |
* gvsig@gva.es
|
35 |
* www.gvsig.gva.es
|
36 |
*
|
37 |
* or
|
38 |
*
|
39 |
* IVER T.I. S.A
|
40 |
* Salamanca 50
|
41 |
* 46005 Valencia
|
42 |
* Spain
|
43 |
*
|
44 |
* +34 963163400
|
45 |
* dac@iver.es
|
46 |
*/
|
47 |
package com.iver.cit.gvsig; |
48 |
|
49 |
import com.iver.andami.PluginServices; |
50 |
import com.iver.andami.plugins.Extension; |
51 |
import com.iver.andami.ui.mdiManager.IWindow; |
52 |
import com.iver.cit.gvsig.fmap.edition.EditableAdapter; |
53 |
import com.iver.cit.gvsig.fmap.edition.IEditableSource; |
54 |
import com.iver.cit.gvsig.fmap.edition.IWriteable; |
55 |
import com.iver.cit.gvsig.fmap.edition.IWriter; |
56 |
import com.iver.cit.gvsig.gui.Table; |
57 |
import com.iver.cit.gvsig.gui.dialogs.DlgFieldManager; |
58 |
import com.iver.cit.gvsig.project.ProjectTable; |
59 |
|
60 |
|
61 |
/**
|
62 |
* Extensi?n que abre las tablas asociadas a las vistas.
|
63 |
*
|
64 |
* @author Vicente Caballero Navarro
|
65 |
*/
|
66 |
public class TableManageFields extends Extension { |
67 |
|
68 |
/**
|
69 |
* @see com.iver.mdiApp.plugins.IExtension#updateUI(java.lang.String)
|
70 |
*/
|
71 |
public void execute(String s) { |
72 |
IWindow v = PluginServices.getMDIManager().getActiveView(); |
73 |
|
74 |
Table t = (Table) v; |
75 |
ProjectTable pt = t.getModel(); |
76 |
IEditableSource ies = pt.getModelo(); |
77 |
if (ies.getOriginalDriver() instanceof IWriteable) |
78 |
{ |
79 |
IWriteable aux = (IWriteable) ies.getOriginalDriver(); |
80 |
IWriter writer = aux.getWriter(); |
81 |
// No todos los writer pueden cambiar los campos (ejemplo: el dxf
|
82 |
// o el dgn siempre tienen los mismos campos).
|
83 |
if (writer.canAlterTable())
|
84 |
{ |
85 |
// IFieldManager fieldManager = (IFieldManager) writer;
|
86 |
DlgFieldManager dlg = new DlgFieldManager(ies);
|
87 |
PluginServices.getMDIManager().addView(dlg); |
88 |
} |
89 |
} |
90 |
|
91 |
} |
92 |
|
93 |
/**
|
94 |
* @see com.iver.andami.plugins.IExtension#initialize()
|
95 |
*/
|
96 |
public void initialize() { |
97 |
} |
98 |
|
99 |
public boolean isEnabled() { |
100 |
IWindow v = PluginServices.getMDIManager().getActiveView(); |
101 |
|
102 |
if (v == null) { |
103 |
return false; |
104 |
} |
105 |
|
106 |
if (v instanceof Table) { |
107 |
Table t = (Table) v; |
108 |
IEditableSource ies = t.getModel().getModelo(); |
109 |
// ProjectTable pt = t.getModel();
|
110 |
if (ies.getOriginalDriver() instanceof IWriteable) |
111 |
{ |
112 |
IWriter writer = ((IWriteable) ies.getOriginalDriver()).getWriter(); |
113 |
if ((writer != null) && (writer.canAlterTable())) |
114 |
{ |
115 |
if (ies.isEditing())
|
116 |
{ |
117 |
return true; |
118 |
} |
119 |
} |
120 |
} |
121 |
} |
122 |
return false; |
123 |
} |
124 |
|
125 |
/**
|
126 |
* @see com.iver.andami.plugins.IExtension#isVisible()
|
127 |
*/
|
128 |
public boolean isVisible() { |
129 |
IWindow v = PluginServices.getMDIManager().getActiveView(); |
130 |
|
131 |
if (v == null) { |
132 |
return false; |
133 |
} |
134 |
|
135 |
if (v instanceof Table) { |
136 |
return true; |
137 |
} |
138 |
return false; |
139 |
} |
140 |
|
141 |
} |