Unterschiede
Hier werden die Unterschiede zwischen der gewählten und der aktuellen Version gezeigt.
eclipse-rcp:editor-open 2008/06/25 11:09 | eclipse-rcp:editor-open 2020/01/22 20:59 aktuell | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | [[eclipse-rcp|Java - Eclipse-RCP]]\\ | ||
====== Editor öffnen ====== | ====== Editor öffnen ====== | ||
Im folgenden Beispiel wird ein Editor geöffnet.\\ | Im folgenden Beispiel wird ein Editor geöffnet.\\ | ||
Dies erfolgt in einem seperatem Thread, damit das GUI während des Öffnens nicht "einfriert".\\ | 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.\\ | Die Methode openEditor(..) muss natürlich nicht zwangsläufig innerhalb des Editors sein.\\ | ||
- | Der Editor muss natürlich in den Extensions innerhalb der Manifest-Datei unter //org.eclipse.ui.editors// registriert sein (Minimal //id// und //class//; empfehlenswert sind auch //name// und //icon//, welche Beide natürlich frei wählbar sind).\\ | + | \\ |
+ | <html> | ||
+ | <script type="text/javascript"><!-- | ||
+ | google_ad_client="pub-9681858985507948"; | ||
+ | google_ad_width = 468; | ||
+ | google_ad_height = 60; | ||
+ | google_ad_format = "468x60_as"; | ||
+ | google_ad_type = "text"; | ||
+ | google_ad_channel = ""; | ||
+ | google_color_border = "cccccc"; | ||
+ | google_color_bg = "FFFFFF"; | ||
+ | google_color_link = "1d2d8c"; | ||
+ | google_color_text = "000000"; | ||
+ | google_color_url = "1d2d8c"; | ||
+ | //--> | ||
+ | </script> | ||
+ | <script type="text/javascript" | ||
+ | src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> | ||
+ | </script> | ||
+ | </html> | ||
+ | \\ | ||
+ | \\ | ||
+ | Der Editor muss in den Extensions innerhalb der plugin.xml unter dem Extension Point //org.eclipse.ui.editors// registriert sein (dazu PDE-Editor verwenden; Aufruf erfolgt duch Öffnen der MANIFEST.MF-Datei).\\ | ||
+ | Minimal müssen //id// (hier: //com.sowas.javawiki.MyEditor//) und //class// (hier: //com.sowas.javawiki.MyEditor//) angegeben werden; empfehlenswert sind auch //name// und //icon//, welche Beide natürlich frei wählbar sind).\\ | ||
<code java> | <code java> | ||
+ | package com.sowas.javawiki; | ||
+ | ... | ||
public class MyEditor extends FormEditor implements IMyEditor { | public class MyEditor extends FormEditor implements IMyEditor { | ||
public static final String ID = "com.sowas.javawiki.MyEditor"; | public static final String ID = "com.sowas.javawiki.MyEditor"; | ||
Zeile 10: | Zeile 36: | ||
... | ... | ||
- | public static IEditorPart openEditor(Object myDataObject) { | + | public static IEditorPart openEditor(final Object myDataObject) { |
final IWorkbenchPage wbp = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); | final IWorkbenchPage wbp = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); | ||
final MutableObject response = new MutableObject(); | final MutableObject response = new MutableObject(); | ||
- | SafeRunner.run(new SafeRunnable() { | + | Display.getCurrent().asyncExec(new Runnable() { |
- | public void run() throws Exception { | + | public void run() { |
final IMyEditorInput input = new MyEditorInput(myDataObject); | final IMyEditorInput input = new MyEditorInput(myDataObject); | ||
final IEditorPart editor = wbp.openEditor(input, MyEditor.ID); | final IEditorPart editor = wbp.openEditor(input, MyEditor.ID); | ||
Zeile 22: | Zeile 48: | ||
IEditorPart editorPart = (IEditorPart) response.getValue(); | IEditorPart editorPart = (IEditorPart) response.getValue(); | ||
return editorPart; | return editorPart; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | class MutableObject { | ||
+ | private Object obj = null; | ||
+ | |||
+ | public Object getObj(){ | ||
+ | return obj; | ||
+ | } | ||
+ | |||
+ | public void setObj(Object obj){ | ||
+ | this.obj = obj; | ||
} | } | ||
} | } |