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/RenameCategory.java | |
| parent | 177f346a9bbe455dc12fd26dfa2c586585c28c1e (diff) | |
added copyright to header
Diffstat (limited to 'sources/client/inputforms/RenameCategory.java')
| -rw-r--r-- | sources/client/inputforms/RenameCategory.java | 196 |
1 files changed, 100 insertions, 96 deletions
diff --git a/sources/client/inputforms/RenameCategory.java b/sources/client/inputforms/RenameCategory.java index 90c6750..b662754 100644 --- a/sources/client/inputforms/RenameCategory.java +++ b/sources/client/inputforms/RenameCategory.java @@ -1,3 +1,7 @@ +/* NetCalendar 2006, 2009 (c) Dipl.-Inform. (FH) Paul C. Buetow + * http://netcalendar.buetow.org - netcalendar@dev.buetow.org + */ + package client.inputforms; import java.awt.event.*; @@ -21,103 +25,103 @@ import shared.remotecall.*; * */ public class RenameCategory extends InputForm { - private final static long serialVersionUID = 1L; - - // Static elements which are the same on all AdvancedSearching objects! - private final static String[] labels = { "Category name: " }; - private final static int iNumPairs = labels.length; - - private CalendarEvent calendarEvent; - - /** - * Create the input form window and show it. - * @param netCalendarClient Specifies the current calendar client session window. - * @param originalCalendarEvent Specifies the calendar event to modify. - */ - public RenameCategory(NetCalendarClient netCalendarClient, CalendarEvent calendarEvent) { - super("Rename whole category", netCalendarClient); - this.calendarEvent = calendarEvent; - initComponents(); - setFieldValues(); - pack(); - setVisible(true); - } - - /** - * Initializes all the GUI components. - */ - protected void initComponents() { - super.initComponents(); - - JPanel jPanel = new JPanel(new SpringLayout()); - - ActionListener actionListenerTextFields = 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; - JTextField textField = new JTextField(InputForm.TEXTFIELD_LENGTH); - textField.addActionListener(actionListenerTextFields); - jComponent = textField; - 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[] labels = { "Category name: " }; + private final static int iNumPairs = labels.length; + + private CalendarEvent calendarEvent; + + /** + * Create the input form window and show it. + * @param netCalendarClient Specifies the current calendar client session window. + * @param originalCalendarEvent Specifies the calendar event to modify. + */ + public RenameCategory(NetCalendarClient netCalendarClient, CalendarEvent calendarEvent) { + super("Rename whole category", netCalendarClient); + this.calendarEvent = calendarEvent; + initComponents(); + setFieldValues(); + pack(); + setVisible(true); } - //Lay out the panel. - GUIHelper.makeCompactGrid(jPanel, - iNumPairs, 2, // iRows, iCols - 6, 6, // iInitX, iInitY - 6, 6); // iXPad, iYPad - - ActionListener actionListenerButtons = new ActionListener() { - public void actionPerformed(ActionEvent event) { - if (event.getActionCommand().equals(BUTTON_CLEAR)) { - for (int i = 1; i < iNumPairs; ++i) - ((JTextField) vecFields.get(i)).setText(""); + /** + * Initializes all the GUI components. + */ + protected void initComponents() { + super.initComponents(); + + JPanel jPanel = new JPanel(new SpringLayout()); + + ActionListener actionListenerTextFields = 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; + JTextField textField = new JTextField(InputForm.TEXTFIELD_LENGTH); + textField.addActionListener(actionListenerTextFields); + jComponent = textField; + jLable.setLabelFor(jComponent); + jPanel.add(jComponent); + vecFields.add(jComponent); } - } - }; - - jButtonClear.addActionListener(actionListenerButtons); - jPanelButtons.remove(jButtonClear); - - JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); - jSplitPane.setTopComponent(jPanel); - jSplitPane.setBottomComponent(jPanelButtons); - jSplitPane.setDividerSize(0); - - setContentPane(jSplitPane); - } - - /** - * This method sets the fields of the edit frame according to the originalCalendarEvent object. - * The date is not set by this method. Its done by the initComponents method. - */ - private void setFieldValues() { - ((JTextField) vecFields.get(0)).setText(calendarEvent.getCategoryName()); - } - - /** - * 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() { - String sNewCategoryName = ((JTextField) vecFields.get(0)).getText(); - - ClientRequest clientRequest = new ClientRequest(ClientRequest.RENAME_CATEGORY); - clientRequest.setEvent(calendarEvent); - clientRequest.setString(sNewCategoryName); - ServerRequester.sendClientRequest(clientRequest); - netCalendarClient.updateLast(); - calendarEvent.setCategoryName(sNewCategoryName); - } + + //Lay out the panel. + GUIHelper.makeCompactGrid(jPanel, + iNumPairs, 2, // iRows, iCols + 6, 6, // iInitX, iInitY + 6, 6); // iXPad, iYPad + + ActionListener actionListenerButtons = new ActionListener() { + public void actionPerformed(ActionEvent event) { + if (event.getActionCommand().equals(BUTTON_CLEAR)) { + for (int i = 1; i < iNumPairs; ++i) + ((JTextField) vecFields.get(i)).setText(""); + } + } + }; + + jButtonClear.addActionListener(actionListenerButtons); + jPanelButtons.remove(jButtonClear); + + JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); + jSplitPane.setTopComponent(jPanel); + jSplitPane.setBottomComponent(jPanelButtons); + jSplitPane.setDividerSize(0); + + setContentPane(jSplitPane); + } + + /** + * This method sets the fields of the edit frame according to the originalCalendarEvent object. + * The date is not set by this method. Its done by the initComponents method. + */ + private void setFieldValues() { + ((JTextField) vecFields.get(0)).setText(calendarEvent.getCategoryName()); + } + + /** + * 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() { + String sNewCategoryName = ((JTextField) vecFields.get(0)).getText(); + + ClientRequest clientRequest = new ClientRequest(ClientRequest.RENAME_CATEGORY); + clientRequest.setEvent(calendarEvent); + clientRequest.setString(sNewCategoryName); + ServerRequester.sendClientRequest(clientRequest); + netCalendarClient.updateLast(); + calendarEvent.setCategoryName(sNewCategoryName); + } } |
