0001: /*
0002: * This file is part of BORG. BORG is free software; you can redistribute it
0003: * and/or modify it under the terms of the GNU General Public License as
0004: * published by the Free Software Foundation; either version 2 of the License,
0005: * or (at your option) any later version. BORG is distributed in the hope that
0006: * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
0007: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0008: * General Public License for more details. You should have received a copy of
0009: * the GNU General Public License along with BORG; if not, write to the Free
0010: * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
0011: * USA Copyright 2003 by Mike Berger
0012: */
0013: package net.sf.borg.ui.calendar;
0014:
0015: import java.awt.Color;
0016: import java.awt.Component;
0017: import java.awt.Dimension;
0018: import java.awt.Graphics;
0019: import java.awt.Graphics2D;
0020: import java.awt.GridBagConstraints;
0021: import java.awt.GridBagLayout;
0022: import java.awt.Insets;
0023: import java.text.SimpleDateFormat;
0024: import java.util.ArrayList;
0025: import java.util.Calendar;
0026: import java.util.Collection;
0027: import java.util.Date;
0028: import java.util.GregorianCalendar;
0029: import java.util.Iterator;
0030:
0031: import javax.swing.BoxLayout;
0032: import javax.swing.DefaultComboBoxModel;
0033: import javax.swing.Icon;
0034: import javax.swing.JButton;
0035: import javax.swing.JCheckBox;
0036: import javax.swing.JLabel;
0037: import javax.swing.JList;
0038: import javax.swing.JPanel;
0039: import javax.swing.JSpinner;
0040: import javax.swing.JTextField;
0041: import javax.swing.JToggleButton;
0042: import javax.swing.ListCellRenderer;
0043: import javax.swing.SpinnerNumberModel;
0044: import javax.swing.SwingConstants;
0045:
0046: import net.sf.borg.common.Errmsg;
0047: import net.sf.borg.common.PrefName;
0048: import net.sf.borg.common.Prefs;
0049: import net.sf.borg.common.Resource;
0050: import net.sf.borg.common.Warning;
0051: import net.sf.borg.common.XTree;
0052: import net.sf.borg.model.AppointmentModel;
0053: import net.sf.borg.model.CategoryModel;
0054: import net.sf.borg.model.ReminderTimes;
0055: import net.sf.borg.model.Repeat;
0056: import net.sf.borg.model.beans.Appointment;
0057: import net.sf.borg.model.beans.AppointmentXMLAdapter;
0058: import net.sf.borg.ui.ResourceHelper;
0059: import net.sf.borg.ui.link.LinkPanel;
0060: import net.sf.borg.ui.popup.PopupOptionsView;
0061:
0062: import com.toedter.calendar.JDateChooser;
0063:
0064: public class AppointmentPanel extends JPanel {
0065:
0066: static private class ColorBoxRenderer extends JLabel implements
0067: ListCellRenderer {
0068:
0069: public ColorBoxRenderer() {
0070: setOpaque(true);
0071: setHorizontalAlignment(CENTER);
0072: setVerticalAlignment(CENTER);
0073: }
0074:
0075: public Component getListCellRendererComponent(JList list,
0076: Object value, int index, boolean isSelected,
0077: boolean cellHasFocus) {
0078: String sel = (String) value;
0079:
0080: if (isSelected) {
0081: setBackground(list.getSelectionBackground());
0082: } else {
0083: setBackground(list.getBackground());
0084: }
0085:
0086: setText(" ");
0087: if (sel.equals("black")) {
0088: setIcon(new SolidComboBoxIcon(new Color(Integer
0089: .parseInt(Prefs.getPref(PrefName.UCS_BLACK)))));
0090: } else if (sel.equals("red")) {
0091: setIcon(new SolidComboBoxIcon(new Color(Integer
0092: .parseInt(Prefs.getPref(PrefName.UCS_RED)))));
0093: } else if (sel.equals("blue")) {
0094: setIcon(new SolidComboBoxIcon(new Color(Integer
0095: .parseInt(Prefs.getPref(PrefName.UCS_BLUE)))));
0096: } else if (sel.equals("green")) {
0097: setIcon(new SolidComboBoxIcon(new Color(Integer
0098: .parseInt(Prefs.getPref(PrefName.UCS_GREEN)))));
0099: } else if (sel.equals("white")) {
0100: setIcon(new SolidComboBoxIcon(new Color(Integer
0101: .parseInt(Prefs.getPref(PrefName.UCS_WHITE)))));
0102: } else {
0103: setForeground(Color.BLACK);
0104: setText(Resource.getResourceString("strike"));
0105: setIcon(null);
0106: }
0107:
0108: return this ;
0109: }
0110:
0111: }
0112:
0113: static private class SolidComboBoxIcon implements Icon {
0114: private Color color = Color.BLACK;
0115:
0116: private final int h = 10;
0117:
0118: private final int w = 60;
0119:
0120: public SolidComboBoxIcon(Color col) {
0121: color = col;
0122: }
0123:
0124: public int getIconHeight() {
0125: return h;
0126: }
0127:
0128: public int getIconWidth() {
0129: return w;
0130: }
0131:
0132: public void paintIcon(Component c, Graphics g, int x, int y) {
0133: Graphics2D g2 = (Graphics2D) g;
0134: g2.setColor(Color.BLACK);
0135: g2.drawRect(x, y, w, h);
0136: g2.setColor(color);
0137: g2.fillRect(x, y, w, h);
0138: }
0139: }
0140:
0141: static private DefaultComboBoxModel milHourModel = new DefaultComboBoxModel(
0142: new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8",
0143: "9", "10", "11", "12", "13", "14", "15", "16",
0144: "17", "18", "19", "20", "21", "22", "23" });
0145:
0146: static private DefaultComboBoxModel normHourModel = new DefaultComboBoxModel(
0147: new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9",
0148: "10", "11", "12" });
0149:
0150: static private SimpleDateFormat shortDayFmt = new SimpleDateFormat(
0151: "EEE");
0152:
0153: // for setting labels
0154: static private GregorianCalendar tmpcal = new GregorianCalendar();
0155:
0156: private JCheckBox alarmcb = null;
0157:
0158: // Variables declaration - do not modify//GEN-BEGIN:variables
0159: private javax.swing.JTextArea appttextarea;
0160:
0161: private JTextField apptTitleField = null;
0162:
0163: private LinkPanel attPanel = null;
0164:
0165: private javax.swing.JComboBox catbox;
0166:
0167: private javax.swing.JCheckBox chgdate;
0168:
0169: private javax.swing.JComboBox colorbox;
0170:
0171: private String colors[] = { "red", "blue", "green", "black",
0172: "white", "strike" };
0173:
0174: private char[] custRemTimes;
0175:
0176: private int day_;
0177:
0178: private JToggleButton dl1 = null;
0179:
0180: private JToggleButton dl2 = null;
0181:
0182: private JToggleButton dl3 = null;
0183:
0184: private JToggleButton dl4 = null;
0185:
0186: private JToggleButton dl5 = null;
0187:
0188: private JToggleButton dl6 = null;
0189:
0190: private JToggleButton dl7 = null;
0191:
0192: private JPanel dlistbuttonpanel = null;
0193:
0194: private javax.swing.JComboBox durhour;
0195:
0196: private javax.swing.JComboBox durmin;
0197:
0198: private javax.swing.JCheckBox foreverbox;
0199:
0200: private javax.swing.JComboBox freq;
0201:
0202: private javax.swing.JCheckBox halfdaycb;
0203:
0204: private javax.swing.JCheckBox holidaycb;
0205:
0206: private JLabel jLabel = null;
0207:
0208: private javax.swing.JLabel jLabel2;
0209:
0210: private JPanel jPanel = null;
0211:
0212: private javax.swing.JPanel jPanel1;
0213:
0214: private javax.swing.JPanel jPanel2;
0215:
0216: private javax.swing.JPanel jPanel3;
0217:
0218: private javax.swing.JPanel jPanel4;
0219:
0220: private JPanel jPanel5;
0221:
0222: private javax.swing.JScrollPane jScrollPane1;
0223:
0224: private int key_;
0225:
0226: private javax.swing.JLabel lblCategory;
0227:
0228: private javax.swing.JLabel lblColor;
0229:
0230: private javax.swing.JLabel lblDuration;
0231:
0232: private javax.swing.JLabel lblFrequency;
0233:
0234: private javax.swing.JLabel lblNewDate;
0235:
0236: private javax.swing.JLabel lblStartTime;
0237:
0238: private javax.swing.JLabel lblTimes;
0239:
0240: private int month_;
0241:
0242: private JSpinner ndays = null;
0243:
0244: private JDateChooser newdatefield;
0245:
0246: private javax.swing.JCheckBox notecb;
0247:
0248: private JButton popupTimesBtn;
0249:
0250: private JLabel popupTimesLabel;
0251:
0252: private javax.swing.JCheckBox privatecb;
0253:
0254: private JCheckBox rptnumbox = null;
0255:
0256: private javax.swing.JSpinner s_times;
0257:
0258: private javax.swing.JButton savebutton;
0259:
0260: private javax.swing.JButton savedefaultsbutton;
0261:
0262: private javax.swing.JCheckBox startap;
0263:
0264: private javax.swing.JComboBox starthour;
0265:
0266: private javax.swing.JComboBox startmin;
0267:
0268: private javax.swing.JCheckBox todocb;
0269:
0270: private javax.swing.JCheckBox vacationcb;
0271:
0272: private int year_;
0273:
0274: public AppointmentPanel(int year, int month, int day) {
0275:
0276: // init GUI
0277: initComponents();
0278:
0279: ColorBoxRenderer cbr = new ColorBoxRenderer();
0280: colorbox.setRenderer(cbr);
0281: colorbox.setEditable(false);
0282:
0283: // set up the spinner for repeat times
0284: SpinnerNumberModel mod = (SpinnerNumberModel) s_times
0285: .getModel();
0286: mod.setMinimum(new Integer(1));
0287:
0288: // set up hours pulldown
0289: String mt = Prefs.getPref(PrefName.MILTIME);
0290: if (mt.equals("true")) {
0291: starthour.setModel(milHourModel);
0292: startap.setVisible(false);
0293: } else {
0294: starthour.setModel(normHourModel);
0295: startap.setVisible(true);
0296: }
0297:
0298: try {
0299: Collection cats = CategoryModel.getReference()
0300: .getCategories();
0301: Iterator it = cats.iterator();
0302: while (it.hasNext()) {
0303: catbox.addItem(it.next());
0304: }
0305: catbox.setSelectedIndex(0);
0306: } catch (Exception e) {
0307: Errmsg.errmsg(e);
0308: }
0309:
0310: for (int i = 0; i < colors.length; i++) {
0311: colorbox.addItem(colors[i]);
0312: }
0313:
0314: for (int i = 0;; i++) {
0315: String fs = Repeat.getFreqString(i);
0316: if (fs == null)
0317: break;
0318: freq.addItem(fs);
0319: }
0320:
0321: setDate(year, month, day);
0322:
0323: String palm = Prefs.getPref(PrefName.PALM_SYNC);
0324: if (!palm.equals("true")) {
0325: alarmcb.setEnabled(false);
0326: }
0327: setCustRemTimes(null);
0328:
0329: apptTitleField.requestFocus();
0330: }
0331:
0332: private void add_appt() {
0333: // user has requested an add of a new appt
0334:
0335: // get a new appt from the model and set it from the user data
0336: AppointmentModel calmod_ = AppointmentModel.getReference();
0337: Appointment r = calmod_.newAppt();
0338: int ret = 0;
0339: try {
0340: ret = setAppt(r, true);
0341: } catch (Warning w) {
0342: Errmsg.notice(w.getMessage());
0343: return;
0344: } catch (Exception e) {
0345: Errmsg.errmsg(e);
0346: return;
0347: }
0348:
0349: if (ret < 0)
0350: return;
0351:
0352: calmod_.saveAppt(r, true);
0353:
0354: showapp(-1, null);
0355: }
0356:
0357: private void chg_appt() {
0358: // user had selected appt change
0359:
0360: // get a new empty appt from the model and set it using the data the
0361: // user has entered
0362: AppointmentModel calmod_ = AppointmentModel.getReference();
0363: Appointment r = calmod_.newAppt();
0364: int newkey = 0;
0365: try {
0366: newkey = setAppt(r, true);
0367: } catch (Warning w) {
0368: Errmsg.notice(w.getMessage());
0369: return;
0370: } catch (Exception e) {
0371: Errmsg.errmsg(e);
0372: return;
0373: }
0374:
0375: if (newkey < 0)
0376: return;
0377:
0378: // call the model to change the appt
0379: if (newkey == 0) {
0380: r.setKey(key_);
0381: // need to preserve data from original appt
0382: try {
0383: Appointment ap = calmod_.getAppt(key_);
0384: Calendar cal = new GregorianCalendar();
0385: Calendar newCal = new GregorianCalendar();
0386:
0387: cal.setTime(ap.getDate());
0388: newCal.setTime(r.getDate());
0389: newCal.set(Calendar.YEAR, cal.get(Calendar.YEAR));
0390: newCal.set(Calendar.MONTH, cal.get(Calendar.MONTH));
0391: newCal.set(Calendar.DATE, cal.get(Calendar.DATE));
0392: r.setDate(newCal.getTime());
0393:
0394: // determine if we can keep certain fields related to repeating
0395: // and todos
0396: if (r.getTimes().intValue() == ap.getTimes().intValue()
0397: && r.getFrequency() != null
0398: && ap.getFrequency() != null
0399: && Repeat.getFreq(r.getFrequency()).equals(
0400: Repeat.getFreq(ap.getFrequency()))
0401: && r.getTodo() == ap.getTodo()
0402: && r.getRepeatFlag() == ap.getRepeatFlag()) {
0403: // we can keep skip list and next todo
0404: r.setSkipList(ap.getSkipList());
0405: r.setNextTodo(ap.getNextTodo());
0406: }
0407:
0408: // should carry forward sync flags
0409: r.setNew(ap.getNew());
0410: r.setModified(ap.getModified());
0411: //AppointmentXMLAdapter aa = new AppointmentXMLAdapter();
0412:
0413: //System.out.println(aa.toXml(r));
0414: //System.out.println(aa.toXml(ap));
0415: } catch (Exception e) {
0416: //Errmsg.errmsg(e);
0417: }
0418: calmod_.saveAppt(r, false);
0419: } else {
0420: r.setKey(key_);
0421: try {
0422: calmod_.changeDate(r);
0423: } catch (Exception e) {
0424: Errmsg.errmsg(e);
0425: }
0426:
0427: }
0428:
0429: showapp(-1, null);
0430: }
0431:
0432: private void chgdateActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_chgdateActionPerformed
0433: newdatefield.setEnabled(chgdate.isSelected());
0434:
0435: }// GEN-LAST:event_chgdateActionPerformed
0436:
0437: private void foreverboxActionPerformed(
0438: java.awt.event.ActionEvent evt)// GEN-FIRST:event_foreverboxActionPerformed
0439: {// GEN-HEADEREND:event_foreverboxActionPerformed
0440: if (foreverbox.isSelected()) {
0441: s_times.setValue(new Integer(0));
0442: s_times.setEnabled(false);
0443:
0444: } else {
0445: s_times.setValue(new Integer(1));
0446: s_times.setEnabled(true);
0447: }
0448: }// GEN-LAST:event_foreverboxActionPerformed
0449:
0450: /**
0451: * This method initializes apptTitleField
0452: *
0453: * @return javax.swing.JTextField
0454: */
0455: private JTextField getApptTitleField() {
0456: if (apptTitleField == null) {
0457: apptTitleField = new JTextField();
0458: }
0459: return apptTitleField;
0460: }
0461:
0462: /**
0463: * This method initializes dl1
0464: *
0465: * @return javax.swing.JToggleButton
0466: */
0467: private JToggleButton getDl1() {
0468: if (dl1 == null) {
0469: dl1 = new JToggleButton();
0470: tmpcal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
0471: dl1.setText(shortDayFmt.format(tmpcal.getTime()));
0472: }
0473: return dl1;
0474: }
0475:
0476: /**
0477: * This method initializes dl2
0478: *
0479: * @return javax.swing.JToggleButton
0480: */
0481: private JToggleButton getDl2() {
0482: if (dl2 == null) {
0483: dl2 = new JToggleButton();
0484: tmpcal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
0485: dl2.setText(shortDayFmt.format(tmpcal.getTime()));
0486: }
0487: return dl2;
0488: }
0489:
0490: /**
0491: * This method initializes dl3
0492: *
0493: * @return javax.swing.JToggleButton
0494: */
0495: private JToggleButton getDl3() {
0496: if (dl3 == null) {
0497: dl3 = new JToggleButton();
0498: tmpcal.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY);
0499: dl3.setText(shortDayFmt.format(tmpcal.getTime()));
0500: }
0501: return dl3;
0502: }
0503:
0504: /**
0505: * This method initializes dl4
0506: *
0507: * @return javax.swing.JToggleButton
0508: */
0509: private JToggleButton getDl4() {
0510: if (dl4 == null) {
0511: dl4 = new JToggleButton();
0512: tmpcal.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY);
0513: dl4.setText(shortDayFmt.format(tmpcal.getTime()));
0514: }
0515: return dl4;
0516: }
0517:
0518: /**
0519: * This method initializes dl5
0520: *
0521: * @return javax.swing.JToggleButton
0522: */
0523: private JToggleButton getDl5() {
0524: if (dl5 == null) {
0525: dl5 = new JToggleButton();
0526: tmpcal.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY);
0527: dl5.setText(shortDayFmt.format(tmpcal.getTime()));
0528: }
0529: return dl5;
0530: }
0531:
0532: /**
0533: * This method initializes dl6
0534: *
0535: * @return javax.swing.JToggleButton
0536: */
0537: private JToggleButton getDl6() {
0538: if (dl6 == null) {
0539: dl6 = new JToggleButton();
0540: tmpcal.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY);
0541: dl6.setText(shortDayFmt.format(tmpcal.getTime()));
0542: }
0543: return dl6;
0544: }
0545:
0546: /**
0547: * This method initializes dl7
0548: *
0549: * @return javax.swing.JToggleButton
0550: */
0551: private JToggleButton getDl7() {
0552: if (dl7 == null) {
0553: dl7 = new JToggleButton();
0554: tmpcal.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
0555: dl7.setText(shortDayFmt.format(tmpcal.getTime()));
0556: }
0557: return dl7;
0558: }
0559:
0560: /**
0561: * This method initializes dlistbuttonpanel
0562: *
0563: * @return javax.swing.JPanel
0564: */
0565: private JPanel getDlistbuttonpanel() {
0566: if (dlistbuttonpanel == null) {
0567: dlistbuttonpanel = new JPanel();
0568: dlistbuttonpanel.setLayout(new BoxLayout(
0569: getDlistbuttonpanel(), BoxLayout.X_AXIS)); // Generated
0570: dlistbuttonpanel.add(getDl1(), null); // Generated
0571: dlistbuttonpanel.add(getDl2(), null); // Generated
0572: dlistbuttonpanel.add(getDl3(), null); // Generated
0573: dlistbuttonpanel.add(getDl4(), null); // Generated
0574: dlistbuttonpanel.add(getDl5(), null); // Generated
0575: dlistbuttonpanel.add(getDl6(), null); // Generated
0576: dlistbuttonpanel.add(getDl7(), null); // Generated
0577: }
0578: return dlistbuttonpanel;
0579: }
0580:
0581: private JPanel getJPanel() {
0582: if (jPanel == null) {
0583: GridBagConstraints gridBagConstraints19 = new GridBagConstraints();
0584: GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
0585: GridBagConstraints gridBagConstraints28 = new GridBagConstraints();
0586: GridBagConstraints gridBagConstraints13 = new GridBagConstraints();
0587: GridBagConstraints gridBagConstraints71 = new GridBagConstraints();
0588: GridBagConstraints gridBagConstraints61 = new GridBagConstraints();
0589: GridBagConstraints gridBagConstraints51 = new GridBagConstraints();
0590: GridBagConstraints gridBagConstraints41 = new GridBagConstraints();
0591: GridBagConstraints gridBagConstraints31 = new GridBagConstraints();
0592: jPanel = new JPanel();
0593: jPanel.setLayout(new GridBagLayout());
0594: jPanel
0595: .setBorder(new javax.swing.border.TitledBorder(
0596: null,
0597: Resource.getResourceString("Recurrence"),
0598: javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
0599: javax.swing.border.TitledBorder.DEFAULT_POSITION,
0600: null, null));
0601: gridBagConstraints31.gridx = 0;
0602: gridBagConstraints31.gridy = 0;
0603: gridBagConstraints31.insets = new java.awt.Insets(0, 0, 0,
0604: 0);
0605: gridBagConstraints41.gridx = 1;
0606: gridBagConstraints41.gridy = 0;
0607: gridBagConstraints41.anchor = java.awt.GridBagConstraints.SOUTHEAST;
0608: gridBagConstraints41.fill = java.awt.GridBagConstraints.HORIZONTAL;
0609: gridBagConstraints41.insets = new java.awt.Insets(4, 4, 4,
0610: 4);
0611: gridBagConstraints41.weightx = 0.0D;
0612: gridBagConstraints51.gridx = 0;
0613: gridBagConstraints51.gridy = 1;
0614: gridBagConstraints51.anchor = java.awt.GridBagConstraints.WEST;
0615: gridBagConstraints51.fill = java.awt.GridBagConstraints.BOTH;
0616: gridBagConstraints51.insets = new java.awt.Insets(4, 4, 4,
0617: 4);
0618: gridBagConstraints61.gridx = 1;
0619: gridBagConstraints61.gridy = 1;
0620: gridBagConstraints61.fill = java.awt.GridBagConstraints.BOTH;
0621: gridBagConstraints61.insets = new java.awt.Insets(4, 4, 4,
0622: 4);
0623: gridBagConstraints61.weightx = 0.0D;
0624: gridBagConstraints71.gridx = 2;
0625: gridBagConstraints71.gridy = 1;
0626: gridBagConstraints71.fill = java.awt.GridBagConstraints.BOTH;
0627: gridBagConstraints13.gridx = 4;
0628: gridBagConstraints13.gridy = 0;
0629: gridBagConstraints28.gridx = 2;
0630: gridBagConstraints28.gridy = 0;
0631: gridBagConstraints28.insets = new java.awt.Insets(4, 4, 4,
0632: 4);
0633: gridBagConstraints28.fill = java.awt.GridBagConstraints.HORIZONTAL;
0634: gridBagConstraints19.gridx = 2;
0635: gridBagConstraints19.gridy = 0;
0636: //gridBagConstraints19.insets = new java.awt.Insets(4, 4, 4, 4);
0637: gridBagConstraints19.fill = java.awt.GridBagConstraints.BOTH;
0638: jPanel.add(lblFrequency, gridBagConstraints31);
0639: jPanel.add(freq, gridBagConstraints41);
0640: jPanel.add(lblTimes, gridBagConstraints51);
0641: jPanel.add(s_times, gridBagConstraints61);
0642: jPanel.add(foreverbox, gridBagConstraints71);
0643: jPanel.add(ndays, gridBagConstraints28);
0644:
0645: jPanel.add(getRptnumbox(), gridBagConstraints19);
0646:
0647: gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; // Generated
0648: gridBagConstraints1.gridy = 0; // Generated
0649: gridBagConstraints1.gridx = 2; // Generated
0650: gridBagConstraints1.gridwidth = 2;
0651: jPanel.add(getDlistbuttonpanel(), gridBagConstraints1); // Generated
0652: }
0653: return jPanel;
0654: }
0655:
0656: private JCheckBox getRemBox() {
0657: if (alarmcb == null) {
0658: alarmcb = new JCheckBox();
0659: ResourceHelper.setText(alarmcb, "Alarm");
0660: }
0661: return alarmcb;
0662: }
0663:
0664: /**
0665: * This method initializes rptnumbox
0666: *
0667: * @return javax.swing.JCheckBox
0668: */
0669: private JCheckBox getRptnumbox() {
0670: if (rptnumbox == null) {
0671: rptnumbox = new JCheckBox();
0672: ResourceHelper.setText(rptnumbox, "show_rpt_num");
0673: }
0674: return rptnumbox;
0675: }
0676:
0677: public String getText() {
0678: String labelstring = appttextarea.getText();
0679: if (labelstring.equals("")) {
0680: return Resource.getResourceString("*****_NEW_APPT_*****");
0681: }
0682:
0683: return labelstring;
0684:
0685: }
0686:
0687: /**
0688: * This method is called from within the constructor to init
0689: * gridBagConstraints28.gridx = 0; gridBagConstraints28.gridy = 4;
0690: * gridBagConstraints28.fill = java.awt.GridBagConstraints.BOTH;
0691: * this.add(getJPanel(), gridBagConstraints28); ialize the form.
0692: * WARNING: Do NOT modify this code. The content of this method is
0693: * always regenerated by the Form Editor.
0694: */
0695: private void initComponents()// GEN-BEGIN:initComponents
0696: {
0697:
0698: GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
0699: gridBagConstraints10.fill = GridBagConstraints.BOTH;
0700: gridBagConstraints10.gridy = 0;
0701: gridBagConstraints10.weightx = 1.0;
0702: gridBagConstraints10.insets = new Insets(4, 4, 4, 4);
0703: gridBagConstraints10.gridx = 1;
0704: GridBagConstraints gridBagConstraints = new GridBagConstraints();
0705: gridBagConstraints.gridx = 0;
0706: gridBagConstraints.gridy = 0;
0707: jLabel = new JLabel();
0708: jLabel.setText(Resource.getPlainResourceString("subject"));
0709: GridBagConstraints gridBagConstraints18 = new GridBagConstraints();
0710: jLabel2 = new javax.swing.JLabel();
0711: jPanel1 = new javax.swing.JPanel();
0712: jScrollPane1 = new javax.swing.JScrollPane();
0713: appttextarea = new javax.swing.JTextArea();
0714: jPanel2 = new javax.swing.JPanel();
0715: starthour = new javax.swing.JComboBox();
0716: startmin = new javax.swing.JComboBox();
0717: startap = new javax.swing.JCheckBox();
0718: durhour = new javax.swing.JComboBox();
0719: durmin = new javax.swing.JComboBox();
0720: lblStartTime = new javax.swing.JLabel();
0721: lblDuration = new javax.swing.JLabel();
0722: notecb = new javax.swing.JCheckBox();
0723: lblNewDate = new javax.swing.JLabel();
0724: newdatefield = new JDateChooser();
0725: newdatefield.setDateFormatString("MMM dd, yyyy");
0726: chgdate = new javax.swing.JCheckBox();
0727: jPanel3 = new javax.swing.JPanel();
0728: todocb = new javax.swing.JCheckBox();
0729: vacationcb = new javax.swing.JCheckBox();
0730: halfdaycb = new javax.swing.JCheckBox();
0731: holidaycb = new javax.swing.JCheckBox();
0732: privatecb = new javax.swing.JCheckBox();
0733: lblColor = new javax.swing.JLabel();
0734: colorbox = new javax.swing.JComboBox();
0735: lblFrequency = new javax.swing.JLabel();
0736: freq = new javax.swing.JComboBox();
0737: s_times = new javax.swing.JSpinner();
0738: lblTimes = new javax.swing.JLabel();
0739: catbox = new javax.swing.JComboBox();
0740: lblCategory = new javax.swing.JLabel();
0741: foreverbox = new javax.swing.JCheckBox();
0742: jPanel4 = new javax.swing.JPanel();
0743: GridBagConstraints gridBagConstraints81 = new GridBagConstraints();
0744: GridBagConstraints gridBagConstraints91 = new GridBagConstraints();
0745: savebutton = new javax.swing.JButton();
0746: savedefaultsbutton = new javax.swing.JButton();
0747: ndays = new JSpinner();
0748: ndays.setModel(new SpinnerNumberModel(2, 2, 3000, 1));
0749:
0750: lblStartTime.setLabelFor(starthour);
0751: lblDuration.setLabelFor(durhour);
0752: lblCategory.setLabelFor(catbox);
0753: lblColor.setLabelFor(colorbox);
0754: lblFrequency.setLabelFor(freq);
0755: lblNewDate.setLabelFor(newdatefield);
0756: lblTimes.setLabelFor(s_times);
0757:
0758: setLayout(new java.awt.GridBagLayout());
0759:
0760: jLabel2.setForeground(java.awt.Color.red);
0761: // jLabel2.setText("jLabel2");
0762: GridBagConstraints gridBagConstraints2 = new java.awt.GridBagConstraints();
0763: gridBagConstraints2.gridx = 0;
0764: gridBagConstraints2.gridy = 0;
0765: gridBagConstraints2.fill = java.awt.GridBagConstraints.BOTH;
0766: add(jLabel2, gridBagConstraints2);
0767:
0768: jPanel1.setLayout(new java.awt.GridBagLayout());
0769:
0770: jPanel1.setBorder(new javax.swing.border.TitledBorder(Resource
0771: .getResourceString("appttext")));
0772: jScrollPane1.setPreferredSize(new Dimension(200, 140));
0773: appttextarea.setColumns(40);
0774: appttextarea.setSize(new Dimension(300, 84));
0775: appttextarea.setPreferredSize(new Dimension(300, 84));
0776: appttextarea.setLineWrap(true);
0777: appttextarea.setRows(5);
0778: appttextarea.setWrapStyleWord(true);
0779: appttextarea.setBorder(new javax.swing.border.BevelBorder(
0780: javax.swing.border.BevelBorder.LOWERED));
0781: appttextarea.setMinimumSize(new java.awt.Dimension(284, 140));
0782: jScrollPane1.setViewportView(appttextarea);
0783:
0784: GridBagConstraints gridBagConstraints1 = new java.awt.GridBagConstraints();
0785: gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH;
0786: gridBagConstraints1.weightx = 0.5D;
0787: gridBagConstraints1.gridy = 2;
0788: gridBagConstraints1.gridwidth = 1;
0789: gridBagConstraints1.gridx = 1;
0790: gridBagConstraints1.insets = new Insets(4, 4, 4, 4);
0791: gridBagConstraints1.weighty = 0.5D;
0792: jPanel1.add(jScrollPane1, gridBagConstraints1);
0793: jPanel1.add(jLabel, gridBagConstraints);
0794: jPanel1.add(getApptTitleField(), gridBagConstraints10);
0795: GridBagConstraints gridBagConstraints3 = new java.awt.GridBagConstraints();
0796: gridBagConstraints3.gridx = 0;
0797: gridBagConstraints3.gridy = 1;
0798: gridBagConstraints3.gridwidth = java.awt.GridBagConstraints.REMAINDER;
0799: gridBagConstraints3.fill = java.awt.GridBagConstraints.BOTH;
0800: gridBagConstraints3.weightx = 1.5;
0801: gridBagConstraints3.weighty = 2.0;
0802: gridBagConstraints3.insets = new java.awt.Insets(5, 5, 5, 5);
0803: add(jPanel1, gridBagConstraints3);
0804:
0805: jPanel2.setLayout(new java.awt.GridBagLayout());
0806:
0807: jPanel2.setBorder(new javax.swing.border.TitledBorder(Resource
0808: .getResourceString("appttime")));
0809: starthour.setMaximumRowCount(24);
0810: starthour.setMinimumSize(new java.awt.Dimension(42, 36));
0811: starthour.setOpaque(false);
0812: GridBagConstraints gridBagConstraints4 = new java.awt.GridBagConstraints();
0813: gridBagConstraints4.gridx = 1;
0814: gridBagConstraints4.gridy = 0;
0815: gridBagConstraints4.fill = java.awt.GridBagConstraints.BOTH;
0816: startmin.setMaximumRowCount(12);
0817: startmin.setModel(new javax.swing.DefaultComboBoxModel(
0818: new String[] { "00", "05", "10", "15", "20", "25",
0819: "30", "35", "40", "45", "50", "55" }));
0820: startmin.setOpaque(false);
0821: GridBagConstraints gridBagConstraints5 = new java.awt.GridBagConstraints();
0822: gridBagConstraints5.gridx = 2;
0823: gridBagConstraints5.gridy = 0;
0824: gridBagConstraints5.fill = java.awt.GridBagConstraints.VERTICAL;
0825: startap.setText("PM");
0826: startap.setOpaque(false);
0827: GridBagConstraints gridBagConstraints6 = new java.awt.GridBagConstraints();
0828: gridBagConstraints6.gridx = 3;
0829: gridBagConstraints6.gridy = 0;
0830: gridBagConstraints6.fill = java.awt.GridBagConstraints.BOTH;
0831: jPanel2.add(startap, gridBagConstraints6);
0832:
0833: durhour.setMaximumRowCount(24);
0834: durhour
0835: .setModel(new javax.swing.DefaultComboBoxModel(
0836: new String[] { "0", "1", "2", "3", "4", "5",
0837: "6", "7", "8", "9", "10", "11", "12",
0838: "13", "14", "15", "16", "17", "18",
0839: "19", "20", "21", "22", "23" }));
0840: GridBagConstraints gridBagConstraints7 = new java.awt.GridBagConstraints();
0841: gridBagConstraints7.gridx = 1;
0842: gridBagConstraints7.gridy = 1;
0843: gridBagConstraints7.fill = java.awt.GridBagConstraints.BOTH;
0844: durmin.setMaximumRowCount(12);
0845: durmin.setModel(new javax.swing.DefaultComboBoxModel(
0846: new String[] { "00", "05", "10", "15", "20", "25",
0847: "30", "35", "40", "45", "50", "55" }));
0848: durmin.setOpaque(false);
0849: GridBagConstraints gridBagConstraints8 = new java.awt.GridBagConstraints();
0850: gridBagConstraints8.gridx = 2;
0851: gridBagConstraints8.gridy = 1;
0852: gridBagConstraints8.fill = java.awt.GridBagConstraints.VERTICAL;
0853: ResourceHelper.setText(lblStartTime, "Start_Time:");
0854: GridBagConstraints gridBagConstraints9 = new java.awt.GridBagConstraints();
0855: gridBagConstraints9.gridx = 0;
0856: gridBagConstraints9.gridy = 0;
0857: gridBagConstraints9.fill = java.awt.GridBagConstraints.VERTICAL;
0858: gridBagConstraints9.anchor = java.awt.GridBagConstraints.EAST;
0859: gridBagConstraints9.insets = new java.awt.Insets(0, 7, 0, 7);
0860: jPanel2.add(lblStartTime, gridBagConstraints9);
0861:
0862: ResourceHelper.setText(lblDuration, "Duration:");
0863: GridBagConstraints gridBagConstraints11 = new java.awt.GridBagConstraints();
0864: gridBagConstraints11.gridx = 0;
0865: gridBagConstraints11.gridy = 1;
0866: gridBagConstraints11.fill = java.awt.GridBagConstraints.VERTICAL;
0867: gridBagConstraints11.anchor = java.awt.GridBagConstraints.EAST;
0868: gridBagConstraints11.insets = new java.awt.Insets(0, 8, 0, 8);
0869: jPanel2.add(lblDuration, gridBagConstraints11);
0870:
0871: ResourceHelper.setText(notecb, "No_Specific_Time");
0872: freq.addActionListener(new java.awt.event.ActionListener() {
0873: public void actionPerformed(java.awt.event.ActionEvent e) {
0874: timesEnable();
0875: }
0876:
0877: });
0878: notecb.addActionListener(new java.awt.event.ActionListener() {
0879: public void actionPerformed(java.awt.event.ActionEvent evt) {
0880: notecbActionPerformed(evt);
0881: }
0882: });
0883:
0884: GridBagConstraints gridBagConstraints12 = new java.awt.GridBagConstraints();
0885: gridBagConstraints12.gridx = 4;
0886: gridBagConstraints12.gridy = 0;
0887: gridBagConstraints12.gridwidth = 1;
0888: gridBagConstraints12.fill = java.awt.GridBagConstraints.BOTH;
0889: ResourceHelper.setText(lblNewDate, "newDate:");
0890: GridBagConstraints gridBagConstraints14 = new java.awt.GridBagConstraints();
0891: gridBagConstraints14.gridx = 5;
0892: gridBagConstraints14.gridy = 1;
0893: gridBagConstraints14.fill = java.awt.GridBagConstraints.BOTH;
0894:
0895: GridBagConstraints gridBagConstraints15 = new java.awt.GridBagConstraints();
0896: gridBagConstraints15.gridx = 6;
0897: gridBagConstraints15.gridy = 1;
0898: gridBagConstraints15.fill = java.awt.GridBagConstraints.BOTH;
0899:
0900: ResourceHelper.setText(chgdate, "changedate");
0901: chgdate.addActionListener(new java.awt.event.ActionListener() {
0902: public void actionPerformed(java.awt.event.ActionEvent evt) {
0903: chgdateActionPerformed(evt);
0904: }
0905: });
0906:
0907: GridBagConstraints gridBagConstraints16 = new java.awt.GridBagConstraints();
0908: gridBagConstraints16.gridx = 4;
0909: gridBagConstraints16.gridy = 1;
0910: GridBagConstraints gridBagConstraints17 = new java.awt.GridBagConstraints();
0911: gridBagConstraints17.gridx = 0;
0912: gridBagConstraints17.gridy = 2;
0913: gridBagConstraints17.gridwidth = java.awt.GridBagConstraints.REMAINDER;
0914: gridBagConstraints17.fill = java.awt.GridBagConstraints.BOTH;
0915: gridBagConstraints17.weightx = 1.0;
0916: gridBagConstraints17.weighty = 1.0;
0917: gridBagConstraints17.insets = new java.awt.Insets(5, 5, 5, 5);
0918: jPanel3.setLayout(new java.awt.GridBagLayout());
0919:
0920: jPanel3.setBorder(new javax.swing.border.TitledBorder(Resource
0921: .getResourceString("Properties")));
0922: jPanel3.setMinimumSize(new java.awt.Dimension(539, 128));
0923: ResourceHelper.setText(todocb, "To_Do");
0924: todocb.setOpaque(false);
0925: GridBagConstraints gridBagConstraints21 = new java.awt.GridBagConstraints();
0926: gridBagConstraints21.weightx = 1.0;
0927: gridBagConstraints21.insets = new java.awt.Insets(4, 4, 4, 4);
0928: jPanel3.add(todocb, gridBagConstraints21);
0929:
0930: vacationcb.setForeground(new java.awt.Color(0, 102, 0));
0931: ResourceHelper.setText(vacationcb, "Vacation");
0932: vacationcb.setOpaque(false);
0933: GridBagConstraints gridBagConstraints22 = new java.awt.GridBagConstraints();
0934: gridBagConstraints22.weightx = 1.0;
0935: gridBagConstraints22.insets = new java.awt.Insets(4, 4, 4, 4);
0936: jPanel3.add(vacationcb, gridBagConstraints22);
0937:
0938: halfdaycb.setForeground(new java.awt.Color(0, 102, 102));
0939: ResourceHelper.setText(halfdaycb, "Half_Day");
0940: halfdaycb.setOpaque(false);
0941: GridBagConstraints gridBagConstraints23 = new java.awt.GridBagConstraints();
0942: gridBagConstraints23.weightx = 1.0;
0943: gridBagConstraints23.insets = new java.awt.Insets(4, 4, 4, 4);
0944: jPanel3.add(halfdaycb, gridBagConstraints23);
0945:
0946: ResourceHelper.setText(holidaycb, "Holiday");
0947: holidaycb.setOpaque(false);
0948: GridBagConstraints gridBagConstraints24 = new java.awt.GridBagConstraints();
0949: gridBagConstraints24.weightx = 1.0;
0950: gridBagConstraints24.insets = new java.awt.Insets(4, 4, 4, 4);
0951: jPanel3.add(holidaycb, gridBagConstraints24);
0952:
0953: ResourceHelper.setText(privatecb, "Private");
0954: privatecb.setOpaque(false);
0955: GridBagConstraints gridBagConstraints25 = new java.awt.GridBagConstraints();
0956: gridBagConstraints25.weightx = 1.0;
0957: gridBagConstraints25.insets = new java.awt.Insets(4, 4, 4, 4);
0958: jPanel3.add(privatecb, gridBagConstraints25);
0959:
0960: lblColor
0961: .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
0962: ResourceHelper.setText(lblColor, "Color");
0963: GridBagConstraints gridBagConstraints26 = new java.awt.GridBagConstraints();
0964: gridBagConstraints26.gridx = 0;
0965: gridBagConstraints26.gridy = 1;
0966: gridBagConstraints26.fill = java.awt.GridBagConstraints.BOTH;
0967: gridBagConstraints26.anchor = java.awt.GridBagConstraints.WEST;
0968: gridBagConstraints26.insets = new java.awt.Insets(4, 4, 4, 4);
0969: jPanel3.add(lblColor, gridBagConstraints26);
0970:
0971: colorbox.setOpaque(false);
0972: GridBagConstraints gridBagConstraints27 = new java.awt.GridBagConstraints();
0973: gridBagConstraints27.gridx = 1;
0974: gridBagConstraints27.gridy = 1;
0975: gridBagConstraints27.fill = java.awt.GridBagConstraints.BOTH;
0976: gridBagConstraints27.anchor = java.awt.GridBagConstraints.WEST;
0977: gridBagConstraints27.insets = new java.awt.Insets(4, 4, 4, 4);
0978: jPanel3.add(colorbox, gridBagConstraints27);
0979:
0980: lblFrequency
0981: .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
0982: ResourceHelper.setText(lblFrequency, "Frequency");
0983: freq.setOpaque(false);
0984: s_times.setBorder(new javax.swing.border.EtchedBorder());
0985: lblTimes
0986: .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
0987: ResourceHelper.setText(lblTimes, "Times");
0988: GridBagConstraints gridBagConstraints35 = new java.awt.GridBagConstraints();
0989: gridBagConstraints35.gridx = 3;
0990: gridBagConstraints35.gridy = 1;
0991: gridBagConstraints35.fill = java.awt.GridBagConstraints.BOTH;
0992: gridBagConstraints35.insets = new java.awt.Insets(4, 4, 4, 4);
0993: jPanel3.add(catbox, gridBagConstraints35);
0994:
0995: lblCategory
0996: .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
0997: ResourceHelper.setText(lblCategory, "Category");
0998: GridBagConstraints gridBagConstraints36 = new java.awt.GridBagConstraints();
0999: gridBagConstraints36.gridx = 2;
1000: gridBagConstraints36.gridy = 1;
1001: gridBagConstraints36.fill = java.awt.GridBagConstraints.BOTH;
1002: gridBagConstraints36.anchor = java.awt.GridBagConstraints.EAST;
1003: gridBagConstraints36.insets = new java.awt.Insets(4, 4, 4, 4);
1004: jPanel3.add(lblCategory, gridBagConstraints36);
1005:
1006: ResourceHelper.setText(foreverbox, "forever");
1007: foreverbox
1008: .addActionListener(new java.awt.event.ActionListener() {
1009: public void actionPerformed(
1010: java.awt.event.ActionEvent evt) {
1011: foreverboxActionPerformed(evt);
1012: }
1013: });
1014:
1015: GridBagConstraints gridBagConstraints38 = new java.awt.GridBagConstraints();
1016: gridBagConstraints38.gridx = 0;
1017: gridBagConstraints38.gridy = 3;
1018: gridBagConstraints38.fill = java.awt.GridBagConstraints.BOTH;
1019: gridBagConstraints38.weightx = 0.0D;
1020: gridBagConstraints38.weighty = 0.0D;
1021: gridBagConstraints38.gridwidth = 2;
1022: gridBagConstraints38.insets = new java.awt.Insets(5, 5, 5, 5);
1023: savebutton.setIcon(new javax.swing.ImageIcon(getClass()
1024: .getResource("/resource/Save16.gif")));
1025: ResourceHelper.setText(savebutton, "Save");
1026: savebutton
1027: .addActionListener(new java.awt.event.ActionListener() {
1028: public void actionPerformed(
1029: java.awt.event.ActionEvent evt) {
1030: savebuttonActionPerformed(evt);
1031: }
1032: });
1033:
1034: jPanel4.add(savebutton);
1035:
1036: savedefaultsbutton.setIcon(new javax.swing.ImageIcon(getClass()
1037: .getResource("/resource/SaveAs16.gif")));
1038: ResourceHelper.setText(savedefaultsbutton, "save_Def");
1039: savedefaultsbutton.setToolTipText(Resource
1040: .getResourceString("sd_tip"));
1041: savedefaultsbutton
1042: .addActionListener(new java.awt.event.ActionListener() {
1043: public void actionPerformed(
1044: java.awt.event.ActionEvent evt) {
1045: saveDefaults(evt);
1046: }
1047: });
1048:
1049: jPanel4.add(savedefaultsbutton);
1050:
1051: gridBagConstraints12.insets = new java.awt.Insets(0, 30, 0, 0);
1052: gridBagConstraints16.insets = new java.awt.Insets(0, 30, 0, 0);
1053: this .add(jPanel2, gridBagConstraints17);
1054: this .setSize(648, 590);
1055: jPanel2.add(notecb, gridBagConstraints12);
1056: jPanel2.add(lblNewDate, gridBagConstraints14);
1057: gridBagConstraints16.fill = java.awt.GridBagConstraints.HORIZONTAL;
1058: jPanel2.add(chgdate, gridBagConstraints16);
1059: gridBagConstraints4.insets = new java.awt.Insets(2, 2, 2, 2);
1060: jPanel2.add(starthour, gridBagConstraints4);
1061: gridBagConstraints7.insets = new java.awt.Insets(2, 2, 2, 2);
1062: jPanel2.add(durhour, gridBagConstraints7);
1063: gridBagConstraints5.insets = new java.awt.Insets(2, 2, 2, 2);
1064: jPanel2.add(startmin, gridBagConstraints5);
1065: gridBagConstraints8.insets = new java.awt.Insets(2, 2, 2, 2);
1066: gridBagConstraints81.gridx = 0;
1067: gridBagConstraints81.gridy = 5;
1068: gridBagConstraints81.weightx = 0.0;
1069: gridBagConstraints81.fill = java.awt.GridBagConstraints.BOTH;
1070: gridBagConstraints81.insets = new java.awt.Insets(4, 4, 4, 4);
1071: gridBagConstraints91.gridx = 0;
1072: gridBagConstraints91.gridy = 6;
1073: gridBagConstraints91.fill = java.awt.GridBagConstraints.BOTH;
1074: gridBagConstraints91.insets = new java.awt.Insets(4, 4, 4, 4);
1075: gridBagConstraints91.gridwidth = 2;
1076: gridBagConstraints15.insets = new java.awt.Insets(4, 4, 4, 4);
1077: gridBagConstraints18.gridx = 4;
1078: gridBagConstraints18.gridy = 1;
1079: gridBagConstraints18.fill = java.awt.GridBagConstraints.NONE;
1080: gridBagConstraints18.insets = new java.awt.Insets(4, 4, 4, 4);
1081: this .add(jPanel3, gridBagConstraints38);
1082: this .add(getJPanel(), gridBagConstraints81);
1083: this .add(jPanel4, gridBagConstraints91);
1084: jPanel2.add(durmin, gridBagConstraints8);
1085:
1086: jPanel3.add(getRemBox(), gridBagConstraints18);
1087: jPanel2.add(newdatefield, gridBagConstraints15);
1088:
1089: popupTimesLabel = new javax.swing.JLabel();
1090: popupTimesLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1091: popupTimesBtn = new javax.swing.JButton();
1092: ResourceHelper.setText(popupTimesBtn, "Change");
1093: popupTimesBtn
1094: .addActionListener(new java.awt.event.ActionListener() {
1095: public void actionPerformed(
1096: java.awt.event.ActionEvent evt) {
1097: popupbuttonActionPerformed(evt);
1098: }
1099: });
1100:
1101: jPanel5 = new javax.swing.JPanel();
1102: jPanel5.setBorder(new javax.swing.border.TitledBorder(Resource
1103: .getResourceString("popup_reminders")));
1104: jPanel5.add(popupTimesLabel);
1105: jPanel5.add(popupTimesBtn);
1106:
1107: GridBagConstraints gridBagConstraints87 = new java.awt.GridBagConstraints();
1108: gridBagConstraints87.gridx = 0;
1109: gridBagConstraints87.gridy = 4;
1110: gridBagConstraints87.fill = java.awt.GridBagConstraints.BOTH;
1111: gridBagConstraints87.weightx = 9.0;
1112: gridBagConstraints87.weighty = 1.0D;
1113: gridBagConstraints87.gridwidth = 2;
1114: gridBagConstraints87.insets = new java.awt.Insets(4, 4, 4, 4);
1115: this .add(jPanel5, gridBagConstraints87); // Generated
1116:
1117: gridBagConstraints87.gridx = 1;
1118: gridBagConstraints87.gridy = 5;
1119: gridBagConstraints87.gridwidth = 1;
1120: gridBagConstraints87.fill = java.awt.GridBagConstraints.BOTH;
1121: gridBagConstraints87.weightx = 0.0;
1122: gridBagConstraints87.insets = new java.awt.Insets(4, 4, 4, 4);
1123:
1124: attPanel = new LinkPanel();
1125: attPanel.setBorder(new javax.swing.border.TitledBorder(Resource
1126: .getResourceString("links")));
1127: this .add(attPanel, gridBagConstraints87);
1128:
1129: }// GEN-END:initComponents
1130:
1131: private void notecbActionPerformed(java.awt.event.ActionEvent evt)// GEN-FIRST:event_notecbActionPerformed
1132: {// GEN-HEADEREND:event_notecbActionPerformed
1133: if (notecb.isSelected()) {
1134: String mt = Prefs.getPref(PrefName.MILTIME);
1135: if (mt.equals("true")) {
1136: starthour.setSelectedIndex(0);
1137: } else {
1138: starthour.setSelectedIndex(11); // hour = 12
1139: }
1140: startmin.setSelectedIndex(0);
1141: durmin.setSelectedIndex(0);
1142: durhour.setSelectedIndex(0);
1143: startap.setSelected(false);
1144: startmin.setEnabled(false);
1145: starthour.setEnabled(false);
1146: durmin.setEnabled(false);
1147: durhour.setEnabled(false);
1148: startap.setEnabled(false);
1149: } else {
1150: startmin.setEnabled(true);
1151: starthour.setEnabled(true);
1152: durmin.setEnabled(true);
1153: durhour.setEnabled(true);
1154: startap.setEnabled(true);
1155: }
1156: }// GEN-LAST:event_notecbActionPerformed
1157:
1158: private void popupbuttonActionPerformed(
1159: java.awt.event.ActionEvent evt) {
1160:
1161: PopupOptionsView pv = new PopupOptionsView(custRemTimes, this );
1162: pv.setVisible(true);
1163: }
1164:
1165: private void savebuttonActionPerformed(
1166: java.awt.event.ActionEvent evt) {// GEN-FIRST:event_savebuttonActionPerformed
1167: if (key_ == -1) {
1168: add_appt();
1169: } else {
1170: chg_appt();
1171: }
1172:
1173: }// GEN-LAST:event_savebuttonActionPerformed
1174:
1175: private void saveDefaults(java.awt.event.ActionEvent evt)// GEN-FIRST:event_saveDefaults
1176: {// GEN-HEADEREND:event_saveDefaults
1177:
1178: Appointment r = new Appointment();
1179: try {
1180: setAppt(r, false);
1181: } catch (Exception e) {
1182: Errmsg.errmsg(e);
1183: return;
1184: }
1185:
1186: AppointmentXMLAdapter axa = new AppointmentXMLAdapter();
1187: XTree xt = axa.toXml(r);
1188: String s = xt.toString();
1189: Prefs.putPref(PrefName.DEFAULT_APPT, s);
1190:
1191: }// GEN-LAST:event_saveDefaults
1192:
1193: // fill in an appt from the user data
1194: // returns changed key if any
1195: private int setAppt(Appointment r, boolean validate)
1196: throws Warning, Exception {
1197:
1198: // get the hour and minute
1199: int hr = starthour.getSelectedIndex();
1200: String mt = Prefs.getPref(PrefName.MILTIME);
1201: if (mt.equals("false")) {
1202: hr = hr + 1;
1203: if (hr == 12)
1204: hr = 0;
1205: if (startap.isSelected())
1206: hr += 12;
1207: }
1208:
1209: if (notecb.isSelected())
1210: r.setUntimed("Y");
1211:
1212: Date nd = null;
1213: int newkey = 0;
1214: if (chgdate.isSelected()) {
1215: nd = newdatefield.getDate();
1216: }
1217:
1218: int min = startmin.getSelectedIndex() * 5;
1219: GregorianCalendar g = new GregorianCalendar();
1220:
1221: if (nd == null) {
1222: g.set(year_, month_, day_, hr, min, 0);
1223: } else {
1224: g.setTime(nd);
1225: g.set(Calendar.HOUR_OF_DAY, hr);
1226: g.set(Calendar.MINUTE, min);
1227: g.set(Calendar.SECOND, 0);
1228: newkey = AppointmentModel.dkey(g);
1229: }
1230:
1231: // set the appt date/time
1232: r.setDate(g.getTime());
1233:
1234: int du = (durhour.getSelectedIndex() * 60)
1235: + (durmin.getSelectedIndex() * 5);
1236: if (du != 0)
1237: r.setDuration(new Integer(du));
1238:
1239: // appointment text of some sort is required
1240: if (apptTitleField.getText().equals("") && validate) {
1241: apptTitleField.requestFocus();
1242: apptTitleField.setBackground(new Color(255, 255, 204));
1243: throw new Warning(
1244: Resource
1245: .getResourceString("Please_enter_some_appointment_text"));
1246: }
1247:
1248: // set text
1249: String t = apptTitleField.getText();
1250: if (appttextarea.getText() != null
1251: && !appttextarea.getText().equals(""))
1252: t += "\n" + appttextarea.getText();
1253: r.setText(t);
1254:
1255: // to do
1256: r.setTodo(todocb.isSelected());
1257:
1258: // vacation, half-day, and private checkboxes
1259: if (vacationcb.isSelected())
1260: r.setVacation(new Integer(1));
1261: if (halfdaycb.isSelected())
1262: r.setVacation(new Integer(2));
1263: if (holidaycb.isSelected())
1264: r.setHoliday(new Integer(1));
1265: if (alarmcb.isSelected())
1266: r.setAlarm("Y");
1267:
1268: r.setPrivate(privatecb.isSelected());
1269:
1270: // color
1271: r.setColor((String) colorbox.getSelectedItem());
1272:
1273: // repeat frequency
1274: if (freq.getSelectedIndex() != 0) {
1275: ArrayList daylist = new ArrayList();
1276: if (dl1.isSelected())
1277: daylist.add(new Integer(Calendar.SUNDAY));
1278: if (dl2.isSelected())
1279: daylist.add(new Integer(Calendar.MONDAY));
1280: if (dl3.isSelected())
1281: daylist.add(new Integer(Calendar.TUESDAY));
1282: if (dl4.isSelected())
1283: daylist.add(new Integer(Calendar.WEDNESDAY));
1284: if (dl5.isSelected())
1285: daylist.add(new Integer(Calendar.THURSDAY));
1286: if (dl6.isSelected())
1287: daylist.add(new Integer(Calendar.FRIDAY));
1288: if (dl7.isSelected())
1289: daylist.add(new Integer(Calendar.SATURDAY));
1290: if (!Repeat.isCompatible(g,
1291: (String) freq.getSelectedItem(), daylist)) {
1292: throw new Warning(Resource
1293: .getResourceString("recur_compat"));
1294: }
1295: r.setFrequency(Repeat.freqString((String) freq
1296: .getSelectedItem(), (Integer) ndays.getValue(),
1297: rptnumbox.isSelected(), daylist));
1298: }
1299:
1300: // repeat times
1301: Integer tm = null;
1302: if (foreverbox.isSelected()) {
1303: tm = new Integer(9999);
1304: } else {
1305: tm = (Integer) s_times.getValue();
1306: }
1307:
1308: if (tm.intValue() > 1 && freq.getSelectedIndex() != 0) {
1309: try {
1310: r.setTimes(tm);
1311:
1312: // set a boolean flag in SMDB if the appt repeats
1313: // this is very important for performance. When the model
1314: // first indexes the appts, it will only have to read and parse
1315: // the textual (non-boolean) data for repeating appointments
1316: // to calculate when the repeats fall. For non-repeating appts
1317: // the boolean will not be set and the model knows the appt can
1318: // be indexed
1319: // on a single day - without needing to read the DB text.
1320: if (tm.intValue() > 1)
1321: r.setRepeatFlag(true);
1322: else
1323: r.setRepeatFlag(false);
1324: } catch (Exception e) {
1325: throw new Exception(Resource
1326: .getResourceString("Could_not_parse_times:_")
1327: + tm);
1328: }
1329:
1330: } else {
1331: r.setTimes(new Integer(1));
1332: }
1333:
1334: String cat = (String) catbox.getSelectedItem();
1335: if (cat.equals("") || cat.equals(CategoryModel.UNCATEGORIZED)) {
1336: r.setCategory(null);
1337: } else {
1338: r.setCategory(cat);
1339: }
1340:
1341: r.setReminderTimes(new String(custRemTimes));
1342:
1343: return (newkey);
1344: }
1345:
1346: private void setCustRemTimes(Appointment r) {
1347: if (r == null) {
1348: custRemTimes = new char[ReminderTimes.getNum()];
1349: for (int i = 0; i < ReminderTimes.getNum(); ++i) {
1350: custRemTimes[i] = 'N';
1351: }
1352: } else {
1353:
1354: try {
1355: custRemTimes = (r.getReminderTimes()).toCharArray();
1356:
1357: } catch (Exception e) {
1358: for (int i = 0; i < ReminderTimes.getNum(); ++i) {
1359: custRemTimes[i] = 'N';
1360: }
1361: }
1362: }
1363: }
1364:
1365: public void setDate(int year, int month, int day) {
1366: year_ = year;
1367: month_ = month;
1368: day_ = day;
1369:
1370: }
1371:
1372: // display a summary of the times selected for popup reminders
1373: public void setPopupTimesString() {
1374: StringBuffer time1 = new StringBuffer(
1375: ReminderTimes.getNum() * 5 + 15);
1376: StringBuffer time2 = new StringBuffer(
1377: ReminderTimes.getNum() * 5 + 15);
1378: if (custRemTimes != null) {
1379: int i = 0;
1380: while (ReminderTimes.getTimes(i) < 0
1381: && i < ReminderTimes.getNum()) {
1382: if (custRemTimes[i] == 'Y') {
1383: int abs = -ReminderTimes.getTimes(i);
1384: if (time1.length() > 0) {
1385: time1 = time1.append(", ").append(abs);
1386: } else {
1387: time1 = time1.append(abs);
1388: }
1389: }
1390: ++i;
1391: }
1392: if (time1.length() > 0) {
1393: time1 = time1.append(" ").append(
1394: Resource.getResourceString("min_aft_app"));
1395: }
1396:
1397: while (i < ReminderTimes.getNum()) {
1398: if (custRemTimes[i] == 'Y') {
1399: if (time2.length() > 0) {
1400: time2 = time2.append(", ").append(
1401: ReminderTimes.getTimes(i));
1402: } else {
1403: time2 = time2.append(ReminderTimes.getTimes(i));
1404: }
1405: }
1406: ++i;
1407: }
1408: if (time2.length() > 0) {
1409: time2 = time2.append(" ").append(
1410: Resource.getResourceString("min_bef_app"));
1411: }
1412:
1413: }
1414: popupTimesLabel.setText("<html><p align=RIGHT>"
1415: + time1.toString() + "<br>" + time2.toString());
1416: }
1417:
1418: // set the view to a single appt (or a new blank)
1419: public void showapp(int key, Appointment defaultAppt) {
1420: key_ = key;
1421: String mt = Prefs.getPref(PrefName.MILTIME);
1422:
1423: startap.setSelected(false);
1424: startmin.setEnabled(false);
1425: starthour.setEnabled(false);
1426: durmin.setEnabled(false);
1427: durhour.setEnabled(false);
1428: startap.setEnabled(false);
1429: notecb.setSelected(true);
1430: chgdate.setSelected(false);
1431: dl1.setSelected(false);
1432: dl2.setSelected(false);
1433: dl3.setSelected(false);
1434: dl4.setSelected(false);
1435: dl5.setSelected(false);
1436: dl6.setSelected(false);
1437: dl7.setSelected(false);
1438:
1439: // get default appt values, if any
1440: String defApptXml = Prefs.getPref(PrefName.DEFAULT_APPT);
1441: if (defaultAppt == null && !defApptXml.equals("")) {
1442: try {
1443: XTree xt = XTree.readFromBuffer(defApptXml);
1444: AppointmentXMLAdapter axa = new AppointmentXMLAdapter();
1445: defaultAppt = (Appointment) axa.fromXml(xt);
1446: } catch (Exception e) {
1447: Errmsg.errmsg(e);
1448: }
1449: }
1450:
1451: // a key of -1 means to show a new blank appointment
1452: if (key_ == -1 && defaultAppt == null) {
1453:
1454: if (mt.equals("true")) {
1455: starthour.setSelectedIndex(0);
1456: } else {
1457: starthour.setSelectedIndex(11); // hour = 12
1458: }
1459:
1460: catbox.setSelectedIndex(0);
1461: startmin.setSelectedIndex(0);
1462: durmin.setSelectedIndex(0);
1463: durhour.setSelectedIndex(0);
1464:
1465: todocb.setSelected(false); // todo unchecked
1466: colorbox.setSelectedIndex(3); // color = black
1467: vacationcb.setSelected(false); // vacation unchecked
1468: halfdaycb.setSelected(false); // half-day unchecked
1469: holidaycb.setSelected(false); // holiday unchecked
1470: privatecb.setSelected(false); // private unchecked
1471: alarmcb.setSelected(false);
1472: appttextarea.setText(""); // clear appt text
1473: freq.setSelectedIndex(0); // freq = once
1474: s_times.setEnabled(true);
1475: s_times.setValue(new Integer(1)); // times = 1
1476: foreverbox.setSelected(false);
1477: rptnumbox.setSelected(false);
1478: rptnumbox.setEnabled(false);
1479: ResourceHelper.setText(jLabel2, "*****_NEW_APPT_*****");
1480:
1481: // only add menu choice active for a new appt
1482:
1483: chgdate.setEnabled(false);
1484: newdatefield.setEnabled(false);
1485:
1486: setCustRemTimes(null);
1487: setPopupTimesString();
1488:
1489: } else {
1490:
1491: try {
1492:
1493: // get the appt Appointment from the calmodel
1494: Appointment r = null;
1495: if (key_ == -1) {
1496: ResourceHelper.setText(jLabel2,
1497: "*****_NEW_APPT_*****");
1498: r = defaultAppt;
1499: attPanel.setOwner(null);
1500: } else {
1501: // erase New Appt indicator
1502: jLabel2.setText(" ");
1503: r = AppointmentModel.getReference().getAppt(key_);
1504: attPanel.setOwner(r);
1505: }
1506:
1507: // set hour and minute
1508: Date d = r.getDate();
1509: GregorianCalendar g = new GregorianCalendar();
1510: g.setTime(d);
1511: if (mt.equals("true")) {
1512: int hour = g.get(Calendar.HOUR_OF_DAY);
1513: if (hour != 0)
1514: starthour.setSelectedIndex(hour);
1515: } else {
1516: int hour = g.get(Calendar.HOUR);
1517: if (hour == 0)
1518: hour = 12;
1519: starthour.setSelectedIndex(hour - 1);
1520: }
1521:
1522: int min = g.get(Calendar.MINUTE);
1523: startmin.setSelectedIndex(min / 5);
1524:
1525: // duration
1526: Integer duration = r.getDuration();
1527: int dur = 0;
1528: if (duration != null)
1529: dur = duration.intValue();
1530: durhour.setSelectedIndex(dur / 60);
1531: durmin.setSelectedIndex((dur % 60) / 5);
1532:
1533: boolean note = AppointmentModel.isNote(r);
1534:
1535: // check if we just have a "note" (non-timed appt)
1536: if (!note) {
1537: notecb.setSelected(false);
1538: startmin.setEnabled(true);
1539: starthour.setEnabled(true);
1540: durmin.setEnabled(true);
1541: durhour.setEnabled(true);
1542: startap.setEnabled(true);
1543: }
1544:
1545: // set ToDo checkbox
1546: todocb.setSelected(r.getTodo());
1547:
1548: // set vacation checkbox
1549: vacationcb.setSelected(false);
1550: Integer ii = r.getVacation();
1551: if (ii != null && ii.intValue() == 1)
1552: vacationcb.setSelected(true);
1553:
1554: // set half-day checkbox
1555: halfdaycb.setSelected(false);
1556: if (ii != null && ii.intValue() == 2)
1557: halfdaycb.setSelected(true);
1558:
1559: // holiday checkbox
1560: holidaycb.setSelected(false);
1561: ii = r.getHoliday();
1562: if (ii != null && ii.intValue() == 1)
1563: holidaycb.setSelected(true);
1564:
1565: String alm = r.getAlarm();
1566: if (alm != null && alm.equals("Y")) {
1567: alarmcb.setSelected(true);
1568: } else {
1569: alarmcb.setSelected(false);
1570: }
1571:
1572: // private checkbox
1573: privatecb.setSelected(r.getPrivate());
1574:
1575: // PM checkbox
1576: boolean pm = true;
1577: if (g.get(Calendar.AM_PM) == Calendar.AM)
1578: pm = false;
1579: startap.setSelected(pm);
1580:
1581: // set appt text
1582: String t = r.getText();
1583: String subj = "";
1584: String det = "";
1585: if (t == null)
1586: t = "";
1587: int nli = t.indexOf('\n');
1588: if (nli != -1) {
1589: subj = t.substring(0, nli);
1590: det = t.substring(nli + 1);
1591: } else {
1592: subj = t;
1593: }
1594: appttextarea.setText(det);
1595: apptTitleField.setText(subj);
1596:
1597: // color
1598: String sel = r.getColor();
1599: if (sel != null) {
1600:
1601: if (sel.equals("black")) {
1602: colorbox.setSelectedIndex(3);
1603: } else if (sel.equals("red")) {
1604: colorbox.setSelectedIndex(0);
1605: } else if (sel.equals("blue")) {
1606: colorbox.setSelectedIndex(1);
1607: } else if (sel.equals("green")) {
1608: colorbox.setSelectedIndex(2);
1609: } else if (sel.equals("white")) {
1610: colorbox.setSelectedIndex(4);
1611: } else {
1612: colorbox.setSelectedIndex(5);
1613: }
1614:
1615: } else {
1616: colorbox.setSelectedIndex(3);
1617: }
1618:
1619: chgdate.setEnabled(true);
1620: newdatefield.setEnabled(false);
1621:
1622: // repeat frequency
1623: String rpt = Repeat.getFreq(r.getFrequency());
1624:
1625: if (rpt != null && rpt.equals(Repeat.NDAYS)) {
1626: ndays.setValue(new Integer(Repeat.getNDays(r
1627: .getFrequency())));
1628: }
1629:
1630: if (rpt != null && rpt.equals(Repeat.DAYLIST)) {
1631: Collection daylist = Repeat.getDaylist(r
1632: .getFrequency());
1633: if (daylist != null) {
1634: if (daylist.contains(new Integer(
1635: Calendar.SUNDAY)))
1636: dl1.setSelected(true);
1637: if (daylist.contains(new Integer(
1638: Calendar.MONDAY)))
1639: dl2.setSelected(true);
1640: if (daylist.contains(new Integer(
1641: Calendar.TUESDAY)))
1642: dl3.setSelected(true);
1643: if (daylist.contains(new Integer(
1644: Calendar.WEDNESDAY)))
1645: dl4.setSelected(true);
1646: if (daylist.contains(new Integer(
1647: Calendar.THURSDAY)))
1648: dl5.setSelected(true);
1649: if (daylist.contains(new Integer(
1650: Calendar.FRIDAY)))
1651: dl6.setSelected(true);
1652: if (daylist.contains(new Integer(
1653: Calendar.SATURDAY)))
1654: dl7.setSelected(true);
1655: }
1656: }
1657:
1658: rptnumbox.setSelected(Repeat
1659: .getRptNum(r.getFrequency()));
1660:
1661: freq.setSelectedItem(Repeat.getFreqString(rpt));
1662:
1663: // repeat times
1664: Integer tm = r.getTimes();
1665: if (tm != null) {
1666: if (tm.intValue() == 9999) {
1667: foreverbox.setSelected(true);
1668: s_times.setValue(new Integer(0));
1669: s_times.setEnabled(false);
1670: } else {
1671: s_times.setEnabled(true);
1672: s_times.setValue(tm);
1673: foreverbox.setSelected(false);
1674: }
1675:
1676: } else {
1677: s_times.setEnabled(true);
1678: s_times.setValue(new Integer(1));
1679: foreverbox.setSelected(false);
1680: }
1681:
1682: String cat = r.getCategory();
1683: if (cat != null && !cat.equals("")) {
1684: catbox.setSelectedItem(cat);
1685: } else {
1686: catbox.setSelectedIndex(0);
1687: }
1688:
1689: // set custRemTimes
1690: setCustRemTimes(r);
1691: setPopupTimesString();
1692:
1693: } catch (Exception e) {
1694: Errmsg.errmsg(e);
1695: Exception ne = new Exception(Resource
1696: .getResourceString("appt_error"));
1697: Errmsg.errmsg(ne);
1698:
1699: }
1700: }
1701:
1702: timesEnable();
1703: apptTitleField.setBackground(new Color(255, 255, 255));
1704: apptTitleField.requestFocus();
1705:
1706: }
1707:
1708: // set the visibility and enabling of components that depend on the
1709: // frequency pulldown
1710: private void timesEnable() {
1711: if (freq.getSelectedIndex() == 0) {
1712: s_times.setEnabled(false);
1713: foreverbox.setEnabled(false);
1714: rptnumbox.setEnabled(false);
1715: } else {
1716: s_times.setEnabled(true);
1717: foreverbox.setEnabled(true);
1718: rptnumbox.setEnabled(true);
1719: }
1720:
1721: if (Repeat.freqToEnglish((String) freq.getSelectedItem())
1722: .equals(Repeat.NDAYS)) {
1723: ndays.setVisible(true);
1724: dlistbuttonpanel.setVisible(false);
1725: } else if (Repeat
1726: .freqToEnglish((String) freq.getSelectedItem()).equals(
1727: Repeat.DAYLIST)) {
1728: dlistbuttonpanel.setVisible(true);
1729: ndays.setVisible(false);
1730: } else {
1731: dlistbuttonpanel.setVisible(false);
1732: ndays.setVisible(false);
1733: }
1734: }
1735: } // @jve:decl-index=0:visual-constraint="10,10"
|