Statistics
| Revision:

svn-gvsig-desktop / branches / CatalogYNomenclator_v1_1_0_1005 / extensions / extCatalogYNomenclator / src / es / gva / cit / gvsig / gazetteer / gui / SearchDialog.java @ 12745

History | View | Annotate | Download (5.66 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.catalogClient.querys.Coordinates;
60
import es.gva.cit.catalogClient.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
    
97
    public void showResultsActionPerformed(Feature[] features) {
98
              JDialog panel = new JDialog((Frame) PluginServices.getMainFrame(), false);
99
            Frames.centerFrame(panel,420,258);
100
            panel.setTitle(Messages.getText( "gazetteer_search")); 
101
            panel.setResizable(false);
102
            
103
            ShowResultsDialog dialog = new ShowResultsDialog(panel,
104
                            client,
105
                            features,
106
                            lowerPanel.getResultsByPage(),
107
                            getQuery());
108
            
109
            panel.getContentPane().add(dialog);
110
            panel.show(); 
111
     }
112
    
113
    protected void closeButtonActionPerformed() {
114
            frame.setVisible(false);
115
         }
116
    
117
         /**
118
          * Size button action performed
119
          */         
120
    protected void resizeButtonActionPerformed(){
121
                if (isMinimized){
122
                        parentDialog.setSize(parentDialog.getWidth(),450);
123
                                 getLowerPanel().setVisible(true);
124
                                getUpperPanel().setUpIcon();
125
                 }else{
126
                         parentDialog.setSize(parentDialog.getWidth(),115);
127
                         getLowerPanel().setVisible(false);                                 
128
                         getUpperPanel().setDownIcon();
129
                }
130
                isMinimized = !isMinimized;
131
         }
132
         /**
133
          * Return button action
134
          */
135
        protected void lastButtonActionPerformed() {  
136
                closeJDialog();
137
                ConnectDialog serverConnect = (ConnectDialog)serverConnectFrame;
138
                parentDialog.setVisible(true);
139
                parentDialog.getControlsPanel().enableSearchButton(false);
140
                PluginServices.getMDIManager().addWindow(serverConnect);
141
        } 
142
    
143
    public void closeJDialog() {
144
            frame.setVisible(false);
145
        }
146
    
147
         /**
148
          * This method loads the view coordinates to the catalog search dialog
149
          *
150
          */
151
         private void loadViewPortCoordinates(){
152
                 BaseView activeView = 
153
                                (BaseView) PluginServices.getMDIManager().getActiveWindow();
154
               
155
                Rectangle2D r2d= activeView.getMapControl().getViewPort().getExtent();
156
                
157
                try{
158
                getLowerPanel().setCoordinates(new Coordinates(r2d.getMinX(),
159
                        r2d.getMaxY(),
160
                        r2d.getMaxX(),
161
                        r2d.getMinY()));
162
                }catch(NullPointerException E){
163
                    //We cant retrieve the coordinates if it doesn't 
164
                    //exist a loaded layer
165
                }
166
         }
167
         /*
168
     * This method joins the viewPort event to the listener
169
     */
170
    private void setViewChangeListener(){
171
        BaseView activeView = 
172
                        (BaseView) PluginServices.getMDIManager().getActiveWindow();
173
               
174
        activeView.getMapControl().getViewPort().addViewPortListener(this);
175
       
176
    }
177

    
178
        public void extentChanged(ExtentEvent e) {
179
                loadViewPortCoordinates();   
180
                
181
        }
182

    
183
        public void backColorChanged(ColorEvent e) {
184
                // TODO Auto-generated method stub
185
                
186
        }
187

    
188
        public void projectionChanged(ProjectionEvent e) {
189
                loadViewPortCoordinates();                
190
        }
191

    
192
        /**
193
         * @param frame the frame to set
194
         */
195
        public void setFrame(JDialog dialog) {
196
                this.frame = dialog;
197
        }
198

    
199

    
200
    
201
 
202
    
203
   
204
}