Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 3e93745533643f14dec7637b05b5cc3bc387dc99 (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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*******************************************************************************
 * Copyright (c) 2009, 2015 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.ui.about;

import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;

import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;

/**
 * Abstract base implementation for an installation dialog page.
 * <p>
 * Clients should extend this class and include the name of the subclass in an
 * extension contributed to the workbench's installation pages extension point
 * (named <code>"org.eclipse.ui.installationPages"</code>). For example, the
 * plug-in's XML markup might contain:
 * </p>
 *
 * <pre>
 * &lt;extension point="org.eclipse.ui.installationPages"&gt;
 *      &lt;page id="com.example.myplugin.installInfo"
 *         name="Example Details"
 *         class="com.example.myplugin.MyInstallationPage" /&gt;
 * &lt;/extension&gt;
 * </pre>
 *
 *
 * @since 3.5
 */
public abstract class InstallationPage extends DialogPage {

	private IInstallationPageContainer container;

	/**
	 * Sets or clears the message for this page.
	 * <p>
	 * This message has no effect when the receiver is used in an
	 * IInstallationPageContainer.
	 * </p>
	 *
	 * @param newMessage
	 *            the message, or <code>null</code> to clear the message
	 */
	@Override
	public void setMessage(String newMessage) {
		super.setMessage(newMessage);
	}

	/**
	 * Sets the message for this page with an indication of what type of message
	 * it is.
	 * <p>
	 * The valid message types are one of <code>NONE</code>,
	 * <code>INFORMATION</code>,<code>WARNING</code>, or <code>ERROR</code>.
	 * </p>
	 * <p>
	 * This message has no effect when the receiver is used in an
	 * IInstallationPageContainer.
	 * </p>
	 *
	 * @param newMessage
	 *            the message, or <code>null</code> to clear the message
	 * @param newType
	 *            the message type
	 */
	@Override
	public void setMessage(String newMessage, int newType) {
		super.setMessage(newMessage, newType);
	}

	/**
	 * Set the page container that is hosting this page. This method is
	 * typically called by the container itself so that the pages have access to
	 * the container when registering buttons using
	 * {@link IInstallationPageContainer#registerPageButton(InstallationPage, Button)}
	 * or performing other container-related tasks.
	 *
	 * @param container
	 *            the container that is hosting the page.
	 */
	public void setPageContainer(IInstallationPageContainer container) {
		this.container = container;
	}

	/**
	 * Create the buttons that belong to this page using the specified parent.
	 *
	 * @param parent
	 *            the parent to use for the buttons.
	 *
	 * @see #createButton(Composite, int, String)
	 * @see #buttonPressed(int)
	 */
	public void createPageButtons(Composite parent) {
		// By default, there are no page-specific buttons
	}

	/**
	 * Creates a new button with the given id.
	 * <p>
	 * This method creates a standard push button, registers it for selection
	 * events, and registers it as a button belonging to this page. Subclasses
	 * should not make any assumptions about the visibility, layout, or
	 * presentation of this button inside the dialog.
	 * </p>
	 *
	 * @param parent
	 *            the parent composite
	 * @param id
	 *            the id of the button (see <code>IDialogConstants.*_ID</code>
	 *            constants for standard dialog button ids)
	 * @param label
	 *            the label from the button
	 * @return the new button
	 *
	 * @see #createPageButtons(Composite)
	 * @see #buttonPressed(int)
	 */
	protected Button createButton(Composite parent, int id, String label) {
		Button button = new Button(parent, SWT.PUSH);
		button.setText(label);
		button.setData(Integer.valueOf(id));
		button.addSelectionListener(widgetSelectedAdapter(event -> buttonPressed(((Integer) event.widget.getData()).intValue())));
		container.registerPageButton(this, button);
		return button;
	}

	/**
	 * Notifies that this page's button with the given id has been pressed.
	 * Subclasses should extend this method to handle the buttons created in
	 * {@link #createButton(Composite, int, String)}
	 *
	 * @param buttonId
	 *            the id of the button that was pressed (see
	 *            <code>IDialogConstants.*_ID</code> constants)
	 */
	protected void buttonPressed(int buttonId) {
	}

	/**
	 * Get the page container that is hosting this page. This method is
	 * typically used when registering buttons using
	 * {@link IInstallationPageContainer#registerPageButton(InstallationPage, Button)}
	 * or performing other container-related tasks.
	 *
	 * @return the container that is hosting the page.
	 */
	protected IInstallationPageContainer getPageContainer() {
		return container;
	}

}

Back to the top