Revision 38358
tags/v2_0_0_Build_2047/extensions/org.gvsig.installer/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/DefaultSwingInstallerLibrary.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2010 {Prodevelop} {Task} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.installer.swing.impl; |
|
29 |
|
|
30 |
import java.util.Locale; |
|
31 |
|
|
32 |
import org.gvsig.i18n.Messages; |
|
33 |
import org.gvsig.installer.lib.api.InstallerLibrary; |
|
34 |
import org.gvsig.installer.swing.api.SwingInstallerLibrary; |
|
35 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
|
36 |
import org.gvsig.installer.swing.api.SwingInstallerManager; |
|
37 |
import org.gvsig.installer.swing.impl.creation.DefaultMakePluginPackageWizard; |
|
38 |
import org.gvsig.installer.swing.impl.execution.DefaultInstallPackageWizard; |
|
39 |
import org.gvsig.tools.library.AbstractLibrary; |
|
40 |
import org.gvsig.tools.library.LibraryException; |
|
41 |
|
|
42 |
/** |
|
43 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a> |
|
44 |
*/ |
|
45 |
public class DefaultSwingInstallerLibrary extends AbstractLibrary { |
|
46 |
|
|
47 |
@Override |
|
48 |
public void doRegistration() { |
|
49 |
registerAsImplementationOf(SwingInstallerLibrary.class); |
|
50 |
require(InstallerLibrary.class); |
|
51 |
} |
|
52 |
|
|
53 |
@Override |
|
54 |
protected void doInitialize() throws LibraryException { |
|
55 |
SwingInstallerLocator |
|
56 |
.registerSwingInstallerManager(DefaultSwingInstallerManager.class); |
|
57 |
if (!Messages.hasLocales()) { |
|
58 |
Messages.addLocale(Locale.getDefault()); |
|
59 |
} |
|
60 |
Messages.addResourceFamily("org.gvsig.installer.swing.impl.text", |
|
61 |
DefaultSwingInstallerLibrary.class.getClassLoader(), |
|
62 |
DefaultSwingInstallerLibrary.class.getClass().getName()); |
|
63 |
} |
|
64 |
|
|
65 |
@Override |
|
66 |
protected void doPostInitialize() throws LibraryException { |
|
67 |
SwingInstallerManager swingInstallerManager = SwingInstallerLocator |
|
68 |
.getSwingInstallerManager(); |
|
69 |
|
|
70 |
swingInstallerManager |
|
71 |
.registerMakePluginPackageWizardInstallerCreationWizard(DefaultMakePluginPackageWizard.class); |
|
72 |
swingInstallerManager |
|
73 |
.registerInstallPackageWizard(DefaultInstallPackageWizard.class); |
|
74 |
} |
|
75 |
} |
|
0 | 76 |
tags/v2_0_0_Build_2047/extensions/org.gvsig.installer/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/panel/DefaultProgressPanel.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2010 {Prodevelop} {Task} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.installer.swing.impl.panel; |
|
29 |
|
|
30 |
import java.awt.GridBagConstraints; |
|
31 |
import java.awt.GridBagLayout; |
|
32 |
import java.awt.Insets; |
|
33 |
|
|
34 |
import org.slf4j.Logger; |
|
35 |
import org.slf4j.LoggerFactory; |
|
36 |
|
|
37 |
import org.gvsig.installer.swing.api.JProgressPanel; |
|
38 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
39 |
import org.gvsig.tools.swing.api.task.JTaskStatus; |
|
40 |
import org.gvsig.tools.task.TaskStatus; |
|
41 |
|
|
42 |
/** |
|
43 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a> |
|
44 |
*/ |
|
45 |
public class DefaultProgressPanel extends JProgressPanel { |
|
46 |
|
|
47 |
private static Logger logger = LoggerFactory |
|
48 |
.getLogger(DefaultProgressPanel.class); |
|
49 |
/** |
|
50 |
* |
|
51 |
*/ |
|
52 |
private static final long serialVersionUID = 3961459135479121712L; |
|
53 |
final private JTaskStatus progressBar; |
|
54 |
|
|
55 |
public DefaultProgressPanel() { |
|
56 |
super(); |
|
57 |
progressBar = ToolsSwingLocator.getTaskStatusSwingManager() |
|
58 |
.createJTaskStatus(); |
|
59 |
|
|
60 |
initComponents(); |
|
61 |
} |
|
62 |
|
|
63 |
@Override |
|
64 |
public void bind(TaskStatus taskStatus) { |
|
65 |
this.progressBar.bind(taskStatus); |
|
66 |
} |
|
67 |
|
|
68 |
protected void initComponents() { |
|
69 |
java.awt.GridBagConstraints gridBagConstraints; |
|
70 |
|
|
71 |
setLayout(new GridBagLayout()); |
|
72 |
gridBagConstraints = new GridBagConstraints(); |
|
73 |
gridBagConstraints.gridx = 0; |
|
74 |
gridBagConstraints.gridy = 2; |
|
75 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; |
|
76 |
gridBagConstraints.weightx = 1.0; |
|
77 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
|
78 |
add(progressBar, gridBagConstraints); |
|
79 |
|
|
80 |
} |
|
81 |
|
|
82 |
@Override |
|
83 |
public void showErrorMessage(String msg, Exception ex) { |
|
84 |
logger.error(msg, ex); |
|
85 |
} |
|
86 |
} |
|
0 | 87 |
tags/v2_0_0_Build_2047/extensions/org.gvsig.installer/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/wizard/WizardListenerAdapter.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2010 {Prodevelop} {Task} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.installer.swing.impl.wizard; |
|
29 |
|
|
30 |
import org.gvsig.gui.beans.wizard.WizardPanel; |
|
31 |
import org.gvsig.gui.beans.wizard.WizardPanelActionListener; |
|
32 |
import org.gvsig.installer.swing.api.wizard.InstallerWizardPanel; |
|
33 |
import org.gvsig.tools.task.CancellableTask; |
|
34 |
|
|
35 |
/** |
|
36 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a> |
|
37 |
*/ |
|
38 |
public class WizardListenerAdapter implements WizardPanelActionListener { |
|
39 |
|
|
40 |
private InstallerWizardPanel installerWizardPanel; |
|
41 |
|
|
42 |
public WizardListenerAdapter(InstallerWizardPanel installerWizardPanel) { |
|
43 |
super(); |
|
44 |
this.installerWizardPanel = installerWizardPanel; |
|
45 |
} |
|
46 |
|
|
47 |
public void cancel(WizardPanel wizardPanel) { |
|
48 |
if (installerWizardPanel.getWizardActionListener() != null) { |
|
49 |
for (CancellableTask task : installerWizardPanel |
|
50 |
.getCancellableTasks()) { |
|
51 |
task.cancelRequest(); |
|
52 |
} |
|
53 |
installerWizardPanel.getWizardActionListener().cancel( |
|
54 |
installerWizardPanel); |
|
55 |
} |
|
56 |
} |
|
57 |
|
|
58 |
public void finish(WizardPanel wizardPanel) { |
|
59 |
if (installerWizardPanel.getWizardActionListener() != null) { |
|
60 |
installerWizardPanel.getWizardActionListener().finish( |
|
61 |
installerWizardPanel); |
|
62 |
} |
|
63 |
} |
|
64 |
} |
|
0 | 65 |
tags/v2_0_0_Build_2047/extensions/org.gvsig.installer/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/PackagePropertiesFilterPanel.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 |
*/ |
|
22 |
package org.gvsig.installer.swing.impl.execution.panel; |
|
23 |
|
|
24 |
import java.awt.GridBagConstraints; |
|
25 |
import java.awt.GridBagLayout; |
|
26 |
import java.awt.Insets; |
|
27 |
import java.awt.event.ActionEvent; |
|
28 |
import java.awt.event.ActionListener; |
|
29 |
import java.awt.event.MouseEvent; |
|
30 |
import java.awt.event.MouseListener; |
|
31 |
import java.util.List; |
|
32 |
|
|
33 |
import javax.swing.DefaultListModel; |
|
34 |
import javax.swing.JButton; |
|
35 |
import javax.swing.JList; |
|
36 |
import javax.swing.JPanel; |
|
37 |
import javax.swing.JScrollPane; |
|
38 |
import javax.swing.ListModel; |
|
39 |
|
|
40 |
import org.gvsig.installer.lib.api.execution.InstallPackageService; |
|
41 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
|
42 |
import org.gvsig.installer.swing.impl.DefaultSwingInstallerManager; |
|
43 |
import org.gvsig.installer.swing.impl.execution.panel.filters.AllFilter; |
|
44 |
import org.gvsig.installer.swing.impl.execution.panel.filters.CategoryFilter; |
|
45 |
import org.gvsig.installer.swing.impl.execution.panel.filters.PackageFilter; |
|
46 |
import org.gvsig.installer.swing.impl.execution.panel.filters.TypeFilter; |
|
47 |
|
|
48 |
/** |
|
49 |
* @author gvSIG Team |
|
50 |
* @version $Id$ |
|
51 |
* |
|
52 |
*/ |
|
53 |
public class PackagePropertiesFilterPanel extends JPanel implements |
|
54 |
ActionListener { |
|
55 |
|
|
56 |
private static final long serialVersionUID = 3767011079359743742L; |
|
57 |
|
|
58 |
public enum PropertiesFilter { |
|
59 |
CATEGORIES, TYPES |
|
60 |
} |
|
61 |
|
|
62 |
private PackagesTablePanel packagesTablePanel; |
|
63 |
|
|
64 |
private JScrollPane filterScrollPane; |
|
65 |
private JList jList; |
|
66 |
// private PropertiesFilter optionFilter = null; |
|
67 |
private DefaultListModel model = null; |
|
68 |
|
|
69 |
private DefaultSwingInstallerManager manager; |
|
70 |
|
|
71 |
public PackagePropertiesFilterPanel(PackagesTablePanel packagesTablePanel) { |
|
72 |
this.packagesTablePanel = packagesTablePanel; |
|
73 |
manager = (DefaultSwingInstallerManager) SwingInstallerLocator |
|
74 |
.getSwingInstallerManager(); |
|
75 |
initComponents(); |
|
76 |
} |
|
77 |
|
|
78 |
private void initComponents() { |
|
79 |
|
|
80 |
model = new DefaultListModel(); |
|
81 |
jList = new JList(model); |
|
82 |
|
|
83 |
filterScrollPane = new JScrollPane(jList); |
|
84 |
MyMouseListener mouseListener = new MyMouseListener(); |
|
85 |
// filterScrollPane.addMouseListener(mouseListener); |
|
86 |
jList.addMouseListener(mouseListener); |
|
87 |
|
|
88 |
JButton categoriesButton = new JButton(manager.getText("_categories")); |
|
89 |
categoriesButton.setActionCommand("categories"); |
|
90 |
categoriesButton.addActionListener(this); |
|
91 |
|
|
92 |
JButton typesButton = new JButton(manager.getText("_types")); |
|
93 |
typesButton.setActionCommand("types"); |
|
94 |
typesButton.addActionListener(this); |
|
95 |
|
|
96 |
this.setLayout(new GridBagLayout()); |
|
97 |
|
|
98 |
java.awt.GridBagConstraints gridBagConstraints; |
|
99 |
|
|
100 |
gridBagConstraints = new GridBagConstraints(); |
|
101 |
gridBagConstraints.fill = GridBagConstraints.BOTH; |
|
102 |
gridBagConstraints.gridx = 0; |
|
103 |
gridBagConstraints.gridy = 0; |
|
104 |
gridBagConstraints.weightx = 1; |
|
105 |
gridBagConstraints.weighty = 1; |
|
106 |
// gridBagConstraints.gridheight = 3; |
|
107 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
|
108 |
this.add(filterScrollPane, gridBagConstraints); |
|
109 |
|
|
110 |
gridBagConstraints = new GridBagConstraints(); |
|
111 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; |
|
112 |
gridBagConstraints.gridx = 0; |
|
113 |
gridBagConstraints.gridy = 1; |
|
114 |
gridBagConstraints.weightx = 1; |
|
115 |
gridBagConstraints.weighty = 0; |
|
116 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
|
117 |
this.add(categoriesButton, gridBagConstraints); |
|
118 |
|
|
119 |
gridBagConstraints = new GridBagConstraints(); |
|
120 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; |
|
121 |
gridBagConstraints.gridx = 0; |
|
122 |
gridBagConstraints.gridy = 2; |
|
123 |
gridBagConstraints.weightx = 1; |
|
124 |
gridBagConstraints.weighty = 0; |
|
125 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
|
126 |
this.add(typesButton, gridBagConstraints); |
|
127 |
|
|
128 |
} |
|
129 |
|
|
130 |
public void resetPanel() { |
|
131 |
model.removeAllElements(); |
|
132 |
// optionFilter = null; |
|
133 |
PackageFilter filter = null; |
|
134 |
packagesTablePanel.setFilter(filter); |
|
135 |
} |
|
136 |
|
|
137 |
public void actionPerformed(ActionEvent e) { |
|
138 |
|
|
139 |
InstallPackageService service = packagesTablePanel |
|
140 |
.getSelectPackagesPanel().getModel().getInstallPackageService(); |
|
141 |
|
|
142 |
if ("categories".equals(e.getActionCommand())) { |
|
143 |
// this.optionFilter = PropertiesFilter.CATEGORIES; |
|
144 |
model.removeAllElements(); |
|
145 |
packagesTablePanel.resetPanel(); |
|
146 |
|
|
147 |
List<String> categories = service.getCategories(); |
|
148 |
|
|
149 |
model.add(0,new AllFilter()); |
|
150 |
if (categories != null) { |
|
151 |
for (int i = 0; i < categories.size(); i++) { |
|
152 |
model.add(i+1, new CategoryFilter(categories.get(i))); |
|
153 |
} |
|
154 |
} |
|
155 |
|
|
156 |
} else { |
|
157 |
if ("types".equals(e.getActionCommand())) { |
|
158 |
// this.optionFilter = PropertiesFilter.TYPES; |
|
159 |
model.removeAllElements(); |
|
160 |
packagesTablePanel.resetPanel(); |
|
161 |
|
|
162 |
List<String> types = service.getTypes(); |
|
163 |
|
|
164 |
model.add(0,new AllFilter()); |
|
165 |
if (types != null) { |
|
166 |
for (int i = 0; i < types.size(); i++) { |
|
167 |
model.add(i+1, new TypeFilter(types.get(i))); |
|
168 |
} |
|
169 |
} |
|
170 |
} |
|
171 |
} |
|
172 |
} |
|
173 |
|
|
174 |
private class MyMouseListener implements MouseListener { |
|
175 |
|
|
176 |
public void mouseClicked(MouseEvent e) { |
|
177 |
int i = jList.getSelectedIndex(); |
|
178 |
if (i >= 0) { |
|
179 |
ListModel listModel = jList.getModel(); |
|
180 |
PackageFilter filter = (PackageFilter) listModel.getElementAt(i); |
|
181 |
packagesTablePanel.setFilter(filter); |
|
182 |
|
|
183 |
// |
|
184 |
// // update packets list to filter |
|
185 |
// if (optionFilter == PropertiesFilter.TYPES) { |
|
186 |
// TypeFilter typeFilter = new TypeFilter(element); |
|
187 |
// packagesTablePanel.setFilter(typeFilter); |
|
188 |
// } else if (optionFilter == PropertiesFilter.CATEGORIES) { |
|
189 |
// CategoryFilter categoryFilter = new CategoryFilter(element); |
|
190 |
// packagesTablePanel.setFilter(categoryFilter); |
|
191 |
// } |
|
192 |
|
|
193 |
} |
|
194 |
} |
|
195 |
|
|
196 |
public void mouseEntered(MouseEvent e) { |
|
197 |
} |
|
198 |
|
|
199 |
public void mouseExited(MouseEvent e) { |
|
200 |
} |
|
201 |
|
|
202 |
public void mousePressed(MouseEvent e) { |
|
203 |
} |
|
204 |
|
|
205 |
public void mouseReleased(MouseEvent e) { |
|
206 |
} |
|
207 |
|
|
208 |
} |
|
209 |
|
|
210 |
} |
|
0 | 211 |
tags/v2_0_0_Build_2047/extensions/org.gvsig.installer/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/SelectPackagesPanel.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2010 {Prodevelop} {Task} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.installer.swing.impl.execution.panel; |
|
29 |
|
|
30 |
import java.awt.BorderLayout; |
|
31 |
import java.util.ArrayList; |
|
32 |
import java.util.List; |
|
33 |
|
|
34 |
import javax.swing.JPanel; |
|
35 |
|
|
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 |
import org.gvsig.installer.swing.impl.DefaultSwingInstallerManager; |
|
40 |
import org.gvsig.installer.swing.impl.execution.DefaultInstallPackageWizard; |
|
41 |
import org.gvsig.installer.swing.impl.execution.panel.model.PackagesTableModel; |
|
42 |
import org.gvsig.installer.swing.impl.execution.wizard.SelectPackagesWizard; |
|
43 |
|
|
44 |
/** |
|
45 |
* @author gvSIG Team |
|
46 |
* @version $Id$ |
|
47 |
*/ |
|
48 |
public class SelectPackagesPanel extends JPanel { |
|
49 |
|
|
50 |
private SelectPackagesWizard wizard; |
|
51 |
private static final long serialVersionUID = -7554097983061858479L; |
|
52 |
protected DefaultSwingInstallerManager swingInstallerManager = null; |
|
53 |
private PackagesTablePanel packagesTablePanel; |
|
54 |
|
|
55 |
private PackagesTableModel pluginsTableModel = null; |
|
56 |
|
|
57 |
public SelectPackagesPanel(SelectPackagesWizard selectPackagesWizard) { |
|
58 |
super(); |
|
59 |
this.wizard = selectPackagesWizard; |
|
60 |
swingInstallerManager = (DefaultSwingInstallerManager) SwingInstallerLocator |
|
61 |
.getSwingInstallerManager(); |
|
62 |
initComponents(); |
|
63 |
} |
|
64 |
|
|
65 |
public JPanel getJPanel() { |
|
66 |
return this; |
|
67 |
} |
|
68 |
|
|
69 |
public void updateTableModel(PackagesTableModel pluginsTableModel) { |
|
70 |
packagesTablePanel.setTableModel(pluginsTableModel); |
|
71 |
add(packagesTablePanel, BorderLayout.CENTER); |
|
72 |
} |
|
73 |
|
|
74 |
public void selectPackages() { |
|
75 |
packagesTablePanel.selectPackages(); |
|
76 |
} |
|
77 |
|
|
78 |
private void initComponents() { |
|
79 |
setLayout(new BorderLayout(0, 0)); |
|
80 |
|
|
81 |
packagesTablePanel = new PackagesTablePanel(this); |
|
82 |
add(packagesTablePanel, BorderLayout.CENTER); |
|
83 |
} |
|
84 |
|
|
85 |
public List<PackageInfo> getPackagesToInstall() { |
|
86 |
|
|
87 |
List<PackageInfo> packages = packagesTablePanel.getPackagesToInstall(); |
|
88 |
|
|
89 |
List<PackageInfo> packagesToInstall = new ArrayList<PackageInfo>(); |
|
90 |
packagesToInstall.addAll(packages); |
|
91 |
return packagesToInstall; |
|
92 |
} |
|
93 |
|
|
94 |
public boolean isPackageSelected() { |
|
95 |
return packagesTablePanel.isPackageSelected(); |
|
96 |
} |
|
97 |
|
|
98 |
public void checkIfPluginSelected() { |
|
99 |
wizard.checkIfPluginSelected(); |
|
100 |
} |
|
101 |
|
|
102 |
public void packageSelectionChanged(Object value, int row, int column) { |
|
103 |
} |
|
104 |
|
|
105 |
public void updatePanel() { |
|
106 |
|
|
107 |
InstallPackageService installerExecutionService = wizard |
|
108 |
.getDefaultInstallPackageWizard() |
|
109 |
.getInstallerExecutionService(); |
|
110 |
|
|
111 |
if (pluginsTableModel == null) { |
|
112 |
pluginsTableModel = new PackagesTableModel(swingInstallerManager, |
|
113 |
installerExecutionService, true); |
|
114 |
} |
|
115 |
pluginsTableModel.updatePackages(); |
|
116 |
|
|
117 |
updateTableModel(pluginsTableModel); |
|
118 |
|
|
119 |
if (wizard.isDefaultPackagesSelectionSet()) { |
|
120 |
pluginsTableModel.selectDefaultPackages(); |
|
121 |
} |
|
122 |
|
|
123 |
} |
|
124 |
|
|
125 |
public DefaultInstallPackageWizard getDefaultInstallPackageWizard() { |
|
126 |
return wizard.getDefaultInstallPackageWizard(); |
|
127 |
} |
|
128 |
|
|
129 |
public PackagesTableModel getModel() { |
|
130 |
return this.pluginsTableModel; |
|
131 |
} |
|
132 |
|
|
133 |
public void clearPanel() { |
|
134 |
packagesTablePanel.clearAllPanels(); |
|
135 |
} |
|
136 |
|
|
137 |
} |
|
0 | 138 |
tags/v2_0_0_Build_2047/extensions/org.gvsig.installer/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/model/IPackageSelectionListener.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2010 {Prodevelop} {Task} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.installer.swing.impl.execution.panel.model; |
|
29 |
|
|
30 |
/** |
|
31 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a> |
|
32 |
*/ |
|
33 |
public interface IPackageSelectionListener { |
|
34 |
|
|
35 |
public void packageSelectionChanged(Object value, int row, int column); |
|
36 |
} |
|
0 | 37 |
tags/v2_0_0_Build_2047/extensions/org.gvsig.installer/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/model/PackagesTableModel.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2010 {Prodevelop} {Task} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.installer.swing.impl.execution.panel.model; |
|
29 |
|
|
30 |
import java.net.URL; |
|
31 |
import java.util.ArrayList; |
|
32 |
import java.util.Arrays; |
|
33 |
import java.util.Comparator; |
|
34 |
import java.util.HashMap; |
|
35 |
import java.util.List; |
|
36 |
import java.util.Map; |
|
37 |
|
|
38 |
import javax.swing.table.AbstractTableModel; |
|
39 |
|
|
40 |
import org.gvsig.installer.lib.api.InstallerLocator; |
|
41 |
import org.gvsig.installer.lib.api.InstallerManager; |
|
42 |
import org.gvsig.installer.lib.api.PackageInfo; |
|
43 |
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException; |
|
44 |
import org.gvsig.installer.lib.api.execution.InstallPackageService; |
|
45 |
import org.gvsig.installer.swing.api.SwingInstallerManager; |
|
46 |
import org.gvsig.installer.swing.impl.execution.panel.filters.NameDescriptionOrCodeFilter; |
|
47 |
import org.gvsig.installer.swing.impl.execution.panel.filters.PackageFilter; |
|
48 |
|
|
49 |
public class PackagesTableModel extends AbstractTableModel { |
|
50 |
|
|
51 |
private static final long serialVersionUID = -454014676003979512L; |
|
52 |
|
|
53 |
public enum PackageStatus { |
|
54 |
INSTALLED, NOT_INSTALLED, TO_REINSTALL, TO_INSTALL, INSTALLED_NOT_INSTALLABLE, BROKEN; |
|
55 |
} |
|
56 |
|
|
57 |
public enum PackageOfficialRecommended { |
|
58 |
OFFICIAL_NOT_RECOMMENDED, OFFICIAL_RECOMMENDED, NOT_OFFICIAL_RECOMMENDED, NOT_OFFICIAL_NOT_RECOMMENDED |
|
59 |
} |
|
60 |
|
|
61 |
public class PackageOsAndArchitecture { |
|
62 |
public String os; |
|
63 |
public String arch; |
|
64 |
} |
|
65 |
|
|
66 |
// |
|
67 |
// public enum PackageOsAndArchitecture { |
|
68 |
// WINDOLS_32, WINDOLS_64, LINUX_32, LINUX_64, ALL, OTHER |
|
69 |
// } |
|
70 |
|
|
71 |
private TablePackageInfo[] installerInfos = null; |
|
72 |
|
|
73 |
private final String[] columnNames; |
|
74 |
|
|
75 |
private InstallerManager installerManager = InstallerLocator |
|
76 |
.getInstallerManager(); |
|
77 |
private InstallPackageService installerExecutionService; |
|
78 |
|
|
79 |
boolean isOfficial; |
|
80 |
private NameDescriptionOrCodeFilter packageFastFilter = null; |
|
81 |
private PackageFilter packageFilter = null; |
|
82 |
|
|
83 |
public PackagesTableModel(SwingInstallerManager swingInstallerManager, |
|
84 |
InstallPackageService installerExecutionService, boolean isOfficial) { |
|
85 |
|
|
86 |
this.installerExecutionService = installerExecutionService; |
|
87 |
this.isOfficial = isOfficial; |
|
88 |
Map<String, TablePackageInfo> infos = getDefaultPackages(); |
|
89 |
|
|
90 |
installerInfos = infos.values().toArray( |
|
91 |
new TablePackageInfo[infos.size()]); |
|
92 |
sortInstallerInfos(); |
|
93 |
|
|
94 |
columnNames = new String[] { |
|
95 |
"", // Check column |
|
96 |
"", "", swingInstallerManager.getText("_name"), |
|
97 |
swingInstallerManager.getText("_version"), |
|
98 |
swingInstallerManager.getText("_type") }; |
|
99 |
|
|
100 |
} |
|
101 |
|
|
102 |
private void sortInstallerInfos() { |
|
103 |
Arrays.sort(this.installerInfos, new Comparator<TablePackageInfo>() { |
|
104 |
|
|
105 |
public int compare(TablePackageInfo o1, TablePackageInfo o2) { |
|
106 |
return o1.getPackageInfo().getName().compareToIgnoreCase( |
|
107 |
o2.getPackageInfo().getName()); |
|
108 |
} |
|
109 |
}); |
|
110 |
} |
|
111 |
|
|
112 |
private Map<String, TablePackageInfo> getDefaultPackages() { |
|
113 |
|
|
114 |
List<String> defaultIDs = installerExecutionService |
|
115 |
.getDefaultSelectedPackagesIDs(); |
|
116 |
|
|
117 |
Map<String, TablePackageInfo> infos = new HashMap<String, TablePackageInfo>(); |
|
118 |
// Add installable package infos |
|
119 |
for (int i = 0; i < installerExecutionService.getPackageCount(); i++) { |
|
120 |
PackageInfo installerInfo = installerExecutionService |
|
121 |
.getPackageInfo(i); |
|
122 |
TablePackageInfo info = new TablePackageInfo(installerInfo, false, |
|
123 |
true); |
|
124 |
if (defaultIDs != null) { |
|
125 |
for (int j = 0; j < defaultIDs.size(); j++) { |
|
126 |
if (info.getPackageInfo().matchID(defaultIDs.get(j))) { |
|
127 |
if (info.getPackageInfo().getOperatingSystem().equals( |
|
128 |
installerManager.getOperatingSystem()) |
|
129 |
|| info.getPackageInfo().getOperatingSystem() |
|
130 |
.equals("all")) { |
|
131 |
info.setDefault(true); |
|
132 |
break; |
|
133 |
} |
|
134 |
|
|
135 |
} |
|
136 |
} |
|
137 |
} |
|
138 |
infos.put(info.getID(), info); |
|
139 |
} |
|
140 |
// Add already installed package infos |
|
141 |
try { |
|
142 |
PackageInfo[] installedPackages = installerManager |
|
143 |
.getInstalledPackages(); |
|
144 |
|
|
145 |
for (int i = 0; i < installedPackages.length; i++) { |
|
146 |
TablePackageInfo info = new TablePackageInfo( |
|
147 |
installedPackages[i], true, false); |
|
148 |
TablePackageInfo x = infos.get(info.getID()); |
|
149 |
if (x == null) { |
|
150 |
infos.put(info.getID(), info); |
|
151 |
} else { |
|
152 |
x.setInstalled(true); |
|
153 |
} |
|
154 |
} |
|
155 |
} catch (MakePluginPackageServiceException e) { |
|
156 |
throw new RuntimeException(e); |
|
157 |
} |
|
158 |
|
|
159 |
return infos; |
|
160 |
} |
|
161 |
|
|
162 |
// get filtered packages |
|
163 |
private Map<String, TablePackageInfo> getFilteredPackages( |
|
164 |
Map<String, TablePackageInfo> packageInfos) { |
|
165 |
|
|
166 |
Map<String, TablePackageInfo> infos = new HashMap<String, TablePackageInfo>(); |
|
167 |
|
|
168 |
TablePackageInfo[] packs = packageInfos.values().toArray( |
|
169 |
new TablePackageInfo[infos.size()]); |
|
170 |
|
|
171 |
for (int i = 0; i < packs.length; i++) { |
|
172 |
PackageInfo installerInfo = packs[i].getPackageInfo(); |
|
173 |
|
|
174 |
if (packageFilter.match(installerInfo)) { |
|
175 |
TablePackageInfo info = packs[i]; |
|
176 |
infos.put(installerInfo.getID(), info); |
|
177 |
} |
|
178 |
} |
|
179 |
return infos; |
|
180 |
} |
|
181 |
|
|
182 |
// get fast filtered packages (by name or description) |
|
183 |
private Map<String, TablePackageInfo> getFastFilteredPackages( |
|
184 |
Map<String, TablePackageInfo> packageInfos) { |
|
185 |
|
|
186 |
Map<String, TablePackageInfo> infos = new HashMap<String, TablePackageInfo>(); |
|
187 |
|
|
188 |
TablePackageInfo[] packs = packageInfos.values().toArray( |
|
189 |
new TablePackageInfo[infos.size()]); |
|
190 |
|
|
191 |
for (int i = 0; i < packs.length; i++) { |
|
192 |
PackageInfo installerInfo = packs[i].getPackageInfo(); |
|
193 |
|
|
194 |
if (packageFastFilter.match(installerInfo)) { |
|
195 |
TablePackageInfo info = packs[i]; |
|
196 |
infos.put(installerInfo.getID(), info); |
|
197 |
} |
|
198 |
} |
|
199 |
return infos; |
|
200 |
} |
|
201 |
|
|
202 |
public void updatePackages() { |
|
203 |
|
|
204 |
Map<String, TablePackageInfo> infos = getDefaultPackages(); |
|
205 |
|
|
206 |
// check if there is a filter set (category, type, etc) |
|
207 |
if (isPackageFilterSet()) { |
|
208 |
infos = getFilteredPackages(infos); |
|
209 |
} |
|
210 |
|
|
211 |
// check if there is any filter set (fastFilter) |
|
212 |
if (isFastFilterSet()) { |
|
213 |
infos = getFastFilteredPackages(infos); |
|
214 |
} |
|
215 |
|
|
216 |
for (int i = 0; i < installerInfos.length; i++) { |
|
217 |
TablePackageInfo installerInfo = infos.get(installerInfos[i] |
|
218 |
.getID()); |
|
219 |
if (installerInfo != null) { |
|
220 |
installerInfo.setSelected(installerInfos[i].isSelected()); |
|
221 |
} |
|
222 |
} |
|
223 |
|
|
224 |
installerInfos = infos.values().toArray( |
|
225 |
new TablePackageInfo[infos.size()]); |
|
226 |
sortInstallerInfos(); |
|
227 |
|
|
228 |
List<String> idList = installerExecutionService |
|
229 |
.getDefaultSelectedPackagesIDs(); |
|
230 |
|
|
231 |
if (idList != null) { |
|
232 |
for (int i = 0; i < installerInfos.length; i++) { |
|
233 |
for (int j = 0; j < idList.size(); j++) { |
|
234 |
if (installerInfos[i].getPackageInfo().matchID( |
|
235 |
idList.get(j))) { |
|
236 |
if (installerInfos[i].getPackageInfo() |
|
237 |
.getOperatingSystem().equals( |
|
238 |
installerManager.getOperatingSystem()) |
|
239 |
|| installerInfos[i].getPackageInfo() |
|
240 |
.getOperatingSystem().equals("all")) { |
|
241 |
installerInfos[i].setDefault(true); |
|
242 |
} |
|
243 |
} |
|
244 |
} |
|
245 |
} |
|
246 |
} |
|
247 |
} |
|
248 |
|
|
249 |
// selects default packages |
|
250 |
public void selectDefaultPackages() { |
|
251 |
for (int i = 0; i < installerInfos.length; i++) { |
|
252 |
if (installerInfos[i].isDefault()) { |
|
253 |
installerInfos[i].setSelected(true); |
|
254 |
} else { |
|
255 |
installerInfos[i].setSelected(false); |
|
256 |
} |
|
257 |
} |
|
258 |
} |
|
259 |
|
|
260 |
public void selectPackage(PackageInfo pkg) { |
|
261 |
for (int i = 0; i < installerInfos.length; i++) { |
|
262 |
if (pkg.equals(installerInfos[i].getPackageInfo())) { |
|
263 |
installerInfos[i].setSelected(true); |
|
264 |
return; |
|
265 |
} |
|
266 |
} |
|
267 |
} |
|
268 |
|
|
269 |
@Override |
|
270 |
public Class<?> getColumnClass(int columnIndex) { |
|
271 |
switch (columnIndex) { |
|
272 |
case 0: |
|
273 |
return PackageStatus.class; |
|
274 |
case 1: |
|
275 |
return PackageOfficialRecommended.class; |
|
276 |
case 2: |
|
277 |
return PackageOsAndArchitecture.class; |
|
278 |
default: |
|
279 |
return String.class; |
|
280 |
} |
|
281 |
} |
|
282 |
|
|
283 |
public int getColumnCount() { |
|
284 |
return columnNames.length; |
|
285 |
} |
|
286 |
|
|
287 |
@Override |
|
288 |
public String getColumnName(int columnIndex) { |
|
289 |
return columnIndex >= columnNames.length ? "" |
|
290 |
: columnNames[columnIndex]; |
|
291 |
} |
|
292 |
|
|
293 |
public int getRowCount() { |
|
294 |
return installerInfos.length; |
|
295 |
} |
|
296 |
|
|
297 |
public Object getValueAt(int rowIndex, int columnIndex) { |
|
298 |
TablePackageInfo tableInfo = installerInfos[rowIndex]; |
|
299 |
PackageInfo installerInfo = tableInfo.getPackageInfo(); |
|
300 |
|
|
301 |
switch (columnIndex) { |
|
302 |
case 0: |
|
303 |
PackageStatus installStatus = checkStatus(rowIndex); |
|
304 |
return installStatus; |
|
305 |
case 1: |
|
306 |
PackageOfficialRecommended officialRecommended = checkOfficialRecommended(rowIndex); |
|
307 |
return officialRecommended; |
|
308 |
case 2: |
|
309 |
PackageOsAndArchitecture packageSystem = checkPackageSystem(rowIndex); |
|
310 |
return packageSystem; |
|
311 |
case 3: |
|
312 |
return installerInfo.getName(); |
|
313 |
case 4: |
|
314 |
return installerInfo.getVersion(); |
|
315 |
case 5: |
|
316 |
return installerInfo.getType(); |
|
317 |
default: |
|
318 |
return ""; |
|
319 |
|
|
320 |
} |
|
321 |
} |
|
322 |
|
|
323 |
/** |
|
324 |
* @param rowIndex |
|
325 |
* @return |
|
326 |
*/ |
|
327 |
private PackageOsAndArchitecture checkPackageSystem(int rowIndex) { |
|
328 |
PackageOsAndArchitecture oSArch = new PackageOsAndArchitecture(); |
|
329 |
TablePackageInfo tableInfo = installerInfos[rowIndex]; |
|
330 |
PackageInfo installerInfo = tableInfo.getPackageInfo(); |
|
331 |
oSArch.os = installerInfo.getOperatingSystem(); |
|
332 |
oSArch.arch = installerInfo.getArchitecture(); |
|
333 |
return oSArch; |
|
334 |
} |
|
335 |
|
|
336 |
/** |
|
337 |
* @return |
|
338 |
*/ |
|
339 |
private PackageStatus checkStatus(int rowIndex) { |
|
340 |
TablePackageInfo tableInfo = installerInfos[rowIndex]; |
|
341 |
|
|
342 |
// TODO: checkboxes when a package is broken dont work correctly |
|
343 |
if (tableInfo.getPackageInfo().isBroken()) { |
|
344 |
return PackageStatus.BROKEN; |
|
345 |
} |
|
346 |
|
|
347 |
if (tableInfo.isInstalled()) { |
|
348 |
if (tableInfo.isInstallable()) { |
|
349 |
if (tableInfo.isSelected()) { |
|
350 |
return PackageStatus.TO_REINSTALL; |
|
351 |
} else { |
|
352 |
return PackageStatus.INSTALLED; |
|
353 |
} |
|
354 |
} else { |
|
355 |
return PackageStatus.INSTALLED_NOT_INSTALLABLE; |
|
356 |
} |
|
357 |
|
|
358 |
} else { |
|
359 |
if (tableInfo.isSelected()) { |
|
360 |
return PackageStatus.TO_INSTALL; |
|
361 |
} else { |
|
362 |
return PackageStatus.NOT_INSTALLED; |
|
363 |
} |
|
364 |
} |
|
365 |
} |
|
366 |
|
|
367 |
private PackageOfficialRecommended checkOfficialRecommended(int rowIndex) { |
|
368 |
TablePackageInfo tableInfo = installerInfos[rowIndex]; |
|
369 |
PackageInfo packageInfo = tableInfo.getPackageInfo(); |
|
370 |
|
|
371 |
if (packageInfo.isOfficial()) { |
|
372 |
if (installerInfos[rowIndex].isDefault()) { |
|
373 |
return PackageOfficialRecommended.OFFICIAL_RECOMMENDED; |
|
374 |
} else { |
|
375 |
return PackageOfficialRecommended.OFFICIAL_NOT_RECOMMENDED; |
|
376 |
} |
|
377 |
} else { |
|
378 |
if (installerInfos[rowIndex].isDefault()) { |
|
379 |
return PackageOfficialRecommended.NOT_OFFICIAL_RECOMMENDED; |
|
380 |
} else { |
|
381 |
return PackageOfficialRecommended.NOT_OFFICIAL_NOT_RECOMMENDED; |
|
382 |
} |
|
383 |
} |
|
384 |
} |
|
385 |
|
|
386 |
public PackageInfo getPackageInfoAt(int rowIndex) { |
|
387 |
return installerInfos[rowIndex].getPackageInfo(); |
|
388 |
} |
|
389 |
|
|
390 |
public String getDescriptionAt(int rowIndex) { |
|
391 |
return getPackageInfoAt(rowIndex).getDescription(); |
|
392 |
} |
|
393 |
|
|
394 |
public URL getSourcesAt(int rowIndex) { |
|
395 |
return getPackageInfoAt(rowIndex).getSourcesURL(); |
|
396 |
} |
|
397 |
|
|
398 |
public URL getOwnerUrlAt(int rowIndex) { |
|
399 |
return getPackageInfoAt(rowIndex).getOwnerURL(); |
|
400 |
} |
|
401 |
|
|
402 |
public String getOwnerAt(int rowIndex) { |
|
403 |
return getPackageInfoAt(rowIndex).getOwner(); |
|
404 |
} |
|
405 |
|
|
406 |
@Override |
|
407 |
public boolean isCellEditable(int rowIndex, int columnIndex) { |
|
408 |
return (columnIndex == 0) && installerInfos[rowIndex].isInstallable(); |
|
409 |
} |
|
410 |
|
|
411 |
@Override |
|
412 |
public void setValueAt(Object aValue, int rowIndex, int columnIndex) { |
|
413 |
|
|
414 |
if (columnIndex == 0) { |
|
415 |
PackageStatus status = (PackageStatus) aValue; |
|
416 |
TablePackageInfo tableInfo = installerInfos[rowIndex]; |
|
417 |
switch (status) { |
|
418 |
case INSTALLED: |
|
419 |
case NOT_INSTALLED: |
|
420 |
tableInfo.setSelected(false); |
|
421 |
break; |
|
422 |
|
|
423 |
case TO_REINSTALL: |
|
424 |
case TO_INSTALL: |
|
425 |
tableInfo.setSelected(true); |
|
426 |
break; |
|
427 |
} |
|
428 |
} |
|
429 |
} |
|
430 |
|
|
431 |
public List<PackageInfo> getPackagesToInstall() { |
|
432 |
List<PackageInfo> packageInfosToInstall = new ArrayList<PackageInfo>(); |
|
433 |
for (int i = 0; i < installerInfos.length; i++) { |
|
434 |
TablePackageInfo tableInfo = installerInfos[i]; |
|
435 |
if (tableInfo.isSelected()) { |
|
436 |
packageInfosToInstall.add(tableInfo.getPackageInfo()); |
|
437 |
} |
|
438 |
} |
|
439 |
return packageInfosToInstall; |
|
440 |
} |
|
441 |
|
|
442 |
public boolean hasAnyPackageSelected() { |
|
443 |
for (int i = 0; i < installerInfos.length; i++) { |
|
444 |
if (installerInfos[i].isSelected) { |
|
445 |
return true; |
|
446 |
} |
|
447 |
} |
|
448 |
return false; |
|
449 |
} |
|
450 |
|
|
451 |
public static final class TablePackageInfo { |
|
452 |
|
|
453 |
private final PackageInfo packageInfo; |
|
454 |
private boolean isInstalled; |
|
455 |
private final boolean isInstallable; |
|
456 |
private boolean isSelected; |
|
457 |
private boolean isDefault; |
|
458 |
|
|
459 |
public TablePackageInfo(PackageInfo packageInfo, boolean isInstalled, |
|
460 |
boolean isInstallable) { |
|
461 |
this(packageInfo, isInstalled, isInstallable, false, false); |
|
462 |
} |
|
463 |
|
|
464 |
public void setInstalled(boolean installed) { |
|
465 |
this.isInstalled = installed; |
|
466 |
} |
|
467 |
|
|
468 |
public TablePackageInfo(PackageInfo packageInfo, boolean isInstalled, |
|
469 |
boolean isInstallable, boolean isSelected, boolean isDefault) { |
|
470 |
this.packageInfo = packageInfo; |
|
471 |
this.isInstalled = isInstalled; |
|
472 |
this.isInstallable = isInstallable; |
|
473 |
this.isSelected = isSelected; |
|
474 |
this.isDefault = isDefault; |
|
475 |
} |
|
476 |
|
|
477 |
public String getID() { |
|
478 |
PackageInfo pkg = this.getPackageInfo(); |
|
479 |
return pkg.getID(); |
|
480 |
} |
|
481 |
|
|
482 |
public PackageInfo getPackageInfo() { |
|
483 |
return packageInfo; |
|
484 |
} |
|
485 |
|
|
486 |
public boolean isInstalled() { |
|
487 |
return isInstalled; |
|
488 |
} |
|
489 |
|
|
490 |
public boolean isInstallable() { |
|
491 |
return isInstallable; |
|
492 |
} |
|
493 |
|
|
494 |
public boolean isSelected() { |
|
495 |
return isSelected; |
|
496 |
} |
|
497 |
|
|
498 |
public void setSelected(boolean isSelected) { |
|
499 |
this.isSelected = isSelected; |
|
500 |
} |
|
501 |
|
|
502 |
public void setDefault(boolean isDefault) { |
|
503 |
this.isDefault = isDefault; |
|
504 |
} |
|
505 |
|
|
506 |
public boolean isDefault() { |
|
507 |
return isDefault; |
|
508 |
} |
|
509 |
|
|
510 |
} |
|
511 |
|
|
512 |
/** |
|
513 |
* Returns the TablePackageInfo located in the given row. |
|
514 |
* |
|
515 |
* @param row |
|
516 |
* the TablePackageInfo located in the given row |
|
517 |
*/ |
|
518 |
public TablePackageInfo getPackageInfo(int row) { |
|
519 |
return installerInfos[row]; |
|
520 |
} |
|
521 |
|
|
522 |
public void setFilter(PackageFilter filter) { |
|
523 |
this.packageFilter = filter; |
|
524 |
} |
|
525 |
|
|
526 |
public void setFilter(NameDescriptionOrCodeFilter filter) { |
|
527 |
this.packageFastFilter = filter; |
|
528 |
} |
|
529 |
|
|
530 |
private Boolean isFastFilterSet() { |
|
531 |
return this.packageFastFilter != null; |
|
532 |
} |
|
533 |
|
|
534 |
private Boolean isPackageFilterSet() { |
|
535 |
return this.packageFilter != null; |
|
536 |
} |
|
537 |
|
|
538 |
public PackageFilter getFilter() { |
|
539 |
return this.packageFastFilter; |
|
540 |
} |
|
541 |
|
|
542 |
public InstallPackageService getInstallPackageService() { |
|
543 |
return this.installerExecutionService; |
|
544 |
} |
|
545 |
} |
|
0 | 546 |
tags/v2_0_0_Build_2047/extensions/org.gvsig.installer/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/FastFilterButtonsPanel.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 |
*/ |
|
22 |
package org.gvsig.installer.swing.impl.execution.panel; |
|
23 |
|
|
24 |
import java.awt.FlowLayout; |
|
25 |
import java.awt.event.ActionEvent; |
|
26 |
import java.awt.event.ActionListener; |
|
27 |
import java.awt.event.KeyEvent; |
|
28 |
import java.awt.event.KeyListener; |
|
29 |
|
|
30 |
import javax.swing.JButton; |
|
31 |
import javax.swing.JLabel; |
|
32 |
import javax.swing.JPanel; |
|
33 |
import javax.swing.JTextField; |
|
34 |
|
|
35 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
|
36 |
import org.gvsig.installer.swing.api.SwingInstallerManager; |
|
37 |
import org.gvsig.installer.swing.impl.execution.panel.filters.NameDescriptionOrCodeFilter; |
|
38 |
|
|
39 |
/** |
|
40 |
* @author gvSIG Team |
|
41 |
* @version $Id$ |
|
42 |
* |
|
43 |
*/ |
|
44 |
public class FastFilterButtonsPanel extends JPanel implements ActionListener { |
|
45 |
|
|
46 |
private static final long serialVersionUID = 3767011079359743742L; |
|
47 |
|
|
48 |
private PackagesTablePanel panel; |
|
49 |
private SwingInstallerManager swingInstallerManager; |
|
50 |
|
|
51 |
private JButton searchButton; |
|
52 |
private JButton resetButton; |
|
53 |
private JTextField textField; |
|
54 |
private NameDescriptionOrCodeFilter filter = null; |
|
55 |
|
|
56 |
public FastFilterButtonsPanel(PackagesTablePanel panel) { |
|
57 |
this.panel = panel; |
|
58 |
swingInstallerManager = SwingInstallerLocator |
|
59 |
.getSwingInstallerManager(); |
|
60 |
initComponents(); |
|
61 |
} |
|
62 |
|
|
63 |
private void initComponents() { |
|
64 |
|
|
65 |
filter = new NameDescriptionOrCodeFilter(""); |
|
66 |
|
|
67 |
JLabel fastFilterLabel = new JLabel(swingInstallerManager |
|
68 |
.getText("_fast_filter")); |
|
69 |
|
|
70 |
textField = new JTextField(20); |
|
71 |
|
|
72 |
MyKeyListener l = new MyKeyListener(); |
|
73 |
|
|
74 |
textField.addKeyListener(l); |
|
75 |
|
|
76 |
searchButton = new JButton(swingInstallerManager.getText("_search")); |
|
77 |
searchButton.setActionCommand("search"); |
|
78 |
searchButton.addActionListener(this); |
|
79 |
|
|
80 |
resetButton = new JButton(swingInstallerManager |
|
81 |
.getText("_reset_filters")); |
|
82 |
resetButton.setActionCommand("reset"); |
|
83 |
resetButton.addActionListener(this); |
|
84 |
|
|
85 |
setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); |
|
86 |
|
|
87 |
add(fastFilterLabel); |
|
88 |
add(textField); |
|
89 |
// search button not needed with key listener |
|
90 |
// add(searchButton); |
|
91 |
add(resetButton); |
|
92 |
|
|
93 |
} |
|
94 |
|
|
95 |
public void actionPerformed(ActionEvent e) { |
|
96 |
if ("search".equals(e.getActionCommand())) { |
|
97 |
searchAction(); |
|
98 |
} else if ("reset".equals(e.getActionCommand())) { |
|
99 |
resetAction(); |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
private void searchAction() { |
|
104 |
filter.setFilter(textField.getText()); |
|
105 |
panel.setFilter(filter); |
|
106 |
} |
|
107 |
|
|
108 |
private void resetAction() { |
|
109 |
this.resetPanel(); |
|
110 |
} |
|
111 |
|
|
112 |
public void resetPanel() { |
|
113 |
textField.setText(""); |
|
114 |
filter.setFilter(""); |
|
115 |
panel.setFilter(filter); |
|
116 |
panel.resetPanel(); |
|
117 |
} |
|
118 |
|
|
119 |
private class MyKeyListener implements KeyListener { |
|
120 |
|
|
121 |
public void keyTyped(KeyEvent e) { |
|
122 |
} |
|
123 |
|
|
124 |
public void keyReleased(KeyEvent e) { |
|
125 |
searchAction(); |
|
126 |
textField.requestFocus(); |
|
127 |
textField.setCaretPosition(textField.getDocument().getLength()); |
|
128 |
} |
|
129 |
|
|
130 |
public void keyPressed(KeyEvent e) { |
|
131 |
} |
|
132 |
} |
|
133 |
|
|
134 |
} |
|
0 | 135 |
tags/v2_0_0_Build_2047/extensions/org.gvsig.installer/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/PackagesTablePanel.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
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 |
*/ |
|
22 |
|
|
23 |
/* |
|
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2010 {Prodevelop} {Task} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.installer.swing.impl.execution.panel; |
|
29 |
|
|
30 |
import java.awt.Color; |
|
31 |
import java.awt.GridBagConstraints; |
|
32 |
import java.awt.GridBagLayout; |
|
33 |
import java.awt.Insets; |
|
34 |
import java.awt.event.MouseEvent; |
|
35 |
import java.awt.event.MouseListener; |
|
36 |
import java.net.URL; |
|
37 |
import java.util.List; |
|
38 |
|
|
39 |
import javax.swing.JEditorPane; |
|
40 |
import javax.swing.JPanel; |
|
41 |
import javax.swing.JScrollPane; |
|
42 |
import javax.swing.JTable; |
|
43 |
import javax.swing.event.ListSelectionEvent; |
|
44 |
import javax.swing.event.ListSelectionListener; |
|
45 |
import javax.swing.table.TableColumnModel; |
|
46 |
|
|
47 |
import org.gvsig.installer.lib.api.PackageInfo; |
|
48 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
|
49 |
import org.gvsig.installer.swing.api.SwingInstallerManager; |
|
50 |
import org.gvsig.installer.swing.impl.execution.panel.filters.NameDescriptionOrCodeFilter; |
|
51 |
import org.gvsig.installer.swing.impl.execution.panel.filters.PackageFilter; |
|
52 |
import org.gvsig.installer.swing.impl.execution.panel.model.PackagesTableModel; |
|
53 |
import org.gvsig.installer.swing.impl.execution.panel.model.PackagesTableModel.PackageOfficialRecommended; |
|
54 |
import org.gvsig.installer.swing.impl.execution.panel.model.PackagesTableModel.PackageOsAndArchitecture; |
|
55 |
import org.gvsig.installer.swing.impl.execution.panel.model.PackagesTableModel.PackageStatus; |
|
56 |
import org.gvsig.installer.swing.impl.execution.panel.renderers.AbstractTablePackageInfoCellRenderer; |
|
57 |
import org.gvsig.installer.swing.impl.execution.panel.renderers.InstallStatusCellEditor; |
|
58 |
import org.gvsig.installer.swing.impl.execution.panel.renderers.InstallStatusCellRenderer; |
|
59 |
import org.gvsig.installer.swing.impl.execution.panel.renderers.InstalledPackageCellRenderer; |
|
60 |
import org.gvsig.installer.swing.impl.execution.panel.renderers.OfficialRecommendedCellRenderer; |
|
61 |
import org.gvsig.installer.swing.impl.execution.panel.renderers.OsAndArchitectureCellRenderer; |
|
62 |
|
|
63 |
/** |
|
64 |
* @author gvSIG Team |
|
65 |
* @version $Id$ |
|
66 |
*/ |
|
67 |
public class PackagesTablePanel extends JPanel implements ListSelectionListener { |
|
68 |
|
|
69 |
private static final long serialVersionUID = 8156088357208685689L; |
|
70 |
protected SwingInstallerManager swingInstallerManager = null; |
|
71 |
|
|
72 |
private JScrollPane descriptionScrollPane; |
|
73 |
private JEditorPane descriptionTextEditor; |
|
74 |
private JScrollPane pluginsScrollPane; |
|
75 |
private JTable pluginsTable; |
|
76 |
private PackagePropertiesFilterPanel filterPanel; |
|
77 |
private FastFilterButtonsPanel fastFilterPanel; |
|
78 |
private SelectPackagesPanel selectPackagesPanel; |
|
79 |
|
|
80 |
public PackagesTablePanel(SelectPackagesPanel selectPackagesPanel) { |
|
81 |
super(); |
|
82 |
swingInstallerManager = SwingInstallerLocator |
|
83 |
.getSwingInstallerManager(); |
|
84 |
this.selectPackagesPanel = selectPackagesPanel; |
|
85 |
initComponents(); |
|
86 |
pluginsTable.getSelectionModel().addListSelectionListener(this); |
|
87 |
pluginsTable.setDefaultRenderer(PackageOfficialRecommended.class, |
|
88 |
new OfficialRecommendedCellRenderer()); |
|
89 |
pluginsTable.setDefaultRenderer(PackageStatus.class, |
|
90 |
new InstallStatusCellRenderer()); |
|
91 |
pluginsTable.setDefaultEditor(PackageStatus.class, |
|
92 |
new InstallStatusCellEditor(this.selectPackagesPanel)); |
|
93 |
AbstractTablePackageInfoCellRenderer ipcr = new InstalledPackageCellRenderer(); |
|
94 |
pluginsTable.setDefaultRenderer(PackageOsAndArchitecture.class, |
|
95 |
new OsAndArchitectureCellRenderer()); |
|
96 |
pluginsTable.setDefaultRenderer(String.class, ipcr); |
|
97 |
pluginsTable.setDefaultRenderer(Number.class, ipcr); |
|
98 |
pluginsTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); |
|
99 |
} |
|
100 |
|
|
101 |
private void initComponents() { |
|
102 |
java.awt.GridBagConstraints gridBagConstraints; |
|
103 |
|
|
104 |
pluginsTable = new JTable(); |
|
105 |
|
|
106 |
MouseListener mouseListener = new MyMouseListener(); |
|
107 |
pluginsTable.addMouseListener(mouseListener); |
|
108 |
|
|
109 |
pluginsScrollPane = new JScrollPane(pluginsTable); |
|
110 |
|
|
111 |
descriptionTextEditor = new JEditorPane(); |
|
112 |
descriptionTextEditor.setBackground(Color.WHITE); |
|
113 |
descriptionTextEditor.setEditable(false); |
|
114 |
descriptionTextEditor.setContentType("text/html"); |
|
115 |
|
|
116 |
descriptionScrollPane = new JScrollPane(descriptionTextEditor); |
|
117 |
|
|
118 |
filterPanel = new PackagePropertiesFilterPanel(this); |
|
119 |
filterPanel.setVisible(true); |
|
120 |
|
|
121 |
fastFilterPanel = new FastFilterButtonsPanel(this); |
Also available in: Unified diff