Back to index

wims  3.65+svn20090927
Public Member Functions | Static Public Attributes | Protected Member Functions | Package Attributes | Private Attributes
SharpTools.FindDialog Class Reference

This class provides a find dialog. More...

Inheritance diagram for SharpTools.FindDialog:
Inheritance graph
[legend]
Collaboration diagram for SharpTools.FindDialog:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 FindDialog (JFrame aFrame, String findValue, boolean mCase, boolean mCell)
boolean isCaseSensitive ()
boolean isCellMatching ()
String getString ()
int getChoice ()
boolean isCancelled ()

Static Public Attributes

static final int CLOSED_OPTION = JOptionPane.CLOSED_OPTION
static final int YES_OPTION = JOptionPane.YES_OPTION
static final int NO_OPTION = JOptionPane.NO_OPTION
static final int OK_OPTION = JOptionPane.OK_OPTION
static final int CANCEL_OPTION = JOptionPane.CANCEL_OPTION

Protected Member Functions

void onOpen ()
 I provide several hooks for the sublasses to override.
boolean onOK ()
 This function is called when the OK button is pressed.
JRootPane createRootPane ()
 override this protected funciton to register ESCAPE with the root pane
boolean onClose ()
 This function is called when (1) the close button is clocked (2) Escape is pressed.
boolean onCancel ()
 This function is called when the Cancel button is pressed.
boolean onYes ()
 This function is called when the Yes button is pressed.
boolean onNo ()
 This function is called when the No button is pressed.
void setOptionPane (Object message, int messageType, int optionType, Icon icon)
 This is used by subclasses to set the JOptionPane component in the dialog.
void setOptionPane (Object message, int messageType, int optionType, Icon icon, int defaultIndex)
 This is used by subclasses to set the JOptionPane component in the dialog.

Package Attributes

final ImageIcon findIcon = new ImageIcon(getClass().getResource("/images/find32.gif"))
final ImageIcon okIcon = new ImageIcon(getClass().getResource("/images/ok.gif"))
final ImageIcon cancelIcon = new ImageIcon(getClass().getResource("/images/cancel.gif"))
final ImageIcon noIcon = new ImageIcon(getClass().getResource("/images/no.gif"))

Private Attributes

JLabel label
JFrame frame
final JTextField textField = new JTextField(10)
JCheckBox caseSensitiveBox
JCheckBox matchCellBox
String typedText = null
boolean caseSensitive = false
boolean matchCell = false

Detailed Description

This class provides a find dialog.

User is prompted to choose find options.

Author:
Andrei Scudder
Hua Zhong (use SharpDialog)
Version:
Revision:
1.3

Definition at line 23 of file FindDialog.java.


Constructor & Destructor Documentation

SharpTools.FindDialog.FindDialog ( JFrame  aFrame,
String  findValue,
boolean  mCase,
boolean  mCell 
) [inline]

Definition at line 36 of file FindDialog.java.

                                   {
       super(aFrame, "Find", true);
       
       textField.setText(findValue);
       
       caseSensitiveBox = new JCheckBox(SharpTools.translation.getProperty("Match_Case"));
       caseSensitiveBox.setMnemonic(KeyEvent.VK_M);
       caseSensitiveBox.setSelected(mCase);
       
       matchCellBox = new JCheckBox(SharpTools.translation.getProperty("Match_Entire_Cell_Only"));
       matchCellBox.setMnemonic(KeyEvent.VK_E); 
       matchCellBox.setSelected(mCell);

       JPanel box = new JPanel(new BorderLayout(0, 5));

       box.add(textField, BorderLayout.NORTH);
       box.add(caseSensitiveBox, BorderLayout.WEST);
       box.add(matchCellBox, BorderLayout.EAST);
       
       setOptionPane(box, 
                    JOptionPane.PLAIN_MESSAGE,
                    JOptionPane.OK_CANCEL_OPTION,
                    findIcon);     
    }

Here is the call graph for this function:


Member Function Documentation

JRootPane SharpTools.SharpDialog.createRootPane ( ) [inline, protected, inherited]

override this protected funciton to register ESCAPE with the root pane

Returns:
a customized JRootPane object

