Revision 38605 branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/view/toolListeners/InfoListener.java

View differences:

InfoListener.java
40 40
 */
41 41
package org.gvsig.app.project.documents.view.toolListeners;
42 42

  
43
import java.awt.GridBagConstraints;
43 44
import java.awt.Image;
44 45
import java.util.HashMap;
45 46
import java.util.Map;
46 47

  
47
import javax.swing.JDialog;
48
import javax.swing.JPanel;
49

  
50 48
import org.slf4j.Logger;
51 49
import org.slf4j.LoggerFactory;
52 50

  
53 51
import org.gvsig.andami.PluginServices;
54 52
import org.gvsig.andami.messages.NotificationManager;
55 53
import org.gvsig.andami.ui.mdiManager.IWindow;
54
import org.gvsig.andami.ui.mdiManager.SingletonWindow;
56 55
import org.gvsig.app.ApplicationLocator;
57 56
import org.gvsig.app.ApplicationManager;
58 57
import org.gvsig.app.project.documents.view.info.gui.FInfoDialog;
......
158 157
            ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
159 158
            InfoByPointRenderer renderer = (InfoByPointRenderer)extensionPoints.get(EP_INFOTOOL_NAME).create(EP_INFOTOOL_RENDERER);
160 159
            
161
            IWindow window = renderer.getPanel();
162
            boolean first_time = (window == null);
163
            renderer.resetPanel(layer2info);
164
            
165
            window = renderer.getPanel();
160
            IWindow window = renderer.getPanel(layer2info);
161

  
166 162
            if (window == null) {
167 163
                logger.info("Error. Unable to create info panel.");
168 164
                return;
169 165
            }
170
            
171
            
172
            if (first_time) {
173
                PluginServices.getMDIManager().addCentredWindow(window);
174
            } else {
175
                // perhaps bring to front
176
            }
177
            
178 166

  
167
            PluginServices.getMDIManager().addWindow(window, GridBagConstraints.LAST_LINE_END);
168

  
179 169
        } catch (Exception e) {
180 170
            NotificationManager.addError("Info by Point", e);
181 171
            e.printStackTrace();
182 172
        }
183 173
    }
184 174

  
175
    /**
176
     * @param window
177
     * @return whether the window is currently one the app windows
178
     */
179
    private boolean isCurrentlyAdded(IWindow iw) {
180
        
181
        IWindow[] iws = PluginServices.getMDIManager().getAllWindows();
182
        for (int i=0; i<iws.length; i++) {
183
            if (iws[i] == iw) {
184
                return true;
185
            }
186
        }
187
        return false;
188
    }
189

  
185 190
    public Image getImageCursor() {
186 191
        return img;
187 192
    }
......
196 201
    
197 202
    public interface InfoByPointRenderer {
198 203
        
199
       public FInfoDialog getPanel();
200
       public void resetPanel(Map<String, DynObjectSet> layersInfo);
204
       public SingletonWindow getPanel(Map<String, DynObjectSet> layersInfo);
201 205
       
202 206
    }
203 207
    
......
205 209
        
206 210
        private FInfoDialog dlgInfo = null;
207 211
        
208
        public FInfoDialog getPanel() {
209
            return dlgInfo;
210
        }
211

  
212
        
213
        public void resetPanel(Map<String, DynObjectSet> layersInfo) {
212
        public SingletonWindow getPanel(Map<String, DynObjectSet> layersInfo) {
214 213
            // TODO: set the writable parameter to true to activate
215 214
            // edition of the info by point information.
216 215
            LayersDynObjectSetComponent infoComponent =
......
222 221
            } else {
223 222
                dlgInfo.setInfo(infoComponent);
224 223
            }
224
            return dlgInfo;
225 225
        }
226 226
       
227 227
    }

Also available in: Unified diff