diff options
| author | Paul Buetow <paul@buetow.org> | 2009-02-18 23:01:21 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2009-02-18 23:01:21 +0000 |
| commit | 89c679eb813611a2ede208b4c8e27c7f596b3be7 (patch) | |
| tree | f44c19435286e78b9e8002990e1b55183a4fbc49 /sources/client/inputforms/AdvancedSearching.java | |
| parent | 177f346a9bbe455dc12fd26dfa2c586585c28c1e (diff) | |
added copyright to header
Diffstat (limited to 'sources/client/inputforms/AdvancedSearching.java')
| -rw-r--r-- | sources/client/inputforms/AdvancedSearching.java | 222 |
1 files changed, 113 insertions, 109 deletions
diff --git a/sources/client/inputforms/AdvancedSearching.java b/sources/client/inputforms/AdvancedSearching.java index 1b39320..54699d6 100644 --- a/sources/client/inputforms/AdvancedSearching.java +++ b/sources/client/inputforms/AdvancedSearching.java @@ -1,3 +1,7 @@ +/* NetCalendar 2006, 2009 (c) Dipl.-Inform. (FH) Paul C. Buetow + * http://netcalendar.buetow.org - netcalendar@dev.buetow.org + */ + /* * A 1.4 application that uses SpringLayout to create a forms-type layout. * Other files required: SpringUtilities.java. @@ -25,117 +29,117 @@ import shared.remotecall.*; * */ public class AdvancedSearching extends InputForm { - private final static long serialVersionUID = 1L; - - // Static elements which are the same on all AdvancedSearching objects! - private final static String BUTTON_GET_ALL = "Get all"; - private final static String[] labels = {"Date string: ", "Description: ", "Category: ", "Place: ", - "Use date ranging: ", "Date range from: ", "Date range to: " - }; - private final static int iNumPairs = labels.length; - private final static int iTextFields = labels.length - 3; - private final static int iCheckBoxes = labels.length - 2; - - /** - * Create the input form window and show it. - * @param netCalendarClient Specifies the current calendar client session window. - */ - public AdvancedSearching(NetCalendarClient netCalendarClient) { - super("Advanced searching", netCalendarClient); - initComponents(); - pack(); - setVisible(true); - } - - /** - * Initializes all the GUI components. - */ - protected void initComponents() { - super.initComponents(); - //Create and populate the panel. - JPanel jPanel = new JPanel(new SpringLayout()); - - ActionListener actionListenerFields = new ActionListener() { - public void actionPerformed(ActionEvent event) { - submit(); - } - }; - - vecFields = new Vector(); - for (int i = 0; i < iNumPairs; ++i) { - JLabel jLable = new JLabel(labels[i], JLabel.TRAILING); - jPanel.add(jLable); - JComponent jComponent = null; - - if (i < iTextFields) { - JTextField jTextField = new JTextField(InputForm.TEXTFIELD_LENGTH); - jTextField.addActionListener(actionListenerFields); - jComponent = jTextField; - - } else if (i < iCheckBoxes) { - jComponent = new JCheckBox(); - - } else { - jComponent = new DateSpinner(); - } - - jLable.setLabelFor(jComponent); - jPanel.add(jComponent); - - vecFields.add(jComponent); + private final static long serialVersionUID = 1L; + + // Static elements which are the same on all AdvancedSearching objects! + private final static String BUTTON_GET_ALL = "Get all"; + private final static String[] labels = {"Date string: ", "Description: ", "Category: ", "Place: ", + "Use date ranging: ", "Date range from: ", "Date range to: " + }; + private final static int iNumPairs = labels.length; + private final static int iTextFields = labels.length - 3; + private final static int iCheckBoxes = labels.length - 2; + + /** + * Create the input form window and show it. + * @param netCalendarClient Specifies the current calendar client session window. + */ + public AdvancedSearching(NetCalendarClient netCalendarClient) { + super("Advanced searching", netCalendarClient); + initComponents(); + pack(); + setVisible(true); } - //Lay out the panel. - GUIHelper.makeCompactGrid(jPanel, - iNumPairs, 2, // iRows, iCols - 6, 6, // iInitX, iInitY - 6, 6); // iXPad, iYPad - - JButton jButtonGetAll = new JButton(BUTTON_GET_ALL); - - ActionListener actionListenerButtons = new ActionListener() { - public void actionPerformed(ActionEvent event) { - if (event.getActionCommand().equals(BUTTON_CLEAR)) - for (int i = 0; i < iTextFields; ++i) - ((JTextField) vecFields.get(i)).setText(""); - - else if (event.getActionCommand().equals(BUTTON_GET_ALL)) - netCalendarClient.update(new ClientRequest(ClientRequest.REQUEST_ALL_EVENTS)); - - } - }; - - jButtonClear.addActionListener(actionListenerButtons); - jButtonGetAll.addActionListener(actionListenerButtons); - jPanelButtons.add(jButtonGetAll); - - JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); - jSplitPane.setTopComponent(jPanel); - jSplitPane.setBottomComponent(jPanelButtons); - jSplitPane.setDividerSize(0); - - setContentPane(jSplitPane); - } - - /** - * This method is invoked if the enter key is pressed or if the submit button - * has been pressed. It starts a client request relating to the user's input of - * the text fields. - */ - protected void submit() { - ClientRequest clientRequest = new ClientRequest(); - clientRequest.setRegexpDate(((JTextField) vecFields.get(0)).getText()); - clientRequest.setRegexpDescription(((JTextField) vecFields.get(1)).getText()); - clientRequest.setRegexpCategory(((JTextField) vecFields.get(2)).getText()); - clientRequest.setRegexpPlace(((JTextField) vecFields.get(3)).getText()); - - JCheckBox jCheckBox = (JCheckBox) vecFields.get(4); - if (jCheckBox.isSelected()) { - Date dateRangeFrom = ((DateSpinner) vecFields.get(5)).getDate(); - Date dateRangeTo = ((DateSpinner) vecFields.get(6)).getDate(); - clientRequest.setDateRange(dateRangeFrom, dateRangeTo); + /** + * Initializes all the GUI components. + */ + protected void initComponents() { + super.initComponents(); + //Create and populate the panel. + JPanel jPanel = new JPanel(new SpringLayout()); + + ActionListener actionListenerFields = new ActionListener() { + public void actionPerformed(ActionEvent event) { + submit(); + } + }; + + vecFields = new Vector(); + for (int i = 0; i < iNumPairs; ++i) { + JLabel jLable = new JLabel(labels[i], JLabel.TRAILING); + jPanel.add(jLable); + JComponent jComponent = null; + + if (i < iTextFields) { + JTextField jTextField = new JTextField(InputForm.TEXTFIELD_LENGTH); + jTextField.addActionListener(actionListenerFields); + jComponent = jTextField; + + } else if (i < iCheckBoxes) { + jComponent = new JCheckBox(); + + } else { + jComponent = new DateSpinner(); + } + + jLable.setLabelFor(jComponent); + jPanel.add(jComponent); + + vecFields.add(jComponent); + } + + //Lay out the panel. + GUIHelper.makeCompactGrid(jPanel, + iNumPairs, 2, // iRows, iCols + 6, 6, // iInitX, iInitY + 6, 6); // iXPad, iYPad + + JButton jButtonGetAll = new JButton(BUTTON_GET_ALL); + + ActionListener actionListenerButtons = new ActionListener() { + public void actionPerformed(ActionEvent event) { + if (event.getActionCommand().equals(BUTTON_CLEAR)) + for (int i = 0; i < iTextFields; ++i) + ((JTextField) vecFields.get(i)).setText(""); + + else if (event.getActionCommand().equals(BUTTON_GET_ALL)) + netCalendarClient.update(new ClientRequest(ClientRequest.REQUEST_ALL_EVENTS)); + + } + }; + + jButtonClear.addActionListener(actionListenerButtons); + jButtonGetAll.addActionListener(actionListenerButtons); + jPanelButtons.add(jButtonGetAll); + + JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); + jSplitPane.setTopComponent(jPanel); + jSplitPane.setBottomComponent(jPanelButtons); + jSplitPane.setDividerSize(0); + + setContentPane(jSplitPane); } - netCalendarClient.update(clientRequest); - } + /** + * This method is invoked if the enter key is pressed or if the submit button + * has been pressed. It starts a client request relating to the user's input of + * the text fields. + */ + protected void submit() { + ClientRequest clientRequest = new ClientRequest(); + clientRequest.setRegexpDate(((JTextField) vecFields.get(0)).getText()); + clientRequest.setRegexpDescription(((JTextField) vecFields.get(1)).getText()); + clientRequest.setRegexpCategory(((JTextField) vecFields.get(2)).getText()); + clientRequest.setRegexpPlace(((JTextField) vecFields.get(3)).getText()); + + JCheckBox jCheckBox = (JCheckBox) vecFields.get(4); + if (jCheckBox.isSelected()) { + Date dateRangeFrom = ((DateSpinner) vecFields.get(5)).getDate(); + Date dateRangeTo = ((DateSpinner) vecFields.get(6)).getDate(); + clientRequest.setDateRange(dateRangeFrom, dateRangeTo); + } + + netCalendarClient.update(clientRequest); + } } |
