01: /*
02: * WbConfirm.java
03: *
04: * This file is part of SQL Workbench/J, http://www.sql-workbench.net
05: *
06: * Copyright 2002-2008, Thomas Kellerer
07: * No part of this code maybe reused without the permission of the author
08: *
09: * To contact the author please send an email to: support@sql-workbench.net
10: *
11: */
12: package workbench.sql.wbcommands;
13:
14: import java.sql.SQLException;
15: import workbench.WbManager;
16: import workbench.gui.WbSwingUtilities;
17: import workbench.resource.ResourceMgr;
18: import workbench.sql.SqlCommand;
19: import workbench.sql.StatementRunnerResult;
20: import workbench.util.StringUtil;
21:
22: /**
23: * A SQL Statement to halt a script and confirm execution by the user
24: *
25: * @author support@sql-workbench.net
26: */
27: public class WbConfirm extends SqlCommand {
28: public static final String VERB = "WBCONFIRM";
29:
30: public WbConfirm() {
31: this .isUpdatingCommand = false;
32: }
33:
34: public String getVerb() {
35: return VERB;
36: }
37:
38: protected boolean isConnectionRequired() {
39: return false;
40: }
41:
42: public StatementRunnerResult execute(String sql)
43: throws SQLException {
44: StatementRunnerResult result = new StatementRunnerResult();
45: result.setStopScript(false);
46: result.setSuccess();
47:
48: if (WbManager.getInstance().isBatchMode())
49: return result;
50:
51: String msg = getCommandLine(sql);
52:
53: if (StringUtil.isEmptyString(msg)) {
54: msg = ResourceMgr.getString("MsgConfirmContinue");
55: }
56:
57: boolean continueScript = WbSwingUtilities.getYesNo(WbManager
58: .getInstance().getCurrentWindow(), StringUtil
59: .trimQuotes(msg));
60: if (!continueScript) {
61: result.setStopScript(true);
62: }
63:
64: return result;
65: }
66:
67: }
|