Another exception in forms. Sample code included.

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Another exception in forms. Sample code included.

Postby Paul.Helster » Wed Jul 20, 2005 7:39 am

Here is another exception get. I stripped down the code to remove all dependancies to the application but I still get the same error. One this though is that at some pooint, it loaded fine. Is there a cache in designer that may cause a corrupted version to be used? How can I cleanup this cache if this is the case?

I include both the exception, and some smple code.

Code: Select all
!ENTRY com.swtdesigner 4 4 2005-07-20 11:34:15.52
!MESSAGE Designer internal error: null
!STACK 0
java.lang.NullPointerException
   at com.swtdesigner.model.util.ast.ASTNodeUtilities.findMostRecentAssignmentInBlock(ASTNodeUtilities.java:2096)
   at com.swtdesigner.model.util.ast.ASTNodeUtilities.access$0(ASTNodeUtilities.java:2091)
   at com.swtdesigner.model.util.ast.ASTNodeUtilities$10.endVisit(ASTNodeUtilities.java:2144)
   at org.eclipse.jdt.core.dom.MethodInvocation.accept0(MethodInvocation.java:246)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
   at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2497)
   at org.eclipse.jdt.core.dom.VariableDeclarationFragment.accept0(VariableDeclarationFragment.java:224)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
   at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2520)
   at org.eclipse.jdt.core.dom.VariableDeclarationStatement.accept0(VariableDeclarationStatement.java:272)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
   at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2520)
   at org.eclipse.jdt.core.dom.Block.accept0(Block.java:135)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
   at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2497)
   at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:501)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
   at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2520)
   at org.eclipse.jdt.core.dom.AnonymousClassDeclaration.accept0(AnonymousClassDeclaration.java:142)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
   at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2497)
   at org.eclipse.jdt.core.dom.ClassInstanceCreation.accept0(ClassInstanceCreation.java:334)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
   at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2520)
   at org.eclipse.jdt.core.dom.MethodInvocation.accept0(MethodInvocation.java:244)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
   at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2497)
   at org.eclipse.jdt.core.dom.ExpressionStatement.accept0(ExpressionStatement.java:143)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
   at com.swtdesigner.model.util.ast.ASTNodeUtilities.findMostRecentAssignmentInBlock(ASTNodeUtilities.java:2102)
   at com.swtdesigner.model.util.ast.ASTNodeUtilities.getMostRecentAssignment(ASTNodeUtilities.java:2080)
   at com.swtdesigner.model.JavaInfo.isRepresentedByNoCache(JavaInfo.java:3961)
   at com.swtdesigner.model.JavaInfo.isRepresentedBy(JavaInfo.java:3899)
   at com.swtdesigner.model.swt.layout.LayoutDataInfo$1.visit(LayoutDataInfo.java:58)
   at org.eclipse.jdt.core.dom.MethodInvocation.accept0(MethodInvocation.java:236)
   at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
   at com.swtdesigner.model.util.ast.ASTNodeList.accept(ASTNodeList.java:194)
   at com.swtdesigner.model.swt.layout.LayoutDataInfo.findParentSetLayoutDataInvocation(LayoutDataInfo.java:51)
   at com.swtdesigner.model.swt.layout.LayoutDataInfo.acceptAsParent(LayoutDataInfo.java:42)
   at com.swtdesigner.model.parser.JavaInfoParser.isParentAndChild(JavaInfoParser.java:825)
   at com.swtdesigner.model.parser.JavaInfoParser.findParentFor(JavaInfoParser.java:743)
   at com.swtdesigner.model.parser.JavaInfoParser.getRootNodes(JavaInfoParser.java:331)
   at com.swtdesigner.gef.DesignerEditor.parseCompilationUnit(DesignerEditor.java:966)
   at com.swtdesigner.gef.DesignerEditor.handleActivate(DesignerEditor.java:900)
   at com.swtdesigner.gef.DesignerEditor.handleActivate(DesignerEditor.java:866)
   at com.swtdesigner.editors.MultiPageEditor.showDesignEditor(MultiPageEditor.java:325)
   at com.swtdesigner.editors.MultiPageEditor$2.widgetSelected(MultiPageEditor.java:168)
   at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:90)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:867)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:852)
   at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:660)
   at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:3138)
   at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1922)
   at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:288)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
   at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3080)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2713)
   at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699)
   at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
   at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:367)
   at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
   at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103)
   at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
   at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
   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.core.launcher.Main.invokeFramework(Main.java:334)
   at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
   at org.eclipse.core.launcher.Main.run(Main.java:973)
   at org.eclipse.core.launcher.Main.main(Main.java:948)


