jreepad-cvs Mailing List for Jreepad - Java Treepad Editor (Page 2)
Brought to you by:
danstowell
You can subscribe to this list here.
2007 |
Jan
(33) |
Feb
(19) |
Mar
(14) |
Apr
(10) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(5) |
Oct
|
Nov
|
Dec
|
---|
From: PeWu <pe...@us...> - 2007-03-15 12:47:11
|
Update of /cvsroot/jreepad/jreepad/src/jreepad In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv22251/src/jreepad Modified Files: TreeView.java Log Message: Code cleanup Index: TreeView.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/TreeView.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TreeView.java 26 Jan 2007 22:38:37 -0000 1.3 --- TreeView.java 15 Mar 2007 12:46:05 -0000 1.4 *************** *** 43,47 **** public class TreeView extends JTree { ! private JreepadTreeModel treeModel; public TreeView(JreepadTreeModel treeModel) --- 43,48 ---- public class TreeView extends JTree { ! private static final String UNTITLED_NODE_TEXT = "<Untitled node>"; ! private JreepadTreeModel treeModel; public TreeView(JreepadTreeModel treeModel) *************** *** 68,77 **** public void editingCanceled(ChangeEvent e) { ! ensureNodeTitleIsNotEmpty(e); } public void editingStopped(ChangeEvent e) { ! ensureNodeTitleIsNotEmpty(e); } }); --- 69,78 ---- public void editingCanceled(ChangeEvent e) { ! ensureNodeTitleIsNotEmpty(); } public void editingStopped(ChangeEvent e) { ! ensureNodeTitleIsNotEmpty(); } }); *************** *** 79,83 **** // Add mouse listener - this will be used to implement drag-and-drop, context menu (?), etc addMouseListener(new TreeViewMouseListener()); - } --- 80,83 ---- *************** *** 87,109 **** JreepadNode lastEditedNode = (JreepadNode)(getSelectionPath().getLastPathComponent()); if (lastEditedNode.getTitle().equals("")) ! lastEditedNode.setTitle("<Untitled node>"); } ! private void ensureNodeTitleIsNotEmpty(ChangeEvent e) ! { ! TreeCellEditor theEditor = (TreeCellEditor)getCellEditor(); ! String newTitle = (String)(theEditor.getCellEditorValue()); ! ! // JreepadNode thatNode = (JreepadNode)(tree.getEditingPath().getLastPathComponent()); ! // System.out.println("ensureNodeTitleIsNotEmpty(): Event source = " + e.getSource()); ! // System.out.println("ensureNodeTitleIsNotEmpty(): thatNode = " + thatNode); ! // System.out.println("getCellEditorValue() = " + newTitle); ! if(newTitle.equals("")) ! { ! theEditor.getTreeCellEditorComponent(this, "<Untitled node>", true, true, false, 1); ! // thatNode.setTitle("<Untitled node>"); ! } ! } public void moveNode(JreepadNode node, JreepadNode newParent) --- 87,102 ---- JreepadNode lastEditedNode = (JreepadNode)(getSelectionPath().getLastPathComponent()); if (lastEditedNode.getTitle().equals("")) ! lastEditedNode.setTitle(UNTITLED_NODE_TEXT); } ! private void ensureNodeTitleIsNotEmpty() ! { ! TreeCellEditor theEditor = getCellEditor(); ! String newTitle = (String) (theEditor.getCellEditorValue()); ! if (newTitle.equals("")) ! theEditor.getTreeCellEditorComponent(this, UNTITLED_NODE_TEXT, ! true, true, false, 1); ! } public void moveNode(JreepadNode node, JreepadNode newParent) *************** *** 112,120 **** // - otherwise things would go really wonky! if (node.isNodeDescendant(newParent)) - { return; - } - - // DEL storeForUndo(); JreepadNode oldParent = node.getParentNode(); --- 105,109 ---- *************** *** 129,144 **** expanded = new Vector(); while (enumer.hasMoreElements()) ! { ! expanded.add((TreePath)enumer.nextElement()); ! // System.out.println(expanded.lastElement()); ! } } ! node.removeFromParent(); ! newParent.add(node); treeModel.reload(oldParent); treeModel.reload(newParent); - // treeModel.reload((TreeNode)tree.getPathForRow(0).getLastPathComponent()); // If the destination node didn't previously have any children, then we'll expand it --- 118,128 ---- expanded = new Vector(); while (enumer.hasMoreElements()) ! expanded.add(enumer.nextElement()); } ! newParent.add(node); // Also removes from old parent treeModel.reload(oldParent); treeModel.reload(newParent); // If the destination node didn't previously have any children, then we'll expand it |
From: PeWu <pe...@us...> - 2007-03-15 12:47:11
|
Update of /cvsroot/jreepad/jreepad/src/jreepad In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv22597/src/jreepad Modified Files: JreepadViewer.java Log Message: Structured menu creating methods Index: JreepadViewer.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadViewer.java,v retrieving revision 1.51 retrieving revision 1.52 diff -C2 -d -r1.51 -r1.52 *** JreepadViewer.java 12 Feb 2007 21:47:28 -0000 1.51 --- JreepadViewer.java 15 Mar 2007 12:46:19 -0000 1.52 *************** *** 102,175 **** private JButton nodeUrlDisplayOkButton; ! private JMenuBar menuBar; ! private JMenu fileMenu; ! private JMenuItem newMenuItem; ! private JMenuItem openMenuItem; private JMenu openRecentMenu; - private JMenuItem saveMenuItem; - private JMenuItem saveAsMenuItem; - private JMenuItem backupToMenuItem; - private JMenuItem printSubtreeMenuItem; - private JMenuItem printArticleMenuItem; - private JMenu importMenu; - private JMenuItem importHjtMenuItem; - private JMenuItem importTextMenuItem; - private JMenuItem importTextAsListMenuItem; - private JMenu exportMenu; - private JMenuItem exportHjtMenuItem; - private JMenuItem exportHtmlMenuItem; - private JMenuItem exportSimpleXmlMenuItem; - private JMenuItem exportListMenuItem; - private JMenuItem exportTextMenuItem; - private JMenuItem exportSubtreeTextMenuItem; - private JMenuItem quitMenuItem; - private JMenu editMenu; - private JMenuItem newFromClipboardMenuItem; private JMenuItem undoMenuItem; private JMenuItem redoMenuItem; - private JMenuItem editNodeTitleMenuItem; - private JMenuItem addAboveMenuItem; - private JMenuItem addBelowMenuItem; - private JMenuItem addChildMenuItem; - private JMenuItem deleteMenuItem; - private JMenuItem upMenuItem; - private JMenuItem downMenuItem; - private JMenuItem indentMenuItem; - private JMenuItem outdentMenuItem; - private JMenuItem expandAllMenuItem; - private JMenuItem collapseAllMenuItem; - private JMenuItem sortMenuItem; - private JMenuItem sortRecursiveMenuItem; - private JMenu searchMenu; - private JMenuItem searchMenuItem; private JMenuItem webSearchMenuItem; - private JMenuItem launchUrlMenuItem; - private JMenuItem thisNodesUrlMenuItem; private JMenuItem characterWrapArticleMenuItem; - private JMenuItem stripTagsMenuItem; - private JMenuItem insertDateMenuItem; - private JMenu viewMenu; - private JMenuItem viewBothMenuItem; - private JMenuItem viewTreeMenuItem; - private JMenuItem viewArticleMenuItem; - private JMenu viewToolbarMenu; private JCheckBoxMenuItem viewToolbarIconsMenuItem; private JCheckBoxMenuItem viewToolbarTextMenuItem; private JCheckBoxMenuItem viewToolbarOffMenuItem; - // private JMenuItem renderHtmlMenuItem; - private JMenuItem articleViewModeMenuItem; - private JMenuItem articleViewModeTextMenuItem; - private JMenuItem articleViewModeHtmlMenuItem; - private JMenuItem articleViewModeCsvMenuItem; - private JMenuItem articleViewModeTextileMenuItem; - private JMenu optionsMenu; - private JMenuItem autoSaveMenuItem; - private JMenuItem prefsMenuItem; - private JMenu helpMenu; - private JMenuItem keyboardHelpMenuItem; - private JMenuItem linksHelpMenuItem; - private JMenuItem dragDropHelpMenuItem; - private JMenuItem aboutMenuItem; - private JMenuItem licenseMenuItem; private ColouredStrip funkyGreenStrip; --- 102,114 ---- private JButton nodeUrlDisplayOkButton; ! private JMenu openRecentMenu; private JMenuItem undoMenuItem; private JMenuItem redoMenuItem; private JMenuItem webSearchMenuItem; private JMenuItem characterWrapArticleMenuItem; private JCheckBoxMenuItem viewToolbarIconsMenuItem; private JCheckBoxMenuItem viewToolbarTextMenuItem; private JCheckBoxMenuItem viewToolbarOffMenuItem; private ColouredStrip funkyGreenStrip; *************** *** 374,560 **** // Used by the constructor ! public void establishMenus() { // Create the menu bar ! menuBar = new JMenuBar(); ! // ! fileMenu = new JMenu(lang.getString("MENU_FILE")); //"File"); ! editMenu = new JMenu(lang.getString("MENU_EDIT")); //"Edit"); ! searchMenu = new JMenu(lang.getString("MENU_ACTIONS")); //"Actions"); ! viewMenu = new JMenu(lang.getString("MENU_VIEW")); //"View"); ! optionsMenu = new JMenu(lang.getString("MENU_OPTIONS")); //"Options"); ! helpMenu = new JMenu(lang.getString("MENU_HELP")); //"Help"); ! // ! newMenuItem = new JMenuItem(lang.getString("MENUITEM_NEW")); //"New"); ! newMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { newAction();}}); ! fileMenu.add(newMenuItem); ! // newWindowMenuItem = new JMenuItem("New window"); ! // newWindowMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { new JreepadViewer();}}); ! // fileMenu.add(newWindowMenuItem); ! openMenuItem = new JMenuItem(lang.getString("MENUITEM_OPEN")); //"Open"); ! openMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {openAction();}}); ! fileMenu.add(openMenuItem); ! openRecentMenu = new JMenu(lang.getString("MENUITEM_OPENRECENT")); //"Open recent"); ! updateOpenRecentMenu(); ! fileMenu.add(openRecentMenu); ! saveMenuItem = new JMenuItem(lang.getString("MENUITEM_SAVE")); //"Save"); ! saveMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {saveAction();}}); ! fileMenu.add(saveMenuItem); ! saveAsMenuItem = new JMenuItem(lang.getString("MENUITEM_SAVEAS")); //"Save as..."); ! saveAsMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {saveAsAction();}}); ! fileMenu.add(saveAsMenuItem); ! backupToMenuItem = new JMenuItem(lang.getString("MENUITEM_BACKUPTO")); //"Backup to..."); ! backupToMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {backupToAction();}}); ! fileMenu.add(backupToMenuItem); ! fileMenu.add(new JSeparator()); ! printSubtreeMenuItem = new JMenuItem(lang.getString("MENUITEM_PRINTSUBTREE")); //"Print subtree"); ! printSubtreeMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {subtreeToBrowserForPrintAction();}}); ! fileMenu.add(printSubtreeMenuItem); ! printArticleMenuItem = new JMenuItem(lang.getString("MENUITEM_PRINTARTICLE")); //"Print article"); ! printArticleMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {articleToBrowserForPrintAction();}}); ! fileMenu.add(printArticleMenuItem); ! fileMenu.add(new JSeparator()); ! importMenu = new JMenu(lang.getString("MENUITEM_IMPORT")); //"Import..."); ! fileMenu.add(importMenu); ! importHjtMenuItem = new JMenuItem(lang.getString("MENUITEM_IMPORT_HJT")); //"...Treepad file as subtree"); ! importHjtMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {importAction(FILE_FORMAT_HJT);}}); ! importMenu.add(importHjtMenuItem); ! importTextMenuItem = new JMenuItem(lang.getString("MENUITEM_IMPORT_TEXTFILES")); //"...text file(s) as child node(s)"); ! importTextMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {importAction(FILE_FORMAT_TEXT);}}); ! importMenu.add(importTextMenuItem); ! importTextAsListMenuItem = new JMenuItem(lang.getString("MENUITEM_IMPORT_TEXTLIST")); //"...text list file, one-child-per-line"); ! importTextAsListMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {importAction(FILE_FORMAT_TEXTASLIST);}}); ! importMenu.add(importTextAsListMenuItem); ! // ! exportMenu = new JMenu(lang.getString("MENUITEM_EXPORT")); //"Export selected..."); ! fileMenu.add(exportMenu); ! exportHjtMenuItem = new JMenuItem(lang.getString("MENUITEM_EXPORT_HJT")); //"...subtree to Treepad HJT file"); ! exportHjtMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {exportAction(FILE_FORMAT_HJT);}}); ! exportMenu.add(exportHjtMenuItem); ! exportHtmlMenuItem = new JMenuItem(lang.getString("MENUITEM_EXPORT_HTML")); //"...subtree to HTML"); ! exportHtmlMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { ! //DELETE htmlExportOkChecker = false; ! //DELETE htmlExportDialog.setVisible(true); ! //DELETE if(htmlExportOkChecker) ! exportAction(FILE_FORMAT_HTML);}}); ! exportMenu.add(exportHtmlMenuItem); ! exportSimpleXmlMenuItem = new JMenuItem(lang.getString("MENUITEM_EXPORT_XML")); //"...subtree to XML"); ! exportSimpleXmlMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {exportAction(FILE_FORMAT_XML);}}); ! exportMenu.add(exportSimpleXmlMenuItem); ! exportListMenuItem = new JMenuItem(lang.getString("MENUITEM_EXPORT_TEXTLIST")); //"...subtree to text list (node titles only)"); ! exportListMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {exportAction(FILE_FORMAT_TEXTASLIST);}}); ! exportMenu.add(exportListMenuItem); ! exportMenu.add(new JSeparator()); ! exportTextMenuItem = new JMenuItem(lang.getString("MENUITEM_EXPORT_ARTICLE")); //"...article to text file"); ! exportTextMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {exportAction(FILE_FORMAT_TEXT);}}); ! exportMenu.add(exportTextMenuItem); ! exportSubtreeTextMenuItem = new JMenuItem(lang.getString("MENUITEM_EXPORT_ARTICLES")); //"...subtree articles to text file"); ! exportSubtreeTextMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {exportAction(FILE_FORMAT_ARTICLESTOTEXT);}}); ! exportMenu.add(exportSubtreeTextMenuItem); ! fileMenu.add(new JSeparator()); ! if(!MAC_OS_X) ! { ! quitMenuItem = new JMenuItem(lang.getString("MENUITEM_QUIT")); //"Quit"); ! quitMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { quitAction(); }}); ! fileMenu.add(quitMenuItem); ! quitMenuItem.setMnemonic('Q'); ! quitMenuItem.setAccelerator(KeyStroke.getKeyStroke('Q', MENU_MASK)); ! } ! // ! undoMenuItem = new JMenuItem(lang.getString("MENUITEM_UNDO")); //"Undo"); ! undoMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { ! undoAction(); ! updateUndoRedoMenuState();}}); ! redoMenuItem = new JMenuItem(lang.getString("MENUITEM_REDO")); //"Redo"); ! redoMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { ! redoAction(); ! updateUndoRedoMenuState();}}); ! editMenu.add(undoMenuItem); ! editMenu.add(redoMenuItem); ! editMenu.add(new JSeparator()); ! addAboveMenuItem = new JMenuItem(lang.getString("MENUITEM_ADDABOVE")); //"Add sibling above"); ! addAboveMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.addNodeAbove(); /* theJreepad.returnFocusToTree(); */ setWarnAboutUnsaved(true); updateWindowTitle();}}); ! editMenu.add(addAboveMenuItem); ! addBelowMenuItem = new JMenuItem(lang.getString("MENUITEM_ADDBELOW")); //"Add sibling below"); ! addBelowMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.addNodeBelow(); /* theJreepad.returnFocusToTree(); */ setWarnAboutUnsaved(true); updateWindowTitle();}}); ! editMenu.add(addBelowMenuItem); ! addChildMenuItem = new JMenuItem(lang.getString("MENUITEM_ADDCHILD")); //"Add child"); ! addChildMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.addNode(); /* theJreepad.returnFocusToTree(); */ setWarnAboutUnsaved(true);updateWindowTitle(); }}); ! editMenu.add(addChildMenuItem); ! editMenu.add(new JSeparator()); ! newFromClipboardMenuItem = new JMenuItem(lang.getString("MENUITEM_NEWFROMCLIPBOARD")); //"New node from clipboard"); ! newFromClipboardMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { systemClipboardToNewNode(); }}); ! editMenu.add(newFromClipboardMenuItem); ! editMenu.add(new JSeparator()); ! editNodeTitleMenuItem = new JMenuItem(lang.getString("MENUITEM_EDITNODETITLE")); //"Edit node title"); ! editNodeTitleMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.editNodeTitleAction(); }}); ! editMenu.add(editNodeTitleMenuItem); ! editMenu.add(new JSeparator()); ! deleteMenuItem = new JMenuItem(lang.getString("MENUITEM_DELETENODE")); //"Delete node"); ! deleteMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { deleteNodeAction(); }}); ! editMenu.add(deleteMenuItem); ! editMenu.add(new JSeparator()); ! upMenuItem = new JMenuItem(lang.getString("MENUITEM_MOVEUP")); //"Move node up"); ! upMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.moveCurrentNodeUp(); theJreepad.returnFocusToTree(); setWarnAboutUnsaved(true);updateWindowTitle(); }}); ! editMenu.add(upMenuItem); ! downMenuItem = new JMenuItem(lang.getString("MENUITEM_MOVEDOWN")); //"Move node down"); ! downMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.moveCurrentNodeDown(); theJreepad.returnFocusToTree(); setWarnAboutUnsaved(true);updateWindowTitle(); }}); ! editMenu.add(downMenuItem); ! editMenu.add(new JSeparator()); ! indentMenuItem = new JMenuItem(lang.getString("MENUITEM_MOVEIN")); //"Indent node (demote)"); ! indentMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.indentCurrentNode(); theJreepad.returnFocusToTree(); setWarnAboutUnsaved(true);updateWindowTitle(); }}); ! editMenu.add(indentMenuItem); ! outdentMenuItem = new JMenuItem(lang.getString("MENUITEM_MOVEOUT")); //"Outdent node (promote)"); ! outdentMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.outdentCurrentNode(); theJreepad.returnFocusToTree(); setWarnAboutUnsaved(true);updateWindowTitle(); }}); ! editMenu.add(outdentMenuItem); ! editMenu.add(new JSeparator()); ! expandAllMenuItem = new JMenuItem(lang.getString("MENUITEM_EXPAND")); //"Expand subtree"); ! expandAllMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.expandAllCurrentNode(); }}); ! editMenu.add(expandAllMenuItem); ! collapseAllMenuItem = new JMenuItem(lang.getString("MENUITEM_COLLAPSE")); //"Collapse subtree"); ! collapseAllMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.collapseAllCurrentNode(); }}); ! editMenu.add(collapseAllMenuItem); ! // ! searchMenuItem = new JMenuItem(lang.getString("MENUITEM_SEARCH")); //"Search"); ! searchMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { searchDialog.open(); }}); ! searchMenu.add(searchMenuItem); ! launchUrlMenuItem = new JMenuItem(lang.getString("MENUITEM_FOLLOWLINK")); //"Follow highlighted link"); ! launchUrlMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.openURLSelectedInArticle(); }}); ! searchMenu.add(launchUrlMenuItem); ! webSearchMenuItem = new JMenuItem(getPrefs().webSearchName); ! webSearchMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.webSearchTextSelectedInArticle(); }}); ! searchMenu.add(webSearchMenuItem); ! searchMenu.add(new JSeparator()); ! characterWrapArticleMenuItem = new JMenuItem(lang.getString("MENUITEM_HARDWRAP1") + getPrefs().characterWrapWidth + lang.getString("MENUITEM_HARDWRAP2")); //); ! characterWrapArticleMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { wrapContentToCharWidth(); }}); ! searchMenu.add(characterWrapArticleMenuItem); ! stripTagsMenuItem = new JMenuItem(lang.getString("MENUITEM_STRIPTAGS")); //"Strip <tags> from article"); ! stripTagsMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { stripAllTags(); }}); ! searchMenu.add(stripTagsMenuItem); ! insertDateMenuItem = new JMenuItem(lang.getString("MENUITEM_INSERTDATE")); //"Insert date"); ! insertDateMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { insertDate(); }}); ! searchMenu.add(insertDateMenuItem); ! searchMenu.add(new JSeparator()); ! sortMenuItem = new JMenuItem(lang.getString("MENUITEM_SORTONELEVEL")); //"Sort children (one level)"); ! sortMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.sortChildren(); setWarnAboutUnsaved(true);updateWindowTitle(); }}); ! searchMenu.add(sortMenuItem); ! sortRecursiveMenuItem = new JMenuItem(lang.getString("MENUITEM_SORTALLLEVELS")); //"Sort children (all levels)"); ! sortRecursiveMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.sortChildrenRecursive(); setWarnAboutUnsaved(true);updateWindowTitle(); }}); ! searchMenu.add(sortRecursiveMenuItem); ! // ! viewBothMenuItem = new JMenuItem(lang.getString("MENUITEM_VIEWBOTH")); //"Both tree and article"); viewBothMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { setViewMode(JreepadPrefs.VIEW_BOTH); }}); viewMenu.add(viewBothMenuItem); ! viewTreeMenuItem = new JMenuItem(lang.getString("MENUITEM_VIEWTREE")); //"Tree"); viewTreeMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { setViewMode(JreepadPrefs.VIEW_TREE); }}); viewMenu.add(viewTreeMenuItem); ! viewArticleMenuItem = new JMenuItem(lang.getString("MENUITEM_VIEWARTICLE")); //"Article"); viewArticleMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { setViewMode(JreepadPrefs.VIEW_ARTICLE); }}); viewMenu.add(viewArticleMenuItem); viewMenu.add(new JSeparator()); ! viewToolbarMenu = new JMenu(lang.getString("MENUITEM_TOOLBAR")); //"Toolbar"); viewMenu.add(viewToolbarMenu); viewToolbarIconsMenuItem = new JCheckBoxMenuItem(lang.getString("MENUITEM_TOOLBAR_ICONS")); //"Icons", true); --- 313,680 ---- // Used by the constructor ! private void establishMenus() { // Create the menu bar ! JMenuBar menuBar = new JMenuBar(); ! // Add menus ! menuBar.add(createFileMenu()); ! menuBar.add(createEditMenu()); ! menuBar.add(createActionsMenu()); ! menuBar.add(createViewMenu()); ! menuBar.add(createOptionsMenu()); ! menuBar.add(createHelpMenu()); ! setJMenuBar(menuBar); ! } ! /** ! * Creates the File menu. ! */ ! private JMenu createFileMenu() ! { ! JMenu fileMenu = new JMenu(lang.getString("MENU_FILE")); //"File"); ! fileMenu.setMnemonic(KeyEvent.VK_F); ! ! JMenuItem newMenuItem = new JMenuItem(lang.getString("MENUITEM_NEW")); //"New"); ! newMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { newAction();}}); ! fileMenu.add(newMenuItem); ! ! JMenuItem openMenuItem = new JMenuItem(lang.getString("MENUITEM_OPEN")); //"Open"); ! openMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {openAction();}}); ! fileMenu.add(openMenuItem); ! ! openRecentMenu = new JMenu(lang.getString("MENUITEM_OPENRECENT")); //"Open recent"); ! updateOpenRecentMenu(); ! fileMenu.add(openRecentMenu); ! ! JMenuItem saveMenuItem = new JMenuItem(lang.getString("MENUITEM_SAVE")); //"Save"); ! saveMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {saveAction();}}); ! fileMenu.add(saveMenuItem); ! ! JMenuItem saveAsMenuItem = new JMenuItem(lang.getString("MENUITEM_SAVEAS")); //"Save as..."); ! saveAsMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {saveAsAction();}}); ! fileMenu.add(saveAsMenuItem); ! ! JMenuItem backupToMenuItem = new JMenuItem(lang.getString("MENUITEM_BACKUPTO")); //"Backup to..."); ! backupToMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {backupToAction();}}); ! fileMenu.add(backupToMenuItem); ! ! fileMenu.add(new JSeparator()); ! ! JMenuItem printSubtreeMenuItem = new JMenuItem(lang.getString("MENUITEM_PRINTSUBTREE")); //"Print subtree"); ! printSubtreeMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {subtreeToBrowserForPrintAction();}}); ! fileMenu.add(printSubtreeMenuItem); ! ! JMenuItem printArticleMenuItem = new JMenuItem(lang.getString("MENUITEM_PRINTARTICLE")); //"Print article"); ! printArticleMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {articleToBrowserForPrintAction();}}); ! fileMenu.add(printArticleMenuItem); ! ! fileMenu.add(new JSeparator()); ! JMenu importMenu = new JMenu(lang.getString("MENUITEM_IMPORT")); //"Import..."); ! fileMenu.add(importMenu); ! ! JMenuItem importHjtMenuItem = new JMenuItem(lang.getString("MENUITEM_IMPORT_HJT")); //"...Treepad file as subtree"); ! importHjtMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {importAction(FILE_FORMAT_HJT);}}); ! importMenu.add(importHjtMenuItem); ! ! JMenuItem importTextMenuItem = new JMenuItem(lang.getString("MENUITEM_IMPORT_TEXTFILES")); //"...text file(s) as child node(s)"); ! importTextMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {importAction(FILE_FORMAT_TEXT);}}); ! importMenu.add(importTextMenuItem); ! ! JMenuItem importTextAsListMenuItem = new JMenuItem(lang.getString("MENUITEM_IMPORT_TEXTLIST")); //"...text list file, one-child-per-line"); ! importTextAsListMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {importAction(FILE_FORMAT_TEXTASLIST);}}); ! importMenu.add(importTextAsListMenuItem); ! ! fileMenu.add(createExportMenu()); ! ! fileMenu.add(new JSeparator()); ! if(!MAC_OS_X) ! { ! JMenuItem quitMenuItem = new JMenuItem(lang.getString("MENUITEM_QUIT")); //"Quit"); ! quitMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { quitAction(); }}); ! fileMenu.add(quitMenuItem); ! quitMenuItem.setMnemonic('Q'); ! quitMenuItem.setAccelerator(KeyStroke.getKeyStroke('Q', MENU_MASK)); ! } ! ! newMenuItem.setMnemonic('N'); ! newMenuItem.setAccelerator(KeyStroke.getKeyStroke('N', MENU_MASK)); ! openMenuItem.setMnemonic('O'); ! openMenuItem.setAccelerator(KeyStroke.getKeyStroke('O', MENU_MASK)); ! openRecentMenu.setMnemonic('R'); ! saveMenuItem.setMnemonic('S'); ! saveMenuItem.setAccelerator(KeyStroke.getKeyStroke('S', MENU_MASK)); ! saveAsMenuItem.setMnemonic('A'); ! printSubtreeMenuItem.setMnemonic('P'); ! printSubtreeMenuItem.setAccelerator(KeyStroke.getKeyStroke('P', MENU_MASK)); ! printArticleMenuItem.setAccelerator(KeyStroke.getKeyStroke('P', MENU_MASK | java.awt.Event.SHIFT_MASK)); ! backupToMenuItem.setMnemonic('B'); ! importMenu.setMnemonic('I'); ! importHjtMenuItem.setMnemonic('f'); ! importTextMenuItem.setMnemonic('t'); ! importTextAsListMenuItem.setMnemonic('l'); ! ! return fileMenu; ! } ! ! /** ! * Creates the Export submenu. ! */ ! private JMenu createExportMenu() ! { ! JMenu exportMenu = new JMenu(lang.getString("MENUITEM_EXPORT")); //"Export selected..."); ! ! JMenuItem exportHjtMenuItem = new JMenuItem(lang.getString("MENUITEM_EXPORT_HJT")); //"...subtree to Treepad HJT file"); ! exportHjtMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {exportAction(FILE_FORMAT_HJT);}}); ! exportMenu.add(exportHjtMenuItem); ! ! JMenuItem exportHtmlMenuItem = new JMenuItem(lang.getString("MENUITEM_EXPORT_HTML")); //"...subtree to HTML"); ! exportHtmlMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {exportAction(FILE_FORMAT_HTML);}}); ! exportMenu.add(exportHtmlMenuItem); ! ! JMenuItem exportSimpleXmlMenuItem = new JMenuItem(lang.getString("MENUITEM_EXPORT_XML")); //"...subtree to XML"); ! exportSimpleXmlMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {exportAction(FILE_FORMAT_XML);}}); ! exportMenu.add(exportSimpleXmlMenuItem); ! ! JMenuItem exportListMenuItem = new JMenuItem(lang.getString("MENUITEM_EXPORT_TEXTLIST")); //"...subtree to text list (node titles only)"); ! exportListMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {exportAction(FILE_FORMAT_TEXTASLIST);}}); ! exportMenu.add(exportListMenuItem); ! ! exportMenu.add(new JSeparator()); ! ! JMenuItem exportTextMenuItem = new JMenuItem(lang.getString("MENUITEM_EXPORT_ARTICLE")); //"...article to text file"); ! exportTextMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {exportAction(FILE_FORMAT_TEXT);}}); ! exportMenu.add(exportTextMenuItem); ! ! JMenuItem exportSubtreeTextMenuItem = new JMenuItem(lang.getString("MENUITEM_EXPORT_ARTICLES")); //"...subtree articles to text file"); ! exportSubtreeTextMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) {exportAction(FILE_FORMAT_ARTICLESTOTEXT);}}); ! exportMenu.add(exportSubtreeTextMenuItem); ! ! exportMenu.setMnemonic('E'); ! exportHjtMenuItem.setMnemonic('f'); ! exportHtmlMenuItem.setMnemonic('h'); ! exportSimpleXmlMenuItem.setMnemonic('x'); ! exportTextMenuItem.setMnemonic('t'); ! ! return exportMenu; ! } ! ! /** ! * Creates the Edit menu. ! */ ! private JMenu createEditMenu() ! { ! JMenu editMenu = new JMenu(lang.getString("MENU_EDIT")); //"Edit"); ! editMenu.setMnemonic(KeyEvent.VK_E); ! ! undoMenuItem = new JMenuItem(lang.getString("MENUITEM_UNDO")); //"Undo"); ! undoMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { ! undoAction(); ! updateUndoRedoMenuState();}}); ! editMenu.add(undoMenuItem); ! ! redoMenuItem = new JMenuItem(lang.getString("MENUITEM_REDO")); //"Redo"); ! redoMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { ! redoAction(); ! updateUndoRedoMenuState();}}); ! editMenu.add(redoMenuItem); ! ! editMenu.add(new JSeparator()); ! ! JMenuItem addAboveMenuItem = new JMenuItem(lang.getString("MENUITEM_ADDABOVE")); //"Add sibling above"); ! addAboveMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.addNodeAbove(); /* theJreepad.returnFocusToTree(); */ setWarnAboutUnsaved(true); updateWindowTitle();}}); ! editMenu.add(addAboveMenuItem); ! ! JMenuItem addBelowMenuItem = new JMenuItem(lang.getString("MENUITEM_ADDBELOW")); //"Add sibling below"); ! addBelowMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.addNodeBelow(); /* theJreepad.returnFocusToTree(); */ setWarnAboutUnsaved(true); updateWindowTitle();}}); ! editMenu.add(addBelowMenuItem); ! ! JMenuItem addChildMenuItem = new JMenuItem(lang.getString("MENUITEM_ADDCHILD")); //"Add child"); ! addChildMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.addNode(); /* theJreepad.returnFocusToTree(); */ setWarnAboutUnsaved(true);updateWindowTitle(); }}); ! editMenu.add(addChildMenuItem); ! ! editMenu.add(new JSeparator()); ! ! JMenuItem newFromClipboardMenuItem = new JMenuItem(lang.getString("MENUITEM_NEWFROMCLIPBOARD")); //"New node from clipboard"); ! newFromClipboardMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { systemClipboardToNewNode(); }}); ! editMenu.add(newFromClipboardMenuItem); ! ! editMenu.add(new JSeparator()); ! ! JMenuItem editNodeTitleMenuItem = new JMenuItem(lang.getString("MENUITEM_EDITNODETITLE")); //"Edit node title"); ! editNodeTitleMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.editNodeTitleAction(); }}); ! editMenu.add(editNodeTitleMenuItem); ! ! editMenu.add(new JSeparator()); ! ! JMenuItem deleteMenuItem = new JMenuItem(lang.getString("MENUITEM_DELETENODE")); //"Delete node"); ! deleteMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { deleteNodeAction(); }}); ! editMenu.add(deleteMenuItem); ! ! editMenu.add(new JSeparator()); ! ! JMenuItem upMenuItem = new JMenuItem(lang.getString("MENUITEM_MOVEUP")); //"Move node up"); ! upMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.moveCurrentNodeUp(); theJreepad.returnFocusToTree(); setWarnAboutUnsaved(true);updateWindowTitle(); }}); ! editMenu.add(upMenuItem); ! ! JMenuItem downMenuItem = new JMenuItem(lang.getString("MENUITEM_MOVEDOWN")); //"Move node down"); ! downMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.moveCurrentNodeDown(); theJreepad.returnFocusToTree(); setWarnAboutUnsaved(true);updateWindowTitle(); }}); ! editMenu.add(downMenuItem); ! ! editMenu.add(new JSeparator()); ! ! JMenuItem indentMenuItem = new JMenuItem(lang.getString("MENUITEM_MOVEIN")); //"Indent node (demote)"); ! indentMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.indentCurrentNode(); theJreepad.returnFocusToTree(); setWarnAboutUnsaved(true);updateWindowTitle(); }}); ! editMenu.add(indentMenuItem); ! ! JMenuItem outdentMenuItem = new JMenuItem(lang.getString("MENUITEM_MOVEOUT")); //"Outdent node (promote)"); ! outdentMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.outdentCurrentNode(); theJreepad.returnFocusToTree(); setWarnAboutUnsaved(true);updateWindowTitle(); }}); ! editMenu.add(outdentMenuItem); ! ! editMenu.add(new JSeparator()); ! ! JMenuItem expandAllMenuItem = new JMenuItem(lang.getString("MENUITEM_EXPAND")); //"Expand subtree"); ! expandAllMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.expandAllCurrentNode(); }}); ! editMenu.add(expandAllMenuItem); ! ! JMenuItem collapseAllMenuItem = new JMenuItem(lang.getString("MENUITEM_COLLAPSE")); //"Collapse subtree"); ! collapseAllMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.collapseAllCurrentNode(); }}); ! editMenu.add(collapseAllMenuItem); ! ! undoMenuItem.setMnemonic('u'); ! undoMenuItem.setAccelerator(KeyStroke.getKeyStroke('Z', MENU_MASK)); ! redoMenuItem.setMnemonic('r'); ! redoMenuItem.setAccelerator(KeyStroke.getKeyStroke('Z', MENU_MASK | java.awt.event.InputEvent.SHIFT_MASK)); ! addAboveMenuItem.setMnemonic('a'); ! addAboveMenuItem.setAccelerator(KeyStroke.getKeyStroke('T', MENU_MASK)); ! addBelowMenuItem.setMnemonic('b'); ! addBelowMenuItem.setAccelerator(KeyStroke.getKeyStroke('B', MENU_MASK)); ! addChildMenuItem.setMnemonic('c'); ! addChildMenuItem.setAccelerator(KeyStroke.getKeyStroke('D', MENU_MASK)); ! newFromClipboardMenuItem.setAccelerator(KeyStroke.getKeyStroke('M', MENU_MASK)); ! upMenuItem.setMnemonic('u'); ! upMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_UP, MENU_MASK | java.awt.Event.ALT_MASK)); ! downMenuItem.setMnemonic('d'); ! downMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, MENU_MASK | java.awt.Event.ALT_MASK)); ! indentMenuItem.setMnemonic('i'); ! indentMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, MENU_MASK | java.awt.Event.ALT_MASK)); ! outdentMenuItem.setMnemonic('o'); ! outdentMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, MENU_MASK | java.awt.Event.ALT_MASK)); ! expandAllMenuItem.setMnemonic('x'); ! expandAllMenuItem.setAccelerator(KeyStroke.getKeyStroke('=', MENU_MASK)); ! collapseAllMenuItem.setMnemonic('l'); ! collapseAllMenuItem.setAccelerator(KeyStroke.getKeyStroke('-', MENU_MASK)); ! deleteMenuItem.setMnemonic('k'); ! deleteMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, MENU_MASK)); ! ! undoMenuItem.setMnemonic('u'); ! undoMenuItem.setAccelerator(KeyStroke.getKeyStroke('Z', MENU_MASK)); ! redoMenuItem.setMnemonic('r'); ! redoMenuItem.setAccelerator(KeyStroke.getKeyStroke('Z', MENU_MASK | java.awt.event.InputEvent.SHIFT_MASK)); ! addAboveMenuItem.setMnemonic('a'); ! addAboveMenuItem.setAccelerator(KeyStroke.getKeyStroke('T', MENU_MASK)); ! addBelowMenuItem.setMnemonic('b'); ! addBelowMenuItem.setAccelerator(KeyStroke.getKeyStroke('B', MENU_MASK)); ! addChildMenuItem.setMnemonic('c'); ! addChildMenuItem.setAccelerator(KeyStroke.getKeyStroke('D', MENU_MASK)); ! newFromClipboardMenuItem.setAccelerator(KeyStroke.getKeyStroke('M', MENU_MASK)); ! upMenuItem.setMnemonic('u'); ! upMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_UP, MENU_MASK | java.awt.Event.ALT_MASK)); ! downMenuItem.setMnemonic('d'); ! downMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, MENU_MASK | java.awt.Event.ALT_MASK)); ! indentMenuItem.setMnemonic('i'); ! indentMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, MENU_MASK | java.awt.Event.ALT_MASK)); ! outdentMenuItem.setMnemonic('o'); ! outdentMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, MENU_MASK | java.awt.Event.ALT_MASK)); ! expandAllMenuItem.setMnemonic('x'); ! expandAllMenuItem.setAccelerator(KeyStroke.getKeyStroke('=', MENU_MASK)); ! collapseAllMenuItem.setMnemonic('l'); ! collapseAllMenuItem.setAccelerator(KeyStroke.getKeyStroke('-', MENU_MASK)); ! deleteMenuItem.setMnemonic('k'); ! deleteMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, MENU_MASK)); ! ! return editMenu; ! } ! ! /** ! * Creates the Actions menu. ! */ ! private JMenu createActionsMenu() ! { ! JMenu actionsMenu = new JMenu(lang.getString("MENU_ACTIONS")); // "Actions"); ! actionsMenu.setMnemonic(KeyEvent.VK_T); ! ! JMenuItem searchMenuItem = new JMenuItem(lang.getString("MENUITEM_SEARCH")); //"Search"); ! searchMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { searchDialog.open(); }}); ! actionsMenu.add(searchMenuItem); ! ! JMenuItem launchUrlMenuItem = new JMenuItem(lang.getString("MENUITEM_FOLLOWLINK")); //"Follow highlighted link"); ! launchUrlMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.openURLSelectedInArticle(); }}); ! actionsMenu.add(launchUrlMenuItem); ! ! webSearchMenuItem = new JMenuItem(getPrefs().webSearchName); ! webSearchMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.webSearchTextSelectedInArticle(); }}); ! actionsMenu.add(webSearchMenuItem); ! ! actionsMenu.add(new JSeparator()); ! ! characterWrapArticleMenuItem = new JMenuItem(lang.getString("MENUITEM_HARDWRAP1") + getPrefs().characterWrapWidth + lang.getString("MENUITEM_HARDWRAP2")); //); ! characterWrapArticleMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { wrapContentToCharWidth(); }}); ! actionsMenu.add(characterWrapArticleMenuItem); ! ! JMenuItem stripTagsMenuItem = new JMenuItem(lang.getString("MENUITEM_STRIPTAGS")); //"Strip <tags> from article"); ! stripTagsMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { stripAllTags(); }}); ! actionsMenu.add(stripTagsMenuItem); ! ! JMenuItem insertDateMenuItem = new JMenuItem(lang.getString("MENUITEM_INSERTDATE")); //"Insert date"); ! insertDateMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { insertDate(); }}); ! actionsMenu.add(insertDateMenuItem); ! ! actionsMenu.add(new JSeparator()); ! ! JMenuItem sortMenuItem = new JMenuItem(lang.getString("MENUITEM_SORTONELEVEL")); //"Sort children (one level)"); ! sortMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.sortChildren(); setWarnAboutUnsaved(true);updateWindowTitle(); }}); ! actionsMenu.add(sortMenuItem); ! ! JMenuItem sortRecursiveMenuItem = new JMenuItem(lang.getString("MENUITEM_SORTALLLEVELS")); //"Sort children (all levels)"); ! sortRecursiveMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.sortChildrenRecursive(); setWarnAboutUnsaved(true);updateWindowTitle(); }}); ! actionsMenu.add(sortRecursiveMenuItem); ! ! searchMenuItem.setMnemonic('s'); ! searchMenuItem.setAccelerator(KeyStroke.getKeyStroke('F', MENU_MASK)); ! webSearchMenuItem.setMnemonic('g'); ! webSearchMenuItem.setAccelerator(KeyStroke.getKeyStroke('G', MENU_MASK)); ! characterWrapArticleMenuItem.setAccelerator(KeyStroke.getKeyStroke('R', MENU_MASK)); ! characterWrapArticleMenuItem.setMnemonic('r'); ! launchUrlMenuItem.setAccelerator(KeyStroke.getKeyStroke('L', MENU_MASK)); ! launchUrlMenuItem.setMnemonic('l'); ! stripTagsMenuItem.setAccelerator(KeyStroke.getKeyStroke('T', MENU_MASK)); ! stripTagsMenuItem.setMnemonic('t'); ! insertDateMenuItem.setAccelerator(KeyStroke.getKeyStroke('E', MENU_MASK)); ! insertDateMenuItem.setMnemonic('e'); ! ! return actionsMenu; ! } ! ! /** ! * Creates the View menu. ! */ ! private JMenu createViewMenu() ! { ! JMenu viewMenu = new JMenu(lang.getString("MENU_VIEW")); //"View"); ! viewMenu.setMnemonic('V'); ! ! JMenuItem viewBothMenuItem = new JMenuItem(lang.getString("MENUITEM_VIEWBOTH")); //"Both tree and article"); viewBothMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { setViewMode(JreepadPrefs.VIEW_BOTH); }}); viewMenu.add(viewBothMenuItem); ! JMenuItem viewTreeMenuItem = new JMenuItem(lang.getString("MENUITEM_VIEWTREE")); //"Tree"); viewTreeMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { setViewMode(JreepadPrefs.VIEW_TREE); }}); viewMenu.add(viewTreeMenuItem); ! JMenuItem viewArticleMenuItem = new JMenuItem(lang.getString("MENUITEM_VIEWARTICLE")); //"Article"); viewArticleMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { setViewMode(JreepadPrefs.VIEW_ARTICLE); }}); viewMenu.add(viewArticleMenuItem); viewMenu.add(new JSeparator()); ! JMenu viewToolbarMenu = new JMenu(lang.getString("MENUITEM_TOOLBAR")); //"Toolbar"); viewMenu.add(viewToolbarMenu); viewToolbarIconsMenuItem = new JCheckBoxMenuItem(lang.getString("MENUITEM_TOOLBAR_ICONS")); //"Icons", true); *************** *** 578,583 **** viewMenu.add(new JSeparator()); ! articleViewModeMenuItem = new JMenu(lang.getString("MENUITEM_ARTICLEFORMAT")); //"View this article as..."); ! articleViewModeTextMenuItem = new JMenuItem(lang.getString("MENUITEM_ARTICLEFORMAT_TEXT")); //"Text"); articleViewModeTextMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.setArticleMode(JreepadArticle.ARTICLEMODE_ORDINARY); --- 698,703 ---- viewMenu.add(new JSeparator()); ! JMenuItem articleViewModeMenuItem = new JMenu(lang.getString("MENUITEM_ARTICLEFORMAT")); //"View this article as..."); ! JMenuItem articleViewModeTextMenuItem = new JMenuItem(lang.getString("MENUITEM_ARTICLEFORMAT_TEXT")); //"Text"); articleViewModeTextMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.setArticleMode(JreepadArticle.ARTICLEMODE_ORDINARY); *************** *** 585,589 **** }}); articleViewModeMenuItem.add(articleViewModeTextMenuItem); ! articleViewModeHtmlMenuItem = new JMenuItem(lang.getString("MENUITEM_ARTICLEFORMAT_HTML")); //"HTML"); articleViewModeHtmlMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.setArticleMode(JreepadArticle.ARTICLEMODE_HTML); --- 705,709 ---- }}); articleViewModeMenuItem.add(articleViewModeTextMenuItem); ! JMenuItem articleViewModeHtmlMenuItem = new JMenuItem(lang.getString("MENUITEM_ARTICLEFORMAT_HTML")); //"HTML"); articleViewModeHtmlMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.setArticleMode(JreepadArticle.ARTICLEMODE_HTML); *************** *** 591,595 **** }}); articleViewModeMenuItem.add(articleViewModeHtmlMenuItem); ! articleViewModeCsvMenuItem = new JMenuItem(lang.getString("MENUITEM_ARTICLEFORMAT_CSV")); //"Table (comma-separated data)"); articleViewModeCsvMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.setArticleMode(JreepadArticle.ARTICLEMODE_CSV); --- 711,715 ---- }}); articleViewModeMenuItem.add(articleViewModeHtmlMenuItem); ! JMenuItem articleViewModeCsvMenuItem = new JMenuItem(lang.getString("MENUITEM_ARTICLEFORMAT_CSV")); //"Table (comma-separated data)"); articleViewModeCsvMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.setArticleMode(JreepadArticle.ARTICLEMODE_CSV); *************** *** 597,601 **** }}); articleViewModeMenuItem.add(articleViewModeCsvMenuItem); ! articleViewModeTextileMenuItem = new JMenuItem(lang.getString("MENUITEM_ARTICLEFORMAT_TEXTILE")); articleViewModeTextileMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.setArticleMode(JreepadArticle.ARTICLEMODE_TEXTILEHTML); --- 717,721 ---- }}); articleViewModeMenuItem.add(articleViewModeCsvMenuItem); ! JMenuItem articleViewModeTextileMenuItem = new JMenuItem(lang.getString("MENUITEM_ARTICLEFORMAT_TEXTILE")); articleViewModeTextileMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { theJreepad.setArticleMode(JreepadArticle.ARTICLEMODE_TEXTILEHTML); *************** *** 607,728 **** viewMenu.add(new JSeparator()); ! thisNodesUrlMenuItem = new JMenuItem(lang.getString("MENUITEM_NODEADDRESS")); //"\"node://\" address for current node"); thisNodesUrlMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { getTreepadNodeUrl(); }}); viewMenu.add(thisNodesUrlMenuItem); ! // ! autoSaveMenuItem = new JMenuItem(lang.getString("MENUITEM_AUTOSAVE_PREFS")); //"Autosave..."); ! autoSaveMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { showAutoSaveDialog(); }}); ! optionsMenu.add(autoSaveMenuItem); ! prefsMenuItem = new JMenuItem(lang.getString("MENUITEM_PREFS")); //"Preferences"); ! prefsMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { ! // updateFontsInPrefsBox(); ! showPrefsDialog(); }}); ! optionsMenu.add(prefsMenuItem); ! // ! keyboardHelpMenuItem = new JMenuItem(lang.getString("MENUITEM_KEYBOARDSHORTCUTS")); //"Keyboard shortcuts"); ! keyboardHelpMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) ! { keyboardHelp(); ! }}); ! helpMenu.add(keyboardHelpMenuItem); ! linksHelpMenuItem = new JMenuItem(lang.getString("MENUITEM_LINKSHELP")); //"Help with links"); ! linksHelpMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) ! { linksHelp(); ! }}); ! helpMenu.add(linksHelpMenuItem); ! dragDropHelpMenuItem = new JMenuItem(lang.getString("MENUITEM_DRAGDROPHELP")); //"Help with drag-and-drop"); ! dragDropHelpMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) ! { dragDropHelp(); ! }}); ! helpMenu.add(dragDropHelpMenuItem); ! helpMenu.add(new JSeparator()); ! if(!MAC_OS_X) ! { ! aboutMenuItem = new JMenuItem(lang.getString("MENUITEM_ABOUT")); //"About Jreepad"); ! aboutMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) ! { ! aboutAction(); ! }}); ! aboutMenuItem.setMnemonic('a'); ! helpMenu.add(aboutMenuItem); ! } ! licenseMenuItem = new JMenuItem(lang.getString("MENUITEM_LICENSE")); //"License"); ! licenseMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) ! { ! showLicense(); ! }}); ! helpMenu.add(licenseMenuItem); ! // ! menuBar.add(fileMenu); ! menuBar.add(editMenu); ! menuBar.add(searchMenu); ! menuBar.add(viewMenu); ! menuBar.add(optionsMenu); ! menuBar.add(helpMenu); ! setJMenuBar(menuBar); ! // ! // Now the mnemonics... ! fileMenu.setMnemonic('F'); ! newMenuItem.setMnemonic('N'); ! newMenuItem.setAccelerator(KeyStroke.getKeyStroke('N', MENU_MASK)); ! openMenuItem.setMnemonic('O'); ! openMenuItem.setAccelerator(KeyStroke.getKeyStroke('O', MENU_MASK)); ! openRecentMenu.setMnemonic('R'); ! saveMenuItem.setMnemonic('S'); ! saveMenuItem.setAccelerator(KeyStroke.getKeyStroke('S', MENU_MASK)); ! saveAsMenuItem.setMnemonic('A'); ! printSubtreeMenuItem.setMnemonic('P'); ! printSubtreeMenuItem.setAccelerator(KeyStroke.getKeyStroke('P', MENU_MASK)); ! printArticleMenuItem.setAccelerator(KeyStroke.getKeyStroke('P', MENU_MASK | java.awt.Event.SHIFT_MASK)); ! backupToMenuItem.setMnemonic('B'); ! importMenu.setMnemonic('I'); ! importHjtMenuItem.setMnemonic('f'); ! importTextMenuItem.setMnemonic('t'); ! importTextAsListMenuItem.setMnemonic('l'); ! exportMenu.setMnemonic('E'); ! exportHjtMenuItem.setMnemonic('f'); ! exportHtmlMenuItem.setMnemonic('h'); ! exportSimpleXmlMenuItem.setMnemonic('x'); ! exportTextMenuItem.setMnemonic('t'); ! editMenu.setMnemonic('E'); ! undoMenuItem.setMnemonic('u'); ! undoMenuItem.setAccelerator(KeyStroke.getKeyStroke('Z', MENU_MASK)); ! redoMenuItem.setMnemonic('r'); ! redoMenuItem.setAccelerator(KeyStroke.getKeyStroke('Z', MENU_MASK | java.awt.event.InputEvent.SHIFT_MASK)); ! addAboveMenuItem.setMnemonic('a'); ! addAboveMenuItem.setAccelerator(KeyStroke.getKeyStroke('T', MENU_MASK)); ! addBelowMenuItem.setMnemonic('b'); ! addBelowMenuItem.setAccelerator(KeyStroke.getKeyStroke('B', MENU_MASK)); ! addChildMenuItem.setMnemonic('c'); ! addChildMenuItem.setAccelerator(KeyStroke.getKeyStroke('D', MENU_MASK)); ! newFromClipboardMenuItem.setAccelerator(KeyStroke.getKeyStroke('M', MENU_MASK)); ! upMenuItem.setMnemonic('u'); ! upMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_UP, MENU_MASK | java.awt.Event.ALT_MASK)); ! downMenuItem.setMnemonic('d'); ! downMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, MENU_MASK | java.awt.Event.ALT_MASK)); ! indentMenuItem.setMnemonic('i'); ! indentMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, MENU_MASK | java.awt.Event.ALT_MASK)); ! outdentMenuItem.setMnemonic('o'); ! outdentMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, MENU_MASK | java.awt.Event.ALT_MASK)); ! expandAllMenuItem.setMnemonic('x'); ! expandAllMenuItem.setAccelerator(KeyStroke.getKeyStroke('=', MENU_MASK)); ! collapseAllMenuItem.setMnemonic('l'); ! collapseAllMenuItem.setAccelerator(KeyStroke.getKeyStroke('-', MENU_MASK)); ! deleteMenuItem.setMnemonic('k'); ! deleteMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, MENU_MASK)); ! searchMenu.setMnemonic('t'); ! searchMenuItem.setMnemonic('s'); ! searchMenuItem.setAccelerator(KeyStroke.getKeyStroke('F', MENU_MASK)); ! webSearchMenuItem.setMnemonic('g'); ! webSearchMenuItem.setAccelerator(KeyStroke.getKeyStroke('G', MENU_MASK)); ! launchUrlMenuItem.setAccelerator(KeyStroke.getKeyStroke('L', MENU_MASK)); ! launchUrlMenuItem.setMnemonic('l'); ! stripTagsMenuItem.setAccelerator(KeyStroke.getKeyStroke('T', MENU_MASK)); ! stripTagsMenuItem.setMnemonic('t'); ! insertDateMenuItem.setAccelerator(KeyStroke.getKeyStroke('E', MENU_MASK)); ! insertDateMenuItem.setMnemonic('e'); ! characterWrapArticleMenuItem.setAccelerator(KeyStroke.getKeyStroke('R', MENU_MASK)); ! characterWrapArticleMenuItem.setMnemonic('r'); thisNodesUrlMenuItem.setMnemonic('n'); - viewMenu.setMnemonic('V'); viewBothMenuItem.setMnemonic('b'); viewTreeMenuItem.setMnemonic('t'); --- 727,735 ---- viewMenu.add(new JSeparator()); ! JMenuItem thisNodesUrlMenuItem = new JMenuItem(lang.getString("MENUITEM_NODEADDRESS")); //"\"node://\" address for current node"); thisNodesUrlMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { getTreepadNodeUrl(); }}); viewMenu.add(thisNodesUrlMenuItem); ! thisNodesUrlMenuItem.setMnemonic('n'); viewBothMenuItem.setMnemonic('b'); viewTreeMenuItem.setMnemonic('t'); *************** *** 739,751 **** articleViewModeTextileMenuItem.setAccelerator(KeyStroke.getKeyStroke('0', MENU_MASK)); viewToolbarMenu.setMnemonic('o'); ! optionsMenu.setMnemonic('O'); ! autoSaveMenuItem.setMnemonic('a'); ! prefsMenuItem.setMnemonic('p'); ! helpMenu.setMnemonic('H'); ! keyboardHelpMenuItem.setMnemonic('k'); ! dragDropHelpMenuItem.setMnemonic('d'); ! linksHelpMenuItem.setMnemonic('l'); ! licenseMenuItem.setMnemonic('i'); ! // Finished creating the menu bar } --- 746,820 ---- articleViewModeTextileMenuItem.setAccelerator(KeyStroke.getKeyStroke('0', MENU_MASK)); viewToolbarMenu.setMnemonic('o'); ! ! return viewMenu; ! } ! ! /** ! * Creates the Options menu. ! */ ! private JMenu createOptionsMenu() ! { ! JMenu optionsMenu = new JMenu(lang.getString("MENU_OPTIONS")); //"Options"); ! optionsMenu.setMnemonic('O'); ! ! JMenuItem autoSaveMenuItem = new JMenuItem(lang.getString("MENUITEM_AUTOSAVE_PREFS")); //"Autosave..."); ! autoSaveMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { showAutoSaveDialog(); }}); ! optionsMenu.add(autoSaveMenuItem); ! JMenuItem prefsMenuItem = new JMenuItem(lang.getString("MENUITEM_PREFS")); //"Preferences"); ! prefsMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { ! // updateFontsInPrefsBox(); ! showPrefsDialog(); }}); ! optionsMenu.add(prefsMenuItem); ! ! autoSaveMenuItem.setMnemonic('a'); ! prefsMenuItem.setMnemonic('p'); ! ! return optionsMenu; ! } ! ! private JMenu createHelpMenu() ! { ! JMenu helpMenu = new JMenu(lang.getString("MENU_HELP")); //"Help"); ! helpMenu.setMnemonic('H'); ! ! JMenuItem keyboardHelpMenuItem = new JMenuItem(lang.getString("MENUITEM_KEYBOARDSHORTCUTS")); //"Keyboard shortcuts"); ! keyboardHelpMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) ! { keyboardHelp(); ! }}); ! helpMenu.add(keyboardHelpMenuItem); ! JMenuItem linksHelpMenuItem = new JMenuItem(lang.getString("MENUITEM_LINKSHELP")); //"Help with links"); ! linksHelpMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) ! { linksHelp(); ! }}); ! helpMenu.add(linksHelpMenuItem); ! JMenuItem dragDropHelpMenuItem = new JMenuItem(lang.getString("MENUITEM_DRAGDROPHELP")); //"Help with drag-and-drop"); ! dragDropHelpMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) ! { dragDropHelp(); ! }}); ! helpMenu.add(dragDropHelpMenuItem); ! helpMenu.add(new JSeparator()); ! if(!MAC_OS_X) ! { ! JMenuItem aboutMenuItem = new JMenuItem(lang.getString("MENUITEM_ABOUT")); //"About Jreepad"); ! aboutMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) ! { ! aboutAction(); ! }}); ! aboutMenuItem.setMnemonic('a'); ! helpMenu.add(aboutMenuItem); ! } ! JMenuItem licenseMenuItem = new JMenuItem(lang.getString("MENUITEM_LICENSE")); //"License"); ! licenseMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) ! { ! showLicense(); ! }}); ! helpMenu.add(licenseMenuItem); ! ! keyboardHelpMenuItem.setMnemonic('k'); ! dragDropHelpMenuItem.setMnemonic('d'); ! linksHelpMenuItem.setMnemonic('l'); ! licenseMenuItem.setMnemonic('i'); ! ! return helpMenu; } |
From: PeWu <pe...@us...> - 2007-03-01 12:11:14
|
Update of /cvsroot/jreepad/jreepad/src/jreepad/lang In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv8169/src/jreepad/lang Modified Files: JreepadStrings.properties Log Message: Added option to set the date format (for inserting the current date) Index: JreepadStrings.properties =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/lang/JreepadStrings.properties,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** JreepadStrings.properties 12 Mar 2006 15:46:20 -0000 1.5 --- JreepadStrings.properties 1 Mar 2007 12:10:59 -0000 1.6 *************** *** 51,55 **** MENUITEM_SEARCH=Search MENUITEM_FOLLOWLINK=Follow highlighted link ! MENUITEM_HARDWRAP1=Hard-wrap current article to MENUITEM_HARDWRAP2= characters MENUITEM_STRIPTAGS=Strip <tags> from article --- 51,55 ---- MENUITEM_SEARCH=Search MENUITEM_FOLLOWLINK=Follow highlighted link ! MENUITEM_HARDWRAP1=Hard-wrap current article to MENUITEM_HARDWRAP2= characters MENUITEM_STRIPTAGS=Strip <tags> from article *************** *** 115,118 **** --- 115,120 ---- PREFS_QUOTE_CSV=Add quote marks when converting tables to CSV PREFS_GREEN_STRIP=Show funky green strip on window + PREFS_DATEFORMAT_LABEL=Date format: + PREFS_DATEFORMAT_LABEL2=leave blank for default PREFS_GENERAL=General PREFS_DEFAULT_LINK_ACTION=Default action to take with ordinary words/phrases: *************** *** 141,145 **** AUTOSAVE=Autosave ! AUTOSAVE_EVERY=Autosave every AUTOSAVE_MINUTES= minutes AUTOSAVE_ACTIVE=Autosave on --- 143,147 ---- AUTOSAVE=Autosave ! AUTOSAVE_EVERY=Autosave every AUTOSAVE_MINUTES= minutes AUTOSAVE_ACTIVE=Autosave on *************** *** 151,155 **** #------------------------------------------------------------------------ SEARCH_WINDOWTITLE=Search Jreepad ! SEARCH_SEARCHFOR=Search for: SEARCH_SEARCHWHERE=Search where: SEARCH_SELECTEDNODE=Selected node and its children --- 153,157 ---- #------------------------------------------------------------------------ SEARCH_WINDOWTITLE=Search Jreepad ! SEARCH_SEARCHFOR=Search for: SEARCH_SEARCHWHERE=Search where: SEARCH_SELECTEDNODE=Selected node and its children *************** *** 184,188 **** PROMPT_CONFIRM_DELETE=Delete node TITLE_CONFIRM_OVERWRITE=Overwrite file? ! PROMPT_CONFIRM_OVERWRITE1=The file PROMPT_CONFIRM_OVERWRITE2= already exists.\nAre you sure you want to overwrite it? TITLE_CONFIRM_STRIPTAGS=Strip all tags? --- 186,190 ---- PROMPT_CONFIRM_DELETE=Delete node TITLE_CONFIRM_OVERWRITE=Overwrite file? ! PROMPT_CONFIRM_OVERWRITE1=The file PROMPT_CONFIRM_OVERWRITE2= already exists.\nAre you sure you want to overwrite it? TITLE_CONFIRM_STRIPTAGS=Strip all tags? *************** *** 200,204 **** MSG_NODE_NOT_FOUND=No node found in the current file\nto match that path. MSG_NODE_NOT_FOUND_PROMPT_CREATE=No node with that name was found. Create it? ! #------------------------------------------------------------------------ --- 202,207 ---- MSG_NODE_NOT_FOUND=No node found in the current file\nto match that path. MSG_NODE_NOT_FOUND_PROMPT_CREATE=No node with that name was found. Create it? ! TITLE_INVALID_DATEFORMAT=Invalid date format ! MSG_INVALID_DATEFORMAT=The provided date format is invalid.\n See http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html for syntax. #------------------------------------------------------------------------ |
From: PeWu <pe...@us...> - 2007-03-01 12:11:14
|
Update of /cvsroot/jreepad/jreepad/src/jreepad In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv8169/src/jreepad Modified Files: JreepadPrefs.java PrefsDialog.java JreepadView.java Log Message: Added option to set the date format (for inserting the current date) Index: JreepadView.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadView.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** JreepadView.java 7 Feb 2007 23:01:01 -0000 1.44 --- JreepadView.java 1 Mar 2007 12:11:00 -0000 1.45 *************** *** 27,30 **** --- 27,33 ---- import java.io.IOException; import java.io.InputStreamReader; + import java.text.DateFormat; + import java.text.SimpleDateFormat; + import java.util.Date; import java.util.Vector; *************** *** 417,424 **** } - private java.text.DateFormat dateFormat = java.text.DateFormat.getDateInstance(); private String getCurrentDate() { ! return dateFormat.format(new java.util.Date()); } --- 420,444 ---- } private String getCurrentDate() { ! DateFormat dateFormat = null; ! String format = getPrefs().dateFormat; ! ! if (!format.equals("")) ! { ! try ! { ! dateFormat = new SimpleDateFormat(format); ! } ! catch (IllegalArgumentException e) ! { ! // Default format will be set ! // TODO: Log this ! } ! } ! if (dateFormat == null) ! dateFormat = DateFormat.getDateInstance(); ! ! return dateFormat.format(new Date()); } Index: JreepadPrefs.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadPrefs.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** JreepadPrefs.java 6 Feb 2007 18:33:09 -0000 1.23 --- JreepadPrefs.java 1 Mar 2007 12:10:59 -0000 1.24 *************** *** 133,136 **** --- 133,141 ---- boolean showGreenStrip; + /** + * Date format string used to format inserted date. + */ + public String dateFormat; + JreepadPrefs(Dimension wndSize) { // Grab the prefs object from wherever Java's API has put it... *************** *** 241,245 **** showGreenStrip = prefs.getBoolean("SHOWGREENSTRIP", true); ! } --- 246,250 ---- showGreenStrip = prefs.getBoolean("SHOWGREENSTRIP", true); ! dateFormat = prefs.get("DATEFORMAT", ""); } *************** *** 317,320 **** --- 322,327 ---- prefs.putBoolean("SHOWGREENSTRIP", showGreenStrip); + prefs.put("DATEFORMAT", dateFormat); + try{ Index: PrefsDialog.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/PrefsDialog.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PrefsDialog.java 28 Jan 2007 21:29:30 -0000 1.1 --- PrefsDialog.java 1 Mar 2007 12:10:59 -0000 1.2 *************** *** 2,8 **** --- 2,10 ---- import java.awt.Component; + import java.awt.Dimension; import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; + import java.text.SimpleDateFormat; import javax.swing.BorderFactory; *************** *** 13,16 **** --- 15,19 ---- import javax.swing.JDialog; import javax.swing.JLabel; + import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JSpinner; *************** *** 32,35 **** --- 35,39 ---- private JComboBox fileFormatSelector; private JCheckBox showGreenStripCheckBox; + private JTextField dateFormatField; private JComboBox defaultSearchModeSelector; private JSpinner wrapWidthSpinner; *************** *** 95,98 **** --- 99,110 ---- showGreenStripCheckBox.setHorizontalAlignment(SwingConstants.LEFT); + hBox = Box.createHorizontalBox(); + hBox.setAlignmentX(Component.LEFT_ALIGNMENT); + hBox.add(new JLabel(JreepadViewer.lang.getString("PREFS_DATEFORMAT_LABEL"), SwingConstants.LEFT)); + dateFormatField = new JTextField(getPrefs().dateFormat, 30); + hBox.add(dateFormatField); + hBox.add(new JLabel("(" + JreepadViewer.lang.getString("PREFS_DATEFORMAT_LABEL2") + ")", SwingConstants.LEFT)); + genPrefVBox.add(hBox); + JPanel genPanel = new JPanel(); genPanel.setAlignmentX(Component.LEFT_ALIGNMENT); *************** *** 266,269 **** --- 278,296 ---- getPrefs().showGreenStrip = showGreenStripCheckBox.isSelected(); + String dateFormat = dateFormatField.getText(); + try + { + new SimpleDateFormat(dateFormat); + } + catch (IllegalArgumentException ex) + { + JOptionPane.showMessageDialog(PrefsDialog.this, + JreepadViewer.lang.getString("MSG_INVALID_DATEFORMAT"), + JreepadViewer.lang.getString("TITLE_INVALID_DATEFORMAT") , + JOptionPane.ERROR_MESSAGE); + return; + } + getPrefs().dateFormat = dateFormat; + // If exporting as HTML then we ignore this checkbox if (htmlExportModeSelector.getSelectedIndex() != 2) |
From: PeWu <pe...@us...> - 2007-02-12 21:47:38
|
Update of /cvsroot/jreepad/jreepad/src/jreepad In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv17259/src/jreepad Modified Files: JreepadViewer.java Log Message: Start with tree focused Index: JreepadViewer.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadViewer.java,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** JreepadViewer.java 5 Feb 2007 11:06:44 -0000 1.50 --- JreepadViewer.java 12 Feb 2007 21:47:28 -0000 1.51 *************** *** 370,373 **** --- 370,374 ---- theJreepad.expandPaths(getPrefs().treePathCollection.paths); } + theJreepad.returnFocusToTree(); } |
From: PeWu <pe...@us...> - 2007-02-07 23:01:06
|
Update of /cvsroot/jreepad/jreepad/src/jreepad In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv1155/src/jreepad Modified Files: JreepadView.java Log Message: refactoring: Adapted JreepadView to the new ArticleView interface Index: JreepadView.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadView.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** JreepadView.java 7 Feb 2007 21:19:11 -0000 1.43 --- JreepadView.java 7 Feb 2007 23:01:01 -0000 1.44 *************** *** 31,35 **** import javax.swing.Box; import javax.swing.BoxLayout; - import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.JScrollPane; --- 31,34 ---- *************** *** 42,45 **** --- 41,45 ---- import javax.swing.tree.TreePath; + import jreepad.editor.ArticleView; import jreepad.editor.ContentChangeListener; import jreepad.editor.HtmlViewer; *************** *** 61,65 **** private TreeView tree; private JScrollPane treeView; ! private JScrollPane articleView; // editorPane is supposed to represent the pane currently displayed/edited - so it's the one --- 61,65 ---- private TreeView tree; private JScrollPane treeView; ! private JScrollPane articlePane; // editorPane is supposed to represent the pane currently displayed/edited - so it's the one *************** *** 72,76 **** private TableViewer editorPaneCsv; ! private JComponent currentArticleView; --- 72,76 ---- private TableViewer editorPaneCsv; ! private ArticleView currentArticleView; *************** *** 166,171 **** editorPaneTextile = new TextileViewer(root.getArticle()); editorPaneCsv = new TableViewer(root.getArticle()); ! articleView = new JScrollPane(getEditorPaneComponent(), JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); /* XXX Is this really needed? --- 166,179 ---- editorPaneTextile = new TextileViewer(root.getArticle()); editorPaneCsv = new TableViewer(root.getArticle()); + currentArticleView = editorPanePlainText; ! editorPanePlainText.setContentChangeListener(new ContentChangeListener() { ! public void contentChanged() ! { ! setWarnAboutUnsaved(true); ! } ! }); ! ! articlePane = new JScrollPane(editorPanePlainText.getComponent(), JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); /* XXX Is this really needed? *************** *** 199,209 **** */ - editorPanePlainText.setContentChangeListener(new ContentChangeListener() { - public void contentChanged() - { - setWarnAboutUnsaved(true); - } - }); - setCurrentNode(root); --- 207,210 ---- *************** *** 236,241 **** } setSize(getSize()); ! currentArticleView.setPreferredSize(articleView.getViewport().getExtentSize()); ! currentArticleView.setSize(articleView.getViewport().getExtentSize()); validate(); repaint(); --- 237,242 ---- } setSize(getSize()); ! currentArticleView.getComponent().setPreferredSize(articlePane.getViewport().getExtentSize()); ! currentArticleView.getComponent().setSize(articlePane.getViewport().getExtentSize()); validate(); repaint(); *************** *** 251,255 **** ensureCorrectArticleRenderMode(); splitPane.setLeftComponent(treeView); ! splitPane.setRightComponent(articleView); this.add(splitPane); // editorPane.setSize(articleView.getSize()); --- 252,256 ---- ensureCorrectArticleRenderMode(); splitPane.setLeftComponent(treeView); ! splitPane.setRightComponent(articlePane); this.add(splitPane); // editorPane.setSize(articleView.getSize()); *************** *** 258,262 **** private void setViewTreeOnly() { this.remove(splitPane); ! this.remove(articleView); this.add(treeView); treeView.setSize(getSize()); --- 259,263 ---- private void setViewTreeOnly() { this.remove(splitPane); ! this.remove(articlePane); this.add(treeView); treeView.setSize(getSize()); *************** *** 267,272 **** this.remove(treeView); ensureCorrectArticleRenderMode(); ! this.add(articleView); ! articleView.setSize(getSize()); } --- 268,273 ---- this.remove(treeView); ensureCorrectArticleRenderMode(); ! this.add(articlePane); ! articlePane.setSize(getSize()); } *************** *** 277,287 **** return; ! editorPanePlainText.lockEdits(); // Deactivate the caret-listener, effectively - ALSO DEACTIVATES UNDO-STORAGE currentNode = n; - setEditorPaneText(n.getArticle()); ensureCorrectArticleRenderMode(); ! editorPanePlainText.unlockEdits(); // Reactivate the caret listener - ALSO REACTIVATES UNDO-STORAGE } --- 278,288 ---- return; ! ArticleView oldView = currentArticleView; ! oldView.lockEdits(); // Deactivate the caret-listener, effectively - ALSO DEACTIVATES UNDO-STORAGE currentNode = n; ensureCorrectArticleRenderMode(); ! oldView.unlockEdits(); // Reactivate the caret listener - ALSO REACTIVATES UNDO-STORAGE } *************** *** 499,503 **** int index = parent.getIndex(currentNode); JreepadNode ret = parent.removeChild(index); - setCurrentNode(parent); tree.setSelectionPath(parentPath); --- 500,503 ---- *************** *** 608,627 **** } - public String getSelectedTextInArticle() - { - switch(currentNode.getArticle().getArticleMode()) - { - case JreepadArticle.ARTICLEMODE_CSV: - return editorPaneCsv.getSelectedText(); - case JreepadArticle.ARTICLEMODE_HTML: - return editorPaneHtml.getSelectedText(); - case JreepadArticle.ARTICLEMODE_TEXTILEHTML: - return editorPaneTextile.getSelectedText(); - case JreepadArticle.ARTICLEMODE_ORDINARY: - default: - return editorPanePlainText.getSelectedText(); - } - } - public static JreepadPrefs getPrefs() { --- 608,611 ---- *************** *** 638,642 **** { // JComponent treeOrArticle; ! String url = getSelectedTextInArticle(); if(url==null || url.length()==0) --- 622,626 ---- { // JComponent treeOrArticle; ! String url = currentArticleView.getSelectedText(); if(url==null || url.length()==0) *************** *** 659,663 **** public void openURLSelectedInArticle() { ! String url = getSelectedTextInArticle(); if((url == null) && (currentNode.getArticle().getArticleMode()==JreepadArticle.ARTICLEMODE_ORDINARY)) url = editorPanePlainText.selectWordUnderCursor(); --- 643,647 ---- public void openURLSelectedInArticle() { ! String url = currentArticleView.getSelectedText(); if((url == null) && (currentNode.getArticle().getArticleMode()==JreepadArticle.ARTICLEMODE_ORDINARY)) url = editorPanePlainText.selectWordUnderCursor(); *************** *** 939,946 **** //DEL storeForUndo(); currentNode.getArticle().wrapContentToCharWidth(charWidth); ! editorPanePlainText.reloadArticle(); ! editorPaneHtml.reloadArticle(); ! editorPaneTextile.reloadArticle(); ! editorPaneCsv.reloadArticle(); setWarnAboutUnsaved(true); } --- 923,927 ---- //DEL storeForUndo(); currentNode.getArticle().wrapContentToCharWidth(charWidth); ! currentArticleView.reloadArticle(); setWarnAboutUnsaved(true); } *************** *** 950,1051 **** //DEL storeForUndo(); currentNode.getArticle().stripAllTags(); ! editorPanePlainText.reloadArticle(); ! editorPaneHtml.reloadArticle(); ! editorPaneTextile.reloadArticle(); ! editorPaneCsv.reloadArticle(); setWarnAboutUnsaved(true); } - public void setArticleMode(int newMode) { ! editorPanePlainText.lockEdits(); // Disables store-for-undo - switch(newMode) - { - case JreepadArticle.ARTICLEMODE_ORDINARY: - editorPanePlainText.reloadArticle(); - break; - case JreepadArticle.ARTICLEMODE_HTML: - editorPaneHtml.reloadArticle(); - break; - case JreepadArticle.ARTICLEMODE_TEXTILEHTML: - editorPaneTextile.reloadArticle(); - break; - case JreepadArticle.ARTICLEMODE_CSV: - editorPaneCsv.reloadArticle(); - break; - default: - return; - } currentNode.getArticle().setArticleMode(newMode); ensureCorrectArticleRenderMode(); ! getEditorPaneComponent().repaint(); ! editorPanePlainText.unlockEdits(); // Re-enables store-for-undo ! } ! public void ensureCorrectArticleRenderMode() ! { ! articleView.setViewportView(getEditorPaneComponent()); } ! // The following functions allow us to use either a JEditorPane or a JTable to display article data ! JComponent getEditorPaneComponent() { - if(currentNode==null) - { - currentArticleView = editorPanePlainText.getComponent(); - return currentArticleView; // This is a bit of a hack - it shouldn't really even be called to act on null - } - switch(currentNode.getArticle().getArticleMode()) { case JreepadArticle.ARTICLEMODE_ORDINARY: ! currentArticleView = editorPanePlainText.getComponent(); break; case JreepadArticle.ARTICLEMODE_HTML: ! currentArticleView = editorPaneHtml.getComponent(); break; case JreepadArticle.ARTICLEMODE_TEXTILEHTML: ! currentArticleView = editorPaneTextile.getComponent(); break; case JreepadArticle.ARTICLEMODE_CSV: ! currentArticleView = editorPaneCsv.getComponent(); break; default: System.err.println("getEditorPaneComponent() says: JreepadNode.getArticleMode() returned an unrecognised value"); ! return null; ! } ! return currentArticleView; ! } ! ! String getEditorPaneText() ! { ! switch(currentNode.getArticle().getArticleMode()) ! { ! case JreepadArticle.ARTICLEMODE_ORDINARY: ! return editorPanePlainText.getText(); ! case JreepadArticle.ARTICLEMODE_HTML: ! return editorPaneHtml.getText(); ! case JreepadArticle.ARTICLEMODE_TEXTILEHTML: ! return editorPaneTextile.getText(); ! case JreepadArticle.ARTICLEMODE_CSV: ! return editorPaneCsv.getText(); ! default: ! System.err.println("getEditorPaneText() says: JreepadNode.getArticleMode() returned an unrecognised value"); ! return null; } } - void setEditorPaneText(JreepadArticle a) - { - editorPanePlainText.setArticle(a); - editorPaneHtml.setArticle(a); - editorPaneTextile.setArticle(a); - editorPaneCsv.setArticle(a); - } - // End of: functions which should allow us to switch between JEditorPane and JTable - - public void editNodeTitleAction() { --- 931,974 ---- //DEL storeForUndo(); currentNode.getArticle().stripAllTags(); ! currentArticleView.reloadArticle(); setWarnAboutUnsaved(true); } public void setArticleMode(int newMode) { ! ArticleView oldView = currentArticleView; ! oldView.lockEdits(); // Disables store-for-undo currentNode.getArticle().setArticleMode(newMode); ensureCorrectArticleRenderMode(); ! currentArticleView.getComponent().repaint(); ! oldView.unlockEdits(); // Re-enables store-for-undo } ! public void ensureCorrectArticleRenderMode() { switch(currentNode.getArticle().getArticleMode()) { case JreepadArticle.ARTICLEMODE_ORDINARY: ! currentArticleView = editorPanePlainText; break; case JreepadArticle.ARTICLEMODE_HTML: ! currentArticleView = editorPaneHtml; break; case JreepadArticle.ARTICLEMODE_TEXTILEHTML: ! currentArticleView = editorPaneTextile; break; case JreepadArticle.ARTICLEMODE_CSV: ! currentArticleView = editorPaneCsv; break; default: System.err.println("getEditorPaneComponent() says: JreepadNode.getArticleMode() returned an unrecognised value"); ! currentArticleView = null; } + currentArticleView.setArticle(currentNode.getArticle()); + articlePane.setViewportView(currentArticleView.getComponent()); } public void editNodeTitleAction() { |
From: PeWu <pe...@us...> - 2007-02-07 21:19:16
|
Update of /cvsroot/jreepad/jreepad/src/jreepad/editor In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv22782/src/jreepad/editor Modified Files: TableViewer.java Log Message: refactoring: Moved TableViewer to ArticleView interface Index: TableViewer.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/editor/TableViewer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TableViewer.java 6 Feb 2007 18:33:08 -0000 1.1 --- TableViewer.java 7 Feb 2007 21:19:11 -0000 1.2 *************** *** 22,25 **** --- 22,26 ---- import java.awt.Color; + import javax.swing.JComponent; import javax.swing.JTable; import javax.swing.table.DefaultTableModel; *************** *** 34,60 **** * Converts CSV content to table view. */ ! public class TableViewer extends JTable { ! private JreepadArticle article; public TableViewer(JreepadArticle article) { ! super(getTableModel(article)); ! this.article = article; ! setAutoResizeMode(JTable.AUTO_RESIZE_OFF); ! setGridColor(Color.GRAY); ! setShowGrid(true); ! setShowVerticalLines(true); ! setShowHorizontalLines(true); } ! public void setArticle(JreepadArticle article) { ! this.article = article; ! reloadArticle(); } public void reloadArticle() { ! setModel(getTableModel(article)); } --- 35,61 ---- * Converts CSV content to table view. */ ! public class TableViewer extends AbstractArticleView { ! private JTable table; public TableViewer(JreepadArticle article) { ! super(article); ! table = new JTable(getTableModel(article)); ! table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); ! table.setGridColor(Color.GRAY); ! table.setShowGrid(true); ! table.setShowVerticalLines(true); ! table.setShowHorizontalLines(true); } ! public JComponent getComponent() { ! return table; } + public void reloadArticle() { ! table.setModel(getTableModel(article)); } *************** *** 70,75 **** public String getText() { ! int w = getColumnCount(); ! int h = getRowCount(); StringBuffer csv = new StringBuffer(); String quoteMark = getPrefs().addQuotesToCsvOutput ? "\"" : ""; --- 71,76 ---- public String getText() { ! int w = table.getColumnCount(); ! int h = table.getRowCount(); StringBuffer csv = new StringBuffer(); String quoteMark = getPrefs().addQuotesToCsvOutput ? "\"" : ""; *************** *** 77,84 **** { for (int j = 0; j < (w - 1); j++) ! csv.append(quoteMark + (String) getValueAt(i, j) + quoteMark ! + ","); ! csv.append(quoteMark + (String) getValueAt(i, w - 1) + quoteMark ! + "\n"); } return csv.toString(); --- 78,83 ---- { for (int j = 0; j < (w - 1); j++) ! csv.append(quoteMark + (String) table.getValueAt(i, j) + quoteMark + ","); ! csv.append(quoteMark + (String) table.getValueAt(i, w - 1) + quoteMark + "\n"); } return csv.toString(); *************** *** 87,95 **** public String getSelectedText() { ! int x = getSelectedColumn(); ! int y = getSelectedRow(); if(x==-1 || y ==-1) return ""; ! return getValueAt(y,x).toString(); } --- 86,94 ---- public String getSelectedText() { ! int x = table.getSelectedColumn(); ! int y = table.getSelectedRow(); if(x==-1 || y ==-1) return ""; ! return table.getValueAt(y,x).toString(); } |
From: PeWu <pe...@us...> - 2007-02-07 21:19:16
|
Update of /cvsroot/jreepad/jreepad/src/jreepad In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv22782/src/jreepad Modified Files: JreepadView.java Log Message: refactoring: Moved TableViewer to ArticleView interface Index: JreepadView.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadView.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** JreepadView.java 7 Feb 2007 21:10:44 -0000 1.42 --- JreepadView.java 7 Feb 2007 21:19:11 -0000 1.43 *************** *** 1011,1015 **** break; case JreepadArticle.ARTICLEMODE_CSV: ! currentArticleView = editorPaneCsv; break; default: --- 1011,1015 ---- break; case JreepadArticle.ARTICLEMODE_CSV: ! currentArticleView = editorPaneCsv.getComponent(); break; default: |
Update of /cvsroot/jreepad/jreepad/src/jreepad/editor In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv18896/src/jreepad/editor Modified Files: HtmlViewer.java TextileViewer.java PlainTextEditor.java ArticleView.java AbstractArticleView.java Added Files: EditorPaneView.java Log Message: refactoring: Changed HtmlViewer to ArticleView interface Index: TextileViewer.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/editor/TextileViewer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TextileViewer.java 6 Feb 2007 11:10:10 -0000 1.1 --- TextileViewer.java 7 Feb 2007 21:10:43 -0000 1.2 *************** *** 25,29 **** /** ! * The plain text editor pane. */ public class TextileViewer extends HtmlViewer --- 25,29 ---- /** ! * The Textile viewer pane. */ public class TextileViewer extends HtmlViewer *************** *** 38,42 **** try { ! setText(JTextile.textile(article.getContent())); } catch (Exception e) --- 38,42 ---- try { ! editorPane.setText(JTextile.textile(article.getContent())); } catch (Exception e) Index: HtmlViewer.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/editor/HtmlViewer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HtmlViewer.java 6 Feb 2007 11:10:10 -0000 1.1 --- HtmlViewer.java 7 Feb 2007 21:10:43 -0000 1.2 *************** *** 20,51 **** package jreepad.editor; - import javax.swing.JEditorPane; - import jreepad.JreepadArticle; /** ! * The plain text editor pane. */ ! public class HtmlViewer extends JEditorPane { - protected JreepadArticle article; - public HtmlViewer(JreepadArticle article) { ! super("text/html", ""); ! this.article = article; ! setEditable(false); ! reloadArticle(); ! } ! ! public void reloadArticle() ! { ! setText(article.getContent()); ! } ! ! public void setArticle(JreepadArticle article) ! { ! this.article = article; ! reloadArticle(); } } --- 20,34 ---- package jreepad.editor; import jreepad.JreepadArticle; /** ! * The plain HTML viewer pane. */ ! public class HtmlViewer extends EditorPaneView { public HtmlViewer(JreepadArticle article) { ! super("text/html", article); ! editorPane.setEditable(false); } } Index: PlainTextEditor.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/editor/PlainTextEditor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PlainTextEditor.java 7 Feb 2007 20:16:20 -0000 1.3 --- PlainTextEditor.java 7 Feb 2007 21:10:43 -0000 1.4 *************** *** 20,25 **** package jreepad.editor; - import javax.swing.JComponent; - import javax.swing.JEditorPane; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; --- 20,23 ---- *************** *** 46,59 **** * The plain text editor pane. */ ! public class PlainTextEditor extends AbstractArticleView implements CaretListener, UndoableEditListener { - private JEditorPane editorPane; - private ContentChangeListener contentChangeListener = null; public PlainTextEditor(JreepadArticle article) { ! super(article); ! editorPane = new JEditorPane("text/plain", article.getContent()); editorPane.setEditable(true); --- 44,54 ---- * The plain text editor pane. */ ! public class PlainTextEditor extends EditorPaneView implements CaretListener, UndoableEditListener { private ContentChangeListener contentChangeListener = null; public PlainTextEditor(JreepadArticle article) { ! super("text/plain", article); editorPane.setEditable(true); *************** *** 83,107 **** } ! public void reloadArticle() ! { ! editorPane.setText(article.getContent()); ! } ! ! public JComponent getComponent() ! { ! return editorPane; ! } ! ! public String getText() ! { ! return editorPane.getText(); ! } ! ! public String getSelectedText() ! { ! return editorPane.getSelectedText(); ! } ! ! public void setContentChangeListener(ContentChangeListener listener) { contentChangeListener = listener; --- 78,82 ---- } ! public void setContentChangeListener(ContentChangeListener listener) { contentChangeListener = listener; Index: ArticleView.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/editor/ArticleView.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ArticleView.java 7 Feb 2007 20:16:20 -0000 1.1 --- ArticleView.java 7 Feb 2007 21:10:43 -0000 1.2 *************** *** 1,2 **** --- 1,21 ---- + /* + Jreepad - personal information manager. + Copyright (C) 2004 Dan Stowell + + 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 (at your option) 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. + + The full license can be read online here: + + http://www.gnu.org/copyleft/gpl.html + */ + package jreepad.editor; --- NEW FILE: EditorPaneView.java --- /* Jreepad - personal information manager. Copyright (C) 2004 Dan Stowell 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 (at your option) 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. The full license can be read online here: http://www.gnu.org/copyleft/gpl.html */ package jreepad.editor; import javax.swing.JComponent; import javax.swing.JEditorPane; import jreepad.JreepadArticle; /** * Abstract article view in the form of a JEditorPane. * * @author <a href="mailto:pe...@lo...">Przemek WiÄch</a> * @version $Id: EditorPaneView.java,v 1.1 2007/02/07 21:10:43 pewu Exp $ */ public abstract class EditorPaneView extends AbstractArticleView { protected JEditorPane editorPane; public EditorPaneView(String type, JreepadArticle article) { super(article); editorPane = new JEditorPane(type, ""); reloadArticle(); } public void reloadArticle() { editorPane.setText(article.getContent()); } public JComponent getComponent() { return editorPane; } public String getText() { return editorPane.getText(); } public String getSelectedText() { return editorPane.getSelectedText(); } } Index: AbstractArticleView.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/editor/AbstractArticleView.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AbstractArticleView.java 7 Feb 2007 20:16:20 -0000 1.1 --- AbstractArticleView.java 7 Feb 2007 21:10:43 -0000 1.2 *************** *** 1,6 **** --- 1,32 ---- + /* + Jreepad - personal information manager. + Copyright (C) 2004 Dan Stowell + + 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 (at your option) 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. + + The full license can be read online here: + + http://www.gnu.org/copyleft/gpl.html + */ + package jreepad.editor; import jreepad.JreepadArticle; + /** + * Abstract implementation of ArticleView. + * Several basic methods are implemented. + * + * @author <a href="mailto:pe...@lo...">Przemek WiÄch</a> + * @version $Id$ + */ public abstract class AbstractArticleView implements ArticleView { |
From: PeWu <pe...@us...> - 2007-02-07 21:10:51
|
Update of /cvsroot/jreepad/jreepad/src/jreepad In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv18896/src/jreepad Modified Files: JreepadView.java Log Message: refactoring: Changed HtmlViewer to ArticleView interface Index: JreepadView.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadView.java,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** JreepadView.java 7 Feb 2007 20:16:20 -0000 1.41 --- JreepadView.java 7 Feb 2007 21:10:44 -0000 1.42 *************** *** 1005,1012 **** break; case JreepadArticle.ARTICLEMODE_HTML: ! currentArticleView = editorPaneHtml; break; case JreepadArticle.ARTICLEMODE_TEXTILEHTML: ! currentArticleView = editorPaneTextile; break; case JreepadArticle.ARTICLEMODE_CSV: --- 1005,1012 ---- break; case JreepadArticle.ARTICLEMODE_HTML: ! currentArticleView = editorPaneHtml.getComponent(); break; case JreepadArticle.ARTICLEMODE_TEXTILEHTML: ! currentArticleView = editorPaneTextile.getComponent(); break; case JreepadArticle.ARTICLEMODE_CSV: |
From: PeWu <pe...@us...> - 2007-02-07 20:37:36
|
Update of /cvsroot/jreepad/jreepad/src/jreepad/editor In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25085/src/jreepad/editor Modified Files: PlainTextEditor.java Added Files: ArticleView.java AbstractArticleView.java Log Message: refactoring: Started new ArticleView interface. Moved PlainTextEditor to new interface --- NEW FILE: AbstractArticleView.java --- package jreepad.editor; import jreepad.JreepadArticle; public abstract class AbstractArticleView implements ArticleView { protected JreepadArticle article; // The following boolean should be TRUE while we're changing from node to // node, and false otherwise protected boolean editLocked = false; public AbstractArticleView(JreepadArticle article) { this.article = article; } public void lockEdits() { editLocked = true; } public void unlockEdits() { editLocked = false; } public void saveArticle() { article.setContent(getText()); } public void setArticle(JreepadArticle article) { this.article = article; reloadArticle(); } } Index: PlainTextEditor.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/editor/PlainTextEditor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PlainTextEditor.java 7 Feb 2007 17:39:16 -0000 1.2 --- PlainTextEditor.java 7 Feb 2007 20:16:20 -0000 1.3 *************** *** 20,23 **** --- 20,24 ---- package jreepad.editor; + import javax.swing.JComponent; import javax.swing.JEditorPane; import javax.swing.event.CaretEvent; *************** *** 45,82 **** * The plain text editor pane. */ ! public class PlainTextEditor extends JEditorPane implements CaretListener, UndoableEditListener { ! private JreepadArticle article; private ContentChangeListener contentChangeListener = null; - // The following boolean should be TRUE while we're changing from node to - // node, and false otherwise - private boolean editLocked = false; - public PlainTextEditor(JreepadArticle article) { ! super("text/plain", article.getContent()); ! this.article = article; ! setEditable(true); if (getPrefs().wrapToWindow) ! setEditorKit(new JPEditorKit()); // Add a listener to make sure the editorpane's content is always stored // when it changes ! addCaretListener(this); ! getDocument().addUndoableEditListener(this); } public void insertText(String text) { ! Document doc = getDocument(); ! int here = getCaretPosition(); try { ! setText(doc.getText(0, here) + text + doc.getText(here, doc.getLength() - here)); ! setCaretPosition(here + text.length()); } catch (BadLocationException e) --- 46,79 ---- * The plain text editor pane. */ ! public class PlainTextEditor extends AbstractArticleView implements CaretListener, UndoableEditListener { ! private JEditorPane editorPane; private ContentChangeListener contentChangeListener = null; public PlainTextEditor(JreepadArticle article) { ! super(article); ! editorPane = new JEditorPane("text/plain", article.getContent()); ! editorPane.setEditable(true); if (getPrefs().wrapToWindow) ! editorPane.setEditorKit(new JPEditorKit()); // Add a listener to make sure the editorpane's content is always stored // when it changes ! editorPane.addCaretListener(this); ! editorPane.getDocument().addUndoableEditListener(this); } public void insertText(String text) { ! Document doc = editorPane.getDocument(); ! int here = editorPane.getCaretPosition(); try { ! editorPane.setText(doc.getText(0, here) + text + doc.getText(here, doc.getLength() - here)); ! editorPane.setCaretPosition(here + text.length()); } catch (BadLocationException e) *************** *** 88,113 **** public void reloadArticle() { ! setText(article.getContent()); } ! public void setArticle(JreepadArticle article) ! { ! this.article = article; ! setText(article.getContent()); ! } ! ! public void lockEdits() { ! editLocked = true; } ! public void unlockEdits() { ! editLocked = false; } ! public boolean isEditLocked() { ! return editLocked; } --- 85,104 ---- public void reloadArticle() { ! editorPane.setText(article.getContent()); } ! public JComponent getComponent() { ! return editorPane; } ! public String getText() { ! return editorPane.getText(); } ! public String getSelectedText() { ! return editorPane.getSelectedText(); } *************** *** 127,132 **** try { ! String text = getText(); ! int startpos = getCaretPosition(); int endpos = startpos; if (text.length() > 0) --- 118,123 ---- try { ! String text = editorPane.getText(); ! int startpos = editorPane.getCaretPosition(); int endpos = startpos; if (text.length() > 0) *************** *** 134,145 **** // Select the character before/after the current position, and // grow it until we hit whitespace... ! while (startpos > 0 && !Character.isWhitespace(getText(startpos - 1, 1).charAt(0))) startpos--; ! while (endpos < (text.length()) && !Character.isWhitespace(getText(endpos, 1).charAt(0))) endpos++; if (endpos > startpos) { ! setSelectionStart(startpos); ! setSelectionEnd(endpos); return getSelectedText(); } --- 125,136 ---- // Select the character before/after the current position, and // grow it until we hit whitespace... ! while (startpos > 0 && !Character.isWhitespace(editorPane.getText(startpos - 1, 1).charAt(0))) startpos--; ! while (endpos < (text.length()) && !Character.isWhitespace(editorPane.getText(endpos, 1).charAt(0))) endpos++; if (endpos > startpos) { ! editorPane.setSelectionStart(startpos); ! editorPane.setSelectionEnd(endpos); return getSelectedText(); } *************** *** 159,167 **** return; // i.e. we are only relevant when in plain-text mode ! if (!getText().equals(article.getContent())) { // System.out.println("UPDATE - I'd now overwrite node content with // editorpane content"); ! article.setContent(getText()); notifyContentChangeListener(); } --- 150,158 ---- return; // i.e. we are only relevant when in plain-text mode ! if (!editorPane.getText().equals(article.getContent())) { // System.out.println("UPDATE - I'd now overwrite node content with // editorpane content"); ! article.setContent(editorPane.getText()); notifyContentChangeListener(); } --- NEW FILE: ArticleView.java --- package jreepad.editor; import javax.swing.JComponent; import jreepad.JreepadArticle; /** * Interface for an article viewer or editor. * * @author <a href="mailto:pe...@lo...">Przemek WiÄch</a> * @version $Id: ArticleView.java,v 1.1 2007/02/07 20:16:20 pewu Exp $ */ public interface ArticleView { /** * Returns the GUI viewer/editor component. */ public JComponent getComponent(); /** * Returns selected text in view. */ public String getSelectedText(); /** * Reloads the article. * Transfers data from article to view. */ public void reloadArticle(); /** * Saves the current article. * Transfers data from view to article. */ public void saveArticle(); /** * Returns the content text. */ public String getText(); /** * Sets new article content. */ public void setArticle(JreepadArticle article); /** * Lock editor - no edits will be allowed. */ public void lockEdits(); /** * Unlock editor - edits will now be allowed. */ public void unlockEdits(); } |
From: PeWu <pe...@us...> - 2007-02-07 20:36:51
|
Update of /cvsroot/jreepad/jreepad/src/jreepad In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25085/src/jreepad Modified Files: JreepadView.java Log Message: refactoring: Started new ArticleView interface. Moved PlainTextEditor to new interface Index: JreepadView.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadView.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** JreepadView.java 7 Feb 2007 17:39:16 -0000 1.40 --- JreepadView.java 7 Feb 2007 20:16:20 -0000 1.41 *************** *** 40,44 **** import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; - import javax.swing.text.BadLocationException; import javax.swing.tree.TreePath; --- 40,43 ---- *************** *** 996,1000 **** if(currentNode==null) { ! currentArticleView = editorPanePlainText; return currentArticleView; // This is a bit of a hack - it shouldn't really even be called to act on null } --- 995,999 ---- if(currentNode==null) { ! currentArticleView = editorPanePlainText.getComponent(); return currentArticleView; // This is a bit of a hack - it shouldn't really even be called to act on null } *************** *** 1003,1007 **** { case JreepadArticle.ARTICLEMODE_ORDINARY: ! currentArticleView = editorPanePlainText; break; case JreepadArticle.ARTICLEMODE_HTML: --- 1002,1006 ---- { case JreepadArticle.ARTICLEMODE_ORDINARY: ! currentArticleView = editorPanePlainText.getComponent(); break; case JreepadArticle.ARTICLEMODE_HTML: |
From: PeWu <pe...@us...> - 2007-02-07 17:39:33
|
Update of /cvsroot/jreepad/jreepad/src/jreepad In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv18867/src/jreepad Modified Files: JreepadView.java Log Message: moved selectWordUnderCursor() to PlainTextEditor; code cleanup Index: JreepadView.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadView.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** JreepadView.java 6 Feb 2007 20:58:01 -0000 1.39 --- JreepadView.java 7 Feb 2007 17:39:16 -0000 1.40 *************** *** 274,301 **** private void setCurrentNode(JreepadNode n) { ! boolean isSame = currentNode!=null && n.equals(currentNode); ! //System.out.println("setCurrentNode() activated: sameness test = "+isSame); ! // ! // This "isSame" test should stop the caret jumping to the end of the text when we press Save. ! // ! if(isSame) ! { ! // Only update the node's stored content if it's a plaintext node ! if(currentNode.getArticle().getArticleMode() == JreepadArticle.ARTICLEMODE_ORDINARY) ! currentNode.getArticle().setContent(getEditorPaneText()); return; - } editorPanePlainText.lockEdits(); // Deactivate the caret-listener, effectively - ALSO DEACTIVATES UNDO-STORAGE - if(currentNode != null) - { - // Only update the node's stored content if it's a plaintext node - if(currentNode.getArticle().getArticleMode() == JreepadArticle.ARTICLEMODE_ORDINARY) - currentNode.getArticle().setContent(getEditorPaneText()); - } currentNode = n; setEditorPaneText(n.getArticle()); ensureCorrectArticleRenderMode(); editorPanePlainText.unlockEdits(); // Reactivate the caret listener - ALSO REACTIVATES UNDO-STORAGE } --- 274,287 ---- private void setCurrentNode(JreepadNode n) { ! // This should stop the caret jumping to the end of the text when we press Save. ! if (currentNode == n) return; editorPanePlainText.lockEdits(); // Deactivate the caret-listener, effectively - ALSO DEACTIVATES UNDO-STORAGE currentNode = n; setEditorPaneText(n.getArticle()); ensureCorrectArticleRenderMode(); + editorPanePlainText.unlockEdits(); // Reactivate the caret listener - ALSO REACTIVATES UNDO-STORAGE } *************** *** 308,312 **** public JreepadNode getRootJreepadNode() { - setCurrentNode(getCurrentNode()); // Ensures any edits have been committed return root; } --- 294,297 ---- *************** *** 660,690 **** if((url == null) && (currentNode.getArticle().getArticleMode()==JreepadArticle.ARTICLEMODE_ORDINARY)) ! { ! try ! { ! ! String text = getEditorPaneText(); ! int startpos = editorPanePlainText.getCaretPosition(); ! int endpos = startpos; ! if(text.length()>0) ! { ! // Select the character before/after the current position, and grow it until we hit whitespace... ! while(startpos>0 && !Character.isWhitespace(editorPanePlainText.getText(startpos-1,1).charAt(0))) ! startpos--; ! while(endpos<(text.length()) && !Character.isWhitespace(editorPanePlainText.getText(endpos,1).charAt(0))) ! endpos++; ! if(endpos>startpos) ! { ! editorPanePlainText.setSelectionStart(startpos); ! editorPanePlainText.setSelectionEnd(endpos); ! url = editorPanePlainText.getSelectedText(); ! } ! } ! } ! catch(BadLocationException err) ! { ! System.out.println(err); ! } ! } if(url==null || !(url.length()>0)) --- 645,649 ---- if((url == null) && (currentNode.getArticle().getArticleMode()==JreepadArticle.ARTICLEMODE_ORDINARY)) ! url = editorPanePlainText.selectWordUnderCursor(); if(url==null || !(url.length()>0)) *************** *** 703,732 **** String url = getSelectedTextInArticle(); if((url == null) && (currentNode.getArticle().getArticleMode()==JreepadArticle.ARTICLEMODE_ORDINARY)) ! { ! try ! { ! ! String text = getEditorPaneText(); ! int startpos = editorPanePlainText.getCaretPosition(); ! int endpos = startpos; ! if(text != null) ! { ! // Select the character before/after the current position, and grow it until we hit whitespace... ! while(startpos>0 && !Character.isWhitespace(editorPanePlainText.getText(startpos-1,1).charAt(0))) ! startpos--; ! while(endpos<(text.length()) && !Character.isWhitespace(editorPanePlainText.getText(endpos,1).charAt(0))) ! endpos++; ! if(endpos>startpos) ! { ! editorPanePlainText.setSelectionStart(startpos); ! editorPanePlainText.setSelectionEnd(endpos); ! url = editorPanePlainText.getSelectedText(); ! } ! } ! } ! catch(BadLocationException err) ! { ! } ! } openURL(url); } --- 662,666 ---- String url = getSelectedTextInArticle(); if((url == null) && (currentNode.getArticle().getArticleMode()==JreepadArticle.ARTICLEMODE_ORDINARY)) ! url = editorPanePlainText.selectWordUnderCursor(); openURL(url); } *************** *** 1029,1033 **** editorPanePlainText.lockEdits(); // Disables store-for-undo - currentNode.getArticle().setContent(editorPanePlainText.getText()); switch(newMode) { --- 963,966 ---- |
From: PeWu <pe...@us...> - 2007-02-07 17:39:21
|
Update of /cvsroot/jreepad/jreepad/src/jreepad/editor In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv18867/src/jreepad/editor Modified Files: PlainTextEditor.java Log Message: moved selectWordUnderCursor() to PlainTextEditor; code cleanup Index: PlainTextEditor.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/editor/PlainTextEditor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PlainTextEditor.java 5 Feb 2007 10:56:43 -0000 1.1 --- PlainTextEditor.java 7 Feb 2007 17:39:16 -0000 1.2 *************** *** 123,126 **** --- 123,155 ---- } + public String selectWordUnderCursor() + { + try + { + String text = getText(); + int startpos = getCaretPosition(); + int endpos = startpos; + if (text.length() > 0) + { + // Select the character before/after the current position, and + // grow it until we hit whitespace... + while (startpos > 0 && !Character.isWhitespace(getText(startpos - 1, 1).charAt(0))) + startpos--; + while (endpos < (text.length()) && !Character.isWhitespace(getText(endpos, 1).charAt(0))) + endpos++; + if (endpos > startpos) + { + setSelectionStart(startpos); + setSelectionEnd(endpos); + return getSelectedText(); + } + } + } + catch (BadLocationException e) + { + } + return ""; + } + public void caretUpdate(CaretEvent e) { |
From: PeWu <pe...@us...> - 2007-02-06 20:58:21
|
Update of /cvsroot/jreepad/jreepad/src/jreepad In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv1321/src/jreepad Modified Files: JreepadView.java Log Message: code cleanup Index: JreepadView.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadView.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** JreepadView.java 6 Feb 2007 18:33:09 -0000 1.38 --- JreepadView.java 6 Feb 2007 20:58:01 -0000 1.39 *************** *** 271,280 **** articleView.setSize(getSize()); } ! /* ! private void setCurrentNode(DefaultMutableTreeNode node) ! { ! setCurrentNode((JreepadNode)(node.getUserObject())); ! } ! */ private void setCurrentNode(JreepadNode n) { --- 271,275 ---- articleView.setSize(getSize()); } ! private void setCurrentNode(JreepadNode n) { *************** *** 302,307 **** currentNode = n; setEditorPaneText(n.getArticle()); - // editorPanePlainText.setText(n.getContent()); - // editorPaneHtml.setText(n.getContent()); ensureCorrectArticleRenderMode(); editorPanePlainText.unlockEdits(); // Reactivate the caret listener - ALSO REACTIVATES UNDO-STORAGE --- 297,300 ---- *************** *** 312,315 **** --- 305,309 ---- return tree; } + public JreepadNode getRootJreepadNode() { *************** *** 317,320 **** --- 311,315 ---- return root; } + public JreepadNode getCurrentNode() { *************** *** 331,336 **** } - - public void indentCurrentNode() { --- 326,329 ---- *************** *** 359,362 **** --- 352,356 ---- } } + public void outdentCurrentNode() { *************** *** 399,402 **** --- 393,397 ---- tree.setSelectionPath(nodePath); } + public void moveCurrentNodeDown() { *************** *** 475,478 **** --- 470,474 ---- return ret; } + public JreepadNode addNodeBelow() { *************** *** 495,498 **** --- 491,495 ---- return ret; } + public JreepadNode addNode() { *************** *** 508,511 **** --- 505,509 ---- return ret; } + public JreepadNode removeNode() { *************** *** 536,539 **** --- 534,538 ---- // System.out.println(currentNode.toFullString()); } + public void sortChildrenRecursive() { *************** *** 553,556 **** --- 552,556 ---- tree.expandAll(currentNode, tree.getLeadSelectionPath()); } + public void collapseAllCurrentNode() { *************** *** 585,588 **** --- 585,589 ---- return true; } + public JreepadSearcher.JreepadSearchResult[] getSearchResults() { *************** *** 649,701 **** } - - /* - - DEPRECATED - I wrote this before discovering Java's UndoManager. - - - - // Stuff concerned with undo - public void undoAction() - { - if(!canWeUndo()) - return; - - // Swap the old root / selectionpath / expandedpaths for the current ones - JreepadNode tempRoot = root; - root = oldRootForUndo; - oldRootForUndo = tempRoot; - - // Fire a tree-structure-changed event for the entire tree - treeModel.setRoot(root); - treeModel.reload(root); - // Set the correct selection and expanded paths - tree.setSelectionPath(oldSelectedPath); // I hope this ends up firing the setCurrentNode() function... - - editorPanePlainText.setText(currentNode.getContent()); - editorPaneHtml.setText(currentNode.getContent()); - repaint(); - } - public boolean canWeUndo() - { - return oldRootForUndo != null; - } - private void storeForUndo() - { - // Use JreepadNode.getCopy() on the root node to get a copy of the whole tree - oldRootForUndo = root.getCopy(); - // Also get the tree's entire set of open TreePaths and selected TreePaths - oldSelectedPath = tree.getSelectionPath(); - } - void clearUndoCache() - { - oldRootForUndo = null; - } - // End of: stuff concerned with undo - - */ - - - // Stuff concerned with linking public void webSearchTextSelectedInArticle() --- 650,653 ---- *************** *** 741,748 **** --- 693,702 ---- webSearchText(url); } + public void webSearchText(String text) { openURL("http://" + getPrefs().webSearchPrefix + text + getPrefs().webSearchPostfix); } + public void openURLSelectedInArticle() { *************** *** 777,780 **** --- 731,735 ---- openURL(url); } + public static boolean isPureWord(String in) { *************** *** 785,788 **** --- 740,744 ---- return true; } + public static boolean isWikiWord(String in) { *************** *** 810,813 **** --- 766,770 ---- return uppers>1; } + public void openURL(String url) { *************** *** 982,985 **** --- 939,943 ---- tree.setSelectionPath(tp); } + public TreePath findNearestNodeTitled(String text) { *************** *** 996,1003 **** --- 954,963 ---- return null; } + public TreePath findChildTitled(String text) { return findChildTitled(text, tree.getLeadSelectionPath()); } + public TreePath findChildTitled(String text, TreePath pathToNode) { *************** *** 1027,1030 **** --- 987,991 ---- return warnAboutUnsaved; } + void setWarnAboutUnsaved(boolean yo) { *************** *** 1051,1054 **** --- 1012,1016 ---- setWarnAboutUnsaved(true); } + public void stripAllTags() { *************** *** 1065,1071 **** public void setArticleMode(int newMode) { - // System.out.println("\n\n\nnode content : " + currentNode.getContent() - // + "\neditorPanePlainText contains: " + editorPanePlainText.getText()); - editorPanePlainText.lockEdits(); // Disables store-for-undo --- 1027,1030 ---- *************** *** 1074,1078 **** { case JreepadArticle.ARTICLEMODE_ORDINARY: - // DELETEME - PLAINTEXT SHOULD NOT BE AFFECTED BY OTHERS editorPanePlainText.reloadArticle(); break; --- 1033,1036 ---- *************** *** 1147,1150 **** --- 1105,1109 ---- } } + void setEditorPaneText(JreepadArticle a) { *************** *** 1167,1198 **** { warnAboutUnsaved = true; - // Object[] parentPath = e.getPath(); // Parent of the changed node(s) - // int[] children = e.getChildIndices(); // Indices of the changed node(s) - // JreepadNode parent = (JreepadNode)(parentPath[parentPath.length-1]); tree.repaint(); } public void treeNodesInserted(TreeModelEvent e) { warnAboutUnsaved = true; - Object[] parentPath = e.getPath(); // Parent of the new node(s) - int[] children = e.getChildIndices(); // Indices of the new node(s) - JreepadNode parent = (JreepadNode)(parentPath[parentPath.length-1]); tree.expandPath(e.getTreePath()); tree.scrollPathToVisible(e.getTreePath()); tree.repaint(); } public void treeNodesRemoved(TreeModelEvent e) { warnAboutUnsaved = true; - Object[] parentPath = e.getPath(); // Parent of the removed node(s) - int[] children = e.getChildIndices(); // Indices the node(s) had before they were removed - JreepadNode parent = (JreepadNode)(parentPath[parentPath.length-1]); tree.repaint(); } public void treeStructureChanged(TreeModelEvent e) { warnAboutUnsaved = true; - Object[] parentPath = e.getPath(); // Parent of the changed node(s) - JreepadNode parent = (JreepadNode)(parentPath[parentPath.length-1]); tree.repaint(); } --- 1126,1149 ---- { warnAboutUnsaved = true; tree.repaint(); } + public void treeNodesInserted(TreeModelEvent e) { warnAboutUnsaved = true; tree.expandPath(e.getTreePath()); tree.scrollPathToVisible(e.getTreePath()); tree.repaint(); } + public void treeNodesRemoved(TreeModelEvent e) { warnAboutUnsaved = true; tree.repaint(); } + public void treeStructureChanged(TreeModelEvent e) { warnAboutUnsaved = true; tree.repaint(); } |
From: PeWu <pe...@us...> - 2007-02-06 18:33:21
|
Update of /cvsroot/jreepad/jreepad/src/jreepad/editor In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv341/src/jreepad/editor Added Files: TableViewer.java Log Message: refactoring: refactored TableViewer from JreepadView --- NEW FILE: TableViewer.java --- /* Jreepad - personal information manager. Copyright (C) 2004 Dan Stowell 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 (at your option) 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. The full license can be read online here: http://www.gnu.org/copyleft/gpl.html */ package jreepad.editor; import java.awt.Color; import javax.swing.JTable; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; import jreepad.JreepadArticle; import jreepad.JreepadPrefs; import jreepad.JreepadView; /** * The table view pane. * Converts CSV content to table view. */ public class TableViewer extends JTable { private JreepadArticle article; public TableViewer(JreepadArticle article) { super(getTableModel(article)); this.article = article; setAutoResizeMode(JTable.AUTO_RESIZE_OFF); setGridColor(Color.GRAY); setShowGrid(true); setShowVerticalLines(true); setShowHorizontalLines(true); } public void setArticle(JreepadArticle article) { this.article = article; reloadArticle(); } public void reloadArticle() { setModel(getTableModel(article)); } private static TableModel getTableModel(JreepadArticle a) { String[][] rowData = a.interpretContentAsCsv(); String[] columnNames = new String[rowData[0].length]; for (int i = 0; i < columnNames.length; i++) columnNames[i] = " "; return new ArticleTableModel(rowData, columnNames); } public String getText() { int w = getColumnCount(); int h = getRowCount(); StringBuffer csv = new StringBuffer(); String quoteMark = getPrefs().addQuotesToCsvOutput ? "\"" : ""; for (int i = 0; i < h; i++) { for (int j = 0; j < (w - 1); j++) csv.append(quoteMark + (String) getValueAt(i, j) + quoteMark + ","); csv.append(quoteMark + (String) getValueAt(i, w - 1) + quoteMark + "\n"); } return csv.toString(); } public String getSelectedText() { int x = getSelectedColumn(); int y = getSelectedRow(); if(x==-1 || y ==-1) return ""; return getValueAt(y,x).toString(); } public static JreepadPrefs getPrefs() { return JreepadView.getPrefs(); } private static class ArticleTableModel extends DefaultTableModel { public ArticleTableModel(Object[][] data, Object[] columnNames) { super(data, columnNames); } public ArticleTableModel() { super(); } public boolean isCellEditable(int row, int col) { return false; } } // End of: class ArticleTableModel } |
From: PeWu <pe...@us...> - 2007-02-06 18:33:20
|
Update of /cvsroot/jreepad/jreepad/src/jreepad In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv341/src/jreepad Modified Files: JreepadPrefs.java JreepadView.java Log Message: refactoring: refactored TableViewer from JreepadView Index: JreepadView.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadView.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** JreepadView.java 6 Feb 2007 11:10:11 -0000 1.37 --- JreepadView.java 6 Feb 2007 18:33:09 -0000 1.38 *************** *** 20,27 **** package jreepad; - import java.awt.Color; - import java.awt.Dimension; - import java.awt.event.ComponentEvent; - import java.awt.event.ComponentListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; --- 20,23 ---- *************** *** 39,53 **** import javax.swing.JScrollPane; import javax.swing.JSplitPane; - import javax.swing.JTable; import javax.swing.JTree; - import javax.swing.event.ChangeEvent; - import javax.swing.event.ChangeListener; - import javax.swing.event.TableModelEvent; - import javax.swing.event.TableModelListener; import javax.swing.event.TreeModelEvent; import javax.swing.event.TreeModelListener; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; - import javax.swing.table.DefaultTableModel; import javax.swing.text.BadLocationException; import javax.swing.tree.TreePath; --- 35,43 ---- *************** *** 56,59 **** --- 46,50 ---- import jreepad.editor.HtmlViewer; import jreepad.editor.PlainTextEditor; + import jreepad.editor.TableViewer; import jreepad.editor.TextileViewer; import edu.stanford.ejalbert.BrowserLauncher; *************** *** 62,66 **** import edu.stanford.ejalbert.exception.UnsupportedOperatingSystemException; ! public class JreepadView extends Box implements TableModelListener { --- 53,57 ---- import edu.stanford.ejalbert.exception.UnsupportedOperatingSystemException; ! public class JreepadView extends Box { *************** *** 80,84 **** private HtmlViewer editorPaneHtml; private TextileViewer editorPaneTextile; ! private JTable editorPaneCsv; private JComponent currentArticleView; --- 71,75 ---- private HtmlViewer editorPaneHtml; private TextileViewer editorPaneTextile; ! private TableViewer editorPaneCsv; private JComponent currentArticleView; *************** *** 175,180 **** editorPaneHtml = new HtmlViewer(root.getArticle()); editorPaneTextile = new TextileViewer(root.getArticle()); ! editorPaneCsv = new JTable(new ArticleTableModel()); ! editorPaneCsv.getModel().addTableModelListener(this); articleView = new JScrollPane(getEditorPaneComponent(), JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); --- 166,170 ---- editorPaneHtml = new HtmlViewer(root.getArticle()); editorPaneTextile = new TextileViewer(root.getArticle()); ! editorPaneCsv = new TableViewer(root.getArticle()); articleView = new JScrollPane(getEditorPaneComponent(), JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); *************** *** 638,646 **** { case JreepadArticle.ARTICLEMODE_CSV: ! int x = editorPaneCsv.getSelectedColumn(); ! int y = editorPaneCsv.getSelectedRow(); ! if(x==-1 || y ==-1) ! return ""; ! return editorPaneCsv.getValueAt(y,x).toString(); case JreepadArticle.ARTICLEMODE_HTML: return editorPaneHtml.getSelectedText(); --- 628,632 ---- { case JreepadArticle.ARTICLEMODE_CSV: ! return editorPaneCsv.getSelectedText(); case JreepadArticle.ARTICLEMODE_HTML: return editorPaneHtml.getSelectedText(); *************** *** 1062,1065 **** --- 1048,1052 ---- editorPaneHtml.reloadArticle(); editorPaneTextile.reloadArticle(); + editorPaneCsv.reloadArticle(); setWarnAboutUnsaved(true); } *************** *** 1071,1074 **** --- 1058,1062 ---- editorPaneHtml.reloadArticle(); editorPaneTextile.reloadArticle(); + editorPaneCsv.reloadArticle(); setWarnAboutUnsaved(true); } *************** *** 1096,1100 **** break; case JreepadArticle.ARTICLEMODE_CSV: ! articleToJTable(currentNode.getArticle()); break; default: --- 1084,1088 ---- break; case JreepadArticle.ARTICLEMODE_CSV: ! editorPaneCsv.reloadArticle(); break; default: *************** *** 1112,1149 **** } - public void articleToJTable() - { - String[][] rowData = currentNode.getArticle().interpretContentAsCsv(); - String[] columnNames = null; - - // System.out.println("articleToJTable(): rows=" + rowData.length + ", cols="+rowData[0].length); - initJTable(rowData, columnNames); - } - public void articleToJTable(JreepadArticle a) - { - String[][] rowData = a.interpretContentAsCsv(); - String[] columnNames = new String[rowData[0].length]; - for(int i=0; i<columnNames.length; i++) - columnNames[i] = " "; - - // System.out.println("articleToJTable(s): rows=" + rowData.length + ", cols="+rowData[0].length); - initJTable(rowData, columnNames); - } - - private void initJTable(String[][] rowData, String[] columnNames) - { - editorPaneCsv = new JTable(new ArticleTableModel(rowData, columnNames)); - // editorPaneCsv = new JTable(new ArticleTableModel(rowData, columnNames), - // (getCurrentNode().tblColModel==null ? new ArticleTableColumnModel(): getCurrentNode().tblColModel)); - // editorPaneCsv = new JTable(rowData, columnNames); - // editorPaneCsv.setModel(new ArticleTableModel()); - editorPaneCsv.getModel().addTableModelListener(this); - editorPaneCsv.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); - editorPaneCsv.setGridColor(Color.GRAY); - editorPaneCsv.setShowGrid(true); - editorPaneCsv.setShowVerticalLines(true); - editorPaneCsv.setShowHorizontalLines(true); - } - // The following functions allow us to use either a JEditorPane or a JTable to display article data JComponent getEditorPaneComponent() --- 1100,1103 ---- *************** *** 1187,1191 **** return editorPaneTextile.getText(); case JreepadArticle.ARTICLEMODE_CSV: ! return jTableContentToCsv(); default: System.err.println("getEditorPaneText() says: JreepadNode.getArticleMode() returned an unrecognised value"); --- 1141,1145 ---- return editorPaneTextile.getText(); case JreepadArticle.ARTICLEMODE_CSV: ! return editorPaneCsv.getText(); default: System.err.println("getEditorPaneText() says: JreepadNode.getArticleMode() returned an unrecognised value"); *************** *** 1198,1203 **** editorPaneHtml.setArticle(a); editorPaneTextile.setArticle(a); ! if (a.getArticleMode() == JreepadArticle.ARTICLEMODE_CSV) ! articleToJTable(a); } // End of: functions which should allow us to switch between JEditorPane and JTable --- 1152,1156 ---- editorPaneHtml.setArticle(a); editorPaneTextile.setArticle(a); ! editorPaneCsv.setArticle(a); } // End of: functions which should allow us to switch between JEditorPane and JTable *************** *** 1209,1235 **** } - public String jTableContentToCsv() - { - int w = editorPaneCsv.getColumnCount(); - int h = editorPaneCsv.getRowCount(); - StringBuffer csv = new StringBuffer(); - String quoteMark = getPrefs().addQuotesToCsvOutput ? "\"" : ""; - for(int i=0; i<h; i++) - { - for(int j=0; j<(w-1); j++) - csv.append(quoteMark + (String)editorPaneCsv.getValueAt(i,j) + quoteMark + ","); - csv.append(quoteMark + (String)editorPaneCsv.getValueAt(i,w-1) + quoteMark + "\n"); - } - return csv.toString(); - } - - // Called by the TableModelListener interface - public void tableChanged(TableModelEvent e) - { - // System.out.println(" -- tableChanged() -- "); - if(currentNode.getArticle().getArticleMode() == JreepadArticle.ARTICLEMODE_CSV) - currentNode.getArticle().setContent(jTableContentToCsv()); - } - class JreepadTreeModelListener implements TreeModelListener { --- 1162,1165 ---- *************** *** 1268,1285 **** } } // End of: class JreepadTreeModelListener ! ! ! class ArticleTableModel extends DefaultTableModel { ! public ArticleTableModel(Object[][] data, Object[] columnNames){ ! super(data, columnNames); ! } ! public ArticleTableModel(){ ! super(); ! } ! ! public boolean isCellEditable(int row, int col) { ! return false; ! } ! } // End of: class ArticleTableModel ! ! } \ No newline at end of file --- 1198,1200 ---- } } // End of: class JreepadTreeModelListener ! } Index: JreepadPrefs.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadPrefs.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** JreepadPrefs.java 5 Feb 2007 10:56:43 -0000 1.22 --- JreepadPrefs.java 6 Feb 2007 18:33:09 -0000 1.23 *************** *** 119,123 **** boolean autoDetectHtmlArticles; ! boolean addQuotesToCsvOutput; static final int FILETYPE_XML = 0; --- 119,123 ---- boolean autoDetectHtmlArticles; ! public boolean addQuotesToCsvOutput; static final int FILETYPE_XML = 0; |
From: PeWu <pe...@us...> - 2007-02-06 11:10:17
|
Update of /cvsroot/jreepad/jreepad/src/jreepad/editor In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv32050/src/jreepad/editor Added Files: HtmlViewer.java TextileViewer.java Log Message: refactoring: refactored HtmlViewer and TextileViewer from JreepadView --- NEW FILE: TextileViewer.java --- /* Jreepad - personal information manager. Copyright (C) 2004 Dan Stowell 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 (at your option) 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. The full license can be read online here: http://www.gnu.org/copyleft/gpl.html */ package jreepad.editor; import org.philwilson.JTextile; import jreepad.JreepadArticle; /** * The plain text editor pane. */ public class TextileViewer extends HtmlViewer { public TextileViewer(JreepadArticle article) { super(article); } public void reloadArticle() { try { setText(JTextile.textile(article.getContent())); } catch (Exception e) { // Fallback to HTML if Textile failed e.printStackTrace(); super.reloadArticle(); } } } --- NEW FILE: HtmlViewer.java --- /* Jreepad - personal information manager. Copyright (C) 2004 Dan Stowell 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 (at your option) 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. The full license can be read online here: http://www.gnu.org/copyleft/gpl.html */ package jreepad.editor; import javax.swing.JEditorPane; import jreepad.JreepadArticle; /** * The plain text editor pane. */ public class HtmlViewer extends JEditorPane { protected JreepadArticle article; public HtmlViewer(JreepadArticle article) { super("text/html", ""); this.article = article; setEditable(false); reloadArticle(); } public void reloadArticle() { setText(article.getContent()); } public void setArticle(JreepadArticle article) { this.article = article; reloadArticle(); } } |
From: PeWu <pe...@us...> - 2007-02-06 11:10:16
|
Update of /cvsroot/jreepad/jreepad/src/jreepad In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv32050/src/jreepad Modified Files: JreepadView.java Log Message: refactoring: refactored HtmlViewer and TextileViewer from JreepadView Index: JreepadView.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadView.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** JreepadView.java 5 Feb 2007 10:56:43 -0000 1.36 --- JreepadView.java 6 Feb 2007 11:10:11 -0000 1.37 *************** *** 36,40 **** import javax.swing.BoxLayout; import javax.swing.JComponent; - import javax.swing.JEditorPane; import javax.swing.JOptionPane; import javax.swing.JScrollPane; --- 36,39 ---- *************** *** 44,49 **** import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; - import javax.swing.event.DocumentEvent; - import javax.swing.event.DocumentListener; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; --- 43,46 ---- *************** *** 54,65 **** import javax.swing.table.DefaultTableModel; import javax.swing.text.BadLocationException; - import javax.swing.text.Document; import javax.swing.tree.TreePath; import jreepad.editor.ContentChangeListener; import jreepad.editor.PlainTextEditor; ! ! import org.philwilson.JTextile; ! import edu.stanford.ejalbert.BrowserLauncher; import edu.stanford.ejalbert.exception.BrowserLaunchingExecutionException; --- 51,60 ---- import javax.swing.table.DefaultTableModel; import javax.swing.text.BadLocationException; import javax.swing.tree.TreePath; import jreepad.editor.ContentChangeListener; + import jreepad.editor.HtmlViewer; import jreepad.editor.PlainTextEditor; ! import jreepad.editor.TextileViewer; import edu.stanford.ejalbert.BrowserLauncher; import edu.stanford.ejalbert.exception.BrowserLaunchingExecutionException; *************** *** 83,89 **** // private JEditorPane editorPane; private PlainTextEditor editorPanePlainText; ! private JEditorPane editorPaneHtml; private JTable editorPaneCsv; // Undo features --- 78,87 ---- // private JEditorPane editorPane; private PlainTextEditor editorPanePlainText; ! private HtmlViewer editorPaneHtml; ! private TextileViewer editorPaneTextile; private JTable editorPaneCsv; + private JComponent currentArticleView; + // Undo features *************** *** 175,184 **** editorPanePlainText = new PlainTextEditor(root.getArticle()); ! editorPaneHtml = new JEditorPanePlus("text/html", root.getContent()); ! editorPaneHtml.setEditable(false); editorPaneCsv = new JTable(new ArticleTableModel()); editorPaneCsv.getModel().addTableModelListener(this); articleView = new JScrollPane(getEditorPaneComponent(), JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); articleView.addComponentListener(new ComponentListener() { --- 173,184 ---- editorPanePlainText = new PlainTextEditor(root.getArticle()); ! editorPaneHtml = new HtmlViewer(root.getArticle()); ! editorPaneTextile = new TextileViewer(root.getArticle()); editorPaneCsv = new JTable(new ArticleTableModel()); editorPaneCsv.getModel().addTableModelListener(this); articleView = new JScrollPane(getEditorPaneComponent(), JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + + /* XXX Is this really needed? articleView.addComponentListener(new ComponentListener() { *************** *** 208,211 **** --- 208,212 ---- } ); + */ editorPanePlainText.setContentChangeListener(new ContentChangeListener() { *************** *** 246,253 **** } setSize(getSize()); ! editorPanePlainText.setPreferredSize(articleView.getViewport().getExtentSize()); ! editorPanePlainText.setSize(articleView.getViewport().getExtentSize()); ! editorPaneHtml.setPreferredSize(articleView.getViewport().getExtentSize()); ! editorPaneHtml.setSize(articleView.getViewport().getExtentSize()); validate(); repaint(); --- 247,252 ---- } setSize(getSize()); ! currentArticleView.setPreferredSize(articleView.getViewport().getExtentSize()); ! currentArticleView.setSize(articleView.getViewport().getExtentSize()); validate(); repaint(); *************** *** 461,475 **** //DEL storeForUndo(); String theDate = getCurrentDate(); - Document doc = editorPanePlainText.getDocument(); - int here = editorPanePlainText.getCaretPosition(); - try - { - editorPaneHtml.setText(doc.getText(0, here) + theDate + - doc.getText(here, doc.getLength() - here)); - } - catch(BadLocationException e) - { - // Simply ignore this - } editorPanePlainText.insertText(theDate); } --- 460,463 ---- *************** *** 657,660 **** --- 645,650 ---- case JreepadArticle.ARTICLEMODE_HTML: return editorPaneHtml.getSelectedText(); + case JreepadArticle.ARTICLEMODE_TEXTILEHTML: + return editorPaneTextile.getSelectedText(); case JreepadArticle.ARTICLEMODE_ORDINARY: default: *************** *** 1070,1074 **** currentNode.getArticle().wrapContentToCharWidth(charWidth); editorPanePlainText.reloadArticle(); ! editorPaneHtml.setText(currentNode.getContent()); setWarnAboutUnsaved(true); } --- 1060,1065 ---- currentNode.getArticle().wrapContentToCharWidth(charWidth); editorPanePlainText.reloadArticle(); ! editorPaneHtml.reloadArticle(); ! editorPaneTextile.reloadArticle(); setWarnAboutUnsaved(true); } *************** *** 1078,1082 **** currentNode.getArticle().stripAllTags(); editorPanePlainText.reloadArticle(); ! editorPaneHtml.setText(currentNode.getContent()); setWarnAboutUnsaved(true); } --- 1069,1074 ---- currentNode.getArticle().stripAllTags(); editorPanePlainText.reloadArticle(); ! editorPaneHtml.reloadArticle(); ! editorPaneTextile.reloadArticle(); setWarnAboutUnsaved(true); } *************** *** 1091,1125 **** currentNode.getArticle().setContent(editorPanePlainText.getText()); - /* - switch(currentNode.getArticleMode()) - { - case JreepadNode.ARTICLEMODE_ORDINARY: - currentNode.setContent(editorPanePlainText.getText()); - break; - case JreepadNode.ARTICLEMODE_HTML: - currentNode.setContent(editorPaneHtml.getText()); - break; - case JreepadNode.ARTICLEMODE_CSV: - currentNode.setContent(jTableContentToCsv()); - break; - default: - return; - } - */ switch(newMode) { case JreepadArticle.ARTICLEMODE_ORDINARY: // DELETEME - PLAINTEXT SHOULD NOT BE AFFECTED BY OTHERS ! editorPanePlainText.setText(currentNode.getContent()); break; case JreepadArticle.ARTICLEMODE_HTML: ! editorPaneHtml.setText(currentNode.getContent()); break; case JreepadArticle.ARTICLEMODE_TEXTILEHTML: ! try{ ! editorPaneHtml.setText(JTextile.textile(currentNode.getContent())); ! }catch(Exception e){ ! editorPaneHtml.setText(currentNode.getContent()); ! } break; case JreepadArticle.ARTICLEMODE_CSV: --- 1083,1097 ---- currentNode.getArticle().setContent(editorPanePlainText.getText()); switch(newMode) { case JreepadArticle.ARTICLEMODE_ORDINARY: // DELETEME - PLAINTEXT SHOULD NOT BE AFFECTED BY OTHERS ! editorPanePlainText.reloadArticle(); break; case JreepadArticle.ARTICLEMODE_HTML: ! editorPaneHtml.reloadArticle(); break; case JreepadArticle.ARTICLEMODE_TEXTILEHTML: ! editorPaneTextile.reloadArticle(); break; case JreepadArticle.ARTICLEMODE_CSV: *************** *** 1178,1197 **** { if(currentNode==null) ! return editorPanePlainText; // This is a bit of a hack - it shouldn't really even be called to act on null switch(currentNode.getArticle().getArticleMode()) { case JreepadArticle.ARTICLEMODE_ORDINARY: ! return editorPanePlainText; case JreepadArticle.ARTICLEMODE_HTML: case JreepadArticle.ARTICLEMODE_TEXTILEHTML: ! return editorPaneHtml; case JreepadArticle.ARTICLEMODE_CSV: ! return editorPaneCsv; default: System.err.println("getEditorPaneComponent() says: JreepadNode.getArticleMode() returned an unrecognised value"); return null; } } String getEditorPaneText() { --- 1150,1179 ---- { if(currentNode==null) ! { ! currentArticleView = editorPanePlainText; ! return currentArticleView; // This is a bit of a hack - it shouldn't really even be called to act on null ! } switch(currentNode.getArticle().getArticleMode()) { case JreepadArticle.ARTICLEMODE_ORDINARY: ! currentArticleView = editorPanePlainText; ! break; case JreepadArticle.ARTICLEMODE_HTML: + currentArticleView = editorPaneHtml; + break; case JreepadArticle.ARTICLEMODE_TEXTILEHTML: ! currentArticleView = editorPaneTextile; ! break; case JreepadArticle.ARTICLEMODE_CSV: ! currentArticleView = editorPaneCsv; ! break; default: System.err.println("getEditorPaneComponent() says: JreepadNode.getArticleMode() returned an unrecognised value"); return null; } + return currentArticleView; } + String getEditorPaneText() { *************** *** 1203,1207 **** return editorPaneHtml.getText(); case JreepadArticle.ARTICLEMODE_TEXTILEHTML: ! return editorPaneHtml.getText(); case JreepadArticle.ARTICLEMODE_CSV: return jTableContentToCsv(); --- 1185,1189 ---- return editorPaneHtml.getText(); case JreepadArticle.ARTICLEMODE_TEXTILEHTML: ! return editorPaneTextile.getText(); case JreepadArticle.ARTICLEMODE_CSV: return jTableContentToCsv(); *************** *** 1213,1268 **** void setEditorPaneText(JreepadArticle a) { ! String s = a.getContent(); ! try{ ! editorPanePlainText.setArticle(a); ! }catch(Exception ex){ ! // This shouldn't cause a problem. So this try-catch is only for debugging really. ! System.err.println("setEditorPaneText(): Exception during editorPanePlainText.setText(s)"); ! System.err.println("String: " + s); ! ex.printStackTrace(); ! } ! switch(currentNode.getArticle().getArticleMode()) ! { ! case JreepadArticle.ARTICLEMODE_ORDINARY: ! break; ! case JreepadArticle.ARTICLEMODE_HTML: ! editorPaneHtml.setText(s); ! break; ! case JreepadArticle.ARTICLEMODE_TEXTILEHTML: ! try{ ! editorPaneHtml.setText(JTextile.textile(s)); ! }catch(Exception e){ ! editorPaneHtml.setText(s); ! } ! break; ! case JreepadArticle.ARTICLEMODE_CSV: articleToJTable(a); - break; - default: - System.err.println("setEditorPaneText() says: JreepadNode.getArticleMode() returned an unrecognised value"); - return; - } - /* - switch(currentNode.getArticleMode()) - { - case JreepadNode.ARTICLEMODE_ORDINARY: - editorPanePlainText.setText(s); - break; - case JreepadNode.ARTICLEMODE_HTML: - editorPaneHtml.setText(s); - break; - case JreepadNode.ARTICLEMODE_CSV: - articleToJTable(s); - break; - default: - System.err.println("setEditorPaneText() says: JreepadNode.getArticleMode() returned an unrecognised value"); - return; - } - */ } // End of: functions which should allow us to switch between JEditorPane and JTable - public void editNodeTitleAction() { --- 1195,1207 ---- void setEditorPaneText(JreepadArticle a) { ! editorPanePlainText.setArticle(a); ! editorPaneHtml.setArticle(a); ! editorPaneTextile.setArticle(a); ! if (a.getArticleMode() == JreepadArticle.ARTICLEMODE_CSV) articleToJTable(a); } // End of: functions which should allow us to switch between JEditorPane and JTable public void editNodeTitleAction() { *************** *** 1339,1343 **** } - public boolean isCellEditable(int row, int col) { return false; --- 1278,1281 ---- *************** *** 1345,1363 **** } // End of: class ArticleTableModel - - class JEditorPanePlus extends JEditorPane implements DocumentListener { - JEditorPanePlus(String type, String text) { - super(type, text); - } - public void changedUpdate(DocumentEvent e){ - setWarnAboutUnsaved(true); - } - public void insertUpdate(DocumentEvent e){ - setWarnAboutUnsaved(true); - } - public void removeUpdate(DocumentEvent e){ - setWarnAboutUnsaved(true); - } - } // End of class JEditorPanePlus - } \ No newline at end of file --- 1283,1285 ---- |
From: PeWu <pe...@us...> - 2007-02-05 11:06:49
|
Update of /cvsroot/jreepad/jreepad/src/jreepad In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv10280/src/jreepad Modified Files: JreepadViewer.java Added Files: SearchDialog.java Log Message: refactoring: refactored SearchDialog from JreepadViewer --- NEW FILE: SearchDialog.java --- package jreepad; import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import javax.swing.Box; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JScrollPane; import javax.swing.JSpinner; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.ListSelectionModel; import javax.swing.SpinnerNumberModel; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.table.AbstractTableModel; /** * The search dialog. * * @version $Id: SearchDialog.java,v 1.1 2007/02/05 11:06:44 pewu Exp $ */ public class SearchDialog extends JDialog { private JTextField nodeSearchField; private JComboBox searchWhereSelector; private JSpinner searchMaxNumSpinner; private JCheckBox searchCaseCheckBox; private AbstractTableModel searchResultsTableModel; private JTable searchResultsTable; private JScrollPane searchResultsTableScrollPane; private JLabel searchResultsLabel; private JreepadView theJreepad; public SearchDialog(Frame owner, JreepadView theJreepad) { super(owner, JreepadViewer.lang.getString("SEARCH_WINDOWTITLE"), false); this.theJreepad = theJreepad; setVisible(false); Box vBox = Box.createVerticalBox(); // Box hBox = Box.createHorizontalBox(); nodeSearchField = new JTextField(""); vBox.add(new JLabel(JreepadViewer.lang.getString("SEARCH_SEARCHFOR"))); hBox.add(nodeSearchField); nodeSearchField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doTheSearch(); } }); nodeSearchField.addCaretListener(new CaretListener() { public void caretUpdate(CaretEvent e) { doTheSearch(); } }); vBox.add(hBox); // searchWhereSelector = new JComboBox(new String[] { JreepadViewer.lang.getString("SEARCH_SELECTEDNODE"), JreepadViewer.lang.getString("SEARCH_WHOLETREE") }); searchWhereSelector.setSelectedIndex(1); searchWhereSelector.setEditable(false); searchWhereSelector.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doTheSearch(); } }); hBox = Box.createHorizontalBox(); hBox.add(Box.createGlue()); hBox.add(new JLabel(JreepadViewer.lang.getString("SEARCH_SEARCHWHERE"))); hBox.add(searchWhereSelector); hBox.add(Box.createGlue()); hBox.add(searchCaseCheckBox = new JCheckBox(JreepadViewer.lang .getString("SEARCH_CASESENSITIVE"), false)); searchCaseCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doTheSearch(); } }); hBox.add(Box.createGlue()); vBox.add(hBox); // // searchMaxNumSpinner = new DSpinner(1,1000,getPrefs().searchMaxNum); searchMaxNumSpinner = new JSpinner(new SpinnerNumberModel(getPrefs().searchMaxNum, 1, 1000, 1)); /* * searchMaxNumSpinner.addCaretListener(new CaretListener(){ public void * caretUpdate(CaretEvent e){ doTheSearch();}}); searchMaxNumSpinner.addActionListener(new * ActionListener(){ public void actionPerformed(ActionEvent e){ doTheSearch();}}); */ searchMaxNumSpinner.getModel().addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { doTheSearch(); } }); hBox = Box.createHorizontalBox(); hBox.add(Box.createGlue()); hBox.add(new JLabel(JreepadViewer.lang.getString("SEARCH_MAXRESULTS"))); hBox.add(searchMaxNumSpinner); hBox.add(Box.createGlue()); vBox.add(hBox); // // NOW FOR THE SEARCH RESULTS TABLE - COULD BE TRICKY! searchResultsTableModel = new AbstractTableModel() { private final String[] columns = new String[] { JreepadViewer.lang.getString("SEARCH_TBL_COL_NODE"), JreepadViewer.lang.getString("SEARCH_TBL_COL_ARTICLETEXT"), JreepadViewer.lang.getString("SEARCH_TBL_COL_FULLPATH") }; public int getColumnCount() { return columns.length; } public String getColumnName(int index) { return columns[index]; } public int getRowCount() { JreepadSearcher.JreepadSearchResult[] results = SearchDialog.this.theJreepad .getSearchResults(); if (results == null || results.length == 0) return 1; else return results.length; } public Object getValueAt(int row, int col) { JreepadSearcher.JreepadSearchResult[] results = SearchDialog.this.theJreepad .getSearchResults(); if (results == null || results.length == 0) switch (col) { case 2: return ""; case 1: return (nodeSearchField.getText() == "" ? JreepadViewer.lang .getString("SEARCH_TBL_BEFORERESULTS") : JreepadViewer.lang .getString("SEARCH_TBL_NORESULTS")); default: return ""; } else switch (col) { case 2: return results[row].getTreePath(); case 1: return results[row].getArticleQuote(); default: return results[row].getNode().getTitle(); } } }; searchResultsTable = new JTable(searchResultsTableModel); searchResultsTable.setCellSelectionEnabled(false); searchResultsTable.setColumnSelectionAllowed(false); searchResultsTable.setRowSelectionAllowed(true); searchResultsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); searchResultsTableScrollPane = new JScrollPane(searchResultsTable); vBox.add(searchResultsLabel = new JLabel(JreepadViewer.lang.getString("SEARCH_RESULTS"))); vBox.add(searchResultsTableScrollPane); // // Add mouse listener MouseListener sml = new MouseAdapter() { public void mouseClicked(MouseEvent e) { mouseClickedOnSearchResultsTable(e); } }; searchResultsTable.addMouseListener(sml); // getContentPane().add(vBox); // Now we'll add some keyboard shortcuts KeyAdapter searchKeyListener = new KeyAdapter() { public void keyPressed(KeyEvent eek) { switch (eek.getKeyCode()) { case KeyEvent.VK_ESCAPE: setVisible(false); break; case KeyEvent.VK_W: if (eek.isControlDown() || eek.isMetaDown()) setVisible(false); break; } } }; addKeyListener(searchKeyListener); nodeSearchField.addKeyListener(searchKeyListener); searchCaseCheckBox.addKeyListener(searchKeyListener); searchWhereSelector.addKeyListener(searchKeyListener); searchResultsTable.addKeyListener(searchKeyListener); searchMaxNumSpinner.addKeyListener(searchKeyListener); searchResultsTable.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent eek) { switch (eek.getKeyCode()) { case KeyEvent.VK_SPACE: case KeyEvent.VK_ENTER: mouseClickedOnSearchResultsTable(null); break; } } }); // Finished establishing the search dialogue box } private void doTheSearch() { getPrefs().searchMaxNum = ((Integer)searchMaxNumSpinner.getValue()).intValue(); // DSpinner version getPrefs().searchMaxNum = searchMaxNumSpinner.getValue(); performSearch(nodeSearchField.getText(), nodeSearchField.getText(), // articleSearchField.getText(), searchWhereSelector.getSelectedIndex(), true /* searchCombinatorSelector.getSelectedIndex()==0 */, searchCaseCheckBox .isSelected(), getPrefs().searchMaxNum); } private boolean performSearch(String inNodes, String inArticles, int searchWhat /* 0=selected, 1=all */, boolean orNotAnd, boolean caseSensitive, int maxResults) { // setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); boolean ret = theJreepad.performSearch(inNodes, inArticles, searchWhat, orNotAnd, caseSensitive, maxResults); // setCursor(Cursor.getDefaultCursor()); if (!ret) { // JOptionPane.showMessageDialog(searchDialog, "Found nothing.", "Search result..." , // JOptionPane.INFORMATION_MESSAGE); searchResultsLabel.setText(JreepadViewer.lang.getString("SEARCH_RESULTS")); } else searchResultsLabel.setText(JreepadViewer.lang.getString("SEARCH_RESULTS") + theJreepad.getSearchResults().length + JreepadViewer.lang.getString("SEARCH_NODES_MATCHED")); searchResultsTableModel.fireTableStructureChanged(); // searchResultsTable.repaint(); return ret; } private void mouseClickedOnSearchResultsTable(MouseEvent e) { JreepadSearcher.JreepadSearchResult[] results = theJreepad.getSearchResults(); int selectedRow = searchResultsTable.getSelectedRow(); if (results == null || results.length == 0 || selectedRow == -1) return; // Select the node in the tree theJreepad.getTree().setSelectionPath(results[selectedRow].getTreePath()); theJreepad.getTree().scrollPathToVisible(results[selectedRow].getTreePath()); } private static JreepadPrefs getPrefs() { return JreepadView.getPrefs(); } public void setJreepad(JreepadView theJreepad) { this.theJreepad = theJreepad; } public void open() { setVisible(true); nodeSearchField.requestFocus(); nodeSearchField.setSelectionStart(0); } } Index: JreepadViewer.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadViewer.java,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** JreepadViewer.java 28 Jan 2007 21:29:30 -0000 1.49 --- JreepadViewer.java 5 Feb 2007 11:06:44 -0000 1.50 *************** *** 22,27 **** import javax.swing.*; - import javax.swing.event.*; - import javax.swing.table.*; import javax.swing.undo.*; import java.awt.*; --- 22,25 ---- *************** *** 98,111 **** private JDialog prefsDialog; ! ! private JDialog searchDialog; ! private JTextField nodeSearchField; ! private JCheckBox searchCaseCheckBox; ! private JComboBox searchWhereSelector; ! private JSpinner searchMaxNumSpinner; ! private JLabel searchResultsLabel; ! private JTable searchResultsTable; ! private JScrollPane searchResultsTableScrollPane; ! private AbstractTableModel searchResultsTableModel; private JDialog nodeUrlDisplayDialog; --- 96,100 ---- private JDialog prefsDialog; ! private SearchDialog searchDialog; private JDialog nodeUrlDisplayDialog; *************** *** 264,268 **** establishMenus(); establishToolbar(); ! establishSearchDialogue(); prefsDialog = new PrefsDialog(this); establishAutosaveDialogue(); --- 253,257 ---- establishMenus(); establishToolbar(); ! searchDialog = new SearchDialog(this, theJreepad); prefsDialog = new PrefsDialog(this); establishAutosaveDialogue(); *************** *** 324,327 **** --- 313,318 ---- getPrefs().saveLocation = getPrefs().exportLocation = getPrefs().importLocation = getPrefs().openLocation; content.add(theJreepad); + searchDialog.setJreepad(theJreepad); + getPrefs().saveLocation = getPrefs().openLocation; setTitleBasedOnFilename(getPrefs().openLocation.getName()); *************** *** 334,337 **** --- 325,329 ---- theJreepad = new JreepadView(new JreepadNode()); content.add(theJreepad); + searchDialog.setJreepad(theJreepad); setTitleBasedOnFilename(""); } *************** *** 526,530 **** // searchMenuItem = new JMenuItem(lang.getString("MENUITEM_SEARCH")); //"Search"); ! searchMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { openSearchDialog(); }}); searchMenu.add(searchMenuItem); launchUrlMenuItem = new JMenuItem(lang.getString("MENUITEM_FOLLOWLINK")); //"Follow highlighted link"); --- 518,522 ---- // searchMenuItem = new JMenuItem(lang.getString("MENUITEM_SEARCH")); //"Search"); ! searchMenuItem.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e) { searchDialog.open(); }}); searchMenu.add(searchMenuItem); launchUrlMenuItem = new JMenuItem(lang.getString("MENUITEM_FOLLOWLINK")); //"Follow highlighted link"); *************** *** 1039,1202 **** } - - private void establishSearchDialogue() - { - // Establish the search dialogue box - so that it can be called whenever wanted - searchDialog = new JDialog(this, lang.getString("SEARCH_WINDOWTITLE"), false); - searchDialog.setVisible(false); - Box vBox = Box.createVerticalBox(); - // - Box hBox = Box.createHorizontalBox(); - nodeSearchField = new JTextField(""); - vBox.add(new JLabel(lang.getString("SEARCH_SEARCHFOR"))); - hBox.add(nodeSearchField); - nodeSearchField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ - doTheSearch();}}); - nodeSearchField.addCaretListener(new CaretListener(){ public void caretUpdate(CaretEvent e){ - doTheSearch();}}); - vBox.add(hBox); - // - searchWhereSelector = new JComboBox(new String[]{lang.getString("SEARCH_SELECTEDNODE"), lang.getString("SEARCH_WHOLETREE")}); - searchWhereSelector.setSelectedIndex(1); - searchWhereSelector.setEditable(false); - searchWhereSelector.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ - doTheSearch();}}); - hBox = Box.createHorizontalBox(); - hBox.add(Box.createGlue()); - hBox.add(new JLabel(lang.getString("SEARCH_SEARCHWHERE"))); - hBox.add(searchWhereSelector); - hBox.add(Box.createGlue()); - hBox.add(searchCaseCheckBox = new JCheckBox(lang.getString("SEARCH_CASESENSITIVE"), false)); - searchCaseCheckBox.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ - doTheSearch();}}); - hBox.add(Box.createGlue()); - vBox.add(hBox); - // - // searchMaxNumSpinner = new DSpinner(1,1000,getPrefs().searchMaxNum); - searchMaxNumSpinner = new JSpinner(new SpinnerNumberModel(getPrefs().searchMaxNum,1,1000,1)); - /* searchMaxNumSpinner.addCaretListener(new CaretListener(){ public void caretUpdate(CaretEvent e){ - doTheSearch();}}); - searchMaxNumSpinner.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ - doTheSearch();}}); - */ - searchMaxNumSpinner.getModel().addChangeListener(new ChangeListener(){ public void stateChanged(ChangeEvent e){ - doTheSearch();}}); - hBox = Box.createHorizontalBox(); - hBox.add(Box.createGlue()); - hBox.add(new JLabel(lang.getString("SEARCH_MAXRESULTS"))); - hBox.add(searchMaxNumSpinner); - hBox.add(Box.createGlue()); - vBox.add(hBox); - // - // NOW FOR THE SEARCH RESULTS TABLE - COULD BE TRICKY! - searchResultsTableModel = new AbstractTableModel() - { - private final String[] columns = new String[]{lang.getString("SEARCH_TBL_COL_NODE"),lang.getString("SEARCH_TBL_COL_ARTICLETEXT"),lang.getString("SEARCH_TBL_COL_FULLPATH")}; - public int getColumnCount() { return columns.length; } - public String getColumnName(int index) - { - return columns[index]; - } - public int getRowCount() - { - JreepadSearcher.JreepadSearchResult[] results = theJreepad.getSearchResults(); - if(results==null || results.length==0) - return 1; - else - return results.length; - } - public Object getValueAt(int row, int col) - { - JreepadSearcher.JreepadSearchResult[] results = theJreepad.getSearchResults(); - if(results==null || results.length==0) - switch(col) - { - case 2: - return ""; - case 1: - return (nodeSearchField.getText()=="" ? lang.getString("SEARCH_TBL_BEFORERESULTS") : lang.getString("SEARCH_TBL_NORESULTS")); - default: - return ""; - } - else - switch(col) - { - case 2: - return results[row].getTreePath(); - case 1: - return results[row].getArticleQuote(); - default: - return results[row].getNode().getTitle(); - } - } - }; - searchResultsTable = new JTable(searchResultsTableModel); - searchResultsTable.setCellSelectionEnabled(false); - searchResultsTable.setColumnSelectionAllowed(false); - searchResultsTable.setRowSelectionAllowed(true); - searchResultsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - searchResultsTableScrollPane = new JScrollPane(searchResultsTable); - vBox.add(searchResultsLabel = new JLabel(lang.getString("SEARCH_RESULTS"))); - vBox.add(searchResultsTableScrollPane); - // - // Add mouse listener - MouseListener sml = new MouseAdapter(){public void mouseClicked(MouseEvent e){ - mouseClickedOnSearchResultsTable(e);}}; - searchResultsTable.addMouseListener(sml); - // - searchDialog.getContentPane().add(vBox); - - // Now we'll add some keyboard shortcuts - KeyAdapter searchKeyListener = new KeyAdapter(){ public void keyPressed(KeyEvent eek) - { - switch(eek.getKeyCode()) - { - case KeyEvent.VK_ESCAPE: - closeSearchDialogue(); - break; - case KeyEvent.VK_W: - if(eek.isControlDown() || eek.isMetaDown()) - closeSearchDialogue(); - break; - } - }}; - searchDialog.addKeyListener(searchKeyListener); - nodeSearchField.addKeyListener(searchKeyListener); - searchCaseCheckBox.addKeyListener(searchKeyListener); - searchWhereSelector.addKeyListener(searchKeyListener); - searchResultsTable.addKeyListener(searchKeyListener); - searchMaxNumSpinner.addKeyListener(searchKeyListener); - searchResultsTable.addKeyListener(new KeyAdapter(){ public void keyPressed(KeyEvent eek) - { - switch(eek.getKeyCode()) - { - case KeyEvent.VK_SPACE: - case KeyEvent.VK_ENTER: - mouseClickedOnSearchResultsTable(null); - break; - } - }}); - - - // Finished establishing the search dialogue box - } - - private void closeSearchDialogue() - { - searchDialog.setVisible(false); - } - - private void mouseClickedOnSearchResultsTable(MouseEvent e) - { - JreepadSearcher.JreepadSearchResult[] results = theJreepad.getSearchResults(); - int selectedRow = searchResultsTable.getSelectedRow(); - if(results==null || results.length==0 || selectedRow==-1) - return; - - // Select the node in the tree - theJreepad.getTree().setSelectionPath(results[selectedRow].getTreePath()); - theJreepad.getTree().scrollPathToVisible(results[selectedRow].getTreePath()); - } - public void establishAutosaveDialogue() { --- 1031,1034 ---- *************** *** 1338,1341 **** --- 1170,1175 ---- getPrefs().saveLocation = null; content.add(theJreepad); + searchDialog.setJreepad(theJreepad); + setTitleBasedOnFilename(""); validate(); *************** *** 1379,1382 **** --- 1213,1218 ---- getPrefs().saveLocation = getPrefs().openLocation; content.add(theJreepad); + searchDialog.setJreepad(theJreepad); + addToOpenRecentMenu(getPrefs().openLocation); setTitleBasedOnFilename(getPrefs().openLocation.getName()); *************** *** 1512,1540 **** } // End of: backupToAction() - private void openSearchDialog() - { - searchDialog.setVisible(true); - nodeSearchField.requestFocus(); - nodeSearchField.setSelectionStart(0); - } // End of: openSearchDialog() - - private boolean performSearch(String inNodes, String inArticles, int searchWhat /* 0=selected, 1=all */, - boolean orNotAnd, boolean caseSensitive, int maxResults) - { - // setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - boolean ret = theJreepad.performSearch(inNodes, inArticles, searchWhat, orNotAnd, - caseSensitive, maxResults); - // setCursor(Cursor.getDefaultCursor()); - if(!ret) - { - // JOptionPane.showMessageDialog(searchDialog, "Found nothing.", "Search result..." , JOptionPane.INFORMATION_MESSAGE); - searchResultsLabel.setText(lang.getString("SEARCH_RESULTS")); - } - else - searchResultsLabel.setText(lang.getString("SEARCH_RESULTS") + theJreepad.getSearchResults().length + lang.getString("SEARCH_NODES_MATCHED")); - searchResultsTableModel.fireTableStructureChanged(); - // searchResultsTable.repaint(); - return ret; - } private void setTitleBasedOnFilename(String filename) --- 1348,1351 ---- *************** *** 2191,2206 **** - public void doTheSearch() - { - getPrefs().searchMaxNum = ((Integer)searchMaxNumSpinner.getValue()).intValue(); - //DSpinner version getPrefs().searchMaxNum = searchMaxNumSpinner.getValue(); - - performSearch(nodeSearchField.getText(), nodeSearchField.getText(), // articleSearchField.getText(), - searchWhereSelector.getSelectedIndex(), true /* searchCombinatorSelector.getSelectedIndex()==0 */, - searchCaseCheckBox.isSelected(), - getPrefs().searchMaxNum - ); - } - protected void systemClipboardToNewNode() { --- 2002,2005 ---- |
From: PeWu <pe...@us...> - 2007-02-05 10:56:47
|
Update of /cvsroot/jreepad/jreepad/src/jreepad In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv5603/src/jreepad Modified Files: JreepadPrefs.java JreepadView.java Log Message: refactoring: refactored PlainTextEditor from JreepadView Index: JreepadView.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadView.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** JreepadView.java 26 Jan 2007 21:47:55 -0000 1.35 --- JreepadView.java 5 Feb 2007 10:56:43 -0000 1.36 *************** *** 42,47 **** import javax.swing.JTable; import javax.swing.JTree; - import javax.swing.event.CaretEvent; - import javax.swing.event.CaretListener; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; --- 42,45 ---- *************** *** 54,74 **** import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; - import javax.swing.event.UndoableEditEvent; - import javax.swing.event.UndoableEditListener; import javax.swing.table.DefaultTableModel; - import javax.swing.text.AbstractDocument; import javax.swing.text.BadLocationException; - import javax.swing.text.BoxView; - import javax.swing.text.ComponentView; import javax.swing.text.Document; - import javax.swing.text.Element; - import javax.swing.text.IconView; - import javax.swing.text.LabelView; - import javax.swing.text.StyleConstants; - import javax.swing.text.StyledEditorKit; - import javax.swing.text.View; - import javax.swing.text.ViewFactory; import javax.swing.tree.TreePath; import org.philwilson.JTextile; --- 52,63 ---- import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.table.DefaultTableModel; import javax.swing.text.BadLocationException; import javax.swing.text.Document; import javax.swing.tree.TreePath; + import jreepad.editor.ContentChangeListener; + import jreepad.editor.PlainTextEditor; + import org.philwilson.JTextile; *************** *** 81,128 **** { - // Code to ensure that the article word-wraps follows - // - contributed by Michael Labhard based on code found on the web... - static class JPEditorKit extends StyledEditorKit - { - public ViewFactory getViewFactory() - { - return new JPRTFViewFactory(); - } - } - - static class JPRTFViewFactory implements ViewFactory - { - public View create(Element elem) - { - String kind = elem.getName(); - if(kind != null) - if (kind.equals(AbstractDocument.ContentElementName)) { - return new LabelView(elem); - } else if (kind.equals(AbstractDocument.ParagraphElementName)) { - return new JPParagraphView(elem); - } else if (kind.equals(AbstractDocument.SectionElementName)) { - return new BoxView(elem, View.Y_AXIS); - } else if (kind.equals(StyleConstants.ComponentElementName)) { - return new ComponentView(elem); - } else if (kind.equals(StyleConstants.IconElementName)) { - return new IconView(elem); - } - // default to text display - return new LabelView(elem); - } - } - - private static short paraRightMargin = 0; - static class JPParagraphView extends javax.swing.text.ParagraphView - { - public JPParagraphView(Element e) - { - super(e); - this.setInsets((short)0, (short)0, (short)0, paraRightMargin); - } - } - // Code to ensure that the article word-wraps ends here - // - contributed by Michael Labhard - private static JreepadPrefs prefs; private JreepadNode root; --- 70,73 ---- *************** *** 137,141 **** // It will be equal to one of the content-type-specific panes. Need to set the content of BOTH of these... // private JEditorPane editorPane; ! private JEditorPane editorPanePlainText; private JEditorPane editorPaneHtml; private JTable editorPaneCsv; --- 82,86 ---- // It will be equal to one of the content-type-specific panes. Need to set the content of BOTH of these... // private JEditorPane editorPane; ! private PlainTextEditor editorPanePlainText; private JEditorPane editorPaneHtml; private JTable editorPaneCsv; *************** *** 149,155 **** private JreepadSearcher searcher; - // The following boolean should be FALSE while we're changing from node to node, and true otherwise - private boolean copyEditorPaneContentToNodeContent = true; - private boolean warnAboutUnsaved = false; --- 94,97 ---- *************** *** 232,237 **** ! editorPanePlainText = new JEditorPanePlus("text/plain", root.getContent()); ! editorPanePlainText.setEditable(true); editorPaneHtml = new JEditorPanePlus("text/html", root.getContent()); editorPaneHtml.setEditable(false); --- 174,178 ---- ! editorPanePlainText = new PlainTextEditor(root.getArticle()); editorPaneHtml = new JEditorPanePlus("text/html", root.getContent()); editorPaneHtml.setEditable(false); *************** *** 239,264 **** editorPaneCsv.getModel().addTableModelListener(this); - setEditorPaneKit(); - - // Add a listener to make sure the editorpane's content is always stored when it changes - editorPanePlainText.addCaretListener(new CaretListener() { - public void caretUpdate(CaretEvent e) - { - if(!copyEditorPaneContentToNodeContent) - return; // i.e. we are deactivated while changing from node to node - if(currentNode.getArticle().getArticleMode() != JreepadArticle.ARTICLEMODE_ORDINARY) - return; // i.e. we are only relevant when in plain-text mode - - if(!editorPanePlainText.getText().equals(currentNode.getContent())) - { - // System.out.println("UPDATE - I'd now overwrite node content with editorpane content"); - currentNode.getArticle().setContent(editorPanePlainText.getText()); - setWarnAboutUnsaved(true); - } - else - { - // System.out.println(" No need to update content."); - } - }}); articleView = new JScrollPane(getEditorPaneComponent(), JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); articleView.addComponentListener(new ComponentListener() --- 180,183 ---- *************** *** 290,308 **** ); setCurrentNode(root); setViewBoth(); tree.setSelectionRow(0); - - editorPanePlainText.getDocument().addUndoableEditListener(new JreepadUndoableEditListener()); - - } - - public void setEditorPaneKit() - { - if(getPrefs().wrapToWindow) - editorPanePlainText.setEditorKit(new JPEditorKit()); - // else - // editorPane.setEditorKit(new javax.swing.text.StyledEditorKit()); } --- 209,223 ---- ); + editorPanePlainText.setContentChangeListener(new ContentChangeListener() { + public void contentChanged() + { + setWarnAboutUnsaved(true); + } + }); + setCurrentNode(root); setViewBoth(); tree.setSelectionRow(0); } *************** *** 388,392 **** } ! copyEditorPaneContentToNodeContent = false; // Deactivate the caret-listener, effectively - ALSO DEACTIVATES UNDO-STORAGE if(currentNode != null) { --- 303,308 ---- } ! editorPanePlainText.lockEdits(); // Deactivate the caret-listener, effectively - ALSO DEACTIVATES UNDO-STORAGE ! if(currentNode != null) { *************** *** 400,404 **** // editorPaneHtml.setText(n.getContent()); ensureCorrectArticleRenderMode(); ! copyEditorPaneContentToNodeContent = true; // Reactivate the caret listener - ALSO REACTIVATES UNDO-STORAGE } --- 316,320 ---- // editorPaneHtml.setText(n.getContent()); ensureCorrectArticleRenderMode(); ! editorPanePlainText.unlockEdits(); // Reactivate the caret listener - ALSO REACTIVATES UNDO-STORAGE } *************** *** 549,557 **** try { - editorPanePlainText.setText(doc.getText(0, here) + theDate + - doc.getText(here, doc.getLength() - here)); editorPaneHtml.setText(doc.getText(0, here) + theDate + doc.getText(here, doc.getLength() - here)); - editorPanePlainText.setCaretPosition(here + theDate.length()); } catch(BadLocationException e) --- 465,470 ---- *************** *** 559,562 **** --- 472,476 ---- // Simply ignore this } + editorPanePlainText.insertText(theDate); } *************** *** 1155,1159 **** //DEL storeForUndo(); currentNode.getArticle().wrapContentToCharWidth(charWidth); ! editorPanePlainText.setText(currentNode.getContent()); editorPaneHtml.setText(currentNode.getContent()); setWarnAboutUnsaved(true); --- 1069,1073 ---- //DEL storeForUndo(); currentNode.getArticle().wrapContentToCharWidth(charWidth); ! editorPanePlainText.reloadArticle(); editorPaneHtml.setText(currentNode.getContent()); setWarnAboutUnsaved(true); *************** *** 1163,1167 **** //DEL storeForUndo(); currentNode.getArticle().stripAllTags(); ! editorPanePlainText.setText(currentNode.getContent()); editorPaneHtml.setText(currentNode.getContent()); setWarnAboutUnsaved(true); --- 1077,1081 ---- //DEL storeForUndo(); currentNode.getArticle().stripAllTags(); ! editorPanePlainText.reloadArticle(); editorPaneHtml.setText(currentNode.getContent()); setWarnAboutUnsaved(true); *************** *** 1174,1178 **** // + "\neditorPanePlainText contains: " + editorPanePlainText.getText()); ! copyEditorPaneContentToNodeContent = false; // Disables store-for-undo currentNode.getArticle().setContent(editorPanePlainText.getText()); --- 1088,1092 ---- // + "\neditorPanePlainText contains: " + editorPanePlainText.getText()); ! editorPanePlainText.lockEdits(); // Disables store-for-undo currentNode.getArticle().setContent(editorPanePlainText.getText()); *************** *** 1218,1222 **** ensureCorrectArticleRenderMode(); getEditorPaneComponent().repaint(); ! copyEditorPaneContentToNodeContent = true; // Re-enables store-for-undo } --- 1132,1136 ---- ensureCorrectArticleRenderMode(); getEditorPaneComponent().repaint(); ! editorPanePlainText.unlockEdits(); // Re-enables store-for-undo } *************** *** 1301,1305 **** String s = a.getContent(); try{ ! editorPanePlainText.setText(s); }catch(Exception ex){ // This shouldn't cause a problem. So this try-catch is only for debugging really. --- 1215,1219 ---- String s = a.getContent(); try{ ! editorPanePlainText.setArticle(a); }catch(Exception ex){ // This shouldn't cause a problem. So this try-catch is only for debugging really. *************** *** 1447,1514 **** } // End of class JEditorPanePlus - - //This one listens for edits that can be undone. - protected class JreepadUndoableEditListener - implements UndoableEditListener { - public void undoableEditHappened(UndoableEditEvent e) { - - //System.out.println("Undoable event is " + (e.getEdit().isSignificant()?"":"NOT ") + "significant"); - //System.out.println("Undoable event source: " + e.getEdit()); - - //Remember the edit and update the menus. - - if(copyEditorPaneContentToNodeContent){ - //System.out.println("Storing undoable event for node " + getCurrentNode().getTitle()); - //System.out.println(" Event is " + e.getEdit().getPresentationName() ); - //if(getCurrentNode().lastEditStyle != e.getEdit().getPresentationName()){ - // System.out.println(" This is a SIGNIFICANT change."); - //} - //System.out.println(" Content: " + getCurrentNode().getContent()); - //System.out.println(" Node undoMgr: " + getCurrentNode().undoMgr); - //Thread.currentThread().dumpStack(); - getCurrentNode().getArticle().getUndoMgr().addEdit(e.getEdit()); - } - - - - //undoAction.updateUndoState(); - //redoAction.updateRedoState(); - } - } - - - - - - - - - - /* - class ArticleTableColumnModel extends DefaultTableColumnModel { - public ArticleTableColumnModel(){ - super(); - initColListener(); - } - - private void initColListener(){ - addColumnModelListener(new TableColumnModelListener() - { - public void columnAdded(TableColumnModelEvent e){ storeColumnModel(); } - public void columnMarginChanged(ChangeEvent e){ storeColumnModel(); } - public void columnMoved(TableColumnModelEvent e){ storeColumnModel(); } - public void columnRemoved(TableColumnModelEvent e){ storeColumnModel(); } - public void columnSelectionChanged(ListSelectionEvent e){ storeColumnModel();} - }); - } - - private void storeColumnModel() - { - // Simply store the TableColumnModel in the node, for future reference - getCurrentNode().tblColModel = this; - } - - } // End of: class ArticleTableColumnModel - */ - } \ No newline at end of file --- 1361,1363 ---- Index: JreepadPrefs.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadPrefs.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** JreepadPrefs.java 25 Aug 2006 11:11:30 -0000 1.21 --- JreepadPrefs.java 5 Feb 2007 10:56:43 -0000 1.22 *************** *** 33,37 **** /* ! A class to hold Jreepad's preferences - and hopefully to store them on disk in a nice permanent way which can be carried across from different versions --- 33,37 ---- /* ! A class to hold Jreepad's preferences - and hopefully to store them on disk in a nice permanent way which can be carried across from different versions *************** *** 42,58 **** Preferences prefs; File openLocation, saveLocation, importLocation, exportLocation, backupLocation; ! boolean seenLicense; ! int autoSavePeriod; boolean autoSave; ! public static final int VIEW_BOTH = 0; public static final int VIEW_TREE = 1; public static final int VIEW_ARTICLE = 2; int viewWhich; ! boolean viewToolbar; ! int searchMaxNum; --- 42,58 ---- Preferences prefs; File openLocation, saveLocation, importLocation, exportLocation, backupLocation; ! boolean seenLicense; ! int autoSavePeriod; boolean autoSave; ! public static final int VIEW_BOTH = 0; public static final int VIEW_TREE = 1; public static final int VIEW_ARTICLE = 2; int viewWhich; ! boolean viewToolbar; ! int searchMaxNum; *************** *** 60,78 **** boolean loadLastFileOnOpen; ! String webSearchName; String webSearchPrefix; String webSearchPostfix; ! int defaultSearchMode; ! boolean wikiBehaviourActive; ! ! static final String[] characterEncodings = new String[]{"ISO-8859-1", "ISO-8859-15", "UTF-8", "UTF-16", "US-ASCII", "8859_15"}; int fileEncoding; String getEncoding() { return characterEncodings[fileEncoding]; } ! Vector openRecentList; int openRecentListLength; --- 60,78 ---- boolean loadLastFileOnOpen; ! String webSearchName; String webSearchPrefix; String webSearchPostfix; ! int defaultSearchMode; ! boolean wikiBehaviourActive; ! ! static final String[] characterEncodings = new String[]{"ISO-8859-1", "ISO-8859-15", "UTF-8", "UTF-16", "US-ASCII", "8859_15"}; int fileEncoding; String getEncoding() { return characterEncodings[fileEncoding]; } ! Vector openRecentList; int openRecentListLength; *************** *** 83,97 **** else return (File)openRecentList.get(0); ! } ! Font treeFont; Font articleFont; ! int characterWrapWidth; ! ! boolean wrapToWindow; ! int windowLeft, windowTop, windowWidth, windowHeight; ! public static final int LINEBREAK_WIN=0; public static final int LINEBREAK_MAC=1; --- 83,97 ---- else return (File)openRecentList.get(0); ! } ! Font treeFont; Font articleFont; ! int characterWrapWidth; ! ! public boolean wrapToWindow; ! int windowLeft, windowTop, windowWidth, windowHeight; ! public static final int LINEBREAK_WIN=0; public static final int LINEBREAK_MAC=1; *************** *** 108,136 **** return "\r\n"; } ! TreePathCollection treePathCollection; ! int htmlExportArticleType; boolean htmlExportUrlsToLinks; int htmlExportAnchorLinkType; ! int dividerLocation; ! boolean autoDetectHtmlArticles; ! boolean addQuotesToCsvOutput; ! static final int FILETYPE_XML = 0; static final int FILETYPE_HJT = 1; int mainFileType; public static final String[] mainFileTypes = {"Jreepad XML","Treepad HJT"}; ! static final int TOOLBAR_TEXT = 0; static final int TOOLBAR_ICON = 1; static final int TOOLBAR_OFF = 2; int toolbarMode; ! boolean showGreenStrip; ! JreepadPrefs(Dimension wndSize) { // Grab the prefs object from wherever Java's API has put it... --- 108,136 ---- return "\r\n"; } ! TreePathCollection treePathCollection; ! int htmlExportArticleType; boolean htmlExportUrlsToLinks; int htmlExportAnchorLinkType; ! int dividerLocation; ! boolean autoDetectHtmlArticles; ! boolean addQuotesToCsvOutput; ! static final int FILETYPE_XML = 0; static final int FILETYPE_HJT = 1; int mainFileType; public static final String[] mainFileTypes = {"Jreepad XML","Treepad HJT"}; ! static final int TOOLBAR_TEXT = 0; static final int TOOLBAR_ICON = 1; static final int TOOLBAR_OFF = 2; int toolbarMode; ! boolean showGreenStrip; ! JreepadPrefs(Dimension wndSize) { // Grab the prefs object from wherever Java's API has put it... *************** *** 144,172 **** seenLicense = prefs.getBoolean("SEENLICENSE", false); ! autoSavePeriod = prefs.getInt("AUTOSAVEPERIOD", 10); autoSave = prefs.getBoolean("AUTOSAVE", false); ! viewWhich = prefs.getInt("VIEWWHICH", 0); ! viewToolbar = prefs.getBoolean("VIEWTOOLBAR", true); ! searchMaxNum = prefs.getInt("SEARCHMAXNUM", 200); ! autoDateInArticles = prefs.getBoolean("AUTODATEINARTICLES", true); ! loadLastFileOnOpen = prefs.getBoolean("LOADLASTFILEONOPEN", true); ! webSearchName = prefs.get("WEBSEARCHNAME", JreepadViewer.lang.getString("PREFS_DEFAULT_SEARCH_TEXT")); //"Google search for highlighted text"; webSearchPrefix = prefs.get("WEBSEARCHPREFIX", "www.google.co.uk/search?q="); webSearchPostfix = prefs.get("WEBSEARCHPOSTFIX", "&hl=en"); ! defaultSearchMode = prefs.getInt("DEFAULTSEARCHMODE", 0); ! wikiBehaviourActive = prefs.getBoolean("WIKIBEHAVIOURACTIVE", true); ! fileEncoding = prefs.getInt("FILEENCODING", 2); // Default to UTF-8 ! openRecentList = new Vector(); openRecentListLength = prefs.getInt("OPENRECENTLISTLENGTH", 10); --- 144,172 ---- seenLicense = prefs.getBoolean("SEENLICENSE", false); ! autoSavePeriod = prefs.getInt("AUTOSAVEPERIOD", 10); autoSave = prefs.getBoolean("AUTOSAVE", false); ! viewWhich = prefs.getInt("VIEWWHICH", 0); ! viewToolbar = prefs.getBoolean("VIEWTOOLBAR", true); ! searchMaxNum = prefs.getInt("SEARCHMAXNUM", 200); ! autoDateInArticles = prefs.getBoolean("AUTODATEINARTICLES", true); ! loadLastFileOnOpen = prefs.getBoolean("LOADLASTFILEONOPEN", true); ! webSearchName = prefs.get("WEBSEARCHNAME", JreepadViewer.lang.getString("PREFS_DEFAULT_SEARCH_TEXT")); //"Google search for highlighted text"; webSearchPrefix = prefs.get("WEBSEARCHPREFIX", "www.google.co.uk/search?q="); webSearchPostfix = prefs.get("WEBSEARCHPOSTFIX", "&hl=en"); ! defaultSearchMode = prefs.getInt("DEFAULTSEARCHMODE", 0); ! wikiBehaviourActive = prefs.getBoolean("WIKIBEHAVIOURACTIVE", true); ! fileEncoding = prefs.getInt("FILEENCODING", 2); // Default to UTF-8 ! openRecentList = new Vector(); openRecentListLength = prefs.getInt("OPENRECENTLISTLENGTH", 10); *************** *** 185,194 **** int treeFontSize = prefs.getInt("TREEFONTSIZE", (new JTree()).getFont().getSize()); int articleFontSize = prefs.getInt("ARTICLEFONTSIZE", (new JEditorPane()).getFont().getSize()); ! treeFont = new Font(treeFontName, Font.PLAIN, treeFontSize); articleFont = new Font(articleFontName, Font.PLAIN, articleFontSize); ! characterWrapWidth = prefs.getInt("CHARACTERWRAPWIDTH", 80); ! wrapToWindow = prefs.getBoolean("WRAPTOWINDOW", true); --- 185,194 ---- int treeFontSize = prefs.getInt("TREEFONTSIZE", (new JTree()).getFont().getSize()); int articleFontSize = prefs.getInt("ARTICLEFONTSIZE", (new JEditorPane()).getFont().getSize()); ! treeFont = new Font(treeFontName, Font.PLAIN, treeFontSize); articleFont = new Font(articleFontName, Font.PLAIN, articleFontSize); ! characterWrapWidth = prefs.getInt("CHARACTERWRAPWIDTH", 80); ! wrapToWindow = prefs.getBoolean("WRAPTOWINDOW", true); *************** *** 200,208 **** windowLeft = prefs.getInt("WINDOWLEFT", 0); if(windowWidth==0 || windowWidth==0){ ! windowWidth = (int)(wndSize.getWidth() * 0.6f); windowHeight = (int)(wndSize.getHeight() * 0.6f); ! ! // This bit attempts to ensure that the Jreepad view doesn't get too wide // (e.g. for people with dual-screen systems) // - it limits the width/height proportion to the golden ratio! --- 200,208 ---- windowLeft = prefs.getInt("WINDOWLEFT", 0); if(windowWidth==0 || windowWidth==0){ ! windowWidth = (int)(wndSize.getWidth() * 0.6f); windowHeight = (int)(wndSize.getHeight() * 0.6f); ! ! // This bit attempts to ensure that the Jreepad view doesn't get too wide // (e.g. for people with dual-screen systems) // - it limits the width/height proportion to the golden ratio! *************** *** 212,219 **** else if(windowHeight > (int)(((float)windowWidth)*1.618034f) ) windowHeight = (int)(((float)windowWidth)*1.618034f); ! windowTop = windowHeight/3; ! windowLeft = windowWidth/3; ! } --- 212,219 ---- else if(windowHeight > (int)(((float)windowWidth)*1.618034f) ) windowHeight = (int)(((float)windowWidth)*1.618034f); ! windowTop = windowHeight/3; ! windowLeft = windowWidth/3; ! } *************** *** 224,242 **** // NEED SOME WAY OF STORING THE TREE STATE WHICH ACTUALLY WORKS. treePathCollection = new TreePathCollection(new javax.swing.tree.TreePath[0]); ! htmlExportArticleType = prefs.getInt("HTMLEXPORTARTICLETYPE", 0); htmlExportUrlsToLinks = prefs.getBoolean("HTMLEXPORTURLSTOLINKS", true); htmlExportAnchorLinkType = prefs.getInt("HTMLEXPORTANCHORLINKTYPE", 1); ! dividerLocation = prefs.getInt("DIVIDERLOCATION", -1); ! autoDetectHtmlArticles = prefs.getBoolean("AUTODETECTHTMLINARTICLES", true); ! addQuotesToCsvOutput = prefs.getBoolean("ADDQUOTESTOCSVOUTPUT", false); ! mainFileType = prefs.getInt("MAINFILETYPE", FILETYPE_HJT); ! toolbarMode = prefs.getInt("TOOLBARMODE", TOOLBAR_ICON); ! showGreenStrip = prefs.getBoolean("SHOWGREENSTRIP", true); --- 224,242 ---- // NEED SOME WAY OF STORING THE TREE STATE WHICH ACTUALLY WORKS. treePathCollection = new TreePathCollection(new javax.swing.tree.TreePath[0]); ! htmlExportArticleType = prefs.getInt("HTMLEXPORTARTICLETYPE", 0); htmlExportUrlsToLinks = prefs.getBoolean("HTMLEXPORTURLSTOLINKS", true); htmlExportAnchorLinkType = prefs.getInt("HTMLEXPORTANCHORLINKTYPE", 1); ! dividerLocation = prefs.getInt("DIVIDERLOCATION", -1); ! autoDetectHtmlArticles = prefs.getBoolean("AUTODETECTHTMLINARTICLES", true); ! addQuotesToCsvOutput = prefs.getBoolean("ADDQUOTESTOCSVOUTPUT", false); ! mainFileType = prefs.getInt("MAINFILETYPE", FILETYPE_HJT); ! toolbarMode = prefs.getInt("TOOLBARMODE", TOOLBAR_ICON); ! showGreenStrip = prefs.getBoolean("SHOWGREENSTRIP", true); *************** *** 252,269 **** prefs.put("EXPORTLOCATION", ""+exportLocation); prefs.put("BACKUPLOCATION", ""+backupLocation); ! prefs.putBoolean("SEENLICENSE", seenLicense); prefs.putInt("AUTOSAVEPERIOD", autoSavePeriod); prefs.putBoolean("AUTOSAVE", autoSave); ! prefs.putInt("VIEWWHICH", viewWhich); ! prefs.putBoolean("VIEWTOOLBAR", viewToolbar); ! prefs.putInt("SEARCHMAXNUM", searchMaxNum); ! prefs.putBoolean("AUTODATEINARTICLES", autoDateInArticles); ! prefs.putBoolean("LOADLASTFILEONOPEN", loadLastFileOnOpen); --- 252,269 ---- prefs.put("EXPORTLOCATION", ""+exportLocation); prefs.put("BACKUPLOCATION", ""+backupLocation); ! prefs.putBoolean("SEENLICENSE", seenLicense); prefs.putInt("AUTOSAVEPERIOD", autoSavePeriod); prefs.putBoolean("AUTOSAVE", autoSave); ! prefs.putInt("VIEWWHICH", viewWhich); ! prefs.putBoolean("VIEWTOOLBAR", viewToolbar); ! prefs.putInt("SEARCHMAXNUM", searchMaxNum); ! prefs.putBoolean("AUTODATEINARTICLES", autoDateInArticles); ! prefs.putBoolean("LOADLASTFILEONOPEN", loadLastFileOnOpen); *************** *** 273,277 **** prefs.putInt("DEFAULTSEARCHMODE", defaultSearchMode); ! prefs.putBoolean("WIKIBEHAVIOURACTIVE", wikiBehaviourActive); --- 273,277 ---- prefs.putInt("DEFAULTSEARCHMODE", defaultSearchMode); ! prefs.putBoolean("WIKIBEHAVIOURACTIVE", wikiBehaviourActive); *************** *** 287,293 **** prefs.put("ARTICLEFONTNAME", articleFont.getName()); prefs.putInt("ARTICLEFONTSIZE", articleFont.getSize()); ! prefs.putInt("CHARACTERWRAPWIDTH", characterWrapWidth); ! prefs.putBoolean("WRAPTOWINDOW", wrapToWindow); --- 287,293 ---- prefs.put("ARTICLEFONTNAME", articleFont.getName()); prefs.putInt("ARTICLEFONTSIZE", articleFont.getSize()); ! prefs.putInt("CHARACTERWRAPWIDTH", characterWrapWidth); ! prefs.putBoolean("WRAPTOWINDOW", wrapToWindow); *************** *** 298,321 **** prefs.putInt("LINEBREAKTYPE", linebreakType); ! // HOW TO SERIALISE? prefs.put(""+treePathCollection); ! prefs.putInt("HTMLEXPORTARTICLETYPE", htmlExportArticleType); prefs.putBoolean("HTMLEXPORTURLSTOLINKS", htmlExportUrlsToLinks); prefs.putInt("HTMLEXPORTANCHORLINKTYPE", htmlExportAnchorLinkType); ! prefs.putInt("DIVIDERLOCATION", dividerLocation); ! prefs.putBoolean("AUTODETECTHTMLINARTICLES", autoDetectHtmlArticles); ! prefs.putBoolean("ADDQUOTESTOCSVOUTPUT", addQuotesToCsvOutput); ! prefs.putInt("MAINFILETYPE", mainFileType); ! prefs.putInt("TOOLBARMODE", toolbarMode); ! prefs.putBoolean("SHOWGREENSTRIP", showGreenStrip); ! ! try{ prefs.flush(); // Encourage the store to be saved --- 298,321 ---- prefs.putInt("LINEBREAKTYPE", linebreakType); ! // HOW TO SERIALISE? prefs.put(""+treePathCollection); ! prefs.putInt("HTMLEXPORTARTICLETYPE", htmlExportArticleType); prefs.putBoolean("HTMLEXPORTURLSTOLINKS", htmlExportUrlsToLinks); prefs.putInt("HTMLEXPORTANCHORLINKTYPE", htmlExportAnchorLinkType); ! prefs.putInt("DIVIDERLOCATION", dividerLocation); ! prefs.putBoolean("AUTODETECTHTMLINARTICLES", autoDetectHtmlArticles); ! prefs.putBoolean("ADDQUOTESTOCSVOUTPUT", addQuotesToCsvOutput); ! prefs.putInt("MAINFILETYPE", mainFileType); ! prefs.putInt("TOOLBARMODE", toolbarMode); ! prefs.putBoolean("SHOWGREENSTRIP", showGreenStrip); ! ! try{ prefs.flush(); // Encourage the store to be saved *************** *** 324,329 **** } ! /* ! // We override the serialization routines so that different versions of our class can read // each other's serialized states. private void writeObject(java.io.ObjectOutputStream out) --- 324,329 ---- } ! /* ! // We override the serialization routines so that different versions of our class can read // each other's serialized states. private void writeObject(java.io.ObjectOutputStream out) *************** *** 335,350 **** out.writeObject(exportLocation); out.writeObject(backupLocation); ! out.writeInt(autoSavePeriod); out.writeBoolean(autoSave); ! out.writeInt(viewWhich); ! out.writeBoolean(viewToolbar); ! out.writeInt(searchMaxNum); ! out.writeBoolean(autoDateInArticles); ! out.writeBoolean(loadLastFileOnOpen); --- 335,350 ---- out.writeObject(exportLocation); out.writeObject(backupLocation); ! out.writeInt(autoSavePeriod); out.writeBoolean(autoSave); ! out.writeInt(viewWhich); ! out.writeBoolean(viewToolbar); ! out.writeInt(searchMaxNum); ! out.writeBoolean(autoDateInArticles); ! out.writeBoolean(loadLastFileOnOpen); *************** *** 354,358 **** out.writeInt(defaultSearchMode); ! out.writeBoolean(wikiBehaviourActive); --- 354,358 ---- out.writeInt(defaultSearchMode); ! out.writeBoolean(wikiBehaviourActive); *************** *** 364,370 **** out.writeObject(treeFont); out.writeObject(articleFont); ! out.writeInt(characterWrapWidth); ! out.writeBoolean(wrapToWindow); --- 364,370 ---- out.writeObject(treeFont); out.writeObject(articleFont); ! out.writeInt(characterWrapWidth); ! out.writeBoolean(wrapToWindow); *************** *** 375,395 **** out.writeInt(linebreakType); ! out.writeObject(treePathCollection); ! out.writeInt(htmlExportArticleType); out.writeBoolean(htmlExportUrlsToLinks); out.writeInt(htmlExportAnchorLinkType); ! out.writeInt(dividerLocation); ! out.writeBoolean(autoDetectHtmlArticles); ! out.writeBoolean(addQuotesToCsvOutput); ! out.writeInt(mainFileType); ! out.writeInt(toolbarMode); ! out.writeBoolean(showGreenStrip); } --- 375,395 ---- out.writeInt(linebreakType); ! out.writeObject(treePathCollection); ! out.writeInt(htmlExportArticleType); out.writeBoolean(htmlExportUrlsToLinks); out.writeInt(htmlExportAnchorLinkType); ! out.writeInt(dividerLocation); ! out.writeBoolean(autoDetectHtmlArticles); ! out.writeBoolean(addQuotesToCsvOutput); ! out.writeInt(mainFileType); ! out.writeInt(toolbarMode); ! out.writeBoolean(showGreenStrip); } *************** *** 404,419 **** exportLocation = (File)in.readObject(); backupLocation = (File)in.readObject(); ! autoSavePeriod = in.readInt(); autoSave = in.readBoolean(); ! viewWhich = in.readInt(); ! viewToolbar = in.readBoolean(); ! searchMaxNum = in.readInt(); ! autoDateInArticles = in.readBoolean(); ! loadLastFileOnOpen = in.readBoolean(); --- 404,419 ---- exportLocation = (File)in.readObject(); backupLocation = (File)in.readObject(); ! autoSavePeriod = in.readInt(); autoSave = in.readBoolean(); ! viewWhich = in.readInt(); ! viewToolbar = in.readBoolean(); ! searchMaxNum = in.readInt(); ! autoDateInArticles = in.readBoolean(); ! loadLastFileOnOpen = in.readBoolean(); *************** *** 423,431 **** defaultSearchMode = in.readInt(); ! wikiBehaviourActive = in.readBoolean(); ! fileEncoding = in.readInt(); ! openRecentList = (Vector)in.readObject(); openRecentListLength = in.readInt(); --- 423,431 ---- defaultSearchMode = in.readInt(); ! wikiBehaviourActive = in.readBoolean(); ! fileEncoding = in.readInt(); ! openRecentList = (Vector)in.readObject(); openRecentListLength = in.readInt(); *************** *** 433,441 **** treeFont = (Font)in.readObject(); articleFont = (Font)in.readObject(); ! characterWrapWidth = in.readInt(); ! wrapToWindow = in.readBoolean(); ! windowLeft = in.readInt(); windowTop = in.readInt(); --- 433,441 ---- treeFont = (Font)in.readObject(); articleFont = (Font)in.readObject(); ! characterWrapWidth = in.readInt(); ! wrapToWindow = in.readBoolean(); ! windowLeft = in.readInt(); windowTop = in.readInt(); *************** *** 444,464 **** linebreakType = in.readInt(); ! treePathCollection = (TreePathCollection)in.readObject(); ! htmlExportArticleType = in.readInt(); htmlExportUrlsToLinks = in.readBoolean(); htmlExportAnchorLinkType = in.readInt(); ! dividerLocation = in.readInt(); ! autoDetectHtmlArticles = in.readBoolean(); ! addQuotesToCsvOutput = in.readBoolean(); ! mainFileType = in.readInt(); ! toolbarMode = in.readInt(); ! showGreenStrip = in.readBoolean(); } --- 444,464 ---- linebreakType = in.readInt(); ! treePathCollection = (TreePathCollection)in.readObject(); ! htmlExportArticleType = in.readInt(); htmlExportUrlsToLinks = in.readBoolean(); htmlExportAnchorLinkType = in.readInt(); ! dividerLocation = in.readInt(); ! autoDetectHtmlArticles = in.readBoolean(); ! addQuotesToCsvOutput = in.readBoolean(); ! mainFileType = in.readInt(); ! toolbarMode = in.readInt(); ! showGreenStrip = in.readBoolean(); } |
From: PeWu <pe...@us...> - 2007-02-05 10:56:46
|
Update of /cvsroot/jreepad/jreepad/src/jreepad/editor In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv5603/src/jreepad/editor Added Files: ContentChangeListener.java PlainTextEditor.java Log Message: refactoring: refactored PlainTextEditor from JreepadView --- NEW FILE: PlainTextEditor.java --- /* Jreepad - personal information manager. Copyright (C) 2004 Dan Stowell 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 (at your option) 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. The full license can be read online here: http://www.gnu.org/copyleft/gpl.html */ package jreepad.editor; import javax.swing.JEditorPane; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; import javax.swing.event.UndoableEditEvent; import javax.swing.event.UndoableEditListener; import javax.swing.text.AbstractDocument; import javax.swing.text.BadLocationException; import javax.swing.text.BoxView; import javax.swing.text.ComponentView; import javax.swing.text.Document; import javax.swing.text.Element; import javax.swing.text.IconView; import javax.swing.text.LabelView; import javax.swing.text.StyleConstants; import javax.swing.text.StyledEditorKit; import javax.swing.text.View; import javax.swing.text.ViewFactory; import jreepad.JreepadArticle; import jreepad.JreepadPrefs; import jreepad.JreepadView; /** * The plain text editor pane. */ public class PlainTextEditor extends JEditorPane implements CaretListener, UndoableEditListener { private JreepadArticle article; private ContentChangeListener contentChangeListener = null; // The following boolean should be TRUE while we're changing from node to // node, and false otherwise private boolean editLocked = false; public PlainTextEditor(JreepadArticle article) { super("text/plain", article.getContent()); this.article = article; setEditable(true); if (getPrefs().wrapToWindow) setEditorKit(new JPEditorKit()); // Add a listener to make sure the editorpane's content is always stored // when it changes addCaretListener(this); getDocument().addUndoableEditListener(this); } public void insertText(String text) { Document doc = getDocument(); int here = getCaretPosition(); try { setText(doc.getText(0, here) + text + doc.getText(here, doc.getLength() - here)); setCaretPosition(here + text.length()); } catch (BadLocationException e) { // Simply ignore this } } public void reloadArticle() { setText(article.getContent()); } public void setArticle(JreepadArticle article) { this.article = article; setText(article.getContent()); } public void lockEdits() { editLocked = true; } public void unlockEdits() { editLocked = false; } public boolean isEditLocked() { return editLocked; } public void setContentChangeListener(ContentChangeListener listener) { contentChangeListener = listener; } private void notifyContentChangeListener() { if (contentChangeListener != null) contentChangeListener.contentChanged(); } public void caretUpdate(CaretEvent e) { if (editLocked) return; // i.e. we are deactivated while changing from node to node if (article.getArticleMode() != JreepadArticle.ARTICLEMODE_ORDINARY) return; // i.e. we are only relevant when in plain-text mode if (!getText().equals(article.getContent())) { // System.out.println("UPDATE - I'd now overwrite node content with // editorpane content"); article.setContent(getText()); notifyContentChangeListener(); } else { // System.out.println(" No need to update content."); } } public static JreepadPrefs getPrefs() { return JreepadView.getPrefs(); } // Code to ensure that the article word-wraps follows // - contributed by Michael Labhard based on code found on the web... private static class JPEditorKit extends StyledEditorKit { public ViewFactory getViewFactory() { return new JPRTFViewFactory(); } } private static class JPRTFViewFactory implements ViewFactory { public View create(Element elem) { String kind = elem.getName(); if (kind != null) if (kind.equals(AbstractDocument.ContentElementName)) { return new LabelView(elem); } else if (kind.equals(AbstractDocument.ParagraphElementName)) { return new JPParagraphView(elem); } else if (kind.equals(AbstractDocument.SectionElementName)) { return new BoxView(elem, View.Y_AXIS); } else if (kind.equals(StyleConstants.ComponentElementName)) { return new ComponentView(elem); } else if (kind.equals(StyleConstants.IconElementName)) { return new IconView(elem); } // default to text display return new LabelView(elem); } } private static short paraRightMargin = 0; static class JPParagraphView extends javax.swing.text.ParagraphView { public JPParagraphView(Element e) { super(e); this.setInsets((short) 0, (short) 0, (short) 0, paraRightMargin); } } // Code to ensure that the article word-wraps ends here // - contributed by Michael Labhard //This one listens for edits that can be undone. public void undoableEditHappened(UndoableEditEvent e) { // System.out.println("Undoable event is " + // (e.getEdit().isSignificant()?"":"NOT ") + "significant"); // System.out.println("Undoable event source: " + e.getEdit()); // Remember the edit and update the menus. if(!editLocked) { // System.out.println("Storing undoable event for node " + // getCurrentNode().getTitle()); // System.out.println(" Event is " + // e.getEdit().getPresentationName() ); // if(getCurrentNode().lastEditStyle != // e.getEdit().getPresentationName()){ // System.out.println(" This is a SIGNIFICANT change."); // } // System.out.println(" Content: " + getCurrentNode().getContent()); // System.out.println(" Node undoMgr: " + getCurrentNode().undoMgr); // Thread.currentThread().dumpStack(); article.getUndoMgr().addEdit(e.getEdit()); } // undoAction.updateUndoState(); // redoAction.updateRedoState(); } } --- NEW FILE: ContentChangeListener.java --- /* Jreepad - personal information manager. Copyright (C) 2004 Dan Stowell 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 (at your option) 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. The full license can be read online here: http://www.gnu.org/copyleft/gpl.html */ package jreepad.editor; /** * Listener for changes in article content. * * @author <a href="mailto:pe...@lo...">Przemek WiÄch</a> * @version $Id: ContentChangeListener.java,v 1.1 2007/02/05 10:56:43 pewu Exp $ */ public interface ContentChangeListener { public void contentChanged(); } |
From: PeWu <pe...@us...> - 2007-02-05 10:56:39
|
Update of /cvsroot/jreepad/jreepad/src/jreepad/editor In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv5587/src/jreepad/editor Log Message: Directory /cvsroot/jreepad/jreepad/src/jreepad/editor added to the repository |
From: PeWu <pe...@us...> - 2007-01-28 21:29:34
|
Update of /cvsroot/jreepad/jreepad/src/jreepad In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv25487/src/jreepad Modified Files: JreepadViewer.java Added Files: PrefsDialog.java Log Message: refactoring: refactored PrefsDialog class out of JreepadViewer --- NEW FILE: PrefsDialog.java --- package jreepad; import java.awt.Component; import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JSpinner; import javax.swing.JTextField; import javax.swing.SpinnerNumberModel; import javax.swing.SwingConstants; /** * The preferences dialog. * * @version $Id$ */ public class PrefsDialog extends JDialog { private JCheckBox loadLastFileOnOpenCheckBox; private JCheckBox autoDateNodesCheckBox; private JCheckBox autoDetectHtmlCheckBox; private JComboBox fileEncodingSelector; private JComboBox fileFormatSelector; private JCheckBox showGreenStripCheckBox; private JComboBox defaultSearchModeSelector; private JSpinner wrapWidthSpinner; private Box webSearchPrefsBox; private JTextField webSearchNameField; private JTextField webSearchPrefixField; private JTextField webSearchPostfixField; private JComboBox htmlExportModeSelector; private JCheckBox urlsToLinksCheckBox; private JComboBox htmlExportAnchorTypeSelector; private JButton prefsOkButton; private JButton prefsCancelButton; public PrefsDialog(Frame owner) { super(owner, JreepadViewer.lang.getString("PREFS_WINDOWTITLE"), true); setVisible(false); Box vBox = Box.createVerticalBox(); vBox.setAlignmentX(Component.LEFT_ALIGNMENT); Box genPrefVBox = Box.createVerticalBox(); vBox.setAlignmentX(Component.LEFT_ALIGNMENT); genPrefVBox.add(loadLastFileOnOpenCheckBox = new JCheckBox(JreepadViewer.lang .getString("PREFS_LOADLASTFILEONOPEN"), getPrefs().loadLastFileOnOpen)); loadLastFileOnOpenCheckBox.setHorizontalAlignment(SwingConstants.LEFT); loadLastFileOnOpenCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); genPrefVBox.add(autoDateNodesCheckBox = new JCheckBox(JreepadViewer.lang .getString("PREFS_AUTODATE_NODES"), getPrefs().autoDateInArticles)); autoDateNodesCheckBox.setHorizontalAlignment(SwingConstants.LEFT); autoDateNodesCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); genPrefVBox.add(autoDetectHtmlCheckBox = new JCheckBox(JreepadViewer.lang .getString("PREFS_AUTODETECT_HTML"), getPrefs().autoDetectHtmlArticles)); autoDetectHtmlCheckBox.setHorizontalAlignment(SwingConstants.LEFT); autoDetectHtmlCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); Box hBox = Box.createHorizontalBox(); hBox.setAlignmentX(Component.LEFT_ALIGNMENT); // hBox.add(Box.createGlue()); hBox.add(new JLabel(JreepadViewer.lang.getString("PREFS_CHAR_ENCODING"), SwingConstants.LEFT)); hBox.add(fileEncodingSelector = new JComboBox(JreepadPrefs.characterEncodings)); fileEncodingSelector.setAlignmentX(Component.LEFT_ALIGNMENT); hBox.add(Box.createGlue()); genPrefVBox.add(hBox); fileEncodingSelector.setSelectedIndex(getPrefs().fileEncoding); hBox = Box.createHorizontalBox(); hBox.setAlignmentX(Component.LEFT_ALIGNMENT); // hBox.add(Box.createGlue()); hBox.add(new JLabel(JreepadViewer.lang.getString("PREFS_SAVE_FILETYPE"), SwingConstants.LEFT)); hBox.add(fileFormatSelector = new JComboBox(JreepadPrefs.mainFileTypes)); fileFormatSelector.setAlignmentX(Component.LEFT_ALIGNMENT); hBox.add(Box.createGlue()); genPrefVBox.add(hBox); fileFormatSelector.setSelectedIndex(getPrefs().mainFileType); // genPrefVBox.add(quoteCsvCheckBox = new JCheckBox(lang.getString("PREFS_QUOTE_CSV"), // getPrefs().addQuotesToCsvOutput)); // quoteCsvCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); // quoteCsvCheckBox.setHorizontalAlignment(SwingConstants.LEFT); genPrefVBox.add(showGreenStripCheckBox = new JCheckBox(JreepadViewer.lang.getString("PREFS_GREEN_STRIP"), getPrefs().showGreenStrip)); showGreenStripCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); showGreenStripCheckBox.setHorizontalAlignment(SwingConstants.LEFT); JPanel genPanel = new JPanel(); genPanel.setAlignmentX(Component.LEFT_ALIGNMENT); genPanel.add(genPrefVBox); genPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JreepadViewer.lang.getString("PREFS_GENERAL"))); vBox.add(genPanel); genPanel = new JPanel(); genPanel.setAlignmentX(Component.LEFT_ALIGNMENT); hBox = Box.createHorizontalBox(); hBox.setAlignmentX(Component.LEFT_ALIGNMENT); hBox.add(new JLabel(JreepadViewer.lang.getString("PREFS_DEFAULT_LINK_ACTION"), SwingConstants.LEFT)); hBox.add(defaultSearchModeSelector = new JComboBox(new String[] { JreepadViewer.lang.getString("PREFS_DEFAULT_LINK_ACTION_WEBSEARCH"), JreepadViewer.lang.getString("PREFS_DEFAULT_LINK_ACTION_NODESEARCH") })); hBox.add(Box.createGlue()); defaultSearchModeSelector.setSelectedIndex(getPrefs().defaultSearchMode); defaultSearchModeSelector.setAlignmentX(Component.LEFT_ALIGNMENT); genPanel.add(hBox); genPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JreepadViewer.lang.getString("PREFS_LINK_ACTION_NAME"))); vBox.add(genPanel); genPanel = new JPanel(); genPanel.setAlignmentX(Component.LEFT_ALIGNMENT); genPrefVBox = Box.createVerticalBox(); // hBox = Box.createHorizontalBox(); // hBox.add(wrapToWindowCheckBox = new JCheckBox("Wrap article to window width", // getPrefs().wrapToWindow)); // hBox.add(new JLabel("(won't take effect until you restart Jreepad)")); // genPrefVBox.add(hBox); hBox = Box.createHorizontalBox(); hBox.setAlignmentX(Component.LEFT_ALIGNMENT); hBox.add(new JLabel(JreepadViewer.lang.getString("PREFS_HARDWRAP_WIDTH"), SwingConstants.LEFT)); hBox.add(wrapWidthSpinner = new JSpinner(new SpinnerNumberModel( getPrefs().characterWrapWidth, 1, 1000, 1))); hBox.add(Box.createGlue()); wrapWidthSpinner.setAlignmentX(Component.LEFT_ALIGNMENT); wrapWidthSpinner.getEditor().setAlignmentX(Component.LEFT_ALIGNMENT); // hBox.add(wrapWidthSpinner = new DSpinner(1,1000,getPrefs().characterWrapWidth)); hBox.add(Box.createGlue()); genPrefVBox.add(hBox); genPanel.add(genPrefVBox); genPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JreepadViewer.lang.getString("PREFS_HARDWRAP_NAME"))); vBox.add(genPanel); // fontsPrefsBox = Box.createHorizontalBox(); // fontsPrefsBox.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), // "Font (for article)")); // Box tempVBox = Box.createHorizontalBox(); // tempVBox.add(new JLabel("Font for tree:")); // tempVBox.add(treeFontFamilySelector = new JComboBox(fonts)); // fontsPrefsBox.add(tempVBox); // tempVBox = Box.createHorizontalBox(); // fontsPrefsBox.add(new JLabel("Font face:")); // fontsPrefsBox.add(articleFontFamilySelector = new JComboBox(fonts)); // fontsPrefsBox.add(tempVBox); // tempVBox = Box.createHorizontalBox(); // tempVBox.add(new JLabel("Font size:")); // fontsPrefsBox.add(articleFontSizeSelector = new JComboBox(fontSizes)); // fontsPrefsBox.add(new JLabel("pt")); // fontsPrefsBox.add(tempVBox); // vBox.add(fontsPrefsBox); webSearchPrefsBox = Box.createVerticalBox(); webSearchPrefsBox.setAlignmentX(Component.LEFT_ALIGNMENT); hBox = Box.createHorizontalBox(); hBox.setAlignmentX(Component.LEFT_ALIGNMENT); hBox.add(new JLabel(JreepadViewer.lang.getString("PREFS_WEBSEARCH_LABEL1"), SwingConstants.LEFT)); hBox.add(webSearchNameField = new JTextField(getPrefs().webSearchName)); webSearchNameField.setAlignmentX(Component.LEFT_ALIGNMENT); hBox.add(new JLabel(JreepadViewer.lang.getString("PREFS_WEBSEARCH_LABEL2"), SwingConstants.LEFT)); hBox.add(Box.createGlue()); webSearchPrefsBox.add(hBox); hBox = Box.createHorizontalBox(); hBox.add(new JLabel("http://", SwingConstants.LEFT)); hBox.add(webSearchPrefixField = new JTextField(getPrefs().webSearchPrefix)); webSearchPrefixField.setAlignmentX(Component.LEFT_ALIGNMENT); hBox.add(new JLabel(JreepadViewer.lang.getString("PREFS_SELECTEDTEXT_PLACEHOLDER"), SwingConstants.LEFT)); hBox.add(webSearchPostfixField = new JTextField(getPrefs().webSearchPostfix)); webSearchPostfixField.setAlignmentX(Component.LEFT_ALIGNMENT); webSearchPrefsBox.add(hBox); JPanel webSearchPanel = new JPanel(); webSearchPanel.setAlignmentX(Component.LEFT_ALIGNMENT); webSearchPanel.add(webSearchPrefsBox); webSearchPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory .createEtchedBorder(), JreepadViewer.lang.getString("PREFS_WEBSEARCH_NAME"))); vBox.add(webSearchPanel); // Now the HTML export options genPanel = new JPanel(); genPanel.setAlignmentX(Component.LEFT_ALIGNMENT); genPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JreepadViewer.lang.getString("PREFS_HTML_NAME"))); Box htmlVBox = Box.createVerticalBox(); htmlVBox.setAlignmentX(Component.LEFT_ALIGNMENT); hBox = Box.createHorizontalBox(); hBox.setAlignmentX(Component.LEFT_ALIGNMENT); // hBox.add(Box.createGlue()); hBox.add(new JLabel(JreepadViewer.lang.getString("PREFS_HTML_TREATTEXTAS"), SwingConstants.LEFT)); htmlExportModeSelector = new JComboBox(JreepadArticle.getHtmlExportArticleTypes()); htmlExportModeSelector.setAlignmentX(Component.LEFT_ALIGNMENT); htmlExportModeSelector.setSelectedIndex(getPrefs().htmlExportArticleType); htmlExportModeSelector.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (htmlExportModeSelector.getSelectedIndex() == 2) { urlsToLinksCheckBox.setEnabled(false); urlsToLinksCheckBox.setSelected(false); } else { urlsToLinksCheckBox.setEnabled(true); urlsToLinksCheckBox.setSelected(getPrefs().htmlExportUrlsToLinks); } } }); hBox.add(htmlExportModeSelector); hBox.add(Box.createGlue()); htmlVBox.add(hBox); htmlVBox.add(urlsToLinksCheckBox = new JCheckBox(JreepadViewer.lang.getString("PREFS_HTML_AUTOLINK"), getPrefs().htmlExportUrlsToLinks)); urlsToLinksCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); urlsToLinksCheckBox.setHorizontalAlignment(SwingConstants.LEFT); hBox = Box.createHorizontalBox(); hBox.setAlignmentX(Component.LEFT_ALIGNMENT); // hBox.add(Box.createGlue()); hBox.add(new JLabel(JreepadViewer.lang.getString("PREFS_HTML_INTERNALLINKS"), SwingConstants.LEFT)); htmlExportAnchorTypeSelector = new JComboBox(JreepadArticle.getHtmlExportAnchorLinkTypes()); htmlExportAnchorTypeSelector.setSelectedIndex(getPrefs().htmlExportAnchorLinkType); htmlExportAnchorTypeSelector.setAlignmentX(Component.LEFT_ALIGNMENT); hBox.add(htmlExportAnchorTypeSelector); hBox.add(Box.createGlue()); htmlVBox.add(hBox); genPanel.add(htmlVBox); vBox.add(genPanel); genPanel = new JPanel(); genPanel.setAlignmentX(Component.LEFT_ALIGNMENT); hBox = Box.createHorizontalBox(); hBox.setAlignmentX(Component.CENTER_ALIGNMENT); hBox.add(prefsOkButton = new JButton(JreepadViewer.lang.getString("OK"))); hBox.add(prefsCancelButton = new JButton(JreepadViewer.lang.getString("CANCEL"))); prefsOkButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getPrefs().loadLastFileOnOpen = loadLastFileOnOpenCheckBox.isSelected(); getPrefs().autoDateInArticles = autoDateNodesCheckBox.isSelected(); getPrefs().autoDetectHtmlArticles = autoDetectHtmlCheckBox.isSelected(); getPrefs().webSearchName = webSearchNameField.getText(); getPrefs().webSearchPrefix = webSearchPrefixField.getText(); getPrefs().webSearchPostfix = webSearchPostfixField.getText(); getPrefs().defaultSearchMode = defaultSearchModeSelector.getSelectedIndex(); getPrefs().fileEncoding = fileEncodingSelector.getSelectedIndex(); getPrefs().mainFileType = fileFormatSelector.getSelectedIndex(); getPrefs().characterWrapWidth = ((Integer)(wrapWidthSpinner.getValue())) .intValue(); // getPrefs().characterWrapWidth = wrapWidthSpinner.getValue(); // setFontsFromPrefsBox(); // getPrefs().wrapToWindow = wrapToWindowCheckBox.isSelected(); // theJreepad.setEditorPaneKit(); getPrefs().htmlExportArticleType = htmlExportModeSelector.getSelectedIndex(); getPrefs().htmlExportAnchorLinkType = htmlExportAnchorTypeSelector .getSelectedIndex(); // getPrefs().addQuotesToCsvOutput = quoteCsvCheckBox.isSelected(); getPrefs().showGreenStrip = showGreenStripCheckBox.isSelected(); // If exporting as HTML then we ignore this checkbox if (htmlExportModeSelector.getSelectedIndex() != 2) getPrefs().htmlExportUrlsToLinks = urlsToLinksCheckBox.isSelected(); getPrefs().save(); setVisible(false); } }); prefsCancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); } }); genPanel.add(hBox); vBox.add(genPanel); getContentPane().add(vBox); // Finished establishing the prefs dialogue box } private static JreepadPrefs getPrefs() { return JreepadView.getPrefs(); } } Index: JreepadViewer.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/JreepadViewer.java,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** JreepadViewer.java 26 Jan 2007 21:47:55 -0000 1.48 --- JreepadViewer.java 28 Jan 2007 21:29:30 -0000 1.49 *************** *** 24,29 **** import javax.swing.event.*; import javax.swing.table.*; - import javax.swing.text.*; - import javax.swing.text.html.*; import javax.swing.undo.*; import java.awt.*; --- 24,27 ---- *************** *** 31,35 **** import java.io.*; import java.util.*; - import java.net.MalformedURLException; import java.net.URL; import java.awt.datatransfer.*; --- 29,32 ---- *************** *** 37,43 **** //import javax.swing.plaf.metal.MetalIconFactory; // For icons - // For reflection and Mac OSX specific things - import com.apple.eawt.*; - import edu.stanford.ejalbert.BrowserLauncher; import edu.stanford.ejalbert.exception.BrowserLaunchingExecutionException; --- 34,37 ---- *************** *** 66,71 **** // private static final String[] fontSizes = new String[] {"8","9","10","11","12","13","14","16","18","20","24","30","36"}; - private File tempToBrowserFile; - private JFileChooser fileChooser; --- 60,63 ---- *************** *** 98,108 **** private Thread autoSaveThread; - private JDialog htmlExportDialog; - private JCheckBox urlsToLinksCheckBox; - private JButton htmlExportOkButton; - private JButton htmlExportCancelButton; - private JComboBox htmlExportModeSelector; - private JComboBox htmlExportAnchorTypeSelector; - private JDialog autoSaveDialog; private JCheckBox autoSaveCheckBox; --- 90,93 ---- *************** *** 113,149 **** private JDialog prefsDialog; - private JCheckBox loadLastFileOnOpenCheckBox; - private JCheckBox autoDateNodesCheckBox; - private JCheckBox autoDetectHtmlCheckBox; - private JComboBox fileEncodingSelector; - private JComboBox fileFormatSelector; - // private Box fontsPrefsBox; - // private JComboBox treeFontFamilySelector; - // private JComboBox treeFontSizeSelector; - // private JComboBox articleFontFamilySelector; - // private JComboBox articleFontSizeSelector; - private JSpinner wrapWidthSpinner; - // private DSpinner wrapWidthSpinner; - private Box webSearchPrefsBox; - private JComboBox defaultSearchModeSelector; - private JTextField webSearchNameField; - private JTextField webSearchPrefixField; - private JTextField webSearchPostfixField; - private JCheckBox wrapToWindowCheckBox; - private JCheckBox quoteCsvCheckBox; - private JCheckBox showGreenStripCheckBox; - private JButton prefsOkButton; - private JButton prefsCancelButton; private JDialog searchDialog; private JTextField nodeSearchField; - private JTextField articleSearchField; - private JComboBox searchCombinatorSelector; private JCheckBox searchCaseCheckBox; private JComboBox searchWhereSelector; private JSpinner searchMaxNumSpinner; - // private DSpinner searchMaxNumSpinner; - private JButton searchGoButton; - private JButton searchCloseButton; private JLabel searchResultsLabel; private JTable searchResultsTable; --- 98,107 ---- *************** *** 157,161 **** private JMenuBar menuBar; private JMenu fileMenu; - private JMenuItem newWindowMenuItem; private JMenuItem newMenuItem; private JMenuItem openMenuItem; --- 115,118 ---- *************** *** 308,312 **** establishToolbar(); establishSearchDialogue(); ! establishPrefsDialogue(); establishAutosaveDialogue(); establishNodeUrlDisplayDialogue(); --- 265,269 ---- establishToolbar(); establishSearchDialogue(); ! prefsDialog = new PrefsDialog(this); establishAutosaveDialogue(); establishNodeUrlDisplayDialogue(); *************** *** 1242,1459 **** } - private void establishPrefsDialogue() - { - Box hBox, vBox; - // Establish the prefs dialogue box - prefsDialog = new JDialog(this, lang.getString("PREFS_WINDOWTITLE"), true); - prefsDialog.setVisible(false); - vBox = Box.createVerticalBox(); - vBox.setAlignmentX(Component.LEFT_ALIGNMENT); - Box genPrefVBox = Box.createVerticalBox(); - vBox.setAlignmentX(Component.LEFT_ALIGNMENT); - genPrefVBox.add(loadLastFileOnOpenCheckBox = new JCheckBox(lang.getString("PREFS_LOADLASTFILEONOPEN"), getPrefs().loadLastFileOnOpen)); - loadLastFileOnOpenCheckBox.setHorizontalAlignment(SwingConstants.LEFT); - loadLastFileOnOpenCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); - genPrefVBox.add(autoDateNodesCheckBox = new JCheckBox(lang.getString("PREFS_AUTODATE_NODES"), getPrefs().autoDateInArticles)); - autoDateNodesCheckBox.setHorizontalAlignment(SwingConstants.LEFT); - autoDateNodesCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); - genPrefVBox.add(autoDetectHtmlCheckBox = new JCheckBox(lang.getString("PREFS_AUTODETECT_HTML"), getPrefs().autoDetectHtmlArticles)); - autoDetectHtmlCheckBox.setHorizontalAlignment(SwingConstants.LEFT); - autoDetectHtmlCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); - - hBox = Box.createHorizontalBox(); - hBox.setAlignmentX(Component.LEFT_ALIGNMENT); - // hBox.add(Box.createGlue()); - hBox.add(new JLabel(lang.getString("PREFS_CHAR_ENCODING"), SwingConstants.LEFT)); - hBox.add(fileEncodingSelector = new JComboBox(getPrefs().characterEncodings)); - fileEncodingSelector.setAlignmentX(Component.LEFT_ALIGNMENT); - hBox.add(Box.createGlue()); - genPrefVBox.add(hBox); - fileEncodingSelector.setSelectedIndex(getPrefs().fileEncoding); - - hBox = Box.createHorizontalBox(); - hBox.setAlignmentX(Component.LEFT_ALIGNMENT); - // hBox.add(Box.createGlue()); - hBox.add(new JLabel(lang.getString("PREFS_SAVE_FILETYPE"), SwingConstants.LEFT)); - hBox.add(fileFormatSelector = new JComboBox(getPrefs().mainFileTypes)); - fileFormatSelector.setAlignmentX(Component.LEFT_ALIGNMENT); - hBox.add(Box.createGlue()); - genPrefVBox.add(hBox); - fileFormatSelector.setSelectedIndex(getPrefs().mainFileType); - - // genPrefVBox.add(quoteCsvCheckBox = new JCheckBox(lang.getString("PREFS_QUOTE_CSV"), getPrefs().addQuotesToCsvOutput)); - // quoteCsvCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); - // quoteCsvCheckBox.setHorizontalAlignment(SwingConstants.LEFT); - genPrefVBox.add(showGreenStripCheckBox = new JCheckBox(lang.getString("PREFS_GREEN_STRIP"), getPrefs().showGreenStrip)); - showGreenStripCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); - showGreenStripCheckBox.setHorizontalAlignment(SwingConstants.LEFT); - - JPanel genPanel = new JPanel(); - genPanel.setAlignmentX(Component.LEFT_ALIGNMENT); - genPanel.add(genPrefVBox); - genPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), lang.getString("PREFS_GENERAL"))); - vBox.add(genPanel); - - genPanel = new JPanel(); - genPanel.setAlignmentX(Component.LEFT_ALIGNMENT); - hBox = Box.createHorizontalBox(); - hBox.setAlignmentX(Component.LEFT_ALIGNMENT); - hBox.add(new JLabel(lang.getString("PREFS_DEFAULT_LINK_ACTION"), SwingConstants.LEFT)); - hBox.add(defaultSearchModeSelector = new JComboBox(new String[]{lang.getString("PREFS_DEFAULT_LINK_ACTION_WEBSEARCH"),lang.getString("PREFS_DEFAULT_LINK_ACTION_NODESEARCH")})); - hBox.add(Box.createGlue()); - defaultSearchModeSelector.setSelectedIndex(getPrefs().defaultSearchMode); - defaultSearchModeSelector.setAlignmentX(Component.LEFT_ALIGNMENT); - genPanel.add(hBox); - genPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), lang.getString("PREFS_LINK_ACTION_NAME"))); - vBox.add(genPanel); - - genPanel = new JPanel(); - genPanel.setAlignmentX(Component.LEFT_ALIGNMENT); - genPrefVBox = Box.createVerticalBox(); - // hBox = Box.createHorizontalBox(); - // hBox.add(wrapToWindowCheckBox = new JCheckBox("Wrap article to window width", getPrefs().wrapToWindow)); - // hBox.add(new JLabel("(won't take effect until you restart Jreepad)")); - // genPrefVBox.add(hBox); - hBox = Box.createHorizontalBox(); - hBox.setAlignmentX(Component.LEFT_ALIGNMENT); - hBox.add(new JLabel(lang.getString("PREFS_HARDWRAP_WIDTH"), SwingConstants.LEFT)); - hBox.add(wrapWidthSpinner = new JSpinner(new SpinnerNumberModel(getPrefs().characterWrapWidth,1,1000,1))); - hBox.add(Box.createGlue()); - wrapWidthSpinner.setAlignmentX(Component.LEFT_ALIGNMENT); - wrapWidthSpinner.getEditor().setAlignmentX(Component.LEFT_ALIGNMENT); - // hBox.add(wrapWidthSpinner = new DSpinner(1,1000,getPrefs().characterWrapWidth)); - hBox.add(Box.createGlue()); - genPrefVBox.add(hBox); - genPanel.add(genPrefVBox); - genPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), lang.getString("PREFS_HARDWRAP_NAME"))); - vBox.add(genPanel); - - // fontsPrefsBox = Box.createHorizontalBox(); - // fontsPrefsBox.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Font (for article)")); - // Box tempVBox = Box.createHorizontalBox(); - // tempVBox.add(new JLabel("Font for tree:")); - // tempVBox.add(treeFontFamilySelector = new JComboBox(fonts)); - // fontsPrefsBox.add(tempVBox); - // tempVBox = Box.createHorizontalBox(); - // fontsPrefsBox.add(new JLabel("Font face:")); - // fontsPrefsBox.add(articleFontFamilySelector = new JComboBox(fonts)); - // fontsPrefsBox.add(tempVBox); - // tempVBox = Box.createHorizontalBox(); - // tempVBox.add(new JLabel("Font size:")); - // fontsPrefsBox.add(articleFontSizeSelector = new JComboBox(fontSizes)); - // fontsPrefsBox.add(new JLabel("pt")); - // fontsPrefsBox.add(tempVBox); - // vBox.add(fontsPrefsBox); - - webSearchPrefsBox = Box.createVerticalBox(); - webSearchPrefsBox.setAlignmentX(Component.LEFT_ALIGNMENT); - hBox = Box.createHorizontalBox(); - hBox.setAlignmentX(Component.LEFT_ALIGNMENT); - hBox.add(new JLabel(lang.getString("PREFS_WEBSEARCH_LABEL1"), SwingConstants.LEFT)); - hBox.add(webSearchNameField = new JTextField(getPrefs().webSearchName)); - webSearchNameField.setAlignmentX(Component.LEFT_ALIGNMENT); - hBox.add(new JLabel(lang.getString("PREFS_WEBSEARCH_LABEL2"), SwingConstants.LEFT)); - hBox.add(Box.createGlue()); - webSearchPrefsBox.add(hBox); - hBox = Box.createHorizontalBox(); - hBox.add(new JLabel("http://", SwingConstants.LEFT)); - hBox.add(webSearchPrefixField = new JTextField(getPrefs().webSearchPrefix)); - webSearchPrefixField.setAlignmentX(Component.LEFT_ALIGNMENT); - hBox.add(new JLabel(lang.getString("PREFS_SELECTEDTEXT_PLACEHOLDER"), SwingConstants.LEFT)); - hBox.add(webSearchPostfixField = new JTextField(getPrefs().webSearchPostfix)); - webSearchPostfixField.setAlignmentX(Component.LEFT_ALIGNMENT); - webSearchPrefsBox.add(hBox); - JPanel webSearchPanel = new JPanel(); - webSearchPanel.setAlignmentX(Component.LEFT_ALIGNMENT); - webSearchPanel.add(webSearchPrefsBox); - webSearchPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), lang.getString("PREFS_WEBSEARCH_NAME"))); - vBox.add(webSearchPanel); - - // Now the HTML export options - genPanel = new JPanel(); - genPanel.setAlignmentX(Component.LEFT_ALIGNMENT); - genPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), lang.getString("PREFS_HTML_NAME"))); - Box htmlVBox = Box.createVerticalBox(); - htmlVBox.setAlignmentX(Component.LEFT_ALIGNMENT); - hBox = Box.createHorizontalBox(); - hBox.setAlignmentX(Component.LEFT_ALIGNMENT); - // hBox.add(Box.createGlue()); - hBox.add(new JLabel(lang.getString("PREFS_HTML_TREATTEXTAS"), SwingConstants.LEFT)); - htmlExportModeSelector = new JComboBox(JreepadArticle.getHtmlExportArticleTypes()); - htmlExportModeSelector.setAlignmentX(Component.LEFT_ALIGNMENT); - htmlExportModeSelector.setSelectedIndex(getPrefs().htmlExportArticleType); - htmlExportModeSelector.addActionListener(new ActionListener(){ - public void actionPerformed(ActionEvent e){ - if(htmlExportModeSelector.getSelectedIndex()==2) - { - urlsToLinksCheckBox.setEnabled(false); - urlsToLinksCheckBox.setSelected(false); - } - else - { - urlsToLinksCheckBox.setEnabled(true); - urlsToLinksCheckBox.setSelected(getPrefs().htmlExportUrlsToLinks); - } - }}); - hBox.add(htmlExportModeSelector); - hBox.add(Box.createGlue()); - htmlVBox.add(hBox); - htmlVBox.add(urlsToLinksCheckBox = new JCheckBox(lang.getString("PREFS_HTML_AUTOLINK"), getPrefs().htmlExportUrlsToLinks)); - urlsToLinksCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); - urlsToLinksCheckBox.setHorizontalAlignment(SwingConstants.LEFT); - hBox = Box.createHorizontalBox(); - hBox.setAlignmentX(Component.LEFT_ALIGNMENT); - // hBox.add(Box.createGlue()); - hBox.add(new JLabel(lang.getString("PREFS_HTML_INTERNALLINKS"), SwingConstants.LEFT)); - htmlExportAnchorTypeSelector = new JComboBox(JreepadArticle.getHtmlExportAnchorLinkTypes()); - htmlExportAnchorTypeSelector.setSelectedIndex(getPrefs().htmlExportAnchorLinkType); - htmlExportAnchorTypeSelector.setAlignmentX(Component.LEFT_ALIGNMENT); - hBox.add(htmlExportAnchorTypeSelector); - hBox.add(Box.createGlue()); - htmlVBox.add(hBox); - genPanel.add(htmlVBox); - vBox.add(genPanel); - - genPanel = new JPanel(); - genPanel.setAlignmentX(Component.LEFT_ALIGNMENT); - hBox = Box.createHorizontalBox(); - hBox.setAlignmentX(Component.CENTER_ALIGNMENT); - hBox.add(prefsOkButton = new JButton(lang.getString("OK"))); - hBox.add(prefsCancelButton = new JButton(lang.getString("CANCEL"))); - prefsOkButton.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){ - getPrefs().loadLastFileOnOpen = loadLastFileOnOpenCheckBox.isSelected(); - getPrefs().autoDateInArticles = autoDateNodesCheckBox.isSelected(); - getPrefs().autoDetectHtmlArticles = autoDetectHtmlCheckBox.isSelected(); - webSearchMenuItem.setText(getPrefs().webSearchName = webSearchNameField.getText()); - getPrefs().webSearchPrefix = webSearchPrefixField.getText(); - getPrefs().webSearchPostfix = webSearchPostfixField.getText(); - getPrefs().defaultSearchMode = defaultSearchModeSelector.getSelectedIndex(); - getPrefs().fileEncoding = fileEncodingSelector.getSelectedIndex(); - getPrefs().mainFileType = fileFormatSelector.getSelectedIndex(); - getPrefs().characterWrapWidth = ((Integer)(wrapWidthSpinner.getValue())).intValue(); - // getPrefs().characterWrapWidth = wrapWidthSpinner.getValue(); - characterWrapArticleMenuItem.setText(lang.getString("MENUITEM_HARDWRAP1") + getPrefs().characterWrapWidth + lang.getString("MENUITEM_HARDWRAP2")); - // setFontsFromPrefsBox(); - // getPrefs().wrapToWindow = wrapToWindowCheckBox.isSelected(); - // theJreepad.setEditorPaneKit(); - getPrefs().htmlExportArticleType = htmlExportModeSelector.getSelectedIndex(); - getPrefs().htmlExportAnchorLinkType = htmlExportAnchorTypeSelector.getSelectedIndex(); - // getPrefs().addQuotesToCsvOutput = quoteCsvCheckBox.isSelected(); - getPrefs().showGreenStrip = showGreenStripCheckBox.isSelected(); - funkyGreenStrip.setVisible(getPrefs().showGreenStrip); - - // If exporting as HTML then we ignore this checkbox - if(htmlExportModeSelector.getSelectedIndex()!=2) - getPrefs().htmlExportUrlsToLinks = urlsToLinksCheckBox.isSelected(); - getPrefs().save(); - prefsDialog.setVisible(false); - }}); - prefsCancelButton.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){prefsDialog.setVisible(false);}}); - genPanel.add(hBox); - vBox.add(genPanel); - prefsDialog.getContentPane().add(vBox); - // Finished establishing the prefs dialogue box - } - public void establishAutosaveDialogue() { --- 1199,1202 ---- *************** *** 2201,2210 **** private void showPrefsDialog() { - // First make sure the components in the dialogue reflect the true state - loadLastFileOnOpenCheckBox.setSelected(getPrefs().loadLastFileOnOpen); - autoDateNodesCheckBox.setSelected(getPrefs().autoDateInArticles); - prefsDialog.setVisible(true); prefsDialog.toFront(); } --- 1944,1955 ---- private void showPrefsDialog() { prefsDialog.setVisible(true); prefsDialog.toFront(); + + // Apply preferences that immediately affect the GUI + funkyGreenStrip.setVisible(getPrefs().showGreenStrip); + webSearchMenuItem.setText(getPrefs().webSearchName); + characterWrapArticleMenuItem.setText(JreepadViewer.lang.getString("MENUITEM_HARDWRAP1") + + getPrefs().characterWrapWidth + JreepadViewer.lang.getString("MENUITEM_HARDWRAP2")); } *************** *** 2779,2784 **** } */ - - - } \ No newline at end of file --- 2524,2526 ---- |
From: PeWu <pe...@us...> - 2007-01-26 22:50:52
|
Update of /cvsroot/jreepad/jreepad/src/jreepad In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv24083/src/jreepad Modified Files: SoftLinkNode.java Log Message: refactoring fix: missed one method Index: SoftLinkNode.java =================================================================== RCS file: /cvsroot/jreepad/jreepad/src/jreepad/SoftLinkNode.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SoftLinkNode.java 26 Jan 2007 22:49:04 -0000 1.2 --- SoftLinkNode.java 26 Jan 2007 22:50:46 -0000 1.3 *************** *** 42,45 **** --- 42,50 ---- } + public JreepadArticle getArticle() + { + return target.getArticle(); + } + public void add(MutableTreeNode child) { |