summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2009-02-18 23:01:21 +0000
committerPaul Buetow <paul@buetow.org>2009-02-18 23:01:21 +0000
commit89c679eb813611a2ede208b4c8e27c7f596b3be7 (patch)
treef44c19435286e78b9e8002990e1b55183a4fbc49
parent177f346a9bbe455dc12fd26dfa2c586585c28c1e (diff)
added copyright to header
-rw-r--r--LICENSE.txt7
-rw-r--r--Makefile2
-rw-r--r--sources/client/AboutWindow.java80
-rw-r--r--sources/client/CalendarTableCellRenderer.java216
-rw-r--r--sources/client/CalendarTableModel.java912
-rw-r--r--sources/client/InfoWindow.java84
-rw-r--r--sources/client/LicenseWindow.java48
-rw-r--r--sources/client/NetCalendarClient.java1416
-rw-r--r--sources/client/ServerRequester.java102
-rw-r--r--sources/client/SplashScreen.java70
-rw-r--r--sources/client/SubWindow.java150
-rw-r--r--sources/client/helper/DateSpinner.java88
-rw-r--r--sources/client/helper/GUIHelper.java342
-rw-r--r--sources/client/inputforms/AdvancedSearching.java222
-rw-r--r--sources/client/inputforms/CreateNewEvent.java196
-rw-r--r--sources/client/inputforms/EditExistingEvent.java258
-rw-r--r--sources/client/inputforms/InputForm.java134
-rw-r--r--sources/client/inputforms/Preferences.java158
-rw-r--r--sources/client/inputforms/RenameCategory.java196
-rw-r--r--sources/server/CalendarDatabase.java448
-rw-r--r--sources/server/CalendarFormatParser.java466
-rw-r--r--sources/server/NetCalendarServer.java274
-rw-r--r--sources/shared/CalendarCategory.java408
-rw-r--r--sources/shared/CalendarEvent.java648
-rw-r--r--sources/shared/Config.java412
-rw-r--r--sources/shared/DoCallback.java6
-rw-r--r--sources/shared/Main.java216
-rw-r--r--sources/shared/MyDate.java88
-rw-r--r--sources/shared/MyVector.java24
-rw-r--r--sources/shared/remotecall/ClientRequest.java704
-rw-r--r--sources/shared/remotecall/RemoteCall.java34
-rw-r--r--sources/shared/remotecall/ServerResponse.java76
32 files changed, 4304 insertions, 4181 deletions
diff --git a/LICENSE.txt b/LICENSE.txt
index 1fa73f2..8b32486 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,4 +1,7 @@
- GNU GENERAL PUBLIC LICENSE
+NetCalendar (c) by Dipl.-Inform. (FH) Paul C. Buetow
+http://netcalendar.buetow.org - netcalendar@dev.buetow.org
+
+ GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
@@ -336,4 +339,4 @@ This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
-Public License instead of this License. \ No newline at end of file
+Public License instead of this License.
diff --git a/Makefile b/Makefile
index 62e76ba..7d60a04 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@ sslserverrun:
-Djavax.net.ssl.trustStorePassword=$(PASSWORD) \
shared/Main --server-only
astyle:
- find ./ -name '*.java' -exec sh -c 'astyle -s2 {}; rm -f {}.orig' \;
+ find ./ -name '*.java' -exec sh -c 'astyle -s4 {}; rm -f {}.orig' \;
check:
for f in `find ./ -name '*.[ch]'`; do awk -v f=$$f \
'{ if (length($$0) > 80) { \
diff --git a/sources/client/AboutWindow.java b/sources/client/AboutWindow.java
index 38d947e..f55b5e1 100644
--- a/sources/client/AboutWindow.java
+++ b/sources/client/AboutWindow.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;
import shared.*;
@@ -8,43 +12,43 @@ import shared.*;
*
*/
public class AboutWindow extends InfoWindow {
- final static long serialVersionUID = 1L;
- /**
- * Creates the window and shows it.
- * @param sTitleText Specifies the title text of this JFrame.
- * @param netCalendarClient Specifies the calendar client session object to use.
- */
- public AboutWindow(NetCalendarClient netCalendarClient) {
- super(netCalendarClient, "About",
- Config.VERSION + "\n" +
- "(c) 2006, 2009 by Dipl.-Inform. (FH) Paul C. Buetow; " +
- "Web: netcalendar.buetow.org; E-Mail: " + getEmailAddr() + "\n\n" +
- "NetCalendar is a network capable and mostly UNIX /usr/bin/calendar database compatible Calendar application " +
- "programmed in Java. Its initial motivation was a programming project at the Aachen " +
- "University of Applied Sciences (www.fh-aachen.de) for the object oriented " +
- "programming class. But it became much more than just that!\n\n" +
- "Credits:\n\n" +
- "Bernhard Schertl " +
- "for testing and suggestions for improvements; Web: www.b78.org\n\n" +
- "Prof. Dr. rer. nat. H. Fassbender " +
- "for supervision of expert opinion; Web: www.fassbender.fh-aachen.de\n\n" +
- "Florian P. Buetow " +
- "for ideas concerning the splash image; Web: www.florianbuetow.com\n\n" +
- "Kay Czarnotta " +
- "for ideas concerning the icon and an optimization tip for NetCalendar for Mac OS X; Web: eagleeye.byte-welt.net"
- );
- }
+ final static long serialVersionUID = 1L;
+ /**
+ * Creates the window and shows it.
+ * @param sTitleText Specifies the title text of this JFrame.
+ * @param netCalendarClient Specifies the calendar client session object to use.
+ */
+ public AboutWindow(NetCalendarClient netCalendarClient) {
+ super(netCalendarClient, "About",
+ Config.VERSION + "\n" +
+ "(c) 2006, 2009 by Dipl.-Inform. (FH) Paul C. Buetow; " +
+ "Web: netcalendar.buetow.org; E-Mail: " + getEmailAddr() + "\n\n" +
+ "NetCalendar is a network capable and mostly UNIX /usr/bin/calendar database compatible Calendar application " +
+ "programmed in Java. Its initial motivation was a programming project at the Aachen " +
+ "University of Applied Sciences (www.fh-aachen.de) for the object oriented " +
+ "programming class. But it became much more than just that!\n\n" +
+ "Credits:\n\n" +
+ "Bernhard Schertl " +
+ "for testing and suggestions for improvements; Web: www.b78.org\n\n" +
+ "Prof. Dr. rer. nat. H. Fassbender " +
+ "for supervision of expert opinion; Web: www.fassbender.fh-aachen.de\n\n" +
+ "Florian P. Buetow " +
+ "for ideas concerning the splash image; Web: www.florianbuetow.com\n\n" +
+ "Kay Czarnotta " +
+ "for ideas concerning the icon and an optimization tip for NetCalendar for Mac OS X; Web: eagleeye.byte-welt.net"
+ );
+ }
- /**
- * This method simply returns a string containing the contact email address.
- * This method is needed to protect this sourcecode + the email address for
- * internet spam because some spambots try to fetch this address from the
- * cvsweb interface.
- * @return Returns a string containing the contact email address.
- */
- private static String getEmailAddr() {
- String sEmail = "netcalendar at dev dot buetow dot org";
- sEmail = sEmail.replaceAll(" at ", "@");
- return sEmail.replaceAll(" dot ", ".");
- }
+ /**
+ * This method simply returns a string containing the contact email address.
+ * This method is needed to protect this sourcecode + the email address for
+ * internet spam because some spambots try to fetch this address from the
+ * cvsweb interface.
+ * @return Returns a string containing the contact email address.
+ */
+ private static String getEmailAddr() {
+ String sEmail = "netcalendar at dev dot buetow dot org";
+ sEmail = sEmail.replaceAll(" at ", "@");
+ return sEmail.replaceAll(" dot ", ".");
+ }
}
diff --git a/sources/client/CalendarTableCellRenderer.java b/sources/client/CalendarTableCellRenderer.java
index 67a9b67..da8d02b 100644
--- a/sources/client/CalendarTableCellRenderer.java
+++ b/sources/client/CalendarTableCellRenderer.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;
import java.awt.*;
@@ -14,122 +18,122 @@ import shared.*;
* @author buetow
*/
public class CalendarTableCellRenderer extends DefaultTableCellRenderer {
- private static final long serialVersionUID = 1L;
- private CalendarTableModel tableModel;
- // private NetCalendarClient netCalendarClient;
-
- private static final Color SELECTED_BACKGROUND_COLOR;
- private static final Color SELECTED_FOREGROUND_COLOR;
- private static final Color ALREADY_OVER_BACKGROUND_COLOR;
- private static final Color ALREADY_OVER_FOREGROUND_COLOR;
- private static final Color STANDARD_FOREGROUND_COLOR;
- private static final Color BACKGROUND_COLOR_1_DAY;
- private static final Color BACKGROUND_COLOR_7_DAYS;
- private static final Color BACKGROUND_COLOR_28_DAYS;
- private static final Color BACKGROUND_COLOR_168_DAYS;
- private static final Color BACKGROUND_COLOR_365_DAYS;
- private static final Color BACKGROUND_COLOR_MT_365_DAYS;
- private static final Color YEARLY_BACKGROUND_COLOR;
- private static final Color NOT_YEARLY_BACKGROUND_COLOR;
-
-
- private static final long NANOSECONDS_1_DAY;
- private static final long NANOSECONDS_7_DAYS;
- private static final long NANOSECONDS_28_DAYS;
- private static final long NANOSECONDS_168_DAYS;
- private static final long NANOSECONDS_365_DAYS;
-
- // Initialize once, use often!
- static {
- SELECTED_BACKGROUND_COLOR = new Color(0, 0, 0);
- SELECTED_FOREGROUND_COLOR = new Color(255, 255, 255);
- STANDARD_FOREGROUND_COLOR = new Color(0, 0, 0);
- ALREADY_OVER_FOREGROUND_COLOR = SELECTED_BACKGROUND_COLOR;
- ALREADY_OVER_BACKGROUND_COLOR = SELECTED_FOREGROUND_COLOR;
- BACKGROUND_COLOR_1_DAY = new Color(0xff, 0x00, 0x00);
- BACKGROUND_COLOR_7_DAYS = new Color(0xff, 0x6c, 0x00);
- BACKGROUND_COLOR_28_DAYS = new Color(0xff, 0xa5, 0x00);
- BACKGROUND_COLOR_168_DAYS = new Color(0xe7, 0xa5, 0x5e);
- BACKGROUND_COLOR_365_DAYS = new Color(230, 218, 161);
- BACKGROUND_COLOR_MT_365_DAYS = new Color(0xa2, 0x9c, 0x90); // For more than 365 days
-
- YEARLY_BACKGROUND_COLOR = new Color(0x65, 0xa9, 0xe3);
- NOT_YEARLY_BACKGROUND_COLOR = new Color(0x88, 0xe0, 0x90);
-
-
- NANOSECONDS_1_DAY = 3600 * 24 * 1000;
- NANOSECONDS_7_DAYS = NANOSECONDS_1_DAY * 7;
- NANOSECONDS_28_DAYS = NANOSECONDS_7_DAYS * 4;
- NANOSECONDS_168_DAYS = NANOSECONDS_28_DAYS * 6;
- NANOSECONDS_365_DAYS = NANOSECONDS_1_DAY * 365;
- }
-
- /**
- * This method creates a custom table cell renderer for the calendar client.
- * Its coloring the different cells and sets other special display attributes.
- * @param tableModel Specifies the DefaultTableModel object used by the JTable. This is needed to make decisions about displaying a specific cell.
- */
- public CalendarTableCellRenderer(CalendarTableModel tableModel) {
- // this.netCalendarClient = netCalendarClient;
- this.tableModel = tableModel;
- }
-
- /**
- * This method returns the Component object of a specific table cell.
- * @param jTable Specifies the table object of the calendar client frame.
- * @param object Specifies the object which is inside of the specific table cell.
- * @param isSelected Specifies if the current cell is selected or not.
- * @param hasFocus Specifies if the current cell is focused or not.
- * @param iRow Specifies thr row number of the current cell.
- * @param iCol specifies the column number of the current cell.
- * @return Returns the Component object of a specific table cell.
- */
- public Component getTableCellRendererComponent(JTable jTable, Object object,
- boolean isSelected, boolean hasFocus, int iRow, int iCol) {
- JLabel jLable =(JLabel) super.getTableCellRendererComponent(jTable, object, isSelected, hasFocus, iRow, iCol);
-
- //MyVector vecSelected = netCalendarClient.getSelectedIndexes();
-
- //if (vecSelected.hasLike(new Integer(iRow))) {
- if (isSelected) {
- jLable.setBackground(SELECTED_BACKGROUND_COLOR);
- jLable.setForeground(SELECTED_FOREGROUND_COLOR);
- return jLable;
+ private static final long serialVersionUID = 1L;
+ private CalendarTableModel tableModel;
+ // private NetCalendarClient netCalendarClient;
+
+ private static final Color SELECTED_BACKGROUND_COLOR;
+ private static final Color SELECTED_FOREGROUND_COLOR;
+ private static final Color ALREADY_OVER_BACKGROUND_COLOR;
+ private static final Color ALREADY_OVER_FOREGROUND_COLOR;
+ private static final Color STANDARD_FOREGROUND_COLOR;
+ private static final Color BACKGROUND_COLOR_1_DAY;
+ private static final Color BACKGROUND_COLOR_7_DAYS;
+ private static final Color BACKGROUND_COLOR_28_DAYS;
+ private static final Color BACKGROUND_COLOR_168_DAYS;
+ private static final Color BACKGROUND_COLOR_365_DAYS;
+ private static final Color BACKGROUND_COLOR_MT_365_DAYS;
+ private static final Color YEARLY_BACKGROUND_COLOR;
+ private static final Color NOT_YEARLY_BACKGROUND_COLOR;
+
+
+ private static final long NANOSECONDS_1_DAY;
+ private static final long NANOSECONDS_7_DAYS;
+ private static final long NANOSECONDS_28_DAYS;
+ private static final long NANOSECONDS_168_DAYS;
+ private static final long NANOSECONDS_365_DAYS;
+
+ // Initialize once, use often!
+ static {
+ SELECTED_BACKGROUND_COLOR = new Color(0, 0, 0);
+ SELECTED_FOREGROUND_COLOR = new Color(255, 255, 255);
+ STANDARD_FOREGROUND_COLOR = new Color(0, 0, 0);
+ ALREADY_OVER_FOREGROUND_COLOR = SELECTED_BACKGROUND_COLOR;
+ ALREADY_OVER_BACKGROUND_COLOR = SELECTED_FOREGROUND_COLOR;
+ BACKGROUND_COLOR_1_DAY = new Color(0xff, 0x00, 0x00);
+ BACKGROUND_COLOR_7_DAYS = new Color(0xff, 0x6c, 0x00);
+ BACKGROUND_COLOR_28_DAYS = new Color(0xff, 0xa5, 0x00);
+ BACKGROUND_COLOR_168_DAYS = new Color(0xe7, 0xa5, 0x5e);
+ BACKGROUND_COLOR_365_DAYS = new Color(230, 218, 161);
+ BACKGROUND_COLOR_MT_365_DAYS = new Color(0xa2, 0x9c, 0x90); // For more than 365 days
+
+ YEARLY_BACKGROUND_COLOR = new Color(0x65, 0xa9, 0xe3);
+ NOT_YEARLY_BACKGROUND_COLOR = new Color(0x88, 0xe0, 0x90);
+
+
+ NANOSECONDS_1_DAY = 3600 * 24 * 1000;
+ NANOSECONDS_7_DAYS = NANOSECONDS_1_DAY * 7;
+ NANOSECONDS_28_DAYS = NANOSECONDS_7_DAYS * 4;
+ NANOSECONDS_168_DAYS = NANOSECONDS_28_DAYS * 6;
+ NANOSECONDS_365_DAYS = NANOSECONDS_1_DAY * 365;
}
- CalendarEvent calendarEvent = tableModel.getEvent(iRow);
- jLable.setForeground(STANDARD_FOREGROUND_COLOR);
+ /**
+ * This method creates a custom table cell renderer for the calendar client.
+ * Its coloring the different cells and sets other special display attributes.
+ * @param tableModel Specifies the DefaultTableModel object used by the JTable. This is needed to make decisions about displaying a specific cell.
+ */
+ public CalendarTableCellRenderer(CalendarTableModel tableModel) {
+ // this.netCalendarClient = netCalendarClient;
+ this.tableModel = tableModel;
+ }
- if (iCol <= 1) {
- if (!calendarEvent.isYearly())
- jLable.setBackground(NOT_YEARLY_BACKGROUND_COLOR);
- else
- jLable.setBackground(YEARLY_BACKGROUND_COLOR);
+ /**
+ * This method returns the Component object of a specific table cell.
+ * @param jTable Specifies the table object of the calendar client frame.
+ * @param object Specifies the object which is inside of the specific table cell.
+ * @param isSelected Specifies if the current cell is selected or not.
+ * @param hasFocus Specifies if the current cell is focused or not.
+ * @param iRow Specifies thr row number of the current cell.
+ * @param iCol specifies the column number of the current cell.
+ * @return Returns the Component object of a specific table cell.
+ */
+ public Component getTableCellRendererComponent(JTable jTable, Object object,
+ boolean isSelected, boolean hasFocus, int iRow, int iCol) {
+ JLabel jLable =(JLabel) super.getTableCellRendererComponent(jTable, object, isSelected, hasFocus, iRow, iCol);
- return jLable;
- }
+ //MyVector vecSelected = netCalendarClient.getSelectedIndexes();
+
+ //if (vecSelected.hasLike(new Integer(iRow))) {
+ if (isSelected) {
+ jLable.setBackground(SELECTED_BACKGROUND_COLOR);
+ jLable.setForeground(SELECTED_FOREGROUND_COLOR);
+ return jLable;
+ }
- long lCurrentTime = new Date().getTime();
- long lEventTime = calendarEvent.getDate().getTime();
+ CalendarEvent calendarEvent = tableModel.getEvent(iRow);
+ jLable.setForeground(STANDARD_FOREGROUND_COLOR);
- if (lCurrentTime + NANOSECONDS_1_DAY > lEventTime)
- jLable.setBackground(BACKGROUND_COLOR_1_DAY);
+ if (iCol <= 1) {
+ if (!calendarEvent.isYearly())
+ jLable.setBackground(NOT_YEARLY_BACKGROUND_COLOR);
+ else
+ jLable.setBackground(YEARLY_BACKGROUND_COLOR);
- else if (lCurrentTime + NANOSECONDS_7_DAYS > lEventTime)
- jLable.setBackground(BACKGROUND_COLOR_7_DAYS);
+ return jLable;
+ }
- else if (lCurrentTime + NANOSECONDS_28_DAYS > lEventTime)
- jLable.setBackground(BACKGROUND_COLOR_28_DAYS);
+ long lCurrentTime = new Date().getTime();
+ long lEventTime = calendarEvent.getDate().getTime();
- else if (lCurrentTime + NANOSECONDS_168_DAYS > lEventTime)
- jLable.setBackground(BACKGROUND_COLOR_168_DAYS);
+ if (lCurrentTime + NANOSECONDS_1_DAY > lEventTime)
+ jLable.setBackground(BACKGROUND_COLOR_1_DAY);
- else if (lCurrentTime + NANOSECONDS_365_DAYS > lEventTime)
- jLable.setBackground(BACKGROUND_COLOR_365_DAYS);
+ else if (lCurrentTime + NANOSECONDS_7_DAYS > lEventTime)
+ jLable.setBackground(BACKGROUND_COLOR_7_DAYS);
- else
- jLable.setBackground(BACKGROUND_COLOR_MT_365_DAYS);
+ else if (lCurrentTime + NANOSECONDS_28_DAYS > lEventTime)
+ jLable.setBackground(BACKGROUND_COLOR_28_DAYS);
- return jLable;
- }
+ else if (lCurrentTime + NANOSECONDS_168_DAYS > lEventTime)
+ jLable.setBackground(BACKGROUND_COLOR_168_DAYS);
+
+ else if (lCurrentTime + NANOSECONDS_365_DAYS > lEventTime)
+ jLable.setBackground(BACKGROUND_COLOR_365_DAYS);
+
+ else
+ jLable.setBackground(BACKGROUND_COLOR_MT_365_DAYS);
+
+ return jLable;
+ }
}
diff --git a/sources/client/CalendarTableModel.java b/sources/client/CalendarTableModel.java
index 4520c66..20e7967 100644
--- a/sources/client/CalendarTableModel.java
+++ b/sources/client/CalendarTableModel.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;
import javax.swing.table.*;
@@ -13,469 +17,469 @@ import shared.remotecall.*;
*
*/
public final class CalendarTableModel extends AbstractTableModel {
- public static final String NUM_HEADER = "#";
- public static final String DATE_HEADER = "Date";
- public static final String CATEGORY_HEADER = "Category";
- public static final String DESCRIPTION_HEADER = "Description";
- public static final String PLACE_HEADER = "Place";
-
- private static final int iEnumLength = Config.getStringValue("client_max_events").length();
- private static final long serialVersionUID = 1L;
- private static final int iCols = 5; // Num of columns never changes!
- private int iRows = 0;
- private Vector vecEvents;
- private Comparator lastSortComparator = null;
- private JTable jTable;
-
- /**
- * Simple constructor, creates a calendar table model to be used with the JTable of the netcalendar client main window.
- * @param jTable Specifies the JTable object of this table model.
- */
- public CalendarTableModel(JTable jTable) {
- this.jTable = jTable;
- }
-
- /**
- * This method returns the number of columns of the JTable.
- * @return Returns the number of columns of the JTable.
- */
- public int getColumnCount() {
- return iCols;
- }
-
- /**
- * This method retuns the number of rows of the JTable.
- * @return Returns the number of rows of the JTable.
- */
- public int getRowCount() {
- return iRows;
- }
-
- /**
- * This method sets the number of rows of the JTable.
- * @param iRows Specifies the number of rows of the JTable.
- */
- public void setRowCount(int iRows) {
- this.iRows = iRows;
- }
-
- /**
- * This method checks if a cell is editable or not.
- * @param iRow Specifies the tables row.
- * @param iCol Specifies the tables column.
- * @return Returns true if the cell is editable. Else, false will be returned.
- */
- public boolean isCellEditable(int iRow, int iCol) {
- if (iCol > 1)
- return true;
-
- return false;
- }
-
- /**
- * Gets a specific table value
- * @param iRow Specifies the tables row
- * @param iCol Specifies the tables column
- * @return Returns the object at (row,column)
- */
- public Object getValueAt(int iRow, int iCol) {
- CalendarEvent calendarEvent = (CalendarEvent) vecEvents.get(iRow);
-
- switch (iCol) {
- case 0:
- String sEnum = "" + (iRow + 1);
- while (sEnum.length() < iEnumLength)
- sEnum = "0" + sEnum;
- return sEnum;
- case 1:
- return calendarEvent.getDate();
- case 2:
- return calendarEvent.getDescription();
- case 3:
- return calendarEvent.getCategoryName();
- case 4:
- return calendarEvent.getPlace();
+ public static final String NUM_HEADER = "#";
+ public static final String DATE_HEADER = "Date";
+ public static final String CATEGORY_HEADER = "Category";
+ public static final String DESCRIPTION_HEADER = "Description";
+ public static final String PLACE_HEADER = "Place";
+
+ private static final int iEnumLength = Config.getStringValue("client_max_events").length();
+ private static final long serialVersionUID = 1L;
+ private static final int iCols = 5; // Num of columns never changes!
+ private int iRows = 0;
+ private Vector vecEvents;
+ private Comparator lastSortComparator = null;
+ private JTable jTable;
+
+ /**
+ * Simple constructor, creates a calendar table model to be used with the JTable of the netcalendar client main window.
+ * @param jTable Specifies the JTable object of this table model.
+ */
+ public CalendarTableModel(JTable jTable) {
+ this.jTable = jTable;
}
- return "N/A";
- }
-
- /**
- * This function updates the data of the JTable.
- * @param object Specifies the new value.
- * @param iRow Specifies the row of the cell to be updated.
- * @param iCol Specifies the column of the cell to be updated.
- */
- public void setValueAt(Object object, int iRow, int iCol) {
- CalendarEvent calendarEvent = (CalendarEvent) vecEvents.get(iRow);
-
- switch (iCol) {
- case 2:
- calendarEvent.setDescription((String) object);
- break;
- case 3:
- calendarEvent.setCategoryName((String) object);
- break;
- case 4:
- calendarEvent.setPlace((String) object);
- break;
- default:
- return;
+ /**
+ * This method returns the number of columns of the JTable.
+ * @return Returns the number of columns of the JTable.
+ */
+ public int getColumnCount() {
+ return iCols;
}
- runLastSorter();
- jTable.updateUI();
-
- ClientRequest clientRequest = new ClientRequest(ClientRequest.MODIFY_EVENT);
- clientRequest.setEvent(calendarEvent);
- ServerRequester.sendClientRequest(clientRequest);
- }
-
- /**
- * This method returns the class types of a specific table column.
- * @param iCol Specifies the column index to get the class type for.
- * @return Returns the class type of the specified column.
- */
- public Class getColumnClass(int iCol) {
- switch (iCol) {
- case 0:
- return String.class;
- case 1:
- return MyDate.class;
- case 2:
- return String.class;
- case 3:
- return String.class;
- case 4:
- return String.class;
+ /**
+ * This method retuns the number of rows of the JTable.
+ * @return Returns the number of rows of the JTable.
+ */
+ public int getRowCount() {
+ return iRows;
}
- return String.class;
- }
-
- /**
- * This method returns the column header of a specific table column.
- * @param iCol Specifies the column index to get the column header for.
- * @return Returns the header string of the specified column.
- */
- public String getColumnName(int iCol) {
- switch (iCol) {
- case 0:
- return NUM_HEADER;
- case 1:
- return DATE_HEADER;
- case 2:
- return DESCRIPTION_HEADER;
- case 3:
- return CATEGORY_HEADER;
- case 4:
- return PLACE_HEADER;
+ /**
+ * This method sets the number of rows of the JTable.
+ * @param iRows Specifies the number of rows of the JTable.
+ */
+ public void setRowCount(int iRows) {
+ this.iRows = iRows;
}
- return "N/A";
- }
-
- /**
- * This method returns the calendar event which belongs to a specific table row
- * @param iRow Specifies the table row index
- * @return Returns the calendar event
- */
- public CalendarEvent getEvent(int iRow) {
- return (CalendarEvent) vecEvents.get(iRow);
- }
-
- /**
- * This method updates all the value objects (calendar events) of the table.
- * @param vecEvents Specifies the vector of the events to be used.
- */
- public void setEvents(Vector vecEvents) {
- if (vecEvents == null)
- return;
-
- this.vecEvents = vecEvents;
- setRowCount(vecEvents.size());
-
- runLastSorter();
- }
-
- /**
- * This method sorts the data again using the last sorting method being used.
- */
- private void runLastSorter() {
- if (lastSortComparator == null) {
- sortByDate();
-
- } else {
- Collections.sort(vecEvents, lastSortComparator);
- jTable.updateUI();
+ /**
+ * This method checks if a cell is editable or not.
+ * @param iRow Specifies the tables row.
+ * @param iCol Specifies the tables column.
+ * @return Returns true if the cell is editable. Else, false will be returned.
+ */
+ public boolean isCellEditable(int iRow, int iCol) {
+ if (iCol > 1)
+ return true;
+
+ return false;
}
- }
-
- /**
- * Sorts the table content by a specified table column.
- * @param iCol Specifies the table column to sort against.
- */
- public void sortByCol(int iCol) {
- switch (iCol) {
- case 0:
- case 1:
- sortByDate();
- break;
- case 2:
- sortByDescription();
- break;
- case 3:
- sortByCategory();
- break;
- case 4:
- sortByPlace();
- break;
+
+ /**
+ * Gets a specific table value
+ * @param iRow Specifies the tables row
+ * @param iCol Specifies the tables column
+ * @return Returns the object at (row,column)
+ */
+ public Object getValueAt(int iRow, int iCol) {
+ CalendarEvent calendarEvent = (CalendarEvent) vecEvents.get(iRow);
+
+ switch (iCol) {
+ case 0:
+ String sEnum = "" + (iRow + 1);
+ while (sEnum.length() < iEnumLength)
+ sEnum = "0" + sEnum;
+ return sEnum;
+ case 1:
+ return calendarEvent.getDate();
+ case 2:
+ return calendarEvent.getDescription();
+ case 3:
+ return calendarEvent.getCategoryName();
+ case 4:
+ return calendarEvent.getPlace();
+ }
+
+ return "N/A";
}
- }
-
- /**
- * Reverse sorts the table content by a specified table column.
- * @param iCol Specifies the table column to reverse sort against.
- */
- public void reverseSortByCol(int iCol) {
- switch (iCol) {
- case 0:
- case 1:
- reverseSortByDate();
- break;
- case 2:
- reverseSortByDescription();
- break;
- case 3:
- reverseSortByCategory();
- break;
- case 4:
- reverseSortByPlace();
- break;
+
+ /**
+ * This function updates the data of the JTable.
+ * @param object Specifies the new value.
+ * @param iRow Specifies the row of the cell to be updated.
+ * @param iCol Specifies the column of the cell to be updated.
+ */
+ public void setValueAt(Object object, int iRow, int iCol) {
+ CalendarEvent calendarEvent = (CalendarEvent) vecEvents.get(iRow);
+
+ switch (iCol) {
+ case 2:
+ calendarEvent.setDescription((String) object);
+ break;
+ case 3:
+ calendarEvent.setCategoryName((String) object);
+ break;
+ case 4:
+ calendarEvent.setPlace((String) object);
+ break;
+ default:
+ return;
+ }
+
+ runLastSorter();
+ jTable.updateUI();
+
+ ClientRequest clientRequest = new ClientRequest(ClientRequest.MODIFY_EVENT);
+ clientRequest.setEvent(calendarEvent);
+ ServerRequester.sendClientRequest(clientRequest);
+ }
+
+ /**
+ * This method returns the class types of a specific table column.
+ * @param iCol Specifies the column index to get the class type for.
+ * @return Returns the class type of the specified column.
+ */
+ public Class getColumnClass(int iCol) {
+ switch (iCol) {
+ case 0:
+ return String.class;
+ case 1:
+ return MyDate.class;
+ case 2:
+ return String.class;
+ case 3:
+ return String.class;
+ case 4:
+ return String.class;
+ }
+
+ return String.class;
+ }
+
+ /**
+ * This method returns the column header of a specific table column.
+ * @param iCol Specifies the column index to get the column header for.
+ * @return Returns the header string of the specified column.
+ */
+ public String getColumnName(int iCol) {
+ switch (iCol) {
+ case 0:
+ return NUM_HEADER;
+ case 1:
+ return DATE_HEADER;
+ case 2:
+ return DESCRIPTION_HEADER;
+ case 3:
+ return CATEGORY_HEADER;
+ case 4:
+ return PLACE_HEADER;
+ }
+
+ return "N/A";
+ }
+
+ /**
+ * This method returns the calendar event which belongs to a specific table row
+ * @param iRow Specifies the table row index
+ * @return Returns the calendar event
+ */
+ public CalendarEvent getEvent(int iRow) {
+ return (CalendarEvent) vecEvents.get(iRow);
+ }
+
+ /**
+ * This method updates all the value objects (calendar events) of the table.
+ * @param vecEvents Specifies the vector of the events to be used.
+ */
+ public void setEvents(Vector vecEvents) {
+ if (vecEvents == null)
+ return;
+
+ this.vecEvents = vecEvents;
+ setRowCount(vecEvents.size());
+
+ runLastSorter();
+ }
+
+ /**
+ * This method sorts the data again using the last sorting method being used.
+ */
+ private void runLastSorter() {
+ if (lastSortComparator == null) {
+ sortByDate();
+
+ } else {
+ Collections.sort(vecEvents, lastSortComparator);
+ jTable.updateUI();
+ }
+ }
+
+ /**
+ * Sorts the table content by a specified table column.
+ * @param iCol Specifies the table column to sort against.
+ */
+ public void sortByCol(int iCol) {
+ switch (iCol) {
+ case 0:
+ case 1:
+ sortByDate();
+ break;
+ case 2:
+ sortByDescription();
+ break;
+ case 3:
+ sortByCategory();
+ break;
+ case 4:
+ sortByPlace();
+ break;
+ }
+ }
+
+ /**
+ * Reverse sorts the table content by a specified table column.
+ * @param iCol Specifies the table column to reverse sort against.
+ */
+ public void reverseSortByCol(int iCol) {
+ switch (iCol) {
+ case 0:
+ case 1:
+ reverseSortByDate();
+ break;
+ case 2:
+ reverseSortByDescription();
+ break;
+ case 3:
+ reverseSortByCategory();
+ break;
+ case 4:
+ reverseSortByPlace();
+ break;
+ }
+ }
+
+ /**
+ * Sorts the table content by their IDs.
+ */
+ public void sortByID() {
+ Main.statusMessage("Sorting by ID...");
+
+ lastSortComparator = new Comparator() {
+ public int compare(Object objectA, Object objectB) {
+ int i = ((CalendarEvent) objectA).getID();
+ int j = ((CalendarEvent) objectB).getID();
+ if (i == j)
+ return 0;
+ else if (i < j)
+ return -1;
+ else
+ return 1;
+ }
+ public boolean equals(Object object) {
+ return false;
+ }
+ };
+ Collections.sort(vecEvents, lastSortComparator);
+ jTable.updateUI();
+
+ Main.statusMessage("Sorting by date done");
+ }
+
+ /**
+ * Sorts the table content by their dates.
+ */
+ public void sortByDate() {
+ Main.statusMessage("Sorting by date...");
+
+ lastSortComparator = new Comparator() {
+ public int compare(Object objectA, Object objectB) {
+ long l = ((CalendarEvent) objectA).getDate().getTime();
+ long m = ((CalendarEvent) objectB).getDate().getTime();
+ if (l == m)
+ return 0;
+ else if (l < m)
+ return -1;
+ else
+ return 1;
+ }
+ public boolean equals(Object object) {
+ return false;
+ }
+ };
+ Collections.sort(vecEvents, lastSortComparator);
+ jTable.updateUI();
+
+ Main.statusMessage("Sorting by date done");
+ }
+
+ /**
+ * Sorts the table content by their category names.
+ */
+ public void sortByCategory() {
+ Main.statusMessage("Sorting by category...");
+ lastSortComparator = new Comparator() {
+ public int compare(Object objectA, Object objectB) {
+ CalendarEvent eventA = (CalendarEvent) objectA;
+ CalendarEvent eventB = (CalendarEvent) objectB;
+ return eventA.getCategoryName().compareTo(eventB.getCategoryName());
+ }
+ public boolean equals(Object object) {
+ return false;
+ }
+ };
+ Collections.sort(vecEvents, lastSortComparator);
+ jTable.updateUI();
+ Main.statusMessage("Sorting by category done");
+ }
+
+ /**
+ * Sorts the table content by their description texts.
+ */
+ public void sortByDescription() {
+ Main.statusMessage("Sorting by description...");
+ lastSortComparator = new Comparator() {
+ public int compare(Object objectA, Object objectB) {
+ CalendarEvent eventA = (CalendarEvent) objectA;
+ CalendarEvent eventB = (CalendarEvent) objectB;
+ return eventA.getDescription().compareTo(eventB.getDescription());
+ }
+ public boolean equals(Object object) {
+ return false;
+ }
+ };
+ Collections.sort(vecEvents, lastSortComparator);
+ jTable.updateUI();
+ Main.statusMessage("Sorting by description done");
+ }
+
+ /**
+ * Sorts the table content by their places.
+ */
+ public void sortByPlace() {
+ Main.statusMessage("Sorting by place...");
+ lastSortComparator = new Comparator() {
+ public int compare(Object objectA, Object objectB) {
+ CalendarEvent eventA = (CalendarEvent) objectA;
+ CalendarEvent eventB = (CalendarEvent) objectB;
+ return eventA.getPlace().compareTo(eventB.getPlace());
+ }
+ public boolean equals(Object object) {
+ return false;
+ }
+ };
+ Collections.sort(vecEvents, lastSortComparator);
+ jTable.updateUI();
+ Main.statusMessage("Sorting by place done");
+ }
+
+ /**
+ * Reverse sorts the table content by their IDs.
+ */
+ public void reverseSortByID() {
+ Main.statusMessage("Reverse sorting by date...");
+ lastSortComparator = new Comparator() {
+ public int compare(Object objectA, Object objectB) {
+ long i = ((CalendarEvent) objectA).getID();
+ long j = ((CalendarEvent) objectB).getID();
+ if (i == j)
+ return 0;
+ else if (i > j)
+ return -1;
+ else
+ return 1;
+ }
+ public boolean equals(Object object) {
+ return false;
+ }
+ };
+ Collections.sort(vecEvents, lastSortComparator);
+ jTable.updateUI();
+ Main.statusMessage("Reverse sorting by date done");
+ }
+
+ /**
+ * Reverse sorts the table content by their dates.
+ */
+ public void reverseSortByDate() {
+ Main.statusMessage("Reverse sorting by date...");
+ lastSortComparator = new Comparator() {
+ public int compare(Object objectA, Object objectB) {
+ long l = ((CalendarEvent) objectA).getDate().getTime();
+ long m = ((CalendarEvent) objectB).getDate().getTime();
+ if (l == m)
+ return 0;
+ else if (l > m)
+ return -1;
+ else
+ return 1;
+ }
+ public boolean equals(Object object) {
+ return false;
+ }
+ };
+ Collections.sort(vecEvents, lastSortComparator);
+ jTable.updateUI();
+ Main.statusMessage("Reverse sorting by date done");
+ }
+
+ /**
+ * Reverse sorts the table content by their category names.
+ */
+ public void reverseSortByCategory() {
+ Main.statusMessage("Reverse sorting by category...");
+ lastSortComparator = new Comparator() {
+ public int compare(Object objectA, Object objectB) {
+ CalendarEvent eventA = (CalendarEvent) objectA;
+ CalendarEvent eventB = (CalendarEvent) objectB;
+ return eventB.getCategoryName().compareTo(eventA.getCategoryName());
+ }
+ public boolean equals(Object object) {
+ return false;
+ }
+ };
+ Collections.sort(vecEvents, lastSortComparator);
+ jTable.updateUI();
+ Main.statusMessage("Reverse sorting by category done");
+ }
+
+ /**
+ * Reverse sorts the table content by their description texts.
+ */
+ public void reverseSortByDescription() {
+ Main.statusMessage("Reverse sorting by description...");
+ lastSortComparator = new Comparator() {
+ public int compare(Object objectA, Object objectB) {
+ CalendarEvent eventA = (CalendarEvent) objectA;
+ CalendarEvent eventB = (CalendarEvent) objectB;
+ return eventB.getDescription().compareTo(eventA.getDescription());
+ }
+ public boolean equals(Object object) {
+ return false;
+ }
+ };
+ Collections.sort(vecEvents, lastSortComparator);
+ jTable.updateUI();
+ Main.statusMessage("Reverse sorting by description done!");
+ }
+
+ /**
+ * Reverse sorts the table content by their places.
+ */
+ public void reverseSortByPlace() {
+ Main.statusMessage("Reverse sorting by place...");
+ lastSortComparator = new Comparator() {
+ public int compare(Object objectA, Object objectB) {
+ CalendarEvent eventA = (CalendarEvent) objectA;
+ CalendarEvent eventB = (CalendarEvent) objectB;
+ return eventB.getPlace().compareTo(eventA.getPlace());
+ }
+ public boolean equals(Object object) {
+ return false;
+ }
+ };
+ Collections.sort(vecEvents, lastSortComparator);
+ jTable.updateUI();
+ Main.statusMessage("Reverse sorting by place done");
}
- }
-
- /**
- * Sorts the table content by their IDs.
- */
- public void sortByID() {
- Main.statusMessage("Sorting by ID...");
-
- lastSortComparator = new Comparator() {
- public int compare(Object objectA, Object objectB) {
- int i = ((CalendarEvent) objectA).getID();
- int j = ((CalendarEvent) objectB).getID();
- if (i == j)
- return 0;
- else if (i < j)
- return -1;
- else
- return 1;
- }
- public boolean equals(Object object) {
- return false;
- }
- };
- Collections.sort(vecEvents, lastSortComparator);
- jTable.updateUI();
-
- Main.statusMessage("Sorting by date done");
- }
-
- /**
- * Sorts the table content by their dates.
- */
- public void sortByDate() {
- Main.statusMessage("Sorting by date...");
-
- lastSortComparator = new Comparator() {
- public int compare(Object objectA, Object objectB) {
- long l = ((CalendarEvent) objectA).getDate().getTime();
- long m = ((CalendarEvent) objectB).getDate().getTime();
- if (l == m)
- return 0;
- else if (l < m)
- return -1;
- else
- return 1;
- }
- public boolean equals(Object object) {
- return false;
- }
- };
- Collections.sort(vecEvents, lastSortComparator);
- jTable.updateUI();
-
- Main.statusMessage("Sorting by date done");
- }
-
- /**
- * Sorts the table content by their category names.
- */
- public void sortByCategory() {
- Main.statusMessage("Sorting by category...");
- lastSortComparator = new Comparator() {
- public int compare(Object objectA, Object objectB) {
- CalendarEvent eventA = (CalendarEvent) objectA;
- CalendarEvent eventB = (CalendarEvent) objectB;
- return eventA.getCategoryName().compareTo(eventB.getCategoryName());
- }
- public boolean equals(Object object) {
- return false;
- }
- };
- Collections.sort(vecEvents, lastSortComparator);
- jTable.updateUI();
- Main.statusMessage("Sorting by category done");
- }
-
- /**
- * Sorts the table content by their description texts.
- */
- public void sortByDescription() {
- Main.statusMessage("Sorting by description...");
- lastSortComparator = new Comparator() {
- public int compare(Object objectA, Object objectB) {
- CalendarEvent eventA = (CalendarEvent) objectA;
- CalendarEvent eventB = (CalendarEvent) objectB;
- return eventA.getDescription().compareTo(eventB.getDescription());
- }
- public boolean equals(Object object) {
- return false;
- }
- };
- Collections.sort(vecEvents, lastSortComparator);
- jTable.updateUI();
- Main.statusMessage("Sorting by description done");
- }
-
- /**
- * Sorts the table content by their places.
- */
- public void sortByPlace() {
- Main.statusMessage("Sorting by place...");
- lastSortComparator = new Comparator() {
- public int compare(Object objectA, Object objectB) {
- CalendarEvent eventA = (CalendarEvent) objectA;
- CalendarEvent eventB = (CalendarEvent) objectB;
- return eventA.getPlace().compareTo(eventB.getPlace());
- }
- public boolean equals(Object object) {
- return false;
- }
- };
- Collections.sort(vecEvents, lastSortComparator);
- jTable.updateUI();
- Main.statusMessage("Sorting by place done");
- }
-
- /**
- * Reverse sorts the table content by their IDs.
- */
- public void reverseSortByID() {
- Main.statusMessage("Reverse sorting by date...");
- lastSortComparator = new Comparator() {
- public int compare(Object objectA, Object objectB) {
- long i = ((CalendarEvent) objectA).getID();
- long j = ((CalendarEvent) objectB).getID();
- if (i == j)
- return 0;
- else if (i > j)
- return -1;
- else
- return 1;
- }
- public boolean equals(Object object) {
- return false;
- }
- };
- Collections.sort(vecEvents, lastSortComparator);
- jTable.updateUI();
- Main.statusMessage("Reverse sorting by date done");
- }
-
- /**
- * Reverse sorts the table content by their dates.
- */
- public void reverseSortByDate() {
- Main.statusMessage("Reverse sorting by date...");
- lastSortComparator = new Comparator() {
- public int compare(Object objectA, Object objectB) {
- long l = ((CalendarEvent) objectA).getDate().getTime();
- long m = ((CalendarEvent) objectB).getDate().getTime();
- if (l == m)
- return 0;
- else if (l > m)
- return -1;
- else
- return 1;
- }
- public boolean equals(Object object) {
- return false;
- }
- };
- Collections.sort(vecEvents, lastSortComparator);
- jTable.updateUI();
- Main.statusMessage("Reverse sorting by date done");
- }
-
- /**
- * Reverse sorts the table content by their category names.
- */
- public void reverseSortByCategory() {
- Main.statusMessage("Reverse sorting by category...");
- lastSortComparator = new Comparator() {
- public int compare(Object objectA, Object objectB) {
- CalendarEvent eventA = (CalendarEvent) objectA;
- CalendarEvent eventB = (CalendarEvent) objectB;
- return eventB.getCategoryName().compareTo(eventA.getCategoryName());
- }
- public boolean equals(Object object) {
- return false;
- }
- };
- Collections.sort(vecEvents, lastSortComparator);
- jTable.updateUI();
- Main.statusMessage("Reverse sorting by category done");
- }
-
- /**
- * Reverse sorts the table content by their description texts.
- */
- public void reverseSortByDescription() {
- Main.statusMessage("Reverse sorting by description...");
- lastSortComparator = new Comparator() {
- public int compare(Object objectA, Object objectB) {
- CalendarEvent eventA = (CalendarEvent) objectA;
- CalendarEvent eventB = (CalendarEvent) objectB;
- return eventB.getDescription().compareTo(eventA.getDescription());
- }
- public boolean equals(Object object) {
- return false;
- }
- };
- Collections.sort(vecEvents, lastSortComparator);
- jTable.updateUI();
- Main.statusMessage("Reverse sorting by description done!");
- }
-
- /**
- * Reverse sorts the table content by their places.
- */
- public void reverseSortByPlace() {
- Main.statusMessage("Reverse sorting by place...");
- lastSortComparator = new Comparator() {
- public int compare(Object objectA, Object objectB) {
- CalendarEvent eventA = (CalendarEvent) objectA;
- CalendarEvent eventB = (CalendarEvent) objectB;
- return eventB.getPlace().compareTo(eventA.getPlace());
- }
- public boolean equals(Object object) {
- return false;
- }
- };
- Collections.sort(vecEvents, lastSortComparator);
- jTable.updateUI();
- Main.statusMessage("Reverse sorting by place done");
- }
}
diff --git a/sources/client/InfoWindow.java b/sources/client/InfoWindow.java
index bdcc744..2fc7725 100644
--- a/sources/client/InfoWindow.java
+++ b/sources/client/InfoWindow.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;
import java.awt.*;
@@ -10,48 +14,48 @@ import javax.swing.*;
*
*/
public class InfoWindow extends SubWindow {
- final static long serialVersionUID = 1L;
- private String sText;
+ final static long serialVersionUID = 1L;
+ private String sText;
- /**
- * Creates the window and shows it.
- * @param netCalendarClient Specifies the calendar client session object to use.
- * @param jTitle Speicifies the title text to be displayd in the title bar.
- * @param jText Specifies the text to be displayed at the text area.
- */
- public InfoWindow(NetCalendarClient netCalendarClient, String jTitle, String sText) {
- super(jTitle, netCalendarClient);
- this.sText = sText;
- initComponents();
- setResizable(false);
- pack();
- setVisible(true);
- }
+ /**
+ * Creates the window and shows it.
+ * @param netCalendarClient Specifies the calendar client session object to use.
+ * @param jTitle Speicifies the title text to be displayd in the title bar.
+ * @param jText Specifies the text to be displayed at the text area.
+ */
+ public InfoWindow(NetCalendarClient netCalendarClient, String jTitle, String sText) {
+ super(jTitle, netCalendarClient);
+ this.sText = sText;
+ initComponents();
+ setResizable(false);
+ pack();
+ setVisible(true);
+ }
- /**
- * This method initializes all the GUI components.
- */
- protected void initComponents() {
- setSize(306,400);
- JPanel contentPane = (JPanel) getContentPane();
- contentPane.setBackground(Color.BLACK);
+ /**
+ * This method initializes all the GUI components.
+ */
+ protected void initComponents() {
+ setSize(306,400);
+ JPanel contentPane = (JPanel) getContentPane();
+ contentPane.setBackground(Color.BLACK);
- // Build the splash screen
- JLabel jLabel = new JLabel(new ImageIcon("images/netcal.png"));
- contentPane.add(jLabel, BorderLayout.CENTER);
+ // Build the splash screen
+ JLabel jLabel = new JLabel(new ImageIcon("images/netcal.png"));
+ contentPane.add(jLabel, BorderLayout.CENTER);
- JTextArea jTextArea = new JTextArea();
- jTextArea.setEditable(false);
- jTextArea.setBackground(Color.BLACK);
- jTextArea.setForeground(Color.WHITE);
- jTextArea.setLineWrap(true);
- jTextArea.setWrapStyleWord(true);
- jTextArea.setMargin(new Insets(10, 10, 10, 10));
- jTextArea.setText(sText);
- jTextArea.setFocusable(false);
- jTextArea.setEnabled(false);
- JScrollPane jScrollPane = new JScrollPane(jTextArea);
- jScrollPane.setPreferredSize(new Dimension(306, 400-261));
- contentPane.add(jScrollPane, BorderLayout.SOUTH);
- }
+ JTextArea jTextArea = new JTextArea();
+ jTextArea.setEditable(false);
+ jTextArea.setBackground(Color.BLACK);
+ jTextArea.setForeground(Color.WHITE);
+ jTextArea.setLineWrap(true);
+ jTextArea.setWrapStyleWord(true);
+ jTextArea.setMargin(new Insets(10, 10, 10, 10));
+ jTextArea.setText(sText);
+ jTextArea.setFocusable(false);
+ jTextArea.setEnabled(false);
+ JScrollPane jScrollPane = new JScrollPane(jTextArea);
+ jScrollPane.setPreferredSize(new Dimension(306, 400-261));
+ contentPane.add(jScrollPane, BorderLayout.SOUTH);
+ }
}
diff --git a/sources/client/LicenseWindow.java b/sources/client/LicenseWindow.java
index b8a2faa..73562c0 100644
--- a/sources/client/LicenseWindow.java
+++ b/sources/client/LicenseWindow.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;
import shared.*;
@@ -8,26 +12,26 @@ import shared.*;
*
*/
public class LicenseWindow extends InfoWindow {
- final static long serialVersionUID = 1L;
- /**
- * Creates the window and shows it.
- * @param netCalendarClient Specifies the calendar client session object to use.
- */
- public LicenseWindow(NetCalendarClient netCalendarClient) {
- super(netCalendarClient, "License",
- Config.VERSION + "\n" +
- "Copyright (C) 2006, 2009 by Paul C. Buetow\n\n" +
- "This program is free software; you can redistribute it and/or " +
- "modify it under the terms of the GNU General Public License " +
- "as published by the Free Software Foundation; either version 2 " +
- "of the License, or (at your option) any later version.\n\n" +
- "This program is distributed in the hope that it will be useful, " +
- "but WITHOUT ANY WARRANTY; without even the implied warranty of " +
- "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " +
- "GNU General Public License for more details.\n\n" +
- "You should have received a copy of the GNU General Public License " +
- "along with this program; if not, write to the Free Software " +
- "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA."
- );
- }
+ final static long serialVersionUID = 1L;
+ /**
+ * Creates the window and shows it.
+ * @param netCalendarClient Specifies the calendar client session object to use.
+ */
+ public LicenseWindow(NetCalendarClient netCalendarClient) {
+ super(netCalendarClient, "License",
+ Config.VERSION + "\n" +
+ "Copyright (C) 2006, 2009 by Paul C. Buetow\n\n" +
+ "This program is free software; you can redistribute it and/or " +
+ "modify it under the terms of the GNU General Public License " +
+ "as published by the Free Software Foundation; either version 2 " +
+ "of the License, or (at your option) any later version.\n\n" +
+ "This program is distributed in the hope that it will be useful, " +
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of " +
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " +
+ "GNU General Public License for more details.\n\n" +
+ "You should have received a copy of the GNU General Public License " +
+ "along with this program; if not, write to the Free Software " +
+ "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA."
+ );
+ }
}
diff --git a/sources/client/NetCalendarClient.java b/sources/client/NetCalendarClient.java
index 14c6708..caed516 100644
--- a/sources/client/NetCalendarClient.java
+++ b/sources/client/NetCalendarClient.java
@@ -1,3 +1,7 @@
+/* NetCalendar 2006, 2009 (c) Dipl.-Inform. (FH) Paul C. Buetow
+ * http://netcalendar.buetow.org - netcalendar@dev.buetow.org
+ */
+
/**
*/
@@ -19,713 +23,713 @@ import client.inputforms.*;
* @author buetow
*/
public class NetCalendarClient extends JFrame {
- private static final long serialVersionUID = 1L;
- private static int iNextSession = 1;
- private static int iNumCurrentSessions = 0;
- private int iCurrentSession;
- private NetCalendarClient netCalendarClient;
- private Vector vecFrames = new Vector();
-
- // Diverse components
- private ClientRequest lastClientRequest = null;
- protected int iCurrentMouseSelectedRow = 0;
- protected int iCurrentMouseSelectedCol = 0;
-
- // GUI components
- private JMenuBar jMenuBar;
- private JPopupMenu jPopupMenu;
- private CalendarTableModel tableModel;
- private JTable jTable;
-
- private JTextField jTextFieldRegexp;
- private JTextField jTextFieldStatusMessages;
-
- // Some callback objects
- private DoCallback doCallbackEditEvent;
- private DoCallback doCallbackDeleteEvent;
- private DoCallback doCallbackCopyEvent;
- private DoCallback doCallbackDeleteCategory;
- private DoCallback doCallbackRenameCategory;
-
- // Static GUI strings which needs to be specified at least twice
- private final static String DELETE_EVENT = "Delete event(s)";
- private final static String EDIT_EVENT = "Edit event(s)";
- private final static String COPY_EVENT = "Copy event(s)";
- private final static String CREATE_EVENT = "Create new event";
- private final static String DELETE_CATEGORY = "Delete whole category(s)";
- private final static String RENAME_CATEGORY = "Rename whole category(s)";
- private final static String ADVANCED_SEARCH = "Advanced searching";
- private final static String SORT_BY_COL = "Sort by this row";
- private final static String REVERSE_SORT_BY_COL = "Reverse sort by this row";
- private final static String ENTER_REGEXP_HERE ="Enter some regexp search string here...";
-
- /**
- * Standard constructor, creates the client GUI.
- */
- public NetCalendarClient() {
- super(getSessionString(iNextSession) + Config.VERSION);
- this.iCurrentSession = iNextSession++;
-
- // Save a reference of this to allow to access this object through
- // inner-classes
- // (See the "Advanced searching" action listener object for example!)
- this.netCalendarClient = this;
- iNumCurrentSessions++;
-
- initComponents();
- setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- setLocationRelativeTo(null);
- pack();
- setVisible(true);
-
- // Start a default request to the netcalendar server
- update(new ClientRequest(ClientRequest.REQUEST_ALL_EVENTS));
- }
-
- /**
- * Initializes all the GUI components.
- */
- private void initComponents() {
- this.addWindowListener(new WindowListener() {
- public void windowActivated(WindowEvent e) { }
- public void windowClosing(WindowEvent e) {}
- public void windowDeactivated(WindowEvent e) {}
- public void windowDeiconified(WindowEvent e) {}
- public void windowIconified(WindowEvent e) { }
- public void windowOpened(WindowEvent e) {}
- public void windowClosed(WindowEvent e) {
- if (--iNumCurrentSessions == 0)
- Main.exit(0);
-
- Main.infoMessage("Closing a session window");
- }
- });
-
- Container container = getContentPane();
-
- jMenuBar = new JMenuBar();
- setJMenuBar(jMenuBar);
-
- JMenu jMenuSession = new JMenu("Session");
- jMenuBar.add(jMenuSession);
-
- JMenuItem jMenuItemNewWindow = new JMenuItem("New window");
- jMenuSession.add(jMenuItemNewWindow);
- jMenuItemNewWindow.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- new NetCalendarClient();
- }
- });
-
- JMenuItem jMenuItemCloseWindow = new JMenuItem("Close window");
- jMenuSession.add(jMenuItemCloseWindow);
- jMenuItemCloseWindow.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- dispose();
- }
- });
-
- jMenuSession.add(new JSeparator());
-
- JMenuItem jMenuItemPreferences = new JMenuItem("Preferences");
- jMenuSession.add(jMenuItemPreferences);
- jMenuItemPreferences.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- new Preferences(netCalendarClient);
- }
- });
-
- jMenuSession.add(new JSeparator());
-
- JMenuItem jMenuItemQuit = new JMenuItem("Quit");
- jMenuSession.add(jMenuItemQuit);
- jMenuItemQuit.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- System.exit(0);
- }
- });
-
- JMenu jMenuEdit = new JMenu("Edit");
- jMenuBar.add(jMenuEdit);
-
- JMenuItem jMenuItemCreate = new JMenuItem(CREATE_EVENT);
- jMenuEdit.add(jMenuItemCreate);
- jMenuItemCreate.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- new CreateNewEvent(netCalendarClient);
- }
- });
-
- JMenuItem jMenuItemEdit = new JMenuItem(EDIT_EVENT);
- jMenuEdit.add(jMenuItemEdit);
- doCallbackEditEvent = new DoCallback() {
- public void callback(Object obj) {
- new EditExistingEvent(netCalendarClient, (CalendarEvent) obj);
- }
- };
- jMenuItemEdit.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- foreachSelectedEvent(doCallbackEditEvent);
- }
- });
-
- JMenuItem jMenuItemCopy = new JMenuItem(COPY_EVENT);
- jMenuEdit.add(jMenuItemCopy);
- doCallbackCopyEvent = new DoCallback() {
- public void callback(Object obj) {
- CalendarEvent calendarEvent = (CalendarEvent) obj;
- ClientRequest clientRequest = new ClientRequest(ClientRequest.ADD_EVENT);
- clientRequest.setEvent(calendarEvent);
- ServerRequester.sendClientRequest(clientRequest);
- netCalendarClient.updateLast();
- }
- };
- jMenuItemCopy.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- foreachSelectedEvent(doCallbackCopyEvent);
- }
- });
-
- JMenuItem jMenuItemDelete = new JMenuItem(DELETE_EVENT);
- jMenuEdit.add(jMenuItemDelete);
- doCallbackDeleteEvent = new DoCallback() {
- public void callback(Object obj) {
- deleteEvent((CalendarEvent)obj);
- jTable.getSelectionModel().clearSelection();
- }
- };
- jMenuItemDelete.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- foreachSelectedEvent(doCallbackDeleteEvent);
- }
- });
-
- jMenuEdit.add(new JSeparator());
-
- JMenuItem jMenuItemRenameCategory = new JMenuItem(RENAME_CATEGORY);
- jMenuEdit.add(jMenuItemRenameCategory);
- doCallbackRenameCategory = new DoCallback() {
- public void callback(Object obj) {
- new RenameCategory(netCalendarClient, (CalendarEvent) obj);
- jTable.getSelectionModel().clearSelection();
- }
- };
- jMenuItemRenameCategory.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- foreachSelectedEvent(doCallbackRenameCategory);
- }
- });
-
- JMenuItem jMenuItemDeleteCategory = new JMenuItem(DELETE_CATEGORY);
- jMenuEdit.add(jMenuItemDeleteCategory);
- doCallbackDeleteCategory = new DoCallback() {
- public void callback(Object obj) {
- deleteCategory((CalendarEvent)obj);
- jTable.getSelectionModel().clearSelection();
- }
- };
- jMenuItemDeleteCategory.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- foreachSelectedEvent(doCallbackDeleteCategory);
- }
- });
-
-
- JMenu jMenuSorting = new JMenu("Sorting");
- jMenuBar.add(jMenuSorting);
-
- JMenuItem jMenuItemSortByDate = new JMenuItem("Sort by date");
- jMenuSorting.add(jMenuItemSortByDate);
- jMenuItemSortByDate.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- tableModel.sortByDate();
- }
- });
- JMenuItem jMenuItemSortByCategory = new JMenuItem("Sort by category");
- jMenuSorting.add(jMenuItemSortByCategory);
- jMenuItemSortByCategory.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- tableModel.sortByCategory();
- }
- });
- JMenuItem jMenuItemSortByDescr = new JMenuItem("Sort by description");
- jMenuSorting.add(jMenuItemSortByDescr);
- jMenuItemSortByDescr.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- tableModel.sortByDescription();
- }
- });
- JMenuItem jMenuItemSortByPlace = new JMenuItem("Sort by place");
- jMenuSorting.add(jMenuItemSortByPlace);
- jMenuItemSortByPlace.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- tableModel.sortByPlace();
- }
- });
- JMenuItem jMenuItemSortByEventIDs = new JMenuItem("Sort by event IDs");
- jMenuSorting.add(jMenuItemSortByEventIDs);
- jMenuItemSortByEventIDs.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- tableModel.sortByID();
- }
- });
-
- jMenuSorting.add(new JSeparator());
-
- JMenuItem jMenuItemReverseSortByDate = new JMenuItem(
- "Reverse sort by date");
- jMenuSorting.add(jMenuItemReverseSortByDate);
- jMenuItemReverseSortByDate.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- tableModel.reverseSortByDate();
- }
- });
- JMenuItem jMenuItemReverseSortByCategory = new JMenuItem(
- "Reverse sort by category");
- jMenuSorting.add(jMenuItemReverseSortByCategory);
- jMenuItemReverseSortByCategory.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- tableModel.reverseSortByCategory();
- }
- });
- JMenuItem jMenuItemReverseSortByDescr = new JMenuItem(
- "Reverse sort by description");
- jMenuSorting.add(jMenuItemReverseSortByDescr);
- jMenuItemReverseSortByDescr.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- tableModel.reverseSortByDescription();
- }
- });
- JMenuItem jMenuItemReverseSortByPlace = new JMenuItem(
- "Reverse sort by place");
- jMenuSorting.add(jMenuItemReverseSortByPlace);
- jMenuItemReverseSortByPlace.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- tableModel.reverseSortByPlace();
- }
- });
- JMenuItem jMenuItemReverseSortByIDs = new JMenuItem(
- "Reverse sort by event IDs");
- jMenuSorting.add(jMenuItemReverseSortByIDs);
- jMenuItemReverseSortByIDs.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- tableModel.reverseSortByID();
- }
- });
-
- JMenu jMenuServer = new JMenu("Server");
- jMenuBar.add(jMenuServer);
-
- JMenuItem jMenuItemUpdate = new JMenuItem("Update events from server");
- jMenuServer.add(jMenuItemUpdate);
- jMenuItemUpdate.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- update(lastClientRequest);
- }
- });
-
- JMenuItem jMenuItemGetAll = new JMenuItem("Get all events from server");
- jMenuServer.add(jMenuItemGetAll);
- ActionListener actionListenerGetAll = new ActionListener() {
- public void actionPerformed(ActionEvent event) {
+ private static final long serialVersionUID = 1L;
+ private static int iNextSession = 1;
+ private static int iNumCurrentSessions = 0;
+ private int iCurrentSession;
+ private NetCalendarClient netCalendarClient;
+ private Vector vecFrames = new Vector();
+
+ // Diverse components
+ private ClientRequest lastClientRequest = null;
+ protected int iCurrentMouseSelectedRow = 0;
+ protected int iCurrentMouseSelectedCol = 0;
+
+ // GUI components
+ private JMenuBar jMenuBar;
+ private JPopupMenu jPopupMenu;
+ private CalendarTableModel tableModel;
+ private JTable jTable;
+
+ private JTextField jTextFieldRegexp;
+ private JTextField jTextFieldStatusMessages;
+
+ // Some callback objects
+ private DoCallback doCallbackEditEvent;
+ private DoCallback doCallbackDeleteEvent;
+ private DoCallback doCallbackCopyEvent;
+ private DoCallback doCallbackDeleteCategory;
+ private DoCallback doCallbackRenameCategory;
+
+ // Static GUI strings which needs to be specified at least twice
+ private final static String DELETE_EVENT = "Delete event(s)";
+ private final static String EDIT_EVENT = "Edit event(s)";
+ private final static String COPY_EVENT = "Copy event(s)";
+ private final static String CREATE_EVENT = "Create new event";
+ private final static String DELETE_CATEGORY = "Delete whole category(s)";
+ private final static String RENAME_CATEGORY = "Rename whole category(s)";
+ private final static String ADVANCED_SEARCH = "Advanced searching";
+ private final static String SORT_BY_COL = "Sort by this row";
+ private final static String REVERSE_SORT_BY_COL = "Reverse sort by this row";
+ private final static String ENTER_REGEXP_HERE ="Enter some regexp search string here...";
+
+ /**
+ * Standard constructor, creates the client GUI.
+ */
+ public NetCalendarClient() {
+ super(getSessionString(iNextSession) + Config.VERSION);
+ this.iCurrentSession = iNextSession++;
+
+ // Save a reference of this to allow to access this object through
+ // inner-classes
+ // (See the "Advanced searching" action listener object for example!)
+ this.netCalendarClient = this;
+ iNumCurrentSessions++;
+
+ initComponents();
+ setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ setLocationRelativeTo(null);
+ pack();
+ setVisible(true);
+
+ // Start a default request to the netcalendar server
update(new ClientRequest(ClientRequest.REQUEST_ALL_EVENTS));
- }
- };
- jMenuItemGetAll.addActionListener(actionListenerGetAll);
-
- JMenuItem jMenuItemAdvancedSearch = new JMenuItem(
- "Advanced searching for events");
- jMenuServer.add(jMenuItemAdvancedSearch);
- jMenuItemAdvancedSearch.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- new AdvancedSearching(netCalendarClient);
- }
- });
-
- jMenuServer.add(new JSeparator());
-
- JMenuItem jMenuItemReloadDatabase = new JMenuItem("Reload database");
- jMenuServer.add(jMenuItemReloadDatabase);
- jMenuItemReloadDatabase.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- ServerRequester.sendClientRequest(new ClientRequest(
- ClientRequest.RELOAD_DATABASE));
- updateLast();
- }
- });
- JMenuItem jMenuItemFlushDatabase = new JMenuItem("Flush database");
- jMenuServer.add(jMenuItemFlushDatabase);
- jMenuItemFlushDatabase.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- ServerRequester.sendClientRequest(new ClientRequest(
- ClientRequest.FLUSH_DATABASE));
- }
- });
-
- jMenuServer.add(new JSeparator());
-
- JMenuItem jMenuItemShutdownServer = new JMenuItem("Shutdown server");
- jMenuServer.add(jMenuItemShutdownServer);
- jMenuItemShutdownServer.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- ServerRequester.sendClientRequest(new ClientRequest(
- ClientRequest.SHUTDOWN_SERVER));
- }
- });
-
- JMenu jMenuAbout = new JMenu("About");
- jMenuBar.add(jMenuAbout);
-
- JMenuItem jMenuItemAbout = new JMenuItem("About");
- jMenuAbout.add(jMenuItemAbout);
- jMenuItemAbout.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- new AboutWindow(netCalendarClient);
- }
- });
- JMenuItem jMenuItemLicense = new JMenuItem("License");
- jMenuAbout.add(jMenuItemLicense);
- jMenuItemLicense.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- new LicenseWindow(netCalendarClient);
- }
- });
-
- jPopupMenu = new JPopupMenu();
- ActionListener jPopupMenuActionListener = new ActionListener() {
- public void actionPerformed(ActionEvent actionEvent) {
- String sActionCommand = actionEvent.getActionCommand();
- if (sActionCommand.equals(DELETE_EVENT)) {
- foreachSelectedEvent(doCallbackDeleteEvent);
-
- } else if (sActionCommand.equals(CREATE_EVENT)) {
- new CreateNewEvent(netCalendarClient);
-
- } else if (sActionCommand.equals(EDIT_EVENT)) {
- foreachSelectedEvent(doCallbackEditEvent);
-
- } else if (sActionCommand.equals(COPY_EVENT)) {
- foreachSelectedEvent(doCallbackCopyEvent);
-
- } else if (sActionCommand.equals(RENAME_CATEGORY)) {
- foreachSelectedEvent(doCallbackRenameCategory);
-
- } else if (sActionCommand.equals(DELETE_CATEGORY)) {
- foreachSelectedEvent(doCallbackDeleteCategory);
-
- } else if (sActionCommand.equals(ADVANCED_SEARCH)) {
- new AdvancedSearching(netCalendarClient);
-
- } else if (sActionCommand.equals(SORT_BY_COL)) {
- tableModel.sortByCol(iCurrentMouseSelectedCol);
-
- } else if (sActionCommand.equals(REVERSE_SORT_BY_COL)) {
- tableModel.reverseSortByCol(iCurrentMouseSelectedCol);
- }
- }
- };
-
- JMenuItem jMenuItemPopupCreate = new JMenuItem(CREATE_EVENT);
- jMenuItemPopupCreate.addActionListener(jPopupMenuActionListener);
- jPopupMenu.add(jMenuItemPopupCreate);
- JMenuItem jMenuItemPopupEdit = new JMenuItem(EDIT_EVENT);
- jMenuItemPopupEdit.addActionListener(jPopupMenuActionListener);
- jPopupMenu.add(jMenuItemPopupEdit);
- JMenuItem jMenuItemPopupCopy = new JMenuItem(COPY_EVENT);
- jMenuItemPopupCopy.addActionListener(jPopupMenuActionListener);
- jPopupMenu.add(jMenuItemPopupCopy);
- JMenuItem jMenuItemPopupDelete = new JMenuItem(DELETE_EVENT);
- jMenuItemPopupDelete.addActionListener(jPopupMenuActionListener);
- jPopupMenu.add(jMenuItemPopupDelete);
- jPopupMenu.add(new JSeparator());
-
- JMenuItem jMenuItemPopupRenameCategory = new JMenuItem(RENAME_CATEGORY);
- jMenuItemPopupRenameCategory.addActionListener(jPopupMenuActionListener);
- jPopupMenu.add(jMenuItemPopupRenameCategory);
- JMenuItem jMenuItemPopupDeleteCategory = new JMenuItem(DELETE_CATEGORY);
- jMenuItemPopupDeleteCategory.addActionListener(jPopupMenuActionListener);
- jPopupMenu.add(jMenuItemPopupDeleteCategory);
- jPopupMenu.add(new JSeparator());
-
- JMenuItem jMenuItemPopupSort = new JMenuItem(SORT_BY_COL);
- jMenuItemPopupSort.addActionListener(jPopupMenuActionListener);
- jPopupMenu.add(jMenuItemPopupSort);
- JMenuItem jMenuItemPopupReverseSort = new JMenuItem(REVERSE_SORT_BY_COL);
- jMenuItemPopupReverseSort.addActionListener(jPopupMenuActionListener);
- jPopupMenu.add(jMenuItemPopupReverseSort);
- jPopupMenu.add(new JSeparator());
-
- JMenuItem jMenuItemPopupAdvancedSearch = new JMenuItem(ADVANCED_SEARCH);
- jMenuItemPopupAdvancedSearch
- .addActionListener(jPopupMenuActionListener);
- jPopupMenu.add(jMenuItemPopupAdvancedSearch);
-
- jTable = new JTable();
- jTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
-
- jTable.setColumnModel(new DefaultTableColumnModel() {
- private static final long serialVersionUID = 1L;
- // Dont allow column moving!
- public void moveColumn(int iColumnIndex, int iNewColumnIndex) { }
- });
-
- tableModel = new CalendarTableModel(jTable);
- jTable.setModel(tableModel);
- jTable.addMouseListener(new MouseListener() {
- public void mouseClicked(MouseEvent mouseEvent) {
- iCurrentMouseSelectedRow = jTable.rowAtPoint(mouseEvent.getPoint());
- iCurrentMouseSelectedCol = jTable.columnAtPoint(mouseEvent.getPoint());
-
- if (mouseEvent.getButton() != MouseEvent.BUTTON1)
- jPopupMenu.show(jTable, mouseEvent.getX(), mouseEvent.getY());
- }
-
- public void mouseEntered(MouseEvent event) { }
- public void mouseExited(MouseEvent event) {}
- public void mousePressed(MouseEvent event) { }
- public void mouseReleased(MouseEvent event) {
- }
- });
-
- CalendarTableCellRenderer cellRenderer = new CalendarTableCellRenderer(tableModel);
-
- TableColumn column = jTable.getColumn(CalendarTableModel.NUM_HEADER);
- column.setMaxWidth(Config.getStringValue("client_max_events").length() * 10);
- column.setResizable(false);
- column.setCellRenderer(cellRenderer);
-
- column = jTable.getColumn(CalendarTableModel.CATEGORY_HEADER);
- column.setPreferredWidth(10);
- column.setCellRenderer(cellRenderer);
-
- column = jTable.getColumn(CalendarTableModel.PLACE_HEADER);
- column.setPreferredWidth(10);
- column.setCellRenderer(cellRenderer);
-
- jTable.getColumn(CalendarTableModel.DATE_HEADER).setCellRenderer(cellRenderer);
- jTable.getColumn(CalendarTableModel.DESCRIPTION_HEADER).setCellRenderer(cellRenderer);
-
- jTextFieldRegexp = new JTextField();
- jTextFieldRegexp.setText(ENTER_REGEXP_HERE);
- jTextFieldRegexp.setEnabled(false);
-
- ActionListener actionListenerSearchRegexp = new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- ClientRequest clientRequest = new ClientRequest();
- clientRequest.setRegexpAll(jTextFieldRegexp.getText());
- clientRequest.setMainRegexp(true);
- jTextFieldRegexp.setText("");
+ }
+
+ /**
+ * Initializes all the GUI components.
+ */
+ private void initComponents() {
+ this.addWindowListener(new WindowListener() {
+ public void windowActivated(WindowEvent e) { }
+ public void windowClosing(WindowEvent e) {}
+ public void windowDeactivated(WindowEvent e) {}
+ public void windowDeiconified(WindowEvent e) {}
+ public void windowIconified(WindowEvent e) { }
+ public void windowOpened(WindowEvent e) {}
+ public void windowClosed(WindowEvent e) {
+ if (--iNumCurrentSessions == 0)
+ Main.exit(0);
+
+ Main.infoMessage("Closing a session window");
+ }
+ });
+
+ Container container = getContentPane();
+
+ jMenuBar = new JMenuBar();
+ setJMenuBar(jMenuBar);
+
+ JMenu jMenuSession = new JMenu("Session");
+ jMenuBar.add(jMenuSession);
+
+ JMenuItem jMenuItemNewWindow = new JMenuItem("New window");
+ jMenuSession.add(jMenuItemNewWindow);
+ jMenuItemNewWindow.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ new NetCalendarClient();
+ }
+ });
+
+ JMenuItem jMenuItemCloseWindow = new JMenuItem("Close window");
+ jMenuSession.add(jMenuItemCloseWindow);
+ jMenuItemCloseWindow.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ dispose();
+ }
+ });
+
+ jMenuSession.add(new JSeparator());
+
+ JMenuItem jMenuItemPreferences = new JMenuItem("Preferences");
+ jMenuSession.add(jMenuItemPreferences);
+ jMenuItemPreferences.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ new Preferences(netCalendarClient);
+ }
+ });
+
+ jMenuSession.add(new JSeparator());
+
+ JMenuItem jMenuItemQuit = new JMenuItem("Quit");
+ jMenuSession.add(jMenuItemQuit);
+ jMenuItemQuit.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ System.exit(0);
+ }
+ });
+
+ JMenu jMenuEdit = new JMenu("Edit");
+ jMenuBar.add(jMenuEdit);
+
+ JMenuItem jMenuItemCreate = new JMenuItem(CREATE_EVENT);
+ jMenuEdit.add(jMenuItemCreate);
+ jMenuItemCreate.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ new CreateNewEvent(netCalendarClient);
+ }
+ });
+
+ JMenuItem jMenuItemEdit = new JMenuItem(EDIT_EVENT);
+ jMenuEdit.add(jMenuItemEdit);
+ doCallbackEditEvent = new DoCallback() {
+ public void callback(Object obj) {
+ new EditExistingEvent(netCalendarClient, (CalendarEvent) obj);
+ }
+ };
+ jMenuItemEdit.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ foreachSelectedEvent(doCallbackEditEvent);
+ }
+ });
+
+ JMenuItem jMenuItemCopy = new JMenuItem(COPY_EVENT);
+ jMenuEdit.add(jMenuItemCopy);
+ doCallbackCopyEvent = new DoCallback() {
+ public void callback(Object obj) {
+ CalendarEvent calendarEvent = (CalendarEvent) obj;
+ ClientRequest clientRequest = new ClientRequest(ClientRequest.ADD_EVENT);
+ clientRequest.setEvent(calendarEvent);
+ ServerRequester.sendClientRequest(clientRequest);
+ netCalendarClient.updateLast();
+ }
+ };
+ jMenuItemCopy.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ foreachSelectedEvent(doCallbackCopyEvent);
+ }
+ });
+
+ JMenuItem jMenuItemDelete = new JMenuItem(DELETE_EVENT);
+ jMenuEdit.add(jMenuItemDelete);
+ doCallbackDeleteEvent = new DoCallback() {
+ public void callback(Object obj) {
+ deleteEvent((CalendarEvent)obj);
+ jTable.getSelectionModel().clearSelection();
+ }
+ };
+ jMenuItemDelete.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ foreachSelectedEvent(doCallbackDeleteEvent);
+ }
+ });
+
+ jMenuEdit.add(new JSeparator());
+
+ JMenuItem jMenuItemRenameCategory = new JMenuItem(RENAME_CATEGORY);
+ jMenuEdit.add(jMenuItemRenameCategory);
+ doCallbackRenameCategory = new DoCallback() {
+ public void callback(Object obj) {
+ new RenameCategory(netCalendarClient, (CalendarEvent) obj);
+ jTable.getSelectionModel().clearSelection();
+ }
+ };
+ jMenuItemRenameCategory.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ foreachSelectedEvent(doCallbackRenameCategory);
+ }
+ });
+
+ JMenuItem jMenuItemDeleteCategory = new JMenuItem(DELETE_CATEGORY);
+ jMenuEdit.add(jMenuItemDeleteCategory);
+ doCallbackDeleteCategory = new DoCallback() {
+ public void callback(Object obj) {
+ deleteCategory((CalendarEvent)obj);
+ jTable.getSelectionModel().clearSelection();
+ }
+ };
+ jMenuItemDeleteCategory.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ foreachSelectedEvent(doCallbackDeleteCategory);
+ }
+ });
+
+
+ JMenu jMenuSorting = new JMenu("Sorting");
+ jMenuBar.add(jMenuSorting);
+
+ JMenuItem jMenuItemSortByDate = new JMenuItem("Sort by date");
+ jMenuSorting.add(jMenuItemSortByDate);
+ jMenuItemSortByDate.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ tableModel.sortByDate();
+ }
+ });
+ JMenuItem jMenuItemSortByCategory = new JMenuItem("Sort by category");
+ jMenuSorting.add(jMenuItemSortByCategory);
+ jMenuItemSortByCategory.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ tableModel.sortByCategory();
+ }
+ });
+ JMenuItem jMenuItemSortByDescr = new JMenuItem("Sort by description");
+ jMenuSorting.add(jMenuItemSortByDescr);
+ jMenuItemSortByDescr.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ tableModel.sortByDescription();
+ }
+ });
+ JMenuItem jMenuItemSortByPlace = new JMenuItem("Sort by place");
+ jMenuSorting.add(jMenuItemSortByPlace);
+ jMenuItemSortByPlace.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ tableModel.sortByPlace();
+ }
+ });
+ JMenuItem jMenuItemSortByEventIDs = new JMenuItem("Sort by event IDs");
+ jMenuSorting.add(jMenuItemSortByEventIDs);
+ jMenuItemSortByEventIDs.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ tableModel.sortByID();
+ }
+ });
+
+ jMenuSorting.add(new JSeparator());
+
+ JMenuItem jMenuItemReverseSortByDate = new JMenuItem(
+ "Reverse sort by date");
+ jMenuSorting.add(jMenuItemReverseSortByDate);
+ jMenuItemReverseSortByDate.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ tableModel.reverseSortByDate();
+ }
+ });
+ JMenuItem jMenuItemReverseSortByCategory = new JMenuItem(
+ "Reverse sort by category");
+ jMenuSorting.add(jMenuItemReverseSortByCategory);
+ jMenuItemReverseSortByCategory.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ tableModel.reverseSortByCategory();
+ }
+ });
+ JMenuItem jMenuItemReverseSortByDescr = new JMenuItem(
+ "Reverse sort by description");
+ jMenuSorting.add(jMenuItemReverseSortByDescr);
+ jMenuItemReverseSortByDescr.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ tableModel.reverseSortByDescription();
+ }
+ });
+ JMenuItem jMenuItemReverseSortByPlace = new JMenuItem(
+ "Reverse sort by place");
+ jMenuSorting.add(jMenuItemReverseSortByPlace);
+ jMenuItemReverseSortByPlace.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ tableModel.reverseSortByPlace();
+ }
+ });
+ JMenuItem jMenuItemReverseSortByIDs = new JMenuItem(
+ "Reverse sort by event IDs");
+ jMenuSorting.add(jMenuItemReverseSortByIDs);
+ jMenuItemReverseSortByIDs.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ tableModel.reverseSortByID();
+ }
+ });
+
+ JMenu jMenuServer = new JMenu("Server");
+ jMenuBar.add(jMenuServer);
+
+ JMenuItem jMenuItemUpdate = new JMenuItem("Update events from server");
+ jMenuServer.add(jMenuItemUpdate);
+ jMenuItemUpdate.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ update(lastClientRequest);
+ }
+ });
+
+ JMenuItem jMenuItemGetAll = new JMenuItem("Get all events from server");
+ jMenuServer.add(jMenuItemGetAll);
+ ActionListener actionListenerGetAll = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ update(new ClientRequest(ClientRequest.REQUEST_ALL_EVENTS));
+ }
+ };
+ jMenuItemGetAll.addActionListener(actionListenerGetAll);
+
+ JMenuItem jMenuItemAdvancedSearch = new JMenuItem(
+ "Advanced searching for events");
+ jMenuServer.add(jMenuItemAdvancedSearch);
+ jMenuItemAdvancedSearch.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ new AdvancedSearching(netCalendarClient);
+ }
+ });
+
+ jMenuServer.add(new JSeparator());
+
+ JMenuItem jMenuItemReloadDatabase = new JMenuItem("Reload database");
+ jMenuServer.add(jMenuItemReloadDatabase);
+ jMenuItemReloadDatabase.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ ServerRequester.sendClientRequest(new ClientRequest(
+ ClientRequest.RELOAD_DATABASE));
+ updateLast();
+ }
+ });
+ JMenuItem jMenuItemFlushDatabase = new JMenuItem("Flush database");
+ jMenuServer.add(jMenuItemFlushDatabase);
+ jMenuItemFlushDatabase.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ ServerRequester.sendClientRequest(new ClientRequest(
+ ClientRequest.FLUSH_DATABASE));
+ }
+ });
+
+ jMenuServer.add(new JSeparator());
+
+ JMenuItem jMenuItemShutdownServer = new JMenuItem("Shutdown server");
+ jMenuServer.add(jMenuItemShutdownServer);
+ jMenuItemShutdownServer.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ ServerRequester.sendClientRequest(new ClientRequest(
+ ClientRequest.SHUTDOWN_SERVER));
+ }
+ });
+
+ JMenu jMenuAbout = new JMenu("About");
+ jMenuBar.add(jMenuAbout);
+
+ JMenuItem jMenuItemAbout = new JMenuItem("About");
+ jMenuAbout.add(jMenuItemAbout);
+ jMenuItemAbout.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ new AboutWindow(netCalendarClient);
+ }
+ });
+ JMenuItem jMenuItemLicense = new JMenuItem("License");
+ jMenuAbout.add(jMenuItemLicense);
+ jMenuItemLicense.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ new LicenseWindow(netCalendarClient);
+ }
+ });
+
+ jPopupMenu = new JPopupMenu();
+ ActionListener jPopupMenuActionListener = new ActionListener() {
+ public void actionPerformed(ActionEvent actionEvent) {
+ String sActionCommand = actionEvent.getActionCommand();
+ if (sActionCommand.equals(DELETE_EVENT)) {
+ foreachSelectedEvent(doCallbackDeleteEvent);
+
+ } else if (sActionCommand.equals(CREATE_EVENT)) {
+ new CreateNewEvent(netCalendarClient);
+
+ } else if (sActionCommand.equals(EDIT_EVENT)) {
+ foreachSelectedEvent(doCallbackEditEvent);
+
+ } else if (sActionCommand.equals(COPY_EVENT)) {
+ foreachSelectedEvent(doCallbackCopyEvent);
+
+ } else if (sActionCommand.equals(RENAME_CATEGORY)) {
+ foreachSelectedEvent(doCallbackRenameCategory);
+
+ } else if (sActionCommand.equals(DELETE_CATEGORY)) {
+ foreachSelectedEvent(doCallbackDeleteCategory);
+
+ } else if (sActionCommand.equals(ADVANCED_SEARCH)) {
+ new AdvancedSearching(netCalendarClient);
+
+ } else if (sActionCommand.equals(SORT_BY_COL)) {
+ tableModel.sortByCol(iCurrentMouseSelectedCol);
+
+ } else if (sActionCommand.equals(REVERSE_SORT_BY_COL)) {
+ tableModel.reverseSortByCol(iCurrentMouseSelectedCol);
+ }
+ }
+ };
+
+ JMenuItem jMenuItemPopupCreate = new JMenuItem(CREATE_EVENT);
+ jMenuItemPopupCreate.addActionListener(jPopupMenuActionListener);
+ jPopupMenu.add(jMenuItemPopupCreate);
+ JMenuItem jMenuItemPopupEdit = new JMenuItem(EDIT_EVENT);
+ jMenuItemPopupEdit.addActionListener(jPopupMenuActionListener);
+ jPopupMenu.add(jMenuItemPopupEdit);
+ JMenuItem jMenuItemPopupCopy = new JMenuItem(COPY_EVENT);
+ jMenuItemPopupCopy.addActionListener(jPopupMenuActionListener);
+ jPopupMenu.add(jMenuItemPopupCopy);
+ JMenuItem jMenuItemPopupDelete = new JMenuItem(DELETE_EVENT);
+ jMenuItemPopupDelete.addActionListener(jPopupMenuActionListener);
+ jPopupMenu.add(jMenuItemPopupDelete);
+ jPopupMenu.add(new JSeparator());
+
+ JMenuItem jMenuItemPopupRenameCategory = new JMenuItem(RENAME_CATEGORY);
+ jMenuItemPopupRenameCategory.addActionListener(jPopupMenuActionListener);
+ jPopupMenu.add(jMenuItemPopupRenameCategory);
+ JMenuItem jMenuItemPopupDeleteCategory = new JMenuItem(DELETE_CATEGORY);
+ jMenuItemPopupDeleteCategory.addActionListener(jPopupMenuActionListener);
+ jPopupMenu.add(jMenuItemPopupDeleteCategory);
+ jPopupMenu.add(new JSeparator());
+
+ JMenuItem jMenuItemPopupSort = new JMenuItem(SORT_BY_COL);
+ jMenuItemPopupSort.addActionListener(jPopupMenuActionListener);
+ jPopupMenu.add(jMenuItemPopupSort);
+ JMenuItem jMenuItemPopupReverseSort = new JMenuItem(REVERSE_SORT_BY_COL);
+ jMenuItemPopupReverseSort.addActionListener(jPopupMenuActionListener);
+ jPopupMenu.add(jMenuItemPopupReverseSort);
+ jPopupMenu.add(new JSeparator());
+
+ JMenuItem jMenuItemPopupAdvancedSearch = new JMenuItem(ADVANCED_SEARCH);
+ jMenuItemPopupAdvancedSearch
+ .addActionListener(jPopupMenuActionListener);
+ jPopupMenu.add(jMenuItemPopupAdvancedSearch);
+
+ jTable = new JTable();
+ jTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+
+ jTable.setColumnModel(new DefaultTableColumnModel() {
+ private static final long serialVersionUID = 1L;
+ // Dont allow column moving!
+ public void moveColumn(int iColumnIndex, int iNewColumnIndex) { }
+ });
+
+ tableModel = new CalendarTableModel(jTable);
+ jTable.setModel(tableModel);
+ jTable.addMouseListener(new MouseListener() {
+ public void mouseClicked(MouseEvent mouseEvent) {
+ iCurrentMouseSelectedRow = jTable.rowAtPoint(mouseEvent.getPoint());
+ iCurrentMouseSelectedCol = jTable.columnAtPoint(mouseEvent.getPoint());
+
+ if (mouseEvent.getButton() != MouseEvent.BUTTON1)
+ jPopupMenu.show(jTable, mouseEvent.getX(), mouseEvent.getY());
+ }
+
+ public void mouseEntered(MouseEvent event) { }
+ public void mouseExited(MouseEvent event) {}
+ public void mousePressed(MouseEvent event) { }
+ public void mouseReleased(MouseEvent event) {
+ }
+ });
+
+ CalendarTableCellRenderer cellRenderer = new CalendarTableCellRenderer(tableModel);
+
+ TableColumn column = jTable.getColumn(CalendarTableModel.NUM_HEADER);
+ column.setMaxWidth(Config.getStringValue("client_max_events").length() * 10);
+ column.setResizable(false);
+ column.setCellRenderer(cellRenderer);
+
+ column = jTable.getColumn(CalendarTableModel.CATEGORY_HEADER);
+ column.setPreferredWidth(10);
+ column.setCellRenderer(cellRenderer);
+
+ column = jTable.getColumn(CalendarTableModel.PLACE_HEADER);
+ column.setPreferredWidth(10);
+ column.setCellRenderer(cellRenderer);
+
+ jTable.getColumn(CalendarTableModel.DATE_HEADER).setCellRenderer(cellRenderer);
+ jTable.getColumn(CalendarTableModel.DESCRIPTION_HEADER).setCellRenderer(cellRenderer);
+
+ jTextFieldRegexp = new JTextField();
+ jTextFieldRegexp.setText(ENTER_REGEXP_HERE);
+ jTextFieldRegexp.setEnabled(false);
+
+ ActionListener actionListenerSearchRegexp = new ActionListener() {
+ public void actionPerformed(ActionEvent event) {
+ ClientRequest clientRequest = new ClientRequest();
+ clientRequest.setRegexpAll(jTextFieldRegexp.getText());
+ clientRequest.setMainRegexp(true);
+ jTextFieldRegexp.setText("");
+ update(ServerRequester.sendClientRequest(clientRequest));
+ lastClientRequest = clientRequest;
+ }
+ };
+ MouseListener mouseListenerSearchRegexp = new MouseListener() {
+ public void mouseClicked(MouseEvent mouseEvent) {}
+ public void mousePressed(MouseEvent mouseEvent) {}
+ public void mouseReleased(MouseEvent mouseEvent) {}
+ public void mouseExited(MouseEvent mouseEvent) {
+ if (jTextFieldRegexp.getText().equals("")) {
+ jTextFieldRegexp.setText(ENTER_REGEXP_HERE);
+ jTextFieldRegexp.setEnabled(false);
+ }
+ }
+ public void mouseEntered(MouseEvent mouseEvent) {
+ if (!jTextFieldRegexp.isEnabled()) {
+ jTextFieldRegexp.setText("");
+ jTextFieldRegexp.setEnabled(true);
+ }
+ }
+ };
+
+ jTextFieldRegexp.addActionListener(actionListenerSearchRegexp);
+ jTextFieldRegexp.addMouseListener(mouseListenerSearchRegexp);
+
+ JButton jButtonSearch = new JButton("Search");
+ jButtonSearch.addActionListener(actionListenerSearchRegexp);
+ jButtonSearch.addMouseListener(mouseListenerSearchRegexp);
+
+ JButton jButtonGetAll = new JButton("Get all");
+ jButtonGetAll.addActionListener(actionListenerGetAll);
+
+ // Init split panes
+ JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
+ jSplitPane.setResizeWeight(1);
+ jSplitPane.setDividerSize(0);
+
+ JSplitPane jSplitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
+ jSplitPane2.setResizeWeight(1);
+ jSplitPane2.setDividerSize(0);
+
+ JSplitPane jSplitPane3 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
+ jSplitPane3.setResizeWeight(1);
+ jSplitPane3.setDividerSize(0);
+
+ JSplitPane jSplitPane4 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
+ jSplitPane4.setDividerSize(0);
+
+ // Init components
+ JScrollPane jScrollPaneTable = new JScrollPane(jTable);
+
+ jTextFieldStatusMessages = new JTextField("Welcome to "
+ + Config.VERSION);
+ jTextFieldStatusMessages.setEditable(false);
+
+ // Set split pane components
+ jSplitPane.setTopComponent(jScrollPaneTable);
+ jSplitPane.setBottomComponent(jSplitPane2);
+
+ jSplitPane2.setTopComponent(jSplitPane3);
+ jSplitPane2.setBottomComponent(jTextFieldStatusMessages);
+
+ JPanel jPanelButtons = new JPanel();
+ jPanelButtons.add(jButtonSearch);
+ jPanelButtons.add(jButtonGetAll);
+
+ jSplitPane3.setLeftComponent(jTextFieldRegexp);
+ jSplitPane3.setRightComponent(jPanelButtons);
+
+ container.add(jSplitPane);
+ }
+
+ /**
+ * This method sends a client request object to the server and used the server response object
+ * to update the JTable ith its new values using the table model.
+ * @param clientRequest Specifies the client request object to use for the updating.
+ */
+ public void update(ClientRequest clientRequest) {
+ if (clientRequest == null)
+ return;
+
update(ServerRequester.sendClientRequest(clientRequest));
lastClientRequest = clientRequest;
- }
- };
- MouseListener mouseListenerSearchRegexp = new MouseListener() {
- public void mouseClicked(MouseEvent mouseEvent) {}
- public void mousePressed(MouseEvent mouseEvent) {}
- public void mouseReleased(MouseEvent mouseEvent) {}
- public void mouseExited(MouseEvent mouseEvent) {
- if (jTextFieldRegexp.getText().equals("")) {
- jTextFieldRegexp.setText(ENTER_REGEXP_HERE);
- jTextFieldRegexp.setEnabled(false);
- }
- }
- public void mouseEntered(MouseEvent mouseEvent) {
- if (!jTextFieldRegexp.isEnabled()) {
- jTextFieldRegexp.setText("");
- jTextFieldRegexp.setEnabled(true);
- }
- }
- };
-
- jTextFieldRegexp.addActionListener(actionListenerSearchRegexp);
- jTextFieldRegexp.addMouseListener(mouseListenerSearchRegexp);
-
- JButton jButtonSearch = new JButton("Search");
- jButtonSearch.addActionListener(actionListenerSearchRegexp);
- jButtonSearch.addMouseListener(mouseListenerSearchRegexp);
-
- JButton jButtonGetAll = new JButton("Get all");
- jButtonGetAll.addActionListener(actionListenerGetAll);
-
- // Init split panes
- JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
- jSplitPane.setResizeWeight(1);
- jSplitPane.setDividerSize(0);
-
- JSplitPane jSplitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
- jSplitPane2.setResizeWeight(1);
- jSplitPane2.setDividerSize(0);
-
- JSplitPane jSplitPane3 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
- jSplitPane3.setResizeWeight(1);
- jSplitPane3.setDividerSize(0);
-
- JSplitPane jSplitPane4 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
- jSplitPane4.setDividerSize(0);
-
- // Init components
- JScrollPane jScrollPaneTable = new JScrollPane(jTable);
-
- jTextFieldStatusMessages = new JTextField("Welcome to "
- + Config.VERSION);
- jTextFieldStatusMessages.setEditable(false);
-
- // Set split pane components
- jSplitPane.setTopComponent(jScrollPaneTable);
- jSplitPane.setBottomComponent(jSplitPane2);
-
- jSplitPane2.setTopComponent(jSplitPane3);
- jSplitPane2.setBottomComponent(jTextFieldStatusMessages);
-
- JPanel jPanelButtons = new JPanel();
- jPanelButtons.add(jButtonSearch);
- jPanelButtons.add(jButtonGetAll);
-
- jSplitPane3.setLeftComponent(jTextFieldRegexp);
- jSplitPane3.setRightComponent(jPanelButtons);
-
- container.add(jSplitPane);
- }
-
- /**
- * This method sends a client request object to the server and used the server response object
- * to update the JTable ith its new values using the table model.
- * @param clientRequest Specifies the client request object to use for the updating.
- */
- public void update(ClientRequest clientRequest) {
- if (clientRequest == null)
- return;
-
- update(ServerRequester.sendClientRequest(clientRequest));
- lastClientRequest = clientRequest;
- }
-
- /**
- * This method sends the last client request object being used to the server again. If
- * If there is no last client request, nothing will be done.
- */
- public void updateLast() {
- if (lastClientRequest != null)
- update(ServerRequester.sendClientRequest(lastClientRequest));
- }
-
- /**
- * This method updates the GUI unsing a given server response object.
- * @param serverResponse Specifies the server response to use for the updating.
- */
- public void update(ServerResponse serverResponse) {
- if (serverResponse == null)
- return;
-
- tableModel.setEvents(serverResponse.getEvents());
- }
-
- /**
- * This method tells the calendar server to delete a given calendar event.
- * @param deleteEvent Specifies the calendar event to delete.
- */
- public void deleteEvent(CalendarEvent deleteEvent) {
- ClientRequest deleteRequest = new ClientRequest(
- ClientRequest.DELETE_EVENT);
- deleteRequest.setEvent(deleteEvent);
- ServerRequester.sendClientRequest(deleteRequest);
- updateLast();
- }
-
- /**
- * This method tells the calendar server to delete a given calendar category.
- * @param deleteEventsCategory Specifies the calendar event to delete its category!
- */
- public void deleteCategory(CalendarEvent deleteEventsCategory) {
- ClientRequest deleteRequest = new ClientRequest(
- ClientRequest.DELETE_CATEGORY);
- deleteRequest.setEvent(deleteEventsCategory);
- ServerRequester.sendClientRequest(deleteRequest);
- updateLast();
- }
-
- /**
- * If the client has several main windows open, then it will display a
- * session indicator so that the user knows which window belongs to which
- * session window!
- * @param iSession Specifies the session number of the current client window.
- * @return Returns the session indicator of the current client session.
- */
- private static String getSessionString(int iSession) {
- return iSession > 1 ? "[" + iSession + "] " : "";
- }
-
- /**
- * If the client has several main windows open, then it will display a
- * session indicator so that the user knows which window belongs to which
- * session window.
- * @return Returns the session indicator of the current client session.
- */
- public String getSessionString() {
- return iCurrentSession > 1 ? "[" + iCurrentSession + "] " : "";
- }
-
- /**
- * Runs a callback function on each selected event of the table.
- * @param doCallback Specifies the callback object to be used.
- */
- public void foreachSelectedEvent(DoCallback doCallback) {
- ListSelectionModel listSelectionModel = jTable.getSelectionModel();
-
- int iMinIndex = listSelectionModel.getMinSelectionIndex();
- int iMaxIndex = listSelectionModel.getMaxSelectionIndex();
-
- Vector vecEvents = new Vector();
-
- for (int i = iMinIndex; i <= iMaxIndex; ++i)
- if (listSelectionModel.isSelectedIndex(i))
- vecEvents.add(tableModel.getEvent(i));
-
- Enumeration enumEvents = vecEvents.elements();
- while (enumEvents.hasMoreElements())
- doCallback.callback(enumEvents.nextElement());
- }
-
- /**
- * This method is for various status messages. All messages will show up in the
- * status bar of the current client session window.
- * @param sMessage Specifies the message to be displayed in the status bar.
- */
- public void statusMessage(String sMessage) {
- jTextFieldStatusMessages.setText(sMessage);
- jTextFieldStatusMessages.updateUI();
- }
-
- /**
- * This method disposes this JFrame window including all the JFrame windows which
- * belong to this session.
- */
- public void dispose() {
- Enumeration enumFrames = vecFrames.elements();
-
- while (enumFrames.hasMoreElements())
- ((JFrame) enumFrames.nextElement()).dispose();
-
- super.dispose();
- }
-
- /**
- * This method tells the main netcalendar client JFrame which sub JFrames are opened.
- * So that all the sub JFrames will be disposed as well if the main JFrame gets disposed.
- * A sub JFrame is for example a input form for advanced searching or the preferences dialog.
- * @param jFrame Specifies the frame object to add. .
- */
- public void addFrame(JFrame jFrame) {
- vecFrames.add(jFrame);
- }
-
- /**
- * This method tells the main netcalendar client JFrame which sub JFrames are opened.
- * So that all the sub JFrames will be disposed as well if the main JFrame gets disposed.
- * A sub JFrame is for example a input form for advanced searching or the preferences dialog.
- * @param jFrame Specifies the frame object to remove.
- */
- public void removeFrame(JFrame jFrame) {
- vecFrames.remove(jFrame);
- }
+ }
+
+ /**
+ * This method sends the last client request object being used to the server again. If
+ * If there is no last client request, nothing will be done.
+ */
+ public void updateLast() {
+ if (lastClientRequest != null)
+ update(ServerRequester.sendClientRequest(lastClientRequest));
+ }
+
+ /**
+ * This method updates the GUI unsing a given server response object.
+ * @param serverResponse Specifies the server response to use for the updating.
+ */
+ public void update(ServerResponse serverResponse) {
+ if (serverResponse == null)
+ return;
+
+ tableModel.setEvents(serverResponse.getEvents());
+ }
+
+ /**
+ * This method tells the calendar server to delete a given calendar event.
+ * @param deleteEvent Specifies the calendar event to delete.
+ */
+ public void deleteEvent(CalendarEvent deleteEvent) {
+ ClientRequest deleteRequest = new ClientRequest(
+ ClientRequest.DELETE_EVENT);
+ deleteRequest.setEvent(deleteEvent);
+ ServerRequester.sendClientRequest(deleteRequest);
+ updateLast();
+ }
+
+ /**
+ * This method tells the calendar server to delete a given calendar category.
+ * @param deleteEventsCategory Specifies the calendar event to delete its category!
+ */
+ public void deleteCategory(CalendarEvent deleteEventsCategory) {
+ ClientRequest deleteRequest = new ClientRequest(
+ ClientRequest.DELETE_CATEGORY);
+ deleteRequest.setEvent(deleteEventsCategory);
+ ServerRequester.sendClientRequest(deleteRequest);
+ updateLast();
+ }
+
+ /**
+ * If the client has several main windows open, then it will display a
+ * session indicator so that the user knows which window belongs to which
+ * session window!
+ * @param iSession Specifies the session number of the current client window.
+ * @return Returns the session indicator of the current client session.
+ */
+ private static String getSessionString(int iSession) {
+ return iSession > 1 ? "[" + iSession + "] " : "";
+ }
+
+ /**
+ * If the client has several main windows open, then it will display a
+ * session indicator so that the user knows which window belongs to which
+ * session window.
+ * @return Returns the session indicator of the current client session.
+ */
+ public String getSessionString() {
+ return iCurrentSession > 1 ? "[" + iCurrentSession + "] " : "";
+ }
+
+ /**
+ * Runs a callback function on each selected event of the table.
+ * @param doCallback Specifies the callback object to be used.
+ */
+ public void foreachSelectedEvent(DoCallback doCallback) {
+ ListSelectionModel listSelectionModel = jTable.getSelectionModel();
+
+ int iMinIndex = listSelectionModel.getMinSelectionIndex();
+ int iMaxIndex = listSelectionModel.getMaxSelectionIndex();
+
+ Vector vecEvents = new Vector();
+
+ for (int i = iMinIndex; i <= iMaxIndex; ++i)
+ if (listSelectionModel.isSelectedIndex(i))
+ vecEvents.add(tableModel.getEvent(i));
+
+ Enumeration enumEvents = vecEvents.elements();
+ while (enumEvents.hasMoreElements())
+ doCallback.callback(enumEvents.nextElement());
+ }
+
+ /**
+ * This method is for various status messages. All messages will show up in the
+ * status bar of the current client session window.
+ * @param sMessage Specifies the message to be displayed in the status bar.
+ */
+ public void statusMessage(String sMessage) {
+ jTextFieldStatusMessages.setText(sMessage);
+ jTextFieldStatusMessages.updateUI();
+ }
+
+ /**
+ * This method disposes this JFrame window including all the JFrame windows which
+ * belong to this session.
+ */
+ public void dispose() {
+ Enumeration enumFrames = vecFrames.elements();
+
+ while (enumFrames.hasMoreElements())
+ ((JFrame) enumFrames.nextElement()).dispose();
+
+ super.dispose();
+ }
+
+ /**
+ * This method tells the main netcalendar client JFrame which sub JFrames are opened.
+ * So that all the sub JFrames will be disposed as well if the main JFrame gets disposed.
+ * A sub JFrame is for example a input form for advanced searching or the preferences dialog.
+ * @param jFrame Specifies the frame object to add. .
+ */
+ public void addFrame(JFrame jFrame) {
+ vecFrames.add(jFrame);
+ }
+
+ /**
+ * This method tells the main netcalendar client JFrame which sub JFrames are opened.
+ * So that all the sub JFrames will be disposed as well if the main JFrame gets disposed.
+ * A sub JFrame is for example a input form for advanced searching or the preferences dialog.
+ * @param jFrame Specifies the frame object to remove.
+ */
+ public void removeFrame(JFrame jFrame) {
+ vecFrames.remove(jFrame);
+ }
}
diff --git a/sources/client/ServerRequester.java b/sources/client/ServerRequester.java
index 9cd7485..6ccb7ee 100644
--- a/sources/client/ServerRequester.java
+++ b/sources/client/ServerRequester.java
@@ -1,3 +1,7 @@
+/* NetCalendar 2006, 2009 (c) Dipl.-Inform. (FH) Paul C. Buetow
+ * http://netcalendar.buetow.org - netcalendar@dev.buetow.org
+ */
+
/**
*
*/
@@ -19,64 +23,64 @@ import shared.remotecall.*;
* @author buetow
*/
public class ServerRequester {
- /**
- * This method creates a new client socket.
- * @return Returns a client socket object.
- * @throws IOException
- */
- private static Socket makeClientSocket() throws IOException {
- if (!Config.getBooleanValue("use_ssl")) {
- Main.statusMessage("Making non-SSL Socket...");
- return new Socket(Config.getServerAddress(), Config.getIntValue("server_port"));
+ /**
+ * This method creates a new client socket.
+ * @return Returns a client socket object.
+ * @throws IOException
+ */
+ private static Socket makeClientSocket() throws IOException {
+ if (!Config.getBooleanValue("use_ssl")) {
+ Main.statusMessage("Making non-SSL Socket...");
+ return new Socket(Config.getServerAddress(), Config.getIntValue("server_port"));
+ }
+
+ Main.statusMessage("Making SSL Socket...");
+ //Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
+ SocketFactory socketFactory = SSLSocketFactory.getDefault();
+ return socketFactory.createSocket(Config.getServerAddress(), Config.getIntValue("server_port"));
}
- Main.statusMessage("Making SSL Socket...");
- //Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
- SocketFactory socketFactory = SSLSocketFactory.getDefault();
- return socketFactory.createSocket(Config.getServerAddress(), Config.getIntValue("server_port"));
- }
+ /**
+ * Sends a client request to the netcalendar server end receives a server response object.
+ * @param clientRequest Specifies the client request to send to the calendar server.
+ * @return Returns the server response. It returns null if no response is available.
+ */
+ public final static ServerResponse sendClientRequest(ClientRequest clientRequest) {
+ Main.statusMessage("Sending client request to server...");
- /**
- * Sends a client request to the netcalendar server end receives a server response object.
- * @param clientRequest Specifies the client request to send to the calendar server.
- * @return Returns the server response. It returns null if no response is available.
- */
- public final static ServerResponse sendClientRequest(ClientRequest clientRequest) {
- Main.statusMessage("Sending client request to server...");
+ ServerResponse serverResponse = null;
- ServerResponse serverResponse = null;
+ try {
+ Socket socket = makeClientSocket();
+ socket.setKeepAlive(true);
- try {
- Socket socket = makeClientSocket();
- socket.setKeepAlive(true);
+ // Send the client request to the server
+ OutputStream outputStream = socket.getOutputStream();
+ ObjectOutput objectOutput = new ObjectOutputStream(outputStream);
- // Send the client request to the server
- OutputStream outputStream = socket.getOutputStream();
- ObjectOutput objectOutput = new ObjectOutputStream(outputStream);
+ objectOutput.writeObject(clientRequest);
+ objectOutput.flush();
- objectOutput.writeObject(clientRequest);
- objectOutput.flush();
+ // We only want to receive data if the request new events, not if we only send
+ // changed events!
+ if (clientRequest.requestsNewEvents()) {
+ // Recieve the server's response
+ InputStream inputStream = socket.getInputStream();
+ ObjectInput objectInput = new ObjectInputStream(inputStream);
+ serverResponse = (ServerResponse) objectInput.readObject();
+ }
- // We only want to receive data if the request new events, not if we only send
- // changed events!
- if (clientRequest.requestsNewEvents()) {
- // Recieve the server's response
- InputStream inputStream = socket.getInputStream();
- ObjectInput objectInput = new ObjectInputStream(inputStream);
- serverResponse = (ServerResponse) objectInput.readObject();
- }
+ objectOutput.close();
+ socket.close();
- objectOutput.close();
- socket.close();
+ } catch (Exception e) {
+ Main.infoMessage("Client error during serialization: " + e.getMessage());
+ Main.statusMessage("Error: Client request did not succeed! Server down?");
+ return serverResponse;
+ }
- } catch (Exception e) {
- Main.infoMessage("Client error during serialization: " + e.getMessage());
- Main.statusMessage("Error: Client request did not succeed! Server down?");
- return serverResponse;
+ Main.statusMessage("Last client request succeeded");
+ // Returns null if no response is available!
+ return serverResponse;
}
-
- Main.statusMessage("Last client request succeeded");
- // Returns null if no response is available!
- return serverResponse;
- }
}
diff --git a/sources/client/SplashScreen.java b/sources/client/SplashScreen.java
index 6ad8416..ec33d3a 100644
--- a/sources/client/SplashScreen.java
+++ b/sources/client/SplashScreen.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;
import java.awt.*;
@@ -5,38 +9,38 @@ import javax.swing.*;
import shared.*;
public class SplashScreen extends JWindow implements Runnable {
- private static final long serialVersionUID = 1L;
-
- /**
- * A simple little method to show a title screen in the center
- * of the screen for the amount of time given in the constructor
- */
- public void run() {
- JPanel jPanel = (JPanel)getContentPane();
- jPanel.setBackground(Color.BLACK);
- jPanel.setForeground(Color.WHITE);
-
- // Set the window's bounds, centering the window
- int iWidth = 411;
- int iHeight = 261;
- Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
-
- int x = (dimension.width-iWidth)/2;
- int y = (dimension.height-iHeight)/2;
- setBounds(x,y,iWidth,iHeight);
-
- JLabel jLabel = new JLabel(new ImageIcon("images/netcal.png"));
- jPanel.add(jLabel, BorderLayout.CENTER);
- jPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 3));
- setVisible(true);
-
- try {
- Thread.sleep(3000);
-
- } catch (Exception e) {
- Main.infoMessage(e.getMessage());
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * A simple little method to show a title screen in the center
+ * of the screen for the amount of time given in the constructor
+ */
+ public void run() {
+ JPanel jPanel = (JPanel)getContentPane();
+ jPanel.setBackground(Color.BLACK);
+ jPanel.setForeground(Color.WHITE);
+
+ // Set the window's bounds, centering the window
+ int iWidth = 411;
+ int iHeight = 261;
+ Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
+
+ int x = (dimension.width-iWidth)/2;
+ int y = (dimension.height-iHeight)/2;
+ setBounds(x,y,iWidth,iHeight);
+
+ JLabel jLabel = new JLabel(new ImageIcon("images/netcal.png"));
+ jPanel.add(jLabel, BorderLayout.CENTER);
+ jPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 3));
+ setVisible(true);
+
+ try {
+ Thread.sleep(3000);
+
+ } catch (Exception e) {
+ Main.infoMessage(e.getMessage());
+ }
+
+ dispose();
}
-
- dispose();
- }
} \ No newline at end of file
diff --git a/sources/client/SubWindow.java b/sources/client/SubWindow.java
index e043679..36e9529 100644
--- a/sources/client/SubWindow.java
+++ b/sources/client/SubWindow.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;
import java.awt.event.WindowEvent;
@@ -13,89 +17,89 @@ import javax.swing.*;
*
*/
public abstract class SubWindow extends JFrame {
- protected final static long serialVersionUID = 1L;
- protected NetCalendarClient netCalendarClient;
- private SubWindow subWindow;
-
- /**
- * Creates the window and shows it.
- * @param sTitleText Specifies the title text of this JFrame.
- * @param netCalendarClient Specifies the calendar client session object to use.
- */
- public SubWindow(String sTitleText, NetCalendarClient netCalendarClient) {
- super(netCalendarClient.getSessionString() + sTitleText);
- netCalendarClient.addFrame(this);
- this.netCalendarClient = netCalendarClient;
- this.subWindow = this;
- this.addWindowListener(new MyWindowListener());
- setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- setLocationRelativeTo(netCalendarClient);
- }
-
- /**
- * Creates the window and shows it.
- * @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) {
- initComponents();
- pack();
- setVisible(true);
- }
+ protected final static long serialVersionUID = 1L;
+ protected NetCalendarClient netCalendarClient;
+ private SubWindow subWindow;
- /**
- * The implemented method should initialize all the GUI components.
- */
- protected abstract void initComponents();
-
- /**
- * This private class is only needed for removing the current JFrame of the outer class
- * from the NetCalendarClient object's frame Vector.
- * @author buetow
- */
- private class MyWindowListener implements WindowListener {
- /*
- * (non-Javadoc)
- * @see java.awt.event.WindowListener#windowClosed(java.awt.event.WindowEvent)
+ /**
+ * Creates the window and shows it.
+ * @param sTitleText Specifies the title text of this JFrame.
+ * @param netCalendarClient Specifies the calendar client session object to use.
*/
- public void windowClosed(WindowEvent e) {
- netCalendarClient.removeFrame(subWindow);
+ public SubWindow(String sTitleText, NetCalendarClient netCalendarClient) {
+ super(netCalendarClient.getSessionString() + sTitleText);
+ netCalendarClient.addFrame(this);
+ this.netCalendarClient = netCalendarClient;
+ this.subWindow = this;
+ this.addWindowListener(new MyWindowListener());
+ setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
+ setLocationRelativeTo(netCalendarClient);
}
- /*
- * (non-Javadoc)
- * @see java.awt.event.WindowListener#windowActivated(java.awt.event.WindowEvent)
+ /**
+ * Creates the window and shows it.
+ * @param sTitleText Specifies the title text of this JFrame.
+ * @param netCalendarClient Specifies the calendar client session object to use.
*/
- public void windowActivated(WindowEvent e) { }
+ public void init(String sTitleText, NetCalendarClient netCalendarClient) {
+ initComponents();
+ pack();
+ setVisible(true);
+ }
- /*
- * (non-Javadoc)
- * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
+ /**
+ * The implemented method should initialize all the GUI components.
*/
- public void windowClosing(WindowEvent e) {}
+ protected abstract void initComponents();
- /*
- * (non-Javadoc)
- * @see java.awt.event.WindowListener#windowDeactivated(java.awt.event.WindowEvent)
+ /**
+ * This private class is only needed for removing the current JFrame of the outer class
+ * from the NetCalendarClient object's frame Vector.
+ * @author buetow
*/
- public void windowDeactivated(WindowEvent e) {}
+ private class MyWindowListener implements WindowListener {
+ /*
+ * (non-Javadoc)
+ * @see java.awt.event.WindowListener#windowClosed(java.awt.event.WindowEvent)
+ */
+ public void windowClosed(WindowEvent e) {
+ netCalendarClient.removeFrame(subWindow);
+ }
- /*
- * (non-Javadoc)
- * @see java.awt.event.WindowListener#windowDeiconified(java.awt.event.WindowEvent)
- */
- public void windowDeiconified(WindowEvent e) {}
+ /*
+ * (non-Javadoc)
+ * @see java.awt.event.WindowListener#windowActivated(java.awt.event.WindowEvent)
+ */
+ public void windowActivated(WindowEvent e) { }
- /*
- * (non-Javadoc)
- * @see java.awt.event.WindowListener#windowIconified(java.awt.event.WindowEvent)
- */
- public void windowIconified(WindowEvent e) { }
+ /*
+ * (non-Javadoc)
+ * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
+ */
+ public void windowClosing(WindowEvent e) {}
- /*
- * (non-Javadoc)
- * @see java.awt.event.WindowListener#windowOpened(java.awt.event.WindowEvent)
- */
- public void windowOpened(WindowEvent e) {}
- }
+ /*
+ * (non-Javadoc)
+ * @see java.awt.event.WindowListener#windowDeactivated(java.awt.event.WindowEvent)
+ */
+ public void windowDeactivated(WindowEvent e) {}
+
+ /*
+ * (non-Javadoc)
+ * @see java.awt.event.WindowListener#windowDeiconified(java.awt.event.WindowEvent)
+ */
+ public void windowDeiconified(WindowEvent e) {}
+
+ /*
+ * (non-Javadoc)
+ * @see java.awt.event.WindowListener#windowIconified(java.awt.event.WindowEvent)
+ */
+ public void windowIconified(WindowEvent e) { }
+
+ /*
+ * (non-Javadoc)
+ * @see java.awt.event.WindowListener#windowOpened(java.awt.event.WindowEvent)
+ */
+ public void windowOpened(WindowEvent e) {}
+ }
}
diff --git a/sources/client/helper/DateSpinner.java b/sources/client/helper/DateSpinner.java
index e374107..3683bc2 100644
--- a/sources/client/helper/DateSpinner.java
+++ b/sources/client/helper/DateSpinner.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.helper;
@@ -12,46 +16,46 @@ import javax.swing.*;
* @author buetow
*/
public class DateSpinner extends JComponent {
- private final static long serialVersionUID = 1L;
- private Date date;
- private SpinnerDateModel spinnerDateModel;
-
- /**
- * Creates a date spinner to set/edit a given date. This constructor uses the
- * current date!
- */
- public DateSpinner() {
- this.date = new Date();
- initComponents();
- }
-
- /**
- * Creates a date spinner to set/edit a given date.
- * @param date The date to be used for the date spinner!
- */
- public DateSpinner(Date date) {
- this.date = date;
- initComponents();
- }
-
- /**
- * Initializes all the date spinner GUI components.
- */
- private void initComponents() {
- setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4));
-
- spinnerDateModel = new SpinnerDateModel(date, null, null, Calendar.MONTH);
- JSpinner jSpinner = new JSpinner(spinnerDateModel);
- new JSpinner.DateEditor(jSpinner, "MM/yy");
-
- add(jSpinner);
- }
-
- /**
- * Returns the date which is represented by this spinner.
- * @return Returns the date which is represented by this spinner.
- */
- public Date getDate() {
- return spinnerDateModel.getDate();
- }
+ private final static long serialVersionUID = 1L;
+ private Date date;
+ private SpinnerDateModel spinnerDateModel;
+
+ /**
+ * Creates a date spinner to set/edit a given date. This constructor uses the
+ * current date!
+ */
+ public DateSpinner() {
+ this.date = new Date();
+ initComponents();
+ }
+
+ /**
+ * Creates a date spinner to set/edit a given date.
+ * @param date The date to be used for the date spinner!
+ */
+ public DateSpinner(Date date) {
+ this.date = date;
+ initComponents();
+ }
+
+ /**
+ * Initializes all the date spinner GUI components.
+ */
+ private void initComponents() {
+ setLayout(new FlowLayout(FlowLayout.LEFT, 4, 4));
+
+ spinnerDateModel = new SpinnerDateModel(date, null, null, Calendar.MONTH);
+ JSpinner jSpinner = new JSpinner(spinnerDateModel);
+ new JSpinner.DateEditor(jSpinner, "MM/yy");
+
+ add(jSpinner);
+ }
+
+ /**
+ * Returns the date which is represented by this spinner.
+ * @return Returns the date which is represented by this spinner.
+ */
+ public Date getDate() {
+ return spinnerDateModel.getDate();
+ }
}
diff --git a/sources/client/helper/GUIHelper.java b/sources/client/helper/GUIHelper.java
index 5da3bbf..a2de13a 100644
--- a/sources/client/helper/GUIHelper.java
+++ b/sources/client/helper/GUIHelper.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.helper;
import javax.swing.*;
@@ -12,178 +16,178 @@ import shared.*;
* @author buetow
*/
public class GUIHelper {
- /**
- * Aligns the first <code>iRows</code> * <code>iCols</code>
- * components of the parent in a grid. Each component is as big as the maximum
- * preferred width and height of the components.
- * The parent is made just big enough to fit them all.
- * @param containerParent Specifies the container to be used
- * @param iRows Specifies the number of rows to use.
- * @param iCols Specifies the number of columns to use.
- * @param iInitialX Specifies the x location to start the grid at.
- * @param iInitialY Specifies the y location to start the grid at.
- * @param iXPad Specifies the x padding between the cells.
- * @param iYPad Specifies the y padding between the cells
- */
- public static void makeGrid(Container containerParent,
- int iRows, int iCols,
- int iInitialX, int iInitialY,
- int iXPad, int iYPad) {
- SpringLayout helper;
- try {
- helper = (SpringLayout)containerParent.getLayout();
- } catch (ClassCastException exc) {
- Main.infoMessage("Error: The first argument to makeGrid must use SpringLayout.");
- return;
- }
-
- Spring iXPadSpring = Spring.constant(iXPad);
- Spring iYPadSpring = Spring.constant(iYPad);
- Spring iInitialXSpring = Spring.constant(iInitialX);
- Spring iInitialYSpring = Spring.constant(iInitialY);
- int max = iRows * iCols;
-
- // Calculate Springs that are the max of the width/height so that all
- // cells have the same size.
- Spring maxWidthSpring = helper.getConstraints(containerParent.getComponent(0)).
- getWidth();
- Spring maxHeightSpring = helper.getConstraints(containerParent.getComponent(0)).
- getWidth();
- for (int i = 1; i < max; i++) {
- SpringLayout.Constraints cons = helper.getConstraints(
- containerParent.getComponent(i));
-
- maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth());
- maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight());
- }
-
- // Apply the new width/height Spring. This forces all the
- // components to have the same size.
- for (int i = 0; i < max; i++) {
- SpringLayout.Constraints cons = helper.getConstraints(
- containerParent.getComponent(i));
-
- cons.setWidth(maxWidthSpring);
- cons.setHeight(maxHeightSpring);
- }
-
- // Then adjust the x/y constraints of all the cells so that they
- // are aligned in a grid.
- SpringLayout.Constraints lastCons = null;
- SpringLayout.Constraints lastRowCons = null;
- for (int i = 0; i < max; i++) {
- SpringLayout.Constraints cons = helper.getConstraints(
- containerParent.getComponent(i));
- if (i % iCols == 0) { //start of new iRow
- lastRowCons = lastCons;
- cons.setX(iInitialXSpring);
- } else { //x position depends on previous component
- cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST),
- iXPadSpring));
- }
-
- if (i / iCols == 0) { //first iRow
- cons.setY(iInitialYSpring);
- } else { //y position depends on previous iRow
- cons.setY(Spring.sum(lastRowCons.getConstraint(SpringLayout.SOUTH),
- iYPadSpring));
- }
- lastCons = cons;
- }
-
- // Set the containerParent's size.
- SpringLayout.Constraints pCons = helper.getConstraints(containerParent);
- pCons.setConstraint(SpringLayout.SOUTH,
- Spring.sum(Spring.constant(iYPad), lastCons.getConstraint(SpringLayout.SOUTH)));
- pCons.setConstraint(SpringLayout.EAST,
- Spring.sum(Spring.constant(iXPad), lastCons.getConstraint(SpringLayout.EAST)));
- }
-
- /**
- * This is a helper method for makeGrid. It returns the constraints for a specific cell.
- * @param iRow Specifies the row to get the constraints for.
- * @param iCol Specifies the column to get the constraints for.
- * @param containerParent Specifies the parent container.
- * @param iCols Specifies the number of columns being used.
- * @return Returns the constraints object of the current SpringLayout.
- */
- private static SpringLayout.Constraints getConstraintsForCell(int iRow, int iCol,
- Container containerParent, int iCols) {
-
- SpringLayout helper = (SpringLayout) containerParent.getLayout();
- Component component = containerParent.getComponent(iRow * iCols + iCol);
- return helper.getConstraints(component);
- }
-
- /**
- * Aligns the first <code>iRows</code> * <code>iCols</code>
- * components of <code>containerParent</code> in
- * a grid. Each component in a iColumn is as wide as the maximum
- * preferred width of the components in that iColumn;
- * height is similarly determined for each iRow.
- * The containerParent is made just big enough to fit them all.
- * @param iRows Specifies number of rows.
- * @param iCols Specifies the number of columns.
- * @param iInitialX Specifies the x location to start the grid at.
- * @param iInitialY Specifies the y location to start the grid at.
- * @param iXPad Specifies the x padding between the cells.
- * @param iYPad Specifies the y padding between the cells.
- */
- public static void makeCompactGrid(Container containerParent,
- int iRows, int iCols,
- int iInitialX, int iInitialY,
- int iXPad, int iYPad) {
- SpringLayout helper;
-
- try {
- helper = (SpringLayout)containerParent.getLayout();
- } catch (ClassCastException exc) {
- Main.infoMessage("Error: The first argument to makeCompactGrid must use SpringLayout.");
- return;
+ /**
+ * Aligns the first <code>iRows</code> * <code>iCols</code>
+ * components of the parent in a grid. Each component is as big as the maximum
+ * preferred width and height of the components.
+ * The parent is made just big enough to fit them all.
+ * @param containerParent Specifies the container to be used
+ * @param iRows Specifies the number of rows to use.
+ * @param iCols Specifies the number of columns to use.
+ * @param iInitialX Specifies the x location to start the grid at.
+ * @param iInitialY Specifies the y location to start the grid at.
+ * @param iXPad Specifies the x padding between the cells.
+ * @param iYPad Specifies the y padding between the cells
+ */
+ public static void makeGrid(Container containerParent,
+ int iRows, int iCols,
+ int iInitialX, int iInitialY,
+ int iXPad, int iYPad) {
+ SpringLayout helper;
+ try {
+ helper = (SpringLayout)containerParent.getLayout();
+ } catch (ClassCastException exc) {
+ Main.infoMessage("Error: The first argument to makeGrid must use SpringLayout.");
+ return;
+ }
+
+ Spring iXPadSpring = Spring.constant(iXPad);
+ Spring iYPadSpring = Spring.constant(iYPad);
+ Spring iInitialXSpring = Spring.constant(iInitialX);
+ Spring iInitialYSpring = Spring.constant(iInitialY);
+ int max = iRows * iCols;
+
+ // Calculate Springs that are the max of the width/height so that all
+ // cells have the same size.
+ Spring maxWidthSpring = helper.getConstraints(containerParent.getComponent(0)).
+ getWidth();
+ Spring maxHeightSpring = helper.getConstraints(containerParent.getComponent(0)).
+ getWidth();
+ for (int i = 1; i < max; i++) {
+ SpringLayout.Constraints cons = helper.getConstraints(
+ containerParent.getComponent(i));
+
+ maxWidthSpring = Spring.max(maxWidthSpring, cons.getWidth());
+ maxHeightSpring = Spring.max(maxHeightSpring, cons.getHeight());
+ }
+
+ // Apply the new width/height Spring. This forces all the
+ // components to have the same size.
+ for (int i = 0; i < max; i++) {
+ SpringLayout.Constraints cons = helper.getConstraints(
+ containerParent.getComponent(i));
+
+ cons.setWidth(maxWidthSpring);
+ cons.setHeight(maxHeightSpring);
+ }
+
+ // Then adjust the x/y constraints of all the cells so that they
+ // are aligned in a grid.
+ SpringLayout.Constraints lastCons = null;
+ SpringLayout.Constraints lastRowCons = null;
+ for (int i = 0; i < max; i++) {
+ SpringLayout.Constraints cons = helper.getConstraints(
+ containerParent.getComponent(i));
+ if (i % iCols == 0) { //start of new iRow
+ lastRowCons = lastCons;
+ cons.setX(iInitialXSpring);
+ } else { //x position depends on previous component
+ cons.setX(Spring.sum(lastCons.getConstraint(SpringLayout.EAST),
+ iXPadSpring));
+ }
+
+ if (i / iCols == 0) { //first iRow
+ cons.setY(iInitialYSpring);
+ } else { //y position depends on previous iRow
+ cons.setY(Spring.sum(lastRowCons.getConstraint(SpringLayout.SOUTH),
+ iYPadSpring));
+ }
+ lastCons = cons;
+ }
+
+ // Set the containerParent's size.
+ SpringLayout.Constraints pCons = helper.getConstraints(containerParent);
+ pCons.setConstraint(SpringLayout.SOUTH,
+ Spring.sum(Spring.constant(iYPad), lastCons.getConstraint(SpringLayout.SOUTH)));
+ pCons.setConstraint(SpringLayout.EAST,
+ Spring.sum(Spring.constant(iXPad), lastCons.getConstraint(SpringLayout.EAST)));
}
- // Align all cells in each iColumn and make them the same width.
- Spring x = Spring.constant(iInitialX);
- for (int c = 0; c < iCols; c++) {
- Spring width = Spring.constant(0);
- for (int r = 0; r < iRows; r++) {
- width = Spring.max(width,
- getConstraintsForCell(r, c, containerParent, iCols).getWidth());
- }
-
- for (int r = 0; r < iRows; r++) {
- SpringLayout.Constraints constraints =
- getConstraintsForCell(r, c, containerParent, iCols);
- constraints.setX(x);
- constraints.setWidth(width);
- }
- x = Spring.sum(x, Spring.sum(width, Spring.constant(iXPad)));
+ /**
+ * This is a helper method for makeGrid. It returns the constraints for a specific cell.
+ * @param iRow Specifies the row to get the constraints for.
+ * @param iCol Specifies the column to get the constraints for.
+ * @param containerParent Specifies the parent container.
+ * @param iCols Specifies the number of columns being used.
+ * @return Returns the constraints object of the current SpringLayout.
+ */
+ private static SpringLayout.Constraints getConstraintsForCell(int iRow, int iCol,
+ Container containerParent, int iCols) {
+
+ SpringLayout helper = (SpringLayout) containerParent.getLayout();
+ Component component = containerParent.getComponent(iRow * iCols + iCol);
+ return helper.getConstraints(component);
}
- // Align all cells in each iRow and make them the same height.
- Spring y = Spring.constant(iInitialY);
- for (int r = 0; r < iRows; r++) {
- Spring height = Spring.constant(0);
-
- for (int c = 0; c < iCols; c++) {
- height = Spring.max(height,
- getConstraintsForCell(r, c, containerParent, iCols).getHeight());
- }
-
- for (int c = 0; c < iCols; c++) {
- SpringLayout.Constraints constraints =
- getConstraintsForCell(r, c, containerParent, iCols);
-
- constraints.setY(y);
- constraints.setHeight(height);
- }
-
- y = Spring.sum(y, Spring.sum(height, Spring.constant(iYPad)));
+ /**
+ * Aligns the first <code>iRows</code> * <code>iCols</code>
+ * components of <code>containerParent</code> in
+ * a grid. Each component in a iColumn is as wide as the maximum
+ * preferred width of the components in that iColumn;
+ * height is similarly determined for each iRow.
+ * The containerParent is made just big enough to fit them all.
+ * @param iRows Specifies number of rows.
+ * @param iCols Specifies the number of columns.
+ * @param iInitialX Specifies the x location to start the grid at.
+ * @param iInitialY Specifies the y location to start the grid at.
+ * @param iXPad Specifies the x padding between the cells.
+ * @param iYPad Specifies the y padding between the cells.
+ */
+ public static void makeCompactGrid(Container containerParent,
+ int iRows, int iCols,
+ int iInitialX, int iInitialY,
+ int iXPad, int iYPad) {
+ SpringLayout helper;
+
+ try {
+ helper = (SpringLayout)containerParent.getLayout();
+ } catch (ClassCastException exc) {
+ Main.infoMessage("Error: The first argument to makeCompactGrid must use SpringLayout.");
+ return;
+ }
+
+ // Align all cells in each iColumn and make them the same width.
+ Spring x = Spring.constant(iInitialX);
+ for (int c = 0; c < iCols; c++) {
+ Spring width = Spring.constant(0);
+ for (int r = 0; r < iRows; r++) {
+ width = Spring.max(width,
+ getConstraintsForCell(r, c, containerParent, iCols).getWidth());
+ }
+
+ for (int r = 0; r < iRows; r++) {
+ SpringLayout.Constraints constraints =
+ getConstraintsForCell(r, c, containerParent, iCols);
+ constraints.setX(x);
+ constraints.setWidth(width);
+ }
+ x = Spring.sum(x, Spring.sum(width, Spring.constant(iXPad)));
+ }
+
+ // Align all cells in each iRow and make them the same height.
+ Spring y = Spring.constant(iInitialY);
+ for (int r = 0; r < iRows; r++) {
+ Spring height = Spring.constant(0);
+
+ for (int c = 0; c < iCols; c++) {
+ height = Spring.max(height,
+ getConstraintsForCell(r, c, containerParent, iCols).getHeight());
+ }
+
+ for (int c = 0; c < iCols; c++) {
+ SpringLayout.Constraints constraints =
+ getConstraintsForCell(r, c, containerParent, iCols);
+
+ constraints.setY(y);
+ constraints.setHeight(height);
+ }
+
+ y = Spring.sum(y, Spring.sum(height, Spring.constant(iYPad)));
+ }
+
+ // Set the containerParent's size.
+ SpringLayout.Constraints pCons = helper.getConstraints(containerParent);
+ pCons.setConstraint(SpringLayout.SOUTH, y);
+ pCons.setConstraint(SpringLayout.EAST, x);
}
-
- // Set the containerParent's size.
- SpringLayout.Constraints pCons = helper.getConstraints(containerParent);
- pCons.setConstraint(SpringLayout.SOUTH, y);
- pCons.setConstraint(SpringLayout.EAST, x);
- }
}
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);
+ }
}
diff --git a/sources/client/inputforms/CreateNewEvent.java b/sources/client/inputforms/CreateNewEvent.java
index 430f982..5defb0f 100644
--- a/sources/client/inputforms/CreateNewEvent.java
+++ b/sources/client/inputforms/CreateNewEvent.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,102 +25,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);
- }
-
- /**
- * 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);
+ 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);
}
- //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();
- }
+ /**
+ * 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();
+ }
}
diff --git a/sources/client/inputforms/EditExistingEvent.java b/sources/client/inputforms/EditExistingEvent.java
index 6c65aeb..35e584d 100644
--- a/sources/client/inputforms/EditExistingEvent.java
+++ b/sources/client/inputforms/EditExistingEvent.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,136 +25,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);
- }
-
- /**
- * 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);
+ 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);
}
- //Lay out the panel.
- GUIHelper.makeCompactGrid(jPanel,
- iNumPairs, 2, // iRows, iCols
- 6, 6, // iInitX, iInitY
- 6, 6); // iXPad, iYPad
+ /**
+ * 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);
+ }
- JButton jButtonDelete = new JButton(BUTTON_DELETE);
+ //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);
+ }
- 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("");
+ /**
+ * 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());
+ }
- } 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();
- }
+ /**
+ * 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();
+ }
}
diff --git a/sources/client/inputforms/InputForm.java b/sources/client/inputforms/InputForm.java
index 41004fa..0c507f8 100644
--- a/sources/client/inputforms/InputForm.java
+++ b/sources/client/inputforms/InputForm.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.ActionEvent;
@@ -14,80 +18,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 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 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 int TEXTFIELD_LENGTH = 20;
+ 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);
- }
+ /**
+ * 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);
+ }
- /**
- * 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 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);
+ /**
+ * 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();
+ 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_APPLY)) {
+ bApplyHasBeenPressed = true;
+ submit();
- } else if (event.getActionCommand().equals(BUTTON_OK)) {
- if (!bApplyHasBeenPressed)
- submit();
- dispose();
- }
- }
- };
+ } else if (event.getActionCommand().equals(BUTTON_OK)) {
+ if (!bApplyHasBeenPressed)
+ submit();
+ dispose();
+ }
+ }
+ };
- jButtonCancel.addActionListener(actionListenerButtons);
- jButtonClear.addActionListener(actionListenerButtons);
- jButtonApply.addActionListener(actionListenerButtons);
- jButtonOK.addActionListener(actionListenerButtons);
+ 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);
- }
+ 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();
+ /**
+ * Submits the input form of the implementating class.
+ */
+ protected abstract void submit();
}
diff --git a/sources/client/inputforms/Preferences.java b/sources/client/inputforms/Preferences.java
index a08fa65..02ebfd6 100644
--- a/sources/client/inputforms/Preferences.java
+++ b/sources/client/inputforms/Preferences.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.*;
@@ -17,83 +21,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);
- }
-
- /**
- * 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);
+ 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);
+ }
+
+ //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);
}
- //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 netcalendar.conf file.
- */
- protected void submit() {
- for (int i = 0; i < iNumPairs; ++i)
- Config.setValue(labels[i], ((JTextField) vecFields.get(i)).getText());
-
- Config.writeConfigToFile();
- }
+ /**
+ * 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 netcalendar.conf 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/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);
+ }
}
diff --git a/sources/server/CalendarDatabase.java b/sources/server/CalendarDatabase.java
index 3b5e1e0..0e37d0d 100644
--- a/sources/server/CalendarDatabase.java
+++ b/sources/server/CalendarDatabase.java
@@ -1,3 +1,7 @@
+/* NetCalendar 2006, 2009 (c) Dipl.-Inform. (FH) Paul C. Buetow
+ * http://netcalendar.buetow.org - netcalendar@dev.buetow.org
+ */
+
package server;
import java.util.*;
@@ -12,260 +16,260 @@ import shared.remotecall.*;
*
*/
public final class CalendarDatabase {
- private Vector vecCategories;
- private HashMap mapEvents;
- private HashMap mapCategories;
-
- /**
- * Simple constructur. Creates a calendar database.
- * @param vecCategories Specifies the vector of CalendarCategory objects for initial database content.
- */
- public CalendarDatabase(Vector vecCategories) {
- this.vecCategories = vecCategories;
- initializeMaps();
- }
-
- /**
- * Initializes a private hash map so that the server can access events by their id numbers very fast.
- */
- private void initializeMaps() {
- this.mapEvents = new HashMap();
- this.mapCategories = new HashMap();
-
- Enumeration enumCategory = vecCategories.elements();
- while (enumCategory.hasMoreElements()) {
- CalendarCategory category = (CalendarCategory) enumCategory.nextElement();
- mapCategories.put(category.getName(), category);
-
- Vector vecEvents = category.getEvents();
- Enumeration enumEvents = vecEvents.elements();
- while (enumEvents.hasMoreElements()) {
- CalendarEvent event = (CalendarEvent) enumEvents.nextElement();
- mapEvents.put(new Integer(event.getEventID()), event);
- }
+ private Vector vecCategories;
+ private HashMap mapEvents;
+ private HashMap mapCategories;
+
+ /**
+ * Simple constructur. Creates a calendar database.
+ * @param vecCategories Specifies the vector of CalendarCategory objects for initial database content.
+ */
+ public CalendarDatabase(Vector vecCategories) {
+ this.vecCategories = vecCategories;
+ initializeMaps();
}
- }
-
- /**
- * Returns a specific calendar event using fast hash lookup.
- * @param iEventID Specifies the ID of the calendar event to lookup.
- * @return Returns the requested calendar event.
- */
- public CalendarEvent getEvent(int iEventID) {
- return (CalendarEvent) mapEvents.get(new Integer(iEventID));
- }
-
- /**
- * Returns a specific calendar category using fast hash lookup.
- * @param sCategoryName Specifies the name of the calendar category to lookup.
- * @return Returns the requested calendar category.
- */
- public CalendarCategory getCategory(String sCategoryName) {
- return (CalendarCategory) mapCategories.get(sCategoryName);
- }
-
- /**
- * Gets all calendar categories.
- * @return Returns a Vector of all available CalendarCategory objects.
- */
- public Vector getCategories() {
- return vecCategories;
- }
-
- /**
- * This method returns a Vector of all available calendar events.
- * @return Returns all available CalendarEvent objects of the database.
- */
- public Vector getAllEvents() {
- MyVector vecAllEvents = new MyVector();
- Enumeration enumCategories = vecCategories.elements();
-
- while (enumCategories.hasMoreElements()) {
- CalendarCategory category = (CalendarCategory) enumCategories.nextElement();
- vecAllEvents.appendVector(category.getEvents());
+
+ /**
+ * Initializes a private hash map so that the server can access events by their id numbers very fast.
+ */
+ private void initializeMaps() {
+ this.mapEvents = new HashMap();
+ this.mapCategories = new HashMap();
+
+ Enumeration enumCategory = vecCategories.elements();
+ while (enumCategory.hasMoreElements()) {
+ CalendarCategory category = (CalendarCategory) enumCategory.nextElement();
+ mapCategories.put(category.getName(), category);
+
+ Vector vecEvents = category.getEvents();
+ Enumeration enumEvents = vecEvents.elements();
+ while (enumEvents.hasMoreElements()) {
+ CalendarEvent event = (CalendarEvent) enumEvents.nextElement();
+ mapEvents.put(new Integer(event.getEventID()), event);
+ }
+ }
}
- return vecAllEvents;
- }
+ /**
+ * Returns a specific calendar event using fast hash lookup.
+ * @param iEventID Specifies the ID of the calendar event to lookup.
+ * @return Returns the requested calendar event.
+ */
+ public CalendarEvent getEvent(int iEventID) {
+ return (CalendarEvent) mapEvents.get(new Integer(iEventID));
+ }
- /**
- * This method looks for all calendar events which match the a given client request.
- * @param clientRequest Specifies the client request sent by the calendar client.
- * @return Returns a Vector of all matching CalendarEvent objects.
- */
- public Vector getMatchingEvents(ClientRequest clientRequest) {
- MyVector vecEvents = new MyVector();
- int iNumEventsToRequest = clientRequest.getNumEventsToRequest();
+ /**
+ * Returns a specific calendar category using fast hash lookup.
+ * @param sCategoryName Specifies the name of the calendar category to lookup.
+ * @return Returns the requested calendar category.
+ */
+ public CalendarCategory getCategory(String sCategoryName) {
+ return (CalendarCategory) mapCategories.get(sCategoryName);
+ }
- Enumeration enumCategories = vecCategories.elements();
- while (enumCategories.hasMoreElements()) {
- CalendarCategory category = (CalendarCategory) enumCategories.nextElement();
- Vector vecNewEvents = category.getMatchingEvents(clientRequest);
- vecEvents.appendVector(vecNewEvents);
+ /**
+ * Gets all calendar categories.
+ * @return Returns a Vector of all available CalendarCategory objects.
+ */
+ public Vector getCategories() {
+ return vecCategories;
+ }
- if (iNumEventsToRequest > -1) {
- if (iNumEventsToRequest == vecEvents.size())
- break;
+ /**
+ * This method returns a Vector of all available calendar events.
+ * @return Returns all available CalendarEvent objects of the database.
+ */
+ public Vector getAllEvents() {
+ MyVector vecAllEvents = new MyVector();
+ Enumeration enumCategories = vecCategories.elements();
- } else {
- clientRequest.setNumEventsToRequest(iNumEventsToRequest - vecNewEvents.size());
- }
+ while (enumCategories.hasMoreElements()) {
+ CalendarCategory category = (CalendarCategory) enumCategories.nextElement();
+ vecAllEvents.appendVector(category.getEvents());
+ }
+ return vecAllEvents;
}
- return vecEvents;
- }
-
- /**
- * This method adds a calendar event to the calendar database.
- * @param clientRequest Specifies the client request sent by the netcalendar client. Its containing the new event to add.
- */
- public void addEvent(ClientRequest clientRequest) {
- CalendarEvent event = clientRequest.getEvent();
- String sCategoryName = event.getCategoryName();
- CalendarCategory category = getCategory(sCategoryName);
-
- // Check if the have to create a new category
- if (category == null) {
- category = new CalendarCategory(sCategoryName);
- mapCategories.put(sCategoryName, category);
- vecCategories.add(category);
- }
+ /**
+ * This method looks for all calendar events which match the a given client request.
+ * @param clientRequest Specifies the client request sent by the calendar client.
+ * @return Returns a Vector of all matching CalendarEvent objects.
+ */
+ public Vector getMatchingEvents(ClientRequest clientRequest) {
+ MyVector vecEvents = new MyVector();
+ int iNumEventsToRequest = clientRequest.getNumEventsToRequest();
- category.addEvent(event);
- category.setHasChanged(true);
- event.setCategory(category);
- mapEvents.put(new Integer(event.getEventID()), event);
- }
-
- /**
- * This method modifies an calendar event of the calendar database.
- * @param clientRequest Specifies the client request sent by the calendar client.
- */
- public void modifyEvent(ClientRequest clientRequest) {
- CalendarEvent newEvent = clientRequest.getEvent();
- CalendarEvent orgEvent = getEvent(newEvent.getEventID());
-
- // If the event doesnt exist any more, recreate it
- if (orgEvent == null) {
- clientRequest.setEvent(newEvent);
- addEvent(clientRequest);
- return;
- }
+ Enumeration enumCategories = vecCategories.elements();
+ while (enumCategories.hasMoreElements()) {
+ CalendarCategory category = (CalendarCategory) enumCategories.nextElement();
+ Vector vecNewEvents = category.getMatchingEvents(clientRequest);
+ vecEvents.appendVector(vecNewEvents);
- orgEvent.setDate(newEvent.getDate());
- orgEvent.setYearly(newEvent.isYearly());
- orgEvent.setDescription(newEvent.getDescription());
- orgEvent.setPlace(newEvent.getPlace());
+ if (iNumEventsToRequest > -1) {
+ if (iNumEventsToRequest == vecEvents.size())
+ break;
- // Modify the events category
- if (!orgEvent.getCategoryName().equals(newEvent.getCategoryName())) {
- String sNewCategoryName = newEvent.getCategoryName();
+ } else {
+ clientRequest.setNumEventsToRequest(iNumEventsToRequest - vecNewEvents.size());
+ }
- // First remove the event from its current category
- orgEvent.removeFromCurrentCategory();
- CalendarCategory category = getCategory(sNewCategoryName);
+ }
- if (category == null) {
- category = new CalendarCategory(sNewCategoryName);
- mapCategories.put(sNewCategoryName, category);
- vecCategories.add(category);
- }
+ return vecEvents;
+ }
- category.addEvent(orgEvent);
- category.setHasChanged(true);
- orgEvent.setCategory(category);
+ /**
+ * This method adds a calendar event to the calendar database.
+ * @param clientRequest Specifies the client request sent by the netcalendar client. Its containing the new event to add.
+ */
+ public void addEvent(ClientRequest clientRequest) {
+ CalendarEvent event = clientRequest.getEvent();
+ String sCategoryName = event.getCategoryName();
+ CalendarCategory category = getCategory(sCategoryName);
+
+ // Check if the have to create a new category
+ if (category == null) {
+ category = new CalendarCategory(sCategoryName);
+ mapCategories.put(sCategoryName, category);
+ vecCategories.add(category);
+ }
+
+ category.addEvent(event);
+ category.setHasChanged(true);
+ event.setCategory(category);
+ mapEvents.put(new Integer(event.getEventID()), event);
+ }
- } else {
- orgEvent.getCategory().setHasChanged(true);
+ /**
+ * This method modifies an calendar event of the calendar database.
+ * @param clientRequest Specifies the client request sent by the calendar client.
+ */
+ public void modifyEvent(ClientRequest clientRequest) {
+ CalendarEvent newEvent = clientRequest.getEvent();
+ CalendarEvent orgEvent = getEvent(newEvent.getEventID());
+
+ // If the event doesnt exist any more, recreate it
+ if (orgEvent == null) {
+ clientRequest.setEvent(newEvent);
+ addEvent(clientRequest);
+ return;
+ }
+
+ orgEvent.setDate(newEvent.getDate());
+ orgEvent.setYearly(newEvent.isYearly());
+ orgEvent.setDescription(newEvent.getDescription());
+ orgEvent.setPlace(newEvent.getPlace());
+
+ // Modify the events category
+ if (!orgEvent.getCategoryName().equals(newEvent.getCategoryName())) {
+ String sNewCategoryName = newEvent.getCategoryName();
+
+ // First remove the event from its current category
+ orgEvent.removeFromCurrentCategory();
+ CalendarCategory category = getCategory(sNewCategoryName);
+
+ if (category == null) {
+ category = new CalendarCategory(sNewCategoryName);
+ mapCategories.put(sNewCategoryName, category);
+ vecCategories.add(category);
+ }
+
+ category.addEvent(orgEvent);
+ category.setHasChanged(true);
+ orgEvent.setCategory(category);
+
+ } else {
+ orgEvent.getCategory().setHasChanged(true);
+ }
}
- }
-
- /**
- * This method deletes a calendar event of the calendar database. If the specified calendar event doesnt
- * exist eny more, nothing will be changed.
- * @param clientRequest Specifies the client request sent by the netcalendar client.
- */
- public void deleteEvent(ClientRequest clientRequest) {
- // Get the server side reference of the calendar event
- CalendarEvent event = getEvent(clientRequest.getEvent().getEventID());
-
- if (event != null) {
- event.getCategory().setHasChanged(true);
- event.removeFromCurrentCategory();
- mapEvents.remove(new Integer(event.getEventID()));
+
+ /**
+ * This method deletes a calendar event of the calendar database. If the specified calendar event doesnt
+ * exist eny more, nothing will be changed.
+ * @param clientRequest Specifies the client request sent by the netcalendar client.
+ */
+ public void deleteEvent(ClientRequest clientRequest) {
+ // Get the server side reference of the calendar event
+ CalendarEvent event = getEvent(clientRequest.getEvent().getEventID());
+
+ if (event != null) {
+ event.getCategory().setHasChanged(true);
+ event.removeFromCurrentCategory();
+ mapEvents.remove(new Integer(event.getEventID()));
+ }
}
- }
- /**
- * This method renames a calendar category.
- * @param clientRequest Specifies the client request sent by the netcalendar client.
- */
- public void renameCategory(ClientRequest clientRequest) {
- String sOldCategoryName = clientRequest.getEvent().getCategoryName();
- CalendarCategory category = getCategory(sOldCategoryName);
+ /**
+ * This method renames a calendar category.
+ * @param clientRequest Specifies the client request sent by the netcalendar client.
+ */
+ public void renameCategory(ClientRequest clientRequest) {
+ String sOldCategoryName = clientRequest.getEvent().getCategoryName();
+ CalendarCategory category = getCategory(sOldCategoryName);
- if (category == null)
- return;
+ if (category == null)
+ return;
- String sNewCategoryName = clientRequest.getString();
+ String sNewCategoryName = clientRequest.getString();
- if (sOldCategoryName.equals(sNewCategoryName))
- return;
+ if (sOldCategoryName.equals(sNewCategoryName))
+ return;
- mapCategories.remove(sOldCategoryName);
+ mapCategories.remove(sOldCategoryName);
- category.setName(sNewCategoryName);
+ category.setName(sNewCategoryName);
- Vector vecEvents = category.getEvents();
- Enumeration enumEvents = vecEvents.elements();
- while (enumEvents.hasMoreElements()) {
- CalendarEvent event = (CalendarEvent) enumEvents.nextElement();
- event.setCategoryName(sNewCategoryName);
- }
+ Vector vecEvents = category.getEvents();
+ Enumeration enumEvents = vecEvents.elements();
+ while (enumEvents.hasMoreElements()) {
+ CalendarEvent event = (CalendarEvent) enumEvents.nextElement();
+ event.setCategoryName(sNewCategoryName);
+ }
+
+ // Check if the category exists already
+ CalendarCategory categoryExists = getCategory(sNewCategoryName);
- // Check if the category exists already
- CalendarCategory categoryExists = getCategory(sNewCategoryName);
+ if (categoryExists == null) {
+ mapCategories.put(category.getName(), category);
+ } else {
+ vecCategories.remove(category);
+ categoryExists.merge(category);
+ }
- if (categoryExists == null) {
- mapCategories.put(category.getName(), category);
- } else {
- vecCategories.remove(category);
- categoryExists.merge(category);
}
- }
-
- /**
- * This method daletes a calendar category.
- * @param clientRequest Specifies the client request sent by the netcalendar client.
- */
- public void deleteCategory(ClientRequest clientRequest) {
- String sCategoryName = clientRequest.getEvent().getCategoryName();
- CalendarCategory category = getCategory(sCategoryName);
-
- if (category == null)
- return;
-
- mapCategories.remove(sCategoryName);
- vecCategories.remove(category);
- category.deleteDatabaseFile();
- }
-
- /**
- * This method flushes all the changed calendar categories of the calendar database to the filesystem.
- */
- public void flush() {
- Enumeration enumCategories = vecCategories.elements();
-
- while (enumCategories.hasMoreElements()) {
- CalendarCategory category = (CalendarCategory) enumCategories.nextElement();
- if (category.hasChanged())
- category.flush();
+ /**
+ * This method daletes a calendar category.
+ * @param clientRequest Specifies the client request sent by the netcalendar client.
+ */
+ public void deleteCategory(ClientRequest clientRequest) {
+ String sCategoryName = clientRequest.getEvent().getCategoryName();
+ CalendarCategory category = getCategory(sCategoryName);
+
+ if (category == null)
+ return;
+
+ mapCategories.remove(sCategoryName);
+ vecCategories.remove(category);
+ category.deleteDatabaseFile();
}
- Main.execExternalCommand(Config.getStringValue("server_updatedb_command"));
- }
+ /**
+ * This method flushes all the changed calendar categories of the calendar database to the filesystem.
+ */
+ public void flush() {
+ Enumeration enumCategories = vecCategories.elements();
+
+ while (enumCategories.hasMoreElements()) {
+ CalendarCategory category = (CalendarCategory) enumCategories.nextElement();
+ if (category.hasChanged())
+ category.flush();
+ }
+
+ Main.execExternalCommand(Config.getStringValue("server_updatedb_command"));
+ }
}
diff --git a/sources/server/CalendarFormatParser.java b/sources/server/CalendarFormatParser.java
index 5d38f24..852fd73 100644
--- a/sources/server/CalendarFormatParser.java
+++ b/sources/server/CalendarFormatParser.java
@@ -1,3 +1,7 @@
+/* NetCalendar 2006, 2009 (c) Dipl.-Inform. (FH) Paul C. Buetow
+ * http://netcalendar.buetow.org - netcalendar@dev.buetow.org
+ */
+
/**
*
*/
@@ -20,259 +24,259 @@ import shared.*;
*
*/
public final class CalendarFormatParser {
- private int iCurrentYear;
- private Date dateCurrent;
- private String sWorkdir;
- private Vector vecCategories;
- private static final Pattern datePattern;
- private static final Pattern dateYearlyPattern;
- private static final Pattern dateElsePattern;
- private static final Pattern dateEndPattern;
- // private static final Pattern emptyLine;
- private static final String DATE_FORMAT = "M/d-y";
- private static final String EXTENDED_DATE_FORMAT = "M/d-y-H:m";
-
- // Those pattern will be used later, precompile here once to use often
- static {
- // Matches calendar date format like: "01/25 2006-14:23"
- datePattern = Pattern.compile("\\d{2}/\\d{2}\t\\d{4}-\\d{2}:\\d{2}");
-
- // Matches calendar date format like: "01/25 yearly-14:23"
- dateYearlyPattern = Pattern.compile("\\d{2}/\\d{2}\tyearly-\\d{2}:\\d{2}");
-
- // Matches calendar date format like: "01/25 Some free text here
- dateElsePattern = Pattern.compile("\\d{2}/\\d{2}\t");
-
- // Matches the end of the date string like: "arly-14:23 " or "2006-14:23"
- dateEndPattern = Pattern.compile(".{4}-\\d{2}:\\d{2}");
- }
-
- /**
- * Simple constructor. Creates a calendar format parser object and initializes some private members.
- */
- public CalendarFormatParser() {
- // Use current dir as workdir by default
- this.sWorkdir = ".";
- this.vecCategories = new Vector();
-
- // Events without a year specified will use the current year!
- GregorianCalendar cal = new GregorianCalendar();
- iCurrentYear = cal.get(Calendar.YEAR);
-
- dateCurrent = new Date();
- }
-
- /**
- * This method returns a vector of all found calendar categories after parsing.
- * @return Returns a Vector of all available CalendarCategory objects.
- */
- public Vector getCategories() {
- return vecCategories;
- }
-
- /**
- * This method sets the working directory. Its the "server_database_dir" variable defined in the current configuration by default.
- * @param sWorkdir Specifies the working directory.
- */
- public void setWorkdir(String sWorkdir) {
- this.sWorkdir = sWorkdir;
- }
-
- /**
- * Starts the parsing work of the calendar database files.
- */
- public void start() {
- lookForCategories();
- parseAllCategories();
- Main.execExternalCommand(Config.getStringValue("server_startup_command"));
- }
-
- /**
- * Parses for the available calendar categories.
- */
- private void lookForCategories() {
- File dir = new File(sWorkdir);
- File[] dirContent = dir.listFiles();
-
- for (int i = 0; i < dirContent.length; ++i)
- if (dirContent[i].isFile())
- // Ignore the 'calendar' file, only read the 'calendar.*' files
- if (!dirContent[i].getName().equals("calendar"))
- vecCategories.add(new CalendarCategory(dirContent[i]));
- }
-
- /**
- * Parses all events of all available categories.
- */
- private void parseAllCategories() {
- Enumeration enumCategories = vecCategories.elements();
- while (enumCategories.hasMoreElements())
- parseCategory((CalendarCategory) enumCategories.nextElement());
- }
-
- /**
- * Parses all events of a category file.
- * @param category Specifies the calendar category to be parsed.
- */
- private void parseCategory(CalendarCategory category) {
- Vector vecEvents = new Vector();
- File file = category.getFile();
-
- try {
- BufferedReader in = new BufferedReader(new FileReader(file));
- String sLine;
-
- while ((sLine = in.readLine()) != null) {
- CalendarEvent event = new CalendarEvent(category);
-
- // Ignore empty lines!
- if (sLine.equals(""))
- continue;
-
- setEventsDate(event, sLine);
- setEventsPlace(event, sLine);
- setEventsDescription(event, sLine);
-
- vecEvents.add(event);
- }
-
- } catch (Exception e) {
- Main.infoMessage("Error: " + e.toString());
+ private int iCurrentYear;
+ private Date dateCurrent;
+ private String sWorkdir;
+ private Vector vecCategories;
+ private static final Pattern datePattern;
+ private static final Pattern dateYearlyPattern;
+ private static final Pattern dateElsePattern;
+ private static final Pattern dateEndPattern;
+ // private static final Pattern emptyLine;
+ private static final String DATE_FORMAT = "M/d-y";
+ private static final String EXTENDED_DATE_FORMAT = "M/d-y-H:m";
+
+ // Those pattern will be used later, precompile here once to use often
+ static {
+ // Matches calendar date format like: "01/25 2006-14:23"
+ datePattern = Pattern.compile("\\d{2}/\\d{2}\t\\d{4}-\\d{2}:\\d{2}");
+
+ // Matches calendar date format like: "01/25 yearly-14:23"
+ dateYearlyPattern = Pattern.compile("\\d{2}/\\d{2}\tyearly-\\d{2}:\\d{2}");
+
+ // Matches calendar date format like: "01/25 Some free text here
+ dateElsePattern = Pattern.compile("\\d{2}/\\d{2}\t");
+
+ // Matches the end of the date string like: "arly-14:23 " or "2006-14:23"
+ dateEndPattern = Pattern.compile(".{4}-\\d{2}:\\d{2}");
}
- category.setEvents(vecEvents);
- category.unsetFile();
- }
-
- /**
- * This method parses all known informations from a given calendar format line and saves them
- * into the given calendar event object.
- * @param event Specifies the calendar event to be modified.
- * @param sLine Specifies the single line of the category file to be parsed.
- */
- private void setEventsDate(CalendarEvent event, String sLine) {
- // Create a local copy because the string may be modified
- String sMyLine = new String(sLine).replaceAll(" ", "");
- String sDateFormat;
- boolean bValidDateFormat = false;
-
- // Check if its a yearly event
- Matcher matcher = dateYearlyPattern.matcher(sMyLine);
- if (matcher.find()) {
- sMyLine = sMyLine.replaceFirst("\tyearly", "-" + iCurrentYear);
- sDateFormat = EXTENDED_DATE_FORMAT;
- event.setYearly(true);
- bValidDateFormat = true;
-
- } else {
- // Event is not yearly, but check if its still using NetCalendars
- // extended format which contains the event's time (hours:minutes)
- matcher = datePattern.matcher(sMyLine);
- if (matcher.find()) {
- sMyLine = sMyLine.replaceFirst("\t", "-");
- sDateFormat = EXTENDED_DATE_FORMAT;
- event.setYearly(false);
- bValidDateFormat = true;
-
- } else {
- //matcher = dateElsePattern.matcher(sMyLine);
- //if (matcher.find()) {
- // Just use original Calendar format without any year and time
- // informations
- // Assume yearly
- sMyLine = sMyLine.replaceFirst("\t", "-" + iCurrentYear);
- sDateFormat = DATE_FORMAT;
- event.setYearly(true);
- bValidDateFormat = true;
- /*} else {
- return;
- }*/
- }
+ /**
+ * Simple constructor. Creates a calendar format parser object and initializes some private members.
+ */
+ public CalendarFormatParser() {
+ // Use current dir as workdir by default
+ this.sWorkdir = ".";
+ this.vecCategories = new Vector();
+
+ // Events without a year specified will use the current year!
+ GregorianCalendar cal = new GregorianCalendar();
+ iCurrentYear = cal.get(Calendar.YEAR);
+
+ dateCurrent = new Date();
}
- // Create a new date object containing the events time informations
- SimpleDateFormat formatter = new SimpleDateFormat(sDateFormat);
- Date date = null;
+ /**
+ * This method returns a vector of all found calendar categories after parsing.
+ * @return Returns a Vector of all available CalendarCategory objects.
+ */
+ public Vector getCategories() {
+ return vecCategories;
+ }
- if (bValidDateFormat) {
- try {
- date = formatter.parse(sMyLine);
+ /**
+ * This method sets the working directory. Its the "server_database_dir" variable defined in the current configuration by default.
+ * @param sWorkdir Specifies the working directory.
+ */
+ public void setWorkdir(String sWorkdir) {
+ this.sWorkdir = sWorkdir;
+ }
- } catch (ParseException e) {
- Main.infoMessage("Error: Calendar format parser error at category "
- + event.getCategoryName() + ": " + e.getMessage());
- }
+ /**
+ * Starts the parsing work of the calendar database files.
+ */
+ public void start() {
+ lookForCategories();
+ parseAllCategories();
+ Main.execExternalCommand(Config.getStringValue("server_startup_command"));
}
- // The event is yearly, but occured already this year, so increment the events
- // year by one!
- if (event.isYearly() && date.getTime() < dateCurrent.getTime()) {
- Calendar calendar = new GregorianCalendar();
- calendar.setTime(date);
- calendar.set(Calendar.YEAR, iCurrentYear + 1);
- date = calendar.getTime();
+ /**
+ * Parses for the available calendar categories.
+ */
+ private void lookForCategories() {
+ File dir = new File(sWorkdir);
+ File[] dirContent = dir.listFiles();
+
+ for (int i = 0; i < dirContent.length; ++i)
+ if (dirContent[i].isFile())
+ // Ignore the 'calendar' file, only read the 'calendar.*' files
+ if (!dirContent[i].getName().equals("calendar"))
+ vecCategories.add(new CalendarCategory(dirContent[i]));
}
- event.setDate(date);
- }
+ /**
+ * Parses all events of all available categories.
+ */
+ private void parseAllCategories() {
+ Enumeration enumCategories = vecCategories.elements();
+ while (enumCategories.hasMoreElements())
+ parseCategory((CalendarCategory) enumCategories.nextElement());
+ }
- /**
- * Parses a single calendar line for the place information.
- * @param event Specifies the calendar event to be modified.
- * @param sLine Specifies the single line of the category file to be parsed.
- */
- private void setEventsPlace(CalendarEvent event, String sLine) {
- int iPos = sLine.indexOf(";;");
+ /**
+ * Parses all events of a category file.
+ * @param category Specifies the calendar category to be parsed.
+ */
+ private void parseCategory(CalendarCategory category) {
+ Vector vecEvents = new Vector();
+ File file = category.getFile();
- // No event! Return empty string!
- if (iPos < 0) {
- event.setPlace("");
+ try {
+ BufferedReader in = new BufferedReader(new FileReader(file));
+ String sLine;
- } else {
- event.setPlace(trim(sLine.substring(iPos + 2)));
- }
- }
+ while ((sLine = in.readLine()) != null) {
+ CalendarEvent event = new CalendarEvent(category);
- /**
- * Parses a single calendar line for the description information.
- * @param event Specifies the calendar event to be modified.
- * @param sLine Specifies the single line of the category file to be parsed.
- */
- private void setEventsDescription(CalendarEvent event, String sLine) {
- // We need a local copy because we may modify the string
- String sTmp = new String(sLine);
+ // Ignore empty lines!
+ if (sLine.equals(""))
+ continue;
- // Check if there is a place string...
- int iPos = sLine.indexOf(";;");
+ setEventsDate(event, sLine);
+ setEventsPlace(event, sLine);
+ setEventsDescription(event, sLine);
- // ... if yes, dont include it!
- if (iPos >= 0)
- sTmp = sTmp.substring(0, iPos);
+ vecEvents.add(event);
+ }
- // Remove the events date from the string
- Matcher matcher = dateEndPattern.matcher(sTmp);
+ } catch (Exception e) {
+ Main.infoMessage("Error: " + e.toString());
+ }
- if (matcher.find()) {
- sTmp = sTmp.substring(matcher.start()+11);
+ category.setEvents(vecEvents);
+ category.unsetFile();
+ }
- } else {
- sTmp = sTmp.substring(sTmp.indexOf("\t")+1);
+ /**
+ * This method parses all known informations from a given calendar format line and saves them
+ * into the given calendar event object.
+ * @param event Specifies the calendar event to be modified.
+ * @param sLine Specifies the single line of the category file to be parsed.
+ */
+ private void setEventsDate(CalendarEvent event, String sLine) {
+ // Create a local copy because the string may be modified
+ String sMyLine = new String(sLine).replaceAll(" ", "");
+ String sDateFormat;
+ boolean bValidDateFormat = false;
+
+ // Check if its a yearly event
+ Matcher matcher = dateYearlyPattern.matcher(sMyLine);
+ if (matcher.find()) {
+ sMyLine = sMyLine.replaceFirst("\tyearly", "-" + iCurrentYear);
+ sDateFormat = EXTENDED_DATE_FORMAT;
+ event.setYearly(true);
+ bValidDateFormat = true;
+
+ } else {
+ // Event is not yearly, but check if its still using NetCalendars
+ // extended format which contains the event's time (hours:minutes)
+ matcher = datePattern.matcher(sMyLine);
+ if (matcher.find()) {
+ sMyLine = sMyLine.replaceFirst("\t", "-");
+ sDateFormat = EXTENDED_DATE_FORMAT;
+ event.setYearly(false);
+ bValidDateFormat = true;
+
+ } else {
+ //matcher = dateElsePattern.matcher(sMyLine);
+ //if (matcher.find()) {
+ // Just use original Calendar format without any year and time
+ // informations
+ // Assume yearly
+ sMyLine = sMyLine.replaceFirst("\t", "-" + iCurrentYear);
+ sDateFormat = DATE_FORMAT;
+ event.setYearly(true);
+ bValidDateFormat = true;
+ /*} else {
+ return;
+ }*/
+ }
+ }
+
+ // Create a new date object containing the events time informations
+ SimpleDateFormat formatter = new SimpleDateFormat(sDateFormat);
+ Date date = null;
+
+ if (bValidDateFormat) {
+ try {
+ date = formatter.parse(sMyLine);
+
+ } catch (ParseException e) {
+ Main.infoMessage("Error: Calendar format parser error at category "
+ + event.getCategoryName() + ": " + e.getMessage());
+ }
+ }
+
+ // The event is yearly, but occured already this year, so increment the events
+ // year by one!
+ if (event.isYearly() && date.getTime() < dateCurrent.getTime()) {
+ Calendar calendar = new GregorianCalendar();
+ calendar.setTime(date);
+ calendar.set(Calendar.YEAR, iCurrentYear + 1);
+ date = calendar.getTime();
+ }
+
+ event.setDate(date);
}
- event.setDescription(trim(sTmp));
- }
+ /**
+ * Parses a single calendar line for the place information.
+ * @param event Specifies the calendar event to be modified.
+ * @param sLine Specifies the single line of the category file to be parsed.
+ */
+ private void setEventsPlace(CalendarEvent event, String sLine) {
+ int iPos = sLine.indexOf(";;");
+
+ // No event! Return empty string!
+ if (iPos < 0) {
+ event.setPlace("");
+
+ } else {
+ event.setPlace(trim(sLine.substring(iPos + 2)));
+ }
+ }
- /**
- * Its like String.trim() but also removes a ending newline.
- * @param sTrimString Specifies the String to be trimmed.
- * @return Returns a copy of the string, with leading and trailing whitespace omitted, also a trailing newline will be omitted.
- */
- private String trim(String sTrimString) {
- int iPos = sTrimString.indexOf("\n");
+ /**
+ * Parses a single calendar line for the description information.
+ * @param event Specifies the calendar event to be modified.
+ * @param sLine Specifies the single line of the category file to be parsed.
+ */
+ private void setEventsDescription(CalendarEvent event, String sLine) {
+ // We need a local copy because we may modify the string
+ String sTmp = new String(sLine);
- if (iPos >= 0)
- return sTrimString.substring(0, iPos).trim();
+ // Check if there is a place string...
+ int iPos = sLine.indexOf(";;");
- return sTrimString.trim();
- }
+ // ... if yes, dont include it!
+ if (iPos >= 0)
+ sTmp = sTmp.substring(0, iPos);
+
+ // Remove the events date from the string
+ Matcher matcher = dateEndPattern.matcher(sTmp);
+
+ if (matcher.find()) {
+ sTmp = sTmp.substring(matcher.start()+11);
+
+ } else {
+ sTmp = sTmp.substring(sTmp.indexOf("\t")+1);
+ }
+
+ event.setDescription(trim(sTmp));
+ }
+
+ /**
+ * Its like String.trim() but also removes a ending newline.
+ * @param sTrimString Specifies the String to be trimmed.
+ * @return Returns a copy of the string, with leading and trailing whitespace omitted, also a trailing newline will be omitted.
+ */
+ private String trim(String sTrimString) {
+ int iPos = sTrimString.indexOf("\n");
+
+ if (iPos >= 0)
+ return sTrimString.substring(0, iPos).trim();
+
+ return sTrimString.trim();
+ }
}
diff --git a/sources/server/NetCalendarServer.java b/sources/server/NetCalendarServer.java
index ad02d2b..6fe6f74 100644
--- a/sources/server/NetCalendarServer.java
+++ b/sources/server/NetCalendarServer.java
@@ -1,3 +1,7 @@
+/* NetCalendar 2006, 2009 (c) Dipl.-Inform. (FH) Paul C. Buetow
+ * http://netcalendar.buetow.org - netcalendar@dev.buetow.org
+ */
+
/**
*
*/
@@ -18,143 +22,143 @@ import shared.remotecall.*;
* @author buetow
*/
public class NetCalendarServer extends Thread {
- private int iPort;
- private String sWorkdir;
-
- /**
- * Creates a NetCalendarServer instance and runs it as a thread.
- * @param iPort Specifies the server port of the server to be used.
- * @param sWorkdir Specifies the working directory of the server.
- */
- public NetCalendarServer(int iPort, String sWorkdir) {
- this.iPort = iPort;
- this.sWorkdir = sWorkdir;
-
- start();
- }
-
- /**
- * This method initializes a new server socket.
- * @return Returns the server socket object.
- */
- private ServerSocket makeServerSocket() throws IOException {
- if (!Config.getBooleanValue("use_ssl"))
- return new ServerSocket(iPort);
-
- ServerSocketFactory sslSocketFactory = SSLServerSocketFactory.getDefault();
- return sslSocketFactory.createServerSocket(iPort);
- }
-
- /**
- * This method specifies the start method of the Thread. Its setting up the server port.
- */
- public void run() {
- ServerSocket serverSocket = null;
- Socket socket = null;
-
- // Read and parse the whole calendar database from file!
- CalendarFormatParser parser = new CalendarFormatParser();
- parser.setWorkdir(sWorkdir);
- parser.start();
-
- CalendarDatabase calendarDatabase = new CalendarDatabase(parser.getCategories());
-
- try {
- serverSocket = makeServerSocket();
-
- while (true) {
- // This will wait for a connection to be made to this socket.
- socket = serverSocket.accept();
- // serverSocket.accept();
- socket.setKeepAlive(true);
-
- // Recieve the client's request object
- InputStream inputStream = socket.getInputStream();
- ObjectInput objectInput = new ObjectInputStream(inputStream);
- ClientRequest clientRequest = (ClientRequest) objectInput.readObject();
-
- if (!clientRequest.checkPassphrase(Config.getStringValue("passphrase", false))) {
- Main.infoMessage("Server: Client refused, wrong passphrase!");
-
- // Check if a event has been modified!
- } else if (clientRequest.requestsNewEvents()) {
- Main.infoMessage("Server: Client requests new events");
-
- // Get all calendar events which match the request
- Vector vecEvents = calendarDatabase.getMatchingEvents(clientRequest);
- ServerResponse serverResponse = new ServerResponse(vecEvents);
-
- OutputStream outputStream = socket.getOutputStream();
- ObjectOutput objectOutput = new ObjectOutputStream(outputStream);
- objectOutput.writeObject(serverResponse);
- objectOutput.flush();
- objectOutput.close();
-
- } else if (clientRequest.actionIs(ClientRequest.MODIFY_EVENT)) {
- Main.infoMessage("Server: Client wants to modify an event");
- calendarDatabase.modifyEvent(clientRequest);
- // if (Config.getBooleanValue("client_run"))
- calendarDatabase.flush();
-
- } else if (clientRequest.actionIs(ClientRequest.DELETE_EVENT)) {
- Main.infoMessage("Server: Client wants to delete an event");
- calendarDatabase.deleteEvent(clientRequest);
- // if (Config.getBooleanValue("client_run"))
- calendarDatabase.flush();
-
- } else if (clientRequest.actionIs(ClientRequest.ADD_EVENT)) {
- Main.infoMessage("Server: Client wants to add an event");
- calendarDatabase.addEvent(clientRequest);
- // if (Config.getBooleanValue("client_run"))
- calendarDatabase.flush();
-
- } else if (clientRequest.actionIs(ClientRequest.RENAME_CATEGORY)) {
- Main.infoMessage("Server: Client wants to rename a category");
- calendarDatabase.renameCategory(clientRequest);
- // if (Config.getBooleanValue("client_run"))
- calendarDatabase.flush();
-
- } else if (clientRequest.actionIs(ClientRequest.DELETE_CATEGORY)) {
- Main.infoMessage("Server: Client wants to delete a category (NYI)");
- calendarDatabase.deleteCategory(clientRequest);
- // if (Config.getBooleanValue("client_run"))
- calendarDatabase.flush();
-
- } else if (clientRequest.actionIs(ClientRequest.RELOAD_DATABASE)) {
- // Read and parse the whole calendar database from file!
- parser = new CalendarFormatParser();
- parser.setWorkdir(sWorkdir);
- parser.start();
-
- calendarDatabase = new CalendarDatabase(parser.getCategories());
-
- } else if (clientRequest.actionIs(ClientRequest.FLUSH_DATABASE)) {
- Main.infoMessage("Server: Client wants to flush the database");
- calendarDatabase.flush();
-
- } else if (clientRequest.actionIs(ClientRequest.SHUTDOWN_SERVER)) {
- Main.infoMessage("Server: Client wants the server to shut down");
- calendarDatabase.flush();
- socket.close();
-
- if (Config.getBooleanValue("client_run")) {
- Main.infoMessage("Server: Shutting down the server thread");
- socket.close();
- serverSocket.close();
- break;
- } else {
- Main.exit(0);
- }
- }
+ private int iPort;
+ private String sWorkdir;
+
+ /**
+ * Creates a NetCalendarServer instance and runs it as a thread.
+ * @param iPort Specifies the server port of the server to be used.
+ * @param sWorkdir Specifies the working directory of the server.
+ */
+ public NetCalendarServer(int iPort, String sWorkdir) {
+ this.iPort = iPort;
+ this.sWorkdir = sWorkdir;
+
+ start();
+ }
- socket.close();
- }
+ /**
+ * This method initializes a new server socket.
+ * @return Returns the server socket object.
+ */
+ private ServerSocket makeServerSocket() throws IOException {
+ if (!Config.getBooleanValue("use_ssl"))
+ return new ServerSocket(iPort);
- } catch (ClassNotFoundException e) {
- Main.infoMessage("Error: Server error during serialization: " + e.getMessage());
+ ServerSocketFactory sslSocketFactory = SSLServerSocketFactory.getDefault();
+ return sslSocketFactory.createServerSocket(iPort);
+ }
- } catch (IOException e) {
- Main.infoMessage("Error: Server error during serialization: " + e.getMessage());
+ /**
+ * This method specifies the start method of the Thread. Its setting up the server port.
+ */
+ public void run() {
+ ServerSocket serverSocket = null;
+ Socket socket = null;
+
+ // Read and parse the whole calendar database from file!
+ CalendarFormatParser parser = new CalendarFormatParser();
+ parser.setWorkdir(sWorkdir);
+ parser.start();
+
+ CalendarDatabase calendarDatabase = new CalendarDatabase(parser.getCategories());
+
+ try {
+ serverSocket = makeServerSocket();
+
+ while (true) {
+ // This will wait for a connection to be made to this socket.
+ socket = serverSocket.accept();
+ // serverSocket.accept();
+ socket.setKeepAlive(true);
+
+ // Recieve the client's request object
+ InputStream inputStream = socket.getInputStream();
+ ObjectInput objectInput = new ObjectInputStream(inputStream);
+ ClientRequest clientRequest = (ClientRequest) objectInput.readObject();
+
+ if (!clientRequest.checkPassphrase(Config.getStringValue("passphrase", false))) {
+ Main.infoMessage("Server: Client refused, wrong passphrase!");
+
+ // Check if a event has been modified!
+ } else if (clientRequest.requestsNewEvents()) {
+ Main.infoMessage("Server: Client requests new events");
+
+ // Get all calendar events which match the request
+ Vector vecEvents = calendarDatabase.getMatchingEvents(clientRequest);
+ ServerResponse serverResponse = new ServerResponse(vecEvents);
+
+ OutputStream outputStream = socket.getOutputStream();
+ ObjectOutput objectOutput = new ObjectOutputStream(outputStream);
+ objectOutput.writeObject(serverResponse);
+ objectOutput.flush();
+ objectOutput.close();
+
+ } else if (clientRequest.actionIs(ClientRequest.MODIFY_EVENT)) {
+ Main.infoMessage("Server: Client wants to modify an event");
+ calendarDatabase.modifyEvent(clientRequest);
+ // if (Config.getBooleanValue("client_run"))
+ calendarDatabase.flush();
+
+ } else if (clientRequest.actionIs(ClientRequest.DELETE_EVENT)) {
+ Main.infoMessage("Server: Client wants to delete an event");
+ calendarDatabase.deleteEvent(clientRequest);
+ // if (Config.getBooleanValue("client_run"))
+ calendarDatabase.flush();
+
+ } else if (clientRequest.actionIs(ClientRequest.ADD_EVENT)) {
+ Main.infoMessage("Server: Client wants to add an event");
+ calendarDatabase.addEvent(clientRequest);
+ // if (Config.getBooleanValue("client_run"))
+ calendarDatabase.flush();
+
+ } else if (clientRequest.actionIs(ClientRequest.RENAME_CATEGORY)) {
+ Main.infoMessage("Server: Client wants to rename a category");
+ calendarDatabase.renameCategory(clientRequest);
+ // if (Config.getBooleanValue("client_run"))
+ calendarDatabase.flush();
+
+ } else if (clientRequest.actionIs(ClientRequest.DELETE_CATEGORY)) {
+ Main.infoMessage("Server: Client wants to delete a category (NYI)");
+ calendarDatabase.deleteCategory(clientRequest);
+ // if (Config.getBooleanValue("client_run"))
+ calendarDatabase.flush();
+
+ } else if (clientRequest.actionIs(ClientRequest.RELOAD_DATABASE)) {
+ // Read and parse the whole calendar database from file!
+ parser = new CalendarFormatParser();
+ parser.setWorkdir(sWorkdir);
+ parser.start();
+
+ calendarDatabase = new CalendarDatabase(parser.getCategories());
+
+ } else if (clientRequest.actionIs(ClientRequest.FLUSH_DATABASE)) {
+ Main.infoMessage("Server: Client wants to flush the database");
+ calendarDatabase.flush();
+
+ } else if (clientRequest.actionIs(ClientRequest.SHUTDOWN_SERVER)) {
+ Main.infoMessage("Server: Client wants the server to shut down");
+ calendarDatabase.flush();
+ socket.close();
+
+ if (Config.getBooleanValue("client_run")) {
+ Main.infoMessage("Server: Shutting down the server thread");
+ socket.close();
+ serverSocket.close();
+ break;
+ } else {
+ Main.exit(0);
+ }
+ }
+
+ socket.close();
+ }
+
+ } catch (ClassNotFoundException e) {
+ Main.infoMessage("Error: Server error during serialization: " + e.getMessage());
+
+ } catch (IOException e) {
+ Main.infoMessage("Error: Server error during serialization: " + e.getMessage());
+ }
}
- }
}
diff --git a/sources/shared/CalendarCategory.java b/sources/shared/CalendarCategory.java
index 94c215c..1e686d7 100644
--- a/sources/shared/CalendarCategory.java
+++ b/sources/shared/CalendarCategory.java
@@ -1,3 +1,7 @@
+/* NetCalendar 2006, 2009 (c) Dipl.-Inform. (FH) Paul C. Buetow
+ * http://netcalendar.buetow.org - netcalendar@dev.buetow.org
+ */
+
/**
*
*/
@@ -18,206 +22,206 @@ import shared.remotecall.*;
*
*/
public class CalendarCategory {
- private Vector vecEvents;
- private String sCategoryName;
- private boolean bHasChanged = false;
- private File categoryFile;
-
- /**
- * Creates a new calendar category object and sets the categorie's name to the filename of the category.
- * @param categoryFile The file object which contains the unparsed events for this specific category. It will be unset after parsing.
- */
- public CalendarCategory(File categoryFile) {
- this.categoryFile = categoryFile;
- this.sCategoryName = categoryFile.getName();
-
- // sCategoryName is now "calendar.Name", remove now the leading 'calendar.'
- sCategoryName = sCategoryName.substring(sCategoryName.indexOf('.') + 1);
- }
-
- /**
- * Creates a new calendar category object and sets the categorie's File to the name of the category.
- * @param sCategoryName Specifies the categorie's name.
- */
- public CalendarCategory(String sCategoryName) {
- this.sCategoryName = sCategoryName;
- }
-
- /**
- * This method sets the categorie's initial events.
- * @param vecEvents Specifies the categorie's events.
- */
- public void setEvents(Vector vecEvents) {
- this.vecEvents = vecEvents;
- }
-
- /**
- * This method adds an event to the category.
- * @param event Specifies the calendar event to add to this category.
- */
- public void addEvent(CalendarEvent event) {
- if (vecEvents == null)
- vecEvents = new Vector();
-
- vecEvents.add(event);
- }
-
- /**
- * This method returns the calendar events file object.
- * @return Returns the categorie's file object.
- */
- public File getFile() {
- return categoryFile;
- }
-
- /**
- * This method Sets the categories file handle to null. This is done if all the data has been read from
- * the file database.
- */
- public void unsetFile() {
- categoryFile = null;
- }
-
- /**
- * This method returns the categorie's name.
- * @return Returns the categorie's name.
- */
- public String getName() {
- return sCategoryName;
- }
-
- /**
- * This method sets the categorie's name.
- */
- public void setName(String sCategoryName) {
- if (this.sCategoryName.equals(sCategoryName))
- return;
-
- deleteDatabaseFile();
- this.sCategoryName = sCategoryName;
- categoryFile = new File(Config.getStringValue("server_database_dir")+"/calendar."+sCategoryName);
- setHasChanged(true);
- }
-
- /**
- * This method deletes the database file of this event.
- */
- public void deleteDatabaseFile() {
- if (categoryFile == null)
- categoryFile = new File(Config.getStringValue("server_database_dir")+"/calendar."+getName());
-
- Main.infoMessage("Removing " + categoryFile.getPath());
- categoryFile.delete();
- }
-
- /**
- * This method returns the categorie's events.
- * @return Returns a Vector of all CalendarEvent objects.
- */
- public Vector getEvents() {
- return vecEvents;
- }
-
- /**
- * This method looks for all calendar events of this category which matches a given client's request.
- * @param clientRequest Specifies the client request sent by the calendar client.
- * @return Returns a Vector of all matching CalendarEvent objects.
- */
- public Vector getMatchingEvents(ClientRequest clientRequest) {
- Vector vecMatching = new Vector();
- int iNumEventsToRequest = clientRequest.getNumEventsToRequest();
-
- Enumeration enumEvents = vecEvents.elements();
- while (enumEvents.hasMoreElements()) {
- CalendarEvent event = (CalendarEvent) enumEvents.nextElement();
- if (clientRequest.match(event))
- vecMatching.add(event);
-
- if (iNumEventsToRequest > -1 && iNumEventsToRequest == vecMatching.size())
- break;
- }
-
- return vecMatching;
- }
-
- /**
- * This method checks the current category's name against a regular expression pattern.
- * @param pattern Specifies the pattern to be used.
- * @return Returns true if the event matches, else false will be returned.
- */
- public boolean matchesName(Pattern pattern) {
- if (pattern == null)
- return false;
-
- return pattern.matcher(getName()).find();
- }
-
- /**
- * This method removes a given event from its event vector.
- * @param event Specifies the calendar event object to be removed from this category
- */
- public void removeEvent(CalendarEvent event) {
- getEvents().removeElement(event);
- }
-
- /**
- * This method lets you check if the calendar category has been modified/changed by a
- * calendar client request. This is needed by the CalendarDatabase.flush method, to write all
- * the changes back to the database files.
- * @return Returns true if the category has changed, else it will return false.
- */
- public boolean hasChanged() {
- return bHasChanged;
- }
-
- /**
- * This method merges two categories.
- * @param calendarCategory Specifies the category to merge with.
- */
- public void merge(CalendarCategory calendarCategory) {
- Enumeration enumEvents = calendarCategory.getEvents().elements();
- while (enumEvents.hasMoreElements())
- vecEvents.add(enumEvents.nextElement());
-
- System.out.println(vecEvents);
- }
-
- /**
- * This method specifies if the calendar category has been modified/changed or not.
- * @param bHasChanged Specifies if the category has been modified/changed or not.
- */
- public void setHasChanged(boolean bHasChanged) {
- this.bHasChanged = bHasChanged;
- }
-
- /**
- * This method flushes the calendar category to the database at the filesystem.
- */
- public void flush() {
- Main.infoMessage("Flushing category " + getName() + " to database!");
-
- if (vecEvents.size() == 0) {
- deleteDatabaseFile();
- return;
- }
-
- try {
- FileWriter fileWriter = new FileWriter(
- Config.getStringValue("server_database_dir") + "/calendar." + getName());
- BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
-
- Enumeration enumEvent = vecEvents.elements();
- while (enumEvent.hasMoreElements()) {
- CalendarEvent event = (CalendarEvent) enumEvent.nextElement();
- event.flush(bufferedWriter);
- }
-
- bufferedWriter.close();
-
- } catch (IOException e) {
- Main.infoMessage("Error: Database flush error: " + e.getMessage());
- }
-
- setHasChanged(false);
- }
+ private Vector vecEvents;
+ private String sCategoryName;
+ private boolean bHasChanged = false;
+ private File categoryFile;
+
+ /**
+ * Creates a new calendar category object and sets the categorie's name to the filename of the category.
+ * @param categoryFile The file object which contains the unparsed events for this specific category. It will be unset after parsing.
+ */
+ public CalendarCategory(File categoryFile) {
+ this.categoryFile = categoryFile;
+ this.sCategoryName = categoryFile.getName();
+
+ // sCategoryName is now "calendar.Name", remove now the leading 'calendar.'
+ sCategoryName = sCategoryName.substring(sCategoryName.indexOf('.') + 1);
+ }
+
+ /**
+ * Creates a new calendar category object and sets the categorie's File to the name of the category.
+ * @param sCategoryName Specifies the categorie's name.
+ */
+ public CalendarCategory(String sCategoryName) {
+ this.sCategoryName = sCategoryName;
+ }
+
+ /**
+ * This method sets the categorie's initial events.
+ * @param vecEvents Specifies the categorie's events.
+ */
+ public void setEvents(Vector vecEvents) {
+ this.vecEvents = vecEvents;
+ }
+
+ /**
+ * This method adds an event to the category.
+ * @param event Specifies the calendar event to add to this category.
+ */
+ public void addEvent(CalendarEvent event) {
+ if (vecEvents == null)
+ vecEvents = new Vector();
+
+ vecEvents.add(event);
+ }
+
+ /**
+ * This method returns the calendar events file object.
+ * @return Returns the categorie's file object.
+ */
+ public File getFile() {
+ return categoryFile;
+ }
+
+ /**
+ * This method Sets the categories file handle to null. This is done if all the data has been read from
+ * the file database.
+ */
+ public void unsetFile() {
+ categoryFile = null;
+ }
+
+ /**
+ * This method returns the categorie's name.
+ * @return Returns the categorie's name.
+ */
+ public String getName() {
+ return sCategoryName;
+ }
+
+ /**
+ * This method sets the categorie's name.
+ */
+ public void setName(String sCategoryName) {
+ if (this.sCategoryName.equals(sCategoryName))
+ return;
+
+ deleteDatabaseFile();
+ this.sCategoryName = sCategoryName;
+ categoryFile = new File(Config.getStringValue("server_database_dir")+"/calendar."+sCategoryName);
+ setHasChanged(true);
+ }
+
+ /**
+ * This method deletes the database file of this event.
+ */
+ public void deleteDatabaseFile() {
+ if (categoryFile == null)
+ categoryFile = new File(Config.getStringValue("server_database_dir")+"/calendar."+getName());
+
+ Main.infoMessage("Removing " + categoryFile.getPath());
+ categoryFile.delete();
+ }
+
+ /**
+ * This method returns the categorie's events.
+ * @return Returns a Vector of all CalendarEvent objects.
+ */
+ public Vector getEvents() {
+ return vecEvents;
+ }
+
+ /**
+ * This method looks for all calendar events of this category which matches a given client's request.
+ * @param clientRequest Specifies the client request sent by the calendar client.
+ * @return Returns a Vector of all matching CalendarEvent objects.
+ */
+ public Vector getMatchingEvents(ClientRequest clientRequest) {
+ Vector vecMatching = new Vector();
+ int iNumEventsToRequest = clientRequest.getNumEventsToRequest();
+
+ Enumeration enumEvents = vecEvents.elements();
+ while (enumEvents.hasMoreElements()) {
+ CalendarEvent event = (CalendarEvent) enumEvents.nextElement();
+ if (clientRequest.match(event))
+ vecMatching.add(event);
+
+ if (iNumEventsToRequest > -1 && iNumEventsToRequest == vecMatching.size())
+ break;
+ }
+
+ return vecMatching;
+ }
+
+ /**
+ * This method checks the current category's name against a regular expression pattern.
+ * @param pattern Specifies the pattern to be used.
+ * @return Returns true if the event matches, else false will be returned.
+ */
+ public boolean matchesName(Pattern pattern) {
+ if (pattern == null)
+ return false;
+
+ return pattern.matcher(getName()).find();
+ }
+
+ /**
+ * This method removes a given event from its event vector.
+ * @param event Specifies the calendar event object to be removed from this category
+ */
+ public void removeEvent(CalendarEvent event) {
+ getEvents().removeElement(event);
+ }
+
+ /**
+ * This method lets you check if the calendar category has been modified/changed by a
+ * calendar client request. This is needed by the CalendarDatabase.flush method, to write all
+ * the changes back to the database files.
+ * @return Returns true if the category has changed, else it will return false.
+ */
+ public boolean hasChanged() {
+ return bHasChanged;
+ }
+
+ /**
+ * This method merges two categories.
+ * @param calendarCategory Specifies the category to merge with.
+ */
+ public void merge(CalendarCategory calendarCategory) {
+ Enumeration enumEvents = calendarCategory.getEvents().elements();
+ while (enumEvents.hasMoreElements())
+ vecEvents.add(enumEvents.nextElement());
+
+ System.out.println(vecEvents);
+ }
+
+ /**
+ * This method specifies if the calendar category has been modified/changed or not.
+ * @param bHasChanged Specifies if the category has been modified/changed or not.
+ */
+ public void setHasChanged(boolean bHasChanged) {
+ this.bHasChanged = bHasChanged;
+ }
+
+ /**
+ * This method flushes the calendar category to the database at the filesystem.
+ */
+ public void flush() {
+ Main.infoMessage("Flushing category " + getName() + " to database!");
+
+ if (vecEvents.size() == 0) {
+ deleteDatabaseFile();
+ return;
+ }
+
+ try {
+ FileWriter fileWriter = new FileWriter(
+ Config.getStringValue("server_database_dir") + "/calendar." + getName());
+ BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
+
+ Enumeration enumEvent = vecEvents.elements();
+ while (enumEvent.hasMoreElements()) {
+ CalendarEvent event = (CalendarEvent) enumEvent.nextElement();
+ event.flush(bufferedWriter);
+ }
+
+ bufferedWriter.close();
+
+ } catch (IOException e) {
+ Main.infoMessage("Error: Database flush error: " + e.getMessage());
+ }
+
+ setHasChanged(false);
+ }
}
diff --git a/sources/shared/CalendarEvent.java b/sources/shared/CalendarEvent.java
index 9a54237..8558d91 100644
--- a/sources/shared/CalendarEvent.java
+++ b/sources/shared/CalendarEvent.java
@@ -1,3 +1,7 @@
+/* NetCalendar 2006, 2009 (c) Dipl.-Inform. (FH) Paul C. Buetow
+ * http://netcalendar.buetow.org - netcalendar@dev.buetow.org
+ */
+
/**
*
*/
@@ -14,326 +18,326 @@ import java.io.*;
*
*/
public class CalendarEvent implements Serializable {
- private static final long serialVersionUID = 1L;
- private MyDate date;
- private CalendarCategory category;
- private String sCategoryName;
- private String sDescription;
- private String sPlace;
- private boolean bYearly;
- private int iEventID;
-
- static private int iEventIDCount = 0;
-
- /**
- * Simple constructor, creates an event object and increments iEventIDCount by one.
- * @param category Specifies the event's category.
- */
- public CalendarEvent(CalendarCategory category) {
- setCategory(category);
- setEventID(iEventIDCount++);
- setYearly(false);
- }
-
- /**
- * Simple constructor, creates an event object and increments iEventIDCount by one.
- * @param sCategoryName Specifies the event's category name.
- */
- public CalendarEvent(String sCategoryName) {
- setCategoryName(sCategoryName.trim());
- setEventID(iEventIDCount++);
- setYearly(false);
- }
-
- /**
- * This method sets the event's date.
- * @param date Specifies the event's date.
- */
- public void setDate(Date date) {
- if (date instanceof MyDate)
- this.date = (MyDate) date;
- else
- this.date = new MyDate(date);
- }
-
- /**
- * This method sets the event's category.
- * @param category Specifies the event's category.
- */
- public void setCategory(CalendarCategory category) {
- this.category = category;
- setCategoryName(category.getName());
- }
-
- /**
- * This event returns the event's calendar category.
- * @return Returns the event's calenda category.
- */
- public CalendarCategory getCategory() {
- return category;
- }
-
- /**
- * This methos sets thhe event's category name.
- * @param sCategoryName Specifies the event's category name.
- */
- public void setCategoryName(String sCategoryName) {
- this.sCategoryName = sCategoryName.trim();
- }
-
- /**
- * This method sets the event's descriptions tring.
- * @param sDescription Specifies the event's description string.
- */
- public void setDescription(String sDescription) {
- this.sDescription = sDescription.trim();
- }
-
- /**
- * This method sets the event's place string.
- * @param sPlace Specifies the event's place string.
- */
- public void setPlace(String sPlace) {
- this.sPlace = sPlace.trim();
- }
-
- /**
- * This method sets the event's ID number.
- * @param iEventID specifies the event's ID number.
- */
- public void setEventID(int iEventID) {
- this.iEventID = iEventID;
- }
-
- /**
- * This method specifies if this event occurs yearly or not.
- * @param bYearly Specifies if this event occury yearly or not.
- */
- public void setYearly(boolean bYearly) {
- this.bYearly = bYearly;
- }
-
- /**
- * This method returns the event's category name.
- * @return Returns the event's category name.
- */
- public String getCategoryName() {
- return sCategoryName;
- }
-
- /**
- * This method returns the event's description string.
- * @return Returns the event's description string.
- */
- public String getDescription() {
- return sDescription;
- }
-
- /**
- * This method returns the event's place string.
- * @return Returns the event's place string.
- */
- public String getPlace() {
- return sPlace;
- }
-
- /**
- * This method returns the event's ID.
- * @return Returns the event's ID.
- */
- public int getID() {
- return iEventID;
- }
-
- /**
- * This method returns the event's date object.
- * @return Returns the event's date object.
- */
- public MyDate getDate() {
- return date;
- }
-
- /**
- * This method returns the event's ID number.
- * @return Returns the event's ID number.
- */
- public int getEventID() {
- return iEventID;
- }
-
- /**
- * This method checks if this event occurs yearly or not.
- * @return Returns true if the event occurs yearly, else it returns false.
- */
- public boolean isYearly() {
- return bYearly;
- }
-
- /**
- * Checks if the current event matches all available data of the event agains
- * a given regular expression pattern.
- * @param pattern Specifies the pattern to match against.
- * @return Returns true if one element of the event matches.
- */
- public boolean matches(Pattern pattern) {
- if (pattern == null)
- return false;
-
- else if (matchesDescription(pattern))
- return true;
-
- else if (matchesPlace(pattern))
- return true;
-
- else if (matchesCategoryName(pattern))
- return true;
-
- return matchesDateString(pattern);
- }
-
- /**
- * Checks if the current event's name matches agains a regular expression pattern.
- * @param pattern Specifies the pattern to be matched against.
- * @return Returns true if the event matches, else false will be returned. If the pattern is null, true will be returned.
- */
- public boolean matchesCategoryName(Pattern pattern) {
- if (pattern == null)
- return true;
-
- return pattern.matcher(getCategoryName()).find();
- }
-
- /**
- * Checks if the current event's description string matches agains a regular expression pattern.
- * @param pattern Specifies the pattern to match against.
- * @return Returns true if the event matches, else false will be returned. If the pattern is null, true will be returned.
- */
- public boolean matchesDescription(Pattern pattern) {
- if (pattern == null)
- return true;
-
- return pattern.matcher(getDescription()).find();
- }
-
- /**
- * Checks if the current event's place string matches agains a regular expression pattern.
- * @param pattern Specifies the pattern to match against.
- * @return Returns true if the event matches, else false will be returned. If the pattern is null, true will be returned.
- */
- public boolean matchesPlace(Pattern pattern) {
- if (pattern == null)
- return true;
-
- return pattern.matcher(getPlace()).find();
- }
-
- /**
- * Checks if the current event's category name matches agains a regular expression pattern
- * @param pattern Specifies the pattern to match against.
- * @return Returns true if the event matches, else false will be returned. If the pattern is null, true will be returned.
- */
- public boolean matchesCategory(Pattern pattern) {
- if (pattern == null)
- return true;
-
- return pattern.matcher(getCategoryName()).find();
- }
-
- /**
- * Checks if the current event's date string matches agains a regular expression pattern
- * @param pattern Specifies the pattern to match against.
- * @return Returns true if the event matches, else false will be returned. If the pattern is null, true will be returned.
- */
- public boolean matchesDateString(Pattern pattern) {
- if (pattern == null)
- return true;
-
- return pattern.matcher(getDate().toString()).find();
- }
-
- /**
- * Needed for ojbect serialization (sending part)-
- * @param objectOutputStream Specifies the output stream to use.
- * @throws IOException
- */
- private void writeObject(ObjectOutputStream objectOutputStream)
- throws IOException {
- objectOutputStream.writeInt(iEventID);
- objectOutputStream.writeBoolean(isYearly());
- objectOutputStream.writeObject(getDate());
- objectOutputStream.writeObject(getCategoryName());
- objectOutputStream.writeObject(getDescription());
- objectOutputStream.writeObject(getPlace());
- }
-
- /**
- * Needed for object serialization (receiving part).
- * @param objectInputStream Specifies the input stream to use.
- * @throws IOException
- * @throws ClassNotFoundException
- */
- private void readObject(ObjectInputStream objectInputStream)
- throws IOException, ClassNotFoundException {
- setEventID(objectInputStream.readInt());
- setYearly(objectInputStream.readBoolean());
- setDate((Date) objectInputStream.readObject());
- setCategoryName((String) objectInputStream.readObject());
- setDescription((String) objectInputStream.readObject());
- setPlace((String) objectInputStream.readObject());
-
- if (getEventID() < 0 )
- setEventID(iEventIDCount++);
- }
-
- /**
- * Removes the calendar event from its current category and sets the
- * category reference to null.
- */
- public void removeFromCurrentCategory() {
- CalendarCategory category = getCategory();
- category.removeEvent(this);
- }
-
- /**
- * This method flushes the calendar event to the database at the filesystem.
- * @param bufferedWriter Specifies the buffered writer to write to.
- */
- protected void flush(BufferedWriter bufferedWriter) throws IOException {
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(getDate());
- int iYear = calendar.get(Calendar.YEAR);
- // if (iYear < 11) iYear += 2000;
- int iMonth = calendar.get(Calendar.MONTH) + 1;
- int iDays = calendar.get(Calendar.DAY_OF_MONTH);
- int iHours= calendar.get(Calendar.HOUR);
- int iMinutes = calendar.get(Calendar.MINUTE);
-
- String sPlace = getPlace();
- if (!sPlace.equals(""))
- sPlace = ";;" + sPlace;
-
- String sYearly = isYearly() ? "yearly" : MyDate.addZerosToFront(iYear, 4);
- String sEventLine =
- MyDate.addZerosToFront(iMonth, 2) + "/"
- + MyDate.addZerosToFront(iDays, 2) + "\t"
- + sYearly + "-"
- + MyDate.addZerosToFront(iHours, 2) + ":"
- + MyDate.addZerosToFront(iMinutes, 2) + " "
- + getDescription()
- + sPlace + "\n";
-
- bufferedWriter.write(sEventLine);
- }
-
- /**
- * This method is needed for a text representation of the object.
- * @return Returns object represented as a String.
- */
- public String toString() {
- return "#" + getEventID() + " " + getDate() + "\n"
- + "Yearly : " + isYearly() + "\n"
- + "Category : " + getCategoryName() + "\n"
- + "Description: " + getDescription() + "\n"
- + "Place : " + getPlace() + "\n";
- }
+ private static final long serialVersionUID = 1L;
+ private MyDate date;
+ private CalendarCategory category;
+ private String sCategoryName;
+ private String sDescription;
+ private String sPlace;
+ private boolean bYearly;
+ private int iEventID;
+
+ static private int iEventIDCount = 0;
+
+ /**
+ * Simple constructor, creates an event object and increments iEventIDCount by one.
+ * @param category Specifies the event's category.
+ */
+ public CalendarEvent(CalendarCategory category) {
+ setCategory(category);
+ setEventID(iEventIDCount++);
+ setYearly(false);
+ }
+
+ /**
+ * Simple constructor, creates an event object and increments iEventIDCount by one.
+ * @param sCategoryName Specifies the event's category name.
+ */
+ public CalendarEvent(String sCategoryName) {
+ setCategoryName(sCategoryName.trim());
+ setEventID(iEventIDCount++);
+ setYearly(false);
+ }
+
+ /**
+ * This method sets the event's date.
+ * @param date Specifies the event's date.
+ */
+ public void setDate(Date date) {
+ if (date instanceof MyDate)
+ this.date = (MyDate) date;
+ else
+ this.date = new MyDate(date);
+ }
+
+ /**
+ * This method sets the event's category.
+ * @param category Specifies the event's category.
+ */
+ public void setCategory(CalendarCategory category) {
+ this.category = category;
+ setCategoryName(category.getName());
+ }
+
+ /**
+ * This event returns the event's calendar category.
+ * @return Returns the event's calenda category.
+ */
+ public CalendarCategory getCategory() {
+ return category;
+ }
+
+ /**
+ * This methos sets thhe event's category name.
+ * @param sCategoryName Specifies the event's category name.
+ */
+ public void setCategoryName(String sCategoryName) {
+ this.sCategoryName = sCategoryName.trim();
+ }
+
+ /**
+ * This method sets the event's descriptions tring.
+ * @param sDescription Specifies the event's description string.
+ */
+ public void setDescription(String sDescription) {
+ this.sDescription = sDescription.trim();
+ }
+
+ /**
+ * This method sets the event's place string.
+ * @param sPlace Specifies the event's place string.
+ */
+ public void setPlace(String sPlace) {
+ this.sPlace = sPlace.trim();
+ }
+
+ /**
+ * This method sets the event's ID number.
+ * @param iEventID specifies the event's ID number.
+ */
+ public void setEventID(int iEventID) {
+ this.iEventID = iEventID;
+ }
+
+ /**
+ * This method specifies if this event occurs yearly or not.
+ * @param bYearly Specifies if this event occury yearly or not.
+ */
+ public void setYearly(boolean bYearly) {
+ this.bYearly = bYearly;
+ }
+
+ /**
+ * This method returns the event's category name.
+ * @return Returns the event's category name.
+ */
+ public String getCategoryName() {
+ return sCategoryName;
+ }
+
+ /**
+ * This method returns the event's description string.
+ * @return Returns the event's description string.
+ */
+ public String getDescription() {
+ return sDescription;
+ }
+
+ /**
+ * This method returns the event's place string.
+ * @return Returns the event's place string.
+ */
+ public String getPlace() {
+ return sPlace;
+ }
+
+ /**
+ * This method returns the event's ID.
+ * @return Returns the event's ID.
+ */
+ public int getID() {
+ return iEventID;
+ }
+
+ /**
+ * This method returns the event's date object.
+ * @return Returns the event's date object.
+ */
+ public MyDate getDate() {
+ return date;
+ }
+
+ /**
+ * This method returns the event's ID number.
+ * @return Returns the event's ID number.
+ */
+ public int getEventID() {
+ return iEventID;
+ }
+
+ /**
+ * This method checks if this event occurs yearly or not.
+ * @return Returns true if the event occurs yearly, else it returns false.
+ */
+ public boolean isYearly() {
+ return bYearly;
+ }
+
+ /**
+ * Checks if the current event matches all available data of the event agains
+ * a given regular expression pattern.
+ * @param pattern Specifies the pattern to match against.
+ * @return Returns true if one element of the event matches.
+ */
+ public boolean matches(Pattern pattern) {
+ if (pattern == null)
+ return false;
+
+ else if (matchesDescription(pattern))
+ return true;
+
+ else if (matchesPlace(pattern))
+ return true;
+
+ else if (matchesCategoryName(pattern))
+ return true;
+
+ return matchesDateString(pattern);
+ }
+
+ /**
+ * Checks if the current event's name matches agains a regular expression pattern.
+ * @param pattern Specifies the pattern to be matched against.
+ * @return Returns true if the event matches, else false will be returned. If the pattern is null, true will be returned.
+ */
+ public boolean matchesCategoryName(Pattern pattern) {
+ if (pattern == null)
+ return true;
+
+ return pattern.matcher(getCategoryName()).find();
+ }
+
+ /**
+ * Checks if the current event's description string matches agains a regular expression pattern.
+ * @param pattern Specifies the pattern to match against.
+ * @return Returns true if the event matches, else false will be returned. If the pattern is null, true will be returned.
+ */
+ public boolean matchesDescription(Pattern pattern) {
+ if (pattern == null)
+ return true;
+
+ return pattern.matcher(getDescription()).find();
+ }
+
+ /**
+ * Checks if the current event's place string matches agains a regular expression pattern.
+ * @param pattern Specifies the pattern to match against.
+ * @return Returns true if the event matches, else false will be returned. If the pattern is null, true will be returned.
+ */
+ public boolean matchesPlace(Pattern pattern) {
+ if (pattern == null)
+ return true;
+
+ return pattern.matcher(getPlace()).find();
+ }
+
+ /**
+ * Checks if the current event's category name matches agains a regular expression pattern
+ * @param pattern Specifies the pattern to match against.
+ * @return Returns true if the event matches, else false will be returned. If the pattern is null, true will be returned.
+ */
+ public boolean matchesCategory(Pattern pattern) {
+ if (pattern == null)
+ return true;
+
+ return pattern.matcher(getCategoryName()).find();
+ }
+
+ /**
+ * Checks if the current event's date string matches agains a regular expression pattern
+ * @param pattern Specifies the pattern to match against.
+ * @return Returns true if the event matches, else false will be returned. If the pattern is null, true will be returned.
+ */
+ public boolean matchesDateString(Pattern pattern) {
+ if (pattern == null)
+ return true;
+
+ return pattern.matcher(getDate().toString()).find();
+ }
+
+ /**
+ * Needed for ojbect serialization (sending part)-
+ * @param objectOutputStream Specifies the output stream to use.
+ * @throws IOException
+ */
+ private void writeObject(ObjectOutputStream objectOutputStream)
+ throws IOException {
+ objectOutputStream.writeInt(iEventID);
+ objectOutputStream.writeBoolean(isYearly());
+ objectOutputStream.writeObject(getDate());
+ objectOutputStream.writeObject(getCategoryName());
+ objectOutputStream.writeObject(getDescription());
+ objectOutputStream.writeObject(getPlace());
+ }
+
+ /**
+ * Needed for object serialization (receiving part).
+ * @param objectInputStream Specifies the input stream to use.
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ private void readObject(ObjectInputStream objectInputStream)
+ throws IOException, ClassNotFoundException {
+ setEventID(objectInputStream.readInt());
+ setYearly(objectInputStream.readBoolean());
+ setDate((Date) objectInputStream.readObject());
+ setCategoryName((String) objectInputStream.readObject());
+ setDescription((String) objectInputStream.readObject());
+ setPlace((String) objectInputStream.readObject());
+
+ if (getEventID() < 0 )
+ setEventID(iEventIDCount++);
+ }
+
+ /**
+ * Removes the calendar event from its current category and sets the
+ * category reference to null.
+ */
+ public void removeFromCurrentCategory() {
+ CalendarCategory category = getCategory();
+ category.removeEvent(this);
+ }
+
+ /**
+ * This method flushes the calendar event to the database at the filesystem.
+ * @param bufferedWriter Specifies the buffered writer to write to.
+ */
+ protected void flush(BufferedWriter bufferedWriter) throws IOException {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(getDate());
+ int iYear = calendar.get(Calendar.YEAR);
+ // if (iYear < 11) iYear += 2000;
+ int iMonth = calendar.get(Calendar.MONTH) + 1;
+ int iDays = calendar.get(Calendar.DAY_OF_MONTH);
+ int iHours= calendar.get(Calendar.HOUR);
+ int iMinutes = calendar.get(Calendar.MINUTE);
+
+ String sPlace = getPlace();
+ if (!sPlace.equals(""))
+ sPlace = ";;" + sPlace;
+
+ String sYearly = isYearly() ? "yearly" : MyDate.addZerosToFront(iYear, 4);
+ String sEventLine =
+ MyDate.addZerosToFront(iMonth, 2) + "/"
+ + MyDate.addZerosToFront(iDays, 2) + "\t"
+ + sYearly + "-"
+ + MyDate.addZerosToFront(iHours, 2) + ":"
+ + MyDate.addZerosToFront(iMinutes, 2) + " "
+ + getDescription()
+ + sPlace + "\n";
+
+ bufferedWriter.write(sEventLine);
+ }
+
+ /**
+ * This method is needed for a text representation of the object.
+ * @return Returns object represented as a String.
+ */
+ public String toString() {
+ return "#" + getEventID() + " " + getDate() + "\n"
+ + "Yearly : " + isYearly() + "\n"
+ + "Category : " + getCategoryName() + "\n"
+ + "Description: " + getDescription() + "\n"
+ + "Place : " + getPlace() + "\n";
+ }
}
diff --git a/sources/shared/Config.java b/sources/shared/Config.java
index 40e561c..6211699 100644
--- a/sources/shared/Config.java
+++ b/sources/shared/Config.java
@@ -1,3 +1,7 @@
+/* NetCalendar 2006, 2009 (c) Dipl.-Inform. (FH) Paul C. Buetow
+ * http://netcalendar.buetow.org - netcalendar@dev.buetow.org
+ */
+
package shared;
import java.util.*;
@@ -11,226 +15,226 @@ import java.io.*;
*
*/
public final class Config {
- public static final String VERSION = "NetCalendar 1.1 SVN";
- private static final String CONFIG_FILE = "netcalendar.conf";
- private static HashMap mapConfigVals;
-
- /**
- * Initializes all the config values.
- * @param args The start parameters.
- */
- public static void initialize(String[] args) {
- if (args.length > 0) {
- if (args[0].equals("--help")) {
- System.out.println(Config.VERSION + " help");
- System.out.println("(c) 2006, 2009 by Dipl.-Inform. (FH) Paul C. Buetow [netcalendar@dev.buetow.org]");
- System.out.println("This is free software, see the LICENSE.txt for copying conditions. There is NO");
- System.out.println("warranty; not even for MERCHANTABILITY of FITNESS FOR A PARTICULAR PURPOSE.");
- System.out.println();
- System.out.println("Possible start parameters are:");
- System.out.println("\t--help Shows this help and exists");
- System.out.println("\t--client-only Runs the NetCalendar client only");
- System.out.println("\t--server-address=host Specifies the server host to connect to");
- System.out.println("\t--server-only Runs the NetCalendar server only");
- System.out.println("\t--client-and-server Runs the NetCalendar server and client");
- System.out.println("\t within the same process!");
- System.out.println();
- System.exit(0);
- }
+ public static final String VERSION = "NetCalendar 1.1 SVN";
+ private static final String CONFIG_FILE = "netcalendar.conf";
+ private static HashMap mapConfigVals;
+
+ /**
+ * Initializes all the config values.
+ * @param args The start parameters.
+ */
+ public static void initialize(String[] args) {
+ if (args.length > 0) {
+ if (args[0].equals("--help")) {
+ System.out.println(Config.VERSION + " help");
+ System.out.println("(c) 2006, 2009 by Dipl.-Inform. (FH) Paul C. Buetow [netcalendar@dev.buetow.org]");
+ System.out.println("This is free software, see the LICENSE.txt for copying conditions. There is NO");
+ System.out.println("warranty; not even for MERCHANTABILITY of FITNESS FOR A PARTICULAR PURPOSE.");
+ System.out.println();
+ System.out.println("Possible start parameters are:");
+ System.out.println("\t--help Shows this help and exists");
+ System.out.println("\t--client-only Runs the NetCalendar client only");
+ System.out.println("\t--server-address=host Specifies the server host to connect to");
+ System.out.println("\t--server-only Runs the NetCalendar server only");
+ System.out.println("\t--client-and-server Runs the NetCalendar server and client");
+ System.out.println("\t within the same process!");
+ System.out.println();
+ System.exit(0);
+ }
+ }
+
+ mapConfigVals = new HashMap();
+ readConfig(CONFIG_FILE);
+
+ for (int i = 0; i < args.length; ++i) {
+ if (args[i].equals("--server-only")) {
+ mapConfigVals.put("server_run", "true");
+ mapConfigVals.put("client_run", "false");
+
+ } else if (args[i].equals("--client-only")) {
+ mapConfigVals.put("server_run", "false");
+ mapConfigVals.put("client_run", "true");
+
+ } else if (args[i].equals("--client-and-server")) {
+ mapConfigVals.put("server_run", "true");
+ mapConfigVals.put("client_run", "true");
+ mapConfigVals.put("server_address", "localhost");
+
+ } else if (args[i].startsWith("--server-address=")) {
+ mapConfigVals.put("server_address", args[i].substring(17));
+ }
+ }
+
+ if (args.length > 0)
+ writeConfigToFile();
}
- mapConfigVals = new HashMap();
- readConfig(CONFIG_FILE);
+ /**
+ * This methods reads the options from the calendar config file 'netcalendar.conf'.
+ * @param sConfigFile Specifies the relative or absolute path to the config file.
+ */
+ public static void readConfig(String sConfigFile) {
+ Main.infoMessage("Config: Using config file " + sConfigFile);
+ File file = new File(sConfigFile);
+
+ if (!file.isFile()) {
+ Main.infoMessage("Config: " + sConfigFile + " is not a file!");
+ System.exit(1);
+ }
+
+ try {
+ BufferedReader in = new BufferedReader(new FileReader(file));
+ String sLine;
+
+ while ((sLine = in.readLine()) != null) {
+ int iSeperator = sLine.indexOf('=');
- for (int i = 0; i < args.length; ++i) {
- if (args[i].equals("--server-only")) {
- mapConfigVals.put("server_run", "true");
- mapConfigVals.put("client_run", "false");
+ if (iSeperator > -1) {
+ int iEnd = sLine.indexOf(';');
- } else if (args[i].equals("--client-only")) {
- mapConfigVals.put("server_run", "false");
- mapConfigVals.put("client_run", "true");
+ if (iEnd > -1) {
+ String sKey = sLine.substring(0, iSeperator).trim();
+ String sVal = sLine.substring(iSeperator+1, iEnd).trim();
+ mapConfigVals.put(sKey, sVal);
+ }
+ }
+ }
+
+ } catch (Exception e) {
+ Main.infoMessage("Config: " + e.getMessage());
+ System.exit(1);
+ }
+ }
- } else if (args[i].equals("--client-and-server")) {
- mapConfigVals.put("server_run", "true");
- mapConfigVals.put("client_run", "true");
- mapConfigVals.put("server_address", "localhost");
+ /**
+ * This method returns the inet address of the calendar server.
+ * @return Returns the calendar server's address .
+ */
+ public static InetAddress getServerAddress() {
+ InetAddress serverAddress = null;
+
+ try {
+ serverAddress = InetAddress.getByName(Config.getStringValue("server_address"));
+ } catch (Exception e) {
+ Main.infoMessage("Server address error: " + e.getMessage());
+ }
- } else if (args[i].startsWith("--server-address=")) {
- mapConfigVals.put("server_address", args[i].substring(17));
- }
+ return serverAddress;
}
- if (args.length > 0)
- writeConfigToFile();
- }
-
- /**
- * This methods reads the options from the calendar config file 'netcalendar.conf'.
- * @param sConfigFile Specifies the relative or absolute path to the config file.
- */
- public static void readConfig(String sConfigFile) {
- Main.infoMessage("Config: Using config file " + sConfigFile);
- File file = new File(sConfigFile);
-
- if (!file.isFile()) {
- Main.infoMessage("Config: " + sConfigFile + " is not a file!");
- System.exit(1);
+ /**
+ * This method returns a specific string config value.
+ * @param sKey Specifies the key of the config value to return.
+ * @return Returns the requested config value.
+ */
+ public static String getStringValue(String sKey) {
+ return getStringValue(sKey, true);
}
- try {
- BufferedReader in = new BufferedReader(new FileReader(file));
- String sLine;
+ /**
+ * This method returns a specific string config value.
+ * @param sKey Specifies the key of the config value to return.
+ * @param bLogMessages Specifies if this action should be logged or not.
+ * @return Returns the requested config value.
+ */
+ public static String getStringValue(String sKey, boolean bLogMessage) {
+ String sRet = (String) mapConfigVals.get(sKey);
- while ((sLine = in.readLine()) != null) {
- int iSeperator = sLine.indexOf('=');
+ if (sRet != null)
+ sRet = sRet.trim();
- if (iSeperator > -1) {
- int iEnd = sLine.indexOf(';');
+ return sRet;
+ }
- if (iEnd > -1) {
- String sKey = sLine.substring(0, iSeperator).trim();
- String sVal = sLine.substring(iSeperator+1, iEnd).trim();
- mapConfigVals.put(sKey, sVal);
- }
- }
- }
+ /**
+ * This method returns a specific integer config value.
+ * @param sKey Specifies the key of the config value to return.
+ * @return Returns the requested config value.
+ */
+ public static int getIntValue(String sKey) {
+ String sVal = (String) mapConfigVals.get(sKey);
+
+ if (sVal != null)
+ sVal = sVal.trim();
- } catch (Exception e) {
- Main.infoMessage("Config: " + e.getMessage());
- System.exit(1);
+ return Integer.parseInt(sVal);
}
- }
-
- /**
- * This method returns the inet address of the calendar server.
- * @return Returns the calendar server's address .
- */
- public static InetAddress getServerAddress() {
- InetAddress serverAddress = null;
-
- try {
- serverAddress = InetAddress.getByName(Config.getStringValue("server_address"));
- } catch (Exception e) {
- Main.infoMessage("Server address error: " + e.getMessage());
+
+ /**
+ * This method returns a specific boolean config value.
+ * @param sKey Specifies the key of the config value to return.
+ * @return Returns the requested config value.
+ */
+ public static boolean getBooleanValue(String sKey) {
+ String sVal = (String) mapConfigVals.get(sKey);
+
+ if (sVal != null)
+ sVal = sVal.trim();
+
+ boolean bRet = false;
+
+ if (sVal != null)
+ bRet = sVal.equals("true");
+
+ return bRet;
}
- return serverAddress;
- }
-
- /**
- * This method returns a specific string config value.
- * @param sKey Specifies the key of the config value to return.
- * @return Returns the requested config value.
- */
- public static String getStringValue(String sKey) {
- return getStringValue(sKey, true);
- }
-
- /**
- * This method returns a specific string config value.
- * @param sKey Specifies the key of the config value to return.
- * @param bLogMessages Specifies if this action should be logged or not.
- * @return Returns the requested config value.
- */
- public static String getStringValue(String sKey, boolean bLogMessage) {
- String sRet = (String) mapConfigVals.get(sKey);
-
- if (sRet != null)
- sRet = sRet.trim();
-
- return sRet;
- }
-
- /**
- * This method returns a specific integer config value.
- * @param sKey Specifies the key of the config value to return.
- * @return Returns the requested config value.
- */
- public static int getIntValue(String sKey) {
- String sVal = (String) mapConfigVals.get(sKey);
-
- if (sVal != null)
- sVal = sVal.trim();
-
- return Integer.parseInt(sVal);
- }
-
- /**
- * This method returns a specific boolean config value.
- * @param sKey Specifies the key of the config value to return.
- * @return Returns the requested config value.
- */
- public static boolean getBooleanValue(String sKey) {
- String sVal = (String) mapConfigVals.get(sKey);
-
- if (sVal != null)
- sVal = sVal.trim();
-
- boolean bRet = false;
-
- if (sVal != null)
- bRet = sVal.equals("true");
-
- return bRet;
- }
-
- /**
- * This method returns a set of keys of the config hash map.
- * @return Returns a Set object containing all keys of the Config's hash map.
- */
- public static Set getKeySet() {
- return mapConfigVals.keySet();
- }
-
- /**
- * This method changes or adds a specific config value.
- * @param sKey Specifies the config key to set or update.
- * @param sVal Specifies the value of the key to set or update.
- */
- public static void setValue(String sKey, String sVal) {
- mapConfigVals.put(sKey, sVal);
- }
-
- /**
- * This method returns a sorted String array of all available config keys.
- * @return Returns a sorted String array of all available config keys.
- */
- public static String [] getSortedKeyArray() {
- Set keySet = getKeySet();
- Object [] keys = keySet.toArray();
- int iNumPairs = keys.length;
- String [] sKeys = new String[iNumPairs];
-
- for (int i = 0; i < iNumPairs; ++i)
- sKeys[i] = (String) keys[i];
-
- Arrays.sort(sKeys);
-
- return sKeys;
- }
-
- /**
- * This method writes the current configuration to the config file "netcalendar.conf".
- */
- public static void writeConfigToFile() {
- String [] sKeys = getSortedKeyArray();
- int iNumKeys = sKeys.length;
-
- try {
- FileWriter fileWriter = new FileWriter(CONFIG_FILE);
- BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
-
- for (int i = 0; i < iNumKeys; ++i) {
- String sKey = sKeys[i];
- String sVal = getStringValue(sKey);
- bufferedWriter.write(sKey + "=" + sVal + ";\n");
- }
-
- bufferedWriter.close();
-
- } catch (IOException e) {
- Main.infoMessage("Error: " + e.toString());
+ /**
+ * This method returns a set of keys of the config hash map.
+ * @return Returns a Set object containing all keys of the Config's hash map.
+ */
+ public static Set getKeySet() {
+ return mapConfigVals.keySet();
+ }
+
+ /**
+ * This method changes or adds a specific config value.
+ * @param sKey Specifies the config key to set or update.
+ * @param sVal Specifies the value of the key to set or update.
+ */
+ public static void setValue(String sKey, String sVal) {
+ mapConfigVals.put(sKey, sVal);
+ }
+
+ /**
+ * This method returns a sorted String array of all available config keys.
+ * @return Returns a sorted String array of all available config keys.
+ */
+ public static String [] getSortedKeyArray() {
+ Set keySet = getKeySet();
+ Object [] keys = keySet.toArray();
+ int iNumPairs = keys.length;
+ String [] sKeys = new String[iNumPairs];
+
+ for (int i = 0; i < iNumPairs; ++i)
+ sKeys[i] = (String) keys[i];
+
+ Arrays.sort(sKeys);
+
+ return sKeys;
+ }
+
+ /**
+ * This method writes the current configuration to the config file "netcalendar.conf".
+ */
+ public static void writeConfigToFile() {
+ String [] sKeys = getSortedKeyArray();
+ int iNumKeys = sKeys.length;
+
+ try {
+ FileWriter fileWriter = new FileWriter(CONFIG_FILE);
+ BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
+
+ for (int i = 0; i < iNumKeys; ++i) {
+ String sKey = sKeys[i];
+ String sVal = getStringValue(sKey);
+ bufferedWriter.write(sKey + "=" + sVal + ";\n");
+ }
+
+ bufferedWriter.close();
+
+ } catch (IOException e) {
+ Main.infoMessage("Error: " + e.toString());
+ }
}
- }
}
diff --git a/sources/shared/DoCallback.java b/sources/shared/DoCallback.java
index 7552a52..f7f5122 100644
--- a/sources/shared/DoCallback.java
+++ b/sources/shared/DoCallback.java
@@ -1,3 +1,7 @@
+/* NetCalendar 2006, 2009 (c) Dipl.-Inform. (FH) Paul C. Buetow
+ * http://netcalendar.buetow.org - netcalendar@dev.buetow.org
+ */
+
package shared;
/**
@@ -6,5 +10,5 @@ package shared;
*
*/
public interface DoCallback {
- public void callback(Object o);
+ public void callback(Object o);
}
diff --git a/sources/shared/Main.java b/sources/shared/Main.java
index 54e11a9..328867b 100644
--- a/sources/shared/Main.java
+++ b/sources/shared/Main.java
@@ -1,3 +1,7 @@
+/* NetCalendar 2006, 2009 (c) Dipl.-Inform. (FH) Paul C. Buetow
+ * http://netcalendar.buetow.org - netcalendar@dev.buetow.org
+ */
+
package shared;
import java.io.*;
@@ -13,123 +17,123 @@ import client.*;
*
*/
public final class Main {
- private static NetCalendarClient netCalendarClient = null;
- private static BufferedWriter bufferedLogfileWriter = null;
-
- /**
- * This method is the start point of the whole program. Its initializing the static Config object
- * and starts a calendar server and/or a calendar client thread depending on the "server_run" and
- * "client_run" configuration options.
- * @param args Specifies the program arguments (not used yet by the program)
- */
- public static void main(String[] args) {
- Config.initialize(args);
-
- try {
- FileWriter fileWriter = new FileWriter(Config.getStringValue("logfile"));
- bufferedLogfileWriter = new BufferedWriter(fileWriter);
-
- } catch (IOException e) {
- infoMessage("Error: Could not open logfile: " + e.getMessage());
+ private static NetCalendarClient netCalendarClient = null;
+ private static BufferedWriter bufferedLogfileWriter = null;
+
+ /**
+ * This method is the start point of the whole program. Its initializing the static Config object
+ * and starts a calendar server and/or a calendar client thread depending on the "server_run" and
+ * "client_run" configuration options.
+ * @param args Specifies the program arguments (not used yet by the program)
+ */
+ public static void main(String[] args) {
+ Config.initialize(args);
+
+ try {
+ FileWriter fileWriter = new FileWriter(Config.getStringValue("logfile"));
+ bufferedLogfileWriter = new BufferedWriter(fileWriter);
+
+ } catch (IOException e) {
+ infoMessage("Error: Could not open logfile: " + e.getMessage());
+ }
+
+
+ if (Config.getBooleanValue("server_run")) {
+ new NetCalendarServer(
+ Config.getIntValue("server_port"),
+ checkDatabaseDir(Config.getStringValue("server_database_dir")));
+ }
+
+ if (Config.getBooleanValue("client_run")) {
+ new Thread(new SplashScreen()).start();
+ //Make sure we have nice window decorations.
+ JFrame.setDefaultLookAndFeelDecorated(true);
+ netCalendarClient = new NetCalendarClient();
+ }
}
-
- if (Config.getBooleanValue("server_run")) {
- new NetCalendarServer(
- Config.getIntValue("server_port"),
- checkDatabaseDir(Config.getStringValue("server_database_dir")));
+ /**
+ * For checking if the database dir exists. If not, use one upper level
+ * directory.
+ * @param sDatabaseDir The database dir
+ * @return The database dir if exists, else one upper level directory
+ */
+ private static String checkDatabaseDir(String sDatabaseDir) {
+ if (new File(sDatabaseDir).exists())
+ return sDatabaseDir;
+
+ return "../" + sDatabaseDir;
}
- if (Config.getBooleanValue("client_run")) {
- new Thread(new SplashScreen()).start();
- //Make sure we have nice window decorations.
- JFrame.setDefaultLookAndFeelDecorated(true);
- netCalendarClient = new NetCalendarClient();
+ /**
+ * All info messages of the calendar client and the calendar server go through this method.
+ * They are not using System.out.* directly.
+ * @param sMessage Specifies the program info message.
+ */
+ public static void infoMessage(String sMessage) {
+ // Later: Add logging to a logfile!
+ System.out.println(sMessage);
+ logMessage(sMessage);
}
- }
-
- /**
- * For checking if the database dir exists. If not, use one upper level
- * directory.
- * @param sDatabaseDir The database dir
- * @return The database dir if exists, else one upper level directory
- */
- private static String checkDatabaseDir(String sDatabaseDir) {
- if (new File(sDatabaseDir).exists())
- return sDatabaseDir;
-
- return "../" + sDatabaseDir;
- }
-
- /**
- * All info messages of the calendar client and the calendar server go through this method.
- * They are not using System.out.* directly.
- * @param sMessage Specifies the program info message.
- */
- public static void infoMessage(String sMessage) {
- // Later: Add logging to a logfile!
- System.out.println(sMessage);
- logMessage(sMessage);
- }
-
- /**
- * This method is for various messages. All messages will show up in the status bar of the client's main window.
- * If there is no main window, the infoMessage method will be used instead.
- * @param sMessage Specifies the message to be displayed in the status bar.
- */
- public static void statusMessage(String sMessage) {
- if (netCalendarClient != null)
- netCalendarClient.statusMessage(sMessage);
- else
- infoMessage(sMessage);
- }
-
- /**
- * This method writes a specific message string into a logfile which is specified in the netcalendar.conf.
- * @param sMessage Specified the message string to write into the logfile.
- */
- private static void logMessage(String sMessage) {
- if (bufferedLogfileWriter != null) {
- try {
- bufferedLogfileWriter.write(sMessage + "\n");
- // bufferedLogfileWriter.flush();
-
- } catch (IOException e) {
- Main.infoMessage("Error: Could not write to logfile: " + e.toString());
- }
+
+ /**
+ * This method is for various messages. All messages will show up in the status bar of the client's main window.
+ * If there is no main window, the infoMessage method will be used instead.
+ * @param sMessage Specifies the message to be displayed in the status bar.
+ */
+ public static void statusMessage(String sMessage) {
+ if (netCalendarClient != null)
+ netCalendarClient.statusMessage(sMessage);
+ else
+ infoMessage(sMessage);
}
- }
-
- /**
- * This method is called thenever the server or the client process wants to exit.
- * @param iCode Specifies the exit code to use for the System.exit call.
- */
- public static void exit(int iCode) {
- infoMessage("Shutting down the current process");
-
- try {
- bufferedLogfileWriter.close();
- } catch (IOException e) {
- System.err.println("Error: Could not close logfile: " + e.toString());
+
+ /**
+ * This method writes a specific message string into a logfile which is specified in the netcalendar.conf.
+ * @param sMessage Specified the message string to write into the logfile.
+ */
+ private static void logMessage(String sMessage) {
+ if (bufferedLogfileWriter != null) {
+ try {
+ bufferedLogfileWriter.write(sMessage + "\n");
+ // bufferedLogfileWriter.flush();
+
+ } catch (IOException e) {
+ Main.infoMessage("Error: Could not write to logfile: " + e.toString());
+ }
+ }
}
- System.exit(iCode);
- }
+ /**
+ * This method is called thenever the server or the client process wants to exit.
+ * @param iCode Specifies the exit code to use for the System.exit call.
+ */
+ public static void exit(int iCode) {
+ infoMessage("Shutting down the current process");
+
+ try {
+ bufferedLogfileWriter.close();
+ } catch (IOException e) {
+ System.err.println("Error: Could not close logfile: " + e.toString());
+ }
+
+ System.exit(iCode);
+ }
- /**
- * This method executes an external program.
- * @param sCommand Specifies the command string to execute.
- */
- public static void execExternalCommand(String sCommand) {
- if (sCommand.equals("none") || sCommand.equals(""))
- return;
+ /**
+ * This method executes an external program.
+ * @param sCommand Specifies the command string to execute.
+ */
+ public static void execExternalCommand(String sCommand) {
+ if (sCommand.equals("none") || sCommand.equals(""))
+ return;
- try {
- Runtime.getRuntime().exec(sCommand);
+ try {
+ Runtime.getRuntime().exec(sCommand);
- } catch (IOException e) {
- Main.infoMessage("Error while executing external command: " + e.getMessage());
+ } catch (IOException e) {
+ Main.infoMessage("Error while executing external command: " + e.getMessage());
+ }
}
- }
}
diff --git a/sources/shared/MyDate.java b/sources/shared/MyDate.java
index 00bf59d..f1f54fe 100644
--- a/sources/shared/MyDate.java
+++ b/sources/shared/MyDate.java
@@ -1,3 +1,7 @@
+/* NetCalendar 2006, 2009 (c) Dipl.-Inform. (FH) Paul C. Buetow
+ * http://netcalendar.buetow.org - netcalendar@dev.buetow.org
+ */
+
package shared;
import java.util.*;
@@ -9,46 +13,46 @@ import java.util.*;
*
*/
public class MyDate extends Date {
- private final static long serialVersionUID = 1L;
- private final static String [] DAYS = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
-
- /**
- * Copy constructor.
- * @param data Specifies the date objekt to copy the time from.
- */
- public MyDate(Date date) {
- super(date.getTime());
- }
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(this);
-
- String sYear = addZerosToFront(calendar.get(Calendar.YEAR), 4);
- String sMonth = addZerosToFront(calendar.get(Calendar.MONTH) + 1, 2);
- String sDays = addZerosToFront(calendar.get(Calendar.DAY_OF_MONTH), 2);
- String sHours= addZerosToFront(calendar.get(Calendar.HOUR), 2);
- String sMinutes = addZerosToFront(calendar.get(Calendar.MINUTE), 2);
- String sDay = DAYS[calendar.get(Calendar.DAY_OF_WEEK)-1];
-
- return sDays + "." + sMonth + "." + sYear + " " + sHours + ":" + sMinutes + " " + sDay;
- }
-
- /**
- * This method adds zeros in front of a number and returns it as a string.
- * @param iValue Specifies the number to add zeros to.
- * @param iWantedLength Specifies the wanted max length of the string.
- * @return Returns the number represented as a string with additional zeros on front.
- */
- public static String addZerosToFront(int iValue, int iWantedLength) {
- String sValue = iValue + "";
-
- while (sValue.length() < iWantedLength)
- sValue = "0" + sValue;
-
- return sValue;
- }
+ private final static long serialVersionUID = 1L;
+ private final static String [] DAYS = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
+
+ /**
+ * Copy constructor.
+ * @param data Specifies the date objekt to copy the time from.
+ */
+ public MyDate(Date date) {
+ super(date.getTime());
+ }
+
+ /**
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(this);
+
+ String sYear = addZerosToFront(calendar.get(Calendar.YEAR), 4);
+ String sMonth = addZerosToFront(calendar.get(Calendar.MONTH) + 1, 2);
+ String sDays = addZerosToFront(calendar.get(Calendar.DAY_OF_MONTH), 2);
+ String sHours= addZerosToFront(calendar.get(Calendar.HOUR), 2);
+ String sMinutes = addZerosToFront(calendar.get(Calendar.MINUTE), 2);
+ String sDay = DAYS[calendar.get(Calendar.DAY_OF_WEEK)-1];
+
+ return sDays + "." + sMonth + "." + sYear + " " + sHours + ":" + sMinutes + " " + sDay;
+ }
+
+ /**
+ * This method adds zeros in front of a number and returns it as a string.
+ * @param iValue Specifies the number to add zeros to.
+ * @param iWantedLength Specifies the wanted max length of the string.
+ * @return Returns the number represented as a string with additional zeros on front.
+ */
+ public static String addZerosToFront(int iValue, int iWantedLength) {
+ String sValue = iValue + "";
+
+ while (sValue.length() < iWantedLength)
+ sValue = "0" + sValue;
+
+ return sValue;
+ }
}
diff --git a/sources/shared/MyVector.java b/sources/shared/MyVector.java
index 9a76625..3c98d72 100644
--- a/sources/shared/MyVector.java
+++ b/sources/shared/MyVector.java
@@ -1,3 +1,7 @@
+/* NetCalendar 2006, 2009 (c) Dipl.-Inform. (FH) Paul C. Buetow
+ * http://netcalendar.buetow.org - netcalendar@dev.buetow.org
+ */
+
package shared;
import java.util.Enumeration;
@@ -9,15 +13,15 @@ import java.util.Vector;
*
*/
public class MyVector extends Vector {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- /**
- * This method appends a vector at the end.
- * @param vecAppend Specifies the vector to be appended.
- */
- public void appendVector(Vector vecAppend) {
- Enumeration enumAppend = vecAppend.elements();
- while (enumAppend.hasMoreElements())
- this.add(enumAppend.nextElement());
- }
+ /**
+ * This method appends a vector at the end.
+ * @param vecAppend Specifies the vector to be appended.
+ */
+ public void appendVector(Vector vecAppend) {
+ Enumeration enumAppend = vecAppend.elements();
+ while (enumAppend.hasMoreElements())
+ this.add(enumAppend.nextElement());
+ }
}
diff --git a/sources/shared/remotecall/ClientRequest.java b/sources/shared/remotecall/ClientRequest.java
index a6a57a2..2622fa0 100644
--- a/sources/shared/remotecall/ClientRequest.java
+++ b/sources/shared/remotecall/ClientRequest.java
@@ -1,3 +1,7 @@
+/* NetCalendar 2006, 2009 (c) Dipl.-Inform. (FH) Paul C. Buetow
+ * http://netcalendar.buetow.org - netcalendar@dev.buetow.org
+ */
+
package shared.remotecall;
import java.util.*;
@@ -14,356 +18,356 @@ import shared.*;
*
*/
public final class ClientRequest extends RemoteCall implements Serializable {
- private static final long serialVersionUID = 6L;
- private static final Pattern emptyPattern = Pattern.compile("[^\\s]");
-
- public static final int REQUEST_EVENTS = 0;
- public static final int REQUEST_ALL_EVENTS = 1;
- public static final int MODIFY_EVENT = 2;
- public static final int DELETE_EVENT = 3;
- public static final int ADD_EVENT = 4;
- public static final int RELOAD_DATABASE = 5;
- public static final int FLUSH_DATABASE = 6;
- public static final int SHUTDOWN_SERVER = 7;
- public static final int RENAME_CATEGORY = 8;
- public static final int DELETE_CATEGORY = 9;
-
- private int iAction = 0;
- private int iNumEventsToRequest;
-
- private boolean bMainRegexp;
- private boolean bCaseInsensitive;
-
- private Pattern patAll = null;
- private Pattern patCategory = null;
- private Pattern patDescription = null;
- private Pattern patPlace = null;
- private Pattern patDate = null;
- private Date dateRangeFrom = null;
- private Date dateRangeTo = null;
- private CalendarEvent event = null;
- private String sPassphrase;
- private String sString = null;
-
- /**
- * Simple constructor, creates a client request object requesting events up
- * from the current date.
- */
- public ClientRequest() {
- dateRangeFrom = new Date();
- initialize(REQUEST_EVENTS);
- }
-
- /**
- * Simple constructor, creates a client request object requesting events up
- * from the current date.
- * @param iAction Specifies the request type of this request.
- */
- public ClientRequest(int iAction) {
- dateRangeFrom = new Date();
- initialize(iAction);
- }
-
- /**
- * This method initializes some common stuff. Called by each constructor.
- * @param iAction Specifies the request type of this request.
- */
- private void initialize(int iAction) {
- this.iAction = iAction;
- this.sPassphrase = Config.getStringValue("passphrase", false);
- this.bCaseInsensitive = Config.getBooleanValue("regexp_case_insensitive");
- this.iNumEventsToRequest = Config.getIntValue("client_max_events");
- }
-
- /**
- * This method is needed by the clanedar server to get the type of action requested.
- * @param iAction Specifies the action to test against.
- * @return Returns true if the specified action ID matches with the action ID of this request object.
- */
- public boolean actionIs(int iAction) {
- return this.iAction == iAction;
- }
-
- /**
- * This method is needed by the calendar server to get the type of action requested.
- * @return Returns true if this object requests new events from the server.
- */
- public boolean requestsNewEvents() {
- return this.iAction < ClientRequest.MODIFY_EVENT;
- }
-
- /**
- * This method sets the date range to request.
- * @param dateRangeFrom Specifies the beginning date.
- * @param dateRangeTo Specifies the ending date.
- */
- public void setDateRange(Date dateRangeFrom, Date dateRangeTo) {
- this.dateRangeFrom = dateRangeFrom;
- this.dateRangeTo = dateRangeTo;
- }
-
- /**
- * This method sets a calendar event object to be transfered to the calendar server because the event has been modified.
- * @param event Specifies an event to be transfered to the calendar server.
- */
- public void setEvent(CalendarEvent event) {
- this.event = event;
- if (actionIs(ADD_EVENT))
- event.setEventID(-1);
- }
-
- /**
- * This method returns the event object.
- * @return Returns the calendar event which is stored inside this client request.
- */
- public CalendarEvent getEvent() {
- return event;
- }
-
- /**
- * With this method the client can define the maximum number of events to request.
- * @param iNumEvents Specifies the maximum number of events to request.
- */
- public void setNumEventsToRequest(int iNumEvents) {
- this.iNumEventsToRequest = iNumEvents;
- }
-
- /**
- * This method returns the maximum number of events the client wants to request.
- * @return Returns the maximum number of events the client wants to request.
- */
- public int getNumEventsToRequest() {
- return iNumEventsToRequest;
- }
-
- /**
- * This method sets if the client contains a regexp from the main session window.
- * @param bMainRegexp Set to true if the user used the main regexp field of the main GUI window.
- */
- public void setMainRegexp(boolean bMainRegexp) {
- this.bMainRegexp = bMainRegexp;
- }
-
- /**
- * This method compiles a specific pattern object to match with on the server part after serialization.
- * @param sRegexp Compiles a Pattern object with sRegexp as the regular expression.
- */
- public void setRegexpAll(String sRegexp) {
- if (isEmptyPattern(sRegexp))
- return;
-
- if (bCaseInsensitive)
- patAll = Pattern.compile(sRegexp, Pattern.CASE_INSENSITIVE);
- else
- patAll = Pattern.compile(sRegexp);
- }
-
- /**
- * This method compiles a specific pattern object to match with on the server part after serialization.
- * @param sRegexp Compiles a Pattern object with sRegexp as the regular expression.
- */
- public void setRegexpCategory(String sRegexp) {
- if (isEmptyPattern(sRegexp))
- return;
-
- if (bCaseInsensitive)
- patCategory = Pattern.compile(sRegexp, Pattern.CASE_INSENSITIVE);
- else
- patCategory = Pattern.compile(sRegexp);
- }
-
- /**
- * This method compiles a specific pattern object to match with on the server part after serialization.
- * @param sRegexp Compiles a Pattern object with sRegexp as the regular expression.
- */
- public void setRegexpDescription(String sRegexp) {
- if (isEmptyPattern(sRegexp))
- return;
-
- if (bCaseInsensitive)
- patDescription = Pattern.compile(sRegexp, Pattern.CASE_INSENSITIVE);
- else
- patDescription = Pattern.compile(sRegexp);
- }
-
- /**
- * This method sets a string to be transfered to the netcalendar server.
- * @param sString specifies the string to be transfered.
- */
- public void setString(String sString) {
- this.sString = sString;
- }
-
- /**
- * This method returns a string transfered by the netcalendar client. If no string has been transfered,
- * null will be returned.
- * @return Returns a string transfered by the netcalendar client.
- */
- public String getString() {
- return sString;
- }
-
- /**
- * This method compiles a specific pattern object to match with on the server part after serialization.
- * @param sRegexp Compiles a Pattern object with sRegexp as the regular expression.
- */
- public void setRegexpPlace(String sRegexp) {
- if (isEmptyPattern(sRegexp))
- return;
-
- if (bCaseInsensitive)
- patPlace = Pattern.compile(sRegexp, Pattern.CASE_INSENSITIVE);
- else
- patPlace = Pattern.compile(sRegexp);
- }
-
- /**
- * This method compiles a specific pattern object to match with on the server part after serialization.
- * @param sRegexp Compiles a Pattern object with sRegexp as the regular expression.
- */
- public void setRegexpDate(String sRegexp) {
- if (isEmptyPattern(sRegexp))
- return;
-
- if (bCaseInsensitive)
- patDate = Pattern.compile(sRegexp, Pattern.CASE_INSENSITIVE);
- else
- patDate = Pattern.compile(sRegexp);
- }
-
- /**
- * Checks if a specific calendar event matches this client request.
- * @param calendarEvent Specifies the event to match against.
- * @return Returns true if the given event matched. Else, false will be returned.
- */
- public boolean match(CalendarEvent calendarEvent) {
- // If we want to get all events!
- if (actionIs(REQUEST_ALL_EVENTS))
- return true;
-
- // If we use the regex field of the main GUI
- if (bMainRegexp)
- return calendarEvent.matches(patAll);
-
- // If we use advanced searching:
- if (dateRangeFrom != null)
- if (dateRangeFrom.getTime() > calendarEvent.getDate().getTime())
- return false;
+ private static final long serialVersionUID = 6L;
+ private static final Pattern emptyPattern = Pattern.compile("[^\\s]");
+
+ public static final int REQUEST_EVENTS = 0;
+ public static final int REQUEST_ALL_EVENTS = 1;
+ public static final int MODIFY_EVENT = 2;
+ public static final int DELETE_EVENT = 3;
+ public static final int ADD_EVENT = 4;
+ public static final int RELOAD_DATABASE = 5;
+ public static final int FLUSH_DATABASE = 6;
+ public static final int SHUTDOWN_SERVER = 7;
+ public static final int RENAME_CATEGORY = 8;
+ public static final int DELETE_CATEGORY = 9;
+
+ private int iAction = 0;
+ private int iNumEventsToRequest;
+
+ private boolean bMainRegexp;
+ private boolean bCaseInsensitive;
+
+ private Pattern patAll = null;
+ private Pattern patCategory = null;
+ private Pattern patDescription = null;
+ private Pattern patPlace = null;
+ private Pattern patDate = null;
+ private Date dateRangeFrom = null;
+ private Date dateRangeTo = null;
+ private CalendarEvent event = null;
+ private String sPassphrase;
+ private String sString = null;
+
+ /**
+ * Simple constructor, creates a client request object requesting events up
+ * from the current date.
+ */
+ public ClientRequest() {
+ dateRangeFrom = new Date();
+ initialize(REQUEST_EVENTS);
+ }
+
+ /**
+ * Simple constructor, creates a client request object requesting events up
+ * from the current date.
+ * @param iAction Specifies the request type of this request.
+ */
+ public ClientRequest(int iAction) {
+ dateRangeFrom = new Date();
+ initialize(iAction);
+ }
+
+ /**
+ * This method initializes some common stuff. Called by each constructor.
+ * @param iAction Specifies the request type of this request.
+ */
+ private void initialize(int iAction) {
+ this.iAction = iAction;
+ this.sPassphrase = Config.getStringValue("passphrase", false);
+ this.bCaseInsensitive = Config.getBooleanValue("regexp_case_insensitive");
+ this.iNumEventsToRequest = Config.getIntValue("client_max_events");
+ }
+
+ /**
+ * This method is needed by the clanedar server to get the type of action requested.
+ * @param iAction Specifies the action to test against.
+ * @return Returns true if the specified action ID matches with the action ID of this request object.
+ */
+ public boolean actionIs(int iAction) {
+ return this.iAction == iAction;
+ }
+
+ /**
+ * This method is needed by the calendar server to get the type of action requested.
+ * @return Returns true if this object requests new events from the server.
+ */
+ public boolean requestsNewEvents() {
+ return this.iAction < ClientRequest.MODIFY_EVENT;
+ }
+
+ /**
+ * This method sets the date range to request.
+ * @param dateRangeFrom Specifies the beginning date.
+ * @param dateRangeTo Specifies the ending date.
+ */
+ public void setDateRange(Date dateRangeFrom, Date dateRangeTo) {
+ this.dateRangeFrom = dateRangeFrom;
+ this.dateRangeTo = dateRangeTo;
+ }
+
+ /**
+ * This method sets a calendar event object to be transfered to the calendar server because the event has been modified.
+ * @param event Specifies an event to be transfered to the calendar server.
+ */
+ public void setEvent(CalendarEvent event) {
+ this.event = event;
+ if (actionIs(ADD_EVENT))
+ event.setEventID(-1);
+ }
+
+ /**
+ * This method returns the event object.
+ * @return Returns the calendar event which is stored inside this client request.
+ */
+ public CalendarEvent getEvent() {
+ return event;
+ }
+
+ /**
+ * With this method the client can define the maximum number of events to request.
+ * @param iNumEvents Specifies the maximum number of events to request.
+ */
+ public void setNumEventsToRequest(int iNumEvents) {
+ this.iNumEventsToRequest = iNumEvents;
+ }
+
+ /**
+ * This method returns the maximum number of events the client wants to request.
+ * @return Returns the maximum number of events the client wants to request.
+ */
+ public int getNumEventsToRequest() {
+ return iNumEventsToRequest;
+ }
+
+ /**
+ * This method sets if the client contains a regexp from the main session window.
+ * @param bMainRegexp Set to true if the user used the main regexp field of the main GUI window.
+ */
+ public void setMainRegexp(boolean bMainRegexp) {
+ this.bMainRegexp = bMainRegexp;
+ }
+
+ /**
+ * This method compiles a specific pattern object to match with on the server part after serialization.
+ * @param sRegexp Compiles a Pattern object with sRegexp as the regular expression.
+ */
+ public void setRegexpAll(String sRegexp) {
+ if (isEmptyPattern(sRegexp))
+ return;
+
+ if (bCaseInsensitive)
+ patAll = Pattern.compile(sRegexp, Pattern.CASE_INSENSITIVE);
+ else
+ patAll = Pattern.compile(sRegexp);
+ }
+
+ /**
+ * This method compiles a specific pattern object to match with on the server part after serialization.
+ * @param sRegexp Compiles a Pattern object with sRegexp as the regular expression.
+ */
+ public void setRegexpCategory(String sRegexp) {
+ if (isEmptyPattern(sRegexp))
+ return;
+
+ if (bCaseInsensitive)
+ patCategory = Pattern.compile(sRegexp, Pattern.CASE_INSENSITIVE);
+ else
+ patCategory = Pattern.compile(sRegexp);
+ }
+
+ /**
+ * This method compiles a specific pattern object to match with on the server part after serialization.
+ * @param sRegexp Compiles a Pattern object with sRegexp as the regular expression.
+ */
+ public void setRegexpDescription(String sRegexp) {
+ if (isEmptyPattern(sRegexp))
+ return;
+
+ if (bCaseInsensitive)
+ patDescription = Pattern.compile(sRegexp, Pattern.CASE_INSENSITIVE);
+ else
+ patDescription = Pattern.compile(sRegexp);
+ }
+
+ /**
+ * This method sets a string to be transfered to the netcalendar server.
+ * @param sString specifies the string to be transfered.
+ */
+ public void setString(String sString) {
+ this.sString = sString;
+ }
+
+ /**
+ * This method returns a string transfered by the netcalendar client. If no string has been transfered,
+ * null will be returned.
+ * @return Returns a string transfered by the netcalendar client.
+ */
+ public String getString() {
+ return sString;
+ }
+
+ /**
+ * This method compiles a specific pattern object to match with on the server part after serialization.
+ * @param sRegexp Compiles a Pattern object with sRegexp as the regular expression.
+ */
+ public void setRegexpPlace(String sRegexp) {
+ if (isEmptyPattern(sRegexp))
+ return;
+
+ if (bCaseInsensitive)
+ patPlace = Pattern.compile(sRegexp, Pattern.CASE_INSENSITIVE);
+ else
+ patPlace = Pattern.compile(sRegexp);
+ }
+
+ /**
+ * This method compiles a specific pattern object to match with on the server part after serialization.
+ * @param sRegexp Compiles a Pattern object with sRegexp as the regular expression.
+ */
+ public void setRegexpDate(String sRegexp) {
+ if (isEmptyPattern(sRegexp))
+ return;
+
+ if (bCaseInsensitive)
+ patDate = Pattern.compile(sRegexp, Pattern.CASE_INSENSITIVE);
+ else
+ patDate = Pattern.compile(sRegexp);
+ }
+
+ /**
+ * Checks if a specific calendar event matches this client request.
+ * @param calendarEvent Specifies the event to match against.
+ * @return Returns true if the given event matched. Else, false will be returned.
+ */
+ public boolean match(CalendarEvent calendarEvent) {
+ // If we want to get all events!
+ if (actionIs(REQUEST_ALL_EVENTS))
+ return true;
+
+ // If we use the regex field of the main GUI
+ if (bMainRegexp)
+ return calendarEvent.matches(patAll);
+
+ // If we use advanced searching:
+ if (dateRangeFrom != null)
+ if (dateRangeFrom.getTime() > calendarEvent.getDate().getTime())
+ return false;
+
+ if (dateRangeTo != null)
+ if (dateRangeTo.getTime() < calendarEvent.getDate().getTime())
+ return false;
+
+ if (calendarEvent.matches(patAll) ||
+ (calendarEvent.matchesDescription(patDescription)
+ && calendarEvent.matchesCategory(patCategory)
+ && calendarEvent.matchesPlace(patPlace)
+ && calendarEvent.matchesDateString(patDate)))
+ return true;
- if (dateRangeTo != null)
- if (dateRangeTo.getTime() < calendarEvent.getDate().getTime())
return false;
-
- if (calendarEvent.matches(patAll) ||
- (calendarEvent.matchesDescription(patDescription)
- && calendarEvent.matchesCategory(patCategory)
- && calendarEvent.matchesPlace(patPlace)
- && calendarEvent.matchesDateString(patDate)))
- return true;
-
- return false;
- }
-
- /**
- * Needed for ojbect serialization (sending part).
- * @param objectOutputStream Specifies the output stream to use.
- * @throws IOException
- */
- private void writeObject(ObjectOutputStream objectOutputStream)
- throws IOException {
- objectOutputStream.writeInt(iAction);
- objectOutputStream.writeInt(iNumEventsToRequest);
- objectOutputStream.writeObject(sPassphrase);
- objectOutputStream.writeBoolean(bMainRegexp);
- objectOutputStream.writeBoolean(bCaseInsensitive);
-
- super.writeObjectIfDefined(objectOutputStream, sString);
- super.writeObjectIfDefined(objectOutputStream, patAll);
- super.writeObjectIfDefined(objectOutputStream, patCategory);
- super.writeObjectIfDefined(objectOutputStream, patDescription);
- super.writeObjectIfDefined(objectOutputStream, patPlace);
- super.writeObjectIfDefined(objectOutputStream, patDate);
- super.writeObjectIfDefined(objectOutputStream, dateRangeFrom);
- super.writeObjectIfDefined(objectOutputStream, dateRangeTo);
- super.writeObjectIfDefined(objectOutputStream, event);
- }
-
- /**
- * Needed for object serialization (recieving part).
- * @param objectInputStream Specifies the input stream to use.
- * @throws IOException
- * @throws ClassNotFoundException
- */
- private void readObject(ObjectInputStream objectInputStream)
- throws IOException, ClassNotFoundException {
-
- iAction = objectInputStream.readInt();
- iNumEventsToRequest = objectInputStream.readInt();
- sPassphrase = (String) objectInputStream.readObject();
- setMainRegexp(objectInputStream.readBoolean());
- bCaseInsensitive = objectInputStream.readBoolean();
-
- if (objectInputStream.readBoolean())
- sString = (String) objectInputStream.readObject();
-
- if (objectInputStream.readBoolean())
- patAll = (Pattern) objectInputStream.readObject();
-
- if (objectInputStream.readBoolean())
- patCategory = (Pattern) objectInputStream.readObject();
-
- if (objectInputStream.readBoolean())
- patDescription = (Pattern) objectInputStream.readObject();
-
- if (objectInputStream.readBoolean())
- patPlace = (Pattern) objectInputStream.readObject();
-
- if (objectInputStream.readBoolean())
- patDate = (Pattern) objectInputStream.readObject();
-
- if (objectInputStream.readBoolean())
- dateRangeFrom = (Date) objectInputStream.readObject();
-
- if (objectInputStream.readBoolean())
- dateRangeTo = (Date) objectInputStream.readObject();
-
- if (objectInputStream.readBoolean())
- event = (CalendarEvent) objectInputStream.readObject();
- }
-
- /**
- * Checks if a given pattern string has other charactars than whitespaces inside or not.
- * @param sRegexp Specifies the pattern string to check against.
- * @return Returns true if the pattern string only contains whitespaces. Else, false will be returned.
- */
- private boolean isEmptyPattern(String sRegexp) {
- return !emptyPattern.matcher(sRegexp).find();
- }
-
- /**
- * This method checks if the request's passphrase is correct or not.
- * @param sPassphrase Specifies the server passphrase to chack against the request passphrase.
- * @return Returns true if the passphrases equal. Else, false will be returned.
- */
- public boolean checkPassphrase(String sPassphrase) {
- return this.sPassphrase.equals(sPassphrase);
- }
-
- /**
- * This method returns a representation the object as a string.
- * @return Returns the object represented as a string.
- */
- public String toString() {
- return
- "Action : " + iAction + "\n" +
- "NumEvents : " + iNumEventsToRequest + "\n" +
- "MainRegexp : " + bMainRegexp + "\n" +
- "patAll : " + patAll + "\n" +
- "patCategory : " + patCategory + "\n" +
- "patDescription: " + patDescription + "\n" +
- "patDate : " + patDate + "\n" +
- "dateRangeFrom : " + dateRangeFrom + "\n" +
- "dateRangeTo : " + dateRangeTo + "\n" +
- "modifiedEvent :\n" + event+ "\n";
- }
+ }
+
+ /**
+ * Needed for ojbect serialization (sending part).
+ * @param objectOutputStream Specifies the output stream to use.
+ * @throws IOException
+ */
+ private void writeObject(ObjectOutputStream objectOutputStream)
+ throws IOException {
+ objectOutputStream.writeInt(iAction);
+ objectOutputStream.writeInt(iNumEventsToRequest);
+ objectOutputStream.writeObject(sPassphrase);
+ objectOutputStream.writeBoolean(bMainRegexp);
+ objectOutputStream.writeBoolean(bCaseInsensitive);
+
+ super.writeObjectIfDefined(objectOutputStream, sString);
+ super.writeObjectIfDefined(objectOutputStream, patAll);
+ super.writeObjectIfDefined(objectOutputStream, patCategory);
+ super.writeObjectIfDefined(objectOutputStream, patDescription);
+ super.writeObjectIfDefined(objectOutputStream, patPlace);
+ super.writeObjectIfDefined(objectOutputStream, patDate);
+ super.writeObjectIfDefined(objectOutputStream, dateRangeFrom);
+ super.writeObjectIfDefined(objectOutputStream, dateRangeTo);
+ super.writeObjectIfDefined(objectOutputStream, event);
+ }
+
+ /**
+ * Needed for object serialization (recieving part).
+ * @param objectInputStream Specifies the input stream to use.
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ private void readObject(ObjectInputStream objectInputStream)
+ throws IOException, ClassNotFoundException {
+
+ iAction = objectInputStream.readInt();
+ iNumEventsToRequest = objectInputStream.readInt();
+ sPassphrase = (String) objectInputStream.readObject();
+ setMainRegexp(objectInputStream.readBoolean());
+ bCaseInsensitive = objectInputStream.readBoolean();
+
+ if (objectInputStream.readBoolean())
+ sString = (String) objectInputStream.readObject();
+
+ if (objectInputStream.readBoolean())
+ patAll = (Pattern) objectInputStream.readObject();
+
+ if (objectInputStream.readBoolean())
+ patCategory = (Pattern) objectInputStream.readObject();
+
+ if (objectInputStream.readBoolean())
+ patDescription = (Pattern) objectInputStream.readObject();
+
+ if (objectInputStream.readBoolean())
+ patPlace = (Pattern) objectInputStream.readObject();
+
+ if (objectInputStream.readBoolean())
+ patDate = (Pattern) objectInputStream.readObject();
+
+ if (objectInputStream.readBoolean())
+ dateRangeFrom = (Date) objectInputStream.readObject();
+
+ if (objectInputStream.readBoolean())
+ dateRangeTo = (Date) objectInputStream.readObject();
+
+ if (objectInputStream.readBoolean())
+ event = (CalendarEvent) objectInputStream.readObject();
+ }
+
+ /**
+ * Checks if a given pattern string has other charactars than whitespaces inside or not.
+ * @param sRegexp Specifies the pattern string to check against.
+ * @return Returns true if the pattern string only contains whitespaces. Else, false will be returned.
+ */
+ private boolean isEmptyPattern(String sRegexp) {
+ return !emptyPattern.matcher(sRegexp).find();
+ }
+
+ /**
+ * This method checks if the request's passphrase is correct or not.
+ * @param sPassphrase Specifies the server passphrase to chack against the request passphrase.
+ * @return Returns true if the passphrases equal. Else, false will be returned.
+ */
+ public boolean checkPassphrase(String sPassphrase) {
+ return this.sPassphrase.equals(sPassphrase);
+ }
+
+ /**
+ * This method returns a representation the object as a string.
+ * @return Returns the object represented as a string.
+ */
+ public String toString() {
+ return
+ "Action : " + iAction + "\n" +
+ "NumEvents : " + iNumEventsToRequest + "\n" +
+ "MainRegexp : " + bMainRegexp + "\n" +
+ "patAll : " + patAll + "\n" +
+ "patCategory : " + patCategory + "\n" +
+ "patDescription: " + patDescription + "\n" +
+ "patDate : " + patDate + "\n" +
+ "dateRangeFrom : " + dateRangeFrom + "\n" +
+ "dateRangeTo : " + dateRangeTo + "\n" +
+ "modifiedEvent :\n" + event+ "\n";
+ }
}
diff --git a/sources/shared/remotecall/RemoteCall.java b/sources/shared/remotecall/RemoteCall.java
index 8703f00..c95a3a2 100644
--- a/sources/shared/remotecall/RemoteCall.java
+++ b/sources/shared/remotecall/RemoteCall.java
@@ -1,3 +1,7 @@
+/* NetCalendar 2006, 2009 (c) Dipl.-Inform. (FH) Paul C. Buetow
+ * http://netcalendar.buetow.org - netcalendar@dev.buetow.org
+ */
+
package shared.remotecall;
import java.io.*;
@@ -9,21 +13,21 @@ import java.io.*;
*
*/
public abstract class RemoteCall {
- /**
- * This is a help method for writeObject of the child classes, needed for ojbect serialization (sending part).
- * It checks if object is defined. If yes, it will be written to the given object output stream with a leading
- * flag with the value true. Otherwise only the false flag will be written to the object output stream.
- * @param objectOutputStream Specifies the output stream.
- * @throws IOException
- */
- protected final void writeObjectIfDefined(ObjectOutputStream objectOutputStream, Object object)
- throws IOException {
- if (object == null) {
- objectOutputStream.writeBoolean(false);
+ /**
+ * This is a help method for writeObject of the child classes, needed for ojbect serialization (sending part).
+ * It checks if object is defined. If yes, it will be written to the given object output stream with a leading
+ * flag with the value true. Otherwise only the false flag will be written to the object output stream.
+ * @param objectOutputStream Specifies the output stream.
+ * @throws IOException
+ */
+ protected final void writeObjectIfDefined(ObjectOutputStream objectOutputStream, Object object)
+ throws IOException {
+ if (object == null) {
+ objectOutputStream.writeBoolean(false);
- } else {
- objectOutputStream.writeBoolean(true);
- objectOutputStream.writeObject(object);
+ } else {
+ objectOutputStream.writeBoolean(true);
+ objectOutputStream.writeObject(object);
+ }
}
- }
}
diff --git a/sources/shared/remotecall/ServerResponse.java b/sources/shared/remotecall/ServerResponse.java
index 49cd0c9..9c5f961 100644
--- a/sources/shared/remotecall/ServerResponse.java
+++ b/sources/shared/remotecall/ServerResponse.java
@@ -1,3 +1,7 @@
+/* NetCalendar 2006, 2009 (c) Dipl.-Inform. (FH) Paul C. Buetow
+ * http://netcalendar.buetow.org - netcalendar@dev.buetow.org
+ */
+
package shared.remotecall;
import java.io.*;
@@ -10,44 +14,44 @@ import java.util.Vector;
*
*/
public final class ServerResponse extends RemoteCall implements Serializable {
- private static final long serialVersionUID = 1L;
- private Vector vecEvents = null;
+ private static final long serialVersionUID = 1L;
+ private Vector vecEvents = null;
- /**
- * Simple constructor, creates a server response which can be sent to the calendar client.
- * @param vecEvents Specifies all calendar events to be sent to the calendar client.
- */
- public ServerResponse(Vector vecEvents) {
- this.vecEvents = vecEvents;
- }
+ /**
+ * Simple constructor, creates a server response which can be sent to the calendar client.
+ * @param vecEvents Specifies all calendar events to be sent to the calendar client.
+ */
+ public ServerResponse(Vector vecEvents) {
+ this.vecEvents = vecEvents;
+ }
- /**
- * Needed for ojbect serialization (sending part).
- * @param objectOutputStream Specifies the output stream.
- * @throws IOException
- */
- private void writeObject(ObjectOutputStream objectOutputStream)
- throws IOException {
- super.writeObjectIfDefined(objectOutputStream, vecEvents);
- }
+ /**
+ * Needed for ojbect serialization (sending part).
+ * @param objectOutputStream Specifies the output stream.
+ * @throws IOException
+ */
+ private void writeObject(ObjectOutputStream objectOutputStream)
+ throws IOException {
+ super.writeObjectIfDefined(objectOutputStream, vecEvents);
+ }
- /**
- * Needed for object serialization (recieving part).
- * @param objectInputStream Specifies the input stream.
- * @throws IOException
- * @throws ClassNotFoundException
- */
- private void readObject(ObjectInputStream objectInputStream)
- throws IOException, ClassNotFoundException {
- if (objectInputStream.readBoolean())
- vecEvents = (Vector) objectInputStream.readObject();
- }
+ /**
+ * Needed for object serialization (recieving part).
+ * @param objectInputStream Specifies the input stream.
+ * @throws IOException
+ * @throws ClassNotFoundException
+ */
+ private void readObject(ObjectInputStream objectInputStream)
+ throws IOException, ClassNotFoundException {
+ if (objectInputStream.readBoolean())
+ vecEvents = (Vector) objectInputStream.readObject();
+ }
- /**
- * This method returns a vector of all requested calendar events.
- * @return Returns a Vector of all requested CalendarEvent objects.
- */
- public Vector getEvents() {
- return vecEvents;
- }
+ /**
+ * This method returns a vector of all requested calendar events.
+ * @return Returns a Vector of all requested CalendarEvent objects.
+ */
+ public Vector getEvents() {
+ return vecEvents;
+ }
}