From: gmungoc Date: Fri, 29 May 2015 11:01:09 +0000 (+0100) Subject: JAL-1753 duplicated code refactored to new class ProgressBar X-Git-Tag: Release_2_10_0~650^2~4 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=bd318fe40b8d07db486f47d788dcdc2df8cb9e9c;p=jalview.git JAL-1753 duplicated code refactored to new class ProgressBar --- diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 9d56224..c659233 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -20,6 +20,52 @@ */ package jalview.gui; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.dnd.DropTargetEvent; +import java.awt.dnd.DropTargetListener; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.print.PageFormat; +import java.awt.print.PrinterJob; +import java.beans.PropertyChangeEvent; +import java.io.File; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Deque; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.List; +import java.util.Set; +import java.util.Vector; + +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JEditorPane; +import javax.swing.JInternalFrame; +import javax.swing.JLayeredPane; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JRadioButtonMenuItem; +import javax.swing.JScrollPane; +import javax.swing.SwingUtilities; + import jalview.analysis.AAFrequency; import jalview.analysis.AlignmentSorter; import jalview.analysis.AlignmentUtils; @@ -97,57 +143,6 @@ import jalview.ws.jws2.Jws2Discoverer; import jalview.ws.jws2.jabaws2.Jws2Instance; import jalview.ws.seqfetcher.DbSourceProxy; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.GridLayout; -import java.awt.Rectangle; -import java.awt.Toolkit; -import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.StringSelection; -import java.awt.datatransfer.Transferable; -import java.awt.dnd.DnDConstants; -import java.awt.dnd.DropTargetDragEvent; -import java.awt.dnd.DropTargetDropEvent; -import java.awt.dnd.DropTargetEvent; -import java.awt.dnd.DropTargetListener; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.print.PageFormat; -import java.awt.print.PrinterJob; -import java.beans.PropertyChangeEvent; -import java.io.File; -import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Deque; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.List; -import java.util.Set; -import java.util.Vector; - -import javax.swing.JButton; -import javax.swing.JCheckBoxMenuItem; -import javax.swing.JEditorPane; -import javax.swing.JInternalFrame; -import javax.swing.JLabel; -import javax.swing.JLayeredPane; -import javax.swing.JMenu; -import javax.swing.JMenuItem; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JProgressBar; -import javax.swing.JRadioButtonMenuItem; -import javax.swing.JScrollPane; -import javax.swing.SwingUtilities; - /** * DOCUMENT ME! * @@ -315,6 +310,8 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, */ void init() { + progressBar = new ProgressBar(this.statusPanel, this.statusBar); + avc = new jalview.controller.AlignViewController(this, viewport, alignPanel); if (viewport.getAlignmentConservationAnnotation() == null) @@ -875,7 +872,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, // methods for implementing IProgressIndicator // need to refactor to a reusable stub class - Hashtable progressBars, progressBarHandlers; + // Map progressBars; + // + // Map progressBarHandlers; + private ProgressBar progressBar; /* * (non-Javadoc) @@ -885,78 +885,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public void setProgressBar(String message, long id) { - if (progressBars == null) - { - progressBars = new Hashtable(); - progressBarHandlers = new Hashtable(); - } - - JPanel progressPanel; - Long lId = new Long(id); - GridLayout layout = (GridLayout) statusPanel.getLayout(); - if (progressBars.get(lId) != null) - { - progressPanel = (JPanel) progressBars.get(new Long(id)); - statusPanel.remove(progressPanel); - progressBars.remove(lId); - progressPanel = null; - if (message != null) - { - statusBar.setText(message); - } - if (progressBarHandlers.contains(lId)) - { - progressBarHandlers.remove(lId); - } - layout.setRows(layout.getRows() - 1); - } - else - { - progressPanel = new JPanel(new BorderLayout(10, 5)); - - JProgressBar progressBar = new JProgressBar(); - progressBar.setIndeterminate(true); - - progressPanel.add(new JLabel(message), BorderLayout.WEST); - progressPanel.add(progressBar, BorderLayout.CENTER); - - layout.setRows(layout.getRows() + 1); - statusPanel.add(progressPanel); - - progressBars.put(lId, progressPanel); - } - // update GUI - // setMenusForViewport(); - validate(); + progressBar.setProgressBar(message, id); } @Override public void registerHandler(final long id, final IProgressIndicatorHandler handler) { - if (progressBarHandlers == null || !progressBars.contains(new Long(id))) - { - throw new Error(MessageManager.getString("error.call_setprogressbar_before_registering_handler")); - } - progressBarHandlers.put(new Long(id), handler); - final JPanel progressPanel = (JPanel) progressBars.get(new Long(id)); - if (handler.canCancel()) - { - JButton cancel = new JButton( - MessageManager.getString("action.cancel")); - final IProgressIndicator us = this; - cancel.addActionListener(new ActionListener() - { - - @Override - public void actionPerformed(ActionEvent e) - { - handler.cancelActivity(id); - us.setProgressBar(MessageManager.formatMessage("label.cancelled_params", new Object[]{((JLabel) progressPanel.getComponent(0)).getText()}), id); - } - }); - progressPanel.add(cancel, BorderLayout.EAST); - } + progressBar.registerHandler(id, handler); } /** @@ -966,18 +902,14 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, @Override public boolean operationInProgress() { - if (progressBars != null && progressBars.size() > 0) - { - return true; - } - return false; + return progressBar.operationInProgress(); } @Override public void setStatus(String text) { statusBar.setText(text); - }; + } /* * Added so Castor Mapping file can obtain Jalview Version diff --git a/src/jalview/gui/PCAPanel.java b/src/jalview/gui/PCAPanel.java index 2674617..cff9104 100644 --- a/src/jalview/gui/PCAPanel.java +++ b/src/jalview/gui/PCAPanel.java @@ -20,40 +20,34 @@ */ package jalview.gui; -import jalview.datamodel.Alignment; -import jalview.datamodel.AlignmentView; -import jalview.datamodel.ColumnSelection; -import jalview.datamodel.SeqCigar; -import jalview.datamodel.SequenceI; -import jalview.jbgui.GPCAPanel; -import jalview.schemes.ResidueProperties; -import jalview.util.MessageManager; -import jalview.viewmodel.AlignmentViewport; -import jalview.viewmodel.PCAModel; - import java.awt.BorderLayout; import java.awt.Color; import java.awt.Graphics; -import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.print.PageFormat; import java.awt.print.Printable; import java.awt.print.PrinterException; import java.awt.print.PrinterJob; -import java.util.Hashtable; import javax.swing.ButtonGroup; -import javax.swing.JButton; import javax.swing.JCheckBoxMenuItem; import javax.swing.JColorChooser; -import javax.swing.JLabel; import javax.swing.JMenuItem; import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JProgressBar; import javax.swing.JRadioButtonMenuItem; +import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentView; +import jalview.datamodel.ColumnSelection; +import jalview.datamodel.SeqCigar; +import jalview.datamodel.SequenceI; +import jalview.jbgui.GPCAPanel; +import jalview.schemes.ResidueProperties; +import jalview.util.MessageManager; +import jalview.viewmodel.AlignmentViewport; +import jalview.viewmodel.PCAModel; + /** * DOCUMENT ME! * @@ -64,6 +58,8 @@ public class PCAPanel extends GPCAPanel implements Runnable, IProgressIndicator { + private ProgressBar progressBar; + RotatableCanvas rc; AlignmentPanel ap; @@ -87,6 +83,8 @@ public class PCAPanel extends GPCAPanel implements Runnable, this.av = ap.av; this.ap = ap; + progressBar = new ProgressBar(statusPanel, statusBar); + boolean sameLength = true; boolean selected = av.getSelectionGroup() != null && av.getSelectionGroup().getSize() > 0; @@ -632,11 +630,6 @@ public class PCAPanel extends GPCAPanel implements Runnable, cap.dispose(); } } - - // methods for implementing IProgressIndicator - // need to refactor to a reusable stub class - Hashtable progressBars, progressBarHandlers; - /* * (non-Javadoc) * @@ -645,78 +638,82 @@ public class PCAPanel extends GPCAPanel implements Runnable, @Override public void setProgressBar(String message, long id) { - if (progressBars == null) - { - progressBars = new Hashtable(); - progressBarHandlers = new Hashtable(); - } - - JPanel progressPanel; - Long lId = new Long(id); - GridLayout layout = (GridLayout) statusPanel.getLayout(); - if (progressBars.get(lId) != null) - { - progressPanel = (JPanel) progressBars.get(new Long(id)); - statusPanel.remove(progressPanel); - progressBars.remove(lId); - progressPanel = null; - if (message != null) - { - statusBar.setText(message); - } - if (progressBarHandlers.contains(lId)) - { - progressBarHandlers.remove(lId); - } - layout.setRows(layout.getRows() - 1); - } - else - { - progressPanel = new JPanel(new BorderLayout(10, 5)); - - JProgressBar progressBar = new JProgressBar(); - progressBar.setIndeterminate(true); - - progressPanel.add(new JLabel(message), BorderLayout.WEST); - progressPanel.add(progressBar, BorderLayout.CENTER); - - layout.setRows(layout.getRows() + 1); - statusPanel.add(progressPanel); - - progressBars.put(lId, progressPanel); - } - // update GUI - // setMenusForViewport(); - validate(); + progressBar.setProgressBar(message, id); + // if (progressBars == null) + // { + // progressBars = new Hashtable(); + // progressBarHandlers = new Hashtable(); + // } + // + // JPanel progressPanel; + // Long lId = new Long(id); + // GridLayout layout = (GridLayout) statusPanel.getLayout(); + // if (progressBars.get(lId) != null) + // { + // progressPanel = (JPanel) progressBars.get(new Long(id)); + // statusPanel.remove(progressPanel); + // progressBars.remove(lId); + // progressPanel = null; + // if (message != null) + // { + // statusBar.setText(message); + // } + // if (progressBarHandlers.contains(lId)) + // { + // progressBarHandlers.remove(lId); + // } + // layout.setRows(layout.getRows() - 1); + // } + // else + // { + // progressPanel = new JPanel(new BorderLayout(10, 5)); + // + // JProgressBar progressBar = new JProgressBar(); + // progressBar.setIndeterminate(true); + // + // progressPanel.add(new JLabel(message), BorderLayout.WEST); + // progressPanel.add(progressBar, BorderLayout.CENTER); + // + // layout.setRows(layout.getRows() + 1); + // statusPanel.add(progressPanel); + // + // progressBars.put(lId, progressPanel); + // } + // // update GUI + // // setMenusForViewport(); + // validate(); } @Override public void registerHandler(final long id, final IProgressIndicatorHandler handler) { - if (progressBarHandlers == null || !progressBars.contains(new Long(id))) - { - throw new Error(MessageManager.getString("error.call_setprogressbar_before_registering_handler")); - } - progressBarHandlers.put(new Long(id), handler); - final JPanel progressPanel = (JPanel) progressBars.get(new Long(id)); - if (handler.canCancel()) - { - JButton cancel = new JButton( - MessageManager.getString("action.cancel")); - final IProgressIndicator us = this; - cancel.addActionListener(new ActionListener() - { - - @Override - public void actionPerformed(ActionEvent e) - { - handler.cancelActivity(id); - us.setProgressBar(MessageManager.formatMessage("label.cancelled_params", new String[]{((JLabel) progressPanel.getComponent(0)).getText()}), id); - } - }); - progressPanel.add(cancel, BorderLayout.EAST); - } + progressBar.registerHandler(id, handler); + // if (progressBarHandlers == null || !progressBars.contains(new Long(id))) + // { + // throw new + // Error(MessageManager.getString("error.call_setprogressbar_before_registering_handler")); + // } + // progressBarHandlers.put(new Long(id), handler); + // final JPanel progressPanel = (JPanel) progressBars.get(new Long(id)); + // if (handler.canCancel()) + // { + // JButton cancel = new JButton( + // MessageManager.getString("action.cancel")); + // final IProgressIndicator us = this; + // cancel.addActionListener(new ActionListener() + // { + // + // @Override + // public void actionPerformed(ActionEvent e) + // { + // handler.cancelActivity(id); + // us.setProgressBar(MessageManager.formatMessage("label.cancelled_params", + // new String[]{((JLabel) progressPanel.getComponent(0)).getText()}), id); + // } + // }); + // progressPanel.add(cancel, BorderLayout.EAST); + // } } /** @@ -726,11 +723,7 @@ public class PCAPanel extends GPCAPanel implements Runnable, @Override public boolean operationInProgress() { - if (progressBars != null && progressBars.size() > 0) - { - return true; - } - return false; + return progressBar.operationInProgress(); } @Override diff --git a/src/jalview/gui/ProgressBar.java b/src/jalview/gui/ProgressBar.java new file mode 100644 index 0000000..8ebc98d --- /dev/null +++ b/src/jalview/gui/ProgressBar.java @@ -0,0 +1,229 @@ +package jalview.gui; + +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Hashtable; +import java.util.Map; + +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.SwingUtilities; + +import jalview.util.MessageManager; + +/** + * A class to manage multiple progress bars embedded in a JPanel. + */ +/* + * Refactored from code duplicated in AlignFrame, PCAPanel, WebserviceInfo. + */ +public class ProgressBar implements IProgressIndicator +{ + /* + * Progress bars in progress, keyed by any arbitrary long value + */ + Map progressBars; + + /* + * Optional handlers for the progress bars + */ + Map progressBarHandlers; + + /* + * The panel containing the progress bars - must have GridLayout + */ + private JPanel statusPanel; + + /* + * Optional label where a status update message can be written on completion + * of progress + */ + private JLabel statusBar; + + /** + * Constructor. Note that the container of the progress bars, and the status + * bar to which an optional completion message is written, should be unchanged + * for the lifetime of this object for consistent behaviour. + * + * @param container + * the panel holding the progress bars; must have GridLayout manager + * @param statusBar + * an optional place to write a message when a progress bar is + * removed + */ + public ProgressBar(JPanel container, JLabel statusBar) + { + if (container == null) + { + throw new NullPointerException(); + } + if (!GridLayout.class + .isAssignableFrom(container.getLayout().getClass())) + { + throw new IllegalArgumentException("Container must have GridLayout"); + } + this.statusPanel = container; + this.statusBar = statusBar; + this.progressBars = new Hashtable(); + this.progressBarHandlers = new Hashtable(); + + } + + /** + * Returns true if any progress bars are still active + * + * @return + */ + @Override + public boolean operationInProgress() + { + if (progressBars != null && progressBars.size() > 0) + { + return true; + } + return false; + } + + /** + * First call for a given id will show the message as a new progress bar. A + * second call with the same id will remove it. The 'removal' message is + * written to the status bar field (if neither is null). + * + * To avoid progress bars being left orphaned, ensure their removal is + * performed in a finally block if there is any risk of an error during + * execution. + */ + @Override + public void setProgressBar(String message, long id) + { + Long longId = Long.valueOf(id); + + JPanel progressPanel = progressBars.get(longId); + if (progressPanel != null) + { + /* + * Progress bar is displayed for this id - remove it now, and any handler + */ + progressBars.remove(id); + if (message != null && statusBar != null) + { + statusBar.setText(message); + } + if (progressBarHandlers.containsKey(longId)) + { + progressBarHandlers.remove(longId); + } + removeRow(progressPanel); + } + else + { + /* + * No progress bar for this id - add one now + */ + progressPanel = new JPanel(new BorderLayout(10, 5)); + + JProgressBar progressBar = new JProgressBar(); + progressBar.setIndeterminate(true); + + progressPanel.add(new JLabel(message), BorderLayout.WEST); + progressPanel.add(progressBar, BorderLayout.CENTER); + + addRow(progressPanel); + + progressBars.put(longId, progressPanel); + } + + refreshLayout(); + } + + /** + * Lays out progress bar container hierarchy + */ + protected void refreshLayout() + { + /* + * lay out progress bar container hierarchy + */ + SwingUtilities.getRoot(statusPanel).validate(); + } + + /** + * Remove one row with a progress bar, in a thread-safe manner + * + * @param progressPanel + */ + protected void removeRow(JPanel progressPanel) + { + synchronized (statusPanel) + { + statusPanel.remove(progressPanel); + GridLayout layout = (GridLayout) statusPanel.getLayout(); + layout.setRows(layout.getRows() - 1); + statusPanel.remove(progressPanel); + } + } + + /** + * Add one row with a progress bar, in a thread-safe manner + * + * @param progressPanel + */ + protected void addRow(JPanel progressPanel) + { + synchronized (statusPanel) + { + GridLayout layout = (GridLayout) statusPanel.getLayout(); + layout.setRows(layout.getRows() + 1); + statusPanel.add(progressPanel); + } + } + + /** + * Add a 'Cancel' handler for the given progress bar id. This should be called + * _after_ setProgressBar to have any effect. + */ + @Override + public void registerHandler(final long id, + final IProgressIndicatorHandler handler) + { + Long longId = Long.valueOf(id); + final JPanel progressPanel = progressBars.get(longId); + if (progressPanel == null) + { + System.err + .println("call setProgressBar before registering the progress bar's handler."); + return; + } + + /* + * Nothing useful to do if not a Cancel handler + */ + if (!handler.canCancel()) + { + return; + } + + progressBarHandlers.put(longId, handler); + JButton cancel = new JButton(MessageManager.getString("action.cancel")); + final IProgressIndicator us = this; + cancel.addActionListener(new ActionListener() + { + + @Override + public void actionPerformed(ActionEvent e) + { + handler.cancelActivity(id); + us.setProgressBar(MessageManager.formatMessage( + "label.cancelled_params", new Object[] + { ((JLabel) progressPanel.getComponent(0)).getText() }), id); + } + }); + progressPanel.add(cancel, BorderLayout.EAST); + refreshLayout(); + } + +} diff --git a/src/jalview/gui/WebserviceInfo.java b/src/jalview/gui/WebserviceInfo.java index a50cb72..f530018 100644 --- a/src/jalview/gui/WebserviceInfo.java +++ b/src/jalview/gui/WebserviceInfo.java @@ -20,10 +20,6 @@ */ package jalview.gui; -import jalview.jbgui.GWebserviceInfo; -import jalview.util.MessageManager; -import jalview.ws.WSClientI; - import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; @@ -33,19 +29,14 @@ import java.awt.GridLayout; import java.awt.Image; import java.awt.MediaTracker; import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.awt.image.BufferedImage; -import java.util.Hashtable; import java.util.Vector; -import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JEditorPane; import javax.swing.JInternalFrame; -import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; -import javax.swing.JProgressBar; import javax.swing.JScrollPane; import javax.swing.JTabbedPane; import javax.swing.JTextArea; @@ -54,6 +45,10 @@ import javax.swing.event.HyperlinkListener; import javax.swing.text.html.HTMLEditorKit; import javax.swing.text.html.StyleSheet; +import jalview.jbgui.GWebserviceInfo; +import jalview.util.MessageManager; +import jalview.ws.WSClientI; + /** * Base class for web service client thread and gui TODO: create StAX parser to * extract html body content reliably when preparing html formatted job statuses @@ -97,6 +92,8 @@ public class WebserviceInfo extends GWebserviceInfo implements JInternalFrame frame; + private ProgressBar progressBar; + @Override public void setVisible(boolean aFlag) { @@ -326,6 +323,8 @@ public class WebserviceInfo extends GWebserviceInfo implements Desktop.addInternalFrame(frame, title, makeVisible, width, height); frame.setClosable(false); + progressBar = new ProgressBar(statusPanel, statusBar); + this.title = title; setInfoText(info); @@ -879,10 +878,6 @@ public class WebserviceInfo extends GWebserviceInfo implements Desktop.hyperlinkUpdate(e); } - // methods for implementing IProgressIndicator - // need to refactor to a reusable stub class - Hashtable progressBars, progressBarHandlers; - /* * (non-Javadoc) * @@ -891,78 +886,14 @@ public class WebserviceInfo extends GWebserviceInfo implements @Override public void setProgressBar(String message, long id) { - if (progressBars == null) - { - progressBars = new Hashtable(); - progressBarHandlers = new Hashtable(); - } - - JPanel progressPanel; - Long lId = new Long(id); - GridLayout layout = (GridLayout) statusPanel.getLayout(); - if (progressBars.get(lId) != null) - { - progressPanel = (JPanel) progressBars.get(new Long(id)); - statusPanel.remove(progressPanel); - progressBars.remove(lId); - progressPanel = null; - if (message != null) - { - statusBar.setText(message); - } - if (progressBarHandlers.contains(lId)) - { - progressBarHandlers.remove(lId); - } - layout.setRows(layout.getRows() - 1); - } - else - { - progressPanel = new JPanel(new BorderLayout(10, 5)); - - JProgressBar progressBar = new JProgressBar(); - progressBar.setIndeterminate(true); - - progressPanel.add(new JLabel(message), BorderLayout.WEST); - progressPanel.add(progressBar, BorderLayout.CENTER); - - layout.setRows(layout.getRows() + 1); - statusPanel.add(progressPanel); - - progressBars.put(lId, progressPanel); - } - // update GUI - // setMenusForViewport(); - validate(); + progressBar.setProgressBar(message, id); } @Override public void registerHandler(final long id, final IProgressIndicatorHandler handler) { - if (progressBarHandlers == null || !progressBars.contains(new Long(id))) - { - throw new Error(MessageManager.getString("error.call_setprogressbar_before_registering_handler")); - } - progressBarHandlers.put(new Long(id), handler); - final JPanel progressPanel = (JPanel) progressBars.get(new Long(id)); - if (handler.canCancel()) - { - JButton cancel = new JButton( - MessageManager.getString("action.cancel")); - final IProgressIndicator us = this; - cancel.addActionListener(new ActionListener() - { - - @Override - public void actionPerformed(ActionEvent e) - { - handler.cancelActivity(id); - us.setProgressBar(MessageManager.formatMessage("label.cancelled_params", new String[]{((JLabel) progressPanel.getComponent(0)).getText()}), id); - } - }); - progressPanel.add(cancel, BorderLayout.EAST); - } + progressBar.registerHandler(id, handler); } /** @@ -972,10 +903,6 @@ public class WebserviceInfo extends GWebserviceInfo implements @Override public boolean operationInProgress() { - if (progressBars != null && progressBars.size() > 0) - { - return true; - } - return false; + return progressBar.operationInProgress(); } }