// 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.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/PreferenceNodeContribution.java
// public class PreferenceNodeContribution {
// 
// 	private final List<ContributedPreferenceNode> nodes = new ArrayList<>();
// 
// 	public PreferenceNodeContribution(String id, String label, Class<? extends IPreferencePage> pageClass) {
// 		this(id, label, null, pageClass, null, null);
// 	}
// 
// 	public PreferenceNodeContribution(String id, String label, Class<? extends IPreferencePage> pageClass, String path) {
// 		this(id, label, null, pageClass, path, null);
// 	}
// 
// 	public PreferenceNodeContribution(String id, String label, Class<? extends IPreferencePage> pageClass, String path, String nodeQualifier) {
// 		this(id, label, null, pageClass, path, nodeQualifier);
// 	}
// 
// 	public PreferenceNodeContribution(
// 			String id, 
// 			String label, 
// 			ImageDescriptor imageDescriptor,
// 			Class<? extends IPreferencePage> pageClass, 
// 			String path,
// 			String nodeQualifier) {
// 		
// 		this.nodes.add(new ContributedPreferenceNode(id, label, imageDescriptor, pageClass, path, nodeQualifier));
// 	}
// 
// 	public List<ContributedPreferenceNode> getPreferenceNodes() {
// 		return this.nodes;
// 	}
// 
// 	public void addPreferenceNode(String id, String label, Class<? extends IPreferencePage> pageClass) {
// 		addPreferenceNode(id, label, null, pageClass, null, null);
// 	}
// 
// 	public void addPreferenceNode(String id, String label, Class<? extends IPreferencePage> pageClass, String path) {
// 		addPreferenceNode(id, label, null, pageClass, path, null);
// 	}
// 
// 	public void addPreferenceNode(String id, String label, Class<? extends IPreferencePage> pageClass, String path, String nodeQualifier) {
// 		addPreferenceNode(id, label, null, pageClass, path, nodeQualifier);
// 	}
// 	
// 	public void addPreferenceNode(
// 			String id, 
// 			String label, 
// 			ImageDescriptor imageDescriptor,
// 			Class<? extends IPreferencePage> pageClass, 
// 			String path,
// 			String nodeQualifier) {
// 		
// 		this.nodes.add(new ContributedPreferenceNode(id, label, imageDescriptor, pageClass, path, nodeQualifier));
// 	}
// }


import org.eclipse.e4.core.di.suppliers.ExtendedObjectSupplier;
import org.eclipse.e4.core.di.suppliers.IObjectDescriptor;
import org.eclipse.e4.core.di.suppliers.IRequestor;
import org.eclipse.jface.preference.PreferenceManager;
import org.fipro.eclipse.migration.e4.service.preferences.ContributedPreferenceNode;
import org.fipro.eclipse.migration.e4.service.preferences.PreferenceNodeContribution;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;
package org.fipro.eclipse.migration.e4.service.preferences.impl;


@SuppressWarnings("restriction")
@Component(
		service=ExtendedObjectSupplier.class,
		property="dependency.injection.annotation=org.fipro.eclipse.migration.e4.service.preferences.PrefMgr"
)
public class PreferenceManagerSupplier extends ExtendedObjectSupplier {

	PreferenceManager mgr;
	
	@Override
	public Object get(IObjectDescriptor descriptor, IRequestor requestor, boolean track, boolean group) {
		return getManager();
	}

	protected PreferenceManager getManager() {
		if (this.mgr == null) {
			this.mgr = new PreferenceManager();
		}
		return mgr;
	}
	
