这段时间我在做一个用到SWT的项目,第一次接触. 我想建立一个table view,table中的数据已经在数据库中建立了, model层也做好了. 不过我在建立UI层中出现了问题, 我有以下的一个异常 org.eclipse.ui.PartInitException: Could not create view. And I tag the code below:在 detail composit, 我建立了一个openTISComponent(),代码如下。/**
 * Action call - Opens TIS.
 * Function to change....
 * @param unitUnderTest
 *            UnitUnderTest
 */
private void openTISComponent() {
    final Tis tis = new Tis(); 
    final BigDecimal selectedEdrId = tis.getId();    final IWorkbench wb = PlatformUI.getWorkbench();
    final IWorkbenchWindow window = wb.getActiveWorkbenchWindow();    new TISTableViewPart(true, selectedEdrId, tis);
    try {
        window.getActivePage().showView(TISTableViewPart.ID);
    } catch (final PartInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }  
    }
然后在TISTableViewPart, 我写了一些方法去建立一个新的view:public class TISTableViewPart
    extends AbstractTableViewPart implements IContribution {public static final String ID =
        "de.conti.ip3.edr.main.gui.views.table.TISTableViewPart";
public static final DecimalFormat DF = new DecimalFormat("000000");
public static String versionName;
public static BigDecimal selectedEDRId;
private String objectUniqueIdentifier;
public static Tis tisComponent;
public static JEdrTIS tisEdr;public TISTableViewPart() {}/**
 * Constructor, taking as parameter.
 * @param template1
 *            boolean
 * @param selectedEdrId
 *            BigDecimal
 */
public TISTableViewPart(final boolean template1,
        final BigDecimal selectedEdrId,
        final Tis tis) {
    selectedObjectId = selectedEdrId;
    selectedEDRId = selectedEdrId; 
}@Override
public void addHelpToTableViewerPart() {
    // TODO Auto-generated method stub}/**
 * Instantiation of local composite.
 * @param parent
 *            Composite
 */
@Override
protected final void instantiateLocalComposite(final Composite parent) {    localComposite = new ComponentTableCompositeForTis(parent,SWT.NONE,true);}/**
 * Contribution class.
 * @param activePage
 *            IWorkbenchPage
 */
@Override
public final void contribute(final IWorkbenchPage activePage) {
    try {        activePage.showView(TISTableViewPart.ID);        activePage.setEditorAreaVisible(false);    } catch (final PartInitException ep) {
        ep.printStackTrace();
        MessageDialog.openError(activePage.getWorkbenchWindow().getShell(),
                "Error", "Error opening TIS view");
    }}
我把exeption trace贴在这里:org.eclipse.ui.PartInitException: Could not create view: de.conti.ip3.edr.main.gui.views.table.TISTableViewPart
at org.eclipse.ui.internal.ViewFactory.createView(ViewFactory.java:158)
at org.eclipse.ui.internal.Perspective.showView(Perspective.java:2244)
at org.eclipse.ui.internal.WorkbenchPage.busyShowView(WorkbenchPage.java:1071)
at org.eclipse.ui.internal.WorkbenchPage$20.run(WorkbenchPage.java:3822)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchPage.showView(WorkbenchPage.java:3819)
at org.eclipse.ui.internal.WorkbenchPage.showView(WorkbenchPage.java:3795)
at de.conti.ip3.edr.main.gui.detailsComposite.SupersetUUTDetailsComposite.openTISComponent(SupersetUUTDetailsComposite.java:1236)
at de.conti.ip3.edr.main.gui.detailsComposite.SupersetUUTDetailsComposite.access$11(SupersetUUTDetailsComposite.java:1227)
at de.conti.ip3.edr.main.gui.detailsComposite.SupersetUUTDetailsComposite$18.run(SupersetUUTDetailsComposite.java:1060)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at de.conti.ip3.main.Application.start(Application.java:56)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
麻烦大家帮帮我呀,这个问题困扰了我好久了,要不然以后的没法做了,谢谢啦
swtjfacejava