#172599 Use JTable and JTextArea mixed together to improve license display.
diff --git a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/Bundle.properties b/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/Bundle.properties
--- a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/Bundle.properties
+++ b/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/Bundle.properties
@@ -24,6 +24,8 @@
LicenseApprovalPanel_tpLicense_Separator=_______________________________________\n
LicenseApprovalPanel_Header_Head=License Agreement
LicenseApprovalPanel_Header_Content=Please read all of the following license agreements carefully.
+LicenseApprovalPanel_tblPluginList_ColumnName_Name=Name
+LicenseApprovalPanel_tblPluginList_ColumnName_Version=Version
InstallUnitWizard_Title=Plugin Installer
InstallStep_Header_Download_Head=Download
InstallStep_Header_Download_Content=Please wait until the installer downloads the requested plugins.
diff --git a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/InstallUnitWizard.java b/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/InstallUnitWizard.java
--- a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/InstallUnitWizard.java
+++ b/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/InstallUnitWizard.java
@@ -43,6 +43,8 @@
import org.netbeans.modules.autoupdate.ui.*;
import java.awt.Dialog;
+import java.awt.Dimension;
+import java.awt.Image;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.logging.Level;
@@ -51,6 +53,7 @@
import org.netbeans.modules.autoupdate.ui.wizards.OperationWizardModel.OperationType;
import org.openide.DialogDisplayer;
import org.openide.WizardDescriptor;
+import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;
/**
diff --git a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/LicenseApprovalPanel.form b/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/LicenseApprovalPanel.form
--- a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/LicenseApprovalPanel.form
+++ b/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/LicenseApprovalPanel.form
@@ -1,9 +1,13 @@
diff --git a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/LicenseApprovalPanel.java b/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/LicenseApprovalPanel.java
--- a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/LicenseApprovalPanel.java
+++ b/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/LicenseApprovalPanel.java
@@ -41,12 +41,17 @@
package org.netbeans.modules.autoupdate.ui.wizards;
+import java.awt.event.ActionEvent;
+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.ListSelectionModel;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.table.AbstractTableModel;
import org.netbeans.api.autoupdate.UpdateElement;
import org.openide.util.NbBundle;
@@ -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) {
@@ -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 (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,12 @@
private void initComponents() {
taTitle = new javax.swing.JTextArea();
- spLicenses = new javax.swing.JScrollPane();
+ cbAccept = new javax.swing.JCheckBox();
+ spPanel = new javax.swing.JSplitPane();
+ spLicense = new javax.swing.JScrollPane();
taLicenses = new javax.swing.JTextArea();
- cbAccept = new javax.swing.JCheckBox();
+ spPluginInfo = new javax.swing.JScrollPane();
+ tblPluginList = new javax.swing.JTable();
taTitle.setEditable(false);
taTitle.setLineWrap(true);
@@ -122,16 +126,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,16 +133,42 @@
}
});
+ spPanel.setDividerLocation(250);
+
+ 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));
+ spLicense.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
+
+ spPanel.setRightComponent(spLicense);
+
+ tblPluginList.setModel(new javax.swing.table.DefaultTableModel(
+ new Object [][] {
+
+ },
+ new String [] {
+
+ }
+ ));
+ spPluginInfo.setViewportView(tblPluginList);
+
+ spPanel.setLeftComponent(spPluginInfo);
+
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(layout.createSequentialGroup()
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, 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))
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, spPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 509, Short.MAX_VALUE)
+ .add(org.jdesktop.layout.GroupLayout.LEADING, cbAccept)
+ .add(taTitle))
.addContainerGap())
);
layout.setVerticalGroup(
@@ -156,7 +176,7 @@
.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(spPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 147, Short.MAX_VALUE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(cbAccept)
.addContainerGap())
@@ -165,33 +185,84 @@
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
-
-
+
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JCheckBox cbAccept;
- private javax.swing.JScrollPane spLicenses;
+ private javax.swing.JScrollPane spLicense;
+ private javax.swing.JSplitPane spPanel;
+ private javax.swing.JScrollPane spPluginInfo;
private javax.swing.JTextArea taLicenses;
private javax.swing.JTextArea taTitle;
+ private javax.swing.JTable tblPluginList;
// 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);
+ tblPluginList.setModel(new AbstractTableModel() {
+
+ private String[] COLUMN_NAME_PROPERTIES = {
+ "LicenseApprovalPanel_tblPluginList_ColumnName_Name", // NOI18N
+ "LicenseApprovalPanel_tblPluginList_ColumnName_Version" // NOI18N
+ };
+
+ @Override
+ public Class> getColumnClass(int columnIndex) {
+ return String.class;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ return NbBundle.getMessage(LicenseApprovalPanel.class,
+ COLUMN_NAME_PROPERTIES[column]);
+ }
+
+ public int getRowCount() {
+ return license4plugins.size();
+ }
+
+ public int getColumnCount() {
+ return COLUMN_NAME_PROPERTIES.length;
+ }
+
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ UpdateElement el = license4plugins.get(rowIndex);
+ switch(columnIndex) {
+ case 0:
+ return el.getDisplayName();
+
+ case 1:
+ return el.getSpecificationVersion();
+
+ default:
+ return "";
+ }
+ }
+
+ });
+
+ ListSelectionModel selectionModel = tblPluginList.getSelectionModel();
+ selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ selectionModel.addListSelectionListener(new ListSelectionListener() {
+
+ public void valueChanged(ListSelectionEvent e) {
+ if (!e.getValueIsAdjusting()) {
+ String license = getLicense4Plugin(tblPluginList.getSelectedRow());
+ taLicenses.setText(license);
+ taLicenses.setCaretPosition(0);
+ }
+ }
+
+ });
+
+ selectionModel.addSelectionInterval(0, 0);
}
+
+ private String getLicense4Plugin(int selectedIndex) {
+ UpdateElement el = license4plugins.get(selectedIndex);
+ return el.getLicence();
+ }
+
}