Update of /cvsroot/genj/dev/src/core/genj/util/swing
In directory sc8-pr-cvs1:/tmp/cvs-serv25527/src/core/genj/util/swing
Modified Files:
ProgressWidget.java ButtonHelper.java MenuHelper.java
Log Message:
simplified ActionDelegate (now implements Runnable, ActionListener)
Index: ProgressWidget.java
===================================================================
RCS file: /cvsroot/genj/dev/src/core/genj/util/swing/ProgressWidget.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ProgressWidget.java 11 May 2003 08:10:55 -0000 1.1
--- ProgressWidget.java 19 Jun 2003 18:21:35 -0000 1.2
***************
*** 54,62 ****
private JLabel state;
- /** a callback we use */
- private Callback callback = new Callback();
-
/** timer */
! private Timer timer = new Timer(100, callback);
/**
--- 54,59 ----
private JLabel state;
/** timer */
! private Timer timer;
/**
***************
*** 84,88 ****
// .. cancel
gh.setParameter(0)
! .add(new ButtonHelper().create(callback), 0, 2);
// done
--- 81,99 ----
// .. cancel
gh.setParameter(0)
! .add(new ButtonHelper().create(new Cancel()), 0, 2);
!
! // prepare timer
! timer = new Timer(100, new ActionListener() {
! public void actionPerformed(ActionEvent e) {
! // update progress bar
! progress.setValue(trackable.getProgress());
! // update state
! state.setText(trackable.getState());
! // still going?
! if (!worker.isAlive())
! timer.stop();
! // done for now
! }
! });
// done
***************
*** 113,123 ****
/**
! * Callback
*/
! private class Callback extends ActionDelegate implements ActionListener {
/**
* Constructor
*/
! private Callback() {
setText(OPTION_CANCEL);
}
--- 124,134 ----
/**
! * Cancel
*/
! private class Cancel extends ActionDelegate {
/**
* Constructor
*/
! private Cancel() {
setText(OPTION_CANCEL);
}
***************
*** 128,149 ****
trackable.cancel();
}
! /**
! * on timer
! */
! public void actionPerformed(ActionEvent ae) {
!
! // update progress bar
! progress.setValue(trackable.getProgress());
!
! // update state
! state.setText(trackable.getState());
!
! // still going?
! if (!worker.isAlive())
! timer.stop();
!
! // done for now
! }
! } //Callback
} //ProgressWidget
--- 139,143 ----
trackable.cancel();
}
! } //Cancel
} //ProgressWidget
Index: ButtonHelper.java
===================================================================
RCS file: /cvsroot/genj/dev/src/core/genj/util/swing/ButtonHelper.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** ButtonHelper.java 21 May 2003 17:19:38 -0000 1.28
--- ButtonHelper.java 19 Jun 2003 18:21:35 -0000 1.29
***************
*** 27,31 ****
import java.awt.Font;
import java.awt.Insets;
- import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collection;
--- 27,30 ----
***************
*** 157,161 ****
// listening
! result.addActionListener((ActionListener)action.as(ActionListener.class));
// context
--- 156,160 ----
// listening
! result.addActionListener(action);
// context
Index: MenuHelper.java
===================================================================
RCS file: /cvsroot/genj/dev/src/core/genj/util/swing/MenuHelper.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** MenuHelper.java 23 May 2003 00:26:27 -0000 1.20
--- MenuHelper.java 19 Jun 2003 18:21:35 -0000 1.21
***************
*** 22,25 ****
--- 22,26 ----
import genj.util.ActionDelegate;
import genj.util.Resources;
+
import java.awt.Component;
import java.awt.Font;
***************
*** 39,43 ****
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
- import javax.swing.event.PopupMenuListener;
/**
--- 40,43 ----
***************
*** 100,113 ****
/**
- * Creates a menu with an action fired on open
- */
- public JMenu createMenu(ActionDelegate action) {
- JMenu result = createMenu(action.txt, action.img);
- result.getPopupMenu().addPopupMenuListener((PopupMenuListener)action.as(PopupMenuListener.class));
- action.setTarget(result);
- return result;
- }
-
- /**
* Creates a PopupMenu
*/
--- 100,103 ----
***************
*** 204,208 ****
// create a menu item
JMenuItem result = new JMenuItem();
! result.addActionListener((ActionListener)action.as(ActionListener.class));
if (action.txt!=null) result.setText(string(action.txt));
if (action.img!=null) result.setIcon(action.img);
--- 194,198 ----
// create a menu item
JMenuItem result = new JMenuItem();
! result.addActionListener(action);
if (action.txt!=null) result.setText(string(action.txt));
if (action.img!=null) result.setIcon(action.img);
|