[Jreepad-CVS] jreepad/src/jreepad JreepadView.java,1.38,1.39
Brought to you by:
danstowell
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(); } |