src/share/classes/com/sun/java/swing/plaf/motif/MotifFileChooserUI.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 264     //
 265     public static ComponentUI createUI(JComponent c) {
 266         return new MotifFileChooserUI((JFileChooser)c);
 267     }
 268 
 269     public void installUI(JComponent c) {
 270         super.installUI(c);
 271     }
 272 
 273     public void uninstallUI(JComponent c) {
 274         c.removePropertyChangeListener(filterComboBoxModel);
 275         approveButton.removeActionListener(getApproveSelectionAction());
 276         filenameTextField.removeActionListener(getApproveSelectionAction());
 277         super.uninstallUI(c);
 278     }
 279 
 280     public void installComponents(JFileChooser fc) {
 281         fc.setLayout(new BorderLayout(10, 10));
 282         fc.setAlignmentX(JComponent.CENTER_ALIGNMENT);
 283 

 284         JPanel interior = new JPanel() {
 285             public Insets getInsets() {
 286                 return insets;
 287             }
 288         };
 289         interior.setInheritsPopupMenu(true);
 290         align(interior);
 291         interior.setLayout(new BoxLayout(interior, BoxLayout.PAGE_AXIS));
 292 
 293         fc.add(interior, BorderLayout.CENTER);
 294 
 295         // PENDING(jeff) - I18N
 296         JLabel l = new JLabel(pathLabelText);
 297         l.setDisplayedMnemonic(pathLabelMnemonic);
 298         align(l);
 299         interior.add(l);
 300 
 301         File currentDirectory = fc.getCurrentDirectory();
 302         String curDirName = null;
 303         if(currentDirectory != null) {
 304             curDirName = currentDirectory.getPath();
 305         }
 306         pathField = new JTextField(curDirName) {


 307             public Dimension getMaximumSize() {
 308                 Dimension d = super.getMaximumSize();
 309                 d.height = getPreferredSize().height;
 310                 return d;
 311             }
 312         };

 313         pathField.setInheritsPopupMenu(true);
 314         l.setLabelFor(pathField);
 315         align(pathField);
 316 
 317         // Change to folder on return
 318         pathField.addActionListener(getUpdateAction());
 319         interior.add(pathField);
 320 
 321         interior.add(Box.createRigidArea(vstrut10));
 322 
 323 
 324         // CENTER: left, right accessory
 325         JPanel centerPanel = new JPanel();
 326         centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.LINE_AXIS));
 327         align(centerPanel);
 328 
 329         // left panel - Filter & folderList
 330         JPanel leftPanel = new JPanel();
 331         leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS));
 332         align(leftPanel);
 333 
 334         // add the filter PENDING(jeff) - I18N
 335         l = new JLabel(filterLabelText);
 336         l.setDisplayedMnemonic(filterLabelMnemonic);
 337         align(l);
 338         leftPanel.add(l);
 339 
 340         filterComboBox = new JComboBox<FileFilter>() {

 341             public Dimension getMaximumSize() {
 342                 Dimension d = super.getMaximumSize();
 343                 d.height = getPreferredSize().height;
 344                 return d;
 345             }
 346         };

 347         filterComboBox.setInheritsPopupMenu(true);
 348         l.setLabelFor(filterComboBox);
 349         filterComboBoxModel = createFilterComboBoxModel();
 350         filterComboBox.setModel(filterComboBoxModel);
 351         filterComboBox.setRenderer(createFilterComboBoxRenderer());
 352         fc.addPropertyChangeListener(filterComboBoxModel);
 353         align(filterComboBox);
 354         leftPanel.add(filterComboBox);
 355 
 356         // leftPanel.add(Box.createRigidArea(vstrut10));
 357 
 358         // Add the Folder List PENDING(jeff) - I18N
 359         l = new JLabel(foldersLabelText);
 360         l.setDisplayedMnemonic(foldersLabelMnemonic);
 361         align(l);
 362         leftPanel.add(l);
 363         JScrollPane sp = createDirectoryList();
 364         sp.getVerticalScrollBar().setFocusable(false);
 365         sp.getHorizontalScrollBar().setFocusable(false);
 366         sp.setInheritsPopupMenu(true);


 396                 accessoryPanel.setPreferredSize(ZERO_ACC_SIZE);
 397                 accessoryPanel.setMaximumSize(ZERO_ACC_SIZE);
 398             } else {
 399                 getAccessoryPanel().add(accessory, BorderLayout.CENTER);
 400                 accessoryPanel.setPreferredSize(PREF_ACC_SIZE);
 401                 accessoryPanel.setMaximumSize(MAX_SIZE);
 402             }
 403             align(accessoryPanel);
 404             centerPanel.add(accessoryPanel);
 405             accessoryPanel.setInheritsPopupMenu(true);
 406         }
 407         interior.add(centerPanel);
 408         interior.add(Box.createRigidArea(vstrut10));
 409 
 410         // add the filename field PENDING(jeff) - I18N
 411         fileNameLabel = new JLabel();
 412         populateFileNameLabel();
 413         align(fileNameLabel);
 414         interior.add(fileNameLabel);
 415 
 416         filenameTextField = new JTextField() {

 417             public Dimension getMaximumSize() {
 418                 Dimension d = super.getMaximumSize();
 419                 d.height = getPreferredSize().height;
 420                 return d;
 421             }
 422         };

 423         filenameTextField.setInheritsPopupMenu(true);
 424         fileNameLabel.setLabelFor(filenameTextField);
 425         filenameTextField.addActionListener(getApproveSelectionAction());
 426         align(filenameTextField);
 427         filenameTextField.setAlignmentX(JComponent.LEFT_ALIGNMENT);
 428         interior.add(filenameTextField);
 429 
 430         bottomPanel = getBottomPanel();
 431         bottomPanel.add(new JSeparator(), BorderLayout.NORTH);
 432 
 433         // Add buttons
 434         JPanel buttonPanel = new JPanel();
 435         align(buttonPanel);
 436         buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
 437         buttonPanel.add(Box.createGlue());
 438 
 439         approveButton = new JButton(getApproveButtonText(fc)) {

 440             public Dimension getMaximumSize() {
 441                 return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
 442             }
 443         };

 444         approveButton.setMnemonic(getApproveButtonMnemonic(fc));
 445         approveButton.setToolTipText(getApproveButtonToolTipText(fc));
 446         approveButton.setInheritsPopupMenu(true);
 447         align(approveButton);
 448         approveButton.setMargin(buttonMargin);
 449         approveButton.addActionListener(getApproveSelectionAction());
 450         buttonPanel.add(approveButton);
 451         buttonPanel.add(Box.createGlue());
 452 

 453         JButton updateButton = new JButton(updateButtonText) {
 454             public Dimension getMaximumSize() {
 455                 return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
 456             }
 457         };
 458         updateButton.setMnemonic(updateButtonMnemonic);
 459         updateButton.setToolTipText(updateButtonToolTipText);
 460         updateButton.setInheritsPopupMenu(true);
 461         align(updateButton);
 462         updateButton.setMargin(buttonMargin);
 463         updateButton.addActionListener(getUpdateAction());
 464         buttonPanel.add(updateButton);
 465         buttonPanel.add(Box.createGlue());
 466 

 467         JButton cancelButton = new JButton(cancelButtonText) {
 468             public Dimension getMaximumSize() {
 469                 return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
 470             }
 471         };
 472         cancelButton.setMnemonic(cancelButtonMnemonic);
 473         cancelButton.setToolTipText(cancelButtonToolTipText);
 474         cancelButton.setInheritsPopupMenu(true);
 475         align(cancelButton);
 476         cancelButton.setMargin(buttonMargin);
 477         cancelButton.addActionListener(getCancelSelectionAction());
 478         buttonPanel.add(cancelButton);
 479         buttonPanel.add(Box.createGlue());
 480 

 481         JButton helpButton = new JButton(helpButtonText) {
 482             public Dimension getMaximumSize() {
 483                 return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
 484             }
 485         };
 486         helpButton.setMnemonic(helpButtonMnemonic);
 487         helpButton.setToolTipText(helpButtonToolTipText);
 488         align(helpButton);
 489         helpButton.setMargin(buttonMargin);
 490         helpButton.setEnabled(false);
 491         helpButton.setInheritsPopupMenu(true);
 492         buttonPanel.add(helpButton);
 493         buttonPanel.add(Box.createGlue());
 494         buttonPanel.setInheritsPopupMenu(true);
 495 
 496         bottomPanel.add(buttonPanel, BorderLayout.SOUTH);
 497         bottomPanel.setInheritsPopupMenu(true);
 498         if (fc.getControlButtonsAreShown()) {
 499            fc.add(bottomPanel, BorderLayout.SOUTH);
 500         }


 623             return new Dimension(d.width < prefSize.width ? prefSize.width : d.width,
 624                                  d.height < prefSize.height ? prefSize.height : d.height);
 625         } else {
 626             return prefSize;
 627         }
 628     }
 629 
 630     public Dimension getMinimumSize(JComponent x)  {
 631         return MIN_SIZE;
 632     }
 633 
 634     public Dimension getMaximumSize(JComponent x) {
 635         return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
 636     }
 637 
 638     protected void align(JComponent c) {
 639         c.setAlignmentX(JComponent.LEFT_ALIGNMENT);
 640         c.setAlignmentY(JComponent.TOP_ALIGNMENT);
 641     }
 642 

 643     protected class FileCellRenderer extends DefaultListCellRenderer  {
 644         public Component getListCellRendererComponent(JList list, Object value, int index,
 645                                                       boolean isSelected, boolean cellHasFocus) {
 646 
 647             super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
 648             setText(getFileChooser().getName((File) value));
 649             setInheritsPopupMenu(true);
 650             return this;
 651         }
 652     }
 653 

 654     protected class DirectoryCellRenderer extends DefaultListCellRenderer  {
 655         public Component getListCellRendererComponent(JList list, Object value, int index,
 656                                                       boolean isSelected, boolean cellHasFocus) {
 657 
 658             super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
 659             setText(getFileChooser().getName((File) value));
 660             setInheritsPopupMenu(true);
 661             return this;
 662         }
 663     }
 664 

 665     protected class MotifDirectoryListModel extends AbstractListModel<File> implements ListDataListener {
 666         public MotifDirectoryListModel() {
 667             getModel().addListDataListener(this);
 668         }
 669 
 670         public int getSize() {
 671             return getModel().getDirectories().size();
 672         }
 673 
 674         public File getElementAt(int index) {
 675             return getModel().getDirectories().elementAt(index);
 676         }
 677 
 678         public void intervalAdded(ListDataEvent e) {
 679             fireIntervalAdded(this, e.getIndex0(), e.getIndex1());
 680         }
 681 
 682         public void intervalRemoved(ListDataEvent e) {
 683             fireIntervalRemoved(this, e.getIndex0(), e.getIndex1());
 684         }
 685 
 686         // PENDING(jeff) - this is inefficient - should sent out
 687         // incremental adjustment values instead of saying that the
 688         // whole list has changed.
 689         public void fireContentsChanged() {
 690             fireContentsChanged(this, 0, getModel().getDirectories().size()-1);
 691         }
 692 
 693         // PENDING(jeff) - fire the correct interval changed - currently sending
 694         // out that everything has changed
 695         public void contentsChanged(ListDataEvent e) {
 696             fireContentsChanged();
 697         }
 698 
 699     }
 700 

 701     protected class MotifFileListModel extends AbstractListModel<File> implements ListDataListener {
 702         public MotifFileListModel() {
 703             getModel().addListDataListener(this);
 704         }
 705 
 706         public int getSize() {
 707             return getModel().getFiles().size();
 708         }
 709 
 710         public boolean contains(Object o) {
 711             return getModel().getFiles().contains(o);
 712         }
 713 
 714         public int indexOf(Object o) {
 715             return getModel().getFiles().indexOf(o);
 716         }
 717 
 718         public File getElementAt(int index) {
 719             return getModel().getFiles().elementAt(index);
 720         }


 742     }
 743 
 744     //
 745     // DataModel for Types Comboxbox
 746     //
 747     protected FilterComboBoxModel createFilterComboBoxModel() {
 748         return new FilterComboBoxModel();
 749     }
 750 
 751     //
 752     // Renderer for Types ComboBox
 753     //
 754     protected FilterComboBoxRenderer createFilterComboBoxRenderer() {
 755         return new FilterComboBoxRenderer();
 756     }
 757 
 758 
 759     /**
 760      * Render different type sizes and styles.
 761      */

 762     public class FilterComboBoxRenderer extends DefaultListCellRenderer {
 763         public Component getListCellRendererComponent(JList list,
 764             Object value, int index, boolean isSelected,
 765             boolean cellHasFocus) {
 766 
 767             super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
 768 
 769             if (value != null && value instanceof FileFilter) {
 770                 setText(((FileFilter)value).getDescription());
 771             }
 772 
 773             return this;
 774         }
 775     }
 776 
 777     /**
 778      * Data model for a type-face selection combo-box.
 779      */

 780     protected class FilterComboBoxModel extends AbstractListModel<FileFilter> implements ComboBoxModel<FileFilter>,
 781             PropertyChangeListener {
 782         protected FileFilter[] filters;
 783         protected FilterComboBoxModel() {
 784             super();
 785             filters = getFileChooser().getChoosableFileFilters();
 786         }
 787 
 788         public void propertyChange(PropertyChangeEvent e) {
 789             String prop = e.getPropertyName();
 790             if(prop.equals(JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY)) {
 791                 filters = (FileFilter[]) e.getNewValue();
 792                 fireContentsChanged(this, -1, -1);
 793             } else if (prop.equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) {
 794                 fireContentsChanged(this, -1, -1);
 795             }
 796         }
 797 
 798         public void setSelectedItem(Object filter) {
 799             if(filter != null) {


   1 /*
   2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 264     //
 265     public static ComponentUI createUI(JComponent c) {
 266         return new MotifFileChooserUI((JFileChooser)c);
 267     }
 268 
 269     public void installUI(JComponent c) {
 270         super.installUI(c);
 271     }
 272 
 273     public void uninstallUI(JComponent c) {
 274         c.removePropertyChangeListener(filterComboBoxModel);
 275         approveButton.removeActionListener(getApproveSelectionAction());
 276         filenameTextField.removeActionListener(getApproveSelectionAction());
 277         super.uninstallUI(c);
 278     }
 279 
 280     public void installComponents(JFileChooser fc) {
 281         fc.setLayout(new BorderLayout(10, 10));
 282         fc.setAlignmentX(JComponent.CENTER_ALIGNMENT);
 283 
 284         @SuppressWarnings("serial") // anonymous class
 285         JPanel interior = new JPanel() {
 286             public Insets getInsets() {
 287                 return insets;
 288             }
 289         };
 290         interior.setInheritsPopupMenu(true);
 291         align(interior);
 292         interior.setLayout(new BoxLayout(interior, BoxLayout.PAGE_AXIS));
 293 
 294         fc.add(interior, BorderLayout.CENTER);
 295 
 296         // PENDING(jeff) - I18N
 297         JLabel l = new JLabel(pathLabelText);
 298         l.setDisplayedMnemonic(pathLabelMnemonic);
 299         align(l);
 300         interior.add(l);
 301 
 302         File currentDirectory = fc.getCurrentDirectory();
 303         String curDirName = null;
 304         if(currentDirectory != null) {
 305             curDirName = currentDirectory.getPath();
 306         }
 307 
 308         @SuppressWarnings("serial") // anonymous class
 309         JTextField tmp1 = new JTextField(curDirName) {
 310             public Dimension getMaximumSize() {
 311                 Dimension d = super.getMaximumSize();
 312                 d.height = getPreferredSize().height;
 313                 return d;
 314             }
 315         };
 316         pathField = tmp1;
 317         pathField.setInheritsPopupMenu(true);
 318         l.setLabelFor(pathField);
 319         align(pathField);
 320 
 321         // Change to folder on return
 322         pathField.addActionListener(getUpdateAction());
 323         interior.add(pathField);
 324 
 325         interior.add(Box.createRigidArea(vstrut10));
 326 
 327 
 328         // CENTER: left, right accessory
 329         JPanel centerPanel = new JPanel();
 330         centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.LINE_AXIS));
 331         align(centerPanel);
 332 
 333         // left panel - Filter & folderList
 334         JPanel leftPanel = new JPanel();
 335         leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS));
 336         align(leftPanel);
 337 
 338         // add the filter PENDING(jeff) - I18N
 339         l = new JLabel(filterLabelText);
 340         l.setDisplayedMnemonic(filterLabelMnemonic);
 341         align(l);
 342         leftPanel.add(l);
 343 
 344         @SuppressWarnings("serial") // anonymous class
 345         JComboBox tmp2 = new JComboBox<FileFilter>() {
 346             public Dimension getMaximumSize() {
 347                 Dimension d = super.getMaximumSize();
 348                 d.height = getPreferredSize().height;
 349                 return d;
 350             }
 351         };
 352         filterComboBox = tmp2;
 353         filterComboBox.setInheritsPopupMenu(true);
 354         l.setLabelFor(filterComboBox);
 355         filterComboBoxModel = createFilterComboBoxModel();
 356         filterComboBox.setModel(filterComboBoxModel);
 357         filterComboBox.setRenderer(createFilterComboBoxRenderer());
 358         fc.addPropertyChangeListener(filterComboBoxModel);
 359         align(filterComboBox);
 360         leftPanel.add(filterComboBox);
 361 
 362         // leftPanel.add(Box.createRigidArea(vstrut10));
 363 
 364         // Add the Folder List PENDING(jeff) - I18N
 365         l = new JLabel(foldersLabelText);
 366         l.setDisplayedMnemonic(foldersLabelMnemonic);
 367         align(l);
 368         leftPanel.add(l);
 369         JScrollPane sp = createDirectoryList();
 370         sp.getVerticalScrollBar().setFocusable(false);
 371         sp.getHorizontalScrollBar().setFocusable(false);
 372         sp.setInheritsPopupMenu(true);


 402                 accessoryPanel.setPreferredSize(ZERO_ACC_SIZE);
 403                 accessoryPanel.setMaximumSize(ZERO_ACC_SIZE);
 404             } else {
 405                 getAccessoryPanel().add(accessory, BorderLayout.CENTER);
 406                 accessoryPanel.setPreferredSize(PREF_ACC_SIZE);
 407                 accessoryPanel.setMaximumSize(MAX_SIZE);
 408             }
 409             align(accessoryPanel);
 410             centerPanel.add(accessoryPanel);
 411             accessoryPanel.setInheritsPopupMenu(true);
 412         }
 413         interior.add(centerPanel);
 414         interior.add(Box.createRigidArea(vstrut10));
 415 
 416         // add the filename field PENDING(jeff) - I18N
 417         fileNameLabel = new JLabel();
 418         populateFileNameLabel();
 419         align(fileNameLabel);
 420         interior.add(fileNameLabel);
 421 
 422         @SuppressWarnings("serial") // anonymous class
 423         JTextField tmp3 = new JTextField() {
 424             public Dimension getMaximumSize() {
 425                 Dimension d = super.getMaximumSize();
 426                 d.height = getPreferredSize().height;
 427                 return d;
 428             }
 429         };
 430         filenameTextField = tmp3;
 431         filenameTextField.setInheritsPopupMenu(true);
 432         fileNameLabel.setLabelFor(filenameTextField);
 433         filenameTextField.addActionListener(getApproveSelectionAction());
 434         align(filenameTextField);
 435         filenameTextField.setAlignmentX(JComponent.LEFT_ALIGNMENT);
 436         interior.add(filenameTextField);
 437 
 438         bottomPanel = getBottomPanel();
 439         bottomPanel.add(new JSeparator(), BorderLayout.NORTH);
 440 
 441         // Add buttons
 442         JPanel buttonPanel = new JPanel();
 443         align(buttonPanel);
 444         buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
 445         buttonPanel.add(Box.createGlue());
 446 
 447         @SuppressWarnings("serial") // anonymous class
 448         JButton tmp4 = new JButton(getApproveButtonText(fc)) {
 449             public Dimension getMaximumSize() {
 450                 return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
 451             }
 452         };
 453         approveButton = tmp4;
 454         approveButton.setMnemonic(getApproveButtonMnemonic(fc));
 455         approveButton.setToolTipText(getApproveButtonToolTipText(fc));
 456         approveButton.setInheritsPopupMenu(true);
 457         align(approveButton);
 458         approveButton.setMargin(buttonMargin);
 459         approveButton.addActionListener(getApproveSelectionAction());
 460         buttonPanel.add(approveButton);
 461         buttonPanel.add(Box.createGlue());
 462 
 463         @SuppressWarnings("serial") // anonymous class
 464         JButton updateButton = new JButton(updateButtonText) {
 465             public Dimension getMaximumSize() {
 466                 return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
 467             }
 468         };
 469         updateButton.setMnemonic(updateButtonMnemonic);
 470         updateButton.setToolTipText(updateButtonToolTipText);
 471         updateButton.setInheritsPopupMenu(true);
 472         align(updateButton);
 473         updateButton.setMargin(buttonMargin);
 474         updateButton.addActionListener(getUpdateAction());
 475         buttonPanel.add(updateButton);
 476         buttonPanel.add(Box.createGlue());
 477 
 478         @SuppressWarnings("serial") // anonymous class
 479         JButton cancelButton = new JButton(cancelButtonText) {
 480             public Dimension getMaximumSize() {
 481                 return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
 482             }
 483         };
 484         cancelButton.setMnemonic(cancelButtonMnemonic);
 485         cancelButton.setToolTipText(cancelButtonToolTipText);
 486         cancelButton.setInheritsPopupMenu(true);
 487         align(cancelButton);
 488         cancelButton.setMargin(buttonMargin);
 489         cancelButton.addActionListener(getCancelSelectionAction());
 490         buttonPanel.add(cancelButton);
 491         buttonPanel.add(Box.createGlue());
 492 
 493         @SuppressWarnings("serial") // anonymous class
 494         JButton helpButton = new JButton(helpButtonText) {
 495             public Dimension getMaximumSize() {
 496                 return new Dimension(MAX_SIZE.width, this.getPreferredSize().height);
 497             }
 498         };
 499         helpButton.setMnemonic(helpButtonMnemonic);
 500         helpButton.setToolTipText(helpButtonToolTipText);
 501         align(helpButton);
 502         helpButton.setMargin(buttonMargin);
 503         helpButton.setEnabled(false);
 504         helpButton.setInheritsPopupMenu(true);
 505         buttonPanel.add(helpButton);
 506         buttonPanel.add(Box.createGlue());
 507         buttonPanel.setInheritsPopupMenu(true);
 508 
 509         bottomPanel.add(buttonPanel, BorderLayout.SOUTH);
 510         bottomPanel.setInheritsPopupMenu(true);
 511         if (fc.getControlButtonsAreShown()) {
 512            fc.add(bottomPanel, BorderLayout.SOUTH);
 513         }


 636             return new Dimension(d.width < prefSize.width ? prefSize.width : d.width,
 637                                  d.height < prefSize.height ? prefSize.height : d.height);
 638         } else {
 639             return prefSize;
 640         }
 641     }
 642 
 643     public Dimension getMinimumSize(JComponent x)  {
 644         return MIN_SIZE;
 645     }
 646 
 647     public Dimension getMaximumSize(JComponent x) {
 648         return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
 649     }
 650 
 651     protected void align(JComponent c) {
 652         c.setAlignmentX(JComponent.LEFT_ALIGNMENT);
 653         c.setAlignmentY(JComponent.TOP_ALIGNMENT);
 654     }
 655 
 656     @SuppressWarnings("serial") // Superclass is not serializable across versions
 657     protected class FileCellRenderer extends DefaultListCellRenderer  {
 658         public Component getListCellRendererComponent(JList list, Object value, int index,
 659                                                       boolean isSelected, boolean cellHasFocus) {
 660 
 661             super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
 662             setText(getFileChooser().getName((File) value));
 663             setInheritsPopupMenu(true);
 664             return this;
 665         }
 666     }
 667 
 668     @SuppressWarnings("serial") // Superclass is not serializable across versions
 669     protected class DirectoryCellRenderer extends DefaultListCellRenderer  {
 670         public Component getListCellRendererComponent(JList list, Object value, int index,
 671                                                       boolean isSelected, boolean cellHasFocus) {
 672 
 673             super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
 674             setText(getFileChooser().getName((File) value));
 675             setInheritsPopupMenu(true);
 676             return this;
 677         }
 678     }
 679 
 680     @SuppressWarnings("serial") // Superclass is not serializable across versions
 681     protected class MotifDirectoryListModel extends AbstractListModel<File> implements ListDataListener {
 682         public MotifDirectoryListModel() {
 683             getModel().addListDataListener(this);
 684         }
 685 
 686         public int getSize() {
 687             return getModel().getDirectories().size();
 688         }
 689 
 690         public File getElementAt(int index) {
 691             return getModel().getDirectories().elementAt(index);
 692         }
 693 
 694         public void intervalAdded(ListDataEvent e) {
 695             fireIntervalAdded(this, e.getIndex0(), e.getIndex1());
 696         }
 697 
 698         public void intervalRemoved(ListDataEvent e) {
 699             fireIntervalRemoved(this, e.getIndex0(), e.getIndex1());
 700         }
 701 
 702         // PENDING(jeff) - this is inefficient - should sent out
 703         // incremental adjustment values instead of saying that the
 704         // whole list has changed.
 705         public void fireContentsChanged() {
 706             fireContentsChanged(this, 0, getModel().getDirectories().size()-1);
 707         }
 708 
 709         // PENDING(jeff) - fire the correct interval changed - currently sending
 710         // out that everything has changed
 711         public void contentsChanged(ListDataEvent e) {
 712             fireContentsChanged();
 713         }
 714 
 715     }
 716 
 717     @SuppressWarnings("serial") // Superclass is not serializable across versions
 718     protected class MotifFileListModel extends AbstractListModel<File> implements ListDataListener {
 719         public MotifFileListModel() {
 720             getModel().addListDataListener(this);
 721         }
 722 
 723         public int getSize() {
 724             return getModel().getFiles().size();
 725         }
 726 
 727         public boolean contains(Object o) {
 728             return getModel().getFiles().contains(o);
 729         }
 730 
 731         public int indexOf(Object o) {
 732             return getModel().getFiles().indexOf(o);
 733         }
 734 
 735         public File getElementAt(int index) {
 736             return getModel().getFiles().elementAt(index);
 737         }


 759     }
 760 
 761     //
 762     // DataModel for Types Comboxbox
 763     //
 764     protected FilterComboBoxModel createFilterComboBoxModel() {
 765         return new FilterComboBoxModel();
 766     }
 767 
 768     //
 769     // Renderer for Types ComboBox
 770     //
 771     protected FilterComboBoxRenderer createFilterComboBoxRenderer() {
 772         return new FilterComboBoxRenderer();
 773     }
 774 
 775 
 776     /**
 777      * Render different type sizes and styles.
 778      */
 779     @SuppressWarnings("serial") // Superclass is not serializable across versions
 780     public class FilterComboBoxRenderer extends DefaultListCellRenderer {
 781         public Component getListCellRendererComponent(JList list,
 782             Object value, int index, boolean isSelected,
 783             boolean cellHasFocus) {
 784 
 785             super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
 786 
 787             if (value != null && value instanceof FileFilter) {
 788                 setText(((FileFilter)value).getDescription());
 789             }
 790 
 791             return this;
 792         }
 793     }
 794 
 795     /**
 796      * Data model for a type-face selection combo-box.
 797      */
 798     @SuppressWarnings("serial") // Superclass is not serializable across versions
 799     protected class FilterComboBoxModel extends AbstractListModel<FileFilter> implements ComboBoxModel<FileFilter>,
 800             PropertyChangeListener {
 801         protected FileFilter[] filters;
 802         protected FilterComboBoxModel() {
 803             super();
 804             filters = getFileChooser().getChoosableFileFilters();
 805         }
 806 
 807         public void propertyChange(PropertyChangeEvent e) {
 808             String prop = e.getPropertyName();
 809             if(prop.equals(JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY)) {
 810                 filters = (FileFilter[]) e.getNewValue();
 811                 fireContentsChanged(this, -1, -1);
 812             } else if (prop.equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) {
 813                 fireContentsChanged(this, -1, -1);
 814             }
 815         }
 816 
 817         public void setSelectedItem(Object filter) {
 818             if(filter != null) {