< prev index next >

src/org/netbeans/jemmy/operators/JFileChooserOperator.java

Print this page




  26 
  27 import java.awt.Component;
  28 import java.awt.Container;
  29 import java.awt.Rectangle;
  30 import java.awt.Window;
  31 import java.awt.event.ActionListener;
  32 import java.io.File;
  33 
  34 import javax.swing.ComboBoxModel;
  35 import javax.swing.Icon;
  36 import javax.swing.JButton;
  37 import javax.swing.JComboBox;
  38 import javax.swing.JComponent;
  39 import javax.swing.JDialog;
  40 import javax.swing.JFileChooser;
  41 import javax.swing.JList;
  42 import javax.swing.JTable;
  43 import javax.swing.JTextField;
  44 import javax.swing.JToggleButton;
  45 import javax.swing.ListModel;

  46 import javax.swing.filechooser.FileFilter;
  47 import javax.swing.filechooser.FileSystemView;
  48 import javax.swing.filechooser.FileView;
  49 import javax.swing.plaf.FileChooserUI;
  50 import javax.swing.table.TableModel;
  51 
  52 import org.netbeans.jemmy.ComponentChooser;
  53 import org.netbeans.jemmy.ComponentSearcher;
  54 import org.netbeans.jemmy.JemmyException;
  55 import org.netbeans.jemmy.JemmyProperties;
  56 import org.netbeans.jemmy.Outputable;
  57 import org.netbeans.jemmy.TestOut;
  58 import org.netbeans.jemmy.Timeoutable;
  59 import org.netbeans.jemmy.Timeouts;
  60 import org.netbeans.jemmy.Waitable;
  61 import org.netbeans.jemmy.Waiter;
  62 import org.netbeans.jemmy.util.LookAndFeel;
  63 
  64 /**
  65  *


 324                     }
 325 
 326                     @Override
 327                     public String getDescription() {
 328                         return "JTextField";
 329                     }
 330 
 331                     @Override
 332                     public String toString() {
 333                         return "JFileChooserOperator.getPathField.ComponentChooser{description = " + getDescription() + '}';
 334                     }
 335                 }));
 336     }
 337 
 338     /**
 339      * Returns either a JList or JTable, depending on the implementation.
 340      *
 341      * @return a component being used to display directory content.
 342      */
 343     public Component getFileList() {
 344         int index = 0;
 345         // In GTK and Motif L&F, there are two JLists, one is to list folders
 346         // and second one one is to list files
 347         if (LookAndFeel.isMotif() || LookAndFeel.isGTK()) {
 348             index =1;


 349         }
 350         return innerSearcher.
 351                 findComponent(new ComponentChooser() {
 352                     @Override
 353                     public boolean checkComponent(Component comp) {
 354                         return (comp != null
 355                                 && (comp instanceof JList || comp instanceof JTable));
 356                     }
 357 
 358                     @Override
 359                     public String getDescription() {
 360                         return "JList or JTable used to show list of files";
 361                     }
 362 
 363                     @Override
 364                     public String toString() {
 365                         return "JFileChooserOperator.getFileList.ComponentChooser{description = " + getDescription() + '}';
 366                     }
 367                 }, index);
 368     }
 369 
 370     /**
 371      * Pushes approve button.
 372      */
 373     public void approve() {
 374         getQueueTool().waitEmpty();
 375         output.printTrace("Push approve button in JFileChooser\n    : "
 376                 + toStringSource());
 377         JButtonOperator approveOper = new JButtonOperator(getApproveButton());
 378         approveOper.copyEnvironment(this);
 379         approveOper.setOutput(output.createErrorOutput());
 380         approveOper.push();
 381     }
 382 
 383     /**
 384      * Pushes cancel button.
 385      */
 386     public void cancel() {
 387         output.printTrace("Push cancel button in JFileChooser\n    : "




  26 
  27 import java.awt.Component;
  28 import java.awt.Container;
  29 import java.awt.Rectangle;
  30 import java.awt.Window;
  31 import java.awt.event.ActionListener;
  32 import java.io.File;
  33 
  34 import javax.swing.ComboBoxModel;
  35 import javax.swing.Icon;
  36 import javax.swing.JButton;
  37 import javax.swing.JComboBox;
  38 import javax.swing.JComponent;
  39 import javax.swing.JDialog;
  40 import javax.swing.JFileChooser;
  41 import javax.swing.JList;
  42 import javax.swing.JTable;
  43 import javax.swing.JTextField;
  44 import javax.swing.JToggleButton;
  45 import javax.swing.ListModel;
  46 import javax.swing.UIManager;
  47 import javax.swing.filechooser.FileFilter;
  48 import javax.swing.filechooser.FileSystemView;
  49 import javax.swing.filechooser.FileView;
  50 import javax.swing.plaf.FileChooserUI;
  51 import javax.swing.table.TableModel;
  52 
  53 import org.netbeans.jemmy.ComponentChooser;
  54 import org.netbeans.jemmy.ComponentSearcher;
  55 import org.netbeans.jemmy.JemmyException;
  56 import org.netbeans.jemmy.JemmyProperties;
  57 import org.netbeans.jemmy.Outputable;
  58 import org.netbeans.jemmy.TestOut;
  59 import org.netbeans.jemmy.Timeoutable;
  60 import org.netbeans.jemmy.Timeouts;
  61 import org.netbeans.jemmy.Waitable;
  62 import org.netbeans.jemmy.Waiter;
  63 import org.netbeans.jemmy.util.LookAndFeel;
  64 
  65 /**
  66  *


 325                     }
 326 
 327                     @Override
 328                     public String getDescription() {
 329                         return "JTextField";
 330                     }
 331 
 332                     @Override
 333                     public String toString() {
 334                         return "JFileChooserOperator.getPathField.ComponentChooser{description = " + getDescription() + '}';
 335                     }
 336                 }));
 337     }
 338 
 339     /**
 340      * Returns either a JList or JTable, depending on the implementation.
 341      *
 342      * @return a component being used to display directory content.
 343      */
 344     public Component getFileList() {
 345         final String fileListName;


 346         if (LookAndFeel.isMotif() || LookAndFeel.isGTK()) {
 347             fileListName = UIManager.getString("FileChooser.filesLabelText", getLocale());
 348         } else {
 349             fileListName = UIManager.getString("FileChooser.filesListAccessibleName", getLocale());
 350         }
 351         return innerSearcher.
 352                 findComponent(new ComponentChooser() {
 353                     @Override
 354                     public boolean checkComponent(Component comp) {
 355                         return ((comp instanceof JList && fileListName.equals(comp.getAccessibleContext().getAccessibleName()))
 356                                 || comp instanceof JTable);
 357                     }
 358 
 359                     @Override
 360                     public String getDescription() {
 361                         return "JList or JTable used to show list of files";
 362                     }
 363 
 364                     @Override
 365                     public String toString() {
 366                         return "JFileChooserOperator.getFileList.ComponentChooser{description = " + getDescription() + '}';
 367                     }
 368                 });
 369     }
 370 
 371     /**
 372      * Pushes approve button.
 373      */
 374     public void approve() {
 375         getQueueTool().waitEmpty();
 376         output.printTrace("Push approve button in JFileChooser\n    : "
 377                 + toStringSource());
 378         JButtonOperator approveOper = new JButtonOperator(getApproveButton());
 379         approveOper.copyEnvironment(this);
 380         approveOper.setOutput(output.createErrorOutput());
 381         approveOper.push();
 382     }
 383 
 384     /**
 385      * Pushes cancel button.
 386      */
 387     public void cancel() {
 388         output.printTrace("Push cancel button in JFileChooser\n    : "


< prev index next >