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 COPYING file, which can be found * 009 * at the root of the source code distribution tree, * 010 * or in https://www.hdfgroup.org/licenses. * 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() { super(); } 051 052 /** 053 * Creates a new abstract <code>UserOptionsDefaultPage</code> with the 054 * given title. 055 * 056 * @param title the page title 057 */ 058 public UserOptionsDefaultPage(String title) { super(title); } 059 060 /** 061 * Creates a new abstract <code>UserOptionsDefaultPage</code> with the 062 * given title and image. 063 * 064 * @param title the page title 065 * @param image the image for this page, or <code>null</code> if none 066 */ 067 public UserOptionsDefaultPage(String title, ImageDescriptor image) { super(title, image); } 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}