package caltool.view_ui; import caltool.schedule.*; import caltool.schedule_ui.*; import caltool.caltool_ui.*; import mvp.*; import java.util.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; /**** * * Class AppointmentEditor specializes ScheduleAppointmentDialog to provide * editing access to scheduled appointments. An appointment editor has the * same data fields as the scheduling dialog. The editor display differs from * the scheduling dialog as follows: *
* This particular layout is accomplished with an outer JPanel with an * overlay layout, containing two hboxes with left- and center-alignments. * This allows two different horizontal layouts to appear in the same * horizontal row of the display. */ protected JPanel composeDateSummary() { JPanel outer = new JPanel(); outer.setLayout(new OverlayLayout(outer)); outer.setBorder(BorderFactory.createLineBorder(Color.black)); Box hbox1 = Box.createHorizontalBox(); Box hbox2 = Box.createHorizontalBox(); outer.add(hbox1); outer.add(hbox2); return outer; } /** * Compose the buttons row with three JButtons, a la the parent version of * this method, q.v. */ protected Box composeButtonRow() { Box hbox = Box.createHorizontalBox(); /* * Construct the three buttons. */ JButton changeButton = new JButton("Change"); JButton deleteButton = new JButton("Delete"); JButton clearButton = new JButton("Clear"); /* * Attach the appropriate action listeners to each button. */ changeButton.addActionListener( new ChangeAppointmentButtonListener((Schedule) model, this)); deleteButton.addActionListener( new DeleteAppointmentButtonListener((Schedule) model, this)); clearButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { clear(); } } ); /* * Add them to the hbox and return it. */ hbox.add(changeButton); hbox.add(Box.createHorizontalStrut(30)); hbox.add(deleteButton); hbox.add(Box.createHorizontalStrut(30)); hbox.add(clearButton); return hbox; } /** * Display the model data for the currently selected appointment. This * method is only invoked if the current selected item is in fact an * appointment. The appointment is sent in the second arg. See the ItemEditor for the details of how this * method is invoked. */ public void update(Observable o, Object arg) { Appointment appt = (Appointment) arg; titleTextField.setText(appt.getTitle()); startDateTextField.setText(appt.getDate().toString()); if (appt.getEndDate() != null) { endDateTextField.setText(appt.getEndDate().toString()); } else { endDateTextField.setText(""); } startTimeTextField.setText(appt.getStartTime().toString()); durationTextField.setText(appt.getDuration().toString()); recurringInfo.update(null, appt.getRecurringInfo()); categoryComboBox.setSelectedItem(appt.getCategory().toString()); locationComboBox.setSelectedItem(appt.getCategory().toString()); securityComboBox.setSelectedIndex(appt.getSecurity().ordinal()); priorityComboBox.setSelectedIndex(appt.getPriority().ordinal()); remindInfo.update(null, appt.getRemindInfo()); detailsTextArea.setText(appt.getDetails()); } }