2017 bis heute 2016 2015 2014 | 2013 | 2012 | 2011 2010 2009 | 2008 | 2007

(ältere Archiveinträge vor 2007 nicht dargestellt, aber in der Suche enthalten)

Mailingliste - Einträge 2008

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [QF-Test] Problem with importing

  • Subject: Re: [QF-Test] Problem with importing
  • From: Gregor Schmid <Gregor.Schmid@?.de>
  • Date: 25 Feb 2008 15:23:44 +0100

Hello Shi,

the OSGI-based class loading and Jython's concept of where to find
classes don't go together well. QF-Test initializes Jython's class
loader based on the SWT class loader, so it can load those classes,
but it doesn't realize that, thus the import errors.

The best way to import a Java class in a Jython script in an
Eclipse/RCP based appilcations is to get hold of a ClassLoader that
can load it and use loadClass. E.g.

# get hold of any SWT component
shell = rc.getComponent("Workbench")
# get its ClassLoader
cl = shell.getClass().getClassLoader()
# use loadClass instead of import
Tree = cl.loadClass("org.eclipse.swt.widgets.Tree")

Best regards,

Shi Hoch <shi.hoch@?.com> writes:

> hi i'm using qfs to run tests on eclipse.
> i'm trying to add a java selectionListener to a tree running the
> commands on the SUT (either through the terminal or as script).
> running import org.eclipse.swt works.
> but running from org.eclipse.swt.events import * doesn't.
> for that matter running any import on org.eclipse.swt.* (i.e. events,
> widgets etc.) fails with "ImportError: No module named widgets".
> Using reflection a widgets.tree instance can be created but running:
> import import org.eclipse.swt.widgets.Tree
> results in ImportError: No module named widgets.
> running:
> from java.lang import *
> Package.getPackage("org.eclipse.swt.widgets")
> returns:
> package org.eclipse.swt.widgets
> why does the import fails? is it due to library definitions? how can it
> be changed?
> Thank you very much
> Shi

Gregor Schmid                                Gregor.Schmid@?.de
Quality First Software GmbH                     http://www.qfs.de
Tulpenstr. 41                                Tel: +49 8171 919870
DE-82538 Geretsried                          Fax: +49 8171 919876
GF: Gregor Schmid, Karlheinz Kellerer          HRB München 140833