svn-gvsig-desktop / 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 / model / PluginsTableModel.java @ 32401
History | View | Annotate | Download (4.19 KB)
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.model; |
29 |
|
30 |
import java.util.ArrayList; |
31 |
import java.util.List; |
32 |
|
33 |
import javax.swing.JCheckBox; |
34 |
import javax.swing.event.TableModelListener; |
35 |
import javax.swing.table.TableModel; |
36 |
|
37 |
import org.gvsig.installer.lib.api.InstallerInfo; |
38 |
import org.gvsig.installer.lib.api.execution.InstallerExecutionService; |
39 |
import org.gvsig.installer.swing.impl.DefaultSwingInstallerManager; |
40 |
|
41 |
/**
|
42 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a>
|
43 |
*/
|
44 |
public class PluginsTableModel implements TableModel{ |
45 |
private DefaultSwingInstallerManager swingInstallerManager = null; |
46 |
private List<InstallerInfo> installerInfos = null; |
47 |
private List<Boolean> selected = null; |
48 |
|
49 |
public PluginsTableModel(DefaultSwingInstallerManager swingInstallerManager, InstallerExecutionService installerExecutionService, boolean isOfficial) { |
50 |
super();
|
51 |
this.swingInstallerManager = swingInstallerManager;
|
52 |
|
53 |
installerInfos = new ArrayList<InstallerInfo>(); |
54 |
selected = new ArrayList<Boolean>(); |
55 |
for (int i=0 ; i<installerExecutionService.getPluginsSize() ; i++){ |
56 |
InstallerInfo installerInfo = installerExecutionService.getPluginInfoAt(i); |
57 |
if (installerInfo.isOfficial() == isOfficial){
|
58 |
installerInfos.add(installerInfo); |
59 |
selected.add(false);
|
60 |
} |
61 |
} |
62 |
} |
63 |
|
64 |
public void addTableModelListener(TableModelListener l) { |
65 |
// TODO Auto-generated method stub
|
66 |
|
67 |
} |
68 |
|
69 |
public Class<?> getColumnClass(int columnIndex) { |
70 |
switch(columnIndex){
|
71 |
case 0: |
72 |
return Boolean.class; |
73 |
default:
|
74 |
return String.class; |
75 |
} |
76 |
} |
77 |
|
78 |
public int getColumnCount() { |
79 |
return 6; |
80 |
} |
81 |
|
82 |
public String getColumnName(int columnIndex) { |
83 |
switch(columnIndex){
|
84 |
case 0: |
85 |
return swingInstallerManager.getText("selected"); |
86 |
case 1: |
87 |
return swingInstallerManager.getText("name"); |
88 |
case 2: |
89 |
return swingInstallerManager.getText("type"); |
90 |
case 3: |
91 |
return swingInstallerManager.getText("status"); |
92 |
case 4: |
93 |
return swingInstallerManager.getText("version"); |
94 |
case 5: |
95 |
return swingInstallerManager.getText("build"); |
96 |
default:
|
97 |
return ""; |
98 |
} |
99 |
} |
100 |
|
101 |
public int getRowCount() { |
102 |
return installerInfos.size();
|
103 |
} |
104 |
|
105 |
public Object getValueAt(int rowIndex, int columnIndex) { |
106 |
InstallerInfo installerInfo = installerInfos.get(rowIndex); |
107 |
switch (columnIndex){
|
108 |
case 0: |
109 |
return selected.get(rowIndex);
|
110 |
case 1: |
111 |
return installerInfo.getName();
|
112 |
case 2: |
113 |
return installerInfo.getType();
|
114 |
case 3: |
115 |
return installerInfo.getState();
|
116 |
case 4: |
117 |
return installerInfo.getVersion();
|
118 |
case 5: |
119 |
return installerInfo.getBuild();
|
120 |
default:
|
121 |
return ""; |
122 |
|
123 |
} |
124 |
} |
125 |
|
126 |
public String getDescriptionAt(int rowIndex){ |
127 |
return installerInfos.get(rowIndex).getDescription();
|
128 |
} |
129 |
|
130 |
public boolean isCellEditable(int rowIndex, int columnIndex) { |
131 |
if (columnIndex == 0){ |
132 |
return true; |
133 |
} |
134 |
return false; |
135 |
} |
136 |
|
137 |
public void removeTableModelListener(TableModelListener l) { |
138 |
// TODO Auto-generated method stub
|
139 |
|
140 |
} |
141 |
|
142 |
public void setValueAt(Object aValue, int rowIndex, int columnIndex) { |
143 |
selected.remove(rowIndex); |
144 |
selected.add(rowIndex,(Boolean)aValue);
|
145 |
} |
146 |
|
147 |
public void addInstallersToExecute(List<InstallerInfo> installerInfosToInstall){ |
148 |
for (int i=0 ; i<installerInfos.size() ; i++){ |
149 |
if (selected.get(i)){
|
150 |
installerInfosToInstall.add(installerInfos.get(i)); |
151 |
} |
152 |
} |
153 |
} |
154 |
} |
155 |
|