Revision 37584
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/CategoriesFilterPanel.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 |
|
|
39 |
import org.gvsig.installer.lib.api.execution.InstallPackageService; |
|
40 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
|
41 |
import org.gvsig.installer.swing.impl.DefaultSwingInstallerManager; |
|
42 |
|
|
43 |
/** |
|
44 |
* @author gvSIG Team |
|
45 |
* @version $Id$ |
|
46 |
* |
|
47 |
*/ |
|
48 |
public class CategoriesFilterPanel extends JPanel implements ActionListener { |
|
49 |
|
|
50 |
private static final long serialVersionUID = 3767011079359743742L; |
|
51 |
|
|
52 |
private enum FilterType { |
|
53 |
CATEGORIES, TYPES |
|
54 |
} |
|
55 |
|
|
56 |
private PackagesTablePanel packagesTablePanel; |
|
57 |
|
|
58 |
private JScrollPane filterScrollPane; |
|
59 |
private JList jList; |
|
60 |
private FilterType filterType = null; |
|
61 |
private DefaultListModel model = null; |
|
62 |
|
|
63 |
private DefaultSwingInstallerManager manager; |
|
64 |
|
|
65 |
public CategoriesFilterPanel(PackagesTablePanel packagesTablePanel) { |
|
66 |
this.packagesTablePanel = packagesTablePanel; |
|
67 |
manager = |
|
68 |
(DefaultSwingInstallerManager) SwingInstallerLocator |
|
69 |
.getSwingInstallerManager(); |
|
70 |
initComponents(); |
|
71 |
} |
|
72 |
|
|
73 |
private void initComponents() { |
|
74 |
|
|
75 |
model = new DefaultListModel(); |
|
76 |
jList = new JList(model); |
|
77 |
|
|
78 |
filterScrollPane = new JScrollPane(jList); |
|
79 |
|
|
80 |
JButton categoriesButton = new JButton(manager.getText("_Categories")); |
|
81 |
categoriesButton.setActionCommand("categories"); |
|
82 |
categoriesButton.addActionListener(this); |
|
83 |
|
|
84 |
JButton typesButton = new JButton(manager.getText("_Types")); |
|
85 |
typesButton.setActionCommand("types"); |
|
86 |
typesButton.addActionListener(this); |
|
87 |
|
|
88 |
this.setLayout(new GridBagLayout()); |
|
89 |
|
|
90 |
java.awt.GridBagConstraints gridBagConstraints; |
|
91 |
|
|
92 |
gridBagConstraints = new GridBagConstraints(); |
|
93 |
gridBagConstraints.fill = GridBagConstraints.BOTH; |
|
94 |
gridBagConstraints.gridx = 0; |
|
95 |
gridBagConstraints.gridy = 0; |
|
96 |
gridBagConstraints.weightx = 1; |
|
97 |
gridBagConstraints.weighty = 1; |
|
98 |
// gridBagConstraints.gridheight = 3; |
|
99 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
|
100 |
this.add(filterScrollPane, gridBagConstraints); |
|
101 |
|
|
102 |
gridBagConstraints = new GridBagConstraints(); |
|
103 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; |
|
104 |
gridBagConstraints.gridx = 0; |
|
105 |
gridBagConstraints.gridy = 1; |
|
106 |
gridBagConstraints.weightx = 1; |
|
107 |
gridBagConstraints.weighty = 0; |
|
108 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
|
109 |
this.add(categoriesButton, gridBagConstraints); |
|
110 |
|
|
111 |
gridBagConstraints = new GridBagConstraints(); |
|
112 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; |
|
113 |
gridBagConstraints.gridx = 0; |
|
114 |
gridBagConstraints.gridy = 2; |
|
115 |
gridBagConstraints.weightx = 1; |
|
116 |
gridBagConstraints.weighty = 0; |
|
117 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2); |
|
118 |
this.add(typesButton, gridBagConstraints); |
|
119 |
|
|
120 |
} |
|
121 |
|
|
122 |
public void resetPanel() { |
|
123 |
model.removeAllElements(); |
|
124 |
} |
|
125 |
|
|
126 |
/* |
|
127 |
* Sets the filter type, or null to set no filter |
|
128 |
*/ |
|
129 |
public void setFilterType(FilterType filter) { |
|
130 |
this.filterType = filter; |
|
131 |
} |
|
132 |
|
|
133 |
public FilterType getFilterType() { |
|
134 |
return this.filterType; |
|
135 |
} |
|
136 |
|
|
137 |
public void actionPerformed(ActionEvent e) { |
|
138 |
|
|
139 |
InstallPackageService service = |
|
140 |
packagesTablePanel.getSelectPackagesPanel().getModel() |
|
141 |
.getInstallPackageService(); |
|
142 |
|
|
143 |
if ("categories".equals(e.getActionCommand())) { |
|
144 |
this.filterType = FilterType.CATEGORIES; |
|
145 |
model.removeAllElements(); |
|
146 |
|
|
147 |
List<String> categories = service.getCategories(); |
|
148 |
|
|
149 |
if (categories != null) { |
|
150 |
String[] items = categories.toArray((new String[0])); |
|
151 |
for (int i = 0; i < items.length; i++) { |
|
152 |
model.add(i, items[i]); |
|
153 |
} |
|
154 |
} |
|
155 |
|
|
156 |
} else { |
|
157 |
if ("types".equals(e.getActionCommand())) { |
|
158 |
this.filterType = FilterType.TYPES; |
|
159 |
model.removeAllElements(); |
|
160 |
|
|
161 |
List<String> types = service.getTypes(); |
|
162 |
|
|
163 |
if (types != null) { |
|
164 |
String[] items = types.toArray((new String[0])); |
|
165 |
for (int i = 0; i < items.length; i++) { |
|
166 |
model.add(i, items[i]); |
|
167 |
} |
|
168 |
} |
|
169 |
} |
|
170 |
} |
|
171 |
} |
|
172 |
|
|
173 |
private class MyKeyListener implements MouseListener { |
|
174 |
|
|
175 |
public void mouseClicked(MouseEvent e) { |
|
176 |
// TODO Auto-generated method stub |
|
177 |
|
|
178 |
} |
|
179 |
|
|
180 |
public void mouseEntered(MouseEvent e) { |
|
181 |
// TODO Auto-generated method stub |
|
182 |
|
|
183 |
} |
|
184 |
|
|
185 |
public void mouseExited(MouseEvent e) { |
|
186 |
// TODO Auto-generated method stub |
|
187 |
|
|
188 |
} |
|
189 |
|
|
190 |
public void mousePressed(MouseEvent e) { |
|
191 |
// TODO Auto-generated method stub |
|
192 |
|
|
193 |
} |
|
194 |
|
|
195 |
public void mouseReleased(MouseEvent e) { |
|
196 |
// TODO Auto-generated method stub |
|
197 |
|
|
198 |
} |
|
199 |
|
|
200 |
|
|
201 |
} |
|
202 |
|
|
203 |
} |
branches/v2_0_0_prep/extensions/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 | ||
---|---|---|
44 | 44 |
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException; |
45 | 45 |
import org.gvsig.installer.lib.api.execution.InstallPackageService; |
46 | 46 |
import org.gvsig.installer.swing.api.SwingInstallerManager; |
47 |
import org.gvsig.installer.swing.impl.execution.panel.filters.NameAndDescriptionFilter; |
|
47 | 48 |
import org.gvsig.installer.swing.impl.execution.panel.filters.PackageFilter; |
48 | 49 |
|
49 | 50 |
public class PackagesTableModel extends AbstractTableModel { |
50 | 51 |
|
51 |
private static final long serialVersionUID = -454014676003979512L;
|
|
52 |
private static final long serialVersionUID = -454014676003979512L;
|
|
52 | 53 |
|
53 |
public enum PackageStatus {
|
|
54 |
INSTALLED, NOT_INSTALLED, TO_REINSTALL, TO_INSTALL, INSTALLED_NOT_INSTALLABLE;
|
|
55 |
}
|
|
54 |
public enum PackageStatus {
|
|
55 |
INSTALLED, NOT_INSTALLED, TO_REINSTALL, TO_INSTALL, INSTALLED_NOT_INSTALLABLE;
|
|
56 |
}
|
|
56 | 57 |
|
57 |
public enum PackageOfficialRecommended {
|
|
58 |
OFFICIAL_NOT_RECOMMENDED, OFFICIAL_RECOMMENDED, NOT_OFFICIAL_RECOMMENDED, NOT_OFFICIAL_NOT_RECOMMENDED
|
|
59 |
}
|
|
58 |
public enum PackageOfficialRecommended {
|
|
59 |
OFFICIAL_NOT_RECOMMENDED, OFFICIAL_RECOMMENDED, NOT_OFFICIAL_RECOMMENDED, NOT_OFFICIAL_NOT_RECOMMENDED
|
|
60 |
}
|
|
60 | 61 |
|
61 |
public enum PackageOsAndArchitecture {
|
|
62 |
WINDOLS_32, WINDOLS_64, LINUX_32, LINUX_64, ALL, OTHER
|
|
63 |
}
|
|
62 |
public enum PackageOsAndArchitecture {
|
|
63 |
WINDOLS_32, WINDOLS_64, LINUX_32, LINUX_64, ALL, OTHER
|
|
64 |
}
|
|
64 | 65 |
|
65 |
private TablePackageInfo[] installerInfos = null;
|
|
66 |
private TablePackageInfo[] installerInfos = null;
|
|
66 | 67 |
|
67 |
private final String[] columnNames;
|
|
68 |
private final String[] columnNames;
|
|
68 | 69 |
|
69 |
private InstallerManager installerManager =
|
|
70 |
InstallerLocator.getInstallerManager();
|
|
71 |
private InstallPackageService installerExecutionService;
|
|
70 |
private InstallerManager installerManager = InstallerLocator
|
|
71 |
.getInstallerManager();
|
|
72 |
private InstallPackageService installerExecutionService;
|
|
72 | 73 |
|
73 |
boolean isOfficial; |
|
74 |
private File pluginsFolder; |
|
75 |
private PackageFilter packageFilter = null; |
|
74 |
boolean isOfficial; |
|
75 |
private File pluginsFolder; |
|
76 |
private NameAndDescriptionFilter packageFastFilter = null; |
|
77 |
private PackageFilter packageFilter = null; |
|
76 | 78 |
|
77 |
public PackagesTableModel(SwingInstallerManager swingInstallerManager,
|
|
78 |
InstallPackageService installerExecutionService, boolean isOfficial,
|
|
79 |
File pluginsFolder) {
|
|
79 |
public PackagesTableModel(SwingInstallerManager swingInstallerManager,
|
|
80 |
InstallPackageService installerExecutionService,
|
|
81 |
boolean isOfficial, File pluginsFolder) {
|
|
80 | 82 |
|
81 |
this.installerExecutionService = installerExecutionService;
|
|
82 |
this.isOfficial = isOfficial;
|
|
83 |
this.pluginsFolder = pluginsFolder;
|
|
84 |
Map<String, TablePackageInfo> infos = getDefaultPackages();
|
|
83 |
this.installerExecutionService = installerExecutionService;
|
|
84 |
this.isOfficial = isOfficial;
|
|
85 |
this.pluginsFolder = pluginsFolder;
|
|
86 |
Map<String, TablePackageInfo> infos = getDefaultPackages();
|
|
85 | 87 |
|
86 |
installerInfos =
|
|
87 |
infos.values().toArray(new TablePackageInfo[infos.size()]);
|
|
88 |
sortInstallerInfos();
|
|
88 |
installerInfos = infos.values().toArray(
|
|
89 |
new TablePackageInfo[infos.size()]);
|
|
90 |
sortInstallerInfos();
|
|
89 | 91 |
|
90 |
columnNames = |
|
91 |
new String[] { |
|
92 |
"", // Check column |
|
93 |
"", "", swingInstallerManager.getText("name"), |
|
94 |
swingInstallerManager.getText("version"), |
|
95 |
swingInstallerManager.getText("type") }; |
|
92 |
columnNames = new String[] { |
|
93 |
"", // Check column |
|
94 |
"", "", swingInstallerManager.getText("name"), |
|
95 |
swingInstallerManager.getText("version"), |
|
96 |
swingInstallerManager.getText("type") }; |
|
96 | 97 |
|
97 |
}
|
|
98 |
}
|
|
98 | 99 |
|
99 |
private void sortInstallerInfos() {
|
|
100 |
Arrays.sort(this.installerInfos, new Comparator<TablePackageInfo>() {
|
|
100 |
private void sortInstallerInfos() {
|
|
101 |
Arrays.sort(this.installerInfos, new Comparator<TablePackageInfo>() {
|
|
101 | 102 |
|
102 |
public int compare(TablePackageInfo o1, TablePackageInfo o2) {
|
|
103 |
return o1.getPackageInfo().getName().compareToIgnoreCase(
|
|
104 |
o2.getPackageInfo().getName());
|
|
105 |
}
|
|
106 |
});
|
|
107 |
}
|
|
103 |
public int compare(TablePackageInfo o1, TablePackageInfo o2) {
|
|
104 |
return o1.getPackageInfo().getName().compareToIgnoreCase(
|
|
105 |
o2.getPackageInfo().getName());
|
|
106 |
}
|
|
107 |
});
|
|
108 |
}
|
|
108 | 109 |
|
109 |
private Map<String, TablePackageInfo> getDefaultPackages() {
|
|
110 |
private Map<String, TablePackageInfo> getDefaultPackages() {
|
|
110 | 111 |
|
111 |
List<String> defaultIDs =
|
|
112 |
installerExecutionService.getDefaultSelectedPackagesIDs();
|
|
112 |
List<String> defaultIDs = installerExecutionService
|
|
113 |
.getDefaultSelectedPackagesIDs();
|
|
113 | 114 |
|
114 |
Map<String, TablePackageInfo> infos = |
|
115 |
new HashMap<String, TablePackageInfo>(); |
|
116 |
// Add installable package infos |
|
117 |
for (int i = 0; i < installerExecutionService.getPackageCount(); i++) { |
|
118 |
PackageInfo installerInfo = |
|
119 |
installerExecutionService.getPackageInfo(i); |
|
120 |
if (installerInfo.isOfficial() == isOfficial) { |
|
121 |
TablePackageInfo info = |
|
122 |
new TablePackageInfo(installerInfo, false, true); |
|
123 |
if (defaultIDs != null) { |
|
115 |
Map<String, TablePackageInfo> infos = new HashMap<String, TablePackageInfo>(); |
|
116 |
// Add installable package infos |
|
117 |
for (int i = 0; i < installerExecutionService.getPackageCount(); i++) { |
|
118 |
PackageInfo installerInfo = installerExecutionService |
|
119 |
.getPackageInfo(i); |
|
120 |
if (installerInfo.isOfficial() == isOfficial) { |
|
121 |
TablePackageInfo info = new TablePackageInfo(installerInfo, |
|
122 |
false, true); |
|
123 |
if (defaultIDs != null) { |
|
124 | 124 |
|
125 |
for (int j = 0; j < defaultIDs.size(); j++) { |
|
126 |
if (info.getPackageInfo().matchID(defaultIDs.get(j))) { |
|
127 |
if (info.getPackageInfo().getOperatingSystem() |
|
128 |
.equals(installerManager.getOperatingSystem()) |
|
129 |
|| info.getPackageInfo().getOperatingSystem() |
|
130 |
.equals("all")) { |
|
131 |
info.setDefault(true); |
|
132 |
break; |
|
133 |
} |
|
125 |
for (int j = 0; j < defaultIDs.size(); j++) { |
|
126 |
if (info.getPackageInfo().matchID(defaultIDs.get(j))) { |
|
127 |
if (info.getPackageInfo().getOperatingSystem() |
|
128 |
.equals( |
|
129 |
installerManager |
|
130 |
.getOperatingSystem()) |
|
131 |
|| info.getPackageInfo() |
|
132 |
.getOperatingSystem().equals("all")) { |
|
133 |
info.setDefault(true); |
|
134 |
break; |
|
135 |
} |
|
134 | 136 |
|
135 |
}
|
|
136 |
}
|
|
137 |
}
|
|
138 |
}
|
|
137 | 139 |
|
138 |
}
|
|
139 |
infos.put(info.getID(), info);
|
|
140 |
}
|
|
141 |
}
|
|
142 |
// Add already installed package infos
|
|
143 |
try {
|
|
144 |
PackageInfo[] installedPackages =
|
|
145 |
installerManager.getInstalledPackages(pluginsFolder);
|
|
140 |
}
|
|
141 |
infos.put(info.getID(), info);
|
|
142 |
}
|
|
143 |
}
|
|
144 |
// Add already installed package infos
|
|
145 |
try {
|
|
146 |
PackageInfo[] installedPackages = installerManager
|
|
147 |
.getInstalledPackages(pluginsFolder);
|
|
146 | 148 |
|
147 |
for (int i = 0; i < installedPackages.length; i++) {
|
|
148 |
if (installedPackages[i].isOfficial() == isOfficial) {
|
|
149 |
TablePackageInfo info =
|
|
150 |
new TablePackageInfo(installedPackages[i], true, false);
|
|
151 |
TablePackageInfo x = infos.get(info.getID());
|
|
152 |
if (x == null) {
|
|
153 |
infos.put(info.getID(), info);
|
|
154 |
} else {
|
|
155 |
x.setInstalled(true);
|
|
156 |
}
|
|
157 |
}
|
|
158 |
}
|
|
159 |
} catch (MakePluginPackageServiceException e) {
|
|
160 |
throw new RuntimeException(e);
|
|
161 |
}
|
|
149 |
for (int i = 0; i < installedPackages.length; i++) {
|
|
150 |
if (installedPackages[i].isOfficial() == isOfficial) {
|
|
151 |
TablePackageInfo info = new TablePackageInfo(
|
|
152 |
installedPackages[i], true, false);
|
|
153 |
TablePackageInfo x = infos.get(info.getID());
|
|
154 |
if (x == null) {
|
|
155 |
infos.put(info.getID(), info);
|
|
156 |
} else {
|
|
157 |
x.setInstalled(true);
|
|
158 |
}
|
|
159 |
}
|
|
160 |
}
|
|
161 |
} catch (MakePluginPackageServiceException e) {
|
|
162 |
throw new RuntimeException(e);
|
|
163 |
}
|
|
162 | 164 |
|
163 |
return infos;
|
|
164 |
}
|
|
165 |
return infos;
|
|
166 |
}
|
|
165 | 167 |
|
166 |
// get filtered packages
|
|
167 |
private Map<String, TablePackageInfo> getFilteredPackages(
|
|
168 |
Map<String, TablePackageInfo> packageInfos) {
|
|
168 |
// get filtered packages
|
|
169 |
private Map<String, TablePackageInfo> getFilteredPackages(
|
|
170 |
Map<String, TablePackageInfo> packageInfos) {
|
|
169 | 171 |
|
170 |
Map<String, TablePackageInfo> infos = |
|
171 |
new HashMap<String, TablePackageInfo>(); |
|
172 |
Map<String, TablePackageInfo> infos = new HashMap<String, TablePackageInfo>(); |
|
172 | 173 |
|
173 |
TablePackageInfo[] packs =
|
|
174 |
packageInfos.values().toArray(new TablePackageInfo[infos.size()]);
|
|
174 |
TablePackageInfo[] packs = packageInfos.values().toArray(
|
|
175 |
new TablePackageInfo[infos.size()]);
|
|
175 | 176 |
|
176 |
for (int i = 0; i < packs.length; i++) {
|
|
177 |
PackageInfo installerInfo = packs[i].getPackageInfo();
|
|
177 |
for (int i = 0; i < packs.length; i++) {
|
|
178 |
PackageInfo installerInfo = packs[i].getPackageInfo();
|
|
178 | 179 |
|
179 |
if (packageFilter.match(installerInfo)) {
|
|
180 |
TablePackageInfo info = packs[i];
|
|
181 |
infos.put(installerInfo.getID(), info);
|
|
182 |
}
|
|
183 |
}
|
|
184 |
return infos;
|
|
185 |
}
|
|
180 |
if (packageFilter.match(installerInfo)) {
|
|
181 |
TablePackageInfo info = packs[i];
|
|
182 |
infos.put(installerInfo.getID(), info);
|
|
183 |
}
|
|
184 |
}
|
|
185 |
return infos;
|
|
186 |
}
|
|
186 | 187 |
|
187 |
// selects default packages |
|
188 |
public void selectDefaultPackages() { |
|
189 |
for (int i = 0; i < installerInfos.length; i++) { |
|
190 |
if (installerInfos[i].isDefault()) { |
|
191 |
installerInfos[i].setSelected(true); |
|
192 |
} else { |
|
193 |
installerInfos[i].setSelected(false); |
|
194 |
} |
|
195 |
} |
|
196 |
} |
|
188 |
// get fast filtered packages (by name or description) |
|
189 |
private Map<String, TablePackageInfo> getFastFilteredPackages( |
|
190 |
Map<String, TablePackageInfo> packageInfos) { |
|
197 | 191 |
|
198 |
public void selectPackage(PackageInfo pkg) { |
|
199 |
for (int i = 0; i < installerInfos.length; i++) { |
|
200 |
if (pkg.equals(installerInfos[i].getPackageInfo())) { |
|
201 |
installerInfos[i].setSelected(true); |
|
202 |
return; |
|
203 |
} |
|
204 |
} |
|
205 |
} |
|
192 |
Map<String, TablePackageInfo> infos = new HashMap<String, TablePackageInfo>(); |
|
206 | 193 |
|
207 |
public void updatePackages() { |
|
194 |
TablePackageInfo[] packs = packageInfos.values().toArray( |
|
195 |
new TablePackageInfo[infos.size()]); |
|
208 | 196 |
|
209 |
Map<String, TablePackageInfo> infos = getDefaultPackages(); |
|
197 |
for (int i = 0; i < packs.length; i++) { |
|
198 |
PackageInfo installerInfo = packs[i].getPackageInfo(); |
|
210 | 199 |
|
211 |
if (isFilterSet()) { |
|
212 |
infos = getFilteredPackages(infos); |
|
213 |
} |
|
200 |
if (packageFastFilter.match(installerInfo)) { |
|
201 |
TablePackageInfo info = packs[i]; |
|
202 |
infos.put(installerInfo.getID(), info); |
|
203 |
} |
|
204 |
} |
|
205 |
return infos; |
|
206 |
} |
|
214 | 207 |
|
215 |
for (int i = 0; i < installerInfos.length; i++) { |
|
216 |
TablePackageInfo installerInfo = |
|
217 |
infos.get(installerInfos[i].getID()); |
|
218 |
if (installerInfo != null) { |
|
219 |
installerInfo.setSelected(installerInfos[i].isSelected()); |
|
220 |
} |
|
221 |
} |
|
208 |
public void updatePackages() { |
|
222 | 209 |
|
223 |
installerInfos = |
|
224 |
infos.values().toArray(new TablePackageInfo[infos.size()]); |
|
225 |
sortInstallerInfos(); |
|
210 |
Map<String, TablePackageInfo> infos = getDefaultPackages(); |
|
226 | 211 |
|
227 |
List<String> idList = |
|
228 |
installerExecutionService.getDefaultSelectedPackagesIDs(); |
|
212 |
// check if there is a filter set (category, type, etc) |
|
213 |
if (isPackageFilterSet()) { |
|
214 |
infos = getFilteredPackages(infos); |
|
215 |
} |
|
229 | 216 |
|
230 |
if (idList != null) { |
|
231 |
for (int i = 0; i < installerInfos.length; i++) { |
|
232 |
for (int j = 0; j < idList.size(); j++) { |
|
233 |
if (installerInfos[i].getPackageInfo().matchID( |
|
234 |
idList.get(j))) { |
|
235 |
if (installerInfos[i].getPackageInfo() |
|
236 |
.getOperatingSystem().equals( |
|
237 |
installerManager.getOperatingSystem()) |
|
238 |
|| installerInfos[i].getPackageInfo() |
|
239 |
.getOperatingSystem().equals("all")) { |
|
240 |
installerInfos[i].setDefault(true); |
|
241 |
} |
|
242 |
} |
|
243 |
} |
|
244 |
} |
|
245 |
} |
|
246 |
} |
|
217 |
// check if there is any filter set (fastFilter) |
|
218 |
if (isFastFilterSet()) { |
|
219 |
infos = getFastFilteredPackages(infos); |
|
220 |
} |
|
247 | 221 |
|
248 |
public Class<?> getColumnClass(int columnIndex) { |
|
249 |
switch (columnIndex) { |
|
250 |
case 0: |
|
251 |
return PackageStatus.class; |
|
252 |
case 1: |
|
253 |
return PackageOfficialRecommended.class; |
|
254 |
case 2: |
|
255 |
return PackageOsAndArchitecture.class; |
|
256 |
default: |
|
257 |
return String.class; |
|
258 |
} |
|
259 |
} |
|
222 |
for (int i = 0; i < installerInfos.length; i++) { |
|
223 |
TablePackageInfo installerInfo = infos.get(installerInfos[i] |
|
224 |
.getID()); |
|
225 |
if (installerInfo != null) { |
|
226 |
installerInfo.setSelected(installerInfos[i].isSelected()); |
|
227 |
} |
|
228 |
} |
|
260 | 229 |
|
261 |
public int getColumnCount() {
|
|
262 |
return columnNames.length;
|
|
263 |
}
|
|
230 |
installerInfos = infos.values().toArray(
|
|
231 |
new TablePackageInfo[infos.size()]);
|
|
232 |
sortInstallerInfos();
|
|
264 | 233 |
|
265 |
public String getColumnName(int columnIndex) { |
|
266 |
return columnIndex >= columnNames.length ? "" |
|
267 |
: columnNames[columnIndex]; |
|
268 |
} |
|
234 |
List<String> idList = installerExecutionService |
|
235 |
.getDefaultSelectedPackagesIDs(); |
|
269 | 236 |
|
270 |
public int getRowCount() { |
|
271 |
return installerInfos.length; |
|
272 |
} |
|
237 |
if (idList != null) { |
|
238 |
for (int i = 0; i < installerInfos.length; i++) { |
|
239 |
for (int j = 0; j < idList.size(); j++) { |
|
240 |
if (installerInfos[i].getPackageInfo().matchID( |
|
241 |
idList.get(j))) { |
|
242 |
if (installerInfos[i].getPackageInfo() |
|
243 |
.getOperatingSystem().equals( |
|
244 |
installerManager.getOperatingSystem()) |
|
245 |
|| installerInfos[i].getPackageInfo() |
|
246 |
.getOperatingSystem().equals("all")) { |
|
247 |
installerInfos[i].setDefault(true); |
|
248 |
} |
|
249 |
} |
|
250 |
} |
|
251 |
} |
|
252 |
} |
|
253 |
} |
|
273 | 254 |
|
274 |
public Object getValueAt(int rowIndex, int columnIndex) { |
|
275 |
TablePackageInfo tableInfo = installerInfos[rowIndex]; |
|
276 |
PackageInfo installerInfo = tableInfo.getPackageInfo(); |
|
255 |
// selects default packages |
|
256 |
public void selectDefaultPackages() { |
|
257 |
for (int i = 0; i < installerInfos.length; i++) { |
|
258 |
if (installerInfos[i].isDefault()) { |
|
259 |
installerInfos[i].setSelected(true); |
|
260 |
} else { |
|
261 |
installerInfos[i].setSelected(false); |
|
262 |
} |
|
263 |
} |
|
264 |
} |
|
277 | 265 |
|
278 |
switch (columnIndex) { |
|
279 |
case 0: |
|
280 |
PackageStatus installStatus = checkStatus(rowIndex); |
|
281 |
return installStatus; |
|
282 |
case 1: |
|
283 |
PackageOfficialRecommended officialRecommended = |
|
284 |
checkOfficialRecommended(rowIndex); |
|
285 |
return officialRecommended; |
|
286 |
case 2: |
|
287 |
PackageOsAndArchitecture packageSystem = |
|
288 |
checkPackageSystem(rowIndex); |
|
289 |
return packageSystem; |
|
290 |
case 3: |
|
291 |
return installerInfo.getName(); |
|
292 |
case 4: |
|
293 |
return installerInfo.getVersion(); |
|
294 |
case 5: |
|
295 |
return installerInfo.getType(); |
|
296 |
// case 5: |
|
297 |
// if (installerInfo.getOperatingSystem().equals( |
|
298 |
// installerInfo.getArchitecture())) { |
|
299 |
// return "all"; |
|
300 |
// } else { |
|
301 |
// return installerInfo.getOperatingSystem() + " " |
|
302 |
// + installerInfo.getArchitecture(); |
|
303 |
// } |
|
304 |
default: |
|
305 |
return ""; |
|
266 |
public void selectPackage(PackageInfo pkg) { |
|
267 |
for (int i = 0; i < installerInfos.length; i++) { |
|
268 |
if (pkg.equals(installerInfos[i].getPackageInfo())) { |
|
269 |
installerInfos[i].setSelected(true); |
|
270 |
return; |
|
271 |
} |
|
272 |
} |
|
273 |
} |
|
306 | 274 |
|
307 |
} |
|
308 |
} |
|
275 |
public Class<?> getColumnClass(int columnIndex) { |
|
276 |
switch (columnIndex) { |
|
277 |
case 0: |
|
278 |
return PackageStatus.class; |
|
279 |
case 1: |
|
280 |
return PackageOfficialRecommended.class; |
|
281 |
case 2: |
|
282 |
return PackageOsAndArchitecture.class; |
|
283 |
default: |
|
284 |
return String.class; |
|
285 |
} |
|
286 |
} |
|
309 | 287 |
|
310 |
/** |
|
311 |
* @param rowIndex |
|
312 |
* @return |
|
313 |
*/ |
|
314 |
private PackageOsAndArchitecture checkPackageSystem(int rowIndex) { |
|
315 |
TablePackageInfo tableInfo = installerInfos[rowIndex]; |
|
316 |
PackageInfo installerInfo = tableInfo.getPackageInfo(); |
|
317 |
PackageOsAndArchitecture oSArch; |
|
288 |
public int getColumnCount() { |
|
289 |
return columnNames.length; |
|
290 |
} |
|
318 | 291 |
|
319 |
if (installerInfo.getOperatingSystem().equals( |
|
320 |
installerInfo.getArchitecture())) { |
|
321 |
oSArch = PackageOsAndArchitecture.ALL; |
|
322 |
} else |
|
323 |
if ((installerInfo.getOperatingSystem().equals("lin"))) { |
|
324 |
if (installerInfo.getArchitecture().equals("x86")) { |
|
325 |
oSArch = PackageOsAndArchitecture.LINUX_32; |
|
326 |
} else { |
|
327 |
oSArch = PackageOsAndArchitecture.LINUX_64; |
|
328 |
} |
|
329 |
} else |
|
330 |
if ((installerInfo.getOperatingSystem().equals("win"))) { |
|
331 |
if (installerInfo.getArchitecture().equals("x86")) { |
|
332 |
oSArch = PackageOsAndArchitecture.WINDOLS_32; |
|
333 |
} else { |
|
334 |
oSArch = PackageOsAndArchitecture.WINDOLS_64; |
|
335 |
} |
|
336 |
} else { |
|
337 |
oSArch = PackageOsAndArchitecture.OTHER; |
|
338 |
} |
|
339 |
return oSArch; |
|
340 |
} |
|
292 |
public String getColumnName(int columnIndex) { |
|
293 |
return columnIndex >= columnNames.length ? "" |
|
294 |
: columnNames[columnIndex]; |
|
295 |
} |
|
341 | 296 |
|
342 |
/** |
|
343 |
* @return |
|
344 |
*/ |
|
345 |
private PackageStatus checkStatus(int rowIndex) { |
|
346 |
TablePackageInfo tableInfo = installerInfos[rowIndex]; |
|
297 |
public int getRowCount() { |
|
298 |
return installerInfos.length; |
|
299 |
} |
|
347 | 300 |
|
348 |
if (tableInfo.isInstalled()) { |
|
349 |
if (tableInfo.isInstallable()) { |
|
350 |
if (tableInfo.isSelected()) { |
|
351 |
return PackageStatus.TO_REINSTALL; |
|
352 |
} else { |
|
353 |
return PackageStatus.INSTALLED; |
|
354 |
} |
|
355 |
} else { |
|
356 |
return PackageStatus.INSTALLED_NOT_INSTALLABLE; |
|
357 |
} |
|
301 |
public Object getValueAt(int rowIndex, int columnIndex) { |
|
302 |
TablePackageInfo tableInfo = installerInfos[rowIndex]; |
|
303 |
PackageInfo installerInfo = tableInfo.getPackageInfo(); |
|
358 | 304 |
|
359 |
} else { |
|
360 |
if (tableInfo.isSelected()) { |
|
361 |
return PackageStatus.TO_INSTALL; |
|
362 |
} else { |
|
363 |
return PackageStatus.NOT_INSTALLED; |
|
364 |
} |
|
365 |
} |
|
366 |
} |
|
305 |
switch (columnIndex) { |
|
306 |
case 0: |
|
307 |
PackageStatus installStatus = checkStatus(rowIndex); |
|
308 |
return installStatus; |
|
309 |
case 1: |
|
310 |
PackageOfficialRecommended officialRecommended = checkOfficialRecommended(rowIndex); |
|
311 |
return officialRecommended; |
|
312 |
case 2: |
|
313 |
PackageOsAndArchitecture packageSystem = checkPackageSystem(rowIndex); |
|
314 |
return packageSystem; |
|
315 |
case 3: |
|
316 |
return installerInfo.getName(); |
|
317 |
case 4: |
|
318 |
return installerInfo.getVersion(); |
|
319 |
case 5: |
|
320 |
return installerInfo.getType(); |
|
321 |
// case 5: |
|
322 |
// if (installerInfo.getOperatingSystem().equals( |
|
323 |
// installerInfo.getArchitecture())) { |
|
324 |
// return "all"; |
|
325 |
// } else { |
|
326 |
// return installerInfo.getOperatingSystem() + " " |
|
327 |
// + installerInfo.getArchitecture(); |
|
328 |
// } |
|
329 |
default: |
|
330 |
return ""; |
|
367 | 331 |
|
368 |
private PackageOfficialRecommended checkOfficialRecommended(int rowIndex) { |
|
369 |
TablePackageInfo tableInfo = installerInfos[rowIndex]; |
|
370 |
PackageInfo packageInfo = tableInfo.getPackageInfo(); |
|
332 |
} |
|
333 |
} |
|
371 | 334 |
|
372 |
if (packageInfo.isOfficial()) { |
|
373 |
if (installerInfos[rowIndex].isDefault()) { |
|
374 |
return PackageOfficialRecommended.OFFICIAL_RECOMMENDED; |
|
375 |
} else { |
|
376 |
return PackageOfficialRecommended.OFFICIAL_NOT_RECOMMENDED; |
|
377 |
} |
|
378 |
} else { |
|
379 |
if (installerInfos[rowIndex].isDefault()) { |
|
380 |
return PackageOfficialRecommended.NOT_OFFICIAL_RECOMMENDED; |
|
381 |
} else { |
|
382 |
return PackageOfficialRecommended.NOT_OFFICIAL_NOT_RECOMMENDED; |
|
383 |
} |
|
384 |
} |
|
385 |
} |
|
335 |
/** |
|
336 |
* @param rowIndex |
|
337 |
* @return |
|
338 |
*/ |
|
339 |
private PackageOsAndArchitecture checkPackageSystem(int rowIndex) { |
|
340 |
TablePackageInfo tableInfo = installerInfos[rowIndex]; |
|
341 |
PackageInfo installerInfo = tableInfo.getPackageInfo(); |
|
342 |
PackageOsAndArchitecture oSArch; |
|
386 | 343 |
|
387 |
public PackageInfo getPackageInfoAt(int rowIndex) { |
|
388 |
return installerInfos[rowIndex].getPackageInfo(); |
|
389 |
} |
|
344 |
if (installerInfo.getOperatingSystem().equals( |
|
345 |
installerInfo.getArchitecture())) { |
|
346 |
oSArch = PackageOsAndArchitecture.ALL; |
|
347 |
} else if ((installerInfo.getOperatingSystem().equals("lin"))) { |
|
348 |
if (installerInfo.getArchitecture().equals("x86")) { |
|
349 |
oSArch = PackageOsAndArchitecture.LINUX_32; |
|
350 |
} else { |
|
351 |
oSArch = PackageOsAndArchitecture.LINUX_64; |
|
352 |
} |
|
353 |
} else if ((installerInfo.getOperatingSystem().equals("win"))) { |
|
354 |
if (installerInfo.getArchitecture().equals("x86")) { |
|
355 |
oSArch = PackageOsAndArchitecture.WINDOLS_32; |
|
356 |
} else { |
|
357 |
oSArch = PackageOsAndArchitecture.WINDOLS_64; |
|
358 |
} |
|
359 |
} else { |
|
360 |
oSArch = PackageOsAndArchitecture.OTHER; |
|
361 |
} |
|
362 |
return oSArch; |
|
363 |
} |
|
390 | 364 |
|
391 |
public String getDescriptionAt(int rowIndex) { |
|
392 |
return getPackageInfoAt(rowIndex).getDescription(); |
|
393 |
} |
|
365 |
/** |
|
366 |
* @return |
|
367 |
*/ |
|
368 |
private PackageStatus checkStatus(int rowIndex) { |
|
369 |
TablePackageInfo tableInfo = installerInfos[rowIndex]; |
|
394 | 370 |
|
395 |
public URL getSourcesAt(int rowIndex) { |
|
396 |
return getPackageInfoAt(rowIndex).getSourcesURL(); |
|
397 |
} |
|
371 |
if (tableInfo.isInstalled()) { |
|
372 |
if (tableInfo.isInstallable()) { |
|
373 |
if (tableInfo.isSelected()) { |
|
374 |
return PackageStatus.TO_REINSTALL; |
|
375 |
} else { |
|
376 |
return PackageStatus.INSTALLED; |
|
377 |
} |
|
378 |
} else { |
|
379 |
return PackageStatus.INSTALLED_NOT_INSTALLABLE; |
|
380 |
} |
|
398 | 381 |
|
399 |
public String getOwnerAt(int rowIndex) { |
|
400 |
return getPackageInfoAt(rowIndex).getOwner(); |
|
401 |
} |
|
382 |
} else { |
|
383 |
if (tableInfo.isSelected()) { |
|
384 |
return PackageStatus.TO_INSTALL; |
|
385 |
} else { |
|
386 |
return PackageStatus.NOT_INSTALLED; |
|
387 |
} |
|
388 |
} |
|
389 |
} |
|
402 | 390 |
|
403 |
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
|
404 |
return (columnIndex == 0) && installerInfos[rowIndex].isInstallable();
|
|
405 |
}
|
|
391 |
private PackageOfficialRecommended checkOfficialRecommended(int rowIndex) {
|
|
392 |
TablePackageInfo tableInfo = installerInfos[rowIndex];
|
|
393 |
PackageInfo packageInfo = tableInfo.getPackageInfo();
|
|
406 | 394 |
|
407 |
public void setValueAt(Object aValue, int rowIndex, int columnIndex) { |
|
395 |
if (packageInfo.isOfficial()) { |
|
396 |
if (installerInfos[rowIndex].isDefault()) { |
|
397 |
return PackageOfficialRecommended.OFFICIAL_RECOMMENDED; |
|
398 |
} else { |
|
399 |
return PackageOfficialRecommended.OFFICIAL_NOT_RECOMMENDED; |
|
400 |
} |
|
401 |
} else { |
|
402 |
if (installerInfos[rowIndex].isDefault()) { |
|
403 |
return PackageOfficialRecommended.NOT_OFFICIAL_RECOMMENDED; |
|
404 |
} else { |
|
405 |
return PackageOfficialRecommended.NOT_OFFICIAL_NOT_RECOMMENDED; |
|
406 |
} |
|
407 |
} |
|
408 |
} |
|
408 | 409 |
|
409 |
if (columnIndex == 0) { |
|
410 |
PackageStatus status = (PackageStatus) aValue; |
|
411 |
TablePackageInfo tableInfo = installerInfos[rowIndex]; |
|
412 |
switch (status) { |
|
413 |
case INSTALLED: |
|
414 |
case NOT_INSTALLED: |
|
415 |
tableInfo.setSelected(false); |
|
416 |
break; |
|
410 |
public PackageInfo getPackageInfoAt(int rowIndex) { |
|
411 |
return installerInfos[rowIndex].getPackageInfo(); |
|
412 |
} |
|
417 | 413 |
|
418 |
case TO_REINSTALL: |
|
419 |
case TO_INSTALL: |
|
420 |
tableInfo.setSelected(true); |
|
421 |
break; |
|
422 |
} |
|
423 |
} |
|
424 |
} |
|
414 |
public String getDescriptionAt(int rowIndex) { |
|
415 |
return getPackageInfoAt(rowIndex).getDescription(); |
|
416 |
} |
|
425 | 417 |
|
426 |
public List<PackageInfo> getPackagesToInstall() { |
|
427 |
List<PackageInfo> packageInfosToInstall = new ArrayList<PackageInfo>(); |
|
428 |
for (int i = 0; i < installerInfos.length; i++) { |
|
429 |
TablePackageInfo tableInfo = installerInfos[i]; |
|
430 |
if (tableInfo.isSelected()) { |
|
431 |
packageInfosToInstall.add(tableInfo.getPackageInfo()); |
|
432 |
} |
|
433 |
} |
|
434 |
return packageInfosToInstall; |
|
435 |
} |
|
418 |
public URL getSourcesAt(int rowIndex) { |
|
419 |
return getPackageInfoAt(rowIndex).getSourcesURL(); |
|
420 |
} |
|
436 | 421 |
|
437 |
public boolean hasAnyPackageSelected() { |
|
438 |
for (int i = 0; i < installerInfos.length; i++) { |
|
439 |
if (installerInfos[i].isSelected) { |
|
440 |
return true; |
|
441 |
} |
|
442 |
} |
|
443 |
return false; |
|
444 |
} |
|
422 |
public String getOwnerAt(int rowIndex) { |
|
423 |
return getPackageInfoAt(rowIndex).getOwner(); |
|
424 |
} |
|
445 | 425 |
|
446 |
public static final class TablePackageInfo { |
|
426 |
public boolean isCellEditable(int rowIndex, int columnIndex) { |
|
427 |
return (columnIndex == 0) && installerInfos[rowIndex].isInstallable(); |
|
428 |
} |
|
447 | 429 |
|
448 |
private final PackageInfo packageInfo; |
|
449 |
private boolean isInstalled; |
|
450 |
private final boolean isInstallable; |
|
451 |
private boolean isSelected; |
|
452 |
private boolean isDefault; |
|
430 |
public void setValueAt(Object aValue, int rowIndex, int columnIndex) { |
|
453 | 431 |
|
454 |
public TablePackageInfo(PackageInfo packageInfo, boolean isInstalled, |
|
455 |
boolean isInstallable) { |
|
456 |
this(packageInfo, isInstalled, isInstallable, false, false); |
|
457 |
} |
|
432 |
if (columnIndex == 0) { |
|
433 |
PackageStatus status = (PackageStatus) aValue; |
|
434 |
TablePackageInfo tableInfo = installerInfos[rowIndex]; |
|
435 |
switch (status) { |
|
436 |
case INSTALLED: |
|
437 |
case NOT_INSTALLED: |
|
438 |
tableInfo.setSelected(false); |
|
439 |
break; |
|
458 | 440 |
|
459 |
public void setInstalled(boolean installed) { |
|
460 |
this.isInstalled = installed; |
|
461 |
} |
|
441 |
case TO_REINSTALL: |
|
442 |
case TO_INSTALL: |
|
443 |
tableInfo.setSelected(true); |
|
444 |
break; |
|
445 |
} |
|
446 |
} |
|
447 |
} |
|
462 | 448 |
|
463 |
public TablePackageInfo(PackageInfo packageInfo, boolean isInstalled, |
|
464 |
boolean isInstallable, boolean isSelected, boolean isDefault) { |
|
465 |
this.packageInfo = packageInfo; |
|
466 |
this.isInstalled = isInstalled; |
|
467 |
this.isInstallable = isInstallable; |
|
468 |
this.isSelected = isSelected; |
|
469 |
this.isDefault = isDefault; |
|
470 |
} |
|
449 |
public List<PackageInfo> getPackagesToInstall() { |
|
450 |
List<PackageInfo> packageInfosToInstall = new ArrayList<PackageInfo>(); |
|
451 |
for (int i = 0; i < installerInfos.length; i++) { |
|
452 |
TablePackageInfo tableInfo = installerInfos[i]; |
|
453 |
if (tableInfo.isSelected()) { |
|
454 |
packageInfosToInstall.add(tableInfo.getPackageInfo()); |
|
455 |
} |
|
456 |
} |
|
457 |
return packageInfosToInstall; |
|
458 |
} |
|
471 | 459 |
|
472 |
public String getID() { |
|
473 |
PackageInfo pkg = this.getPackageInfo(); |
|
474 |
return pkg.getID(); |
|
475 |
} |
|
460 |
public boolean hasAnyPackageSelected() { |
|
461 |
for (int i = 0; i < installerInfos.length; i++) { |
|
462 |
if (installerInfos[i].isSelected) { |
|
463 |
return true; |
|
464 |
} |
|
465 |
} |
|
466 |
return false; |
|
467 |
} |
|
476 | 468 |
|
477 |
public PackageInfo getPackageInfo() { |
|
478 |
return packageInfo; |
|
479 |
} |
|
469 |
public static final class TablePackageInfo { |
|
480 | 470 |
|
481 |
public boolean isInstalled() { |
|
482 |
return isInstalled; |
|
483 |
} |
|
471 |
private final PackageInfo packageInfo; |
|
472 |
private boolean isInstalled; |
|
473 |
private final boolean isInstallable; |
|
474 |
private boolean isSelected; |
|
475 |
private boolean isDefault; |
|
484 | 476 |
|
485 |
public boolean isInstallable() { |
|
486 |
return isInstallable; |
|
487 |
} |
|
477 |
public TablePackageInfo(PackageInfo packageInfo, boolean isInstalled, |
|
478 |
boolean isInstallable) { |
|
479 |
this(packageInfo, isInstalled, isInstallable, false, false); |
|
480 |
} |
|
488 | 481 |
|
489 |
public boolean isSelected() {
|
|
490 |
return isSelected;
|
|
491 |
}
|
|
482 |
public void setInstalled(boolean installed) {
|
|
483 |
this.isInstalled = installed;
|
|
484 |
}
|
|
492 | 485 |
|
493 |
public void setSelected(boolean isSelected) { |
|
494 |
this.isSelected = isSelected; |
|
495 |
} |
|
486 |
public TablePackageInfo(PackageInfo packageInfo, boolean isInstalled, |
|
487 |
boolean isInstallable, boolean isSelected, boolean isDefault) { |
|
488 |
this.packageInfo = packageInfo; |
|
489 |
this.isInstalled = isInstalled; |
|
490 |
this.isInstallable = isInstallable; |
|
491 |
this.isSelected = isSelected; |
|
492 |
this.isDefault = isDefault; |
|
493 |
} |
|
496 | 494 |
|
497 |
public void setDefault(boolean isDefault) { |
|
498 |
this.isDefault = isDefault; |
|
499 |
} |
|
495 |
public String getID() { |
|
496 |
PackageInfo pkg = this.getPackageInfo(); |
|
497 |
return pkg.getID(); |
|
498 |
} |
|
500 | 499 |
|
501 |
public boolean isDefault() {
|
|
502 |
return isDefault;
|
|
503 |
}
|
|
500 |
public PackageInfo getPackageInfo() {
|
|
501 |
return packageInfo;
|
|
502 |
}
|
|
504 | 503 |
|
505 |
} |
|
504 |
public boolean isInstalled() { |
|
505 |
return isInstalled; |
|
506 |
} |
|
506 | 507 |
|
507 |
/** |
|
508 |
* Returns the TablePackageInfo located in the given row. |
|
509 |
* |
|
510 |
* @param row |
|
511 |
* the TablePackageInfo located in the given row |
|
512 |
*/ |
|
513 |
public TablePackageInfo getPackageInfo(int row) { |
|
514 |
return installerInfos[row]; |
|
515 |
} |
|
508 |
public boolean isInstallable() { |
|
509 |
return isInstallable; |
|
510 |
} |
|
516 | 511 |
|
517 |
public void setFilter(PackageFilter filter) {
|
|
518 |
this.packageFilter = filter;
|
|
519 |
}
|
|
512 |
public boolean isSelected() {
|
|
513 |
return isSelected;
|
|
514 |
}
|
|
520 | 515 |
|
521 |
public Boolean isFilterSet() {
|
|
522 |
return this.packageFilter != null;
|
|
523 |
}
|
|
516 |
public void setSelected(boolean isSelected) {
|
|
517 |
this.isSelected = isSelected;
|
|
518 |
}
|
|
524 | 519 |
|
525 |
public PackageFilter getFilter() {
|
|
526 |
return this.packageFilter;
|
|
527 |
}
|
|
520 |
public void setDefault(boolean isDefault) {
|
|
521 |
this.isDefault = isDefault;
|
|
522 |
}
|
|
528 | 523 |
|
529 |
public InstallPackageService getInstallPackageService() {
|
|
530 |
return this.installerExecutionService;
|
|
531 |
}
|
|
524 |
public boolean isDefault() {
|
|
525 |
return isDefault;
|
|
526 |
}
|
|
532 | 527 |
|
528 |
} |
|
529 |
|
|
530 |
/** |
|
531 |
* Returns the TablePackageInfo located in the given row. |
|
532 |
* |
|
533 |
* @param row |
|
534 |
* the TablePackageInfo located in the given row |
|
535 |
*/ |
|
536 |
public TablePackageInfo getPackageInfo(int row) { |
|
537 |
return installerInfos[row]; |
|
538 |
} |
|
539 |
|
|
540 |
public void setFilter(PackageFilter filter) { |
|
541 |
this.packageFilter = filter; |
|
542 |
} |
|
543 |
|
|
544 |
public void setFilter(NameAndDescriptionFilter filter) { |
|
545 |
this.packageFastFilter = filter; |
|
546 |
} |
|
547 |
|
|
548 |
private Boolean isFastFilterSet() { |
|
549 |
return this.packageFastFilter != null; |
|
550 |
} |
|
551 |
|
|
552 |
private Boolean isPackageFilterSet() { |
|
553 |
return this.packageFilter != null; |
|
554 |
} |
|
555 |
|
|
556 |
public PackageFilter getFilter() { |
|
557 |
return this.packageFastFilter; |
|
558 |
} |
|
559 |
|
|
560 |
public InstallPackageService getInstallPackageService() { |
|
561 |
return this.installerExecutionService; |
|
562 |
} |
|
533 | 563 |
} |
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/FastFilterButtonsPanel.java | ||
---|---|---|
44 | 44 |
*/ |
45 | 45 |
public class FastFilterButtonsPanel extends JPanel implements ActionListener { |
46 | 46 |
|
47 |
private static final long serialVersionUID = 3767011079359743742L;
|
|
47 |
private static final long serialVersionUID = 3767011079359743742L;
|
|
48 | 48 |
|
49 |
private PackagesTablePanel panel;
|
|
50 |
private SwingInstallerManager swingInstallerManager;
|
|
49 |
private PackagesTablePanel panel;
|
|
50 |
private SwingInstallerManager swingInstallerManager;
|
|
51 | 51 |
|
52 |
private JButton searchButton;
|
|
53 |
private JButton resetButton;
|
|
54 |
private JTextField textField;
|
|
55 |
NameAndDescriptionFilter filter = null;
|
|
52 |
private JButton searchButton;
|
|
53 |
private JButton resetButton;
|
|
54 |
private JTextField textField;
|
|
55 |
private NameAndDescriptionFilter filter = null;
|
|
56 | 56 |
|
57 |
public FastFilterButtonsPanel(PackagesTablePanel panel) { |
|
58 |
this.panel = panel; |
|
59 |
swingInstallerManager = |
|
60 |
(DefaultSwingInstallerManager) SwingInstallerLocator |
|
61 |
.getSwingInstallerManager(); |
|
62 |
initComponents(); |
|
63 |
} |
|
57 |
public FastFilterButtonsPanel(PackagesTablePanel panel) { |
|
58 |
this.panel = panel; |
|
59 |
swingInstallerManager = SwingInstallerLocator |
|
60 |
.getSwingInstallerManager(); |
|
61 |
initComponents(); |
|
62 |
} |
|
64 | 63 |
|
65 |
private void initComponents() {
|
|
64 |
private void initComponents() {
|
|
66 | 65 |
|
67 |
filter = new NameAndDescriptionFilter("");
|
|
66 |
filter = new NameAndDescriptionFilter("");
|
|
68 | 67 |
|
69 |
JLabel fastFilterLabel =
|
|
70 |
new JLabel(swingInstallerManager.getText("_fast_filter"));
|
|
68 |
JLabel fastFilterLabel = new JLabel(swingInstallerManager
|
|
69 |
.getText("_fast_filter"));
|
|
71 | 70 |
|
72 |
textField = new JTextField(20);
|
|
71 |
textField = new JTextField(20);
|
|
73 | 72 |
|
74 |
MyKeyListener l = new MyKeyListener();
|
|
73 |
MyKeyListener l = new MyKeyListener();
|
|
75 | 74 |
|
76 |
textField.addKeyListener(l);
|
|
75 |
textField.addKeyListener(l);
|
|
77 | 76 |
|
78 |
searchButton = new JButton(swingInstallerManager.getText("_search"));
|
|
79 |
searchButton.setActionCommand("search");
|
|
80 |
searchButton.addActionListener(this);
|
|
77 |
searchButton = new JButton(swingInstallerManager.getText("_search"));
|
|
78 |
searchButton.setActionCommand("search");
|
|
79 |
searchButton.addActionListener(this);
|
|
81 | 80 |
|
82 |
resetButton = new JButton(swingInstallerManager.getText("_reset"));
|
|
83 |
resetButton.setActionCommand("reset");
|
|
84 |
resetButton.addActionListener(this);
|
|
81 |
resetButton = new JButton(swingInstallerManager.getText("_reset_filters"));
|
|
82 |
resetButton.setActionCommand("reset");
|
|
83 |
resetButton.addActionListener(this);
|
|
85 | 84 |
|
86 |
setLayout(new FlowLayout(FlowLayout.LEFT));
|
|
85 |
setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
|
|
87 | 86 |
|
88 |
add(fastFilterLabel);
|
|
89 |
add(textField);
|
|
90 |
add(searchButton);
|
|
91 |
add(resetButton);
|
|
87 |
add(fastFilterLabel);
|
|
88 |
add(textField);
|
|
89 |
// add(searchButton);
|
|
90 |
add(resetButton);
|
|
92 | 91 |
|
93 |
}
|
|
92 |
}
|
|
94 | 93 |
|
95 |
public void actionPerformed(ActionEvent e) {
|
|
96 |
if ("search".equals(e.getActionCommand())) {
|
|
97 |
searchAction();
|
|
98 |
} else {
|
|
99 |
if ("reset".equals(e.getActionCommand())) {
|
|
100 |
resetAction();
|
|
101 |
}
|
|
102 |
}
|
|
103 |
}
|
|
94 |
public void actionPerformed(ActionEvent e) {
|
|
95 |
if ("search".equals(e.getActionCommand())) {
|
|
96 |
searchAction();
|
|
97 |
} else {
|
|
98 |
if ("reset".equals(e.getActionCommand())) {
|
|
99 |
resetAction();
|
|
100 |
}
|
|
101 |
}
|
|
102 |
}
|
|
104 | 103 |
|
105 |
private void searchAction() {
|
|
106 |
filter.setFilter(textField.getText());
|
|
107 |
panel.setFilter(filter);
|
|
108 |
}
|
|
104 |
private void searchAction() {
|
|
105 |
filter.setFilter(textField.getText());
|
|
106 |
panel.setFilter(filter);
|
|
107 |
}
|
|
109 | 108 |
|
110 |
private void resetAction() { |
|
111 |
this.resetPanel(); |
|
112 |
} |
|
113 |
|
|
114 |
public void resetPanel() { |
|
115 |
textField.setText(""); |
|
116 |
filter.setFilter(""); |
|
117 |
panel.setFilter(filter); |
|
118 |
panel.resetPanel(); |
|
119 |
} |
|
109 |
private void resetAction() { |
|
110 |
this.resetPanel(); |
|
111 |
} |
|
120 | 112 |
|
121 |
private class MyKeyListener implements KeyListener { |
|
113 |
public void resetPanel() { |
|
114 |
textField.setText(""); |
|
115 |
filter.setFilter(""); |
|
116 |
panel.setFilter(filter); |
|
117 |
panel.resetPanel(); |
|
118 |
} |
|
122 | 119 |
|
123 |
public void keyTyped(KeyEvent e) { |
|
124 |
} |
|
120 |
private class MyKeyListener implements KeyListener { |
|
125 | 121 |
|
126 |
public void keyReleased(KeyEvent e) { |
|
127 |
searchAction(); |
|
128 |
textField.requestFocus(); |
|
129 |
textField.setCaretPosition(textField.getDocument().getLength()); |
|
130 |
} |
|
122 |
public void keyTyped(KeyEvent e) { |
|
123 |
} |
|
131 | 124 |
|
132 |
public void keyPressed(KeyEvent e) { |
|
133 |
} |
|
134 |
} |
|
125 |
public void keyReleased(KeyEvent e) { |
|
126 |
searchAction(); |
|
127 |
textField.requestFocus(); |
|
128 |
textField.setCaretPosition(textField.getDocument().getLength()); |
|
129 |
} |
|
135 | 130 |
|
131 |
public void keyPressed(KeyEvent e) { |
|
132 |
} |
|
133 |
} |
|
134 |
|
|
136 | 135 |
} |
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/PackagesTablePanel.java | ||
---|---|---|
49 | 49 |
import org.gvsig.installer.lib.api.PackageInfo; |
50 | 50 |
import org.gvsig.installer.swing.api.SwingInstallerLocator; |
51 | 51 |
import org.gvsig.installer.swing.api.SwingInstallerManager; |
52 |
import org.gvsig.installer.swing.impl.execution.panel.filters.NameAndDescriptionFilter; |
|
52 | 53 |
import org.gvsig.installer.swing.impl.execution.panel.filters.PackageFilter; |
53 | 54 |
import org.gvsig.installer.swing.impl.execution.panel.model.PackagesTableModel; |
54 | 55 |
import org.gvsig.installer.swing.impl.execution.panel.model.PackagesTableModel.PackageOfficialRecommended; |
... | ... | |
75 | 76 |
private JTextPane descriptionTextPane; |
76 | 77 |
private JScrollPane pluginsScrollPane; |
77 | 78 |
private JTable pluginsTable; |
78 |
private CategoriesFilterPanel filterPanel;
|
|
79 |
private PackagePropertiesFilterPanel filterPanel;
|
|
79 | 80 |
private FastFilterButtonsPanel fastFilterPanel; |
80 | 81 |
private SelectPackagesPanel selectPackagesPanel; |
81 | 82 |
|
... | ... | |
121 | 122 |
|
122 | 123 |
descriptionScrollPane = new JScrollPane(descriptionTextArea); |
123 | 124 |
|
124 |
filterPanel = new CategoriesFilterPanel(this);
|
|
125 |
filterPanel.setVisible(false);
|
|
125 |
filterPanel = new PackagePropertiesFilterPanel(this);
|
|
126 |
filterPanel.setVisible(true);
|
|
126 | 127 |
|
127 | 128 |
fastFilterPanel = new FastFilterButtonsPanel(this); |
128 | 129 |
|
129 | 130 |
setLayout(new GridBagLayout()); |
130 | 131 |
|
131 |
// panel filter |
|
132 |
// left panel filter
|
|
132 | 133 |
gridBagConstraints = new GridBagConstraints(); |
133 | 134 |
gridBagConstraints.fill = GridBagConstraints.BOTH; |
134 | 135 |
gridBagConstraints.gridx = 0; |
135 |
gridBagConstraints.gridy = 0;
|
|
136 |
gridBagConstraints.gridy = 1;
|
|
136 | 137 |
gridBagConstraints.weightx = 0.13; |
137 | 138 |
gridBagConstraints.weighty = 1; |
138 |
gridBagConstraints.gridheight = 3;
|
|
139 |
gridBagConstraints.insets = new Insets(2, 2, 2, 2);
|
|
139 |
gridBagConstraints.gridheight = 2;
|
|
140 |
gridBagConstraints.insets = new Insets(0, 2, 2, 2);
|
|
140 | 141 |
add(filterPanel, gridBagConstraints); |
141 | 142 |
|
142 |
// filters buttons panel |
|
143 |
// fast filters buttons panel
|
|
143 | 144 |
gridBagConstraints = new GridBagConstraints(); |
144 | 145 |
gridBagConstraints.fill = GridBagConstraints.BOTH; |
145 | 146 |
gridBagConstraints.gridx = 1; |
... | ... | |
186 | 187 |
pluginsTable.setModel(pluginsTableModel); |
187 | 188 |
pluginsTableModel.fireTableDataChanged(); |
188 | 189 |
TableColumnModel tableColumnModel = pluginsTable.getColumnModel(); |
190 |
// tableColumnModel.getColumn(0).setPreferredWidth(20); |
|
191 |
// tableColumnModel.getColumn(1).setPreferredWidth(20); |
|
192 |
// tableColumnModel.getColumn(2).setPreferredWidth(20); |
|
193 |
// tableColumnModel.getColumn(3).setPreferredWidth(340); |
|
194 |
// tableColumnModel.getColumn(4).setPreferredWidth(150); |
|
195 |
// tableColumnModel.getColumn(5).setPreferredWidth(55); |
|
189 | 196 |
tableColumnModel.getColumn(0).setPreferredWidth(20); |
190 | 197 |
tableColumnModel.getColumn(1).setPreferredWidth(20); |
191 | 198 |
tableColumnModel.getColumn(2).setPreferredWidth(20); |
192 |
tableColumnModel.getColumn(3).setPreferredWidth(325); |
|
193 |
tableColumnModel.getColumn(4).setPreferredWidth(150); |
|
194 |
tableColumnModel.getColumn(5).setPreferredWidth(55); |
|
195 |
// tableColumnModel.getColumn(0).setPreferredWidth(20); |
|
196 |
// tableColumnModel.getColumn(1).setPreferredWidth(20); |
|
197 |
// tableColumnModel.getColumn(2).setPreferredWidth(20); |
|
198 |
// tableColumnModel.getColumn(3).setPreferredWidth(225); |
|
199 |
// tableColumnModel.getColumn(4).setPreferredWidth(130); |
|
200 |
// tableColumnModel.getColumn(5).setPreferredWidth(53); |
|
199 |
tableColumnModel.getColumn(3).setPreferredWidth(225); |
|
200 |
tableColumnModel.getColumn(4).setPreferredWidth(130); |
|
201 |
tableColumnModel.getColumn(5).setPreferredWidth(53); |
|
201 | 202 |
|
202 | 203 |
} |
203 | 204 |
|
... | ... | |
289 | 290 |
selectPackagesPanel.updatePanel(); |
290 | 291 |
} |
291 | 292 |
|
293 |
public void setFilter(NameAndDescriptionFilter filter) { |
|
294 |
PackagesTableModel pluginsTableModel = (PackagesTableModel) pluginsTable |
|
295 |
.getModel(); |
|
296 |
pluginsTableModel.setFilter(filter); |
|
297 |
selectPackagesPanel.updatePanel(); |
|
298 |
} |
|
299 |
|
|
292 | 300 |
private class MyMouseListener implements MouseListener { |
293 | 301 |
|
294 | 302 |
public void mouseClicked(MouseEvent e) { |
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/filters/CategoryFilter.java | ||
---|---|---|
1 |
package org.gvsig.installer.swing.impl.execution.panel.filters; |
|
2 |
|
|
3 |
import java.util.List; |
|
4 |
|
|
5 |
import org.gvsig.installer.lib.api.PackageInfo; |
|
6 |
|
|
7 |
/** |
|
8 |
* @author gvSIG Team |
|
9 |
* @version $Id$ |
|
10 |
* |
|
11 |
*/ |
|
12 |
|
|
13 |
public class CategoryFilter implements PackageFilter { |
|
14 |
|
|
15 |
private String category; |
|
16 |
|
|
17 |
public CategoryFilter(String type) { |
|
18 |
this.category = type; |
|
19 |
} |
|
20 |
|
|
21 |
@Override |
|
22 |
public String toString() { |
|
23 |
return category; |
|
24 |
} |
|
25 |
|
|
26 |
public boolean match(PackageInfo pkg) { |
|
27 |
List<String> list = pkg.getCategories(); |
|
28 |
if (list.contains(category)) { |
|
29 |
return true; |
|
30 |
} else { |
|
31 |
return false; |
|
32 |
} |
|
33 |
} |
|
34 |
|
|
35 |
} |
|
0 | 36 |
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/filters/TypeFilter.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import org.gvsig.installer.lib.api.PackageInfo; |
25 | 25 |
|
26 |
|
|
27 | 26 |
/** |
28 | 27 |
* @author gvSIG Team |
29 | 28 |
* @version $Id$ |
30 |
* |
|
29 |
*
|
|
31 | 30 |
*/ |
32 |
public class TypeFilter implements PackageFilter{ |
|
33 |
|
|
34 |
private String type; |
|
31 |
public class TypeFilter implements PackageFilter { |
|
35 | 32 |
|
36 |
public TypeFilter(String type) { |
|
37 |
this.type = type; |
|
38 |
} |
|
33 |
private String type; |
|
39 | 34 |
|
40 |
public String toString() { |
|
41 |
return type; |
|
42 |
} |
|
43 |
|
|
44 |
public boolean match(PackageInfo pkg) { |
|
45 |
// TODO Auto-generated method stub |
|
46 |
return false; |
|
47 |
} |
|
35 |
public TypeFilter(String type) { |
|
36 |
this.type = type; |
|
37 |
} |
|
48 | 38 |
|
39 |
@Override |
|
40 |
public String toString() { |
|
41 |
return this.type; |
|
42 |
} |
|
43 |
|
|
44 |
public boolean match(PackageInfo pkg) { |
|
45 |
return this.type.equals(pkg.getType()); |
|
46 |
} |
|
47 |
|
|
49 | 48 |
} |
branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/filters/NameAndDescriptionFilter.java | ||
---|---|---|
30 | 30 |
*/ |
31 | 31 |
public class NameAndDescriptionFilter implements PackageFilter { |
32 | 32 |
|
33 |
private String filterString;
|
|
33 |
private String filterString;
|
|
34 | 34 |
|
35 |
public NameAndDescriptionFilter(String filterString) { |
Also available in: Unified diff