📄 rtextoptionsdialog.java
字号:
/*
* 03/25/2004
*
* RTextOptionsDialog.java - Options dialog for RText.
* Copyright (C) 2004 Robert Futrell
* email@address.com
* www.website.com
*
* This file is a part of RText.
*
* RText 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.
*
* RText 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.fife.rtext;
import java.awt.Frame;
import java.util.ResourceBundle;
import javax.swing.Action;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.UIManager;
import org.fife.ui.OptionsDialog;
import org.fife.ui.OptionsDialogPanel;
import org.fife.ui.rtextarea.RTextArea;
import org.fife.ui.rtextarea.RTextAreaOptionPanel;
import org.fife.ui.rtextfilechooser.RTextFileChooserOptionPanel;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextAreaOptionPanel;
import org.fife.ui.rsyntaxtextarea.TemplateOptionPanel;
/**
* The options dialog used by RText.
*
* @author Robert Futrell
* @version 0.3
*/
class RTextOptionsDialog extends OptionsDialog {
private RText owner;
/*****************************************************************************/
/**
* Constructor.
*
* @param owner The parent of this dialog.
*/
public RTextOptionsDialog(RText owner) {
super(owner);
this.owner = owner;
}
/*****************************************************************************/
/**
* Constructor.
*
* @param owner The parent of this dialog.
* @param optionsPanels The option panels to add to this options dialog.
* Note that this array MUST have at least one
* panel in it; otherwise, this constructor will
* throw a <code>NullPointerException</code>.
* @see org.fife.ui.OptionsDialog#OptionsDialog
* @see OptionsDialogPanel
*/
public RTextOptionsDialog(RText owner, OptionsDialogPanel[] optionsPanels) {
super(owner, optionsPanels);
this.owner = owner;
}
/*****************************************************************************/
/**
* Applies all changes specified in the Options dialog to the current
* RText session.
*
* @param owner The RText frame.
*/
public void doApplyImpl(Frame owner) {
RText rtext = (RText)owner;
AbstractMainView mainView = rtext.getMainView();
OptionsDialogPanel[] panels = getOptionsDialogPanels();
int numPanels = panels.length;
for (int i=0; i<numPanels; i++) {
OptionsDialogPanel currentPanel = panels[i];
if (currentPanel instanceof GeneralOptionPanel) {
GeneralOptionPanel gop = (GeneralOptionPanel)currentPanel;
rtext.setWorkingDirectory(gop.getWorkingDirectory()); // Doesn't update if not necessary.
}
else if (currentPanel instanceof UIOptionPanel) {
UIOptionPanel uiop = (UIOptionPanel)currentPanel;
mainView.setDocumentSelectionPlacement(uiop.getDocumentSelectionPlacement()); // Doesn't update if it doesn't have to.
RTextUtilities.setLookAndFeel(rtext, uiop.getLookAndFeelClassName()); // Doesn't update if...
rtext.setIconGroupByName(uiop.getIconGroupName()); // Doesn't update if it doesn't have to.
mainView.setHighlightModifiedDocumentDisplayNames(uiop.highlightModifiedDocumentDisplayNames());
mainView.setModifiedDocumentDisplayNamesColor(uiop.getModifiedDocumentDisplayNamesColor());
rtext.setMainViewStyle(uiop.getMainViewStyle()); // Doesn't update if it doesn't have to.
mainView = rtext.getMainView(); // In case mainView changed in the line above.
rtext.getStatusBar().setStyle(uiop.getStatusBarStyle());
}
else if (currentPanel instanceof PrintingOptionPanel) {
PrintingOptionPanel pop = (PrintingOptionPanel)currentPanel;
mainView.setPrintFont(pop.getPrintFont()); // Doesn't effect GUI.
//mainView.setUsePrintHeader(pop.getUsePrintHeader());
//mainView.setUsePrintFooter(pop.getUsePrintFooter());
}
else if (currentPanel instanceof RTextAreaOptionPanel) {
RTextAreaOptionPanel taop = (RTextAreaOptionPanel)currentPanel;
mainView.setCaretColor(taop.getCaretColor()); // Doesn't update if it doesn't have to.
mainView.setSelectionColor(taop.getSelectionColor()); // Doesn't update if it doesn't have to.
mainView.setMarkAllHighlightColor(taop.getMarkAllHighlightColor()); // Doesn't update if it doesn't have to.
mainView.setCaretStyle(RTextArea.INSERT_MODE, taop.getCaretStyle(RTextArea.INSERT_MODE)); // Ditto.
mainView.setCaretStyle(RTextArea.OVERWRITE_MODE, taop.getCaretStyle(RTextArea.OVERWRITE_MODE)); // Ditto.
mainView.setCaretBlinkRate(taop.getBlinkRate()); // Ditto.
mainView.setBackgroundObject(taop.getBackgroundObject());
mainView.setBackgroundImageFileName(taop.getBackgroundImageFileName());
mainView.setLineWrap(taop.getWordWrap());
((StatusBar)rtext.getStatusBar()).setRowColumnIndicatorVisible(!mainView.getLineWrap());
if (taop.isCurrentLineHighlightCheckboxSelected()==true) {
mainView.setCurrentLineHighlightEnabled(true);
mainView.setCurrentLineHighlightColor(taop.getCurrentLineHighlightColor());
}
else {
mainView.setCurrentLineHighlightEnabled(false);
}
mainView.setTabSize(taop.getTabSize()); // Doesn't update if it doesn't have to.
mainView.setTabsEmulated(taop.getEmulateTabs()); // Doesn't update if it doesn't have to.
mainView.setMarginLineEnabled(taop.isMarginLineEnabled()); // Doesn't update if it doesn't have to.
mainView.setMarginLinePosition(taop.getMarginLinePosition()); // Doesn't update if it doesn't have to.
mainView.setMarginLineColor(taop.getMarginLineColor()); // Doesn't update if it doesn't have to.
mainView.setRoundedSelectionEdges(taop.getRoundedSelection()); // Doesn't update if it doesn't have to.
// The syntax highlighting panel is a child panel.
RSyntaxTextAreaOptionPanel rstaop = (RSyntaxTextAreaOptionPanel)currentPanel.getChildPanel(0);
rtext.setSyntaxHighlightingColorScheme(rstaop.getSyntaxHighlightingColorScheme()); // Doesn't update if it doesn't have to.
boolean bmEnabled = rstaop.isBracketMatchCheckboxSelected();
mainView.setBracketMatchingEnabled(bmEnabled); // Doesn't update if it doesn't have to.
mainView.setMatchedBracketBGColor(rstaop.getBracketMatchBGColor()); // Doesn't update if it doesn't have to.
mainView.setMatchedBracketBorderColor(rstaop.getBracketMatchBorderColor()); // Doesn't update if it doesn't have to.
mainView.setWhitespaceVisible(rstaop.isWhitespaceVisible()); // (RSyntaxTextArea) doesn't update if not necessary.
mainView.setSmoothTextEnabled(rstaop.isSmoothTextEnabled()); // Doesn't update if not necessary.
mainView.setFractionalFontMetricsEnabled(rstaop.isFractionalFontMetricsEnabled()); // Doesn't update if not necessary.
// The template panel is the second child.
TemplateOptionPanel top = (TemplateOptionPanel)currentPanel.getChildPanel(1);
top.updateCodeTemplateManager();
// The macro panel is the third child.
MacroOptionPanel mop = (MacroOptionPanel)currentPanel.getChildPanel(2);
// Nothing to do here...
}
else if (currentPanel instanceof LanguageOptionPanel) {
LanguageOptionPanel lop = (LanguageOptionPanel)currentPanel;
rtext.setLanguage(lop.getSelectedLanguage());
}
else if (currentPanel instanceof FileFilterOptionPanel) {
FileFilterOptionPanel ffop = (FileFilterOptionPanel)currentPanel;
mainView.setSyntaxFilters(ffop.getSyntaxFilters());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -