From: <doc...@us...> - 2007-06-05 21:43:29
|
Revision: 82 http://openpcl.svn.sourceforge.net/openpcl/?rev=82&view=rev Author: documentsystems Date: 2007-06-05 14:43:25 -0700 (Tue, 05 Jun 2007) Log Message: ----------- Howard Hoagland. Moved the "Show/Hide Extra Info" right click popup menu item from subclass plugin to PosTree and PosTreeNode and added the code to show and hide the paper size after the page node names. Modified Paths: -------------- openpcl/src/com/openpcl/viewer/panels/PosView.java openpcl/src/com/openpcl/viewer/tree/PosTree.java openpcl/src/com/openpcl/viewer/tree/PosTreeNode.java Modified: openpcl/src/com/openpcl/viewer/panels/PosView.java =================================================================== --- openpcl/src/com/openpcl/viewer/panels/PosView.java 2007-06-05 01:02:42 UTC (rev 81) +++ openpcl/src/com/openpcl/viewer/panels/PosView.java 2007-06-05 21:43:25 UTC (rev 82) @@ -62,7 +62,7 @@ private MouseWheelListener[] mMouseWheelListeners = null; // Splitter divider default location - public static final int sDefaultSplitterLocPclFiles = 168; + public static final int sDefaultSplitterLocPclFiles = 130; public static final int sTreatSplitterAsClosedIfLessThan = 10; private int mPixelLocForSplitter = 0; Modified: openpcl/src/com/openpcl/viewer/tree/PosTree.java =================================================================== --- openpcl/src/com/openpcl/viewer/tree/PosTree.java 2007-06-05 01:02:42 UTC (rev 81) +++ openpcl/src/com/openpcl/viewer/tree/PosTree.java 2007-06-05 21:43:25 UTC (rev 82) @@ -18,6 +18,8 @@ import javax.swing.JTree; import javax.swing.SwingUtilities; import javax.swing.UIManager; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.DefaultMutableTreeNode; @@ -44,8 +46,9 @@ private DefaultMutableTreeNode mTreeNodeRoot = null; private String mRootNodeName = null; private static String[] sTreePopupMenuItems = new String[] { - "View Selected", "Print All", "Print Selected", "Print Remaining"}; + "View Selected", "Print All", "Print Selected", "Print Remaining", "Show/Hide Extra Info"}; private JPopupMenu mTreeJPopupMenu = null; + private boolean mShowHideExtraInfoOnTree = false; protected static final String sPCL_ICON = "Eye.gif"; protected static final String sPAGE_ICON = "Page.gif"; @@ -72,7 +75,7 @@ mPagesJTree = new JTree(); // Make the root node - PosTreeNode tRootPosTreeNode = new PosTreeNode(mRootNodeName, -1, mRootNodeName); + PosTreeNode tRootPosTreeNode = new PosTreeNode(mRootNodeName, -1, mRootNodeName, this); mTreeNodeRoot = new DefaultMutableTreeNode(tRootPosTreeNode); mTreeNodeRoot.setAllowsChildren(true); @@ -99,6 +102,9 @@ return mPosView; } + /** Get Show/Hide Index Numbers on Tree */ + public boolean getShowHideExtraInfoOnTree() { return mShowHideExtraInfoOnTree; } + /** Add the tree selection listener */ public void addTreeSelectionListener() { mPagesJTree.addTreeSelectionListener(new PosTreeSelectionListener()); @@ -200,7 +206,7 @@ public PosTreeNode makePclPageTreeNode(int pPageNumber) { if (mPagesJTree == null) { return null; } // Put the PCL page as the user object in the tree node - PosTreeNode tPosTreeNode = new PosTreeNode(null, pPageNumber, null); + PosTreeNode tPosTreeNode = new PosTreeNode(null, pPageNumber, null, this); tPosTreeNode.setPclBytes(null); // If the Pcl bytes of this pages is needed later, they can be gotten later tPosTreeNode.setPriRenderCounters(null); // If the render counters are needed later, they can be gotten later DefaultMutableTreeNode child = new DefaultMutableTreeNode(tPosTreeNode); @@ -477,6 +483,17 @@ mRightClickedTreePath = null; }}); pJPopupMenu.add(tJMenuItem); + pJPopupMenu.addSeparator(); + + tJMenuItem = new JMenuItem(sTreePopupMenuItems[4]); // Show/Hide Extra Info + tJMenuItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent pE) { + toggleShowExtraInfoOnTree(); + mRightClickedNode = null; + mRightClickedTreePath = null; + }}); + pJPopupMenu.add(tJMenuItem); + } /** MouseAdapter class for when the user right clicks on a node in the tree.<br> @@ -524,11 +541,31 @@ buildTreePopupMenu(mTreeJPopupMenu); mTreeJPopupMenu.pack(); + mTreeJPopupMenu.addPopupMenuListener(new TreeNodePopupMenuListener()); + // Show the right click menu mTreeJPopupMenu.show(mPagesJTree, pMouseX, pMouseY); } } + private void toggleShowExtraInfoOnTree() { + // Toggle the Show/Hide extra info on tree + mShowHideExtraInfoOnTree = !mShowHideExtraInfoOnTree; + // The below will call the toString() in PosTreeNode to refresh the node names on the screen + SwingUtilities.updateComponentTreeUI(getPagesJTree()); + } + + private class TreeNodePopupMenuListener implements PopupMenuListener { + public void popupMenuWillBecomeVisible(PopupMenuEvent pE) { } + public void popupMenuWillBecomeInvisible(PopupMenuEvent pE) { } + public void popupMenuCanceled(PopupMenuEvent pE) { + // Need to null the below two variables when the user clicks away from the popup menu + // or else the next clicks on tree nodes won't show those clicked on pages + mRightClickedNode = null; + mRightClickedTreePath = null; + } + } + /** * Tree cell renderer class specifies the icons to use for the different node types: * 1. Pcl page Modified: openpcl/src/com/openpcl/viewer/tree/PosTreeNode.java =================================================================== --- openpcl/src/com/openpcl/viewer/tree/PosTreeNode.java 2007-06-05 01:02:42 UTC (rev 81) +++ openpcl/src/com/openpcl/viewer/tree/PosTreeNode.java 2007-06-05 21:43:25 UTC (rev 82) @@ -25,11 +25,14 @@ // For the Root tree node private String mRootNodeName = null; + + // The JTree where this node is in + PosTree mPosTree = null; private int mNodeNumber = 0; private String mPaperSize = "LGL"; - public PosTreeNode(String pNodeName, int pNodeNumber, String pRootNodeName) { + public PosTreeNode(String pNodeName, int pNodeNumber, String pRootNodeName, PosTree pPosTree) { if (pNodeName == null) { mNodeName = "Page: " + pNodeNumber; @@ -39,6 +42,7 @@ mNodeNumber = pNodeNumber; mRootNodeName = pRootNodeName; + mPosTree = pPosTree; mPriRenderCounters = new PriRenderCounters(); } @@ -64,10 +68,14 @@ // toString() here is used to show on the screen the name of the node public String toString() { // This is a Pcl file page node - if (mRootNodeName == null) { - String tPaperSize = "Legal"; - if (getPaperSize().equalsIgnoreCase("LTR")) { tPaperSize = "Letter"; } - return mNodeName + " (" + tPaperSize + ")"; + if (mRootNodeName != null) { + return mRootNodeName; + } + + if (mPosTree.getShowHideExtraInfoOnTree()) { + String tPaperSize = " (Legal)"; + if (mPaperSize.equalsIgnoreCase("LTR")) { tPaperSize = " (Letter)"; } + return mNodeName + tPaperSize ; } else { return mNodeName; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |