Personal tools
You are here: Home Forum Office Integration Editor Plugin (NOA4e) Hello World in SWT/JFace - Was mach ich falsch ?

 • Hello World in SWT/JFace - Was mach ich falsch ?

Replies: 6   Views: 1051
Up one level

 • Hello World in SWT/JFace - Was mach ich falsch ?

Posted by jochenbergmann at 2009-05-18 10:58:22
Hi, ich habe das Hello World in SWT/JFace ausprobiert. Irgendwas mache ich falsch:

ag.ion.bion.officelayer.application.OfficeApplicationException: com/sun/star/lang/XEventListener
at ag.ion.bion.officelayer.internal.application.LocalOfficeApplication.openConnection(LocalOfficeApplication.java:161)
at ag.ion.bion.officelayer.internal.application.AbstractOfficeApplication.activate(AbstractOfficeApplication.java:117)
at ag.ion.bion.officelayer.internal.application.AbstractOfficeApplication.activate(AbstractOfficeApplication.java:140)
at noaapp.MainWindow.createContents(MainWindow.java:90)
at org.eclipse.jface.window.Window.create(Window.java:431)
at org.eclipse.jface.window.Window.open(Window.java:790)
at noaapp.MainWindow.main(MainWindow.java:57)
Caused by: java.lang.NoClassDefFoundError: com/sun/star/lang/XEventListener
at ag.ion.bion.officelayer.internal.application.LocalOfficeApplication.openConnection(LocalOfficeApplication.java:153)
... 6 more
Caused by: java.lang.ClassNotFoundException: com.sun.star.lang.XEventListener
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 7 more
ag.ion.bion.officelayer.application.OfficeApplicationException: Application is not active.
at ag.ion.bion.officelayer.internal.application.AbstractOfficeApplication.getDesktopService(AbstractOfficeApplication.java:220)
at noaapp.MainWindow.createContents(MainWindow.java:98)
at org.eclipse.jface.window.Window.create(Window.java:431)
at org.eclipse.jface.window.Window.open(Window.java:790)
at noaapp.MainWindow.main(MainWindow.java:57)
Caused by: ag.ion.bion.officelayer.application.OfficeApplicationException: Application is not active.
at ag.ion.bion.officelayer.internal.application.AbstractOfficeApplication.getDesktopService(AbstractOfficeApplication.java:210)
... 4 more
java.lang.NullPointerException
at noaapp.MainWindow.close(MainWindow.java:39)
at org.eclipse.jface.window.Window.handleShellCloseEvent(Window.java:741)
at org.eclipse.jface.window.Window$3.shellClosed(Window.java:687)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:92)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012)
at org.eclipse.swt.widgets.Decorations.closeWidget(Decorations.java:307)
at org.eclipse.swt.widgets.Decorations.WM_CLOSE(Decorations.java:1643)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3789)
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:337)
at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1576)
at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:1937)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4528)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2366)
at org.eclipse.swt.widgets.Shell.callWindowProc(Shell.java:477)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3877)
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:337)
at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1576)
at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:1937)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4528)
at org.eclipse.swt.internal.win32.OS.DefWindowProcW(Native Method)
at org.eclipse.swt.internal.win32.OS.DefWindowProc(OS.java:2366)
at org.eclipse.swt.widgets.Shell.callWindowProc(Shell.java:477)
at org.eclipse.swt.widgets.Control.windowProc(Control.java:3877)
at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:337)
at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1576)
at org.eclipse.swt.widgets.Shell.windowProc(Shell.java:1937)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:4528)
at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2371)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3420)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
at org.eclipse.jface.window.Window.open(Window.java:801)
at noaapp.MainWindow.main(MainWindow.java:57)
jochenbergmann Member
Posts: 4

 • Re: Hello World in SWT/JFace - Was mach ich falsch ?

Posted by Markus Krueger at 2009-05-18 11:01:43
Hallo,
das kann ich dir so nicht sagen. Attache mal den Code, dann prüfe ich das mal.
Gruß,
Markus
Markus Krueger Member
Posts: 507

 • Re: Hello World in SWT/JFace - Was mach ich falsch ?

