Statistics
| Revision:

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

History | View | Annotate | Download (4.19 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.ShpPanel;
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
                                wizard.getWizardComponents().addWizardPanel(
80
                                        new ShpPanel(wizard.getWizardComponents()));
81
                                
82
                                wizard.getWizardComponents().setFinishAction(
83
                                                new MyFinishAction(wizard.getWizardComponents(),
84
                                                                vista, actionCommand));
85
                        }
86
                        if (actionCommand.equals("DXF"))
87
                        {
88
                                wizard.getWizardComponents().addWizardPanel(
89
                                        new SimpleLabelWizardPanel(wizard
90
                                                        .getWizardComponents(), new JLabel("Done!")));
91
                        }
92
                        if (actionCommand.equals("POSTGIS"))
93
                        {
94
                                panelChoose.setDriver((ISpatialWriter) writerManager.getDriver("PostGIS JDBC Driver"));
95
                                wizard.getWizardComponents().addWizardPanel(
96
                                        new PostGISpanel(wizard.getWizardComponents()));
97
                                
98
                                wizard.getWizardComponents().setFinishAction(
99
                                                new MyFinishAction(wizard.getWizardComponents(),
100
                                                                vista, actionCommand));
101
                        }                        
102
                        
103
                        wizard.getViewInfo().setWidth(540);
104
                        wizard.getViewInfo().setHeight(350);
105
                        wizard.getViewInfo().setTitle(PluginServices.getText(this,"new_theme"));
106
                        // Utilities.centerComponentOnScreen(wizard);
107
                        // wizardFrame.show();
108
                        PluginServices.getMDIManager().addView(wizard);
109
                        // System.out.println("Salgo con " + panelChoose.getLayerName());
110
                }
111
        }
112
        /**
113
         * @see com.iver.andami.plugins.Extension#isEnabled()
114
         */
115
        public boolean isEnabled() {
116
                View f = (View) PluginServices.getMDIManager().getActiveView();
117

    
118
                if (f == null) {
119
                        return false;
120
                } else
121
                        return true;
122
        }
123

    
124
        /**
125
         * @see com.iver.andami.plugins.Extension#isVisible()
126
         */
127
        public boolean isVisible() {
128
                com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
129
                                .getActiveView();
130

    
131
                if (f == null) {
132
                        return false;
133
                }
134

    
135
                if (f.getClass() == View.class) {
136
                        return true;
137
                } else {
138
                        return false;
139
                }
140

    
141
        }
142
}