Dies ist eine alte Version des Dokuments!
Editor öffnen
Im folgenden Beispiel wird ein Editor geöffnet.
Dies erfolgt in einem seperatem Thread, damit das GUI während des Öffnens nicht „einfriert“.
Die Methode openEditor(..) muss natürlich nicht zwangsläufig innerhalb des Editors sein.
public class MyEditor extends FormEditor implements IMyEditor { public static final String ID = "com.sowas.javawiki.MyEditor"; ... public static IEditorPart openEditor(Object myDataObject) { final IWorkbenchPage wbp = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); final MutableObject response = new MutableObject(); SafeRunner.run(new SafeRunnable() { public void run() throws Exception { final IMyEditorInput input = new MyEditorInput(myDataObject); final IEditorPart editor = wbp.openEditor(input, MyEditor.ID); response.setValue(editor); } }); IEditorPart editorPart = (IEditorPart) response.getValue(); return editorPart; } }
MyEditorInput muss wie folgt aufgebaut sein:
public class MyEditorInput extends PlatformObject implements IMyEditorInput { ... } public interface IMyEditorInput extends IEditorInput { ... }