Posted by jochenbergmann at 2009-05-18 11:21:51
Hallo,
also ich habe einfach das Beispiel(http://www.usegroup.de/software/noa/index.php/Hello_World_in_SWT/JFace) aus der Wiki ausprobiert. Am Ende kommt dann immer die Exception.

package noaapp;

import java.awt.BorderLayout;
import java.awt.Frame;
import java.util.HashMap;

import javax.swing.JPanel;

import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import ag.ion.bion.officelayer.application.IOfficeApplication;
import ag.ion.bion.officelayer.application.OfficeApplicationException;
import ag.ion.bion.officelayer.application.OfficeApplicationRuntime;
import ag.ion.bion.officelayer.desktop.GlobalCommands;
import ag.ion.bion.officelayer.desktop.IFrame;
import ag.ion.bion.officelayer.document.DocumentDescriptor;
import ag.ion.bion.officelayer.document.IDocument;
import ag.ion.bion.officelayer.text.ITextDocument;

public class MainWindow extends ApplicationWindow {
private IOfficeApplication officeApplication=null;
private ITextDocument textDocument=null;

public MainWindow(Shell arg0) {
super(arg0);
}

@Override
public boolean close() {
try {
textDocument.close();
officeApplication.deactivate();
} catch (OfficeApplicationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

return super.close();
}

/**
* @param args
*/
public static void main(String args) {
// TODO Auto-generated method stub
try {
MainWindow window = new MainWindow(null);
window.setBlockOnOpen(true);
window.open();
Display.getCurrent().dispose();
} catch (Exception e) {
e.printStackTrace();
}
}

protected Point getInitialSize() {
return new Point(500, 375);
}

protected Control createContents(Composite parent) {
Composite container = new Composite(parent, SWT.EMBEDDED);
try {
System.setProperty("sun.awt.noerasebackground", "true";);
} catch (NoSuchMethodError error) {
System.out.println("Background not erased";);
}
container.setLayout(new FillLayout());

final Frame frame = SWT_AWT.new_Frame(container);

final JPanel panel = new JPanel(new BorderLayout());
panel.setVisible(true);
frame.add(panel, BorderLayout.CENTER);
try {

HashMap<String, String> configuration = new HashMap<String, String>();
configuration.put(IOfficeApplication.APPLICATION_HOME_KEY, "C:\\Program Files\\OpenOffice.org 2.3";);
configuration.put(IOfficeApplication.APPLICATION_TYPE_KEY, IOfficeApplication.LOCAL_APPLICATION);
try {
officeApplication=OfficeApplicationRuntime.getApplication(configuration);
officeApplication.setConfiguration(configuration);
officeApplication.activate();

} catch (OfficeApplicationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


IFrame officeFrame = officeApplication.getDesktopService().constructNewOfficeFrame(panel);
// create a new document
IDocument document=officeApplication.getDocumentService().constructNewDocument(officeFrame, IDocument.WRITER, DocumentDescriptor.DEFAULT);
// alternatively, you can load an existing document by using
// IDocument document=officeApplication.getDocumentService().loadDocument(officeFrame,<url>;);

// add a close listener so that OOo.o can be cleanly shut down
textDocument=(ITextDocument) document;
textDocument.getTextService().getText().setText("This is a text content for a SWT example with NOA.";);

// build the frame
frame.validate();


// Now it is time to disable two commands in the frame
// This comes from snippet14
officeFrame.disableDispatch(GlobalCommands.CLOSE_DOCUMENT);
officeFrame.disableDispatch(GlobalCommands.QUIT_APPLICATION);
}
catch (Throwable throwable) {
throwable.printStackTrace();
}

//
return container;
}
private void createActions() {
}



}
jochenbergmann Member
Posts: 4

 • Re: Hello World in SWT/JFace - Was mach ich falsch ?

Posted by jochenbergmann at 2009-05-18 13:11:03
Application is not active. muss auf irgendwas hinweisen. Ich weiß nur nicht auf was ???:)
jochenbergmann Member
Posts: 4

 • Re: Hello World in SWT/JFace - Was mach ich falsch ?

Posted by Markus Krueger at 2009-05-19 10:55:04
Hi,

also der Code funktioniert tadellos! Ich glaube eher, dass du die Bibliotheken nicht alles eingebunden hast in deinem Projekt...
Kann das sein?

Gruß,
Markus
Markus Krueger Member
Posts: 507

 • Re: Hello World in SWT/JFace - Was mach ich falsch ?

Posted by jochenbergmann at 2009-05-19 21:52:13
Hallo,

also ich habe eingebunden:

1./eclipse/plugins/org.eclipse.swt.win32.win32.x86_3.4.1.v3452b.jar
2. /eclipse/plugins/org.eclipse.jface_3.4.2.M20090107-0800.jar
3. /eclipse/plugins/org.eclipse.osgi_3.4.3.R34x_v20081215-1030.jar
4. /eclipse/plugins/org.eclipse.core.commands_3.4.0.I20080509-2000.jar
5. /eclipse/plugins/org.eclipse.equinox.common_3.4.0.v20080421-2006.jar

und alle (add all NOA JARs in the lib directory to your list of external JARs) die 10 Stück, die mit ag.ion. anfangen.

Habe ich da was vergessen ?
jochenbergmann Member
Posts: 4

 • Re: Hello World in SWT/JFace - Was mach ich falsch ?

Posted by Markus Krueger at 2009-05-20 09:51:34
Hier der auszug aus meiner Meta-Inf:

Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
ag.ion.noa;bundle-version="2.2.0",
Markus Krueger Member
Posts: 507

Powered by Plone, the Open Source Content Management System

This site conforms to the following standards: