blob: 5741cd7e52b018e4a8e7e3ea26d88c0ca7044bfc [file] [log] [blame]
package org.eclipse.wst.wsdl.ui.internal.asd.util;
import org.eclipse.gef.EditPartFactory;
import org.eclipse.gef.GraphicalViewer;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.wst.wsdl.ui.internal.asd.design.DesignViewGraphicalViewer;
import org.eclipse.wst.wsdl.ui.internal.asd.design.editparts.ASDEditPartFactory;
public class ASDEditPartFactoryHelper {
private static ASDEditPartFactoryHelper instance;
private EditPartFactory editPartFactory;
public static ASDEditPartFactoryHelper getInstance() {
if (instance == null) {
instance = new ASDEditPartFactoryHelper();
}
return instance;
}
public EditPartFactory getEditPartFactory() {
if (editPartFactory == null) {
editPartFactory = new ASDEditPartFactory();
}
return editPartFactory;
}
public void setEditPartFactory(EditPartFactory factory) {
editPartFactory = factory;
IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
Object adapter = editor.getAdapter(GraphicalViewer.class);
if (adapter instanceof DesignViewGraphicalViewer) {
((DesignViewGraphicalViewer) adapter).setEditPartFactory(factory);
}
}
}