mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
148 lines
3.8 KiB
Plaintext
148 lines
3.8 KiB
Plaintext
import javax.swing.tree.*;
|
|
import javax.swing.*;
|
|
import java.awt.Component;
|
|
import java.awt.KeyboardFocusManager;
|
|
|
|
String event = arg("source");
|
|
WindowContext context = argObj("windowContext");
|
|
log.debug("Event received: " + event);
|
|
|
|
if (event == "New Connection")
|
|
{
|
|
script("jheidi");
|
|
}
|
|
else if (event == "Refresh")
|
|
{
|
|
DB db = context.get("db");
|
|
|
|
Panel tab = (Panel)((Tabs)context.get("/mainTabs")).getSelectedComponent();
|
|
if ( tab.getName() != "Host" )
|
|
{
|
|
db.flushCache();
|
|
}
|
|
|
|
Worker w = worker("initTreeOracleWorker", args(), Worker.RunOption.LET_FINISH_IF_RUNNING);
|
|
if ( !w.isCancelled())
|
|
LongRunningTask.detect("initTreeOracleWorker", "progressWaiter", args(), w , 250);
|
|
|
|
String script = tab.getProperty("refreshScript");
|
|
HashObject scriptArgs = (HashObject)tab.getProperty("refreshArgs");
|
|
if ( script != null )
|
|
{
|
|
if ( script.endsWith("Worker") )
|
|
{
|
|
w = worker(script, scriptArgs, Worker.RunOption.LET_FINISH_IF_RUNNING);
|
|
if ( scriptArgs.get("workerKey") != null)
|
|
script = scriptArgs.get("workerKey");
|
|
|
|
if (!w.isCancelled())
|
|
LongRunningTask.detect(script, "progressWaiter", scriptArgs, w , 250);
|
|
}
|
|
else
|
|
{
|
|
script(script, scriptArgs);
|
|
}
|
|
}
|
|
|
|
}
|
|
else if (event == "Cut" || event == "Copy" || event == "Paste" )
|
|
{
|
|
Component compFocusOwner =
|
|
KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
|
|
|
|
if ( compFocusOwner instanceof Editor)
|
|
{
|
|
Editor editor = (Editor)compFocusOwner;
|
|
if ( event == "Cut" )
|
|
{
|
|
editor.cut();
|
|
}
|
|
else if (event == "Copy")
|
|
{
|
|
editor.copy();
|
|
}
|
|
else if (event == "Paste")
|
|
{
|
|
editor.paste();
|
|
}
|
|
}
|
|
}
|
|
else if (event == "Drop Table")
|
|
{
|
|
Tree schemaTree = context.get("/schemaTree");
|
|
NodeInfo node = schemaTree.getSelectedNode();
|
|
if ( node != null && "table".equals(node.getType()) )
|
|
{
|
|
NodeInfo dbNode = node.getParent();
|
|
Frame f = context.get("/");
|
|
if (f.popupConfirm("Confirm Delete!", "Are you sure you want to drop table '" + dbNode.getText() + "." + node.getText() + "'?", "images/deletetable.gif"))
|
|
{
|
|
args().put("tableToDrop", node.getText());
|
|
script("dropTable$oracle", args());
|
|
node.remove();
|
|
//force the tabs to refresh and the db info to reload
|
|
//schema tree events will be called by the tree itself
|
|
context.put("currentDB", null);
|
|
schemaTree.select(dbNode);
|
|
}
|
|
}
|
|
|
|
}
|
|
else if (event == "Create Table")
|
|
{
|
|
if ( script("createTableDialogOracle", args()) != null )
|
|
{
|
|
Tree schemaTree = context.get("/schemaTree");
|
|
Worker w = worker("initTreeOracleWorker", args(), Worker.RunOption.LET_FINISH_IF_RUNNING);
|
|
if (!w.isCancelled())
|
|
{
|
|
LongRunningTask.detect("initTreeOracleWorker", "progressWaiter", args(),w, 250);
|
|
}
|
|
}
|
|
|
|
}
|
|
else if (event == "Print")
|
|
{
|
|
//this is total shit - but it does work if you try to print something that might fit on
|
|
//the page....omg this is bad.
|
|
Table table = null;
|
|
String selectedTab = ((Tabs)context.get("/mainTabs")).selected();
|
|
|
|
if ("Host" != selectedTab && "Query" != selectedTab)
|
|
{
|
|
table = context.get("/mainTabs/"+selectedTab+"/table");
|
|
}
|
|
else if ("Host" == selectedTab)
|
|
{
|
|
String subTab = ((Tabs)context.get("/mainTabs/Host/tabs")).selected();
|
|
table = context.get("/mainTabs/Host/tabs/"+subTab+"/table");
|
|
}
|
|
else if ("Query" == selectedTab)
|
|
{
|
|
table = context.get("/mainTabs/Query/results");
|
|
}
|
|
|
|
try
|
|
{
|
|
table.print();
|
|
} catch (Exception e) {e.printStackTrace();}
|
|
}
|
|
else if (event == "Help")
|
|
{
|
|
script("helpDialog$" + context.get("vendor"), args());
|
|
}
|
|
else if (event == "Exit")
|
|
{
|
|
System.exit(0);
|
|
}
|
|
else if (event == "Close")
|
|
{
|
|
Frame window = context.get("/");
|
|
script("removeFromWindowMenu", args());
|
|
window.dispose();
|
|
}
|
|
else {
|
|
((Frame)context.get("/")).popupMessage("Feature Unimplemented!");
|
|
}
|
|
|