Statistics
| Revision:

gvsig-catalog / org.gvsig.catalog / trunk / org.gvsig.catalog / org.gvsig.catalog.extension / src / main / java / org / gvsig / catalog / gui / ConnectDialog.java @ 144

History | View | Annotate | Download (5.03 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.awt.Frame;
44
import java.util.Map;
45

    
46
import javax.swing.Icon;
47
import javax.swing.JDialog;
48

    
49
import org.gvsig.andami.IconThemeHelper;
50
import org.gvsig.andami.PluginServices;
51
import org.gvsig.andami.ui.mdiManager.IWindow;
52
import org.gvsig.andami.ui.mdiManager.WindowInfo;
53
import org.gvsig.catalog.CatalogLocator;
54
import org.gvsig.catalog.CatalogManager;
55
import org.gvsig.catalog.drivers.ICatalogServiceDriver;
56
import org.gvsig.catalog.ui.serverconnect.ServerConnectDialogPanel;
57
import org.gvsig.catalog.utils.Frames;
58
import org.gvsig.i18n.Messages;
59
import org.gvsig.utils.swing.jcomboServer.ServerData;
60

    
61

    
62
/**
63
 * Inicia la consulta de cat?logo de metadatos
64
 *
65
 * @author luisw
66
 */
67
public class ConnectDialog extends ServerConnectDialogPanel implements IWindow {
68
        public WindowInfo m_windowInfo = null;
69
        private static final CatalogManager catalogManager = CatalogLocator.getCatalogManager();
70

    
71
        /**
72
         * Constructor de la ventana de dialogo.
73
         */
74
        public ConnectDialog() {
75
                super(null);
76
                init();
77
        }
78

    
79
        /**
80
         * Inicializa el Dialog
81
         */
82
        private void init() {
83
                this.setBounds(0, 0, 597, 238);
84
                setName("connectDialog");
85
        }
86

    
87
        /**
88
         * Search Button action
89
         */
90
        protected void searchButtonActionPerformed() {
91
                addCurrentHost();
92
                closeJDialog();
93

    
94
                JDialog panel = new JDialog((Frame) PluginServices.getMainFrame(), false);
95
                Frames.centerFrame(panel,525,165);
96
                panel.setTitle(Messages.getText( "catalog_search"));
97
                SearchDialog dialog = new SearchDialog(getClient(),this);
98
                dialog.setCurrentServer(getCurrentServer());
99
                dialog.setFrame(panel);
100
                panel.getContentPane().add(dialog);
101
                panel.setVisible(true);
102
        }
103

    
104
        /**
105
         * Save the current host (if is neccessary) in a file using the andami
106
         * persistence
107
         */
108
        private void addCurrentHost() {
109
                String host = getClient().getSUri();
110
                ServerData newServerData = new ServerData(host, ServerData.SERVER_TYPE_CATALOG, getClient().getProtocol(),getControlsPanel().getDatabase());
111
                if (client.getServerData() != null){
112
                        if ((client.getServerData().getServerAddress().compareTo(newServerData.getServerAddress()) == 0) &&
113
                                        (client.getServerData() .getServiceSubType().compareTo(newServerData.getServiceSubType()) == 0)){
114
                                newServerData.setProperies(client.getServerData().getProperies());
115
                        }
116
                }
117
        Map serversMap = catalogManager.getServersPersistence();
118
        serversMap.put(newServerData.getServerAddress(), newServerData);
119
        }
120

    
121
        /*
122
         * (non-Javadoc)
123
         * @see es.gva.cit.catalog.ui.serverconnect.ServerConnectDialogPanel#closeButtonActionPerformed()
124
         */
125
        protected void closeButtonActionPerformed() {
126
                closeJDialog();
127
        }
128

    
129
        /*
130
         * (non-Javadoc)
131
         * @see es.gva.cit.catalog.ui.serverconnect.ServerConnectDialogPanel#serverPropertiesButtonActionPerformed()
132
         */
133
        protected void serverPropertiesButtonActionPerformed(){
134
                createClient();
135
                PluginServices.getMDIManager().addWindow(new ServerPropertiesDialog(
136
                                getControlsPanel().getServer(),
137
                                client,
138
                                ((ICatalogServiceDriver)getControlsPanel().getDriver()).getProfile(),
139
                                null));
140
        }
141

    
142
        /**
143
         * Close the dialog
144
         */
145
        public void closeJDialog() {
146
                PluginServices.getMDIManager().closeWindow(ConnectDialog.this);
147
        }
148

    
149
        /* (non-Javadoc)
150
         * @see com.iver.andami.ui.mdiManager.View#getViewInfo()
151
         */
152
        public WindowInfo getWindowInfo() {
153
                if (m_windowInfo == null){
154
                        m_windowInfo = new WindowInfo(WindowInfo.MODALDIALOG);
155
                        m_windowInfo.setTitle(Messages.getText("metadata_catalog"));
156
                        m_windowInfo.setHeight(200);
157
                        m_windowInfo.setWidth(600);
158
                }
159
                return m_windowInfo;
160
        }
161
        public Object getWindowProfile(){
162
                return WindowInfo.DIALOG_PROFILE;
163
        }
164

    
165
        /* (non-Javadoc)
166
         * @see org.gvsig.catalog.ui.serverconnect.ServerConnectDialogPanel#getPropertiesIcon()
167
         */
168
        protected Icon getPropertiesIcon() {
169
            // catalog-move-down
170
            // catalog-move-up
171
            // catalog-server-properties
172
            return IconThemeHelper.getImageIcon("catalog-server-properties");
173
        }
174
}