Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.installer / org.gvsig.installer.swing / org.gvsig.installer.swing.impl / src / main / java / org / gvsig / installer / swing / impl / execution / panel / SelectPackagesPanel.java @ 43126

History | View | Annotate | Download (4.78 KB)

1 40560 jjdelcerro
/**
2
 * gvSIG. Desktop Geographic Information System.
3 40435 jjdelcerro
 *
4 40560 jjdelcerro
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6 43126 jjdelcerro
 * This program is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10 40560 jjdelcerro
 *
11 43126 jjdelcerro
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15 40560 jjdelcerro
 *
16 43126 jjdelcerro
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 40560 jjdelcerro
 *
20 43126 jjdelcerro
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
22 40435 jjdelcerro
 */
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27
package org.gvsig.installer.swing.impl.execution.panel;
28
29
import java.awt.BorderLayout;
30
import java.util.ArrayList;
31
import java.util.List;
32
33
import javax.swing.JPanel;
34 43126 jjdelcerro
import org.apache.commons.lang3.StringUtils;
35 40435 jjdelcerro
36
import org.gvsig.installer.lib.api.PackageInfo;
37
import org.gvsig.installer.lib.api.execution.InstallPackageService;
38
import org.gvsig.installer.swing.api.SwingInstallerLocator;
39 43126 jjdelcerro
import org.gvsig.installer.swing.api.execution.PackageFilter;
40 40435 jjdelcerro
import org.gvsig.installer.swing.impl.DefaultSwingInstallerManager;
41 43126 jjdelcerro
import org.gvsig.installer.swing.impl.execution.panel.filters.TypeFilter;
42 40435 jjdelcerro
import org.gvsig.installer.swing.impl.execution.panel.model.PackagesTableModel;
43 43126 jjdelcerro
import org.gvsig.installer.swing.impl.execution.wizard.SelectPackagesWizardPage;
44 40435 jjdelcerro
45
/**
46
 * @author gvSIG Team
47
 * @version $Id$
48
 */
49
public class SelectPackagesPanel extends JPanel {
50
51 43126 jjdelcerro
    private SelectPackagesWizardPage wizard;
52
    private static final long serialVersionUID = -7554097983061858479L;
53
    protected DefaultSwingInstallerManager swingInstallerManager = null;
54
    private PackagesTablePanel packagesTablePanel;
55 40435 jjdelcerro
56 43126 jjdelcerro
    private PackagesTableModel pluginsTableModel = null;
57 40435 jjdelcerro
58 43126 jjdelcerro
    public SelectPackagesPanel(SelectPackagesWizardPage selectPackagesWizard) {
59
        super();
60
        this.wizard = selectPackagesWizard;
61
        swingInstallerManager = (DefaultSwingInstallerManager) SwingInstallerLocator
62
                .getSwingInstallerManager();
63
        initComponents();
64
    }
65 40435 jjdelcerro
66 43126 jjdelcerro
    public JPanel getJPanel() {
67
        return this;
68
    }
69 40435 jjdelcerro
70 43126 jjdelcerro
    public void updateTableModel(PackagesTableModel pluginsTableModel) {
71
        packagesTablePanel.setTableModel(pluginsTableModel);
72
        add(packagesTablePanel, BorderLayout.CENTER);
73
    }
74 40435 jjdelcerro
75 43126 jjdelcerro
    public void selectPackages() {
76
        packagesTablePanel.selectPackages();
77
    }
78 40435 jjdelcerro
79 43126 jjdelcerro
    private void initComponents() {
80
        setLayout(new BorderLayout(0, 0));
81 40435 jjdelcerro
82 43126 jjdelcerro
        packagesTablePanel = new PackagesTablePanel(this);
83
        add(packagesTablePanel, BorderLayout.CENTER);
84
    }
85 40435 jjdelcerro
86 43126 jjdelcerro
    public List<PackageInfo> getPackagesToInstall() {
87 40435 jjdelcerro
88 43126 jjdelcerro
        List<PackageInfo> packages = packagesTablePanel.getPackagesToInstall();
89 40435 jjdelcerro
90 43126 jjdelcerro
        List<PackageInfo> packagesToInstall = new ArrayList<PackageInfo>();
91
        packagesToInstall.addAll(packages);
92
        return packagesToInstall;
93
    }
94 40435 jjdelcerro
95 43126 jjdelcerro
    public boolean isPackageSelected() {
96
        return packagesTablePanel.isPackageSelected();
97
    }
98 40435 jjdelcerro
99 43126 jjdelcerro
    public void checkIfPluginSelected() {
100
        wizard.checkIfPluginSelected();
101
    }
102 40435 jjdelcerro
103 43126 jjdelcerro
    public void packageSelectionChanged(Object value, int row, int column) {
104
    }
105 40435 jjdelcerro
106 43126 jjdelcerro
    public void updatePanel() {
107 40435 jjdelcerro
108 43126 jjdelcerro
        InstallPackageService installerExecutionService = wizard
109
                .getWizardPanel()
110
                .getInstallerExecutionService();
111 40435 jjdelcerro
112 43126 jjdelcerro
        if (pluginsTableModel == null) {
113
            pluginsTableModel = new PackagesTableModel(swingInstallerManager,
114
                    installerExecutionService, true);
115
        }
116
        pluginsTableModel.updatePackages();
117 40435 jjdelcerro
118 43126 jjdelcerro
        updateTableModel(pluginsTableModel);
119 40435 jjdelcerro
120 43126 jjdelcerro
        if (wizard.isDefaultPackagesSelectionSet()) {
121
            pluginsTableModel.selectDefaultPackages();
122
        }
123 40435 jjdelcerro
124 43126 jjdelcerro
    }
125 40435 jjdelcerro
126 43126 jjdelcerro
    public PackagesTableModel getModel() {
127
        return this.pluginsTableModel;
128
    }
129 40435 jjdelcerro
130 43126 jjdelcerro
    public void clearPanel() {
131
        packagesTablePanel.clearAllPanels();
132
    }
133 40435 jjdelcerro
134
    /**
135 43126 jjdelcerro
     *
136 40435 jjdelcerro
     */
137
    public void setInitialFilter() {
138
        packagesTablePanel.setInitialFilter();
139 43126 jjdelcerro
140 40435 jjdelcerro
    }
141
142 43126 jjdelcerro
    public void setBaseFilter(PackageFilter filter) {
143
        if (filter == null) {
144
            this.packagesTablePanel.setBaseFilter(null);
145
            this.packagesTablePanel.setEnabledTypeFilter(true);
146
        } else {
147
            this.packagesTablePanel.setBaseFilter(filter);
148
            if (filter instanceof TypeFilter) {
149
                this.packagesTablePanel.setEnabledTypeFilter(false);
150
            }
151
        }
152
    }
153
154 40435 jjdelcerro
}