public void itemStateChanged(ItemEvent e) {
        Object source = e.getSource();
        if (source == null)
            return;

        boolean doSetFocus = false;
        int tool = getDocumentViewToolMode();
        setDisplayTool(DocumentViewModelImpl.DISPLAY_TOOL_WAIT);
        try {
            if (source == zoomComboBox) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    setZoomFromZoomComboBox();
                    // Since combobox is an entry component, we don't force focus to the document
                }
            } else if (source == fitActualSizeButton) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    setPageFitMode(org.icepdf.core.views.DocumentViewController.PAGE_FIT_ACTUAL_SIZE, false);
                    doSetFocus = true;
                }
            } else if (source == fitHeightButton) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    setPageFitMode(org.icepdf.core.views.DocumentViewController.PAGE_FIT_WINDOW_HEIGHT, false);
                    doSetFocus = true;
                }
            } else if (source == fitWidthButton) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    setPageFitMode(org.icepdf.core.views.DocumentViewController.PAGE_FIT_WINDOW_WIDTH, false);
                    doSetFocus = true;
                }
            } else if (source == fontEngineButton) {
                if (e.getStateChange() == ItemEvent.SELECTED ||
                        e.getStateChange() == ItemEvent.DESELECTED) {
                    // get instance of the font factory
                    FontFactory.getInstance().toggleAwtFontSubstitution();
                    // refresh the document, refresh will happen by the component.
                    documentViewController.getDocumentView().getViewModel().invalidate();
                    doSetFocus = true;
                }

            } else if (source == panToolButton) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    tool = DocumentViewModelImpl.DISPLAY_TOOL_PAN;
                    setDocumentToolMode(DocumentViewModelImpl.DISPLAY_TOOL_PAN);
                    doSetFocus = true;
                }
            } else if (source == textSelectToolButton) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    tool = DocumentViewModelImpl.DISPLAY_TOOL_TEXT_SELECTION;
                    setDocumentToolMode(DocumentViewModelImpl.DISPLAY_TOOL_TEXT_SELECTION);
                    doSetFocus = true;
                }
            } else if (source == selectToolButton) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    tool = DocumentViewModelImpl.DISPLAY_TOOL_SELECTION;
                    setDocumentToolMode(DocumentViewModelImpl.DISPLAY_TOOL_SELECTION);
                }
            } else if (source == linkAnnotationToolButton) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    tool = DocumentViewModelImpl.DISPLAY_TOOL_LINK_ANNOTATION;
                    setDocumentToolMode(DocumentViewModelImpl.DISPLAY_TOOL_LINK_ANNOTATION);
                }
            } else if (source == zoomInToolButton) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    tool = DocumentViewModelImpl.DISPLAY_TOOL_ZOOM_IN;
                    setDocumentToolMode(DocumentViewModelImpl.DISPLAY_TOOL_ZOOM_IN);
                    doSetFocus = true;
                }
            } else if (source == zoomOutToolButton) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    tool = DocumentViewModelImpl.DISPLAY_TOOL_ZOOM_OUT;
                    setDocumentToolMode(DocumentViewModelImpl.DISPLAY_TOOL_ZOOM_OUT);
                    doSetFocus = true;
                }
            } else if (source == facingPageViewNonContinuousButton) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    setPageViewMode(
                            DocumentViewControllerImpl.TWO_PAGE_RIGHT_VIEW,
                            false);
                    doSetFocus = true;
                }
            } else if (source == facingPageViewContinuousButton) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    setPageViewMode(
                            DocumentViewControllerImpl.TWO_COLUMN_RIGHT_VIEW,
                            false);
                    doSetFocus = true;
                }
            } else if (source == singlePageViewNonContinuousButton) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    setPageViewMode(
                            DocumentViewControllerImpl.ONE_PAGE_VIEW,
                            false);
                    doSetFocus = true;
                }
            } else if (source == singlePageViewContinuousButton) {
                if (e.getStateChange() == ItemEvent.SELECTED) {
                    setPageViewMode(
                            DocumentViewControllerImpl.ONE_COLUMN_VIEW,
                            false);
                    doSetFocus = true;
                }
            }

            if (doSetFocus) {
                // setup focus to ensure page up and page down keys work
                documentViewController.requestViewFocusInWindow();
            }

        } finally {
            setDisplayTool(tool);
        }
    }