/*
 * @(#)ViewGoToPreviousPageAction.java  1.0  2008-09-20
 * 
 * Copyright (c) 2008 Werner Randelshofer, Immensee, Switzerland.
 * All rights reserved.
 *
 * You may not use, copy or modify this file, except in compliance with the
 * license agreement you entered into with Werner Randelshofer.
 * For details see accompanying license terms.
 */

package ch.randelshofer.pdf.action;

import ch.randelshofer.pdf.JPDFFilePanel;
import java.awt.event.ActionEvent;

/**
 * ViewGoToPreviousPageAction.
 * 
 * @author Werner Randelshofer
 * @version 1.0 2008-09
 */
public class ViewGoToPreviousPageAction extends AbstractJPDFFilePanelAction {
    public static String ID = "view.goTo.previousPage";

    public ViewGoToPreviousPageAction(JPDFFilePanel pdfPanel) {
        super(pdfPanel, ID);
    }

    public void actionPerformed(ActionEvent e) {
        pdfPanel.setCurrentPageNumber(pdfPanel.getCurrentPageNumber() - 1);
    }

    @Override
    protected void updateAction() {
        setEnabled(pdfPanel.getPDF() != null &&
                pdfPanel.getCurrentPageNumber() > 0);
    }

}
