Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extCAD / src / com / iver / cit / gvsig / NewTheme.java @ 4937

History | View | Annotate | Download (4.54 KB)

1
package com.iver.cit.gvsig;
2

    
3
import java.util.ArrayList;
4

    
5
import javax.swing.ImageIcon;
6
import javax.swing.JLabel;
7

    
8
import jwizardcomponent.example.SimpleLabelWizardPanel;
9

    
10
import com.hardcode.driverManager.Driver;
11
import com.hardcode.driverManager.DriverManager;
12
import com.iver.andami.PluginServices;
13
import com.iver.andami.plugins.Extension;
14
import com.iver.cit.gvsig.fmap.edition.ISpatialWriter;
15
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
16
import com.iver.cit.gvsig.gui.View;
17
import com.iver.cit.gvsig.gui.cad.MyFinishAction;
18
import com.iver.cit.gvsig.gui.cad.WizardAndami;
19
import com.iver.cit.gvsig.gui.cad.panels.ChooseGeometryType;
20
import com.iver.cit.gvsig.gui.cad.panels.JPanelFieldDefinition;
21
import com.iver.cit.gvsig.gui.cad.panels.PostGISpanel;
22
import com.iver.cit.gvsig.gui.cad.panels.FileBasedPanel;
23

    
24
/**
25
 * DOCUMENT ME!
26
 * 
27
 * @author Vicente Caballero Navarro
28
 */
29
public class NewTheme implements Extension {
30
        static ImageIcon LOGO;
31

    
32
        /**
33
         * @see com.iver.andami.plugins.Extension#inicializar()
34
         */
35
        public void inicializar() {
36
        }
37

    
38
        /**
39
         * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
40
         */
41
public void execute(String actionCommand) {
42
                com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
43
                                .getActiveView();
44

    
45
                if (f instanceof View) {
46
                        View vista = (View) f;
47

    
48
                        LOGO = new javax.swing.ImageIcon(this.getClass().getClassLoader()
49
                                        .getResource("images/package_graphics.png"));
50

    
51
                        /* SimpleLogoJWizardFrame wizardFrame = new SimpleLogoJWizardFrame(
52
                                        LOGO);
53
                        wizardFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
54

55
                        SwingUtilities.updateComponentTreeUI(wizardFrame);
56

57
                        wizardFrame.setTitle("Creaci?n de un nuevo Tema"); */
58
                        WizardAndami wizard = new WizardAndami(LOGO);
59

    
60
                    DriverManager writerManager = LayerFactory.getDM(); 
61
                    ArrayList spatialDrivers = new ArrayList();
62
                    String[] writerNames = writerManager.getDriverNames();
63
                        for (int i=0; i<writerNames.length; i++)
64
                        {
65
                                Driver drv = writerManager.getDriver(writerNames[i]);
66
                                if (drv instanceof ISpatialWriter)
67
                                        spatialDrivers.add(drv.getName());
68
                        }
69

    
70
                        ChooseGeometryType panelChoose = new ChooseGeometryType(wizard.getWizardComponents());
71
                        JPanelFieldDefinition panelFields = new JPanelFieldDefinition(wizard.getWizardComponents());                        
72
                        wizard.getWizardComponents().addWizardPanel(panelChoose);
73

    
74
                        wizard.getWizardComponents().addWizardPanel(panelFields);
75

    
76
                        if (actionCommand.equals("SHP"))
77
                        {
78
                                panelChoose.setDriver((ISpatialWriter) writerManager.getDriver("gvSIG shp driver"));
79
                                FileBasedPanel filePanel = new FileBasedPanel(wizard.getWizardComponents());
80
                                filePanel.setFileExtension("shp");
81
                                wizard.getWizardComponents().addWizardPanel(filePanel);
82
                                
83
                                wizard.getWizardComponents().setFinishAction(
84
                                                new MyFinishAction(wizard.getWizardComponents(),
85
                                                                vista, actionCommand));
86
                        }
87
                        if (actionCommand.equals("DXF"))
88
                        {
89
                                panelChoose.setDriver((ISpatialWriter) writerManager.getDriver("gvSIG DXF Memory Driver"));
90
                                FileBasedPanel filePanel = new FileBasedPanel(wizard.getWizardComponents());
91
                                filePanel.setFileExtension("dxf");
92
                                wizard.getWizardComponents().addWizardPanel(filePanel);
93

    
94
                        
95
                                wizard.getWizardComponents().setFinishAction(
96
                                        new MyFinishAction(wizard.getWizardComponents(),
97
                                                        vista, actionCommand));
98
                        }
99
                        if (actionCommand.equals("POSTGIS"))
100
                        {
101
                                panelChoose.setDriver((ISpatialWriter) writerManager.getDriver("PostGIS JDBC Driver"));
102
                                wizard.getWizardComponents().addWizardPanel(
103
                                        new PostGISpanel(wizard.getWizardComponents()));
104
                                
105
                                wizard.getWizardComponents().setFinishAction(
106
                                                new MyFinishAction(wizard.getWizardComponents(),
107
                                                                vista, actionCommand));
108
                        }                        
109
                        
110
                        wizard.getViewInfo().setWidth(540);
111
                        wizard.getViewInfo().setHeight(350);
112
                        wizard.getViewInfo().setTitle(PluginServices.getText(this,"new_theme"));
113
                        // Utilities.centerComponentOnScreen(wizard);
114
                        // wizardFrame.show();
115
                        PluginServices.getMDIManager().addView(wizard);
116
                        // System.out.println("Salgo con " + panelChoose.getLayerName());
117
                }
118
        }
119
        /**
120
         * @see com.iver.andami.plugins.Extension#isEnabled()
121
         */
122
        public boolean isEnabled() {
123
                View f = (View) PluginServices.getMDIManager().getActiveView();
124

    
125
                if (f == null) {
126
                        return false;
127
                } else
128
                        return true;
129
        }
130

    
131
        /**
132
         * @see com.iver.andami.plugins.Extension#isVisible()
133
         */
134
        public boolean isVisible() {
135
                com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
136
                                .getActiveView();
137

    
138
                if (f == null) {
139
                        return false;
140
                }
141

    
142
                if (f.getClass() == View.class) {
143
                        return true;
144
                } else {
145
                        return false;
146
                }
147

    
148
        }
149
}