#158464: Wrong extending java.awt.Component by impl of WD.Panel
authorJiri Rechtacek <jrechtacek@netbeans.org>
Thu, 12 Feb 2009 17:44:11 +0100
changeset 4144cbd0f239b27f
parent 4143 251f2cf6f188
child 4145 c65ccc8f1915
#158464: Wrong extending java.awt.Component by impl of WD.Panel
sql.wizard/src/org/netbeans/modules/jdbcwizard/wizards/JDBCWizardNamePanel.java
sql.wizard/src/org/netbeans/modules/jdbcwizard/wizards/JDBCWizardTransferPanel.java
sql.wizard/src/org/netbeans/modules/jdbcwizard/wizards/JDBCWizardTransferPanelUI.java
     1.1 --- a/sql.wizard/src/org/netbeans/modules/jdbcwizard/wizards/JDBCWizardNamePanel.java	Thu Feb 12 17:12:53 2009 +0100
     1.2 +++ b/sql.wizard/src/org/netbeans/modules/jdbcwizard/wizards/JDBCWizardNamePanel.java	Thu Feb 12 17:44:11 2009 +0100
     1.3 @@ -66,6 +66,7 @@
     1.4      protected JTextField textField;
     1.5  
     1.6      protected String title;
     1.7 +    private Component comp;
     1.8  
     1.9      /**
    1.10       * Create the wizard panel descriptor, using the given panel title, content panel
    1.11 @@ -111,7 +112,10 @@
    1.12       * @see JDBCWizardPanel#getComponent
    1.13       */
    1.14      public Component getComponent() {
    1.15 -        return new JDBCWizardNamePanelUI (this, owner, title);
    1.16 +        if (comp == null) {
    1.17 +            comp = new JDBCWizardNamePanelUI (this, owner, title);
    1.18 +        }
    1.19 +        return comp;
    1.20      }
    1.21  
    1.22      /**
     2.1 --- a/sql.wizard/src/org/netbeans/modules/jdbcwizard/wizards/JDBCWizardTransferPanel.java	Thu Feb 12 17:12:53 2009 +0100
     2.2 +++ b/sql.wizard/src/org/netbeans/modules/jdbcwizard/wizards/JDBCWizardTransferPanel.java	Thu Feb 12 17:44:11 2009 +0100
     2.3 @@ -13,13 +13,13 @@
     2.4   * "Portions Copyrighted [year] [name of copyright owner]"
     2.5   * 
     2.6   * The Original Software is NetBeans. The Initial Developer of the Original
     2.7 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
     2.8 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2009 Sun
     2.9   * Microsystems, Inc. All Rights Reserved.
    2.10   */
    2.11  
    2.12  /*
    2.13   * 
    2.14 - * Copyright 2005 Sun Microsystems, Inc.
    2.15 + * Copyright 2009 Sun Microsystems, Inc.
    2.16   * 
    2.17   * Licensed under the Apache License, Version 2.0 (the "License");
    2.18   * you may not use this file except in compliance with the License.
    2.19 @@ -46,7 +46,6 @@
    2.20  import java.util.List;
    2.21  import java.util.Set;
    2.22  
    2.23 -import javax.swing.JPanel;
    2.24  import javax.swing.event.ChangeListener;
    2.25  
    2.26  import org.openide.NotifyDescriptor;
    2.27 @@ -58,26 +57,19 @@
    2.28   * 
    2.29   * @author
    2.30   */
    2.31 -public class JDBCWizardTransferPanel extends JPanel implements ActionListener, WizardDescriptor.Panel {
    2.32 -
    2.33 -    /**
    2.34 -     * 
    2.35 -     */
    2.36 -    private static final long serialVersionUID = 1L;
    2.37 +public class JDBCWizardTransferPanel implements ActionListener, WizardDescriptor.Panel {
    2.38  
    2.39      /* Log4J category string */
    2.40      private static final String LOG_CATEGORY = JDBCWizardTransferPanel.class.getName();
    2.41  
    2.42      /* Set <ChangeListeners> */
    2.43 -    private final Set listeners = new HashSet(1);
    2.44 +    private final Set<ChangeListener> listeners = new HashSet<ChangeListener>(1);
    2.45  
    2.46      private List selTableList = new ArrayList();
    2.47  
    2.48      private JDBCWizardTablePanel tablePanel;
    2.49 -
    2.50 -    /** Creates a default instance of JDBCWizardTransferPanel. */
    2.51 -    public JDBCWizardTransferPanel() {
    2.52 -    }
    2.53 +    private JDBCWizardTransferPanelUI comp;
    2.54 +    private String title;
    2.55  
    2.56      /**
    2.57       * Creates a new instance of JDBCWizardTransferPanel using the given ListModels to initially
    2.58 @@ -90,11 +82,7 @@
    2.59       *            it displays available destination OTDs
    2.60       */
    2.61      public JDBCWizardTransferPanel(final String title) {
    2.62 -        this();
    2.63 -        if (title != null && title.trim().length() != 0) {
    2.64 -            this.setName(title);
    2.65 -        }
    2.66 -
    2.67 +        this.title = title;
    2.68  //        final ArrayList testList = new ArrayList();
    2.69  //        this.tablePanel = new JDBCWizardTablePanel(testList);
    2.70  //
    2.71 @@ -126,7 +114,10 @@
    2.72       * @see org.openide.WizardDescriptor.Panel#getComponent
    2.73       */
    2.74      public Component getComponent() {
    2.75 -        return this;
    2.76 +        if (comp == null) {
    2.77 +            comp = new JDBCWizardTransferPanelUI (title);
    2.78 +        }
    2.79 +        return comp;
    2.80      }
    2.81  
    2.82      /**
    2.83 @@ -172,8 +163,11 @@
    2.84  			final ArrayList testList = new ArrayList();
    2.85  		    this.tablePanel = new JDBCWizardTablePanel(testList);
    2.86  
    2.87 -		    this.setLayout(new BorderLayout());
    2.88 -		    this.add(this.tablePanel, BorderLayout.CENTER);
    2.89 +		    if (comp == null) {
    2.90 +                getComponent ();
    2.91 +            }
    2.92 +            comp.setLayout(new BorderLayout());
    2.93 +		    comp.add(this.tablePanel, BorderLayout.CENTER);
    2.94  		    JDBCWizardTransferPanel.this.tablePanel.resetTable(this.selTableList);
    2.95  		}
    2.96  	}
    2.97 @@ -205,7 +199,10 @@
    2.98                  return;
    2.99          }
   2.100          if(selectedOption.toString().equals("PREVIOUS_OPTION")){
   2.101 -        	this.remove(this.tablePanel);
   2.102 +            if (comp == null) {
   2.103 +                getComponent ();
   2.104 +            }
   2.105 +        	comp.remove(this.tablePanel);
   2.106          	this.selTableList = null;
   2.107          	return;
   2.108          }
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/sql.wizard/src/org/netbeans/modules/jdbcwizard/wizards/JDBCWizardTransferPanelUI.java	Thu Feb 12 17:44:11 2009 +0100
     3.3 @@ -0,0 +1,71 @@
     3.4 +/*
     3.5 + * The contents of this file are subject to the terms of the Common Development
     3.6 + * and Distribution License (the License). You may not use this file except in
     3.7 + * compliance with the License.
     3.8 + * 
     3.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
    3.10 + * or http://www.netbeans.org/cddl.txt.
    3.11 + * 
    3.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
    3.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
    3.14 + * If applicable, add the following below the CDDL Header, with the fields
    3.15 + * enclosed by brackets [] replaced by your own identifying information:
    3.16 + * "Portions Copyrighted [year] [name of copyright owner]"
    3.17 + * 
    3.18 + * The Original Software is NetBeans. The Initial Developer of the Original
    3.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2009 Sun
    3.20 + * Microsystems, Inc. All Rights Reserved.
    3.21 + */
    3.22 +
    3.23 +/*
    3.24 + * 
    3.25 + * Copyright 2009 Sun Microsystems, Inc.
    3.26 + * 
    3.27 + * Licensed under the Apache License, Version 2.0 (the "License");
    3.28 + * you may not use this file except in compliance with the License.
    3.29 + * You may obtain a copy of the License at
    3.30 + * 
    3.31 + * 	http://www.apache.org/licenses/LICENSE-2.0
    3.32 + * 
    3.33 + * Unless required by applicable law or agreed to in writing, software
    3.34 + * distributed under the License is distributed on an "AS IS" BASIS,
    3.35 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    3.36 + * See the License for the specific language governing permissions and
    3.37 + * limitations under the License.
    3.38 + * 
    3.39 + */
    3.40 +package org.netbeans.modules.jdbcwizard.wizards;
    3.41 +
    3.42 +
    3.43 +import javax.swing.JPanel;
    3.44 +
    3.45 +
    3.46 +/**
    3.47 + * Implements a two-list transfer panel with bulk add/remove capability.
    3.48 + * 
    3.49 + * @author
    3.50 + */
    3.51 +public class JDBCWizardTransferPanelUI extends JPanel {
    3.52 +
    3.53 +    /**
    3.54 +     * 
    3.55 +     */
    3.56 +    private static final long serialVersionUID = 1L;
    3.57 +
    3.58 +    /**
    3.59 +     * Creates a new instance of JDBCWizardTransferPanel using the given ListModels to initially
    3.60 +     * populate the source and destination panels.
    3.61 +     * 
    3.62 +     * @param title String to be displayed as title of this panel
    3.63 +     * @param dsList List of DatabaseModels used to populate datasource panel
    3.64 +     * @param destColl Collection of selected DatabaseModels
    3.65 +     * @param sourceOTD true if this panel displays available selections for source OTDs; false if
    3.66 +     *            it displays available destination OTDs
    3.67 +     */
    3.68 +    public JDBCWizardTransferPanelUI(final String title) {
    3.69 +        if (title != null && title.trim().length() != 0) {
    3.70 +            this.setName(title);
    3.71 +        }
    3.72 +    }
    3.73 +
    3.74 +}