Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Show About Dialog in RCP 4 Application(Create Dialog and handle it )
Show About Dialog in RCP 4 Application [message #1767652] Sat, 08 July 2017 13:35 Go to next message
Davide Vergnani is currently offline Davide VergnaniFriend
Messages: 1
Registered: July 2017
Junior Member
Hi everybody,
I'm new in the eclipse rcp 4 develop, and I'm in throuble when I want to create a custom dialog. I don't know how I can handle that dialog.

My intension is to create a command whit method execute and open that dialog created in te Windows and Dialogs menu in the Application.e4xmi.

Somebody can help me?!
Re: Show About Dialog in RCP 4 Application [message #1775135 is a reply to message #1767652] Wed, 25 October 2017 08:10 Go to previous message
Mihael Schmidt is currently offline Mihael SchmidtFriend
Messages: 81
Registered: August 2010
Just write a simple handler and open the dialog in the execute method.


public class AboutHandler {
	private IEclipseContext context;
	public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell) {
		AboutDialog dialog = new AboutDialog(shell);
		ContextInjectionFactory.inject(dialog, context);;

Dialog code:

import javax.inject.Inject;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.util.Geometry;
import org.eclipse.swt.SWT;
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.Monitor;
import org.eclipse.swt.widgets.Shell;
import org.osgi.framework.FrameworkUtil;

public class AboutDialog extends Dialog {

	private final String PLUGIN_URI = "platform:/plugin/my.plugin";
	private TranslationService translations;

	public AboutDialog(Shell shell) {
		setShellStyle(SWT.TITLE | SWT.RESIZE);

	protected void configureShell(Shell newShell) {
		newShell.setText(translations.translate("%about.dialog.title", PLUGIN_URI));

	protected Control createDialogArea(Composite parent) {
		parent.setLayout(new GridLayout(2, false));

		InputStream in = null;
		try {
			in = FrameworkUtil.getBundle(this.getClass()).getResource("/images/about-side.jpg")
		catch (IOException e) {

		Image image = new Image(Display.getCurrent(), in);

		Label sideImage = new Label(parent, SWT.BORDER);

		GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
		Label text = new Label(parent, SWT.WRAP);

		return super.createDialogArea(parent);

	protected void createButtonsForButtonBar(Composite parent) {
		createButton(parent, IDialogConstants.OK_ID,
				translations.translate("%common.close", PLUGIN_URI), true);

	private String getDialogText() {
		String text = translations.translate("%about.dialog.text", PLUGIN_URI);
		return text;
	protected Control createContents(Composite parent) {
		Control content = super.createContents(parent);
		return content;
	protected void initializeBounds() {
		Rectangle bounds = getShell().getBounds();
		Point location = getInitialLocation(new Point(bounds.width, bounds.height));
		getShell().setBounds(location.x, location.y, bounds.width, bounds.height);
	 * Returns the initial location to use for the shell. The default
	 * implementation centers the shell horizontally (1/2 of the difference to
	 * the left and 1/2 to the right) and vertically (1/3 above and 2/3 below)
	 * relative to the parent shell, or display bounds if there is no parent
	 * shell.
	 * @param initialSize
	 *            the initial size of the shell, as returned by
	 *            <code>getInitialSize</code>.
	 * @return the initial location of the shell
	protected Point getInitialLocation(Point initialSize) {
		Composite parent = getShell().getParent();

		Monitor monitor = getShell().getDisplay().getPrimaryMonitor();
		if (parent != null) {
			monitor = parent.getMonitor();

		Rectangle monitorBounds = monitor.getClientArea();
		Point centerPoint;
		if (parent != null) {
			centerPoint = Geometry.centerPoint(parent.getBounds());
		} else {
			centerPoint = Geometry.centerPoint(monitorBounds);

		return new Point(centerPoint.x - (initialSize.x / 2), Math.max(
				monitorBounds.y, Math.min(centerPoint.y
						- (initialSize.y * 2 / 3), monitorBounds.y
						+ monitorBounds.height - initialSize.y)));
	protected boolean isResizable() {
		return true;

Previous Topic:Missing project explorer icons after update of platform (git projects)
Next Topic:P2 site
Goto Forum:

Current Time: Thu Oct 22 01:38:50 GMT 2020

Powered by FUDForum. Page generated in 0.01765 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top