Statistics
| Revision:

svn-gvsig-desktop / branches / v05 / extensions / extCatalogYNomenclator / src / es / gva / cit / gvsig / catalogClient / gui / SearchDialog.java @ 4488

History | View | Annotate | Download (5.92 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 es.gva.cit.gvsig.catalogClient.gui;
42

    
43
import java.awt.Dimension;
44
import java.awt.Frame;
45
import java.awt.event.MouseEvent;
46
import java.awt.event.MouseListener;
47
import java.awt.geom.Rectangle2D;
48
import java.util.Collection;
49

    
50
import javax.swing.JDialog;
51
import javax.swing.JFrame;
52

    
53
import com.iver.andami.PluginServices;
54
import com.iver.andami.ui.mdiManager.View;
55
import com.iver.andami.ui.mdiManager.ViewInfo;
56
import com.iver.cit.gvsig.fmap.ColorEvent;
57
import com.iver.cit.gvsig.fmap.ExtentEvent;
58
import com.iver.cit.gvsig.fmap.ViewPortListener;
59

    
60
import es.gva.cit.catalogClient.CatalogClient;
61
import es.gva.cit.catalogClient.querys.Coordinates;
62
import es.gva.cit.catalogClient.ui.search.SearchDialogPanel;
63
import es.gva.cit.catalogClient.ui.showResults.ShowResultsPanel;
64
import es.gva.cit.catalogClient.utils.Frames;
65
import es.gva.cit.gvsig.catalogClient.translation.AndamiTranslation;
66

    
67
/**
68
 * This class is used to search a record using the catalog client
69
 * @author luisw
70
 * @modified by Jorge Piera
71
 */
72
public class SearchDialog extends SearchDialogPanel implements
73
                View,ViewPortListener {
74
    private JDialog frame = null;
75
    public ViewInfo m_viewinfo = null;
76
   
77
        public SearchDialog(JDialog frame,Object serverConnectFrame,CatalogClient client) {
78
                super(null,serverConnectFrame,new AndamiTranslation(),client);
79
                this.frame = frame;
80
                setViewChangeListener();                
81
                loadViewPortCoordinates();
82
        }
83

    
84
        /**
85
         * This method opens the show results frame.
86
         * @param nodes
87
         * XML node returned by the query
88
         */
89
        protected void showResults(Collection nodes) {
90
        JDialog panel = new JDialog((Frame) PluginServices.getMainFrame(), false);
91
        Frames.centerFrame(panel,610,418);
92
        panel.setTitle(PluginServices.getText(this, "search_results")); 
93
        panel.setResizable(false);
94
        
95
        ShowResultsPanel.mustShowThumbnails = true;
96
                ShowResultsDialog dialog =
97
                        new ShowResultsDialog(panel,client,nodes,1);
98
                
99
        panel.getContentPane().add(dialog);
100
        panel.show();      
101
        }
102
                
103
        /**
104
         * It Closes the dialog
105
         */
106
        public void closeJDialog() {
107
            frame.setVisible(false);
108
                
109
        }
110
        
111
        /* (non-Javadoc)
112
         * @see com.iver.andami.ui.mdiManager.View#getViewInfo()
113
         */
114
        public ViewInfo getViewInfo() {
115
            if (m_viewinfo == null){
116
                m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
117
                m_viewinfo.setTitle(getName());
118
            }
119
                return m_viewinfo;
120
        }
121

    
122
        
123
        /**
124
         * Close button Action performed
125
         */        
126
         public void closeButtonActionPerformed() {
127
             closeJDialog();
128
         }
129
         
130
         /**
131
          * Size button action performed
132
          */         
133
         public void sizeButtonActionPerformed(){
134
                if (isMinimized){
135
                    frame.setSize(525,457);
136
                    ppalPanel.setPreferredSize(new Dimension(514,423));
137
                    getLowerPanel().setPreferredSize(new Dimension(514,440));
138
                    getLowerPanel().setVisible(true);
139
                    frame.setVisible(true);
140
                    getUpperPanel().setUpIcon();
141
                }else{
142
                    frame.setSize(525,118);
143
                    ppalPanel.setPreferredSize(new Dimension(514,91));
144
                    getLowerPanel().setPreferredSize(new Dimension(514,0));
145
                    getLowerPanel().setVisible(false);
146
                    frame.setVisible(true);
147
                    getUpperPanel().setDownIcon();
148
                }
149
                isMinimized = !isMinimized;
150
         }
151
        
152
         /**
153
          * Return button action
154
          */
155
        public void returnButtonActionPerformed() {  
156
                closeJDialog();
157
                ConnectDialog serverConnect = (ConnectDialog)serverConnectFrame;
158
                serverConnect.setVisible(true);
159
                serverConnect.getSearchButton().setEnabled(false);
160
                PluginServices.getMDIManager().addView(serverConnect);
161
                
162
                
163
        } 
164

    
165
         
166
         /**
167
          * This method loads the view coordinates to the catalog search dialog
168
          *
169
          */
170
         private void loadViewPortCoordinates(){
171
                 com.iver.cit.gvsig.gui.View activeView = 
172
                                (com.iver.cit.gvsig.gui.View) PluginServices.getMDIManager().getActiveView();
173
               
174
                Rectangle2D r2d= activeView.getMapControl().getViewPort().getAdjustedExtent();
175
                
176
                try{
177
                        getLowerPanel().setCoordinates(new Coordinates(r2d.getMinX(),
178
                        r2d.getMaxY(),
179
                        r2d.getMaxX(),
180
                        r2d.getMinY()));
181
                }catch(NullPointerException E){
182
                    //We cant retrieve the coordinates if it doesn't 
183
                    //exist a loaded layer
184
                }
185
         }  
186
    
187
    /**
188
     * This methos joins the viewPort event to the listener
189
     */
190
    private void setViewChangeListener(){
191
            com.iver.cit.gvsig.gui.View activeView = 
192
                        (com.iver.cit.gvsig.gui.View) PluginServices.getMDIManager().getActiveView();
193
               
194
        activeView.getMapControl().getViewPort().addViewPortListener(this);
195
    }
196

    
197
        public void extentChanged(ExtentEvent e) {
198
                loadViewPortCoordinates();   
199
                
200
        }
201

    
202
        public void backColorChanged(ColorEvent e) {
203
                // TODO Auto-generated method stub
204
                
205
        }
206
    
207
  
208
         
209
         
210
            
211
}