diff options
| author | Paul Buetow <paul@buetow.org> | 2009-02-15 12:59:17 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2009-02-15 12:59:17 +0000 |
| commit | 2a93a612375aa6c8fd35280778624d486a81d2d2 (patch) | |
| tree | 5f0b88be2b6bb5b0eb8a33f5a3e996e2352655c5 /client/inputforms | |
| parent | 3f06de0d35403234601f3bc8325ec8d37071d4a3 (diff) | |
run astyle
Diffstat (limited to 'client/inputforms')
| -rw-r--r-- | client/inputforms/AdvancedSearching.java | 227 | ||||
| -rw-r--r-- | client/inputforms/CreateNewEvent.java | 194 | ||||
| -rw-r--r-- | client/inputforms/EditExistingEvent.java | 256 | ||||
| -rw-r--r-- | client/inputforms/InputForm.java | 144 | ||||
| -rw-r--r-- | client/inputforms/Preferences.java | 154 | ||||
| -rw-r--r-- | client/inputforms/RenameCategory.java | 190 |
6 files changed, 583 insertions, 582 deletions
diff --git a/client/inputforms/AdvancedSearching.java b/client/inputforms/AdvancedSearching.java index 39a8e87..1b39320 100644 --- a/client/inputforms/AdvancedSearching.java +++ b/client/inputforms/AdvancedSearching.java @@ -18,123 +18,124 @@ import shared.remotecall.*; /** * This class contains all the GUI components of the advanced searching dialog. - * Its used for using the andvanced searching options of the client such as using + * Its used for using the andvanced searching options of the client such as using * Java regular expressions on specific elements of the calendar database instead and - * date ranges. + * date ranges. * @author buetow * */ 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); + 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); + } + + //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); - } - - /** - * 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); - } + + netCalendarClient.update(clientRequest); + } } diff --git a/client/inputforms/CreateNewEvent.java b/client/inputforms/CreateNewEvent.java index 5f54e69..430f982 100644 --- a/client/inputforms/CreateNewEvent.java +++ b/client/inputforms/CreateNewEvent.java @@ -21,102 +21,102 @@ import shared.remotecall.*; * */ public class CreateNewEvent extends InputForm { - private final static long serialVersionUID = 1L; - - // Static elements which are the same on all AdvancedSearching objects! - private final static String[] labels = - { "Description: ", "Category: ", "Place: ", "Yearly: ", "Date: "}; - private final static int iNumPairs = labels.length; - private final static int iTextFields = iNumPairs - 2; - private final static int iCheckBoxes = iNumPairs - 1; - - /** - * Create the input form window and show it. - * @param netCalendarClient Specifies the current calendar client session window. * - */ - public CreateNewEvent(NetCalendarClient netCalendarClient) { - super("Create new event", netCalendarClient); - initComponents(); - pack(); - setVisible(true); + private final static long serialVersionUID = 1L; + + // Static elements which are the same on all AdvancedSearching objects! + private final static String[] labels = + { "Description: ", "Category: ", "Place: ", "Yearly: ", "Date: "}; + private final static int iNumPairs = labels.length; + private final static int iTextFields = iNumPairs - 2; + private final static int iCheckBoxes = iNumPairs - 1; + + /** + * Create the input form window and show it. + * @param netCalendarClient Specifies the current calendar client session window. * + */ + public CreateNewEvent(NetCalendarClient netCalendarClient) { + super("Create new event", netCalendarClient); + initComponents(); + 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; + if ( i < iTextFields) { + JTextField textField = new JTextField(InputForm.TEXTFIELD_LENGTH); + textField.addActionListener(actionListenerTextFields); + jComponent = textField; + + } else if (i < iCheckBoxes) { + jComponent = new JCheckBox(); + + } else { + jComponent = new DateSpinner(); + } + + jLable.setLabelFor(jComponent); + jPanel.add(jComponent); + vecFields.add(jComponent); } - - /** - * 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; - if ( i < iTextFields) { - JTextField textField = new JTextField(InputForm.TEXTFIELD_LENGTH); - textField.addActionListener(actionListenerTextFields); - jComponent = textField; - - } 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 - - ActionListener actionListenerButtons = new ActionListener() { - public void actionPerformed(ActionEvent event) { - if (event.getActionCommand().equals(BUTTON_CLEAR)) - for (int i = 0; i < iNumPairs -2; ++i) - ((JTextField) vecFields.get(i)).setText(""); - } - }; - - jButtonClear.addActionListener(actionListenerButtons); - - 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() { - String sCategoryName = ((JTextField) vecFields.get(1)).getText(); - CalendarEvent calendarEvent = new CalendarEvent(sCategoryName); - calendarEvent.setDescription(((JTextField) vecFields.get(0)).getText()); - calendarEvent.setPlace(((JTextField) vecFields.get(2)).getText()); - calendarEvent.setYearly(((JCheckBox) vecFields.get(3)).isSelected()); - calendarEvent.setDate(((DateSpinner) vecFields.get(4)).getDate()); - - ClientRequest clientRequest = new ClientRequest(ClientRequest.ADD_EVENT); - clientRequest.setEvent(calendarEvent); - - ServerRequester.sendClientRequest(clientRequest); - netCalendarClient.updateLast(); - } + + //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 = 0; i < iNumPairs -2; ++i) + ((JTextField) vecFields.get(i)).setText(""); + } + }; + + jButtonClear.addActionListener(actionListenerButtons); + + 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() { + String sCategoryName = ((JTextField) vecFields.get(1)).getText(); + CalendarEvent calendarEvent = new CalendarEvent(sCategoryName); + calendarEvent.setDescription(((JTextField) vecFields.get(0)).getText()); + calendarEvent.setPlace(((JTextField) vecFields.get(2)).getText()); + calendarEvent.setYearly(((JCheckBox) vecFields.get(3)).isSelected()); + calendarEvent.setDate(((DateSpinner) vecFields.get(4)).getDate()); + + ClientRequest clientRequest = new ClientRequest(ClientRequest.ADD_EVENT); + clientRequest.setEvent(calendarEvent); + + ServerRequester.sendClientRequest(clientRequest); + netCalendarClient.updateLast(); + } } diff --git a/client/inputforms/EditExistingEvent.java b/client/inputforms/EditExistingEvent.java index ebb0cc3..6c65aeb 100644 --- a/client/inputforms/EditExistingEvent.java +++ b/client/inputforms/EditExistingEvent.java @@ -21,136 +21,136 @@ import shared.remotecall.*; * */ public class EditExistingEvent extends InputForm { - private final static long serialVersionUID = 1L; - - // Static elements which are the same on all AdvancedSearching objects! - private final static String BUTTON_DELETE = "Delete"; - private final static String[] labels = - { "Event ID: ", "Description: ", "Category: ", "Place: ", "Yearly: ", "Date: "}; - private final static int iNumPairs = labels.length; - private final static int iTextFields = iNumPairs - 2; - private final static int iCheckBoxes = iNumPairs - 1; - - private CalendarEvent originalCalendarEvent; - private Date date; - - /** - * 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 EditExistingEvent(NetCalendarClient netCalendarClient, CalendarEvent originalCalendarEvent) { - super("Edit event", netCalendarClient); - this.originalCalendarEvent = originalCalendarEvent; - this.date = originalCalendarEvent.getDate(); - initComponents(); - setFieldValues(); - pack(); - setVisible(true); + private final static long serialVersionUID = 1L; + + // Static elements which are the same on all AdvancedSearching objects! + private final static String BUTTON_DELETE = "Delete"; + private final static String[] labels = + { "Event ID: ", "Description: ", "Category: ", "Place: ", "Yearly: ", "Date: "}; + private final static int iNumPairs = labels.length; + private final static int iTextFields = iNumPairs - 2; + private final static int iCheckBoxes = iNumPairs - 1; + + private CalendarEvent originalCalendarEvent; + private Date date; + + /** + * 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 EditExistingEvent(NetCalendarClient netCalendarClient, CalendarEvent originalCalendarEvent) { + super("Edit event", netCalendarClient); + this.originalCalendarEvent = originalCalendarEvent; + this.date = originalCalendarEvent.getDate(); + 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; + if ( i < iTextFields) { + JTextField textField = new JTextField(InputForm.TEXTFIELD_LENGTH); + textField.addActionListener(actionListenerTextFields); + jComponent = textField; + + } else if (i < iCheckBoxes) { + jComponent = new JCheckBox(); + + } else { + jComponent = new DateSpinner(date); + } + + jLable.setLabelFor(jComponent); + jPanel.add(jComponent); + vecFields.add(jComponent); } - /** - * 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; - if ( i < iTextFields) { - JTextField textField = new JTextField(InputForm.TEXTFIELD_LENGTH); - textField.addActionListener(actionListenerTextFields); - jComponent = textField; - - } else if (i < iCheckBoxes) { - jComponent = new JCheckBox(); - - } else { - jComponent = new DateSpinner(date); - } - - 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 jButtonDelete = new JButton(BUTTON_DELETE); + + ActionListener actionListenerButtons = new ActionListener() { + public void actionPerformed(ActionEvent event) { + if (event.getActionCommand().equals(BUTTON_CLEAR)) { + for (int i = 1; i < iNumPairs -2; ++i) + ((JTextField) vecFields.get(i)).setText(""); + + } else if (event.getActionCommand().equals(BUTTON_DELETE)) { + netCalendarClient.deleteEvent(originalCalendarEvent); + dispose(); } + } + }; + + jButtonDelete.addActionListener(actionListenerButtons); + jButtonClear.addActionListener(actionListenerButtons); + jPanelButtons.add(jButtonDelete); + + 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 jTextFieldEventID = (JTextField) vecFields.get(0); + jTextFieldEventID.setText(""+originalCalendarEvent.getEventID()); + jTextFieldEventID.setEditable(false); + + ((JTextField) vecFields.get(1)).setText(originalCalendarEvent.getDescription()); + ((JTextField) vecFields.get(2)).setText(originalCalendarEvent.getCategoryName()); + ((JTextField) vecFields.get(3)).setText(originalCalendarEvent.getPlace()); + ((JCheckBox) vecFields.get(4)).setSelected(originalCalendarEvent.isYearly()); + } + + /** + * 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 sCategoryName = ((JTextField) vecFields.get(2)).getText(); + CalendarEvent calendarEvent = new CalendarEvent(sCategoryName); + calendarEvent.setDescription(((JTextField) vecFields.get(1)).getText()); + calendarEvent.setPlace(((JTextField) vecFields.get(3)).getText()); + calendarEvent.setYearly(((JCheckBox) vecFields.get(4)).isSelected()); + calendarEvent.setDate(((DateSpinner) vecFields.get(5)).getDate()); + calendarEvent.setEventID(originalCalendarEvent.getEventID()); + + ClientRequest clientRequest = new ClientRequest(ClientRequest.MODIFY_EVENT); + clientRequest.setEvent(calendarEvent); - //Lay out the panel. - GUIHelper.makeCompactGrid(jPanel, - iNumPairs, 2, // iRows, iCols - 6, 6, // iInitX, iInitY - 6, 6); // iXPad, iYPad - - JButton jButtonDelete = new JButton(BUTTON_DELETE); - - ActionListener actionListenerButtons = new ActionListener() { - public void actionPerformed(ActionEvent event) { - if (event.getActionCommand().equals(BUTTON_CLEAR)) { - for (int i = 1; i < iNumPairs -2; ++i) - ((JTextField) vecFields.get(i)).setText(""); - - } else if (event.getActionCommand().equals(BUTTON_DELETE)) { - netCalendarClient.deleteEvent(originalCalendarEvent); - dispose(); - } - } - }; - - jButtonDelete.addActionListener(actionListenerButtons); - jButtonClear.addActionListener(actionListenerButtons); - jPanelButtons.add(jButtonDelete); - - 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 jTextFieldEventID = (JTextField) vecFields.get(0); - jTextFieldEventID.setText(""+originalCalendarEvent.getEventID()); - jTextFieldEventID.setEditable(false); - - ((JTextField) vecFields.get(1)).setText(originalCalendarEvent.getDescription()); - ((JTextField) vecFields.get(2)).setText(originalCalendarEvent.getCategoryName()); - ((JTextField) vecFields.get(3)).setText(originalCalendarEvent.getPlace()); - ((JCheckBox) vecFields.get(4)).setSelected(originalCalendarEvent.isYearly()); - } - - /** - * 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 sCategoryName = ((JTextField) vecFields.get(2)).getText(); - CalendarEvent calendarEvent = new CalendarEvent(sCategoryName); - calendarEvent.setDescription(((JTextField) vecFields.get(1)).getText()); - calendarEvent.setPlace(((JTextField) vecFields.get(3)).getText()); - calendarEvent.setYearly(((JCheckBox) vecFields.get(4)).isSelected()); - calendarEvent.setDate(((DateSpinner) vecFields.get(5)).getDate()); - calendarEvent.setEventID(originalCalendarEvent.getEventID()); - - ClientRequest clientRequest = new ClientRequest(ClientRequest.MODIFY_EVENT); - clientRequest.setEvent(calendarEvent); - - ServerRequester.sendClientRequest(clientRequest); - netCalendarClient.updateLast(); - } + ServerRequester.sendClientRequest(clientRequest); + netCalendarClient.updateLast(); + } } diff --git a/client/inputforms/InputForm.java b/client/inputforms/InputForm.java index 75a2dec..41004fa 100644 --- a/client/inputforms/InputForm.java +++ b/client/inputforms/InputForm.java @@ -14,80 +14,80 @@ import client.*; * */ public abstract class InputForm extends SubWindow { - protected final static long serialVersionUID = 1L; - protected Vector vecFields; - protected JPanel jPanelButtons; - protected JButton jButtonClear; - protected JButton jButtonApply; - protected JButton jButtonCancel; - protected JButton jButtonOK; - private boolean bApplyHasBeenPressed = false; - - protected final static String BUTTON_CANCEL = "Cancel"; - protected final static String BUTTON_CLEAR = "Clear"; - protected final static String BUTTON_APPLY = "Apply"; - protected final static String BUTTON_OK = "OK"; + protected final static long serialVersionUID = 1L; + protected Vector vecFields; + protected JPanel jPanelButtons; + protected JButton jButtonClear; + protected JButton jButtonApply; + protected JButton jButtonCancel; + protected JButton jButtonOK; + private boolean bApplyHasBeenPressed = false; - protected final static int TEXTFIELD_LENGTH = 20; - - /** - * Creates the input form window and show it. - * @param sTitleText Specifies the title text of this JFrame. - * @param netCalendarClient Specifies the calendar client session object to use. - */ - public InputForm(String sTitleText, NetCalendarClient netCalendarClient) { - super(sTitleText, netCalendarClient); - } + protected final static String BUTTON_CANCEL = "Cancel"; + protected final static String BUTTON_CLEAR = "Clear"; + protected final static String BUTTON_APPLY = "Apply"; + protected final static String BUTTON_OK = "OK"; - /** - * Initializes the input form - * @param sTitleText Specifies the title text of this JFrame. - * @param netCalendarClient Specifies the calendar client session object to use. - */ - public void init(String sTitleText, NetCalendarClient netCalendarClient) { - super.init(sTitleText, netCalendarClient); - } + protected final static int TEXTFIELD_LENGTH = 20; - /** - * Initializes all the GUI components of the implementating class. - */ - protected void initComponents() { - jButtonClear = new JButton(BUTTON_CLEAR); - jButtonApply = new JButton(BUTTON_APPLY); - jButtonCancel = new JButton(BUTTON_CANCEL); - jButtonOK = new JButton(BUTTON_OK); + /** + * Creates the input form window and show it. + * @param sTitleText Specifies the title text of this JFrame. + * @param netCalendarClient Specifies the calendar client session object to use. + */ + public InputForm(String sTitleText, NetCalendarClient netCalendarClient) { + super(sTitleText, netCalendarClient); + } - ActionListener actionListenerButtons = new ActionListener() { - public void actionPerformed(ActionEvent event) { - if (event.getActionCommand().equals(BUTTON_CANCEL)) { - dispose(); - - } else if (event.getActionCommand().equals(BUTTON_APPLY)) { - bApplyHasBeenPressed = true; - submit(); - - } else if (event.getActionCommand().equals(BUTTON_OK)) { - if (!bApplyHasBeenPressed) - submit(); - dispose(); - } - } - }; - - jButtonCancel.addActionListener(actionListenerButtons); - jButtonClear.addActionListener(actionListenerButtons); - jButtonApply.addActionListener(actionListenerButtons); - jButtonOK.addActionListener(actionListenerButtons); - - jPanelButtons = new JPanel(); - jPanelButtons.add(jButtonOK); - jPanelButtons.add(jButtonCancel); - jPanelButtons.add(jButtonApply); - jPanelButtons.add(jButtonClear); - } - - /** - * Submits the input form of the implementating class. - */ - protected abstract void submit(); + /** + * Initializes the input form + * @param sTitleText Specifies the title text of this JFrame. + * @param netCalendarClient Specifies the calendar client session object to use. + */ + public void init(String sTitleText, NetCalendarClient netCalendarClient) { + super.init(sTitleText, netCalendarClient); + } + + /** + * Initializes all the GUI components of the implementating class. + */ + protected void initComponents() { + jButtonClear = new JButton(BUTTON_CLEAR); + jButtonApply = new JButton(BUTTON_APPLY); + jButtonCancel = new JButton(BUTTON_CANCEL); + jButtonOK = new JButton(BUTTON_OK); + + ActionListener actionListenerButtons = new ActionListener() { + public void actionPerformed(ActionEvent event) { + if (event.getActionCommand().equals(BUTTON_CANCEL)) { + dispose(); + + } else if (event.getActionCommand().equals(BUTTON_APPLY)) { + bApplyHasBeenPressed = true; + submit(); + + } else if (event.getActionCommand().equals(BUTTON_OK)) { + if (!bApplyHasBeenPressed) + submit(); + dispose(); + } + } + }; + + jButtonCancel.addActionListener(actionListenerButtons); + jButtonClear.addActionListener(actionListenerButtons); + jButtonApply.addActionListener(actionListenerButtons); + jButtonOK.addActionListener(actionListenerButtons); + + jPanelButtons = new JPanel(); + jPanelButtons.add(jButtonOK); + jPanelButtons.add(jButtonCancel); + jPanelButtons.add(jButtonApply); + jPanelButtons.add(jButtonClear); + } + + /** + * Submits the input form of the implementating class. + */ + protected abstract void submit(); } diff --git a/client/inputforms/Preferences.java b/client/inputforms/Preferences.java index 6be32f3..cefc192 100644 --- a/client/inputforms/Preferences.java +++ b/client/inputforms/Preferences.java @@ -17,83 +17,83 @@ import shared.*; * */ public class Preferences extends InputForm { - private final static long serialVersionUID = 1L; - - private String[] labels = null; - private int iNumPairs = -1; - - /** - * Create the input form window and show it. - * @param netCalendarClient Specifies the current calendar client session window. - */ - public Preferences(NetCalendarClient netCalendarClient) { - super("Preferences", netCalendarClient); - initComponents(); - setFieldValues(); - pack(); - setVisible(true); + private final static long serialVersionUID = 1L; + + private String[] labels = null; + private int iNumPairs = -1; + + /** + * Create the input form window and show it. + * @param netCalendarClient Specifies the current calendar client session window. + */ + public Preferences(NetCalendarClient netCalendarClient) { + super("Preferences", netCalendarClient); + initComponents(); + setFieldValues(); + pack(); + setVisible(true); + } + + /** + * Initializes all the GUI components. + */ + protected void initComponents() { + super.initComponents(); + setFieldValues(); + JPanel jPanel = new JPanel(new SpringLayout()); + + labels = Config.getSortedKeyArray(); + iNumPairs = labels.length; + + 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); + JTextField textField = new JTextField(InputForm.TEXTFIELD_LENGTH); + textField.addActionListener(actionListenerTextFields); + jLable.setLabelFor(textField); + jPanel.add(textField); + vecFields.add(textField); } - /** - * Initializes all the GUI components. - */ - protected void initComponents() { - super.initComponents(); - setFieldValues(); - JPanel jPanel = new JPanel(new SpringLayout()); - - labels = Config.getSortedKeyArray(); - iNumPairs = labels.length; - - 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); - JTextField textField = new JTextField(InputForm.TEXTFIELD_LENGTH); - textField.addActionListener(actionListenerTextFields); - jLable.setLabelFor(textField); - jPanel.add(textField); - vecFields.add(textField); - } - - //Lay out the panel. - GUIHelper.makeCompactGrid(jPanel, - iNumPairs, 2, // iRows, iCols - 6, 6, // iInitX, iInitY - 6, 6); // iXPad, iYPad - - 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 current configuration options. - */ - private void setFieldValues() { - for (int i = 0; i < iNumPairs; ++i) - ((JTextField) vecFields.get(i)).setText(Config.getStringValue(labels[i])); - } - - /** - * 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. It will write all changes to the config.txt file. - */ - protected void submit() { - for (int i = 0; i < iNumPairs; ++i) - Config.setValue(labels[i], ((JTextField) vecFields.get(i)).getText()); - - Config.writeConfigToFile(); - } + //Lay out the panel. + GUIHelper.makeCompactGrid(jPanel, + iNumPairs, 2, // iRows, iCols + 6, 6, // iInitX, iInitY + 6, 6); // iXPad, iYPad + + 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 current configuration options. + */ + private void setFieldValues() { + for (int i = 0; i < iNumPairs; ++i) + ((JTextField) vecFields.get(i)).setText(Config.getStringValue(labels[i])); + } + + /** + * 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. It will write all changes to the config.txt file. + */ + protected void submit() { + for (int i = 0; i < iNumPairs; ++i) + Config.setValue(labels[i], ((JTextField) vecFields.get(i)).getText()); + + Config.writeConfigToFile(); + } } diff --git a/client/inputforms/RenameCategory.java b/client/inputforms/RenameCategory.java index e5e1f29..90c6750 100644 --- a/client/inputforms/RenameCategory.java +++ b/client/inputforms/RenameCategory.java @@ -21,103 +21,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); + 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); } - /** - * 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); + //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(); - //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); - } + ClientRequest clientRequest = new ClientRequest(ClientRequest.RENAME_CATEGORY); + clientRequest.setEvent(calendarEvent); + clientRequest.setString(sNewCategoryName); + ServerRequester.sendClientRequest(clientRequest); + netCalendarClient.updateLast(); + calendarEvent.setCategoryName(sNewCategoryName); + } } |