Definition at line 126 of file SharpDialog.java.

                                         {
       KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
       JRootPane rootPane = new JRootPane();
       rootPane.registerKeyboardAction(
                                   new ActionListener() {
                                          public void actionPerformed
                                              (ActionEvent ev) {    
                                              if (onClose()) {
                                                 choice = CLOSED_OPTION;
                                                 setVisible(false);
                                              }
                                          }
                                       },
                                   stroke,
                                   JComponent.WHEN_IN_FOCUSED_WINDOW);
       return rootPane;
    }

Here is the call graph for this function:

int SharpTools.SharpDialog.getChoice ( ) [inline, inherited]
Returns:
user choice

Definition at line 344 of file SharpDialog.java.

                           {
       return choice;
    }

Here is the caller graph for this function:

String SharpTools.FindDialog.getString ( ) [inline]

Definition at line 70 of file FindDialog.java.

                             {
       return typedText;
    }

Here is the caller graph for this function:

Returns:
whether this operation was cancelled

Definition at line 351 of file SharpDialog.java.

                                 {
       return choice == CANCEL_OPTION || choice == CLOSED_OPTION;
    }

Here is the caller graph for this function:

Definition at line 62 of file FindDialog.java.

                                    {
       return caseSensitive;              
    }

Here is the caller graph for this function:

Definition at line 66 of file FindDialog.java.

                                   {
       return matchCell;
    }

Here is the caller graph for this function:

boolean SharpTools.SharpDialog.onCancel ( ) [inline, protected, inherited]

This function is called when the Cancel button is pressed.

Returns:
whether the dialog should be closed

Reimplemented in SharpTools.SortDialog, SharpTools.NewFileDialog, and SharpTools.PasswordDialog.

Definition at line 187 of file SharpDialog.java.

                                 {
       return true;
    }

Here is the caller graph for this function:

boolean SharpTools.SharpDialog.onClose ( ) [inline, protected, inherited]

This function is called when (1) the close button is clocked (2) Escape is pressed.

By default, we think it's the same as clicking Cancel button

Returns:
whether the dialog should be closed

Reimplemented in SharpTools.NewFileDialog.

Definition at line 167 of file SharpDialog.java.

                                {
       return onCancel();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

boolean SharpTools.SharpDialog.onNo ( ) [inline, protected, inherited]

This function is called when the No button is pressed.

Returns:
whether the dialog should be closed

Definition at line 207 of file SharpDialog.java.

                             {
       return true;
    }

Here is the caller graph for this function:

boolean SharpTools.FindDialog.onOK ( ) [inline, protected]

This function is called when the OK button is pressed.

Returns:
whether the dialog should be closed

Reimplemented from SharpTools.SharpDialog.

Definition at line 79 of file FindDialog.java.

                             {
       typedText = textField.getText();
       caseSensitive = caseSensitiveBox.isSelected();
       matchCell = matchCellBox.isSelected();
       return true;
    }
void SharpTools.FindDialog.onOpen ( ) [inline, protected]

I provide several hooks for the sublasses to override.

This function is called when the dialog window is opened.

Reimplemented from SharpTools.SharpDialog.

Definition at line 74 of file FindDialog.java.

                            {
       textField.selectAll();
       textField.requestFocus();
    }
boolean SharpTools.SharpDialog.onYes ( ) [inline, protected, inherited]

This function is called when the Yes button is pressed.

Returns:
whether the dialog should be closed

Definition at line 197 of file SharpDialog.java.

                              {
       return true;
    }

Here is the caller graph for this function:

void SharpTools.SharpDialog.setOptionPane ( Object  message,
int  messageType,
int  optionType,
Icon  icon 
) [inline, protected, inherited]

This is used by subclasses to set the JOptionPane component in the dialog.

Parameters:
messagethe message box
messageTypethe message type
optionTypethe option type
iconthe icon to display

Definition at line 220 of file SharpDialog.java.

                                        {
       
       setOptionPane(message, messageType, optionType, icon, 0);
    }

Here is the caller graph for this function:

void SharpTools.SharpDialog.setOptionPane ( Object  message,
int  messageType,
int  optionType,
Icon  icon,
int  defaultIndex 
) [inline, protected, inherited]

This is used by subclasses to set the JOptionPane component in the dialog.

Parameters:
messagethe message box
messageTypethe message type
optionTypethe option type
iconthe icon to display
defaultIndexthe default index

Definition at line 238 of file SharpDialog.java.

                                               {
       
       addWindowListener(new WindowAdapter() {

              public void windowOpened(WindowEvent we) {
                  // set the initial focus to rowField
                  onOpen();
              }
              
                public void windowClosing(WindowEvent we) {
                  if (onClose()) {
                     choice = CLOSED_OPTION;
                     setVisible(false);
                  }
              }
           });
       
       // handle this by onClose()
       setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

       okButton.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent evt) {
                  if (onOK()) {
                     choice = OK_OPTION;
                     setVisible(false);
                  }
              }
           });

       cancelButton.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent evt) {
                  if (onCancel()) {
                     choice = CANCEL_OPTION;
                     setVisible(false);
                  }
              }
           });
       
       yesButton.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent evt) {
                  if (onYes()) {
                     choice = YES_OPTION;
                     setVisible(false);
                  }
              }
           });
       
       noButton.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent evt) {
                  if (onNo()) {
                     choice = NO_OPTION;
                     setVisible(false);
                  }
              }
           });

       // setup Mnemonic
       okButton.setMnemonic (KeyEvent.VK_O);
       cancelButton.setMnemonic (KeyEvent.VK_C);
       yesButton.setMnemonic (KeyEvent.VK_Y);
       noButton.setMnemonic (KeyEvent.VK_N);
       
       Object[] buttons = setButtons(optionType);
       JOptionPane optionPane = new JOptionPane(message, messageType,
                                           optionType, icon,
                                           buttons,
                                           buttons[defaultIndex]);
       
       setContentPane(optionPane);

       pack();
       setLocationRelativeTo(getParent());
    }

