Rich Clients: Wie schaff ich es ein Fenster einbinden?

montii

Mitglied
Hallo alle miteinander,

ich arbeite seit kurzen mit Eclipse3 und wollte eine Rcp Applikation erstellen. Das Grundgerüst ist mir auch klar. Angabe von Einsprungpunkten etc.Ich weis auch das man eine Perspektive und eine View erzeugen muss, aber ich hab nichtverstanden, wie ich es schaffe ein Fenster zu implementieren. Der Syntax einer ganz normalen SWT Anwendug ist mir auch klar.

Erst Display --> Shell --> eventuell Compusite --> GUI - Elemente.

Kann mir jemand einen Tip geben? Ich wäre sehr dankbar!

Gruß Micha

Quellcde:

RcpApplication.java
Code:
package de.micha.textEditor;

import org.eclipse.core.runtime.IPlatformRunnable;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.application.WorkbenchAdvisor;


public class RcpApplication implements IPlatformRunnable {
	public Object run(Object args){
		WorkbenchAdvisor workbenchAdvisor = new RcpWorkbenchAdvisor();
		Display display = PlatformUI.createDisplay();
		int returnCode =PlatformUI.createAndRunWorkbench(display, workbenchAdvisor);
		return (returnCode == PlatformUI.RETURN_RESTART)
							? IPlatformRunnable.EXIT_RESTART
							: IPlatformRunnable.EXIT_OK;
		
	}

}

RcpWorkbenchAdvisor.java

Code:
package de.micha.textEditor;

import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchAdvisor;
import org.eclipse.ui.intro.IIntroManager;


public class RcpWorkbenchAdvisor extends WorkbenchAdvisor {
	
	public String getInitialWindowPerspectiveId() {
		return "de.micha.textEditor.RcpPerspective";
	}
	
	public void preWindowOpen(IWorkbenchWindowConfigurer configurer){
		super.preWindowOpen(configurer);
		configurer.setShowCoolBar(false);
		configurer.setShowFastViewBars(false);
		configurer.setShowPerspectiveBar(false);
		configurer.setShowMenuBar(false);
	}
	
	public void postWindowOpen(IWorkbenchWindowConfigurer configurer){
		super.postWindowOpen(configurer);
		configurer.setTitle("TextEditor");
	}
	
	public void openIntro(IWorkbenchWindowConfigurer configurer){
		super.openIntro(configurer);
		IWorkbenchWindow window = configurer.getWindow();
		IWorkbench workbench = window.getWorkbench();
		IIntroManager manager = workbench.getIntroManager();
		manager.showIntro(window, false);
	}
	
}

RcpPerspective.java

Code:
package de.micha.textEditor;

import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;

public class RcpPerspective implements IPerspectiveFactory{
	
	public void createInitialLayout(IPageLayout layout){
		layout.setFixed(true);
		layout.addView("de.micha.textEditor.textEditorView",
						IPageLayout.LEFT, 1.0f,
						IPageLayout.ID_EDITOR_AREA);
		layout.setEditorAreaVisible(false);
	}

}

textEditorView.java

Ich denke hier sollte dann das Fenster aufgerufen werden.

plugin.xmp

Code:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin
   id="de.micha.textEditor"
   name="TextEditor Plug-in"
   version="1.0.0"
   provider-name="">

   <runtime>
      <library name="textEditor.jar">
         <export name="*"/>
      </library>
   </runtime>
   
   <requires>
      <import plugin="org.eclipse.core.runtime"/>
      <import plugin="org.eclipse.ui"/>
      <import plugin="org.eclipse.ui.forms"/>
   </requires>
   
   <extension
         id="RcpApplication"
         point="org.eclipse.core.runtime.applications">
      <application>
         <run class="de.micha.textEditor.RcpApplication"/>
      </application>
   </extension>
   
   <extension
         point="org.eclipse.ui.perspectives">
      <perspective
            class="de.micha.textEditor.RcpPerspective"
            name="TextEditor"
            id="de.micha.textEditor.RcpPerspective"/>
   </extension>
   
   <extension
         point="org.eclipse.ui.views">
      <view
            class="de.micha.textEditor.textEditorView"
            name="TextEditor"
            id="de.micha.textEditor.textEditorView"/>
   </extension>
   
   <extension
         id="product"
         point="org.eclipse.core.runtime.products">
      <product
            description="TextEditor von Michael Lehnert"
            name="TextEditor von Michael Lehnert"
            application="de.micha.textEditor.RcpApplication">
         <property value="TextEditor" name="appName"/>
         <property value="editor.gif" name="windowImage"/>
      </product>
   </extension>
   
   <extension
         point="org.eclipse.ui.intro">
      <intro
            class="de.micha.textEditor.textEditorIntro"
            id="de.micha.textEditor.intro"/>
      <introProductBinding
            introId="de.micha.textEditor.intro"
            productId="de.micha.textEditor.product"/>
   </extension>

</plugin>
 
Hallo,

hat wirklich keiner eine Idee?

Ich hab es jetzt erstmal so versucht:

Code:
package de.micha.textEditor;

import org.eclipse.swt.widgets.Shell;

public class textEditorView {
	
	public Shell shell;
		
	public textEditorView(){
		shell = new Shell(display);
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
	}
}

da Display schon in der Klasse RcpApplication deklariert wird.

Ich bekomme dann folgende Fehlermeldung:

Unhandled event loop exception
Reason:
Widget is disposed

Kann wirklich keiner helfen?

Gruß Micha
 
Zurück