Statistics
| Revision:

root / trunk / extensions / extCatalogAndGazetteer / src / es / gva / cit / gvsig / gazetteer / gui / SearchDialog.java @ 24989

History | View | Annotate | Download (5.72 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.Frame;
44
import java.awt.geom.Rectangle2D;
45

    
46
import javax.swing.JDialog;
47

    
48
import org.gvsig.i18n.Messages;
49

    
50
import com.iver.andami.PluginServices;
51
import com.iver.andami.ui.mdiManager.IWindow;
52
import com.iver.andami.ui.mdiManager.WindowInfo;
53
import com.iver.cit.gvsig.fmap.ColorEvent;
54
import com.iver.cit.gvsig.fmap.ExtentEvent;
55
import com.iver.cit.gvsig.fmap.ProjectionEvent;
56
import com.iver.cit.gvsig.fmap.ViewPortListener;
57
import com.iver.cit.gvsig.project.documents.view.gui.BaseView;
58

    
59
import es.gva.cit.catalog.querys.Coordinates;
60
import es.gva.cit.catalog.utils.Frames;
61
import es.gva.cit.gazetteer.GazetteerClient;
62
import es.gva.cit.gazetteer.querys.Feature;
63
import es.gva.cit.gazetteer.ui.search.SearchDialogPanel;
64

    
65

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

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

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

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

    
196
        /**
197
         * @param frame the frame to set
198
         */
199
        public void setFrame(JDialog dialog) {
200
                this.frame = dialog;
201
        }
202

    
203

    
204
    
205
 
206
    
207
   
208
}