Statistics
| Revision:

gvsig-catalog / org.gvsig.catalog / branches / org.gvsig.catalog-CSW2.0.2 / org.gvsig.catalog / org.gvsig.catalog.extension / src / main / java / org / gvsig / catalog / gui / ChooseResourceDialog.java @ 63

History | View | Annotate | Download (3.91 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.catalog.gui;
42

    
43
import java.lang.reflect.InvocationTargetException;
44
import java.util.Collection;
45

    
46
import javax.swing.JOptionPane;
47

    
48
import org.gvsig.andami.PluginServices;
49
import org.gvsig.andami.ui.mdiManager.IWindow;
50
import org.gvsig.andami.ui.mdiManager.WindowInfo;
51
import org.gvsig.catalog.CatalogLocator;
52
import org.gvsig.catalog.CatalogManager;
53
import org.gvsig.catalog.loaders.LayerLoader;
54
import org.gvsig.catalog.loaders.LayerLoaderException;
55
import org.gvsig.catalog.schemas.Resource;
56
import org.gvsig.catalog.ui.chooseresource.ChooseResourceDialogPanel;
57
import org.gvsig.i18n.Messages;
58

    
59

    
60

    
61
/**
62
 * This class implements the resources list view.
63
 * 
64
 * @author Jorge Piera Llodra (piera_jor@gva.es)
65
 */
66
public class ChooseResourceDialog extends ChooseResourceDialogPanel
67
implements IWindow {
68
        private static final CatalogManager catalogManager = CatalogLocator.getCatalogManager();
69
        /**
70
         * @param resources
71
         * Found resources array
72
         */
73
        public ChooseResourceDialog(Collection resources) {
74
                super(resources);
75
        }   
76
        
77
        public WindowInfo getWindowInfo() {
78
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
79
                m_viewinfo.setTitle(getName());
80
                return m_viewinfo;
81
        }
82
        
83
        
84
        public Object getWindowProfile(){
85
                return WindowInfo.DIALOG_PROFILE;
86
        }
87
        
88
        public void closeButtonActionPerformed() {
89
                closeJDialog();
90
        }
91
        
92
        public void closeJDialog() {
93
                setVisible(true);
94
                PluginServices.getMDIManager().closeWindow(ChooseResourceDialog.this);
95
        }
96
        
97
        /**
98
         * This method is invocated when a resource button is clicked
99
         */
100
        public void resourceButtonActionPerformed(Resource resource){
101
                LayerLoader loader = null;
102
                try {
103
                        loader = catalogManager.getLayerLoader(resource);
104
                        if (loader != null) {
105
                                loader.loadLayer();
106
                        } else {
107
                                JOptionPane.showMessageDialog(this,
108
                                                Messages.getText("pluginNotFound") ,
109
                                                Messages.getText("pluginNotFoundTitle"),                        
110
                                                JOptionPane.INFORMATION_MESSAGE);        
111
                                return;
112
                        }
113
                        
114
                } catch (IllegalArgumentException e) {
115
                        // TODO Auto-generated catch block
116
                        e.printStackTrace();
117
                } catch (SecurityException e) {
118
                        // TODO Auto-generated catch block
119
                        e.printStackTrace();
120
                } catch (InstantiationException e) {
121
                        // TODO Auto-generated catch block
122
                        e.printStackTrace();
123
                } catch (IllegalAccessException e) {
124
                        // TODO Auto-generated catch block
125
                        e.printStackTrace();
126
                } catch (InvocationTargetException e) {
127
                        // TODO Auto-generated catch block
128
                        e.printStackTrace();
129
                } catch (NoSuchMethodException e) {
130
                        // TODO Auto-generated catch block
131
                        e.printStackTrace();
132
                } catch (LayerLoaderException e) {
133
                        e.printStackTrace();
134
                        JOptionPane.showMessageDialog(this,
135
                                        e.getMessage(),
136
                                        e.getWindowMessage(),                        
137
                                        JOptionPane.ERROR_MESSAGE);        
138
                }                
139
                closeJDialog();
140
        }   
141
}
142

    
143

    
144

    
145

    
146