home *** CD-ROM | disk | FTP | other *** search
Wrap
package reminderplugin; import devplugin.Date; import devplugin.Program; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dialog; import java.awt.Image; import java.awt.Window; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.Timer; import util.io.IOUtilities; import util.ui.Localizer; import util.ui.ProgramPanel; import util.ui.UiUtilities; public class ReminderFrame { private static final Localizer mLocalizer; public static final String[] REMIND_MSG_ARR; public static final int[] REMIND_VALUE_ARR; private JFrame mFrame; private JDialog mDialog; private ReminderList mReminderList; private Program mProgram; private JComboBox mReminderCB; private JButton mCloseBt; private String mCloseBtText; private Timer mAutoCloseTimer; private int mRemainingSecs; // $FF: synthetic field static Class class$reminderplugin$ReminderFrame; public ReminderFrame(Component comp, ReminderList list, ReminderListItem item, int autoCloseSecs, Image iconImage) { Window parent = UiUtilities.getBestDialogParent(comp); String title = mLocalizer.msg("title", "Reminder"); if (parent instanceof Dialog) { this.mDialog = new JDialog((Dialog)parent, title); } else { this.mFrame = new JFrame(title); this.mFrame.setIconImage(iconImage); } this.mReminderList = list; list.remove(item); this.mProgram = item.getProgram(); JPanel jcontentPane = new JPanel(new BorderLayout(0, 10)); if (this.mDialog != null) { this.mDialog.setContentPane(jcontentPane); } else { this.mFrame.setContentPane(jcontentPane); } jcontentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); JPanel progPanel = new JPanel(new BorderLayout(5, 10)); int progMinutesAfterMidnight = this.mProgram.getHours() * 60 + this.mProgram.getMinutes(); Date today = Date.getCurrentDate(); String msg; if (today.compareTo(this.mProgram.getDate()) >= 0 && IOUtilities.getMinutesAfterMidnight() > progMinutesAfterMidnight) { msg = mLocalizer.msg("alreadyRunning", "Already running"); } else { msg = mLocalizer.msg("soonStarts", "Soon starts"); } progPanel.add(new JLabel(msg), "North"); JLabel channelLabel = new JLabel(this.mProgram.getChannel().getName()); progPanel.add(channelLabel, "East"); ProgramPanel panel = new ProgramPanel(this.mProgram); panel.addPluginContextMenuMouseListener(ReminderPlugin.getInstance()); progPanel.add(panel, "Center"); JPanel btnPanel = new JPanel(new BorderLayout(10, 0)); this.mCloseBtText = mLocalizer.msg("close", "Close"); this.mCloseBt = new JButton(this.mCloseBtText); if (this.mDialog != null) { this.mDialog.getRootPane().setDefaultButton(this.mCloseBt); } else { this.mFrame.getRootPane().setDefaultButton(this.mCloseBt); } this.mReminderCB = new JComboBox(); for(int i = 0; i < REMIND_VALUE_ARR.length && REMIND_VALUE_ARR[i] < item.getReminderMinutes(); ++i) { this.mReminderCB.addItem(REMIND_MSG_ARR[i]); } btnPanel.add(this.mReminderCB, "West"); btnPanel.add(this.mCloseBt, "East"); jcontentPane.add(progPanel, "North"); jcontentPane.add(btnPanel, "South"); this.mCloseBt.addActionListener(new 1(this)); this.mRemainingSecs = autoCloseSecs; if (this.mRemainingSecs > 0) { this.updateCloseBtText(); this.mAutoCloseTimer = new Timer(1000, new 2(this)); this.mAutoCloseTimer.start(); } this.getWindow().pack(); UiUtilities.centerAndShow(this.getWindow()); } private Window getWindow() { return (Window)(this.mDialog != null ? this.mDialog : this.mFrame); } private void handleTimerEvent() { --this.mRemainingSecs; if (this.mRemainingSecs == 0) { this.close(); } else { this.updateCloseBtText(); } } private void updateCloseBtText() { this.mCloseBt.setText(this.mCloseBtText + " (" + this.mRemainingSecs + ")"); } private void close() { int inx = this.mReminderCB.getSelectedIndex(); int minutes = REMIND_VALUE_ARR[inx]; if (minutes != -1) { this.mReminderList.add(this.mProgram, minutes); } if (this.mAutoCloseTimer != null) { this.mAutoCloseTimer.stop(); } this.getWindow().dispose(); } // $FF: synthetic method static Class class$(String x0) { try { return Class.forName(x0); } catch (ClassNotFoundException x1) { throw new NoClassDefFoundError(x1.getMessage()); } } // $FF: synthetic method static void access$000(ReminderFrame x0) { x0.close(); } // $FF: synthetic method static void access$100(ReminderFrame x0) { x0.handleTimerEvent(); } static { mLocalizer = Localizer.getLocalizerFor(class$reminderplugin$ReminderFrame == null ? (class$reminderplugin$ReminderFrame = class$("reminderplugin.ReminderFrame")) : class$reminderplugin$ReminderFrame); REMIND_MSG_ARR = new String[]{mLocalizer.msg("remind.-1", "Don't remind me"), mLocalizer.msg("remind.0", "Remind me when the program begins"), mLocalizer.msg("remind.1", "Remind me one minute before"), mLocalizer.msg("remind.2", "Remind me 2 minutes before"), mLocalizer.msg("remind.3", "Remind me 3 minutes before"), mLocalizer.msg("remind.5", "Remind me 5 minutes before"), mLocalizer.msg("remind.10", "Remind me 10 minutes before"), mLocalizer.msg("remind.15", "Remind me 15 minutes before"), mLocalizer.msg("remind.30", "Remind me 30 minutes before"), mLocalizer.msg("remind.60", "Remind me one hour before"), mLocalizer.msg("remind.90", "Remind me 1.5 hours before"), mLocalizer.msg("remind.120", "Remind me 2 hours before"), mLocalizer.msg("remind.240", "Remind me 4 hours before"), mLocalizer.msg("remind.480", "Remind me 8 hours before"), mLocalizer.msg("remind.1440", "Remind me one day before")}; REMIND_VALUE_ARR = new int[]{-1, 0, 1, 2, 3, 5, 10, 15, 30, 60, 90, 120, 240, 480, 1440}; } }