    001/*****************************************************************************
    002 * Copyright by The HDF Group.                                               *
    003 * Copyright by the Board of Trustees of the University of Illinois.         *
    004 * All rights reserved.                                                      *
    005 *                                                                           *
    006 * This file is part of the HDF Java Products distribution.                  *
    007 * The full copyright notice, including terms governing use, modification,   *
    008 * and redistribution, is contained in the files COPYING and Copyright.html. *
    009 * COPYING can be found at the root of the source code distribution tree.    *
    010 * Or, see https://support.hdfgroup.org/products/licenses.html               *
    011 * If you do not have access to either file, you may request a copy from     *
    012 * help@hdfgroup.org.                                                        *
    013 ****************************************************************************/
    014
    015package hdf.view.dialog;
    016
    017import org.eclipse.jface.preference.PreferencePage;
    018import org.eclipse.jface.resource.ImageDescriptor;
    019import org.eclipse.swt.graphics.Font;
    020import org.eclipse.swt.widgets.Button;
    021import org.eclipse.swt.widgets.Composite;
    022import org.eclipse.swt.widgets.Shell;
    023
    024/**
    025 * <code>UserOptionsDefaultPage</code> extends <code>PreferencePage</code>
    026 * to display the default button
    027 * images for the ok, cancel, apply and defaults button. All configuration pages
    028 * that need finer control on the created editor <code>Controls</code> should
    029 * inherit this class.
    030 */
    031public abstract class UserOptionsDefaultPage extends PreferencePage {
    032
    033    private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(UserOptionsDefaultPage.class);
    034
    035    protected Shell                 shell;
    036
    037    protected Font                  curFont;
    038
    039    protected String                rootDir = null;
    040
    041    /**
    042     * <code>UserOptionsDefaultPage</code> default constructor.
    043     */
    044    public UserOptionsDefaultPage() {
    045        super();
    046    }
    047
    048    /**
    049     * Creates a new abstract <code>UserOptionsDefaultPage</code> with the
    050     * given title.
    051     *
    052     * @param title the page title
    053     */
    054    public UserOptionsDefaultPage(String title) {
    055        super(title);
    056    }
    057
    058    /**
    059     * Creates a new abstract <code>UserOptionsDefaultPage</code> with the
    060     * given title and image.
    061     *
    062     * @param title the page title
    063     * @param image the image for this page, or <code>null</code> if none
    064     */
    065    public UserOptionsDefaultPage(String title, ImageDescriptor image) {
    066        super(title, image);
    067    }
    068
    069    @Override
    070    public void createControl(Composite parent)
    071    {
    072        super.createControl(parent);
    073
    074        Button applyButton = this.getApplyButton();
    075        Button defaultsButton = this.getDefaultsButton();
    076        if (applyButton != null && defaultsButton != null) {
    077            /* Apply and default button are shown */
    078
    079            /* Customize apply button (text + image) */
    080            applyButton.setText("apply changes");
    081            //applyButton.setImage(SWTHelper.loadImage("save.gif"));
    082            this.setButtonLayoutData(applyButton);
    083
    084            /* Customize defaults button (text + image) */
    085            defaultsButton.setText("restore defaults");
    086            //defaultsButton.setImage(SWTHelper.loadImage("clear.gif"));
    087            this.setButtonLayoutData(defaultsButton);
    088        }
    089    }
    090}