📄 defaulttexteditorcontainer.java
字号:
/* * DefaultTextEditorContainer.java * * Copyright (C) 2002, 2003, 2004, 2005, 2006 Takis Diakoumis * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * */package org.executequery.gui.text;import java.awt.Component;import java.awt.LayoutManager;import java.awt.print.Printable;import javax.swing.JPanel;import javax.swing.text.JTextComponent;import org.executequery.Constants;import org.executequery.GUIUtilities;import org.executequery.print.TextPrinter;/* ---------------------------------------------------------- * CVS NOTE: Changes to the CVS repository prior to the * release of version 3.0.0beta1 has meant a * resetting of CVS revision numbers. * ---------------------------------------------------------- *//** * Default TextEditor combined with TextEditorContainer implementation. * * @author Takis Diakoumis * @version $Revision: 1.4 $ * @date $Date: 2006/05/14 06:56:52 $ */public class DefaultTextEditorContainer extends JPanel implements TextEditor, TextEditorContainer { /** the text component contained within this panel */ protected JTextComponent textComponent; /** * Creates a new instance of DefaultTextEditorContainer. */ public DefaultTextEditorContainer() {} /** * Creates a new instance of DefaultTextEditorContainer with * the specified layout manager for this panel. */ public DefaultTextEditorContainer(LayoutManager layout) { super(layout); } /** * Returns the TextEditor component that this container holds. */ public TextEditor getTextEditor() { return this; } /** * Returns the default focus component for this panel. * * @return the text component */ public Component getDefaultFocusComponent() { return textComponent; } /** * Pastes text from the system clipboard into the text component. */ public void paste() { textComponent.paste(); } /** * Copies text to the system clipboard from the text component. */ public void copy() { textComponent.copy(); } /** * Cuts selected text from the text component. */ public void cut() { textComponent.cut(); } /** * Kicks off a save or save as process for the text components * contents as specified. * * @param saveAs - whether this is a save as call. When this is false * the contents are saved to some already known file name * and path. Otherwise the standard save dialog is shown. */ public int save(boolean saveAs) { return TextUtilities.save(textComponent); } /** * Returns the actual text component encapsulated by this panel. */ public JTextComponent getEditorTextComponent() { return textComponent; } /** * Sets the text component text to that specified. * * @param s - the text to be set in the editor text component */ public void setEditorText(String s) { try { textComponent.setText(s); } catch (OutOfMemoryError e) { System.gc(); GUIUtilities.displayErrorMessage("Out of Memory.\nThe file is " + "too large to\nopen for viewing."); textComponent.setText(Constants.EMPTY); return; } } public String getEditorText() { return textComponent.getText(); } public void changeSelectionCase(boolean upper) { TextUtilities.changeSelectionCase(textComponent, upper); } public void deleteLine() { TextUtilities.deleteLine(textComponent); } public void deleteWord() { TextUtilities.deleteWord(textComponent); } public void deleteSelection() { TextUtilities.deleteSelection(textComponent); } public void insertFromFile() { TextUtilities.insertFromFile(textComponent); } public void selectAll() { TextUtilities.selectAll(textComponent); } public void selectNone() { TextUtilities.selectNone(textComponent); } public void insertLineAfter() { TextUtilities.insertLineAfter(textComponent); } public void insertLineBefore() { TextUtilities.insertLineBefore(textComponent); } public boolean promptToSave() { return false; } public void disableUpdates(boolean disable) {} public boolean canSearch() { return true; } public boolean canPrint() { return true; } public Printable getPrintable() { return new TextPrinter(textComponent.getText()); } public String getPrintJobName() { return "Execute Query"; } public String getDisplayName() { return Constants.EMPTY; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -