KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > AvoidableMessageDialog


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 JavaDoc dialogTitle, Image dialogTitleImage, String JavaDoc dialogMessage, int dialogImageType, String JavaDoc[] dialogButtonLabels, int defaultIndex) {
30         this(shell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex, true);
31     }
32     
33     public AvoidableMessageDialog(Shell shell, String JavaDoc dialogTitle, Image dialogTitleImage, String JavaDoc dialogMessage, int dialogImageType, String JavaDoc[] 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