// Path: e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/ContributedPreferenceNode.java
// public class ContributedPreferenceNode extends PreferenceNode {
// 
// 	private final String path;
// 	private final String nodeQualifier;
// 	private final Class<? extends IPreferencePage> pageClass;
// 	
// 	public ContributedPreferenceNode(
// 			String id, String label, 
// 			ImageDescriptor imageDescriptor, Class<? extends IPreferencePage> pageClass,
// 			String path, String nodeQualifier) {
// 		
// 		super(id, label, imageDescriptor, pageClass.getName());
// 		this.path = path;
// 		this.pageClass = pageClass;
// 		
// 		this.nodeQualifier = nodeQualifier != null ? nodeQualifier : FrameworkUtil.getBundle(pageClass).getSymbolicName();
// 	}
// 
// 	@Override
// 	public void createPage() {
// 		try {
// 			setPage(this.pageClass.newInstance());
// 		} catch (InstantiationException|IllegalAccessException e) {
// 			e.printStackTrace();
// 		}
// 		
// 		if (getLabelImage() != null) {
// 			getPage().setImageDescriptor(getImageDescriptor());
// 		}
//         getPage().setTitle(getLabelText());
//         
//         ((PreferencePage)getPage()).setPreferenceStore(
//         		new ScopedPreferenceStore(InstanceScope.INSTANCE, this.nodeQualifier));
// 	}
// 
// 	public String getPath() {
// 		return path;
// 	}
// 	
// }


import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.preference.PreferenceManager;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.fipro.eclipse.migration.e4.service.preferences.ContributedPreferenceNode;
import org.fipro.eclipse.migration.e4.service.preferences.PrefMgr;
 
package org.fipro.eclipse.migration.e4.ui.handler;


public class PreferencesHandler {
	
	@Execute
	public void execute(Shell shell, @PrefMgr PreferenceManager manager) {
		PreferenceDialog dialog = new PreferenceDialog(shell, manager) {
			@Override
			protected TreeViewer createTreeViewer(Composite parent) {
				TreeViewer viewer = super.createTreeViewer(parent);
				
				viewer.setComparator(new ViewerComparator() {
					
					@Override
					public int category(Object element) {
						// this ensures that the General preferences page is always on top
						// while the other pages are ordered alphabetical
// Path: e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/ContributedPreferenceNode.java
// public class ContributedPreferenceNode extends PreferenceNode {
// 
// 	private final String path;
// 	private final String nodeQualifier;
// 	private final Class<? extends IPreferencePage> pageClass;
// 	
// 	public ContributedPreferenceNode(
// 			String id, String label, 
// 			ImageDescriptor imageDescriptor, Class<? extends IPreferencePage> pageClass,
// 			String path, String nodeQualifier) {
// 		
// 		super(id, label, imageDescriptor, pageClass.getName());
// 		this.path = path;
// 		this.pageClass = pageClass;
// 		
// 		this.nodeQualifier = nodeQualifier != null ? nodeQualifier : FrameworkUtil.getBundle(pageClass).getSymbolicName();
// 	}
// 
// 	@Override
// 	public void createPage() {
// 		try {
// 			setPage(this.pageClass.newInstance());
// 		} catch (InstantiationException|IllegalAccessException e) {
// 			e.printStackTrace();
// 		}
// 		
// 		if (getLabelImage() != null) {
// 			getPage().setImageDescriptor(getImageDescriptor());
// 		}
//         getPage().setTitle(getLabelText());
//         
//         ((PreferencePage)getPage()).setPreferenceStore(
//         		new ScopedPreferenceStore(InstanceScope.INSTANCE, this.nodeQualifier));
// 	}
// 
// 	public String getPath() {
// 		return path;
// 	}
// 	
// }


// Path: e4-based-application/org.fipro.eclipse.migration.e4.ui/src/org/fipro/eclipse/migration/e4/ui/handler/PreferencesHandler.java
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.jface.preference.PreferenceDialog;
import org.eclipse.jface.preference.PreferenceManager;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.fipro.eclipse.migration.e4.service.preferences.ContributedPreferenceNode;
import org.fipro.eclipse.migration.e4.service.preferences.PrefMgr;

 
package org.fipro.eclipse.migration.e4.ui.handler;


public class PreferencesHandler {
	
	@Execute
	public void execute(Shell shell, @PrefMgr PreferenceManager manager) {
		PreferenceDialog dialog = new PreferenceDialog(shell, manager) {
			@Override
			protected TreeViewer createTreeViewer(Composite parent) {
				TreeViewer viewer = super.createTreeViewer(parent);
				
				viewer.setComparator(new ViewerComparator() {
					
					@Override
					public int category(Object element) {
						// this ensures that the General preferences page is always on top
						// while the other pages are ordered alphabetical
						if (element instanceof ContributedPreferenceNode