1
|
/*******************************************************************************
|
2
|
* Copyright (c) 2014 OPCoach.
|
3
|
* All rights reserved. This program and the accompanying materials
|
4
|
* are made available under the terms of the Eclipse Public License v1.0
|
5
|
* which accompanies this distribution, and is available at
|
6
|
* http://www.eclipse.org/legal/epl-v10.html
|
7
|
*
|
8
|
* Contributors:
|
9
|
* Manumitting Technologies : Brian de Alwis for initial API and implementation
|
10
|
* OPCoach : O.Prouvost fix bugs on hierarchy
|
11
|
*******************************************************************************//*
|
12
|
* Handler to open up a configured preferences dialog.
|
13
|
* Written by Brian de Alwis, Manumitting Technologies.
|
14
|
* Placed in the public domain.
|
15
|
* This code comes from : http://www.eclipse.org/forums/index.php/fa/4347/
|
16
|
* and was referenced in the thread : http://www.eclipse.org/forums/index.php/m/750139/
|
17
|
*/
|
18
|
package com.opcoach.e4.preferences.handlers;
|
19
|
|
20
|
import javax.inject.Named;
|
21
|
|
22
|
import org.eclipse.e4.core.di.annotations.CanExecute;
|
23
|
import org.eclipse.e4.core.di.annotations.Execute;
|
24
|
import org.eclipse.e4.ui.services.IServiceConstants;
|
25
|
import org.eclipse.jface.preference.PreferenceDialog;
|
26
|
import org.eclipse.jface.preference.PreferenceManager;
|
27
|
import org.eclipse.jface.viewers.ViewerComparator;
|
28
|
import org.eclipse.swt.widgets.Shell;
|
29
|
|
30
|
import com.opcoach.e4.preferences.E4PreferenceRegistry;
|
31
|
|
32
|
|
33
|
public class E4PreferencesHandler
|
34
|
{
|
35
|
|
36
|
|
37
|
@CanExecute
|
38
|
public boolean canExecute()
|
39
|
{
|
40
|
return true;
|
41
|
}
|
42
|
|
43
|
@Execute
|
44
|
public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell, E4PreferenceRegistry prefReg)
|
45
|
{
|
46
|
PreferenceManager pm = prefReg.getPreferenceManager();
|
47
|
PreferenceDialog dialog = new PreferenceDialog(shell, pm);
|
48
|
dialog.create();
|
49
|
dialog.getTreeViewer().setComparator(new ViewerComparator());
|
50
|
dialog.getTreeViewer().expandToLevel(2);
|
51
|
dialog.open();
|
52
|
}
|
53
|
|
54
|
|
55
|
|
56
|
|
57
|
}
|