private void showHelp(String help[]) { txtCommand.setText(help[0]); bHelp = true; pResult.removeAll(); pResult.add(txtResultScroll, BorderLayout.CENTER); pResult.doLayout(); txtResult.setText(help[1]); pResult.repaint(); txtCommand.requestFocus(); txtCommand.setCaretPosition(help[0].length()); }
private void updateResult() { if (iResult == 0) { // in case 'help' has removed the grid if (bHelp) { pResult.removeAll(); pResult.add(gScrollPane, BorderLayout.CENTER); pResult.doLayout(); gResult.fireTableChanged(null); pResult.repaint(); bHelp = false; } } else { showResultInText(); } txtCommand.selectAll(); txtCommand.requestFocus(); }
void main() { CommonSwing.setDefaultColor(); fMain = new JFrame("HSQL Database Manager"); // (ulrivo): An actual icon. fMain.getContentPane().add(createToolBar(), "North"); fMain.setIconImage(CommonSwing.getIcon()); fMain.addWindowListener(this); JMenuBar bar = new JMenuBar(); // used shortcuts: CERGTSIUDOLM String fitems[] = { "-Connect...", "--", "-Open Script...", "-Save Script...", "-Save Result...", "--", "-Exit" }; addMenu(bar, "File", fitems); String vitems[] = {"RRefresh Tree", "--", "GResults in Grid", "TResults in Text"}; addMenu(bar, "View", vitems); String sitems[] = { "SSELECT", "IINSERT", "UUPDATE", "DDELETE", "---", "-CREATE TABLE", "-DROP TABLE", "-CREATE INDEX", "-DROP INDEX", "--", "-CHECKPOINT", "-SCRIPT", "-SET", "-SHUTDOWN", "--", "-Test Script" }; addMenu(bar, "Command", sitems); mRecent = new JMenu("Recent"); bar.add(mRecent); String soptions[] = { "-AutoCommit on", "-AutoCommit off", "OCommit", "LRollback", "--", "-Disable MaxRows", "-Set MaxRows to 100", "--", "-Logging on", "-Logging off", "--", "-Insert test data" }; addMenu(bar, "Options", soptions); String stools[] = {"-Dump", "-Restore", "-Transfer"}; addMenu(bar, "Tools", stools); fMain.setJMenuBar(bar); initGUI(); sRecent = new String[iMaxRecent]; Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); Dimension size = fMain.getSize(); // (ulrivo): full size on screen with less than 640 width if (d.width >= 640) { fMain.setLocation((d.width - size.width) / 2, (d.height - size.height) / 2); } else { fMain.setLocation(0, 0); fMain.setSize(d); } fMain.show(); // (ulrivo): load query from command line if (defScript != null) { if (defDirectory != null) { defScript = defDirectory + File.separator + defScript; } // if insert stmet is thousands of records...skip showing it // as text. Too huge. StringBuffer buf = new StringBuffer(); ifHuge = DatabaseManagerCommon.readFile(defScript); if (4096 <= ifHuge.length()) { buf.append("This huge file cannot be edited. Please execute\n"); txtCommand.setText(buf.toString()); } else { txtCommand.setText(ifHuge); } } txtCommand.requestFocus(); }