01: package de.ixdb.squirrel_sql.plugins.cache;
02:
03: import net.sourceforge.squirrel_sql.client.session.ISession;
04: import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
05: import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
06: import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
07: import net.sourceforge.squirrel_sql.fw.sql.IProcedureInfo;
08: import org.w3c.dom.Document;
09: import org.w3c.dom.Element;
10: import org.w3c.dom.NodeList;
11:
12: import java.util.StringTokenizer;
13: import java.util.Vector;
14:
15: public class ScriptCdlCommand {
16: private ISession _session;
17: private CachePlugin _plugin;
18:
19: private static ILogger s_log;
20:
21: public ScriptCdlCommand(ISession session, CachePlugin plugin) {
22: _session = session;
23: _plugin = plugin;
24: if (ScriptCdlCommand.s_log == null) {
25: ScriptCdlCommand.s_log = LoggerController
26: .createLogger(getClass());
27: }
28: }
29:
30: public void execute() {
31: String names = getSelectedNames();
32:
33: if (null == names || 0 == names.trim().length()) {
34: return;
35: }
36:
37: String cdl = CdlAccessor.getDefinition(names, _session
38: .getSQLConnection().getConnection());
39:
40: _session.getSessionInternalFrame().getSQLPanelAPI()
41: .appendSQLScript("\n" + cdl + "\n");
42: _session.selectMainTab(ISession.IMainPanelTabIndexes.SQL_TAB);
43:
44: }
45:
46: private String getSelectedNames() {
47: IDatabaseObjectInfo[] dbObjs = _session
48: .getSessionInternalFrame().getObjectTreeAPI()
49: .getSelectedDatabaseObjects();
50:
51: return CdlAccessor.getSearchStringForCdlAccess(dbObjs);
52: }
53:
54: }
|