/******************************************************************************* * Copyright (c) 2002, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package de.tub.tfs.muvitor.ui.utils.test; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.preference.PreferenceDialog; import org.eclipse.jface.preference.PreferenceManager; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; /** * A Preference Dialog which has a Close button in place of OK/Cancel buttons, * and titled "Properties" in place of "Preferences" * * @author Michael Yee */ public class PropertiesDialog extends PreferenceDialog { /** return code constant (value 2) indicating that the window was canceled. */ static public final int CLOSE = 2; /** the close button */ private Button closeButton; /** * PropertiesDialog constructor * * @param parentShell * the parent shell * @param manager * the preference manager */ public PropertiesDialog(final Shell parentShell, final PreferenceManager manager) { super(parentShell, manager); } /* * (non-Javadoc) * @see * org.eclipse.jface.preference.IPreferencePageContainer#updateButtons() */ @Override public void updateButtons() { // do nothing } /* * (non-Javadoc) * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) */ @Override protected void buttonPressed(final int buttonId) { if (buttonId == IDialogConstants.CLOSE_ID) { close(); return; } } /* * (non-Javadoc) * @see * org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse * .swt.widgets.Composite) */ @Override protected void createButtonsForButtonBar(final Composite parent) { // create close button closeButton = createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, true); getShell().setDefaultButton(closeButton); } /* * (non-Javadoc) * @see * org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets * .Composite) */ @Override protected Control createDialogArea(final Composite parent) { final Control control = super.createDialogArea(parent); // set title to "Properties" getShell().setText("Properties"); return control; } }