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 /** The reference to the visual shell */ 036 protected Shell shell; 037 038 /** The setting of the current font */ 039 protected Font curFont; 040 041 /** The setting of the root directory */ 042 protected String rootDir = null; 043 044 /** 045 * <code>UserOptionsDefaultPage</code> default constructor. 046 */ 047 public UserOptionsDefaultPage() { 048 super(); 049 } 050 051 /** 052 * Creates a new abstract <code>UserOptionsDefaultPage</code> with the 053 * given title. 054 * 055 * @param title the page title 056 */ 057 public UserOptionsDefaultPage(String title) { 058 super(title); 059 } 060 061 /** 062 * Creates a new abstract <code>UserOptionsDefaultPage</code> with the 063 * given title and image. 064 * 065 * @param title the page title 066 * @param image the image for this page, or <code>null</code> if none 067 */ 068 public UserOptionsDefaultPage(String title, ImageDescriptor image) { 069 super(title, image); 070 } 071 072 @Override 073 public void createControl(Composite parent) 074 { 075 super.createControl(parent); 076 077 Button applyButton = this.getApplyButton(); 078 Button defaultsButton = this.getDefaultsButton(); 079 if (applyButton != null && defaultsButton != null) { 080 /* Apply and default button are shown */ 081 082 /* Customize apply button (text + image) */ 083 applyButton.setText("apply changes"); 084 //applyButton.setImage(SWTHelper.loadImage("save.gif")); 085 this.setButtonLayoutData(applyButton); 086 087 /* Customize defaults button (text + image) */ 088 defaultsButton.setText("restore defaults"); 089 //defaultsButton.setImage(SWTHelper.loadImage("clear.gif")); 090 this.setButtonLayoutData(defaultsButton); 091 } 092 } 093}