Skip to content

Commit

Permalink
GH-148 Show bookmarks button (#149)
Browse files Browse the repository at this point in the history
* Fixes conflict with PropertiesManager renaming

* GH-148 Adds 'Show bookmarks' button

* GH-148 Renames bookmarks to utility_bookmarks
  • Loading branch information
gtache committed Mar 25, 2021
1 parent 5f209e0 commit 7987f30
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,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;
Expand Down Expand Up @@ -878,6 +879,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
*
Expand Down Expand Up @@ -1602,6 +1613,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) {

Expand Down Expand Up @@ -2140,6 +2152,8 @@ private void reflectToolInToolButtons() {
isUtilityPaneVisible());
reflectSelectionInButton(showAnnotationUtilityPaneButton,
isAnnotationUtilityPaneVisible());
reflectSelectionInButton(showBookmarkUtilityPaneButton,
isBookmarkUtilityPaneVisible());
reflectSelectionInButton(formHighlightButton,
viewModel.isWidgetAnnotationHighlight());
reflectSelectionInButton(annotationEditingModeButton,
Expand Down Expand Up @@ -4271,8 +4285,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();
}

/**
Expand Down Expand Up @@ -4381,14 +4402,20 @@ protected boolean safelySelectUtilityPanel(Component comp) {
if ((utilityTabbedPane != null) && (comp != null)) {
if (utilityTabbedPane.indexOfComponent(comp) > -1) {
utilityTabbedPane.setSelectedComponent(comp);

return true;
}
}

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) {
Expand Down Expand Up @@ -4440,32 +4467,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) {
Expand Down Expand Up @@ -4504,17 +4510,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.
Expand Down Expand Up @@ -4784,7 +4821,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) {
Expand Down Expand Up @@ -5481,7 +5520,7 @@ public void propertyChange(PropertyChangeEvent evt) {
if (logger.isLoggable(Level.FINE)) {
logger.fine("selected annotation " + annotationComponent);
}
showAnnotationPanel(annotationComponent);
showAnnotationPanel(true);
}
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 7987f30

Please sign in to comment.