X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.externaltools/src/net/sourceforge/phpdt/externaltools/internal/ui/MessageDialogWithToggle.java b/net.sourceforge.phpeclipse.externaltools/src/net/sourceforge/phpdt/externaltools/internal/ui/MessageDialogWithToggle.java index 959db60..1e3e84f 100644 --- a/net.sourceforge.phpeclipse.externaltools/src/net/sourceforge/phpdt/externaltools/internal/ui/MessageDialogWithToggle.java +++ b/net.sourceforge.phpeclipse.externaltools/src/net/sourceforge/phpdt/externaltools/internal/ui/MessageDialogWithToggle.java @@ -1,11 +1,11 @@ package net.sourceforge.phpdt.externaltools.internal.ui; /********************************************************************** -Copyright (c) 2000, 2002 IBM Corp. All rights reserved. -This file is made available under the terms of the Common Public License v1.0 -which accompanies this distribution, and is available at -http://www.eclipse.org/legal/cpl-v10.html -**********************************************************************/ + Copyright (c) 2000, 2002 IBM Corp. All rights reserved. + This file is made available under the terms of the Common Public License v1.0 + which accompanies this distribution, and is available at + http://www.eclipse.org/legal/cpl-v10.html + **********************************************************************/ import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; @@ -25,29 +25,36 @@ import org.eclipse.swt.widgets.Shell; * should be shown in the future */ public class MessageDialogWithToggle extends MessageDialog { - + /** - * The preference key which is set by the toggle button. - * This key must be a boolean preference in the preference store. + * The preference key which is set by the toggle button. This key must be a + * boolean preference in the preference store. */ private String fPreferenceKey = null; + /** * The message displayed to the user, with the toggle button */ private String fToggleMessage = null; + private Button fToggleButton = null; + /** * The preference store which will be affected by the toggle button */ IPreferenceStore fStore = null; - public MessageDialogWithToggle(Shell parentShell, String dialogTitle, Image image, String message, int dialogImageType, String[] dialogButtonLabels, int defaultIndex, String preferenceKey, String toggleMessage, IPreferenceStore store) { - super(parentShell, dialogTitle, image, message, dialogImageType, dialogButtonLabels, defaultIndex); + public MessageDialogWithToggle(Shell parentShell, String dialogTitle, + Image image, String message, int dialogImageType, + String[] dialogButtonLabels, int defaultIndex, + String preferenceKey, String toggleMessage, IPreferenceStore store) { + super(parentShell, dialogTitle, image, message, dialogImageType, + dialogButtonLabels, defaultIndex); fStore = store; fPreferenceKey = preferenceKey; fToggleMessage = toggleMessage; } - + protected Control createDialogArea(Composite parent) { Composite dialogArea = (Composite) super.createDialogArea(parent); fToggleButton = createCheckButton(dialogArea, fToggleMessage); @@ -56,16 +63,16 @@ public class MessageDialogWithToggle extends MessageDialog { } /** - * Creates a button with the given label and sets the default - * configuration data. + * Creates a button with the given label and sets the default configuration + * data. */ protected Button createCheckButton(Composite parent, String label) { - Button button= new Button(parent, SWT.CHECK | SWT.LEFT); + Button button = new Button(parent, SWT.CHECK | SWT.LEFT); button.setText(label); GridData data = new GridData(SWT.NONE); - data.horizontalSpan= 2; - data.horizontalAlignment= GridData.CENTER; + data.horizontalSpan = 2; + data.horizontalAlignment = GridData.CENTER; button.setLayoutData(data); button.setFont(parent.getFont()); @@ -78,7 +85,7 @@ public class MessageDialogWithToggle extends MessageDialog { * @see org.eclipse.jface.dialogs.Dialog#buttonPressed(int) */ protected void buttonPressed(int id) { - if (id == IDialogConstants.OK_ID) { // was the OK button pressed? + if (id == IDialogConstants.OK_ID) { // was the OK button pressed? storePreference(); } super.buttonPressed(id); @@ -99,110 +106,116 @@ public class MessageDialogWithToggle extends MessageDialog { protected Button getToggleButton() { return fToggleButton; } - + /** * Convenience method to open a simple confirm (OK/Cancel) dialog. - * - * @param parent the parent shell of the dialog, or null if none - * @param title the dialog's title, or null if none - * @param message the message + * + * @param parent + * the parent shell of the dialog, or null if none + * @param title + * the dialog's title, or null if none + * @param message + * the message * @return true if the user presses the OK button, - * false otherwise + * false otherwise */ - public static boolean openConfirm(Shell parent, String title, String message, String preferenceKey, String toggleMessage, IPreferenceStore store) { - MessageDialogWithToggle dialog = new MessageDialogWithToggle( - parent, - title, - null, // accept the default window icon - message, - QUESTION, - new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}, - 0, // OK is the default - preferenceKey, - toggleMessage, - store); + public static boolean openConfirm(Shell parent, String title, + String message, String preferenceKey, String toggleMessage, + IPreferenceStore store) { + MessageDialogWithToggle dialog = new MessageDialogWithToggle(parent, + title, null, // accept the default window icon + message, QUESTION, new String[] { IDialogConstants.OK_LABEL, + IDialogConstants.CANCEL_LABEL }, 0, // OK is the default + preferenceKey, toggleMessage, store); return dialog.open() == 0; } + /** * Convenience method to open a standard error dialog. - * - * @param parent the parent shell of the dialog, or null if none - * @param title the dialog's title, or null if none - * @param message the message + * + * @param parent + * the parent shell of the dialog, or null if none + * @param title + * the dialog's title, or null if none + * @param message + * the message */ - public static void openError(Shell parent, String title, String message, String preferenceKey, String toggleMessage, IPreferenceStore store) { - MessageDialogWithToggle dialog = new MessageDialogWithToggle( - parent, - title, - null, // accept the default window icon - message, - ERROR, - new String[] {IDialogConstants.OK_LABEL}, - 0, // ok is the default - preferenceKey, - toggleMessage, - store); + public static void openError(Shell parent, String title, String message, + String preferenceKey, String toggleMessage, IPreferenceStore store) { + MessageDialogWithToggle dialog = new MessageDialogWithToggle(parent, + title, null, // accept the default window icon + message, ERROR, new String[] { IDialogConstants.OK_LABEL }, 0, // ok + // is + // the + // default + preferenceKey, toggleMessage, store); dialog.open(); } + /** * Convenience method to open a standard information dialog. - * - * @param parent the parent shell of the dialog, or null if none - * @param title the dialog's title, or null if none - * @param message the message + * + * @param parent + * the parent shell of the dialog, or null if none + * @param title + * the dialog's title, or null if none + * @param message + * the message */ - public static void openInformation( - Shell parent, - String title, - String message, String preferenceKey, String toggleMessage, IPreferenceStore store) { - MessageDialogWithToggle dialog = - new MessageDialogWithToggle(parent, title, null, // accept the default window icon - message, INFORMATION, new String[] { IDialogConstants.OK_LABEL }, 0, // ok is the default - preferenceKey, toggleMessage, store); + public static void openInformation(Shell parent, String title, + String message, String preferenceKey, String toggleMessage, + IPreferenceStore store) { + MessageDialogWithToggle dialog = new MessageDialogWithToggle(parent, + title, + null, // accept the default window icon + message, INFORMATION, + new String[] { IDialogConstants.OK_LABEL }, 0, // ok is the + // default + preferenceKey, toggleMessage, store); dialog.open(); } + /** * Convenience method to open a simple Yes/No question dialog. - * - * @param parent the parent shell of the dialog, or null if none - * @param title the dialog's title, or null if none - * @param message the message + * + * @param parent + * the parent shell of the dialog, or null if none + * @param title + * the dialog's title, or null if none + * @param message + * the message * @return true if the user presses the OK button, - * false otherwise + * false otherwise */ - public static boolean openQuestion(Shell parent, String title, String message, String preferenceKey, String toggleMessage, IPreferenceStore store) { - MessageDialogWithToggle dialog = new MessageDialogWithToggle( - parent, - title, - null, // accept the default window icon - message, - QUESTION, - new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}, - 0, // yes is the default - preferenceKey, - toggleMessage, - store); + public static boolean openQuestion(Shell parent, String title, + String message, String preferenceKey, String toggleMessage, + IPreferenceStore store) { + MessageDialogWithToggle dialog = new MessageDialogWithToggle(parent, + title, null, // accept the default window icon + message, QUESTION, new String[] { IDialogConstants.YES_LABEL, + IDialogConstants.NO_LABEL }, 0, // yes is the default + preferenceKey, toggleMessage, store); return dialog.open() == 0; } + /** * Convenience method to open a standard warning dialog. - * - * @param parent the parent shell of the dialog, or null if none - * @param title the dialog's title, or null if none - * @param message the message + * + * @param parent + * the parent shell of the dialog, or null if none + * @param title + * the dialog's title, or null if none + * @param message + * the message */ - public static void openWarning(Shell parent, String title, String message, String preferenceKey, String toggleMessage, IPreferenceStore store) { - MessageDialogWithToggle dialog = new MessageDialogWithToggle( - parent, - title, - null, // accept the default window icon - message, - WARNING, - new String[] {IDialogConstants.OK_LABEL}, - 0, // ok is the default - preferenceKey, - toggleMessage, - store); + public static void openWarning(Shell parent, String title, String message, + String preferenceKey, String toggleMessage, IPreferenceStore store) { + MessageDialogWithToggle dialog = new MessageDialogWithToggle(parent, + title, + null, // accept the default window icon + message, WARNING, new String[] { IDialogConstants.OK_LABEL }, + 0, // ok is the default + preferenceKey, toggleMessage, store); dialog.open(); }