From b4dc22f0312554d7724d1b7ebb2599afe8e798ac Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 17 Jun 2010 19:53:37 +0200 Subject: [PATCH] Expose whether the insert is currently running. --- src/de/todesbaum/jsite/gui/ProjectInsertPage.java | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/de/todesbaum/jsite/gui/ProjectInsertPage.java b/src/de/todesbaum/jsite/gui/ProjectInsertPage.java index e43510d..86305aa 100644 --- a/src/de/todesbaum/jsite/gui/ProjectInsertPage.java +++ b/src/de/todesbaum/jsite/gui/ProjectInsertPage.java @@ -91,6 +91,9 @@ public class ProjectInsertPage extends TWizardPage implements InsertListener, Cl /** Whether the “copy URI to clipboard” button was used. */ private boolean uriCopied; + /** Whether the insert is currently running. */ + private volatile boolean running = false; + /** * Creates a new progress insert wizard page. * @@ -211,6 +214,7 @@ public class ProjectInsertPage extends TWizardPage implements InsertListener, Cl * Starts the insert. */ public void startInsert() { + running = true; wizard.setNextEnabled(false); copyURIAction.setEnabled(false); progressBar.setValue(0); @@ -220,6 +224,26 @@ public class ProjectInsertPage extends TWizardPage implements InsertListener, Cl } /** + * Stops the currently running insert. + */ + public void stopInsert() { + if (running) { + wizard.setNextEnabled(false); + projectInserter.stop(); + } + } + + /** + * Returns whether the insert is currently running. + * + * @return {@code true} if the insert is currently running, {@code false} + * otherwise + */ + public boolean isRunning() { + return running; + } + + /** * Sets the project to insert. * * @param project @@ -356,6 +380,7 @@ public class ProjectInsertPage extends TWizardPage implements InsertListener, Cl * {@inheritDoc} */ public void projectInsertFinished(Project project, boolean success, Throwable cause) { + running = false; if (success) { String copyURILabel = I18n.getMessage("jsite.insert.okay-copy-uri"); int selectedValue = JOptionPane.showOptionDialog(this, I18n.getMessage("jsite.insert.inserted"), I18n.getMessage("jsite.insert.done.title"), 0, JOptionPane.INFORMATION_MESSAGE, null, new Object[] { I18n.getMessage("jsite.general.ok"), copyURILabel }, copyURILabel); -- 2.7.4