	@Reference(
			cardinality=ReferenceCardinality.MULTIPLE,
			policy=ReferencePolicy.DYNAMIC
	)
	synchronized void addPreferenceNode(PreferenceNodeContribution node) {
// 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.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/PreferenceNodeContribution.java
// public class PreferenceNodeContribution {
// 
// 	private final List<ContributedPreferenceNode> nodes = new ArrayList<>();
// 
// 	public PreferenceNodeContribution(String id, String label, Class<? extends IPreferencePage> pageClass) {
// 		this(id, label, null, pageClass, null, null);
// 	}
// 
// 	public PreferenceNodeContribution(String id, String label, Class<? extends IPreferencePage> pageClass, String path) {
// 		this(id, label, null, pageClass, path, null);
// 	}
// 
// 	public PreferenceNodeContribution(String id, String label, Class<? extends IPreferencePage> pageClass, String path, String nodeQualifier) {
// 		this(id, label, null, pageClass, path, nodeQualifier);
// 	}
// 
// 	public PreferenceNodeContribution(
// 			String id, 
// 			String label, 
// 			ImageDescriptor imageDescriptor,
// 			Class<? extends IPreferencePage> pageClass, 
// 			String path,
// 			String nodeQualifier) {
// 		
// 		this.nodes.add(new ContributedPreferenceNode(id, label, imageDescriptor, pageClass, path, nodeQualifier));
// 	}
// 
// 	public List<ContributedPreferenceNode> getPreferenceNodes() {
// 		return this.nodes;
// 	}
// 
// 	public void addPreferenceNode(String id, String label, Class<? extends IPreferencePage> pageClass) {
// 		addPreferenceNode(id, label, null, pageClass, null, null);
// 	}
// 
// 	public void addPreferenceNode(String id, String label, Class<? extends IPreferencePage> pageClass, String path) {
// 		addPreferenceNode(id, label, null, pageClass, path, null);
// 	}
// 
// 	public void addPreferenceNode(String id, String label, Class<? extends IPreferencePage> pageClass, String path, String nodeQualifier) {
// 		addPreferenceNode(id, label, null, pageClass, path, nodeQualifier);
// 	}
// 	
// 	public void addPreferenceNode(
// 			String id, 
// 			String label, 
// 			ImageDescriptor imageDescriptor,
// 			Class<? extends IPreferencePage> pageClass, 
// 			String path,
// 			String nodeQualifier) {
// 		
// 		this.nodes.add(new ContributedPreferenceNode(id, label, imageDescriptor, pageClass, path, nodeQualifier));
// 	}
// }


// Path: e4-based-application/org.fipro.eclipse.migration.e4.service.preferences/src/org/fipro/eclipse/migration/e4/service/preferences/impl/PreferenceManagerSupplier.java
import org.eclipse.e4.core.di.suppliers.ExtendedObjectSupplier;
import org.eclipse.e4.core.di.suppliers.IObjectDescriptor;
import org.eclipse.e4.core.di.suppliers.IRequestor;
import org.eclipse.jface.preference.PreferenceManager;
import org.fipro.eclipse.migration.e4.service.preferences.ContributedPreferenceNode;
import org.fipro.eclipse.migration.e4.service.preferences.PreferenceNodeContribution;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;

package org.fipro.eclipse.migration.e4.service.preferences.impl;


@SuppressWarnings("restriction")
@Component(
		service=ExtendedObjectSupplier.class,
		property="dependency.injection.annotation=org.fipro.eclipse.migration.e4.service.preferences.PrefMgr"
)
public class PreferenceManagerSupplier extends ExtendedObjectSupplier {

	PreferenceManager mgr;
	
	@Override
	public Object get(IObjectDescriptor descriptor, IRequestor requestor, boolean track, boolean group) {
		return getManager();
	}

	protected PreferenceManager getManager() {
		if (this.mgr == null) {
			this.mgr = new PreferenceManager();
		}
		return mgr;
	}
	
	@Reference(
			cardinality=ReferenceCardinality.MULTIPLE,
			policy=ReferencePolicy.DYNAMIC
	)
	synchronized void addPreferenceNode(PreferenceNodeContribution node) {
		for (ContributedPreferenceNode contribNode : node.getPreferenceNodes()) {