Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / gui / ProjectWindow.java @ 43913

History | View | Annotate | Download (4.04 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.app.project.documents.gui;
25

    
26
import java.awt.BorderLayout;
27
import java.awt.Component;
28
import java.util.List;
29
import javax.swing.JPanel;
30
import javax.swing.JTabbedPane;
31
import org.gvsig.andami.PluginServices;
32
import org.gvsig.andami.ui.mdiManager.SingletonWindow;
33
import org.gvsig.andami.ui.mdiManager.WindowInfo;
34
import org.gvsig.app.project.Project;
35
import org.gvsig.app.project.documents.gui.projectpanel.ProjectPanelPage;
36
import org.gvsig.propertypage.PropertiesPage;
37
import org.gvsig.propertypage.PropertiesPageManager;
38
import org.gvsig.tools.ToolsLocator;
39
import org.gvsig.tools.i18n.I18nManager;
40
import org.gvsig.tools.util.ToolsUtilLocator;
41

    
42
public class ProjectWindow  
43
        extends JPanel
44
        implements SingletonWindow 
45
    {
46

    
47
    private Project project;
48
    private WindowInfo viewInfo;
49
    private final List<PropertiesPage> pages;
50
    
51
    public ProjectWindow() {
52
        PropertiesPageManager manager = ToolsUtilLocator.getPropertiesPageManager();
53
        this.pages = manager.getPages(Project.PROJECT_PANEL_PAGE_GROUP,this, null);        
54
        initComponents();
55
    }
56
    
57
    private void initComponents() {
58
        this.setLayout(new BorderLayout());
59
        Component contents = createPagesPanel();
60
        this.add(contents, BorderLayout.CENTER);
61
    }
62
    
63
    protected Component createPagesPanel() {
64
        if( this.pages.size()==1 && !useTabsAlwais() ) {
65
            PropertiesPage page = this.pages.get(0);
66
            return page.asJComponent();
67
        } else {
68
            JTabbedPane theTabbedPane = new JTabbedPane();
69
            for( int i=0; i<this.pages.size(); i++ ) {
70
                PropertiesPage page = this.pages.get(i);
71
                theTabbedPane.addTab(page.getTitle(), page.asJComponent());
72
            }
73
            return theTabbedPane;
74
        }
75
    }
76
    
77
    protected boolean useTabsAlwais() {
78
        return false;
79
    }
80

    
81
    @Override
82
    public Object getWindowModel() {
83
        return project;
84
    }
85

    
86
    public Project getProject() {
87
        return project;
88
    }
89
    
90
    public void setProject(Project project) {
91
        this.project = project;
92
        for (PropertiesPage page : this.pages) {
93
            if( page instanceof ProjectPanelPage ) {
94
                ((ProjectPanelPage)page).setProject(project);
95
            }
96
        }
97
    }
98
    
99
    @Override
100
    public Object getWindowProfile() {
101
        return WindowInfo.PROJECT_PROFILE;
102
    }
103
    
104
    @Override
105
    public WindowInfo getWindowInfo() {
106
        if (viewInfo == null) {
107
            I18nManager i18n = ToolsLocator.getI18nManager();
108
            viewInfo = new WindowInfo(WindowInfo.MAXIMIZABLE | WindowInfo.RESIZABLE);
109
            viewInfo.setWidth(this.getWidth());
110
            viewInfo.setHeight(this.getHeight());
111
            int w = this.getPreferredSize().width;
112
            if( w < 450 ) {
113
                w = 450;
114
            }
115
            viewInfo.setNormalWidth(w);
116
            viewInfo.setNormalHeight(this.getPreferredSize().height);
117
            viewInfo.setMinimumSize(getPreferredSize());
118
            viewInfo.setTitle(i18n.getTranslation("_Project_manager"));
119
        }
120
        return viewInfo;
121
    }    
122
    
123
}