|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.autoupdate; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeEvent; import java.util.Collection; import java.util.Iterator; import java.util.HashMap; import java.util.Enumeration; import java.util.List; import java.util.ArrayList; import java.text.MessageFormat; import java.awt.event.*; import java.util.Date; import javax.swing.DefaultListModel; import javax.swing.SwingUtilities; import javax.swing.event.ListSelectionListener; import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; import org.openide.awt.HtmlBrowser; import org.openide.nodes.Children; import org.openide.nodes.Node; import org.openide.explorer.ExplorerPanel; import org.openide.explorer.ExplorerManager; import org.openide.explorer.view.BeanTreeView; import org.openide.modules.SpecificationVersion; import org.openide.util.NbBundle; class UpdatePanel extends javax.swing.JPanel { private static final String EMPTY_STRING = ""; // NOI18N private static final java.awt.Dimension PREFERRED_SIZE = new java.awt.Dimension( 600, 500 ); private static final String SPACE = " "; //NOI18N /** Explorer tree */ private ExplorerView explorerView; /** List model for listBox with selected modules */ private DefaultListModel selectedListModel; /** Summation of lengths of all selected modules */ private long totalSize; /** The collection of module updates */ private Updates updates; private Wizard.Validator validator; private UpdateNode.AllServers allNodes; private int duplicateStatus = 0; private PropertyChangeListener nodeListener; static final long serialVersionUID =897622109141801200L; static final String LINE_SEPARATOR = "\n"; //NOI18N /** * Creates new form UpdatePanel * @param validator controls if next button should be enabled or disbled */ public UpdatePanel( Wizard.Validator validator ) { putClientProperty("WizardPanel_autoWizardStyle", Boolean.TRUE); // NOI18N putClientProperty("WizardPanel_contentDisplayed", Boolean.TRUE); // NOI18N putClientProperty("WizardPanel_contentNumbered", Boolean.TRUE); // NOI18N putClientProperty("WizardPanel_contentSelectedIndex", new Integer(1)); // NOI18N putClientProperty("WizardPanel_contentData", new String[] { // NOI18N getBundle("WIZ_First"), getBundle("WIZ_Select"), getBundle("WIZ_Download"), getBundle("WIZ_View") }); initComponents(); setName(getBundle("LAB_Select2")); this.validator = validator; // Add Explorer view explorerView = new ExplorerView(); SwingUtilities.invokeLater (new Runnable () { public void run () { explorerView.requestFocus (); } }); explorerView.getExplorerManager().addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange( PropertyChangeEvent evt ) { if ( evt.getPropertyName() == ExplorerManager.PROP_SELECTED_NODES ) { selectionChange( true ); } } } ); jList1.addFocusListener( new FocusListener() { public void focusGained( FocusEvent evt ) { unselectLeft(); if ( jList1.getSelectedIndex() == -1 && selectedListModel.getSize() > 0 ) jList1.setSelectedIndex( 0 ); } public void focusLost( FocusEvent evt ) { } } ); java.awt.GridBagConstraints gridBagConstraints1 = new java.awt.GridBagConstraints (); gridBagConstraints1.gridwidth = 0; gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints1.weightx = 1.0; gridBagConstraints1.weighty = 1.0; gridBagConstraints1.insets = new java.awt.Insets (0, 3, 0, 3); jPanel1.add (explorerView, gridBagConstraints1); // Customize jList1 jList1.setCellRenderer( new SelectedListCellRenderer() ); selectedListModel = new DefaultListModel(); jList1.setModel( selectedListModel ); jList1.getSelectionModel().setSelectionMode( javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION ); jList1.getSelectionModel().addListSelectionListener( new ListSelectionListener() { public void valueChanged( javax.swing.event.ListSelectionEvent evt ) { selectionChange( false ); } } ); panel1Label.setLabelFor(explorerView); panel1Label.setDisplayedMnemonic(getBundle("LAB_221_Mnemonic").charAt(0)); scrollpaneLabel.setDisplayedMnemonic(getBundle("LAB_222_Mnemonic").charAt(0)); totalsizeLabel.setDisplayedMnemonic(getBundle("LAB_223_Mnemonic").charAt(0)); avLabel.setDisplayedMnemonic(getBundle("LAB_224_Mnemonic").charAt(0)); ivLabel.setDisplayedMnemonic(getBundle("LAB_225_Mnemonic").charAt(0)); getAccessibleContext().setAccessibleName(getBundle("ACS_UpdatePanel")); getAccessibleContext().setAccessibleDescription(getBundle("ACSD_UpdatePanel") + getBundle("LAB_227")); moreButton.getAccessibleContext().setAccessibleDescription(getBundle("ACS_More")); jList1.getAccessibleContext().setAccessibleDescription(getBundle("ACS_InstallList")); SwingUtilities.invokeLater (new Runnable () { public void run () { explorerView.setName (getBundle ("ACSN_ExplorerView")); explorerView.getAccessibleContext ().setAccessibleDescription (getBundle ("ACS_ExplorerView")); } }); } /** Returns preferred size of the panel */ public java.awt.Dimension getPreferredSize() { return PREFERRED_SIZE; } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ private void initComponents() {//GEN-BEGIN:initComponents java.awt.GridBagConstraints gridBagConstraints; panel1Label = new javax.swing.JLabel(); jPanel1 = new javax.swing.JPanel(); addButton = new javax.swing.JButton(); removeButton = new javax.swing.JButton(); addallButton = new javax.swing.JButton(); removeallButton = new javax.swing.JButton(); scrollpaneLabel = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jList1 = new javax.swing.JList(); jPanel3 = new javax.swing.JPanel(); totalsizeLabel = new javax.swing.JLabel(); totalsizeTextField = new javax.swing.JTextField(); jPanel2 = new javax.swing.JPanel(); avLabel = new javax.swing.JLabel(); avTextField = new javax.swing.JTextField(); ivLabel = new javax.swing.JLabel(); ivTextField = new javax.swing.JTextField(); jScrollPane2 = new javax.swing.JScrollPane(); jTextArea1 = new javax.swing.JTextArea(); moreButton = new javax.swing.JButton(); setLayout(new java.awt.GridBagLayout()); panel1Label.setText(getBundle("LAB_221")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; add(panel1Label, gridBagConstraints); jPanel1.setLayout(new java.awt.GridBagLayout()); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = 2; gridBagConstraints.gridheight = 5; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0); add(jPanel1, gridBagConstraints); addButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/autoupdate/resources/add.gif"))); addButton.setToolTipText(getBundle("HINT_Add")); addButton.setMnemonic(getBundle("BTN_221_Mnem").charAt(0)); addButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 1; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(2, 12, 0, 12); add(addButton, gridBagConstraints); removeButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/autoupdate/resources/rm.gif"))); removeButton.setToolTipText(getBundle("HINT_Remove")); removeButton.setMnemonic(getBundle("BTN_222_Mnem").charAt(0)); removeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { removeButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(6, 12, 0, 12); add(removeButton, gridBagConstraints); addallButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/autoupdate/resources/add_all.gif"))); addallButton.setToolTipText(getBundle("HINT_AddAll")); addallButton.setMnemonic(getBundle("BTN_223_Mnem").charAt(0)); addallButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { addallButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 3; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(6, 12, 0, 12); add(addallButton, gridBagConstraints); removeallButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/autoupdate/resources/rm_all.gif"))); removeallButton.setToolTipText(getBundle("HINT_RemoveAll")); removeallButton.setMnemonic(getBundle("BTN_224_Mnem").charAt(0)); removeallButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { removeallButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 4; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(6, 12, 0, 12); add(removeallButton, gridBagConstraints); scrollpaneLabel.setLabelFor(jList1); scrollpaneLabel.setText(getBundle("LAB_222")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 0; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12); add(scrollpaneLabel, gridBagConstraints); jList1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jList1MouseClicked(evt); } }); jScrollPane1.setViewportView(jList1); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = 3; gridBagConstraints.gridheight = 5; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0); add(jScrollPane1, gridBagConstraints); jPanel3.setLayout(new java.awt.GridLayout(1, 2, 6, 0)); totalsizeLabel.setLabelFor(totalsizeTextField); totalsizeLabel.setText(getBundle("LAB_223")); totalsizeLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); jPanel3.add(totalsizeLabel); totalsizeTextField.setEditable(false); totalsizeTextField.setDisabledTextColor(java.awt.Color.black); totalsizeTextField.setMinimumSize(new java.awt.Dimension(6, 20)); totalsizeTextField.setEnabled(false); jPanel3.add(totalsizeTextField); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 3; gridBagConstraints.gridy = 6; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0); add(jPanel3, gridBagConstraints); jPanel2.setLayout(new java.awt.GridBagLayout()); jPanel2.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.TitledBorder(""))); avLabel.setLabelFor(avTextField); avLabel.setText(getBundle("LAB_224")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0); jPanel2.add(avLabel, gridBagConstraints); avTextField.setEditable(false); avTextField.setDisabledTextColor(java.awt.Color.black); avTextField.setMinimumSize(new java.awt.Dimension(60, 21)); avTextField.setPreferredSize(new java.awt.Dimension(60, 21)); avTextField.setEnabled(false); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipadx = 60; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0); jPanel2.add(avTextField, gridBagConstraints); ivLabel.setLabelFor(ivTextField); ivLabel.setText(getBundle("LAB_225")); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; gridBagConstraints.insets = new java.awt.Insets(0, 12, 0, 0); jPanel2.add(ivLabel, gridBagConstraints); ivTextField.setEditable(false); ivTextField.setDisabledTextColor(java.awt.Color.black); ivTextField.setMinimumSize(new java.awt.Dimension(60, 21)); ivTextField.setPreferredSize(new java.awt.Dimension(63, 21)); ivTextField.setEnabled(false); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipadx = 60; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.weightx = 1.0; gridBagConstraints.insets = new java.awt.Insets(0, 6, 0, 0); jPanel2.add(ivTextField, gridBagConstraints); jScrollPane2.setMinimumSize(new java.awt.Dimension(22, 52)); jTextArea1.setEditable(false); jTextArea1.setLineWrap(true); jTextArea1.setRows(4); jTextArea1.setWrapStyleWord(true); jTextArea1.setDisabledTextColor(java.awt.Color.black); jTextArea1.setEnabled(false); jScrollPane2.setViewportView(jTextArea1); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = 5; gridBagConstraints.gridheight = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.insets = new java.awt.Insets(6, 6, 0, 0); gridBagConstraints.weightx = 1.0; gridBagConstraints.weighty = 1.0; jPanel2.add(jScrollPane2, gridBagConstraints); moreButton.setMnemonic(getBundle("BTN_More_Mnem").charAt(0)); moreButton.setText(getBundle("BTN_More")); moreButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); moreButton.setIconTextGap(0); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 5; gridBagConstraints.gridy = 2; gridBagConstraints.insets = new java.awt.Insets(6, 11, 0, 0); gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; jPanel2.add(moreButton, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 7; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0); gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; gridBagConstraints.weighty = 1.0; add(jPanel2, gridBagConstraints); }//GEN-END:initComponents private void removeallButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeallButtonActionPerformed for( int i = 0; i < selectedListModel.size(); i++ ) { ((ModuleUpdate)selectedListModel.get(i)).setSelected( false ); ((ModuleUpdate)selectedListModel.get(i)).setDownloadOK( false ); ((ModuleUpdate)selectedListModel.get(i)).setSecurity( SignVerifier.NOT_CHECKED ); } refreshNodes(); selectedListModel.clear(); Downloader.deleteDownload(); showSize(); validator.setValid( selectedListModel.size() > 0 ); buttonsCheck(); }//GEN-LAST:event_removeallButtonActionPerformed private void addallButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addallButtonActionPerformed Collection modules = Wizard.getAllModules(); Iterator it = modules.iterator(); while ( it.hasNext() ) { if ( !addModule( (ModuleUpdate)it.next() ) ) { // Some licence rejected removeallButtonActionPerformed(evt); return; } } buttonsCheck(); }//GEN-LAST:event_addallButtonActionPerformed private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed int[] index = jList1.getSelectedIndices(); if ( index.length == 0 ) return; java.util.List toremove = new ArrayList(); for (int i = index.length -1; i >= 0 ; i-- ) toremove.add( selectedListModel.get( index[i] )); Iterator it = toremove.iterator(); while (it.hasNext()) removeModule( (ModuleUpdate)it.next() ); refreshNodes(); showSize(); validator.setValid( selectedListModel.size() > 0 ); buttonsCheck(); }//GEN-LAST:event_removeButtonActionPerformed private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed Node[] nodes = explorerView.getSelectedNodes(); List modulesToAdd = new ArrayList(); ModuleUpdate mu = null; for ( int i = 0; i < nodes.length; i ++ ) { mu = (ModuleUpdate)nodes[i].getCookie( ModuleUpdate.class ); if ( mu != null ) { modulesToAdd.add( mu ); } else { // Add whole group - subtree modulesToAdd.addAll( getUnselectedChildren( nodes[i] ) ); } } Iterator iter = modulesToAdd.iterator(); while ( iter.hasNext() ) { mu = (ModuleUpdate)iter.next(); if ( !addModule( mu , modulesToAdd ) ) { return; } } buttonsCheck(); }//GEN-LAST:event_addButtonActionPerformed private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked if ( evt.getClickCount() == 2 ) { int index = jList1.locationToIndex( evt.getPoint() ); if ( index >= 0 && index < selectedListModel.size() ) { removeModule( (ModuleUpdate)selectedListModel.get( index ) ); showSize(); validator.setValid( selectedListModel.size() > 0 ); refreshNodes(); } buttonsCheck(); } }//GEN-LAST:event_jList1MouseClicked // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton addButton; private javax.swing.JButton addallButton; private javax.swing.JLabel avLabel; private javax.swing.JTextField avTextField; private javax.swing.JLabel ivLabel; private javax.swing.JTextField ivTextField; private javax.swing.JList jList1; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JTextArea jTextArea1; private javax.swing.JButton moreButton; private javax.swing.JLabel panel1Label; private javax.swing.JButton removeButton; private javax.swing.JButton removeallButton; private javax.swing.JLabel scrollpaneLabel; private javax.swing.JLabel totalsizeLabel; private javax.swing.JTextField totalsizeTextField; // End of variables declaration//GEN-END:variables void setUpdates( int wizardType ) { boolean firstTime = true; allNodes = null; selectedListModel.clear(); totalSize = 0; Iterator it = Wizard.getAllModules().iterator(); while( it.hasNext() ) { ModuleUpdate mu = (ModuleUpdate)it.next(); if ( mu.isSelected() && ( !selectedListModel.contains( mu ) ) ) { selectedListModel.addElement( mu ); totalSize += mu.getDownloadSize(); } if ( firstTime ) if ( wizardType == 1 || mu.isPurchased() ) addModule( mu ); } validator.setValid( selectedListModel.size() > 0 ); totalsizeTextField.setText( ( totalSize / 1024 ) + SPACE + getBundle("CTL_UpdatePanel_KB") ); buttonsCheck(); showSize(); javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { refreshNodes(); } }); nodeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ( Settings.NODE_DEFAULT_ACTION.equals( evt.getPropertyName() )) { Node[] selectedNodes = explorerView.getSelectedNodes(); if ( selectedNodes.length == 1 ) { ModuleUpdate mu = (ModuleUpdate)selectedNodes[0].getCookie( ModuleUpdate.class ); if ( mu != null ) if ( ! addModule( mu ) ) buttonsCheck(); } } } }; Settings.getShared().addPropertyChangeListener( nodeListener ); } // INNERCLAS ------------------------------------------------------ static class ExplorerView extends ExplorerPanel { private ExplorerManager em; private BeanTreeView btv; static final long serialVersionUID =-5811911993587966912L; ExplorerView( ) { Node waitNode = new UpdateNode.Wait(); createContent( waitNode ); } private void createContent ( Node node ) { btv = new BeanTreeView (); btv.setPopupAllowed( false ); btv.setDefaultActionAllowed( true ); em = getExplorerManager (); //sp.add (new org.openide.explorer.view.ListView (), SplittedPanel.ADD_LEFT); setLayout (new java.awt.BorderLayout()); add ( java.awt.BorderLayout.CENTER, btv ); em.setRootContext ( node ); em.setExploredContext( node ); btv.setDefaultActionAllowed( true ); btv.setRootVisible( false ); } public java.awt.Dimension getPreferredSize () { java.awt.Dimension sup = super.getPreferredSize (); return new java.awt.Dimension ( Math.max (sup.width, 450), Math.max (sup.height, 300 )); } void expandAll() { expandChildren(getExplorerManager().getRootContext()); } private void expandChildren (Node n) { Node[] kids = n.getChildren().getNodes(); for (int i=0; i < kids.length; i++) { if (!kids[i].getDisplayName().startsWith("L10N")) { //NOI18N btv.expandNode(kids[i]); if (kids[i].getChildren() != Children.LEAF) { expandChildren(kids[i]); } } } } Node[] getSelectedNodes() { return em.getSelectedNodes(); } void setContext( Node node ) { em.setRootContext ( node ); em.setExploredContext( node ); } } private ModuleUpdate getSingleSelection() { if ( jList1.getSelectedIndex() >= 0 ) // modules from right panel return ((ModuleUpdate)selectedListModel.get(jList1.getSelectedIndex())); else { // modules from left panel Node[] selectedNodes = explorerView.getSelectedNodes(); if ( selectedNodes.length != 1 ) { return null; } else { return (ModuleUpdate)selectedNodes[0].getCookie( ModuleUpdate.class ); } } } private void unselectLeft() { try { explorerView.getExplorerManager().setSelectedNodes( new Node[0]); } catch (java.beans.PropertyVetoException e) { } } private String formatDescription (ModuleUpdate mu) { Date date = mu.getReleaseDate (); String release = date != null ? ModuleUpdate.DATE_FORMAT.format (date) : ""; // NOI18N String author = mu.getModuleAuthor () == null ? "" : mu.getModuleAuthor (); //NOI18N // Module size String desc = getBundle ("LAB_226") + SPACE + ( mu.getDownloadSize() / 1024 ) //NOI18N + SPACE + getBundle("CTL_UpdatePanel_KB") + LINE_SEPARATOR + //NOI18N // Author ((author.length () == 0) ? "" : getBundle ("LAB_AuthorName") + SPACE + author + LINE_SEPARATOR) + //NOI18N // Release Date ((release.length () == 0) ? "" : getBundle ("LAB_ReleaseDate") + SPACE + release + LINE_SEPARATOR) + //NOI18N // Description mu.getDescription (); return desc; } /** Called when the selection in jList1 or explorerView changes */ private void selectionChange( boolean onLeft ) { ModuleUpdate mu; if ( onLeft && explorerView.getSelectedNodes().length > 0) { jList1.clearSelection(); } mu = getSingleSelection(); if ( mu == null ) { ivTextField.setText( EMPTY_STRING ); avTextField.setText( EMPTY_STRING ); jTextArea1.setText( EMPTY_STRING ); } else { ivTextField.setText( mu.getLocalModule() == null ? getBundle( "CTL_UpdatePanel_ModuleNotInstalled" ) : (mu.getLocalModule().getSpecificationVersion() == null ? "" : mu.getLocalModule().getSpecificationVersion().toString())); SpecificationVersion sv = mu.getRemoteModule().getSpecificationVersion(); avTextField.setText( sv == null ? "" : sv.toString() ); jTextArea1.setText( formatDescription ( mu ) ); jTextArea1.setCaretPosition(0); } buttonsCheck(); } private void buttonsCheck() { if ( selectedListModel.getSize() > 0 ) { removeallButton.setEnabled(true); if ( jList1.getSelectedIndex() != -1 ) removeButton.setEnabled(true); else removeButton.setEnabled(false); } else { removeButton.setEnabled(false); removeallButton.setEnabled(false); } if ( existUnselectedModule() ) { addallButton.setEnabled(true); if ( isLeftSelection() ) addButton.setEnabled(true); else addButton.setEnabled(false); } else { addButton.setEnabled(false); addallButton.setEnabled(false); } ModuleUpdate mu = getSingleSelection(); moreButton.setEnabled(mu != null && mu.getHomePage() != null); } private boolean isLeftSelection() { // modules from left panel Node[] selectedNodes = explorerView.getSelectedNodes(); for (int i=0; i |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.