Statistics
| Revision:

gvsig-geoprocess / org.gvsig.geoprocess / trunk / org.gvsig.geoprocess / org.gvsig.geoprocess.app / org.gvsig.geoprocess.app.mainplugin / src / main / java / org / gvsig / geoprocess / sextante / gui / GeoprocessWindow.java @ 239

History | View | Annotate | Download (3.79 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007,2012 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 2
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
package org.gvsig.geoprocess.sextante.gui;
22

    
23
import java.awt.BorderLayout;
24

    
25
import javax.swing.JComponent;
26
import javax.swing.JPanel;
27

    
28
import es.unex.sextante.core.IInputFactory;
29
import es.unex.sextante.gui.core.SextanteGUI;
30
import es.unex.sextante.gui.toolbox.ToolboxPanel;
31

    
32
import org.gvsig.andami.ui.mdiManager.IWindow;
33
import org.gvsig.andami.ui.mdiManager.IWindowListener;
34
import org.gvsig.andami.ui.mdiManager.WindowInfo;
35

    
36
/**
37
 * Geoprocess modeler window. By default uses a DIALOG type window profile and
38
 * info. Also the window info uses the size from the size of the provided JPanel
39
 * to include.
40
 * 
41
 * @author gvSIG Team
42
 * @version $Id$
43
 */
44
public abstract class GeoprocessWindow extends JPanel implements IWindow,
45
    IWindowListener {
46

    
47
    private static final long serialVersionUID = -677659097155651764L;
48

    
49
    private WindowInfo windowInfo;
50
    private ToolboxPanel toolboxPanel;
51

    
52
    protected JComponent mainComponent;
53

    
54
    /**
55
     * Creates a new {@link GeoprocessWindow}.
56
     * 
57
     * @param toolbox
58
     *            the main geoprocess selector panel
59
     */
60
    public GeoprocessWindow(ToolboxPanel toolbox) {
61
        toolboxPanel = toolbox;
62
        initializeDataObjects();
63

    
64
        initializeUI();
65

    
66
        windowInfo = createWindowInfo();
67
    }
68

    
69
    /**
70
     * Initializes the sextante data objects.
71
     */
72
    protected void initializeDataObjects() {
73
        IInputFactory inputFactory = SextanteGUI.getInputFactory();
74
        if (inputFactory.getDataObjects() == null) {
75
            inputFactory.createDataObjects();
76
        }
77
    }
78

    
79
    /**
80
     * Initializes de window user interface.
81
     */
82
    protected void initializeUI() {
83
        mainComponent = getMainComponent();
84
        this.setLayout(new BorderLayout(0, 0));
85
        this.add(mainComponent);
86
    }
87

    
88
    /**
89
     * Initializes the window info object.
90
     */
91
    protected WindowInfo createWindowInfo() {
92
        WindowInfo windowInfo =
93
            new WindowInfo(WindowInfo.ICONIFIABLE | WindowInfo.RESIZABLE
94
                | WindowInfo.MAXIMIZABLE);
95
        // new WindowInfo(WindowInfo.MODALDIALOG | WindowInfo.RESIZABLE);
96
        windowInfo.setTitle(getTitle());
97
        windowInfo.setWidth(mainComponent.getWidth());
98
        windowInfo.setHeight(mainComponent.getHeight());
99

    
100
        return windowInfo;
101
    }
102

    
103
    public Object getWindowProfile() {
104
        return WindowInfo.EDITOR_PROFILE;
105
        // return WindowInfo.DIALOG_PROFILE;
106
    }
107

    
108
    public WindowInfo getWindowInfo() {
109
        return windowInfo;
110
    }
111

    
112
    public void windowActivated() {
113
        // Nothing to do
114
    }
115

    
116
    public void windowClosed() {
117
        if (toolboxPanel == null) {
118
            SextanteGUI.getInputFactory().clearDataObjects();
119
        }
120
    }
121

    
122
    /**
123
     * Return the title of the window.
124
     * 
125
     * @return the title of the window
126
     */
127
    protected abstract String getTitle();
128

    
129
    /**
130
     * Return the panel to show in the window.
131
     * 
132
     * @return the panel to show in the window
133
     */
134
    protected abstract JComponent getMainComponent();
135
}