Code: Select all
package testWidgets2;

import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Hyperlink;

public abstract class BaseSelector3 extends Composite {

  private CCombo combo;

  public abstract int launchEditor();
 
  public BaseSelector3(Composite parent, int style) {
    super(parent, style);
    FormToolkit toolkit = new FormToolkit(Display.getCurrent());
    toolkit.adapt(this);
    toolkit.paintBordersFor(this);
    final FormLayout formLayout = new FormLayout();
    formLayout.marginHeight = 1;
    setLayout(formLayout);

    combo = new CCombo(this, SWT.READ_ONLY | SWT.FLAT);
   
    final Hyperlink hyperlink = toolkit.createHyperlink(this, "edit", SWT.NONE);

    final FormData formData_1 = new FormData();
    formData_1.top = new FormAttachment(combo, 0, SWT.TOP);
    formData_1.right = new FormAttachment(100, 0);
    hyperlink.setLayoutData(formData_1);
    hyperlink.addHyperlinkListener(new HyperlinkAdapter() {
      public void linkActivated(HyperlinkEvent e) {
        int ret = launchEditor();
      }
    });

    final FormData formData = new FormData();
    formData.bottom = new FormAttachment(100, -1);
    formData.top = new FormAttachment(0, 1);
    formData.right = new FormAttachment(hyperlink, -5, SWT.LEFT);
    formData.left = new FormAttachment(0, 1);
    combo.setLayoutData(formData);
    toolkit.adapt(combo);
    combo.addSelectionListener(new SelectionListener() {
      public void widgetDefaultSelected(SelectionEvent e) {
      }
      public void widgetSelected(SelectionEvent e) {
        //fireModificationEvent();
      }
    });

    //
  }
 

  public void dispose() {
    super.dispose();
  }

  protected void checkSubclass() {
  }
}
Paul.Helster
 
Posts: 31
Joined: Fri Apr 15, 2005 6:03 am

Problem identified

Postby Paul.Helster » Wed Jul 20, 2005 7:46 am

I found the source of the problem: there is an abstract method in this abstract class. The assignement using this abstract method
Code: Select all
int ret = launchEditor();

causes designer to throw an exception.

If I comment out this line, it loads and renders fine.

I have many classes like this that are abstract. Is this supposed to be well supported or am I stretching it?
Paul.Helster
 
Posts: 31
Joined: Fri Apr 15, 2005 6:03 am

Postby Paul.Helster » Wed Jul 20, 2005 8:07 am

In fact, any call to an abstract method in a UI class causes the same exception.
Paul.Helster
 
Posts: 31
Joined: Fri Apr 15, 2005 6:03 am

Postby Eric Clayberg » Wed Jul 20, 2005 8:05 pm

Paul.Helster wrote:In fact, any call to an abstract method in a UI class causes the same exception.

Designer can't execute abstract code within a class being edited.

Rather than comment the code our, you can hide it from the parser with a code hiding tag.

Code: Select all
int ret = launchEditor(); //$hide$
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Postby Paul.Helster » Thu Jul 21, 2005 4:22 am

Code: Select all
int ret = launchEditor(); //$hide$


Thanks, this worked. Note that this exact code was not causing any problems in 4.0.1.
Paul.Helster
 
Posts: 31
Joined: Fri Apr 15, 2005 6:03 am

Postby Eric Clayberg » Thu Jul 21, 2005 5:53 am

Paul.Helster wrote:Thanks, this worked. Note that this exact code was not causing any problems in 4.0.1.

Major improvements have been made in Designer's ability to display dynamically computed values at design time. We can now parse and evaluate a much greater range of code than we could in the past.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to SWT Designer

Who is online

Users browsing this forum: No registered users and 1 guest