1 11 package org.eclipse.team.internal.ccvs.ui; 12 13 import org.eclipse.jface.dialogs.MessageDialog; 14 import org.eclipse.swt.SWT; 15 import org.eclipse.swt.events.SelectionEvent; 16 import org.eclipse.swt.events.SelectionListener; 17 import org.eclipse.swt.graphics.Image; 18 import org.eclipse.swt.layout.GridData; 19 import org.eclipse.swt.widgets.Button; 20 import org.eclipse.swt.widgets.Composite; 21 import org.eclipse.swt.widgets.Control; 22 import org.eclipse.swt.widgets.Shell; 23 24 public class AvoidableMessageDialog extends MessageDialog { 25 Button dontShowAgain; 26 boolean dontShow; 27 boolean showOption; 28 29 public AvoidableMessageDialog(Shell shell, String dialogTitle, Image dialogTitleImage, String dialogMessage, int dialogImageType, String [] dialogButtonLabels, int defaultIndex) { 30 this(shell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex, true); 31 } 32 33 public AvoidableMessageDialog(Shell shell, String dialogTitle, Image dialogTitleImage, String dialogMessage, int dialogImageType, String [] dialogButtonLabels, int defaultIndex, boolean showOption) { 34 super(shell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex); 35 this.showOption = showOption; 36 } 37 38 protected Control createCustomArea(Composite composite) { 39 if ( ! showOption) return null; 40 dontShow = false; 41 dontShowAgain = new Button(composite, SWT.CHECK); 42 GridData data = new GridData(); 43 data.horizontalIndent = 50; 44 dontShowAgain.setLayoutData(data); 45 dontShowAgain.setText(CVSUIMessages.AvoidableMessageDialog_dontShowAgain); 46 dontShowAgain.setSelection(dontShow); 47 dontShowAgain.addSelectionListener(new SelectionListener() { 48 public void widgetSelected(SelectionEvent e) { 49 dontShow = dontShowAgain.getSelection(); 50 } 51 public void widgetDefaultSelected(SelectionEvent e) { 52 widgetSelected(e); 53 } 54 55 }); 56 return dontShowAgain; 57 } 58 59 public boolean isDontShowAgain() { 60 return dontShow; 61 } 62 63 } 64 | Popular Tags |