Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extCatalogYNomenclator / src / es / gva / cit / gvsig / gazetteer / gui / SearchDialog.java @ 6877

History | View | Annotate | Download (5.83 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.gazetteer.gui;
42

    
43
import java.awt.Dimension;
44
import java.awt.Frame;
45
import java.awt.event.ComponentEvent;
46
import java.awt.event.ComponentListener;
47
import java.awt.event.MouseEvent;
48
import java.awt.event.MouseListener;
49
import java.awt.geom.Rectangle2D;
50

    
51
import javax.swing.JDialog;
52

    
53
import org.gvsig.i18n.Messages;
54

    
55
import com.iver.andami.PluginServices;
56
import com.iver.andami.ui.mdiManager.IWindow;
57
import com.iver.andami.ui.mdiManager.ViewInfo;
58
import com.iver.cit.gvsig.fmap.ColorEvent;
59
import com.iver.cit.gvsig.fmap.ExtentEvent;
60
import com.iver.cit.gvsig.fmap.ProjectionEvent;
61
import com.iver.cit.gvsig.fmap.ViewPortListener;
62

    
63
import es.gva.cit.catalogClient.querys.Coordinates;
64
import es.gva.cit.catalogClient.utils.Frames;
65
import es.gva.cit.gazetteer.GazetteerClient;
66
import es.gva.cit.gazetteer.querys.Feature;
67
import es.gva.cit.gazetteer.ui.search.SearchDialogPanel;
68
import es.gva.cit.gvsig.gazetteer.gui.ConnectDialog;
69

    
70

    
71
/**
72
 * @author Jorge Piera Llodra (piera_jor@gva.es)
73
 */
74
public class SearchDialog extends SearchDialogPanel
75
implements IWindow,ViewPortListener{
76
    private JDialog frame = null;
77
    
78
    public SearchDialog(GazetteerClient client,JDialog frame, Object serverConnectFrame){
79
        super(client,serverConnectFrame);
80
        this.frame = frame;  
81
        setViewChangeListener();        
82
            loadViewPortCoordinates();
83
    }
84
    
85
    /* (non-Javadoc)
86
     * @see com.iver.andami.ui.mdiManager.View#getViewInfo()
87
     */
88
    public ViewInfo getViewInfo() {
89
        ViewInfo m_viewinfo=new ViewInfo(ViewInfo.MODALDIALOG);
90
                m_viewinfo.setTitle(Messages.getText( "gazetteer_search"));
91
                return m_viewinfo;
92
    }
93
    
94
    public void ShowResultsActionPerformed(Feature[] features) {
95
        JDialog panel = new JDialog((Frame) PluginServices.getMainFrame(), false);
96
        Frames.centerFrame(panel,420,258);
97
      panel.setTitle(Messages.getText( "gazetteer_search")); 
98
        panel.setResizable(false);
99
        
100
        ShowResultsDialog dialog = new ShowResultsDialog(panel,
101
                client,
102
                features,
103
                lowerPanel.getNPaginas(),
104
                doQuery());
105
                
106
        panel.getContentPane().add(dialog);
107
        panel.show();          
108
       
109
        //PluginServices.getMDIManager().addView(panel);
110
    }
111
    
112
    public void closeButtonActionPerformed() {
113
             frame.setVisible(false);
114
         }
115
    
116
         /**
117
          * Size button action performed
118
          */         
119
         public void sizeButtonActionPerformed(){
120
                if (isMinimized){
121
                        frame.setSize(525,520);
122
                                ppalPanel.setPreferredSize(new Dimension(514,490));
123
                                getLowerPanel().setPreferredSize(new Dimension(514,440));
124
                                getLowerPanel().setVisible(true);
125
                                frame.setVisible(true);
126
                                getUpperPanel().setUpIcon();
127
                 }else{
128
                        frame.setSize(525,117);
129
                                 ppalPanel.setPreferredSize(new Dimension(514,91));
130
                                 getLowerPanel().setPreferredSize(new Dimension(514,0));
131
                                 getLowerPanel().setVisible(false);
132
                                 frame.setVisible(true);
133
                                 getUpperPanel().setDownIcon();
134
                }
135
                isMinimized = !isMinimized;
136
         }
137
         /**
138
          * Return button action
139
          */
140
        public void returnButtonActionPerformed() {  
141
                closeJDialog();
142
                ConnectDialog serverConnect = (ConnectDialog)serverConnectFrame;
143
                serverConnect.setVisible(true);
144
                serverConnect.getSearchButton().setEnabled(false);
145
                PluginServices.getMDIManager().addView(serverConnect);
146
        } 
147
    
148
    public void closeJDialog() {
149
            frame.setVisible(false);
150
        }
151
    
152
         /**
153
          * This method loads the view coordinates to the catalog search dialog
154
          *
155
          */
156
         private void loadViewPortCoordinates(){
157
                 com.iver.cit.gvsig.gui.View activeView = 
158
                                (com.iver.cit.gvsig.gui.View) PluginServices.getMDIManager().getActiveView();
159
               
160
                Rectangle2D r2d= activeView.getMapControl().getViewPort().getExtent();
161
                
162
                try{
163
                getLowerPanel().setCoordinates(new Coordinates(r2d.getMinX(),
164
                        r2d.getMaxY(),
165
                        r2d.getMaxX(),
166
                        r2d.getMinY()));
167
                }catch(NullPointerException E){
168
                    //We cant retrieve the coordinates if it doesn't 
169
                    //exist a loaded layer
170
                }
171
         }
172
         /*
173
     * This methos joins the viewPort event to the listener
174
     */
175
    private void setViewChangeListener(){
176
        com.iver.cit.gvsig.gui.View activeView = 
177
                        (com.iver.cit.gvsig.gui.View) PluginServices.getMDIManager().getActiveView();
178
               
179
        activeView.getMapControl().getViewPort().addViewPortListener(this);
180
       
181
    }
182

    
183
        public void extentChanged(ExtentEvent e) {
184
                loadViewPortCoordinates();   
185
                
186
        }
187

    
188
        public void backColorChanged(ColorEvent e) {
189
                // TODO Auto-generated method stub
190
                
191
        }
192

    
193
        public void projectionChanged(ProjectionEvent e) {
194
                loadViewPortCoordinates();                
195
        }
196

    
197

    
198
    
199
 
200
    
201
   
202
}