1 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 message; 24 private Label messageLabel; 25 private Label imageLabel; 26 private ResourceMappingHierarchyArea selectedMappingsArea; 27 private final ISynchronizationScope scope; 28 private final String description; 29 30 public NoChangesDialog(Shell parentShell, String dialogTitle, String message, String 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 } 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 ); 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 } 69 70 73 private Control createMessageArea(Composite composite) { 74 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 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 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 () { 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 title, String message, String description, ISynchronizationScope scope) { 132 new NoChangesDialog(shell, title, message, description, scope).open(); 133 } 134 135 } 136 | Popular Tags |