Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » eclipse forms example not working
eclipse forms example not working [message #62349] Tue, 10 May 2005 03:53 Go to next message
Eclipse UserFriend
Originally posted by: jtrentlyon.comptrak.com

Hello anyone,

i've created a plugin project and have been trying to get a view using an
eclipse scrollable form (ScrolledForm) to work but am having no luck.
i've attached the forms.jar as an external jar in the Java Build Path. My
code compiles, but when i try to open the view from the runtime workbench
i get a red error. The .log file in the
C:\eclipse\runtime-workbench-workspace\.metadata folder says:

java.lang.NoClassDefFoundError: org/eclipse/ui/forms/widgets/FormToolkit
at ScrollingFormViewer.createPartControl(ScrollingFormViewer.ja va:74)
at org.eclipse.ui.internal.PartPane$2.run(PartPane.java:137)
at
org.eclipse.core.internal.runtime.InternalPlatform.run(Inter nalPlatform.java:616)
at org.eclipse.core.runtime.Platform.run(Platform.java:747)
at org.eclipse.ui.internal.PartPane.createChildControl(PartPane .java:133)
.....

Any help would be greatly appreciated. btw, there seems to be little info
on the web on eclipse forms. I was using the 'Eclipse Forms Programming
Guide', but cant get past first base on it. Are there any other resources?

thanks for some help,

Jesse
Re: eclipse forms example not working [message #62372 is a reply to message #62349] Tue, 10 May 2005 04:16 Go to previous message
Eclipse UserFriend
Originally posted by: dangallery.seanet.com

hi jesse,

i had a similiar problem. i'm not sure why this works, but you need to
remove teh forms.jar from the java build path, and add the following line
into the requires section of your plugin.xml:

<import plugin="org.eclipse.ui.forms"/>

my complete requires section looks like this:

<requires>
<import plugin="org.eclipse.ui"/>
<import plugin="org.eclipse.core.runtime"/>
<import plugin="org.eclipse.ui.forms"/>
</requires>

i don't know why you cant attach the forms.jar as an external jar. the
code does compiles, so the compiler at least can find the library. why
cant the runtime workbench.

As far as resources, here is a crude sample scrolling form viewpart that i
wrote at one point. Hope you dont mind me pasting the wole thing in.
(note: it doesnt have a package reference becuz i created it in the
default package (under \src). It also has a main() method opening the
scrollable form so you can run it as a java app or in a runtime workbench.


import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.part.ViewPart;

public class ScrollingFormViewer extends ViewPart {

FormToolkit toolkit;
ScrolledForm scrollingForm;

public static void main (String [] args) {

FormToolkit toolkit;
ScrolledForm scrollingForm;

final Display display = new Display ();
Shell shell = new Shell(display);
shell.setLayout (new FillLayout());

toolkit = new FormToolkit(shell.getDisplay());
scrollingForm = toolkit.createScrolledForm(shell);
scrollingForm.setText("An eclipse Scrolling Form");

Composite body = scrollingForm.getBody();
GridLayout layout = new GridLayout();
body.setLayout(layout);

layout.numColumns = 4;
GridData gd = new GridData();
gd.horizontalSpan = 4;

Label label = toolkit.createLabel(body, "Text field label:");
Text text = toolkit.createText(body, "");
// text.setBackground()
text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
text.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);

Label label0;
for (int i=0;i<=100;i++) {
label0 = toolkit.createLabel(body, "Text field label "+i);
Text text2 = toolkit.createText(body, new Integer(i).toString());
text2.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
// toolkit.createText(body,
"nill").setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
}

toolkit.paintBordersFor(body);

// scrollingForm.setWeights(new int[] {30,40,30});

shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();

}

public void createPartControl(Composite parent) {

toolkit = new FormToolkit(parent.getDisplay());
scrollingForm = toolkit.createScrolledForm(parent);
scrollingForm.setText("An eclipse ScrolledForm, a scrolling form");

Composite body = scrollingForm.getBody();
GridLayout layout = new GridLayout();
body.setLayout(layout);

layout.numColumns = 2;
GridData gd = new GridData();
gd.horizontalSpan = 2;

Label label0;
for (int i=0;i<=100;i++) {
label0 = toolkit.createLabel(body, "Text field label "+i);
Text text2 = toolkit.createText(body, new Integer(i).toString());
text2.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
// toolkit.createText(body,
"nill").setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
}

Label label = toolkit.createLabel(body, "Text field label:");
Text text = toolkit.createText(body, "");
text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
text.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
toolkit.paintBordersFor(body);

}

public void setFocus() {
}

}

// end of code--------------------------------------------------


Hope that helps,
dan
Previous Topic:Newbie - How To Use Textbook Example Files In Eclipse
Next Topic:os x + eclipse 3.02 = no app icon or tabbing to it. HELP!
Goto Forum:
  


Current Time: Thu Nov 14 12:12:06 GMT 2024

Powered by FUDForum. Page generated in 0.07370 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top