mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2026-03-13 09:24:25 +08:00
make oracle and mysql specific
This commit is contained in:
250
extra/jheidi/mainWindowEventsMySQL.ajl
Normal file
250
extra/jheidi/mainWindowEventsMySQL.ajl
Normal file
@@ -0,0 +1,250 @@
|
||||
import javax.swing.tree.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.Component;
|
||||
import java.awt.KeyboardFocusManager;
|
||||
|
||||
String who = arg("source");
|
||||
WindowContext context = argObj("windowContext");
|
||||
log.debug("Event received: " + who);
|
||||
|
||||
if ("New Connection" == who)
|
||||
{
|
||||
script("jheidi");
|
||||
}
|
||||
else if ("Refresh" == who)
|
||||
{
|
||||
DB db = context.get("db");
|
||||
|
||||
Panel tab = (Panel)((Tabs)context.get("/mainTabs")).getSelectedComponent();
|
||||
if ( tab.getName() != "Host" )
|
||||
{
|
||||
db.flushCache();
|
||||
}
|
||||
|
||||
Worker w = worker("initTreeWorker", args(), Worker.RunOption.LET_FINISH_IF_RUNNING);
|
||||
if ( !w.isCancelled())
|
||||
LongRunningTask.detect("initTreeWorker", "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 ("Cut" == who || "Copy" == who || "Paste" == who )
|
||||
{
|
||||
Component compFocusOwner =
|
||||
KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
|
||||
|
||||
if ( compFocusOwner instanceof Editor)
|
||||
{
|
||||
Editor editor = (Editor)compFocusOwner;
|
||||
if ( "Cut" == who )
|
||||
{
|
||||
editor.cut();
|
||||
}
|
||||
else if ("Copy" == who)
|
||||
{
|
||||
editor.copy();
|
||||
}
|
||||
else if ("Paste" == who)
|
||||
{
|
||||
editor.paste();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ("Drop Table" == who)
|
||||
{
|
||||
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$mysql", 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 ("Create Database" == who)
|
||||
{
|
||||
if ( script("createDBDialog", args()) != null )
|
||||
{
|
||||
Tree schemaTree = context.get("/schemaTree");
|
||||
Worker w = worker("initTreeWorker", args(), Worker.RunOption.LET_FINISH_IF_RUNNING);
|
||||
if (!w.isCancelled())
|
||||
{
|
||||
LongRunningTask.detect("initTreeWorker", "progressWaiter", args(), w, 250);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if ("Create Table" == who)
|
||||
{
|
||||
if ( script("createTableDialogMySQL", args()) != null )
|
||||
{
|
||||
Tree schemaTree = context.get("/schemaTree");
|
||||
Worker w = worker("initTreeWorker", args(), Worker.RunOption.LET_FINISH_IF_RUNNING);
|
||||
if (!w.isCancelled())
|
||||
{
|
||||
LongRunningTask.detect("initTreeWorker", "progressWaiter", args(),w, 250);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if ("Drop Database" == who)
|
||||
{
|
||||
Tree schemaTree = context.get("/schemaTree");
|
||||
NodeInfo node = schemaTree.getSelectedNode();
|
||||
NodeInfo root = node.getParent();
|
||||
if ( node != null && "db".equals(node.getType()) )
|
||||
{
|
||||
Frame f = context.get("/");
|
||||
if (f.popupConfirm("Confirm Delete!", "Are you sure you want to drop db '" + node.getText() + "'?", "images/deletedb.gif"))
|
||||
{
|
||||
args().put("dbToDrop", node.getText());
|
||||
DB db = context.get("db");
|
||||
db.execute("drop database `" + node.getText() + "`");
|
||||
node.remove();
|
||||
schemaTree.select(root);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ("Print" == who)
|
||||
{
|
||||
//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 ("Import" == who)
|
||||
{
|
||||
script("importCSVDialog",args());
|
||||
}
|
||||
else if ("Export" == who)
|
||||
{
|
||||
script("exportDDLDialog",args());
|
||||
}
|
||||
else if ("User Manager" == who)
|
||||
{
|
||||
script ("userManagerDialog", args());
|
||||
}
|
||||
else if ("Load SQL File" == who)
|
||||
{
|
||||
Frame f = context.get("/");
|
||||
Tabs tabs = context.get("/mainTabs");
|
||||
tabs.select("Query");
|
||||
String file = f.openFile(null, "SQL Script Files", "sql");
|
||||
if (file != null)
|
||||
{
|
||||
Editor editor = context.get("/mainTabs/Query/editor");
|
||||
editor.setText(FileUtil.toString(file));
|
||||
editor.setProperty("filePath", file);
|
||||
}
|
||||
}
|
||||
else if ("Import CSV File" == who)
|
||||
{
|
||||
script("importCSVDialog",args());
|
||||
}
|
||||
else if ("Copy as CSV Data" == who)
|
||||
{
|
||||
String csv = (String)script("resultsToCSV",args());
|
||||
SystemUtil.copyToClipboard(csv);
|
||||
}
|
||||
else if ("Copy as HTML Data" == who)
|
||||
{
|
||||
String html = (String)script("resultsToHTML",args());
|
||||
SystemUtil.copyToClipboard(html);
|
||||
}
|
||||
else if ("Copy as XML Data" == who)
|
||||
{
|
||||
String xml = (String)script("resultsToXML",args());
|
||||
SystemUtil.copyToClipboard(xml);
|
||||
}
|
||||
else if ("Export Data..." == who)
|
||||
{
|
||||
DB.Result results = context.get("lastQueryResults");
|
||||
if ( results != null && !results.isEmpty())
|
||||
{
|
||||
Frame f = context.get("/");
|
||||
args().put("source", "exportAsFile");
|
||||
f.saveFileWithCallback("mainWindowEvents", args(), false, null, "CSV", "csv", "HTML", "html", "XML", "xml" );
|
||||
}
|
||||
}
|
||||
else if ("exportAsFile" == who)
|
||||
{
|
||||
String output = (String)script("resultsTo" + arg("fileType"), args());
|
||||
FileUtil.fromString(arg("filePath"), output);
|
||||
}
|
||||
else if ( "Export Tables as SQL" == who )
|
||||
{
|
||||
script("exportDDLDialog",args());
|
||||
}
|
||||
else if ( "Import Files Into Blob Fields" == who )
|
||||
{
|
||||
script("filesToBlobsDialog",args());
|
||||
}
|
||||
else if ("Maintenance" == who)
|
||||
{
|
||||
script("maintenanceDialog", args());
|
||||
}
|
||||
else if ("Help" == who )
|
||||
{
|
||||
script("helpDialog$" + context.get("vendor"), args());
|
||||
}
|
||||
|
||||
else if ( "Exit" == who )
|
||||
{
|
||||
System.exit(0);
|
||||
}
|
||||
else if ("Close" == who )
|
||||
{
|
||||
Frame window = context.get("/");
|
||||
script("removeFromWindowMenu", args());
|
||||
window.dispose();
|
||||
}
|
||||
else {
|
||||
((Frame)context.get("/")).popupMessage("Feature Unimplemented!");
|
||||
}
|
||||
|
||||
143
extra/jheidi/mainWindowEventsOracle.ajl
Normal file
143
extra/jheidi/mainWindowEventsOracle.ajl
Normal file
@@ -0,0 +1,143 @@
|
||||
import javax.swing.tree.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.Component;
|
||||
import java.awt.KeyboardFocusManager;
|
||||
|
||||
String who = arg("source");
|
||||
WindowContext context = argObj("windowContext");
|
||||
log.debug("Event received: " + who);
|
||||
|
||||
if ("New Connection" == who)
|
||||
{
|
||||
script("jheidi");
|
||||
}
|
||||
else if ("Refresh" == who)
|
||||
{
|
||||
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 ("Cut" == who || "Copy" == who || "Paste" == who )
|
||||
{
|
||||
Component compFocusOwner =
|
||||
KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
|
||||
|
||||
if ( compFocusOwner instanceof Editor)
|
||||
{
|
||||
Editor editor = (Editor)compFocusOwner;
|
||||
if ( "Cut" == who )
|
||||
{
|
||||
editor.cut();
|
||||
}
|
||||
else if ("Copy" == who)
|
||||
{
|
||||
editor.copy();
|
||||
}
|
||||
else if ("Paste" == who)
|
||||
{
|
||||
editor.paste();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ("Drop Table" == who)
|
||||
{
|
||||
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 ("Create Table" == who)
|
||||
{
|
||||
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 ("Print" == who)
|
||||
{
|
||||
//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 ( "Exit" == who )
|
||||
{
|
||||
System.exit(0);
|
||||
}
|
||||
else if ("Close" == who )
|
||||
{
|
||||
Frame window = context.get("/");
|
||||
script("removeFromWindowMenu", args());
|
||||
window.dispose();
|
||||
}
|
||||
else {
|
||||
((Frame)context.get("/")).popupMessage("Feature Unimplemented!");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user