Skip to main content
summaryrefslogtreecommitdiffstats
blob: cc35bbfd5ae1f32170d0cd1568c75d12cbc906ea (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
/*******************************************************************************
 * Copyright (c) 2005, 2016 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.help.ui.internal;

import org.eclipse.core.runtime.Platform;
import org.eclipse.help.ILiveHelpAction;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.PreferencesUtil;

public class ShowCapabilitiesPreferenceAction implements ILiveHelpAction {
	private boolean narrow;

	@Override
	public void setInitializationString(String data) {
		if (data!=null && data.equals("narrow")) //$NON-NLS-1$
			narrow=true;
	}

	@Override
	public void run() {
		final Display display = PlatformUI.getWorkbench().getDisplay();
		display.syncExec(() -> {
			Shell windowShell = null;
			if (!narrow) {
				Shell[] shells = display.getShells();
				for (int i = 0; i < shells.length; i++) {
					Object data = shells[i].getData();
					if (data != null && data instanceof IWorkbenchWindow) {
						windowShell = shells[i];
						break;
					}
				}
			}
			if (windowShell != null) {
				windowShell.forceActive();
				if (Platform.getWS().equals(Platform.WS_WIN32)) {
					// feature in Windows. Without this code,
					// the window will only flash in the launch bar.
					windowShell.setVisible(false);
					windowShell.setMinimized(true);
					windowShell.setVisible(true);
					windowShell.setMinimized(false);
				}
			}
			PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(windowShell,
					getCapabilityPageId(), null, null);
			dialog.open();
		});
	}

	private String getCapabilityPageId() {
		return "org.eclipse.sdk.capabilities"; //$NON-NLS-1$
	}
}

Back to the top