!752 lib 1003435 // RSyntaxTextArea lib 1003943 // rstaui + resources import java.awt.BorderLayout; import java.awt.event.*; import javax.swing.*; import javax.swing.UIManager.LookAndFeelInfo; import javax.swing.text.BadLocationException; import org.fife.rsta.ui.CollapsibleSectionPanel; //import org.fife.rsta.ui.DocumentMap; import org.fife.rsta.ui.GoToDialog; import org.fife.rsta.ui.SizeGripIcon; import org.fife.rsta.ui.search.FindDialog; import org.fife.rsta.ui.search.ReplaceDialog; import org.fife.rsta.ui.search.ReplaceToolBar; import org.fife.rsta.ui.search.SearchEvent; import org.fife.rsta.ui.search.SearchListener; import org.fife.rsta.ui.search.FindToolBar; import org.fife.ui.rsyntaxtextarea.ErrorStrip; import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; import org.fife.ui.rsyntaxtextarea.SyntaxConstants; import org.fife.ui.rtextarea.RTextScrollPane; import org.fife.ui.rtextarea.SearchContext; import org.fife.ui.rtextarea.SearchEngine; import org.fife.ui.rtextarea.SearchResult; p { new RSTAUIDemoApp().setVisible(true); } /** * An application that demonstrates use of the RSTAUI project. Please don't * take this as good application design; it's just a simple example.
*
* Unlike the library itself, this class is public domain.
*
* @author Robert Futrell
* @version 1.0
*/
sclass RSTAUIDemoApp extends JFrame implements SearchListener {
private CollapsibleSectionPanel csp;
private RSyntaxTextArea textArea;
private FindDialog findDialog;
private ReplaceDialog replaceDialog;
private FindToolBar findToolBar;
private ReplaceToolBar replaceToolBar;
private StatusBar statusBar;
public RSTAUIDemoApp() {
initSearchDialogs();
JPanel contentPane = new JPanel(new BorderLayout());
setContentPane(contentPane);
csp = new CollapsibleSectionPanel();
contentPane.add(csp);
setJMenuBar(createMenuBar());
textArea = new RSyntaxTextArea(25, 80);
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
textArea.setCodeFoldingEnabled(true);
textArea.setMarkOccurrences(true);
RTextScrollPane sp = new RTextScrollPane(textArea);
csp.add(sp);
ErrorStrip errorStrip = new ErrorStrip(textArea);
contentPane.add(errorStrip, BorderLayout.LINE_END);
//org.fife.rsta.ui.DocumentMap docMap = new org.fife.rsta.ui.DocumentMap(textArea);
//contentPane.add(docMap, BorderLayout.LINE_END);
statusBar = new StatusBar();
contentPane.add(statusBar, BorderLayout.SOUTH);
setTitle("RSTAUI Demo Application");
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
setLocationRelativeTo(null);
}
private void addItem(Action a, ButtonGroup bg, JMenu menu) {
JRadioButtonMenuItem item = new JRadioButtonMenuItem(a);
bg.add(item);
menu.add(item);
}
private JMenuBar createMenuBar() {
JMenuBar mb = new JMenuBar();
JMenu menu = new JMenu("Search");
menu.add(new JMenuItem(new ShowFindDialogAction()));
menu.add(new JMenuItem(new ShowReplaceDialogAction()));
menu.add(new JMenuItem(new GoToLineAction()));
menu.addSeparator();
int ctrl = getToolkit().getMenuShortcutKeyMask();
int shift = InputEvent.SHIFT_MASK;
KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_F, ctrl|shift);
Action a = csp.addBottomComponent(ks, findToolBar);
a.putValue(Action.NAME, "Show Find Search Bar");
menu.add(new JMenuItem(a));
ks = KeyStroke.getKeyStroke(KeyEvent.VK_H, ctrl|shift);
a = csp.addBottomComponent(ks, replaceToolBar);
a.putValue(Action.NAME, "Show Replace Search Bar");
menu.add(new JMenuItem(a));
mb.add(menu);
menu = new JMenu("LookAndFeel");
ButtonGroup bg = new ButtonGroup();
LookAndFeelInfo[] infos = UIManager.getInstalledLookAndFeels();
for (int i=0; i