Lines 41-52
Link Here
|
41 |
|
41 |
|
42 |
package org.netbeans.modules.autoupdate.ui.wizards; |
42 |
package org.netbeans.modules.autoupdate.ui.wizards; |
43 |
|
43 |
|
|
|
44 |
import java.awt.event.ActionEvent; |
45 |
import java.util.ArrayList; |
44 |
import java.util.Collection; |
46 |
import java.util.Collection; |
45 |
import java.util.Collections; |
47 |
import java.util.Collections; |
46 |
import java.util.HashMap; |
|
|
47 |
import java.util.HashSet; |
48 |
import java.util.HashSet; |
48 |
import java.util.Map; |
49 |
import java.util.List; |
49 |
import java.util.Set; |
50 |
import java.util.Set; |
|
|
51 |
import javax.swing.ListSelectionModel; |
52 |
import javax.swing.event.ListSelectionEvent; |
53 |
import javax.swing.event.ListSelectionListener; |
54 |
import javax.swing.table.AbstractTableModel; |
50 |
import org.netbeans.api.autoupdate.UpdateElement; |
55 |
import org.netbeans.api.autoupdate.UpdateElement; |
51 |
import org.openide.util.NbBundle; |
56 |
import org.openide.util.NbBundle; |
52 |
|
57 |
|
Lines 56-62
Link Here
|
56 |
*/ |
61 |
*/ |
57 |
public class LicenseApprovalPanel extends javax.swing.JPanel { |
62 |
public class LicenseApprovalPanel extends javax.swing.JPanel { |
58 |
public static final String LICENSE_APPROVED = "license-approved"; |
63 |
public static final String LICENSE_APPROVED = "license-approved"; |
59 |
private Map<String, Set<String>> license4plugins; |
64 |
private List<UpdateElement> license4plugins; |
60 |
|
65 |
|
61 |
/** Creates new form LicenseApprovalPanel */ |
66 |
/** Creates new form LicenseApprovalPanel */ |
62 |
public LicenseApprovalPanel (InstallUnitWizardModel model, boolean isApproved) { |
67 |
public LicenseApprovalPanel (InstallUnitWizardModel model, boolean isApproved) { |
Lines 75-99
Link Here
|
75 |
if (license4plugins == null && license4plugins.isEmpty ()) { |
80 |
if (license4plugins == null && license4plugins.isEmpty ()) { |
76 |
return Collections.emptyList (); |
81 |
return Collections.emptyList (); |
77 |
} |
82 |
} |
78 |
return license4plugins.keySet (); |
83 |
Set<String> licenses = new HashSet<String>(); |
|
|
84 |
for (UpdateElement el : license4plugins) { |
85 |
licenses.add(el.getLicence()); |
86 |
} |
87 |
return licenses; |
79 |
} |
88 |
} |
80 |
|
89 |
|
81 |
private void goOverLicenses (InstallUnitWizardModel model) { |
90 |
private void goOverLicenses (InstallUnitWizardModel model) { |
82 |
for (UpdateElement el : model.getAllUpdateElements ()) { |
91 |
for (UpdateElement el : model.getAllUpdateElements ()) { |
83 |
if (el.getLicence () != null) { |
92 |
if (el.getLicence() != null) { |
84 |
if (license4plugins == null) { |
93 |
if (license4plugins == null) { |
85 |
license4plugins = new HashMap<String, Set<String>> (); |
94 |
license4plugins = new ArrayList<UpdateElement> (); |
86 |
} |
95 |
} |
87 |
if (license4plugins.containsKey (el.getLicence ())) { |
96 |
|
88 |
// add plugin |
97 |
license4plugins.add(el); |
89 |
license4plugins.get (el.getLicence ()).add (el.getDisplayName ()); |
|
|
90 |
} else { |
91 |
// license |
92 |
Set<String> plugins = new HashSet<String> (); |
93 |
plugins.add (el.getDisplayName ()); |
94 |
license4plugins.put (el.getLicence (), plugins); |
95 |
} |
96 |
//licenses.put (el.getDisplayName (), el.getLicence ()); |
97 |
} |
98 |
} |
98 |
} |
99 |
} |
99 |
} |
100 |
} |
Lines 111-119
Link Here
|
111 |
private void initComponents() { |
112 |
private void initComponents() { |
112 |
|
113 |
|
113 |
taTitle = new javax.swing.JTextArea(); |
114 |
taTitle = new javax.swing.JTextArea(); |
114 |
spLicenses = new javax.swing.JScrollPane(); |
115 |
cbAccept = new javax.swing.JCheckBox(); |
|
|
116 |
spPanel = new javax.swing.JSplitPane(); |
117 |
spLicense = new javax.swing.JScrollPane(); |
115 |
taLicenses = new javax.swing.JTextArea(); |
118 |
taLicenses = new javax.swing.JTextArea(); |
116 |
cbAccept = new javax.swing.JCheckBox(); |
119 |
spPluginInfo = new javax.swing.JScrollPane(); |
|
|
120 |
tblPluginList = new javax.swing.JTable(); |
117 |
|
121 |
|
118 |
taTitle.setEditable(false); |
122 |
taTitle.setEditable(false); |
119 |
taTitle.setLineWrap(true); |
123 |
taTitle.setLineWrap(true); |
Lines 122-137
Link Here
|
122 |
taTitle.setMargin(new java.awt.Insets(0, 4, 0, 0)); |
126 |
taTitle.setMargin(new java.awt.Insets(0, 4, 0, 0)); |
123 |
taTitle.setOpaque(false); |
127 |
taTitle.setOpaque(false); |
124 |
|
128 |
|
125 |
taLicenses.setColumns(20); |
|
|
126 |
taLicenses.setEditable(false); |
127 |
taLicenses.setLineWrap(true); |
128 |
taLicenses.setRows(5); |
129 |
taLicenses.setWrapStyleWord(true); |
130 |
taLicenses.setMargin(new java.awt.Insets(0, 4, 0, 4)); |
131 |
spLicenses.setViewportView(taLicenses); |
132 |
taLicenses.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(LicenseApprovalPanel.class, "LicenseApprovalPanel_taLicenses_ACN")); // NOI18N |
133 |
taLicenses.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(LicenseApprovalPanel.class, "LicenseApprovalPanel_taLicenses_ACD")); // NOI18N |
134 |
|
135 |
org.openide.awt.Mnemonics.setLocalizedText(cbAccept, org.openide.util.NbBundle.getMessage(LicenseApprovalPanel.class, "LicenseApprovalPanel.cbAccept.text")); // NOI18N |
129 |
org.openide.awt.Mnemonics.setLocalizedText(cbAccept, org.openide.util.NbBundle.getMessage(LicenseApprovalPanel.class, "LicenseApprovalPanel.cbAccept.text")); // NOI18N |
136 |
cbAccept.addActionListener(new java.awt.event.ActionListener() { |
130 |
cbAccept.addActionListener(new java.awt.event.ActionListener() { |
137 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
131 |
public void actionPerformed(java.awt.event.ActionEvent evt) { |
Lines 139-154
Link Here
|
139 |
} |
133 |
} |
140 |
}); |
134 |
}); |
141 |
|
135 |
|
|
|
136 |
spPanel.setDividerLocation(250); |
137 |
|
138 |
taLicenses.setColumns(20); |
139 |
taLicenses.setEditable(false); |
140 |
taLicenses.setLineWrap(true); |
141 |
taLicenses.setRows(5); |
142 |
taLicenses.setWrapStyleWord(true); |
143 |
taLicenses.setMargin(new java.awt.Insets(0, 4, 0, 4)); |
144 |
spLicense.setViewportView(taLicenses); |
145 |
taLicenses.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(LicenseApprovalPanel.class, "LicenseApprovalPanel_taLicenses_ACN")); // NOI18N |
146 |
taLicenses.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(LicenseApprovalPanel.class, "LicenseApprovalPanel_taLicenses_ACD")); // NOI18N |
147 |
|
148 |
spPanel.setRightComponent(spLicense); |
149 |
|
150 |
tblPluginList.setModel(new javax.swing.table.DefaultTableModel( |
151 |
new Object [][] { |
152 |
|
153 |
}, |
154 |
new String [] { |
155 |
|
156 |
} |
157 |
)); |
158 |
spPluginInfo.setViewportView(tblPluginList); |
159 |
|
160 |
spPanel.setLeftComponent(spPluginInfo); |
161 |
|
142 |
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); |
162 |
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); |
143 |
this.setLayout(layout); |
163 |
this.setLayout(layout); |
144 |
layout.setHorizontalGroup( |
164 |
layout.setHorizontalGroup( |
145 |
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
165 |
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
146 |
.add(layout.createSequentialGroup() |
166 |
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() |
147 |
.addContainerGap() |
167 |
.addContainerGap() |
148 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) |
168 |
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) |
149 |
.add(cbAccept) |
169 |
.add(org.jdesktop.layout.GroupLayout.LEADING, spPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 509, Short.MAX_VALUE) |
150 |
.add(org.jdesktop.layout.GroupLayout.TRAILING, taTitle, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 461, Short.MAX_VALUE) |
170 |
.add(org.jdesktop.layout.GroupLayout.LEADING, cbAccept) |
151 |
.add(spLicenses, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 461, Short.MAX_VALUE)) |
171 |
.add(taTitle)) |
152 |
.addContainerGap()) |
172 |
.addContainerGap()) |
153 |
); |
173 |
); |
154 |
layout.setVerticalGroup( |
174 |
layout.setVerticalGroup( |
Lines 156-162
Link Here
|
156 |
.add(layout.createSequentialGroup() |
176 |
.add(layout.createSequentialGroup() |
157 |
.add(taTitle, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 45, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
177 |
.add(taTitle, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 45, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) |
158 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
178 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
159 |
.add(spLicenses) |
179 |
.add(spPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 147, Short.MAX_VALUE) |
160 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
180 |
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) |
161 |
.add(cbAccept) |
181 |
.add(cbAccept) |
162 |
.addContainerGap()) |
182 |
.addContainerGap()) |
Lines 165-197
Link Here
|
165 |
cbAccept.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(LicenseApprovalPanel.class, "LicenseApprovalPanel_cbAccept_ACN")); // NOI18N |
185 |
cbAccept.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(LicenseApprovalPanel.class, "LicenseApprovalPanel_cbAccept_ACN")); // NOI18N |
166 |
}// </editor-fold>//GEN-END:initComponents |
186 |
}// </editor-fold>//GEN-END:initComponents |
167 |
|
187 |
|
168 |
private void cbAcceptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbAcceptActionPerformed |
188 |
private void cbAcceptActionPerformed(ActionEvent evt) {//GEN-FIRST:event_cbAcceptActionPerformed |
169 |
firePropertyChange (LICENSE_APPROVED, null, cbAccept.isSelected ()); |
189 |
firePropertyChange (LICENSE_APPROVED, null, cbAccept.isSelected ()); |
170 |
}//GEN-LAST:event_cbAcceptActionPerformed |
190 |
}//GEN-LAST:event_cbAcceptActionPerformed |
171 |
|
191 |
|
172 |
|
|
|
173 |
// Variables declaration - do not modify//GEN-BEGIN:variables |
192 |
// Variables declaration - do not modify//GEN-BEGIN:variables |
174 |
private javax.swing.JCheckBox cbAccept; |
193 |
private javax.swing.JCheckBox cbAccept; |
175 |
private javax.swing.JScrollPane spLicenses; |
194 |
private javax.swing.JScrollPane spLicense; |
|
|
195 |
private javax.swing.JSplitPane spPanel; |
196 |
private javax.swing.JScrollPane spPluginInfo; |
176 |
private javax.swing.JTextArea taLicenses; |
197 |
private javax.swing.JTextArea taLicenses; |
177 |
private javax.swing.JTextArea taTitle; |
198 |
private javax.swing.JTextArea taTitle; |
|
|
199 |
private javax.swing.JTable tblPluginList; |
178 |
// End of variables declaration//GEN-END:variables |
200 |
// End of variables declaration//GEN-END:variables |
179 |
|
201 |
|
180 |
private void writeLicenses (InstallUnitWizardModel model) { |
202 |
private void writeLicenses (InstallUnitWizardModel model) { |
181 |
goOverLicenses (model); |
203 |
goOverLicenses (model); |
182 |
StringBuffer content = new StringBuffer (); |
204 |
tblPluginList.setModel(new AbstractTableModel() { |
183 |
for (String lic : license4plugins.keySet ()) { |
205 |
|
184 |
StringBuffer title = new StringBuffer (); |
206 |
private String[] COLUMN_NAME_PROPERTIES = { |
185 |
for (String plugin : license4plugins.get (lic)) { |
207 |
"LicenseApprovalPanel_tblPluginList_ColumnName_Name", // NOI18N |
186 |
title.append ((title.length () == 0 ? "" : |
208 |
"LicenseApprovalPanel_tblPluginList_ColumnName_Version" // NOI18N |
187 |
NbBundle.getMessage (LicenseApprovalPanel.class, "LicenseApprovalPanel_tpLicense_Delimeter")) + plugin); // NOI18N |
209 |
}; |
188 |
} |
210 |
|
189 |
content.append (NbBundle.getMessage (LicenseApprovalPanel.class, "LicenseApprovalPanel_tpLicense_Head", title)); // NOI18N |
211 |
@Override |
190 |
content.append ("\n"); // NOI18N |
212 |
public Class<?> getColumnClass(int columnIndex) { |
191 |
content.append (lic); |
213 |
return String.class; |
192 |
content.append (NbBundle.getMessage (LicenseApprovalPanel.class, "LicenseApprovalPanel_tpLicense_Separator")); // NOI18N |
214 |
} |
193 |
} |
215 |
|
194 |
taLicenses.setText (content.toString ()); |
216 |
@Override |
195 |
taLicenses.setCaretPosition (0); |
217 |
public String getColumnName(int column) { |
|
|
218 |
return NbBundle.getMessage(LicenseApprovalPanel.class, |
219 |
COLUMN_NAME_PROPERTIES[column]); |
220 |
} |
221 |
|
222 |
public int getRowCount() { |
223 |
return license4plugins.size(); |
224 |
} |
225 |
|
226 |
public int getColumnCount() { |
227 |
return COLUMN_NAME_PROPERTIES.length; |
228 |
} |
229 |
|
230 |
public Object getValueAt(int rowIndex, int columnIndex) { |
231 |
UpdateElement el = license4plugins.get(rowIndex); |
232 |
switch(columnIndex) { |
233 |
case 0: |
234 |
return el.getDisplayName(); |
235 |
|
236 |
case 1: |
237 |
return el.getSpecificationVersion(); |
238 |
|
239 |
default: |
240 |
return ""; |
241 |
} |
242 |
} |
243 |
|
244 |
}); |
245 |
|
246 |
ListSelectionModel selectionModel = tblPluginList.getSelectionModel(); |
247 |
selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
248 |
selectionModel.addListSelectionListener(new ListSelectionListener() { |
249 |
|
250 |
public void valueChanged(ListSelectionEvent e) { |
251 |
if (!e.getValueIsAdjusting()) { |
252 |
String license = getLicense4Plugin(tblPluginList.getSelectedRow()); |
253 |
taLicenses.setText(license); |
254 |
taLicenses.setCaretPosition(0); |
255 |
} |
256 |
} |
257 |
|
258 |
}); |
259 |
|
260 |
selectionModel.addSelectionInterval(0, 0); |
196 |
} |
261 |
} |
|
|
262 |
|
263 |
private String getLicense4Plugin(int selectedIndex) { |
264 |
UpdateElement el = license4plugins.get(selectedIndex); |
265 |
return el.getLicence(); |
266 |
} |
267 |
|
197 |
} |
268 |
} |