blob: 06da1df72c5a33d18095b35ef35f0005e960dee0 [file] [log] [blame]
/******************************************************************************
* Copyright (c) 2002, 2005 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 org.eclipse.gmf.runtime.common.ui.dialogs;
import org.eclipse.gmf.runtime.common.ui.internal.l10n.CommonUIMessages;
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 {
/** the close button */
private Button closeButton;
/** return code constant (value 2) indicating that the window was canceled. */
static public final int CLOSE = 2;
/**
* PropertiesDialog constructor
*
* @param parentShell
* the parent shell
* @param manager
* the preference manager
*/
public PropertiesDialog(Shell parentShell, PreferenceManager manager) {
super(parentShell, manager);
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.preference.IPreferencePageContainer#updateButtons()
*/
public void updateButtons() {
// do nothing
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
*/
protected void createButtonsForButtonBar(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)
*/
protected Control createDialogArea(Composite parent) {
Control control = super.createDialogArea(parent);
// set title to "Properties"
getShell().setText(
CommonUIMessages.PropertiesDialog_title);
return control;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int)
*/
protected void buttonPressed(int buttonId) {
if (buttonId == IDialogConstants.CLOSE_ID) {
close();
return;
}
}
}