Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show bookmarks button #149

Merged
merged 13 commits into from
Mar 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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) {

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

/**
Expand Down Expand Up @@ -4399,14 +4417,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 @@ -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) {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -5509,7 +5545,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