summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
Diffstat (limited to 'sources')
-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
30 files changed, 4298 insertions, 4178 deletions
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();