KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > dialogs > NoChangesDialog


1 /*******************************************************************************
2  * Copyright (c) 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.ui.dialogs;
12
13 import org.eclipse.jface.dialogs.IDialogConstants;
14 import org.eclipse.swt.SWT;
15 import org.eclipse.swt.graphics.Image;
16 import org.eclipse.swt.layout.GridData;
17 import org.eclipse.swt.layout.GridLayout;
18 import org.eclipse.swt.widgets.*;
19 import org.eclipse.team.core.mapping.ISynchronizationScope;
20
21 public class NoChangesDialog extends DetailsDialog {
22
23     private String JavaDoc message;
24     private Label messageLabel;
25     private Label imageLabel;
26     private ResourceMappingHierarchyArea selectedMappingsArea;
27     private final ISynchronizationScope scope;
28     private final String JavaDoc description;
29     
30     public NoChangesDialog(Shell parentShell, String JavaDoc dialogTitle, String JavaDoc message, String JavaDoc description, ISynchronizationScope scope) {
31         super(parentShell, dialogTitle);
32         this.message = message;
33         this.description = description;
34         this.scope = scope;
35     }
36
37     protected void initializeStyle() {
38         // Use the default dialog style
39
}
40     
41     protected Composite createDropDownDialogArea(Composite parent) {
42         Composite composite = new Composite(parent, SWT.NONE);
43         GridLayout layout = new GridLayout();
44         layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
45         layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
46         layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
47         layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
48         composite.setLayout(layout);
49         composite.setLayoutData(new GridData(GridData.FILL_BOTH));
50         selectedMappingsArea = ResourceMappingHierarchyArea.create(scope, null /* no context */);
51         selectedMappingsArea.setDescription(description);
52         selectedMappingsArea.createArea(composite);
53         return composite;
54     }
55
56     protected void createMainDialogArea(Composite parent) {
57         Composite composite = new Composite(parent, SWT.NONE);
58         GridLayout layout = new GridLayout();
59         layout.marginHeight = 0;
60         layout.marginWidth = 0;
61         layout.numColumns = 2;
62         composite.setLayout(layout);
63         createMessageArea(composite);
64     }
65
66     protected void updateEnablements() {
67         // Nothing to do
68
}
69     
70     /*
71      * Code copied from IconandMessageDialog
72      */

73     private Control createMessageArea(Composite composite) {
74         // create composite
75
// create image
76
Image image = getSWTImage(SWT.ICON_INFORMATION);
77         if (image != null) {
78             imageLabel = new Label(composite, SWT.NULL);
79             image.setBackground(imageLabel.getBackground());
80             imageLabel.setImage(image);
81             imageLabel.setLayoutData(new GridData(
82                     GridData.HORIZONTAL_ALIGN_CENTER
83                             | GridData.VERTICAL_ALIGN_BEGINNING));
84         }
85         // create message
86
if (message != null) {
87             messageLabel = new Label(composite, SWT.WRAP);
88             messageLabel.setText(message);
89             GridData data = new GridData(GridData.GRAB_HORIZONTAL
90                     | GridData.HORIZONTAL_ALIGN_FILL
91                     | GridData.VERTICAL_ALIGN_BEGINNING);
92             data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
93             messageLabel.setLayoutData(data);
94         }
95         return composite;
96     }
97     
98     /*
99      * Code copied from IconandMessageDialog
100      */

101     private Image getSWTImage(final int imageID) {
102         Shell shell = getShell();
103         final Display display;
104         if (shell == null) {
105             shell = getParentShell();
106         }
107         if (shell == null) {
108             display = Display.getCurrent();
109         } else {
110             display = shell.getDisplay();
111         }
112
113         final Image[] image = new Image[1];
114         display.syncExec(new Runnable JavaDoc() {
115             public void run() {
116                 image[0] = display.getSystemImage(imageID);
117             }
118         });
119
120         return image[0];
121     }
122
123     public boolean isHelpAvailable() {
124         return false;
125     }
126     
127     protected boolean includeCancelButton() {
128         return false;
129     }
130     
131     public static void open(Shell shell, String JavaDoc title, String JavaDoc message, String JavaDoc description, ISynchronizationScope scope) {
132         new NoChangesDialog(shell, title, message, description, scope).open();
133     }
134
135 }
136
Popular Tags