svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / Tabla.java @ 449
History | View | Annotate | Download (2.6 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 |
package com.iver.cit.gvsig; |
8 |
|
9 |
import com.hardcode.driverManager.DriverLoadException; |
10 |
import com.hardcode.gdbms.engine.data.DataSource; |
11 |
import com.iver.cit.gvsig.fmap.layers.CommonOperations; |
12 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
13 |
import com.iver.cit.gvsig.gui.Table; |
14 |
import com.iver.cit.gvsig.gui.View; |
15 |
import com.iver.cit.gvsig.project.ProjectFactory; |
16 |
import com.iver.cit.gvsig.project.castor.ProjectTable; |
17 |
import com.iver.mdiApp.App; |
18 |
import com.iver.mdiApp.AppStatus; |
19 |
import com.iver.mdiApp.plugins.AbstractExtension; |
20 |
|
21 |
/**
|
22 |
* DOCUMENT ME!
|
23 |
*
|
24 |
* @author vcn To change the template for this generated type comment go to
|
25 |
* Window>Preferences>Java>Code Generation>Code and
|
26 |
* Comments
|
27 |
*/
|
28 |
public class Tabla extends AbstractExtension { |
29 |
/**
|
30 |
* DOCUMENT ME!
|
31 |
*
|
32 |
* @return DOCUMENT ME!
|
33 |
*/
|
34 |
public boolean isEnabled() { |
35 |
View f = (View) App.instance.getMDIContext().getActiveView(); |
36 |
|
37 |
if (f == null) { |
38 |
return false; |
39 |
} |
40 |
|
41 |
FLayer[] selected = f.getModel().getMapContext().getLayers().getActives();
|
42 |
|
43 |
return selected.length > 0; |
44 |
} |
45 |
|
46 |
/**
|
47 |
* DOCUMENT ME!
|
48 |
*
|
49 |
* @return DOCUMENT ME!
|
50 |
*/
|
51 |
public boolean isVisible() { |
52 |
com.iver.mdiApp.ui.MDIManager.View f = App.instance.getMDIContext().getActiveView(); |
53 |
|
54 |
if (f == null) { |
55 |
return false; |
56 |
} |
57 |
|
58 |
return (f.getClass() == View.class); |
59 |
} |
60 |
|
61 |
/**
|
62 |
* DOCUMENT ME!
|
63 |
*
|
64 |
* @param s DOCUMENT ME!
|
65 |
*/
|
66 |
public void updateUI(AppStatus status, String s) { |
67 |
View vista = (View) status.getActiveView(); |
68 |
FLayer[] actives = ((View) vista).getModel().getMapContext().getLayers().getActives(); |
69 |
|
70 |
for (int i = 0; i < actives.length; i++) { |
71 |
if (actives[i] instanceof CommonOperations){ |
72 |
CommonOperations co = (CommonOperations)actives[i]; |
73 |
try {
|
74 |
Table t = new Table();
|
75 |
DataSource dataSource = co.getRecordset();
|
76 |
t.setModel(dataSource); |
77 |
App.instance.getMDIContext().addView(t); |
78 |
|
79 |
ProjectExtension ext = (ProjectExtension) App.instance.getPc().getExtension(ProjectExtension.class); |
80 |
ProjectTable projectTable = ProjectFactory.createTable(vista.getModel().getName()); |
81 |
projectTable.setModelo(dataSource); |
82 |
t.setModel(dataSource); |
83 |
ext.getProject().addTable(projectTable); |
84 |
} catch (DriverLoadException e) {
|
85 |
App.instance.getNm().addError("Error al cargar los drivers", e);
|
86 |
} |
87 |
} |
88 |
} |
89 |
|
90 |
} |
91 |
} |