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.slf4j.Logger; 018import org.slf4j.LoggerFactory; 019 020import org.eclipse.jface.preference.PreferencePage; 021import org.eclipse.jface.resource.ImageDescriptor; 022import org.eclipse.swt.graphics.Font; 023import org.eclipse.swt.widgets.Button; 024import org.eclipse.swt.widgets.Composite; 025import org.eclipse.swt.widgets.Shell; 026 027/** 028 * <code>UserOptionsDefaultPage</code> extends <code>PreferencePage</code> 029 * to display the default button 030 * images for the ok, cancel, apply and defaults button. All configuration pages 031 * that need finer control on the created editor <code>Controls</code> should 032 * inherit this class. 033 */ 034public abstract class UserOptionsDefaultPage extends PreferencePage { 035 036 private static final Logger log = LoggerFactory.getLogger(UserOptionsDefaultPage.class); 037 038 /** The reference to the visual shell */ 039 protected Shell shell; 040 041 /** The setting of the current font */ 042 protected Font curFont; 043 044 /** The setting of the root directory */ 045 protected String rootDir = null; 046 047 /** 048 * <code>UserOptionsDefaultPage</code> default constructor. 049 */ 050 public UserOptionsDefaultPage() { 051 super(); 052 } 053 054 /** 055 * Creates a new abstract <code>UserOptionsDefaultPage</code> with the 056 * given title. 057 * 058 * @param title the page title 059 */ 060 public UserOptionsDefaultPage(String title) { 061 super(title); 062 } 063 064 /** 065 * Creates a new abstract <code>UserOptionsDefaultPage</code> with the 066 * given title and image. 067 * 068 * @param title the page title 069 * @param image the image for this page, or <code>null</code> if none 070 */ 071 public UserOptionsDefaultPage(String title, ImageDescriptor image) { 072 super(title, image); 073 } 074 075 @Override 076 public void createControl(Composite parent) 077 { 078 super.createControl(parent); 079 080 Button applyButton = this.getApplyButton(); 081 Button defaultsButton = this.getDefaultsButton(); 082 if (applyButton != null && defaultsButton != null) { 083 /* Apply and default button are shown */ 084 085 /* Customize apply button (text + image) */ 086 applyButton.setText("apply changes"); 087 //applyButton.setImage(SWTHelper.loadImage("save.gif")); 088 this.setButtonLayoutData(applyButton); 089 090 /* Customize defaults button (text + image) */ 091 defaultsButton.setText("restore defaults"); 092 //defaultsButton.setImage(SWTHelper.loadImage("clear.gif")); 093 this.setButtonLayoutData(defaultsButton); 094 } 095 } 096}