svn commit: r16744 - trunk/src/argouml-app/src/org/argouml: i18n uml/reveng uml/reveng/ui
Tom Morris <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: tfmorris
Date: 2009-02-02 12:44:21-0800
New Revision: 16744
Modified:
trunk/src/argouml-app/src/org/argouml/i18n/label.properties
trunk/src/argouml-app/src/org/argouml/uml/reveng/ImportCommon.java
trunk/src/argouml-app/src/org/argouml/uml/reveng/ui/ImportStatusScreen.java
Log:
RESOLVED - task 5675: Deadlock when displaying C++ reverse engineering warning. Implemented a new status message pane.
http://argouml.tigris.org/issues/show_bug.cgi?id=5675
Modified: trunk/src/argouml-app/src/org/argouml/i18n/label.properties
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/i18n/label.properties?view=diff&pathrev=16744&r1=16743&r2=16744
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/i18n/label.properties (original)
+++ trunk/src/argouml-app/src/org/argouml/i18n/label.properties 2009-02-02 12:44:21-0800
@@ -207,6 +207,7 @@
label.home-model = Home Model:
label.implementations = Implementations:
label.implements = Realizes:
+label.import-messages = Import status messages:
label.import-problems = Some elements are missing in the model due to the \
following problems:
label.import.empty = No files imported.
Modified: trunk/src/argouml-app/src/org/argouml/uml/reveng/ImportCommon.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/reveng/ImportCommon.java?view=diff&pathrev=16744&r1=16743&r2=16744
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/reveng/ImportCommon.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/reveng/ImportCommon.java 2009-02-02 12:44:21-0800
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 2006-2008 The Regents of the University of California. All
+// Copyright (c) 2006, 2009 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
@@ -73,6 +73,8 @@
*/
protected static final int MAX_PROGRESS_IMPORT = 99;
+ protected static final int MAX_PROGRESS = MAX_PROGRESS_PREPARE
+ + MAX_PROGRESS_IMPORT;
/**
* keys are module name, values are PluggableImport instance.
*/
@@ -466,7 +468,7 @@
*/
protected void doImport(ProgressMonitor monitor) {
// Roughly equivalent to and derived from old Import.doFile()
- monitor.setMaximumProgress(MAX_PROGRESS_PREPARE + MAX_PROGRESS_IMPORT);
+ monitor.setMaximumProgress(MAX_PROGRESS);
int progress = 0;
monitor.updateSubTask(Translator.localize("dialog.import.preImport"));
List<File> files = getFileList(monitor);
@@ -474,7 +476,6 @@
monitor.updateProgress(progress);
if (files.size() == 0) {
monitor.notifyNullAction();
- monitor.close();
return;
}
Model.getPump().stopPumpingEvents();
@@ -491,9 +492,6 @@
// TODO: Send an event instead of calling Explorer directly
ExplorerEventAdaptor.getInstance().structureChanged();
Model.getPump().startPumpingEvents();
- // Should already be closed. If not, something bad happened, so
- // make sure it's closed so the user isn't stuck
- monitor.close();
}
}
@@ -532,10 +530,8 @@
Translator.localize("dialog.import.layoutAction"));
layoutDiagrams(monitor, progress + filesLeft.size());
}
- monitor.updateMainTask(Translator.localize("dialog.import.done"));
- monitor.updateSubTask(""); //$NON-NLS-1$
- monitor.updateProgress(MAX_PROGRESS_PREPARE
- + MAX_PROGRESS_IMPORT);
+
+ // Add messages from caught exceptions
if (problems != null && problems.length() > 0) {
monitor.notifyMessage(
Translator.localize(
@@ -543,9 +539,12 @@
Translator.localize(
"label.import-problems"), //$NON-NLS-1$
problems.toString());
- } else {
- monitor.close();
}
+
+ monitor.updateMainTask(Translator.localize("dialog.import.done"));
+ monitor.updateSubTask(""); //$NON-NLS-1$
+ monitor.updateProgress(MAX_PROGRESS);
+
}
Modified: trunk/src/argouml-app/src/org/argouml/uml/reveng/ui/ImportStatusScreen.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/reveng/ui/ImportStatusScreen.java?view=diff&pathrev=16744&r1=16743&r2=16744
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/reveng/ui/ImportStatusScreen.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/reveng/ui/ImportStatusScreen.java 2009-02-02 12:44:21-0800
@@ -1,5 +1,5 @@
// $Id$
-// Copyright (c) 2008 The Regents of the University of California. All
+// Copyright (c) 2008, 2009 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
@@ -25,17 +25,24 @@
package org.argouml.uml.reveng.ui;
import java.awt.BorderLayout;
+import java.awt.Container;
import java.awt.Dimension;
import java.awt.Frame;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.WindowEvent;
+import java.awt.event.WindowListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
@@ -44,20 +51,23 @@
import org.argouml.taskmgmt.ProgressMonitor;
/**
- * A window that shows the progress bar and a cancel button.
- * As a convenience to callers which may be executing on a thread other
- * than the Swing event thread, all methods use SwingUtilities.invokeLater()
- * to make sure that Swing calls happen on the appropriate thread.
- *
+ * A window that shows the progress bar and a cancel button. As a convenience to
+ * callers which may be executing on a thread other than the Swing event thread,
+ * all methods use SwingUtilities.invokeLater() or
+ * SwingUtilities.invokeAndWait() to make sure that Swing calls happen on the
+ * appropriate thread.
+ *<p>
* TODO: React on the close button as if the Cancel button was pressed.
*/
-public class ImportStatusScreen extends JDialog implements ProgressMonitor {
+public class ImportStatusScreen extends JDialog
+ implements ProgressMonitor, WindowListener {
- private Frame parentFrame;
private JButton cancelButton;
private JLabel progressLabel;
private JProgressBar progress;
- private boolean cancelled = false;
+ private JTextArea messageArea;
+ private boolean hasMessages = false;
+ private boolean canceled = false;
/**
* The constructor.
@@ -72,40 +82,71 @@
}
Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
getContentPane().setLayout(new BorderLayout(4, 4));
- parentFrame = frame;
+ Container panel = new JPanel(new GridBagLayout());
// Parsing file x of z.
- JPanel topPanel = new JPanel();
progressLabel = new JLabel();
- progressLabel.setPreferredSize(new Dimension(400, 20));
progressLabel.setHorizontalAlignment(SwingConstants.RIGHT);
- topPanel.add(progressLabel);
- getContentPane().add(topPanel, BorderLayout.NORTH);
+ GridBagConstraints gbc = new GridBagConstraints();
+ gbc.anchor = GridBagConstraints.NORTH;
+ gbc.fill = GridBagConstraints.HORIZONTAL;
+ gbc.gridwidth = GridBagConstraints.REMAINDER;
+ gbc.gridheight = 1;
+ gbc.gridx = 0;
+ gbc.gridy = 0;
+ gbc.weightx = 0.1;
+
+ panel.add(progressLabel, gbc);
+ gbc.gridy++;
+
// progress bar
progress = new JProgressBar();
- progress.setPreferredSize(new Dimension(350, 20));
- getContentPane().add(progress, BorderLayout.CENTER);
+ gbc.anchor = GridBagConstraints.CENTER;
+ panel.add(progress, gbc);
+ gbc.gridy++;
+
+ panel.add(
+ new JLabel(Translator.localize("label.import-messages")), gbc);
+ gbc.gridy++;
+
+ // Error/warning messageArea
+ messageArea = new JTextArea(10, 50);
+ gbc.weighty = 0.8;
+// gbc.gridheight = 10;
+ gbc.fill = GridBagConstraints.BOTH;
+ panel.add(new JScrollPane(messageArea), gbc);
+ gbc.gridy++;
- // stop button
+ // cancel/close button
cancelButton = new JButton(Translator.localize("button.cancel"));
- JPanel bottomPanel = new JPanel();
- bottomPanel.add(cancelButton);
- getContentPane().add(bottomPanel, BorderLayout.SOUTH);
+
+ gbc.fill = GridBagConstraints.NONE;
+ gbc.anchor = GridBagConstraints.SOUTH;
+ gbc.weighty = 0.1;
+ gbc.gridheight = GridBagConstraints.REMAINDER;
+ panel.add(cancelButton, gbc);
+ gbc.gridy++;
+
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
- cancelled = true;
-
+ if (isComplete()) {
+ close();
+ }
+ canceled = true;
}
});
-
+
+ getContentPane().add(panel);
pack();
Dimension contentPaneSize = getContentPane().getPreferredSize();
setLocation(scrSize.width / 2 - contentPaneSize.width / 2,
scrSize.height / 2 - contentPaneSize.height / 2);
- setResizable(false);
+ setResizable(true);
+ setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
+ addWindowListener(this);
}
public void setMaximumProgress(final int i) {
@@ -121,9 +162,21 @@
SwingUtilities.invokeLater(new Runnable () {
public void run() {
progress.setValue(i);
+ if (isComplete()) {
+ if (hasMessages) {
+ cancelButton.setText(
+ Translator.localize("button.close"));
+ } else {
+ close();
+ }
+ }
}
});
}
+
+ private boolean isComplete() {
+ return progress.getValue() == progress.getMaximum();
+ }
/**
* The UID.
@@ -146,28 +199,19 @@
* @see org.argouml.application.api.ProgressMonitor#isCanceled()
*/
public boolean isCanceled() {
- return cancelled;
+ return canceled;
}
/*
* @see org.argouml.application.api.ProgressMonitor#notifyMessage(java.lang.String, java.lang.String, java.lang.String)
*/
- public void notifyMessage(String title, String introduction,
- String message) {
- // TODO: Create an error dialog or panel in our progress dialog
- // for now we just use our old style separate error dialog
- // TODO: BUG - All Swing processing must take place on the AWT event
- // thread and we are on the Import Thread here
- ProblemsDialog problemsDialog = new ProblemsDialog(parentFrame, message);
- problemsDialog.setTitle(title);
- problemsDialog.setVisible(true);
- cancelled = problemsDialog.isAborted();
- // TODO: Only needed while we have a separate problem dialog
- // (see above)
- if (cancelled) {
- setVisible(false);
- dispose();
- }
+ public void notifyMessage(final String title, final String introduction,
+ final String message) {
+ hasMessages = true;
+ // TODO: Add filename ?
+ messageArea.setText(messageArea.getText() + title + "\n" + introduction
+ + "\n" + message + "\n\n");
+ messageArea.setCaretPosition(messageArea.getText().length());
}
/*
@@ -207,4 +251,17 @@
// ignored
}
+ public void windowClosing(WindowEvent e) {
+ // User closing the progress window is interpreted as cancel request
+ canceled = true;
+ close();
+ }
+
+ public void windowActivated(WindowEvent e) { }
+ public void windowClosed(WindowEvent e) { }
+ public void windowDeactivated(WindowEvent e) { }
+ public void windowDeiconified(WindowEvent e) { }
+ public void windowIconified(WindowEvent e) { }
+ public void windowOpened(WindowEvent e) { }
+
}
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=1092250
To unsubscribe from this discussion, e-mail: [[email protected]].