--- a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/Bundle.properties +++ a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/Bundle.properties @@ -24,6 +24,7 @@ LicenseApprovalPanel_tpLicense_Separator=_______________________________________\n LicenseApprovalPanel_Header_Head=License Agreement LicenseApprovalPanel_Header_Content=Please read all of the following license agreements carefully. +LicenseApprovalPanel_cbPlugins_ItemFormat={0} - {1} InstallUnitWizard_Title=Plugin Installer InstallStep_Header_Download_Head=Download InstallStep_Header_Download_Content=Please wait until the installer downloads the requested plugins. @@ -181,3 +182,4 @@ OperationDescriptionStep_AffectedPlugin=      {0}
InstallStep_DownloadProblem=There were some problems while storing {0}.\nCause: {1} InstallStep_DownloadProblem_SomePlugins=selected plugins +LicenseApprovalPanel.lbPlugins.text=Plugins: --- a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/LicenseApprovalPanel.form +++ a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/LicenseApprovalPanel.form @@ -4,6 +4,7 @@ + @@ -15,14 +16,26 @@ - - + + - - - + + + + + + + + + + + + + + + + - @@ -31,8 +44,13 @@ - - + + + + + + + @@ -54,14 +72,39 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -83,20 +126,15 @@ - + + + + - + - - - - - - - - --- a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/LicenseApprovalPanel.java +++ a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/LicenseApprovalPanel.java @@ -41,14 +41,19 @@ package org.netbeans.modules.autoupdate.ui.wizards; +import java.awt.event.ActionEvent; +import java.text.MessageFormat; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashMap; import java.util.HashSet; -import java.util.Map; +import java.util.List; import java.util.Set; +import javax.swing.DefaultComboBoxModel; +import javax.swing.SwingUtilities; import org.netbeans.api.autoupdate.UpdateElement; import org.openide.util.NbBundle; +import org.openide.util.RequestProcessor; /** * @@ -56,7 +61,7 @@ */ public class LicenseApprovalPanel extends javax.swing.JPanel { public static final String LICENSE_APPROVED = "license-approved"; - private Map> license4plugins; + private List license4plugins; /** Creates new form LicenseApprovalPanel */ public LicenseApprovalPanel (InstallUnitWizardModel model, boolean isApproved) { @@ -66,7 +71,7 @@ writeLicenses(model); } else { cbAccept.setEnabled (false); - taLicenses.setEnabled (false); + taLicense.setEnabled (false); } } @@ -75,25 +80,21 @@ if (license4plugins == null && license4plugins.isEmpty ()) { return Collections.emptyList (); } - return license4plugins.keySet (); - } - + Set licenses = new HashSet(); + for (UpdateElement el : license4plugins) { + licenses.add(el.getLicence()); + } + return licenses; + } + private void goOverLicenses (InstallUnitWizardModel model) { for (UpdateElement el : model.getAllUpdateElements ()) { if (el.getLicence () != null) { if (license4plugins == null) { - license4plugins = new HashMap> (); + license4plugins = new ArrayList (); } - if (license4plugins.containsKey (el.getLicence ())) { - // add plugin - license4plugins.get (el.getLicence ()).add (el.getDisplayName ()); - } else { - // license - Set plugins = new HashSet (); - plugins.add (el.getDisplayName ()); - license4plugins.put (el.getLicence (), plugins); - } - //licenses.put (el.getDisplayName (), el.getLicence ()); + + license4plugins.add(el); } } } @@ -111,9 +112,11 @@ private void initComponents() { taTitle = new javax.swing.JTextArea(); - spLicenses = new javax.swing.JScrollPane(); - taLicenses = new javax.swing.JTextArea(); cbAccept = new javax.swing.JCheckBox(); + cbPlugins = new javax.swing.JComboBox(); + spLicense = new javax.swing.JScrollPane(); + taLicense = new javax.swing.JTextArea(); + lbPlugins = new javax.swing.JLabel(); taTitle.setEditable(false); taTitle.setLineWrap(true); @@ -122,16 +125,6 @@ taTitle.setMargin(new java.awt.Insets(0, 4, 0, 0)); taTitle.setOpaque(false); - taLicenses.setColumns(20); - taLicenses.setEditable(false); - taLicenses.setLineWrap(true); - taLicenses.setRows(5); - taLicenses.setWrapStyleWord(true); - taLicenses.setMargin(new java.awt.Insets(0, 4, 0, 4)); - spLicenses.setViewportView(taLicenses); - taLicenses.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(LicenseApprovalPanel.class, "LicenseApprovalPanel_taLicenses_ACN")); // NOI18N - taLicenses.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(LicenseApprovalPanel.class, "LicenseApprovalPanel_taLicenses_ACD")); // NOI18N - org.openide.awt.Mnemonics.setLocalizedText(cbAccept, org.openide.util.NbBundle.getMessage(LicenseApprovalPanel.class, "LicenseApprovalPanel.cbAccept.text")); // NOI18N cbAccept.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -139,6 +132,25 @@ } }); + cbPlugins.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + cbPluginsActionPerformed(evt); + } + }); + + taLicense.setColumns(20); + taLicense.setEditable(false); + taLicense.setLineWrap(true); + taLicense.setRows(5); + taLicense.setWrapStyleWord(true); + taLicense.setMargin(new java.awt.Insets(0, 4, 0, 4)); + spLicense.setViewportView(taLicense); + taLicense.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(LicenseApprovalPanel.class, "LicenseApprovalPanel_taLicenses_ACN")); // NOI18N + taLicense.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(LicenseApprovalPanel.class, "LicenseApprovalPanel_taLicenses_ACD")); // NOI18N + + lbPlugins.setLabelFor(cbPlugins); + org.openide.awt.Mnemonics.setLocalizedText(lbPlugins, org.openide.util.NbBundle.getMessage(LicenseApprovalPanel.class, "LicenseApprovalPanel.lbPlugins.text")); // NOI18N + org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( @@ -146,18 +158,30 @@ .add(layout.createSequentialGroup() .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(cbAccept) - .add(org.jdesktop.layout.GroupLayout.TRAILING, taTitle, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 461, Short.MAX_VALUE) - .add(spLicenses, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 461, Short.MAX_VALUE)) - .addContainerGap()) + .add(taTitle) + .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) + .add(layout.createSequentialGroup() + .add(lbPlugins, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(cbPlugins, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 405, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(org.jdesktop.layout.GroupLayout.LEADING, cbAccept)) + .add(48, 48, 48)) + .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() + .add(spLicense, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 506, Short.MAX_VALUE) + .addContainerGap()))) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(taTitle, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 45, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(spLicenses) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(cbPlugins, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(lbPlugins)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(spLicense, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 127, Short.MAX_VALUE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(cbAccept) .addContainerGap()) ); @@ -165,33 +189,52 @@ cbAccept.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(LicenseApprovalPanel.class, "LicenseApprovalPanel_cbAccept_ACN")); // NOI18N }// //GEN-END:initComponents - private void cbAcceptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbAcceptActionPerformed + private void cbAcceptActionPerformed(ActionEvent evt) {//GEN-FIRST:event_cbAcceptActionPerformed firePropertyChange (LICENSE_APPROVED, null, cbAccept.isSelected ()); }//GEN-LAST:event_cbAcceptActionPerformed - - + + private void cbPluginsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbPluginsActionPerformed + // This is designed on purpose to make the user feel that + // license do refresh when new plugin is selected + taLicense.setText(""); + final int delay = 100; + RequestProcessor.getDefault().post(new Runnable() { + + public void run() { + SwingUtilities.invokeLater(new Runnable() { + + public void run() { + UpdateElement el = license4plugins.get(cbPlugins.getSelectedIndex()); + taLicense.setText(el.getLicence()); + taLicense.setCaretPosition(0); + } + }); + } + }, delay); + }//GEN-LAST:event_cbPluginsActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JCheckBox cbAccept; - private javax.swing.JScrollPane spLicenses; - private javax.swing.JTextArea taLicenses; + private javax.swing.JComboBox cbPlugins; + private javax.swing.JLabel lbPlugins; + private javax.swing.JScrollPane spLicense; + private javax.swing.JTextArea taLicense; private javax.swing.JTextArea taTitle; // End of variables declaration//GEN-END:variables - - private void writeLicenses (InstallUnitWizardModel model) { - goOverLicenses (model); - StringBuffer content = new StringBuffer (); - for (String lic : license4plugins.keySet ()) { - StringBuffer title = new StringBuffer (); - for (String plugin : license4plugins.get (lic)) { - title.append ((title.length () == 0 ? "" : - NbBundle.getMessage (LicenseApprovalPanel.class, "LicenseApprovalPanel_tpLicense_Delimeter")) + plugin); // NOI18N - } - content.append (NbBundle.getMessage (LicenseApprovalPanel.class, "LicenseApprovalPanel_tpLicense_Head", title)); // NOI18N - content.append ("\n"); // NOI18N - content.append (lic); - content.append (NbBundle.getMessage (LicenseApprovalPanel.class, "LicenseApprovalPanel_tpLicense_Separator")); // NOI18N - } - taLicenses.setText (content.toString ()); - taLicenses.setCaretPosition (0); - } + + private void writeLicenses(InstallUnitWizardModel model) { + goOverLicenses(model); + List pluginsModel = new ArrayList(); + String fmt = NbBundle.getMessage(LicenseApprovalPanel.class, + "LicenseApprovalPanel_cbPlugins_ItemFormat"); + for (UpdateElement el : license4plugins) { + String formatted = MessageFormat.format(fmt, + new Object[]{el.getDisplayName(), el.getSpecificationVersion()}); + pluginsModel.add(formatted); + } + + cbPlugins.setModel(new DefaultComboBoxModel(pluginsModel.toArray())); + cbPlugins.setSelectedIndex(0); + } + }