001: /*
002: This file is part of BORG.
003:
004: BORG is free software; you can redistribute it and/or modify
005: it under the terms of the GNU General Public License as published by
006: the Free Software Foundation; either version 2 of the License, or
007: (at your option) any later version.
008:
009: BORG is distributed in the hope that it will be useful,
010: but WITHOUT ANY WARRANTY; without even the implied warranty of
011: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: GNU General Public License for more details.
013:
014: You should have received a copy of the GNU General Public License
015: along with BORG; if not, write to the Free Software
016: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017:
018: Copyright 2003 by Mike Berger
019: */
020:
021: package net.sf.borg.ui.popup;
022:
023: import java.awt.GridBagConstraints;
024: import java.awt.GridBagLayout;
025:
026: import javax.swing.JButton;
027: import javax.swing.JLabel;
028: import javax.swing.JPanel;
029: import javax.swing.JRadioButton;
030: import javax.swing.WindowConstants;
031:
032: import net.sf.borg.common.Resource;
033: import net.sf.borg.model.ReminderTimes;
034: import net.sf.borg.ui.ResourceHelper;
035: import net.sf.borg.ui.View;
036:
037: public class ReminderPopup extends View {
038: private JPanel jPanel = null;
039: private JLabel jLabel1 = null;
040: private JLabel jLabel2 = null;
041: private JRadioButton noMoreButton = null;
042: private JPanel jPanel1 = null;
043: private JButton jButton = null;
044: private char[] remindersShown;
045: private boolean shown_ = false;
046:
047: public void setShown(boolean s) {
048: shown_ = s;
049: }
050:
051: public boolean wasShown() {
052: return shown_;
053: }
054:
055: /**
056: * This method initializes this
057: *
058: * @return void
059: */
060: private void jbInit() {
061: this .setContentPane(getJPanel());
062: this .setCursor(new java.awt.Cursor(
063: java.awt.Cursor.DEFAULT_CURSOR));
064: this .setSize(400, 250);
065:
066: }
067:
068: /**
069: * This method initializes jPanel
070: *
071: * @return javax.swing.JPanel
072: */
073: private JPanel getJPanel() {
074: if (jPanel == null) {
075: jLabel1 = new JLabel();
076: jLabel2 = new JLabel();
077: GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
078: GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
079: GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
080: GridBagConstraints gridBagConstraints15 = new GridBagConstraints();
081: jPanel = new JPanel();
082: jPanel.setLayout(new GridBagLayout());
083: gridBagConstraints9.gridx = 0;
084: gridBagConstraints9.weightx = 1.0D; // Generated
085: gridBagConstraints9.gridy = 1;
086: gridBagConstraints9.ipadx = 100;
087: gridBagConstraints9.ipady = 5;
088: gridBagConstraints9.insets = new java.awt.Insets(5, 0, 5, 0);
089: gridBagConstraints10.gridx = 0;
090: gridBagConstraints10.weightx = 1.0D; // Generated
091: gridBagConstraints10.gridy = 3;
092: gridBagConstraints10.ipadx = 100;
093: gridBagConstraints10.ipady = 0;
094: gridBagConstraints10.insets = new java.awt.Insets(5, 0, 5,
095: 0);
096: gridBagConstraints11.gridx = 0;
097: gridBagConstraints11.weightx = 1.0D; // Generated
098: gridBagConstraints11.gridy = 2;
099: gridBagConstraints11.ipadx = 100;
100: gridBagConstraints11.ipady = 5;
101: gridBagConstraints11.insets = new java.awt.Insets(5, 0, 5,
102: 0);
103: gridBagConstraints15.gridx = 0;
104: gridBagConstraints15.gridy = 4;
105: jPanel.add(jLabel1, gridBagConstraints9); // Generated
106: jPanel.add(jLabel2, gridBagConstraints11); // Generated
107: jPanel.add(getNoMoreButton(), gridBagConstraints10); // Generated
108: jPanel.add(getJPanel1(), gridBagConstraints15);
109: jLabel1.setText("");
110: jLabel1
111: .setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
112: jLabel2.setText("");
113: jLabel2
114: .setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
115: }
116: return jPanel;
117: }
118:
119: /**
120: * This method initializes jRadioButton
121: *
122: * @return javax.swing.JRadioButton
123: */
124: private JRadioButton getNoMoreButton() {
125: if (noMoreButton == null) {
126: noMoreButton = new JRadioButton();
127: ResourceHelper.setText(noMoreButton, "No_more");
128: noMoreButton
129: .setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
130: }
131: return noMoreButton;
132: }
133:
134: /**
135: * This method initializes jPanel1
136: *
137: * @return javax.swing.JPanel
138: */
139: private JPanel getJPanel1() {
140: if (jPanel1 == null) {
141: jPanel1 = new JPanel();
142: jPanel1.setLayout(new GridBagLayout());
143: jPanel1.add(getJButton(), new GridBagConstraints());
144: }
145: return jPanel1;
146: }
147:
148: /**
149: * This method initializes jButton
150: *
151: * @return javax.swing.JButton
152: */
153: private JButton getJButton() {
154: if (jButton == null) {
155: jButton = new JButton();
156: ResourceHelper.setText(jButton, "OK");
157: jButton.setActionCommand("close_it");
158: jButton
159: .addActionListener(new java.awt.event.ActionListener() {
160: public void actionPerformed(
161: java.awt.event.ActionEvent e) {
162: closeit();
163: }
164: });
165: }
166: return jButton;
167: }
168:
169: public ReminderPopup() {
170: super ();
171: this .setTitle("Borg " + Resource.getResourceString("Reminder"));
172: jbInit();
173: this .setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
174: remindersShown = new char[ReminderTimes.getNum()];
175: for (int i = 0; i < ReminderTimes.getNum(); ++i) {
176: remindersShown[i] = 'N';
177: }
178:
179: }
180:
181: public void setText(String str) {
182: jLabel1.setText(str);
183: }
184:
185: public void setText2(String str) {
186: jLabel2.setText(str);
187: }
188:
189: /**
190: * Return Y if Reminder request i has been shown, otherwise N
191: */
192: public char reminderShown(int i) {
193: return remindersShown[i];
194: }
195:
196: /**
197: * Save the fact that Reminder request i has been shown
198: * and shouldnt be shown again
199: */
200: public void setReminderShown(int i) {
201: remindersShown[i] = 'Y';
202: }
203:
204: private void closeit() {
205: if (noMoreButton.isSelected()) {
206: this .dispose();
207: } else {
208: this .setVisible(false);
209: }
210: }
211:
212: public void destroy() {
213: this .dispose();
214: }
215:
216: public void refresh() {
217: }
218:
219: // $protect<<$
220: } // @jve:decl-index=0:visual-constraint="10,10"
|