Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a06094bcc61c5b1b206b1077189ade0464d6bbb0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*******************************************************************************
 * Copyright (c) 2006 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 * IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.team.internal.ui.dialogs;

import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.mapping.ISynchronizationScope;

public class NoChangesDialog extends DetailsDialog {

    private String message;
    private Label messageLabel;
    private Label imageLabel;
    private ResourceMappingHierarchyArea selectedMappingsArea;
	private final ISynchronizationScope scope;
	private final String description;

	public NoChangesDialog(Shell parentShell, String dialogTitle, String message, String description, ISynchronizationScope scope) {
		super(parentShell, dialogTitle);
		this.message = message;
		this.description = description;
		this.scope = scope;
	}

	@Override
	protected void initializeStyle() {
		// Use the default dialog style
	}

	@Override
	protected Composite createDropDownDialogArea(Composite parent) {
		Composite composite = new Composite(parent, SWT.NONE);
		GridLayout layout = new GridLayout();
		layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
		layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
		layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
		layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
		composite.setLayout(layout);
		composite.setLayoutData(new GridData(GridData.FILL_BOTH));
        selectedMappingsArea = ResourceMappingHierarchyArea.create(scope, null /* no context */);
        selectedMappingsArea.setDescription(description);
        selectedMappingsArea.createArea(composite);
        return composite;
	}

	@Override
	protected void createMainDialogArea(Composite parent) {
        Composite composite = new Composite(parent, SWT.NONE);
        GridLayout layout = new GridLayout();
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        layout.numColumns = 2;
        composite.setLayout(layout);
		createMessageArea(composite);
	}

	@Override
	protected void updateEnablements() {
		// Nothing to do
	}

	/*
	 * Code copied from IconandMessageDialog
	 */
	private Control createMessageArea(Composite composite) {
        // create composite
        // create image
        Image image = getSWTImage(SWT.ICON_INFORMATION);
        if (image != null) {
            imageLabel = new Label(composite, SWT.NULL);
            image.setBackground(imageLabel.getBackground());
            imageLabel.setImage(image);
            imageLabel.setLayoutData(new GridData(
                    GridData.HORIZONTAL_ALIGN_CENTER
                            | GridData.VERTICAL_ALIGN_BEGINNING));
        }
        // create message
        if (message != null) {
            messageLabel = new Label(composite, SWT.WRAP);
            messageLabel.setText(message);
            GridData data = new GridData(GridData.GRAB_HORIZONTAL
                    | GridData.HORIZONTAL_ALIGN_FILL
                    | GridData.VERTICAL_ALIGN_BEGINNING);
            data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
            messageLabel.setLayoutData(data);
        }
        return composite;
    }

	/*
	 * Code copied from IconandMessageDialog
	 */
    private Image getSWTImage(final int imageID) {
        Shell shell = getShell();
        final Display display;
        if (shell == null) {
            shell = getParentShell();
        }
        if (shell == null) {
            display = Display.getCurrent();
        } else {
            display = shell.getDisplay();
        }

        final Image[] image = new Image[1];
        display.syncExec(() -> image[0] = display.getSystemImage(imageID));

        return image[0];
    }

    @Override
	public boolean isHelpAvailable() {
    	return false;
    }

    @Override
	protected boolean includeCancelButton() {
    	return false;
    }

	public static void open(Shell shell, String title, String message, String description, ISynchronizationScope scope) {
		new NoChangesDialog(shell, title, message, description, scope).open();
	}

}

Back to the top