Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.annotation.app / org.gvsig.annotation.app.mainplugin / src / main / java / org / gvsig / annotation / app / extension / GvSIGAnnotationWindowManager.java @ 40561

History | View | Annotate | Download (3.85 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.annotation.app.extension;
25

    
26
import java.awt.Component;
27
import java.awt.event.ComponentEvent;
28
import java.awt.event.ComponentListener;
29

    
30
import javax.swing.JOptionPane;
31

    
32
import org.gvsig.andami.PluginServices;
33
import org.gvsig.annotation.swing.AnnotationWindowManager;
34
import org.gvsig.annotation.swing.AnnotationWizardPanelActionListener;
35
import org.gvsig.annotation.swing.JAnnotationCreationServicePanel;
36
import org.gvsig.annotation.swing.JAnnotationPreferencesPanel;
37

    
38
/**
39
 * {@link AnnotationWindowManager} implementation to show Annotation
40
 * windows as gvSIG windows
41
 * 
42
 * @author gvSIG Team
43
 * @version $Id$
44
 */
45
public class GvSIGAnnotationWindowManager implements AnnotationWindowManager, ComponentListener {
46

    
47
    public void showWindow(JAnnotationCreationServicePanel panel, String title, int mode) {
48
        AnnotationWindow window =
49
            new AnnotationWindow(panel, title, mode);
50

    
51
        panel.setAnnotationServicePanelActionListener(new AnnotationWizardListener(window));        
52

    
53
        window.addComponentListener(this);
54

    
55
        PluginServices.getMDIManager().addCentredWindow(window);
56
    }
57

    
58
    public void componentHidden(ComponentEvent componentEvent) {
59
        AnnotationWindow window =
60
            (AnnotationWindow) componentEvent.getSource();
61
        if (window.isVisible()){
62
            PluginServices.getMDIManager().closeWindow(window);
63
        }
64
    }
65

    
66
    public void componentMoved(ComponentEvent e) {
67
        // Nothing to do
68
    }
69

    
70
    public void componentResized(ComponentEvent e) {
71
        // Nothing to do
72
    }
73

    
74
    public void componentShown(ComponentEvent e) {
75
        // Nothing to do
76
    }
77

    
78
    public class AnnotationWizardListener implements AnnotationWizardPanelActionListener{
79
        private AnnotationWindow annotationWindow = null;
80

    
81
        public AnnotationWizardListener(AnnotationWindow annotationWindow) {
82
            super();
83
            this.annotationWindow = annotationWindow;
84
        }
85

    
86
        public void cancel(
87
            JAnnotationCreationServicePanel annotationCreationServicePanel) {
88
            if (annotationWindow.isVisible()){
89
                PluginServices.getMDIManager().closeWindow(annotationWindow); 
90
            }
91
        }
92

    
93
        public void finish(
94
            JAnnotationCreationServicePanel annotationCreationServicePanel) {
95
            if (annotationWindow.isVisible()){
96
                PluginServices.getMDIManager().closeWindow(annotationWindow);    
97
            }
98
        }
99
    }
100

    
101

    
102
    public boolean showFileExistsPopup(String title, String text) {
103
        int resp = JOptionPane.showConfirmDialog(
104
            (Component)PluginServices.getMainFrame(), text,
105
            title, JOptionPane.YES_NO_OPTION);
106
        if (resp == JOptionPane.YES_OPTION) {
107
            return true;
108
        }
109
        return false;
110
    }
111

    
112
    public void showPreferencesWindow(JAnnotationPreferencesPanel panel,
113
        String title, int mode) {
114
        // TODO Auto-generated method stub
115

    
116
    }
117
}