KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > sync > ToolTipMessageDialog


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.sync;
12 import org.eclipse.jface.dialogs.MessageDialog;
13 import org.eclipse.swt.graphics.Image;
14 import org.eclipse.swt.widgets.Composite;
15 import org.eclipse.swt.widgets.Shell;
16 /**
17  * A class that adds tool-tips to the buttons of a standard message dialog.
18  */

19 public class ToolTipMessageDialog extends MessageDialog {
20     private String JavaDoc[] buttonToolTips;
21     /**
22      * Same as the MessageDialog constructor, with the addition of a button tooltip
23      * argument. The number of button tool tips must match the number of button labels.
24      */

25     public ToolTipMessageDialog(Shell parentShell, String JavaDoc dialogTitle, Image dialogTitleImage, String JavaDoc dialogMessage, int dialogImageType, String JavaDoc[] dialogButtonLabels, String JavaDoc[] buttonToolTips, int defaultIndex) {
26         super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex);
27         this.buttonToolTips = buttonToolTips;
28     }
29     /**
30      * Method declared on MessageDialog.
31      */

32     protected void createButtonsForButtonBar(Composite parent) {
33         super.createButtonsForButtonBar(parent);
34         if (buttonToolTips != null) {
35             for (int i = 0; i < buttonToolTips.length; i++) {
36                 getButton(i).setToolTipText(buttonToolTips[i]);
37             }
38         }
39     }
40 }
41
Popular Tags