⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 queryeditor.java

📁 eq跨平台查询工具源码 eq跨平台查询工具源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            GUIUtilities.showNormalCursor();        }    }    /**     * Sets the text of the editor pane to the next     * query available in the history list. Where no     * next query exists, nothing is changed.     */    public void selectNextQuery() {        try {            GUIUtilities.showWaitCursor();            editor.selectNextQuery();        }        finally {            GUIUtilities.showNormalCursor();        }    }        /**     * Enables/disables the show meta data button.     */    public void setMetaDataButtonEnabled(boolean enable) {        if (holdMetaData) {            getTools().setMetaDataButtonEnabled(enable);        }        else {            getTools().setMetaDataButtonEnabled(false);        }    }        /**     * Sets the history next button enabled as specified.     */    public void setNextButtonEnabled(boolean enabled) {        getTools().setNextButtonEnabled(enabled);    }    /**     * Sets the history previous button enabled as specified.     */    public void setPreviousButtonEnabled(boolean enabled) {        getTools().setPreviousButtonEnabled(enabled);    }    /**     * Enables/disables the transaction related buttons.     */    public void setCommitsEnabled(boolean enable) {        getTools().setCommitsEnabled(enable);    }    /**     * Enables/disables the export result set button.     */    public void setExportButtonEnabled(boolean enable) {        getTools().setExportButtonEnabled(enable);    }        /**     * Enables/disables the query execution stop button.     */    public void setStopButtonEnabled(boolean enable) {                getTools().setStopButtonEnabled(enable);    }    /**     * Updates the interface and any system buttons as      * required on a focus gain.     */    public void focusGained() {        QueryEditorToolBar tools = getTools();        tools.setMetaDataButtonEnabled(                resultsPanel.hasResultSetMetaData() && holdMetaData);                tools.setCommitsEnabled(!editor.getCommitMode());        tools.setNextButtonEnabled(editor.hasNextHistory());        tools.setPreviousButtonEnabled(editor.hasPreviousHistory());        tools.setStopButtonEnabled(editor.isExecuting());        tools.setExportButtonEnabled(resultsPanel.isResultSetSelected());        editor.setTextFocus();    }        /**     * Does nothing.     */    public void focusLost() {}    private QueryEditorToolBar getTools() {        return toolBar;    }        public void destroyConnection() {        editor.destroyConnection();    }        public void toggleCommitMode() {        boolean mode = !editor.getCommitMode();        editor.setCommitMode(mode);        getTools().setCommitsEnabled(!mode);        //setRightStatusText(" Auto-Commit:  " + mode);    }            // --------------------------------------------    // TabView implementation    // --------------------------------------------    /**     * Indicates the panel is being removed from the pane     */    public boolean tabViewClosing() {        // check if we are saving        if (SystemUtilities.isPromptingToSave() && contentChanged) {            if (!GUIUtilities.saveOpenChanges(this)) {                return false;            }        }        cleanup();        return true;    }    /**     * Indicates the panel is being selected in the pane     */    public boolean tabViewSelected() {        focusGained();        return true;    }    /**     * Indicates the panel is being de-selected in the pane     */    public boolean tabViewDeselected() {        return true;    }    // --------------------------------------------    /**     * Performs any resource clean up for a pending removal.     */    public void cleanup() {        editor.closingEditor();        resultsPanel.cleanup();        statusBar.cleanup();                resultsPanel = null;        statusBar = null;        toolBar = null;        editor = null;        removeAll();        EventMediator.deregisterListener(EventMediator.CONNECTION_EVENT, this);        EventMediator.deregisterListener(EventMediator.KEYWORD_EVENT, this);        GUIUtilities.registerUndoRedoComponent(null);    }    public void closeConnection() {        //editor.closeConnection();    }    public void interruptStatement() {        editor.interruptStatement();    }        public String getOpenFilePath() {        return absolutePath;    }        public void clearOutputPane() {        resultsPanel.clearOutputPane();    }        public void selectAll() {        editor.selectAll();    }        public void goToRow(int row) {        editor.goToRow(row);    }        public void selectNone() {        editor.selectNone();    }        public Vector getHistoryList() {        return editor.getHistoryList();    }        /**     * Executes the currently selected query text.     */    public void executeSelection() {        String query = editor.getSelectedText();        if (query != null) {            executeSQLQuery(query);        }    }        /**     * Returns the currently selcted connection properties object.     *     * @return the selected connection     */    public DatabaseConnection getSelectedConnection() {        if (connectionsCombo.getSelectedIndex() != -1) {            return (DatabaseConnection)connectionsCombo.getSelectedItem();        }        return null;    }        /**     * Executes the specified query.     *     * @param the query     */    public void executeSQLQuery(String query) {        if (query == null) {            query = editor.getQueryAreaText();        }        editor.resetExecutingLine();        resultsPanel.setExecutingSingle(false);        DatabaseConnection dc = (DatabaseConnection)connectionsCombo.getSelectedItem();         editor.executeSQLQuery(dc, query);    }    protected void setExecutingSingle(boolean executingSingle) {        resultsPanel.setExecutingSingle(executingSingle);    }        public void executeSQLAtCursor() {        resultsPanel.setExecutingSingle(true);        DatabaseConnection dc = (DatabaseConnection)                        connectionsCombo.getSelectedItem();        editor.executeSQLAtCursor(dc);    }    public JTextComponent getEditorTextComponent() {        return editor.getQueryArea();    }        /**     * Adds a comment tag to the beginning of the current line     * or selected lines.     */    public void addCommentToLines() {        editor.addCommentToLines();    }    /**     * Removes a comment tag from the current line or selected lines.     */    public void removeCommentFromLines() {        editor.removeCommentFromLines();    }    /**     * Shifts the text on the current line or the currently     * selected text to the right one TAB.     */    public void shiftTextRight() {        editor.shiftTextRight();    }    /**     * Shifts the text on the current line or the currently     * selected text to the left one TAB.     */    public void shiftTextLeft() {        editor.shiftTextLeft();    }    /**     * Sets the editor's text content that specified.     *     * @param s - the text to be set     */    public void setEditorText(String s) {        editor.setQueryAreaText(s);    }        /**     * Moves the caret to the beginning of the specified query.     *     * @param query - the query to move the cursor to     */    public void caretToQuery(String query) {        editor.caretToQuery(query);    }    /**     * Loads the specified text into a blank 'offscreen' document     * before switching to the SQL document.     */    public void loadText(String text) {        editor.loadText(text);    }        public String getEditorText() {        return editor.getQueryAreaText();    }        public void setOutputMessage(int type, String text) {        resultsPanel.setOutputMessage(type, text);        revalidate();    }    public boolean isOpenFile() {        return openFile;    }        /**     * Sets the state for an open file.     *     * @param the absolute file path     */    public void setAbsoluteFile(String absolutePath) {        this.absolutePath = absolutePath;        openFile = !(MiscUtils.isNull(absolutePath));        if (openFile) {            String separator = System.getProperty("file.separator");            int index = absolutePath.lastIndexOf(separator);            if (index != -1) {                fileName = absolutePath.substring(index + 1);            } else {                fileName = absolutePath;            }        } else {            fileName = defaultFileName;        }    }        /**     * Returns whether the text component is in a printable state.     *     * @return true | false     */    public boolean canPrint() {        return true;    }        public void setPrintingText(boolean printingText) {        this.printingText = printingText;    }        public Printable getPrintable() {/*    PrintSelectDialog dialog = new PrintSelectDialog(this);    int selection = dialog.display();     dialog.dispose();    dialog = null;       if (selection == PrintSelectDialog.EDITOR_TEXT)        return new TextPrinter(editor.getQueryAreaText());       else if (selection == PrintSelectDialog.RESULTS_TABLE)        return new TablePrinter(resultsPanel.getResultsTable(),                                "Query: " + editor.getQueryAreaText());       else        return null; */        String text = editor.getQueryAreaText();                if (printingText) {            return new TextPrinter(text);        } else {            /*            JTable table = resultsPanel.getResultsTable();            return table.getPrintable(JTable.PrintMode.NORMAL,                                       new MessageFormat("Query: " + text),                                       new MessageFormat("Page {0}"));            */            return new TablePrinter(resultsPanel.getResultsTable(),                                        "Query: " + text);                     }            }        public String getPrintJobName() {        return "Execute Query - editor";    }        // ---------------------------------------------    // TextEditor implementation    // ---------------------------------------------    public void paste() {        editor.paste();    }        public void copy() {        editor.copy();    }        public void cut() {        editor.cut();    }        public void deleteLine() {        editor.deleteLine();    }        public void deleteWord() {        editor.deleteWord();    }        public void deleteSelection() {        editor.deleteSelection();    }        public void insertFromFile() {        editor.insertFromFile();    }        public void insertLineAfter() {        editor.insertLineAfter();    }        public void insertLineBefore() {        editor.insertLineBefore();    }        public void changeSelectionCase(boolean upper) {        editor.changeSelectionCase(upper);    }        // ---------------------------------------------        // ---------------------------------------------    // SaveFunction implementation    // ---------------------------------------------        public String getDisplayName() {        return toString();    }        public boolean promptToSave() {        return contentChanged;    }        public int save(boolean saveAs) {        TextFileWriter writer = null;        String text = editor.getQueryAreaText();                if (openFile && !saveAs) {            writer = new TextFileWriter(text, absolutePath);        }        else {            writer = new TextFileWriter(text, new File(defaultFileName));        }                int result = writer.write();        if (result == SaveFunction.SAVE_COMPLETE) {            File file = writer.getSavedFile();            String name = file.getName();            GUIUtilities.setTabTitleForComponent(this, TITLE + " - " + name);            absolutePath = file.getAbsolutePath();            statusBar.setStatus(" File saved to " + name);            openFile = true;            contentChanged = false;        }        return result;            }        // ---------------------------------------------        /**     * Returns the display name of this panel. This may     * include the path of any open file.     *     * @return the display name     */    public String toString() {        if (openFile) {            return TITLE + " - " + fileName;        } else {            return TITLE + " - " + defaultFileName;        }    }    /**     * Returns whether the content has changed for a      * possible document save.     *     * @return true if text content changed, false otherwise     */    public boolean isContentChanged() {        return contentChanged;    }        /**     * Sets that the text content of the editor has changed from     * the original or previously saved state.     *     * @param true | false     */    public void setContentChanged(boolean contentChanged) {        this.contentChanged = contentChanged;    }    // ---------------------------------------------    // ConnectionListener implementation    // ---------------------------------------------        /**     * Indicates a connection has been established.     *      * @param the encapsulating event     */    public void connected(ConnectionEvent connectionEvent) {        connectionsModel.addElement(connectionEvent.getSource());        connectionsCombo.setEnabled(true);    }    /**     * Indicates a connection has been closed.     *      * @param the encapsulating event     */    public void disconnected(ConnectionEvent connectionEvent) {        connectionsModel.removeElement(connectionEvent.getSource());        if (connectionsModel.getSize() == 0) {            connectionsCombo.setEnabled(false);        }        // TODO: NEED TO CHECK OPEN CONN            }    // ---------------------------------------------    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -