01: /*
02: * MissingPkDialog.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.gui.sql;
13:
14: import java.awt.Component;
15: import java.awt.Window;
16: import java.util.List;
17: import javax.swing.JLabel;
18: import javax.swing.SwingUtilities;
19: import workbench.db.ColumnIdentifier;
20: import workbench.gui.components.ValidatingDialog;
21: import workbench.gui.components.ValidatingDialog;
22: import workbench.resource.ResourceMgr;
23:
24: /**
25: * @author support@sql-workbench.net
26: */
27: public class MissingPkDialog {
28: private List<ColumnIdentifier> columns;
29:
30: public MissingPkDialog(List<ColumnIdentifier> cols) {
31: this .columns = cols;
32: }
33:
34: public boolean checkContinue(Component caller) {
35: if (this .columns == null || this .columns.size() == 0)
36: return true;
37: StringBuilder msg = new StringBuilder(100);
38:
39: msg.append("<html>");
40: msg.append("<p style=\"padding:3px;background:white\">");
41: msg.append(ResourceMgr.getString("TxtMissingPk1"));
42: msg.append("</p><p style=\"margin-top:5px;background:white\">");
43: for (ColumnIdentifier col : columns) {
44: msg.append(" » <tt>");
45: msg.append(col.getColumnName());
46: msg.append("</tt><br>");
47: }
48: msg.append("</p><br><center><b style=\"color:red\">");
49: msg.append(ResourceMgr.getString("TxtMissingPk2"));
50: msg.append("</b></center><br><b><center>");
51: msg.append(ResourceMgr.getString("TxtMissingPk3"));
52: msg.append("</b></center><br><br></html>");
53:
54: Window parent = SwingUtilities.getWindowAncestor(caller);
55: boolean ok = ValidatingDialog.showConfirmDialog(parent,
56: new JLabel(msg.toString()), ResourceMgr
57: .getString("TxtMissingPkTitle"), 1);
58: return ok;
59:
60: }
61: }
|