diff --git a/viewer/viewer-awt/src/main/java/org/icepdf/ri/common/SwingController.java b/viewer/viewer-awt/src/main/java/org/icepdf/ri/common/SwingController.java index 2852361e7..c038d0548 100644 --- a/viewer/viewer-awt/src/main/java/org/icepdf/ri/common/SwingController.java +++ b/viewer/viewer-awt/src/main/java/org/icepdf/ri/common/SwingController.java @@ -52,9 +52,6 @@ import org.icepdf.ri.util.ViewerPropertiesManager; import org.icepdf.ri.viewer.WindowManager; -import javax.print.attribute.PrintRequestAttributeSet; -import javax.print.attribute.standard.Media; -import javax.print.attribute.standard.MediaSize; import javax.print.attribute.standard.MediaSizeName; import javax.print.attribute.standard.PrintQuality; import javax.swing.Timer; @@ -180,6 +177,7 @@ public class SwingController extends ComponentAdapter private JButton searchButton; private JToggleButton showHideUtilityPaneButton; private JButton showAnnotationUtilityPaneButton; + private JButton showBookmarkUtilityPaneButton; private JButton firstPageButton; private JButton previousPageButton; private JButton nextPageButton; @@ -883,6 +881,16 @@ public void setShowAnnotationUtilityPaneButton(JButton btn) { btn.addActionListener(this); } + /** + * Called by SwingViewerBuilder, so that Controller can setup event handling + * + * @param btn button to assign + */ + public void setShowBookmarkUtilityPaneButton(JButton btn) { + showBookmarkUtilityPaneButton = btn; + btn.addActionListener(this); + } + /** * Called by SwingViewerBuilder, so that Controller can setup event handling * @@ -1617,6 +1625,7 @@ private void reflectStateInComponents() { setEnabled(searchButton, opened && searchPanel != null && !pdfCollection); setEnabled(showHideUtilityPaneButton, opened && utilityTabbedPane != null); setEnabled(showAnnotationUtilityPaneButton, opened && utilityTabbedPane != null); + setEnabled(showBookmarkUtilityPaneButton, opened && utilityTabbedPane != null); setEnabled(currentPageNumberTextField, opened && nPages > 1 && !pdfCollection); if (numberOfPagesLabel != null) { @@ -2156,6 +2165,8 @@ private void reflectToolInToolButtons() { isUtilityPaneVisible()); reflectSelectionInButton(showAnnotationUtilityPaneButton, isAnnotationUtilityPaneVisible()); + reflectSelectionInButton(showBookmarkUtilityPaneButton, + isBookmarkUtilityPaneVisible()); reflectSelectionInButton(formHighlightButton, viewModel.isWidgetAnnotationHighlight()); reflectSelectionInButton(annotationEditingModeButton, @@ -4289,8 +4300,15 @@ public boolean isUtilityPaneVisible() { } public boolean isAnnotationUtilityPaneVisible() { - return utilityTabbedPane != null && utilityTabbedPane.isVisible() && - annotationPanel != null && annotationPanel.isVisible(); + return isComponentUtilityPaneVisible(annotationPanel); + } + + public boolean isBookmarkUtilityPaneVisible() { + return isComponentUtilityPaneVisible(outlinesScrollPane); + } + + public boolean isComponentUtilityPaneVisible(final Component component) { + return isUtilityPaneVisible() && component != null && component.isVisible(); } /** @@ -4399,7 +4417,6 @@ protected boolean safelySelectUtilityPanel(Component comp) { if ((utilityTabbedPane != null) && (comp != null)) { if (utilityTabbedPane.indexOfComponent(comp) > -1) { utilityTabbedPane.setSelectedComponent(comp); - return true; } } @@ -4407,6 +4424,13 @@ protected boolean safelySelectUtilityPanel(Component comp) { return false; } + protected boolean isUtilityTabSelected(Component comp) { + if (utilityTabbedPane != null && comp != null) { + return utilityTabbedPane.getSelectedComponent() == comp; + } + return false; + } + public void showSearch() { SearchToolBar searchBar = (SearchToolBar) quickSearchToolBar; if (searchBar != null) { @@ -4458,32 +4482,11 @@ public void previousSearchResult() { } } + /** * Make the Annotation Link Panel visible, and if necessary, the utility pane that encloses it * - * @param selectedAnnotation the annotation to show in the panel - * @see #setUtilityPaneVisible(boolean) - */ - public void showAnnotationPanel(AnnotationComponent selectedAnnotation) { - if (utilityTabbedPane != null) { - // Pass the selected annotation to the link panel - if (annotationPanel != null) { - annotationPanel.setEnabled(true); - } - setUtilityPaneVisible(true); - // select the annotationPanel tab - if (annotationPanel != null) { - boolean show = safelySelectUtilityPanel(annotationPanel); - if (show) { - annotationPanel.setSelectedTab(ViewerPropertiesManager.PROPERTY_SHOW_UTILITYPANE_ANNOTATION_MARKUP); - } - } - } - } - - /* Make the Annotation Link Panel visible, and if necessary, the utility pane that encloses it - * - * @param selectedAnnotation the annotation to show in the panel + * @param selectedDestination the destination to show in the panel * @see #setUtilityPaneVisible(boolean) */ public void showAnnotationDestinationPanel(DestinationComponent selectedDestination) { @@ -4522,17 +4525,48 @@ public void showAnnotationDestinationPanel(TreePath path) { } /** - * Make the outline panel panel visible. + * Make the Annotation Link Panel visible, and if necessary, the utility pane that encloses it + * + * @param forceShow Forces the utility pane to be visible + * @see #setUtilityPaneVisible(boolean) */ - public void showOutlinePanel() { - if (utilityTabbedPane != null) { + public void showAnnotationPanel(final boolean forceShow) { + final boolean isShowing = showUtilityPanel(annotationPanel, forceShow); + if (annotationPanel != null && isShowing) { + annotationPanel.setSelectedTab(ViewerPropertiesManager.PROPERTY_SHOW_UTILITYPANE_ANNOTATION_MARKUP); + } + } + + /** + * Shows the given component in the utility panel + * + * @param panelToShow The component to show + * @param forceShow Whether to force showing the utility panel or not + * @return whether the panel has been selected or not + */ + protected boolean showUtilityPanel(final Component panelToShow, final boolean forceShow) { + if (utilityTabbedPane != null && panelToShow != null) { // Pass the selected annotation to the link panel - if (outlinesScrollPane != null && utilityTabbedPane != null) { - utilityTabbedPane.setSelectedComponent(outlinesScrollPane); - } + panelToShow.setEnabled(true); + } + setUtilityPaneVisible(forceShow || (!isUtilityPaneVisible() || !isUtilityTabSelected(panelToShow) || utilityAndDocumentSplitPane.getLeftComponent() != utilityTabbedPane)); + // select the annotationPanel tab + if (!isUtilityTabSelected(panelToShow)) { + return safelySelectUtilityPanel(panelToShow); + } else { + return true; } } + /** + * Make the outline panel panel visible + * + * @param forceShow Whether to force showing the utility pane or not + */ + public void showOutlinePanel(final boolean forceShow) { + showUtilityPanel(outlinesScrollPane, forceShow); + } + /** * Show a dialog, listing every page in the PDF Document, for the user * to select which page to show. @@ -4802,7 +4836,9 @@ public void actionPerformed(ActionEvent event) { } else if (source == showHideUtilityPaneMenuItem || source == showHideUtilityPaneButton) { toggleUtilityPaneVisibility(); } else if (source == showAnnotationUtilityPaneButton) { - showAnnotationPanel(null); + showAnnotationPanel(false); + } else if (source == showBookmarkUtilityPaneButton) { + showOutlinePanel(false); } else if (source == formHighlightButton) { toggleFormHighlight(); } else if (source == annotationEditingModeButton) { @@ -5509,7 +5545,7 @@ public void propertyChange(PropertyChangeEvent evt) { if (logger.isLoggable(Level.FINE)) { logger.fine("selected annotation " + annotationComponent); } - showAnnotationPanel(annotationComponent); + showAnnotationPanel(true); } } break; diff --git a/viewer/viewer-awt/src/main/java/org/icepdf/ri/common/SwingViewBuilder.java b/viewer/viewer-awt/src/main/java/org/icepdf/ri/common/SwingViewBuilder.java index e9269d1a0..06c02a5b1 100644 --- a/viewer/viewer-awt/src/main/java/org/icepdf/ri/common/SwingViewBuilder.java +++ b/viewer/viewer-awt/src/main/java/org/icepdf/ri/common/SwingViewBuilder.java @@ -1297,6 +1297,17 @@ public JButton buildShowAnnotationUtilityButton(final String imageSize) { return btn; } + public JButton buildShowBookmarkUtilityButton(final String imageSize) { + JButton btn = makeToolbarButton( + messageBundle.getString("viewer.toolbar.tool.bookmarkUtility.label"), + messageBundle.getString("viewer.toolbar.tool.bookmarkUtility.tooltip"), + "utility_bookmarks", imageSize, buttonFont); + if (viewerController != null && btn != null) { + viewerController.setShowBookmarkUtilityPaneButton(btn); + } + return btn; + } + public JToggleButton buildShowHideUtilityPaneButton() { JToggleButton btn = makeToolbarToggleButton( messageBundle.getString("viewer.toolbar.utilityPane.label"), @@ -1598,6 +1609,10 @@ public JToolBar buildAnnotationlToolBar() { ViewerPropertiesManager.PROPERTY_SHOW_TOOLBAR_ANNOTATION_UTILITY)) { addToToolBar(toolbar, buildShowAnnotationUtilityButton(iconSize)); } + if (propertiesManager.checkAndStoreBooleanProperty( + ViewerPropertiesManager.PROPERTY_SHOW_TOOLBAR_BOOKMARK_UTILITY)) { + addToToolBar(toolbar, buildShowBookmarkUtilityButton(iconSize)); + } if (propertiesManager.checkAndStoreBooleanProperty( ViewerPropertiesManager.PROPERTY_SHOW_TOOLBAR_ANNOTATION_PREVIEW)) { addToToolBar(toolbar, buildAnnotationPreviewButton(iconSize)); diff --git a/viewer/viewer-awt/src/main/java/org/icepdf/ri/common/utility/search/SearchPanel.java b/viewer/viewer-awt/src/main/java/org/icepdf/ri/common/utility/search/SearchPanel.java index 402601187..be46780b1 100644 --- a/viewer/viewer-awt/src/main/java/org/icepdf/ri/common/utility/search/SearchPanel.java +++ b/viewer/viewer-awt/src/main/java/org/icepdf/ri/common/utility/search/SearchPanel.java @@ -1007,7 +1007,7 @@ public void mouseClicked(MouseEvent e) { OutlineItemTreeNode outlineNode = findOutlineTreeNode(outlineItemTreeNode.getChildAt(i), (OutlineItemTreeNode) node); if (outlineNode != null) { - swingController.showOutlinePanel(); + swingController.showOutlinePanel(true); TreePath outlinePath = new TreePath(outlineNode.getPath()); outlineTree.setSelectionPath(outlinePath); outlineTree.scrollPathToVisible(outlinePath); diff --git a/viewer/viewer-awt/src/main/java/org/icepdf/ri/util/ViewerPropertiesManager.java b/viewer/viewer-awt/src/main/java/org/icepdf/ri/util/ViewerPropertiesManager.java index c2cb28c42..0db21e985 100644 --- a/viewer/viewer-awt/src/main/java/org/icepdf/ri/util/ViewerPropertiesManager.java +++ b/viewer/viewer-awt/src/main/java/org/icepdf/ri/util/ViewerPropertiesManager.java @@ -192,6 +192,7 @@ public final class ViewerPropertiesManager { public static final String PROPERTY_SHOW_TOOLBAR_ANNOTATION_TEXT = "application.toolbar.annotation.text.enabled"; public static final String PROPERTY_SHOW_TOOLBAR_ANNOTATION_PERMISSION = "application.toolbar.annotation.permission.enabled"; public static final String PROPERTY_SHOW_TOOLBAR_ANNOTATION_UTILITY = "application.toolbar.annotation.toolbar.enabled"; + public static final String PROPERTY_SHOW_TOOLBAR_BOOKMARK_UTILITY = "application.toolbar.bookmark.toolbar.enabled"; public static final String PROPERTY_SHOW_TOOLBAR_ANNOTATION_PREVIEW = "application.toolbar.annotation.preview.enabled"; // Individual control of the markup annotation context menu public static final String PROPERTY_SHOW_ANNOTATION_MARKUP_REPLY_TO = "application.annotation.show.markup.replyTo"; diff --git a/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/utility_bookmarks_a_24.png b/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/utility_bookmarks_a_24.png new file mode 100644 index 000000000..39b605058 Binary files /dev/null and b/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/utility_bookmarks_a_24.png differ diff --git a/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/utility_bookmarks_a_32.png b/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/utility_bookmarks_a_32.png new file mode 100644 index 000000000..25f47cc7d Binary files /dev/null and b/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/utility_bookmarks_a_32.png differ diff --git a/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/utility_bookmarks_i_24.png b/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/utility_bookmarks_i_24.png new file mode 100644 index 000000000..371570a14 Binary files /dev/null and b/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/utility_bookmarks_i_24.png differ diff --git a/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/utility_bookmarks_i_32.png b/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/utility_bookmarks_i_32.png new file mode 100644 index 000000000..6118b5e97 Binary files /dev/null and b/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/utility_bookmarks_i_32.png differ diff --git a/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/utility_bookmarks_r_24.png b/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/utility_bookmarks_r_24.png new file mode 100644 index 000000000..ae5497c36 Binary files /dev/null and b/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/utility_bookmarks_r_24.png differ diff --git a/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/utility_bookmarks_r_32.png b/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/utility_bookmarks_r_32.png new file mode 100644 index 000000000..1a30d7850 Binary files /dev/null and b/viewer/viewer-awt/src/main/resources/org/icepdf/ri/images/utility_bookmarks_r_32.png differ diff --git a/viewer/viewer-awt/src/main/resources/org/icepdf/ri/resources/MessageBundle.properties b/viewer/viewer-awt/src/main/resources/org/icepdf/ri/resources/MessageBundle.properties index 5c2870ea7..636a19dcd 100644 --- a/viewer/viewer-awt/src/main/resources/org/icepdf/ri/resources/MessageBundle.properties +++ b/viewer/viewer-awt/src/main/resources/org/icepdf/ri/resources/MessageBundle.properties @@ -145,6 +145,8 @@ viewer.toolbar.tool.annotationPreview.label= viewer.toolbar.tool.annotationPreview.tooltip=Annotation Summary Window viewer.toolbar.tool.annotationUtility.label= viewer.toolbar.tool.annotationUtility.tooltip=Show Annotations Utility Pane +viewer.toolbar.tool.bookmarkUtility.label= +viewer.toolbar.tool.bookmarkUtility.tooltip=Show Bookmarks Utility Pane viewer.toolbar.tool.annotationEditingMode.label= viewer.toolbar.tool.annotationEditingMode.tooltip=Annotation Editing Mode viewer.toolbar.pageFit.fontEngine.label=