Author: kono
Date: 2011-01-13 15:00:31 -0800 (Thu, 13 Jan 2011)
New Revision: 23444
Modified:
core3/work-swing-api/trunk/src/main/java/org/cytoscape/work/swing/GUITaskManager.java
core3/work-swing-impl/trunk/impl/src/main/java/org/cytoscape/work/internal/task/SwingTaskManager.java
core3/work-swing-impl/trunk/impl/src/main/java/org/cytoscape/work/internal/task/SwingTaskMonitor.java
core3/work-swing-impl/trunk/impl/src/main/java/org/cytoscape/work/internal/task/TaskDialog.java
Log:
setParent method had been added to GUITaskManager.
Modified:
core3/work-swing-api/trunk/src/main/java/org/cytoscape/work/swing/GUITaskManager.java
===================================================================
---
core3/work-swing-api/trunk/src/main/java/org/cytoscape/work/swing/GUITaskManager.java
2011-01-13 21:49:39 UTC (rev 23443)
+++
core3/work-swing-api/trunk/src/main/java/org/cytoscape/work/swing/GUITaskManager.java
2011-01-13 23:00:31 UTC (rev 23444)
@@ -1,10 +1,12 @@
package org.cytoscape.work.swing;
+import java.awt.Window;
+
import javax.swing.JPanel;
-import org.cytoscape.work.Task;
+
+import org.cytoscape.work.TaskFactory;
import org.cytoscape.work.TaskManager;
-import org.cytoscape.work.TaskFactory;
/**
@@ -12,11 +14,19 @@
* JPanel to be used to present the {@link org.cytoscape.work.Tunable}s.
*/
public interface GUITaskManager extends TaskManager {
+
/**
- * Sets the parent panel on the TunableInterceptor that it manages.
+ * Set parent component of task monitor GUI.
+ *
+ * @param parent component for the monitor GUI.
+ */
+ void setParent(final Window parent);
+
+ /**
+ * Sets the container panel on the TunableInterceptor that it manages.
* @param parent the new parent panel for the tunables panel
*/
- void setParent(final JPanel parent);
+ void setTunablePanel(final JPanel panel);
/**
* Returns the configuration panel for the specified task factory.
Modified:
core3/work-swing-impl/trunk/impl/src/main/java/org/cytoscape/work/internal/task/SwingTaskManager.java
===================================================================
---
core3/work-swing-impl/trunk/impl/src/main/java/org/cytoscape/work/internal/task/SwingTaskManager.java
2011-01-13 21:49:39 UTC (rev 23443)
+++
core3/work-swing-impl/trunk/impl/src/main/java/org/cytoscape/work/internal/task/SwingTaskManager.java
2011-01-13 23:00:31 UTC (rev 23444)
@@ -1,26 +1,23 @@
package org.cytoscape.work.internal.task;
-import org.cytoscape.work.AbstractTaskManager;
-import org.cytoscape.work.Task;
-import org.cytoscape.work.TaskIterator;
-import org.cytoscape.work.TaskFactory;
-import org.cytoscape.work.TaskMonitor;
-import org.cytoscape.work.swing.GUITunableInterceptor;
-import org.cytoscape.work.swing.GUITaskManager;
-
import java.awt.Frame;
-
+import java.awt.Window;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
import java.util.concurrent.Future;
-import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.TimeUnit;
import javax.swing.JPanel;
+import org.cytoscape.work.AbstractTaskManager;
+import org.cytoscape.work.Task;
+import org.cytoscape.work.TaskFactory;
+import org.cytoscape.work.TaskIterator;
+import org.cytoscape.work.swing.GUITaskManager;
+import org.cytoscape.work.swing.GUITunableInterceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,7 +27,6 @@
* This will not work if the application is running in headless mode.
*/
public class SwingTaskManager extends AbstractTaskManager implements
GUITaskManager {
- private SwingTaskMonitor taskMonitor;
private static final Logger logger =
LoggerFactory.getLogger(SwingTaskManager.class);
@@ -53,12 +49,12 @@
/**
* Used for calling <code>Task.run()</code>.
*/
- ExecutorService taskExecutorService;
+ private ExecutorService taskExecutorService;
/**
* Used for opening dialogs after a specific amount of delay.
*/
- ScheduledExecutorService timedDialogExecutorService;
+ private ScheduledExecutorService timedDialogExecutorService;
/**
* Used for calling <code>Task.cancel()</code>.
@@ -69,9 +65,9 @@
*
* This can be the same as <code>taskExecutorService</code>.
*/
- ExecutorService cancelExecutorService;
+ private ExecutorService cancelExecutorService;
- Frame owner;
+ private Window parent;
/**
* Construct with default behavior.
@@ -85,7 +81,7 @@
public SwingTaskManager(final GUITunableInterceptor tunableInterceptor)
{
super(tunableInterceptor);
- owner = null;
+ parent = null;
taskExecutorService = Executors.newCachedThreadPool();
addShutdownHook(taskExecutorService);
timedDialogExecutorService =
Executors.newSingleThreadScheduledExecutor();
@@ -115,18 +111,19 @@
* @param owner JDialogs created by this <code>TaskManager</code>
* will have its owner set to this parameter.
*/
- public void setOwner(Frame owner) {
- this.owner = owner;
+ @Override public void setParent(final Window parent) {
+ this.parent = parent;
}
@Override
- public void setParent(final JPanel parent) {
- ((GUITunableInterceptor)tunableInterceptor).setParent(parent);
+ public void setTunablePanel(final JPanel tunablePanel) {
+
((GUITunableInterceptor)tunableInterceptor).setParent(tunablePanel);
}
@Override
protected void execute(final TaskFactory factory, boolean wait) {
- final SwingTaskMonitor taskMonitor = new
SwingTaskMonitor(cancelExecutorService, owner);
+ final SwingTaskMonitor taskMonitor = new
SwingTaskMonitor(cancelExecutorService, parent);
+
TaskIterator taskIterator;
Task first;
@@ -183,6 +180,7 @@
private final SwingTaskMonitor taskMonitor;
private final TaskIterator taskIterator;
private final Task first;
+
TaskThread(final Task first, final SwingTaskMonitor tm, final
TaskIterator ti) {
this.first = first;
this.taskMonitor = tm;
Modified:
core3/work-swing-impl/trunk/impl/src/main/java/org/cytoscape/work/internal/task/SwingTaskMonitor.java
===================================================================
---
core3/work-swing-impl/trunk/impl/src/main/java/org/cytoscape/work/internal/task/SwingTaskMonitor.java
2011-01-13 21:49:39 UTC (rev 23443)
+++
core3/work-swing-impl/trunk/impl/src/main/java/org/cytoscape/work/internal/task/SwingTaskMonitor.java
2011-01-13 23:00:31 UTC (rev 23444)
@@ -1,20 +1,17 @@
package org.cytoscape.work.internal.task;
-import org.cytoscape.work.TaskMonitor;
-import org.cytoscape.work.Task;
-
import java.awt.Frame;
-
+import java.awt.Window;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-import javax.swing.JPanel;
+import org.cytoscape.work.Task;
+import org.cytoscape.work.TaskMonitor;
class SwingTaskMonitor implements TaskMonitor {
private Task task;
final private ExecutorService cancelExecutorService;
- final private Frame owner;
+ final private Window parent;
private boolean cancelled = false;
private TaskDialog dialog = null;
@@ -22,9 +19,9 @@
private String statusMessage = null;
private int progress = 0;
- public SwingTaskMonitor(final ExecutorService cancelExecutorService,
final Frame owner) {
+ public SwingTaskMonitor(final ExecutorService cancelExecutorService,
final Window parent) {
this.cancelExecutorService = cancelExecutorService;
- this.owner = owner;
+ this.parent = parent;
}
public void setTask(final Task newTask) {
@@ -35,7 +32,9 @@
if (dialog != null)
return;
- dialog = new TaskDialog(owner, this);
+ dialog = new TaskDialog(parent, this);
+ dialog.setLocationRelativeTo(parent);
+
if (title != null)
dialog.setTaskTitle(title);
if (statusMessage != null)
Modified:
core3/work-swing-impl/trunk/impl/src/main/java/org/cytoscape/work/internal/task/TaskDialog.java
===================================================================
---
core3/work-swing-impl/trunk/impl/src/main/java/org/cytoscape/work/internal/task/TaskDialog.java
2011-01-13 21:49:39 UTC (rev 23443)
+++
core3/work-swing-impl/trunk/impl/src/main/java/org/cytoscape/work/internal/task/TaskDialog.java
2011-01-13 23:00:31 UTC (rev 23444)
@@ -1,4 +1,3 @@
-
/*
Copyright (c) 2006, 2007, The Cytoscape Consortium (www.cytoscape.org)
@@ -32,83 +31,103 @@
You should have received a copy of the GNU Lesser General Public License
along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
+ */
package org.cytoscape.work.internal.task;
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-import javax.swing.border.*;
+import java.awt.CardLayout;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.GridLayout;
+import java.awt.Insets;
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
import java.util.Date;
-class TaskDialog extends JDialog
-{
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JProgressBar;
+import javax.swing.JSeparator;
+import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
+import javax.swing.Timer;
+import javax.swing.UIManager;
+
+class TaskDialog extends JDialog {
+
+ private static final long serialVersionUID = 5121051715524541940L;
+
/**
- * How much time between updating the "Estimated Time Remaining"
- * field, stored in <code>timeLabel</code>.
+ * How much time between updating the "Estimated Time Remaining" field,
+ * stored in <code>timeLabel</code>.
*/
- static final int TIME_UPDATE_INTERVAL_IN_MILLISECONDS = 1000;
+ static final int TIME_UPDATE_INTERVAL_IN_MILLISECONDS = 1000;
/**
- * Description and status messages are stored in
- * <code>JTextArea</code>s; this specifies the number of
- * columns <code>JTextArea</code>s should have.
+ * Description and status messages are stored in
<code>JTextArea</code>s;
+ * this specifies the number of columns <code>JTextArea</code>s should
have.
* This value has a big impact on the size of the dialog.
*/
- static final int TEXT_AREA_COLUMNS = 30;
+ static final int TEXT_AREA_COLUMNS = 30;
/**
* Constant used for <code>CardLayout.show()</code> and
- * <code>CardLayout.add()</code> to switch between normal
- * mode and exception mode.
+ * <code>CardLayout.add()</code> to switch between normal mode and
exception
+ * mode.
*/
- static final String NORMAL_MODE = "normal";
+ static final String NORMAL_MODE = "normal";
/**
* Constant used for <code>CardLayout.show()</code> and
- * <code>CardLayout.add()</code> to switch between normal
- * mode and exception mode.
+ * <code>CardLayout.add()</code> to switch between normal mode and
exception
+ * mode.
*/
- static final String EXCEPTION_MODE = "exception";
+ static final String EXCEPTION_MODE = "exception";
/**
- * If the progress bar is indeterminate, the string format to use
- * for <code>timeLabel</code>.
+ * If the progress bar is indeterminate, the string format to use for
+ * <code>timeLabel</code>.
*/
- static final String ELAPSED_FORMAT = "%s elapsed";
-
+ static final String ELAPSED_FORMAT = "%s elapsed";
+
/**
- * If the progress bar is determinate, the string format to use
- * for <code>timeLabel</code>.
+ * If the progress bar is determinate, the string format to use for
+ * <code>timeLabel</code>.
*/
- static final String ELAPSED_AND_REMAINING_FORMAT = "%s elapsed,
%s remaining";
+ static final String ELAPSED_AND_REMAINING_FORMAT = "%s elapsed, %s
remaining";
- static final String CANCEL_LABEL = " Cancel
";
- static final String CANCELLING_LABEL = "
Cancelling... ";
- static final String CLOSE_LABEL = " Close ";
+ static final String CANCEL_LABEL = " Cancel ";
+ static final String CANCELLING_LABEL = " Cancelling... ";
+ static final String CLOSE_LABEL = " Close ";
// State variables
- boolean haltRequested = false;
- boolean errorOccurred = false;
- SwingTaskMonitor parentTaskMonitor = null;
+ boolean haltRequested = false;
+ boolean errorOccurred = false;
+ SwingTaskMonitor parentTaskMonitor = null;
// Swing components
- JTextArea descriptionLabel = new JTextArea();
- JTextArea descriptionLabel2 = new JTextArea();
- JTextArea statusLabel = new JTextArea();
- JProgressBar progressBar = new JProgressBar();
- JTextArea timeLabel = new JTextArea();
- JButton cancelButton = new
JButton(CANCEL_LABEL);
- JButton closeButton = new
JButton(CLOSE_LABEL);
- JPanel exceptionPanel = new JPanel();
+ JTextArea descriptionLabel = new JTextArea();
+ JTextArea descriptionLabel2 = new JTextArea();
+ JTextArea statusLabel = new JTextArea();
+ JProgressBar progressBar = new JProgressBar();
+ JTextArea timeLabel = new JTextArea();
+ JButton cancelButton = new JButton(CANCEL_LABEL);
+ JButton closeButton = new JButton(CLOSE_LABEL);
+ JPanel exceptionPanel = new JPanel();
// Specific for the timer
- Timer timer = null;
- Date startTime = new Date();
+ Timer timer = null;
+ Date startTime = new Date();
- public TaskDialog(Frame parentFrame, SwingTaskMonitor parentTaskMonitor)
- {
+ public TaskDialog(final Window parentFrame, final SwingTaskMonitor
parentTaskMonitor) {
super(parentFrame);
this.parentTaskMonitor = parentTaskMonitor;
initComponents();
@@ -116,14 +135,12 @@
initLayout();
}
- public void setTaskTitle(final String taskTitle)
- {
- SwingUtilities.invokeLater(new Runnable()
- {
+ public void setTaskTitle(final String taskTitle) {
+ SwingUtilities.invokeLater(new Runnable() {
public void run() {
setTitle(taskTitle);
-
//descriptionLabel.setText(StringUtils.truncateOrPadString(taskTitle));
-
//descriptionLabel2.setText(StringUtils.truncateOrPadString(taskTitle));
+ //
descriptionLabel.setText(StringUtils.truncateOrPadString(taskTitle));
+ //
descriptionLabel2.setText(StringUtils.truncateOrPadString(taskTitle));
descriptionLabel.setText(taskTitle);
descriptionLabel2.setText(taskTitle);
pack();
@@ -131,21 +148,17 @@
});
}
- public void setPercentCompleted(final int percent)
- {
- if (haltRequested) return;
+ public void setPercentCompleted(final int percent) {
+ if (haltRequested)
+ return;
- SwingUtilities.invokeLater(new Runnable()
- {
+ SwingUtilities.invokeLater(new Runnable() {
public void run() {
- if (percent < 0)
- {
+ if (percent < 0) {
if (!progressBar.isIndeterminate()) {
progressBar.setIndeterminate(true);
}
- }
- else
- {
+ } else {
if (progressBar.isIndeterminate()) {
progressBar.setIndeterminate(false);
}
@@ -156,21 +169,21 @@
});
}
- public void setException(final Throwable t, final String
userErrorMessage)
- {
+ public void setException(final Throwable t, final String
userErrorMessage) {
this.errorOccurred = true;
stopTimer();
- SwingUtilities.invokeLater(new Runnable()
- {
+ SwingUtilities.invokeLater(new Runnable() {
public void run() {
- // Create Error Panel
- ErrorPanel errorPanel = new
ErrorPanel(TaskDialog.this, t, userErrorMessage, t.getMessage());
+ // Create Error Panel
+ ErrorPanel errorPanel = new
ErrorPanel(TaskDialog.this, t,
+ userErrorMessage,
t.getMessage());
exceptionPanel.add(errorPanel);
- CardLayout cardLayout = (CardLayout)
getContentPane().getLayout();
+ CardLayout cardLayout = (CardLayout)
getContentPane()
+ .getLayout();
cardLayout.show(getContentPane(),
EXCEPTION_MODE);
pack();
- // Make sure TaskDialog is actually visible
+ // Make sure TaskDialog is actually visible
if (!TaskDialog.this.isShowing()) {
TaskDialog.this.setVisible(true);
}
@@ -179,18 +192,18 @@
}
/**
- * Sets the Status Message.
- * Called by a child task thread.
- * Safely queues changes to the Swing Event Dispatch Thread.
- *
- * @param message status message.
+ * Sets the Status Message. Called by a child task thread. Safely queues
+ * changes to the Swing Event Dispatch Thread.
+ *
+ * @param message
+ * status message.
*/
public void setStatus(final String message) {
if (!haltRequested) {
- // Update the UI
+ // Update the UI
SwingUtilities.invokeLater(new Runnable() {
public void run() {
-
//statusLabel.setText(StringUtils.truncateOrPadString(message));
+ //
statusLabel.setText(StringUtils.truncateOrPadString(message));
statusLabel.setText(message);
pack();
}
@@ -198,9 +211,8 @@
}
}
- public void setTimeMessage(final String message)
- {
- // Update the UI
+ public void setTimeMessage(final String message) {
+ // Update the UI
SwingUtilities.invokeLater(new Runnable() {
public void run() {
timeLabel.setText(message);
@@ -210,7 +222,7 @@
/**
* Returns true if Task Has Encountered An Error.
- *
+ *
* @return boolean value.
*/
public boolean errorOccurred() {
@@ -219,15 +231,14 @@
/**
* Returns true if User Has Requested to Halt the Task.
- *
+ *
* @return boolean value.
*/
public boolean haltRequested() {
return haltRequested;
}
- synchronized void cancel()
- {
+ synchronized void cancel() {
if (haltRequested)
return;
@@ -238,39 +249,31 @@
parentTaskMonitor.cancel();
}
- synchronized void close()
- {
+ synchronized void close() {
stopTimer();
parentTaskMonitor.close();
}
- void initComponents()
- {
+ void initComponents() {
initTextArea(descriptionLabel);
initTextArea(descriptionLabel2);
initTextArea(statusLabel);
initTextArea(timeLabel);
- closeButton.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
+ closeButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
close();
}
});
- cancelButton.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
+ cancelButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
cancel();
}
});
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
- addWindowListener(new WindowAdapter()
- {
- public void windowClosing(WindowEvent e)
- {
+ addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
if (errorOccurred)
close();
else
@@ -279,20 +282,18 @@
});
}
- JLabel initLabel(JLabel label)
- {
+ JLabel initLabel(JLabel label) {
label.setHorizontalAlignment(JLabel.LEFT);
label.setFont(new Font(null, Font.PLAIN, 13));
return label;
}
- JTextArea initTextArea(JTextArea textArea)
- {
+ JTextArea initTextArea(JTextArea textArea) {
textArea.setEditable(false);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
textArea.setColumns(TEXT_AREA_COLUMNS);
- //textArea.setBorder(new EmptyBorder(5, 5, 5, 5));
+ // textArea.setBorder(new EmptyBorder(5, 5, 5, 5));
textArea.setBackground((Color)
UIManager.get("Label.background"));
textArea.setForeground((Color)
UIManager.get("Label.foreground"));
@@ -300,68 +301,99 @@
return textArea;
}
- void initLayout()
- {
+ void initLayout() {
getContentPane().setLayout(new CardLayout());
JPanel panel1 = new JPanel(new GridBagLayout());
JLabel element0 = initLabel(new JLabel("Description: "));
- panel1.add(element0, new GridBagConstraints(0, 0, 1, 1, 0, 0,
GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(10, 10, 0,
0), 0, 0));
- panel1.add(descriptionLabel, new GridBagConstraints(1, 0, 1, 1,
1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new
Insets(10, 10, 0, 10), 0, 0));
+ panel1.add(element0, new GridBagConstraints(0, 0, 1, 1, 0, 0,
+ GridBagConstraints.NORTHEAST,
GridBagConstraints.NONE,
+ new Insets(10, 10, 0, 0), 0, 0));
+ panel1.add(descriptionLabel, new GridBagConstraints(1, 0, 1, 1,
1, 0,
+ GridBagConstraints.NORTHWEST,
GridBagConstraints.HORIZONTAL,
+ new Insets(10, 10, 0, 10), 0, 0));
JLabel element1 = initLabel(new JLabel("Status: "));
- panel1.add(element1, new GridBagConstraints(0, 1, 1, 1, 0, 0,
GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(10, 10, 0,
0), 0, 0));
- panel1.add(statusLabel, new GridBagConstraints(1, 1, 1, 1, 1,
0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(10,
10, 0, 10), 0, 0));
+ panel1.add(element1, new GridBagConstraints(0, 1, 1, 1, 0, 0,
+ GridBagConstraints.NORTHEAST,
GridBagConstraints.NONE,
+ new Insets(10, 10, 0, 0), 0, 0));
+ panel1.add(statusLabel, new GridBagConstraints(1, 1, 1, 1, 1, 0,
+ GridBagConstraints.NORTHWEST,
GridBagConstraints.HORIZONTAL,
+ new Insets(10, 10, 0, 10), 0, 0));
JLabel element2 = initLabel(new JLabel("Progress: "));
- panel1.add(element2, new GridBagConstraints(0, 2, 1, 1, 0, 0,
GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 10, 0, 0), 0,
0));
- panel1.add(progressBar, new GridBagConstraints(1, 2, 1, 1, 1,
0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(10, 10,
0, 10), 0, 0));
- panel1.add(timeLabel, new GridBagConstraints(1, 3, 1, 1, 1, 0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 0,
10), 0, 0));
+ panel1.add(element2, new GridBagConstraints(0, 2, 1, 1, 0, 0,
+ GridBagConstraints.EAST,
GridBagConstraints.NONE, new Insets(
+ 10, 10, 0, 0), 0, 0));
+ panel1.add(progressBar, new GridBagConstraints(1, 2, 1, 1, 1, 0,
+ GridBagConstraints.CENTER,
GridBagConstraints.HORIZONTAL,
+ new Insets(10, 10, 0, 10), 0, 0));
+ panel1.add(timeLabel, new GridBagConstraints(1, 3, 1, 1, 1, 0,
+ GridBagConstraints.CENTER,
GridBagConstraints.HORIZONTAL,
+ new Insets(10, 10, 0, 10), 0, 0));
JSeparator element3 = new JSeparator();
- panel1.add(element3, new GridBagConstraints(0, 4, 2, 1, 1, 0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 0,
10), 0, 0));
- panel1.add(cancelButton, new GridBagConstraints(0, 5, 2, 1, 1,
1, GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 10,
10), 0, 0));
+ panel1.add(element3, new GridBagConstraints(0, 4, 2, 1, 1, 0,
+ GridBagConstraints.CENTER,
GridBagConstraints.HORIZONTAL,
+ new Insets(10, 10, 0, 10), 0, 0));
+ panel1.add(cancelButton, new GridBagConstraints(0, 5, 2, 1, 1,
1,
+ GridBagConstraints.SOUTHEAST,
GridBagConstraints.NONE,
+ new Insets(0, 0, 10, 10), 0, 0));
getContentPane().add(panel1, NORMAL_MODE);
JPanel panel2 = new JPanel(new GridBagLayout());
JLabel element4 = initLabel(new JLabel("Description: "));
- panel2.add(element4, new GridBagConstraints(0, 0, 1, 1, 0, 0,
GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(10, 10, 0,
0), 0, 0));
- panel2.add(descriptionLabel2, new GridBagConstraints(1, 0, 1,
1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new
Insets(10, 10, 0, 0), 0, 0));
- panel2.add(exceptionPanel, new GridBagConstraints(0, 1, 2, 1,
1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(10, 10, 0,
10), 0, 0));
+ panel2.add(element4, new GridBagConstraints(0, 0, 1, 1, 0, 0,
+ GridBagConstraints.NORTHEAST,
GridBagConstraints.NONE,
+ new Insets(10, 10, 0, 0), 0, 0));
+ panel2.add(descriptionLabel2, new GridBagConstraints(1, 0, 1,
1, 1, 0,
+ GridBagConstraints.NORTHWEST,
GridBagConstraints.HORIZONTAL,
+ new Insets(10, 10, 0, 0), 0, 0));
+ panel2.add(exceptionPanel, new GridBagConstraints(0, 1, 2, 1,
1, 1,
+ GridBagConstraints.CENTER,
GridBagConstraints.BOTH, new Insets(
+ 10, 10, 0, 10), 0, 0));
JSeparator element6 = new JSeparator();
- panel2.add(element6, new GridBagConstraints(0, 2, 2, 1, 1, 0,
GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 0,
10), 0, 0));
- panel2.add(closeButton, new GridBagConstraints(0, 3, 2, 1, 1,
0, GridBagConstraints.SOUTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 10,
10), 0, 0));
+ panel2.add(element6, new GridBagConstraints(0, 2, 2, 1, 1, 0,
+ GridBagConstraints.CENTER,
GridBagConstraints.HORIZONTAL,
+ new Insets(10, 10, 0, 10), 0, 0));
+ panel2.add(closeButton, new GridBagConstraints(0, 3, 2, 1, 1, 0,
+ GridBagConstraints.SOUTHEAST,
GridBagConstraints.NONE,
+ new Insets(0, 0, 10, 10), 0, 0));
getContentPane().add(panel2, EXCEPTION_MODE);
- exceptionPanel.setLayout(new GridLayout(1,1));
+ exceptionPanel.setLayout(new GridLayout(1, 1));
setResizable(false);
pack();
setVisible(true);
}
-
/**
- * Initialize the Timer Object.
- * Note that timer events are sent to the Swing Event-Dispatch Thread.
+ * Initialize the Timer Object. Note that timer events are sent to the
Swing
+ * Event-Dispatch Thread.
*/
void initTimer() {
- // Create Auto-Timer
+ // Create Auto-Timer
timer = new Timer(TIME_UPDATE_INTERVAL_IN_MILLISECONDS,
- new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- Date currentTime = new Date();
- long timeElapsed =
currentTime.getTime() - startTime.getTime();
- String timeElapsedString =
StringUtils.getTimeString(timeElapsed);
- if (!progressBar.isIndeterminate() &&
progressBar.getValue() != 0)
- {
- long timeRemaining = (long)
((100.0 / progressBar.getValue() - 1.0) * timeElapsed);
- String timeRemainingString =
StringUtils.getTimeString(timeRemaining);
-
timeLabel.setText(String.format(ELAPSED_AND_REMAINING_FORMAT,
timeElapsedString, timeRemainingString));
+ new ActionListener() {
+ public void actionPerformed(ActionEvent
e) {
+ Date currentTime = new Date();
+ long timeElapsed =
currentTime.getTime()
+ -
startTime.getTime();
+ String timeElapsedString =
StringUtils
+
.getTimeString(timeElapsed);
+ if
(!progressBar.isIndeterminate()
+ &&
progressBar.getValue() != 0) {
+ long timeRemaining =
(long) ((100.0 / progressBar
+
.getValue() - 1.0) * timeElapsed);
+ String
timeRemainingString = StringUtils
+
.getTimeString(timeRemaining);
+
timeLabel.setText(String.format(
+
ELAPSED_AND_REMAINING_FORMAT,
+
timeElapsedString, timeRemainingString));
+ } else {
+
timeLabel.setText(String.format(ELAPSED_FORMAT,
+
timeElapsedString));
+ }
+ pack();
}
- else
- {
-
timeLabel.setText(String.format(ELAPSED_FORMAT, timeElapsedString));
- }
- pack();
- }
- });
+ });
timer.start();
}
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.