Here is the call graph for this function:


Member Data Documentation

final int SharpTools.SharpDialog.CANCEL_OPTION = JOptionPane.CANCEL_OPTION [static, inherited]

Definition at line 26 of file SharpDialog.java.

final ImageIcon SharpTools.SharpDialog.cancelIcon = new ImageIcon(getClass().getResource("/images/cancel.gif")) [package, inherited]

Definition at line 28 of file SharpDialog.java.

Definition at line 31 of file FindDialog.java.

Definition at line 28 of file FindDialog.java.

final int SharpTools.SharpDialog.CLOSED_OPTION = JOptionPane.CLOSED_OPTION [static, inherited]

Definition at line 22 of file SharpDialog.java.

final ImageIcon SharpTools.FindDialog.findIcon = new ImageIcon(getClass().getResource("/images/find32.gif")) [package]

Definition at line 33 of file FindDialog.java.

JFrame SharpTools.FindDialog.frame [private]

Definition at line 26 of file FindDialog.java.

JLabel SharpTools.FindDialog.label [private]

Definition at line 25 of file FindDialog.java.

Definition at line 32 of file FindDialog.java.

Definition at line 29 of file FindDialog.java.

final int SharpTools.SharpDialog.NO_OPTION = JOptionPane.NO_OPTION [static, inherited]

Definition at line 24 of file SharpDialog.java.

final ImageIcon SharpTools.SharpDialog.noIcon = new ImageIcon(getClass().getResource("/images/no.gif")) [package, inherited]

Definition at line 29 of file SharpDialog.java.

final int SharpTools.SharpDialog.OK_OPTION = JOptionPane.OK_OPTION [static, inherited]

Definition at line 25 of file SharpDialog.java.

final ImageIcon SharpTools.SharpDialog.okIcon = new ImageIcon(getClass().getResource("/images/ok.gif")) [package, inherited]

Definition at line 27 of file SharpDialog.java.

final JTextField SharpTools.FindDialog.textField = new JTextField(10) [private]

Definition at line 27 of file FindDialog.java.

String SharpTools.FindDialog.typedText = null [private]

Definition at line 30 of file FindDialog.java.

final int SharpTools.SharpDialog.YES_OPTION = JOptionPane.YES_OPTION [static, inherited]

Definition at line 23 of file SharpDialog.java.


The documentation for this class was generated from the following file: