Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] gtk port

Hi Havoc,

The SWT team uses Eclipse the same way that James mentioned below, but 
with one extra step required after step 2.
You may have discovered this already, but just in case you haven't, I 
thought I'd better mention it.

All Java projects in Eclipse need to have a .classpath file.
Because SWT is multi-platform, we do not ship a .classpath file.
Instead, we ship several files that have a ".classpath_" prefix.
When you first load the org.eclipse.swt project it will not have a 
.classpath, and there will be many errors.
(So many, that I usually turn off the "auto-build" feature in 
Window->Preferences until after I have set up the .classpath).

To set the correct .classpath for Motif, you need to copy the file named 
".classpath_motif" to ".classpath".
If you are new to Eclipse this step can be frustrating because by default 
you can't see files that start with "." in the Packages view. To see them, 
you have to go to the "view menu" (the little triangle in the top right 
corner of the view), select Filters... and then uncheck ".*".

After you do this once, all should be well, and you should compile 
cleanly. If you turned off autobuild, it is safe to turn it back on now. 
:)

One more thing I'd like to mention. If you want to test some SWT changes 
you have made, the simplest thing to do is create your own Java project to 
put test code in, and write a small stand-alone SWT test class. (I will 
paste an example to the end of this email). You don't actually need to 
launch a run-time Eclipse workbench to test SWT changes until after your 
simple test class is working properly. In order to run these SWT 
stand-alone tests, you need to copy ws/motif/libswt-linux-20xx.so  to your 
jre/bin directory so the VM can find it. To run the class, select it in 
the Packages view or Hierarchy view, and click on the "Running Man" tool 
in the toolbar.

I hope this info helps.
Carolyn

James Moody <James_Moody@xxxxxxx> writes:
The steps we use on the VCM team are (SWT team members can correct if 
their setup differs):

1. Start Eclipse workbench.
2. Add the projects you want to hack on to the workspace using the 
repositories view
        and anonymous CVS.
3. Change code, implement new features, etc.
4. Select the project, Properties->Launcher. Select "Run-time Workbench". 
You only have
to do this step once.
5. Select the project and hit the running man icon in the Java 
perspective.


Here's a little test class to look at the selection event in an SWT List:

package test;

import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.events.*;

public class ListTest {
        static Display display;
        static Shell shell;
        static List list;
 
        public static void main(String[] args) {
                display = new Display();
                shell = new Shell(display);
                shell.setLayout(new GridLayout());
                shell.setText("Multi-Select List Test");
 
                list = new List(shell, SWT.MULTI);
                list.setLayoutData(new GridData(GridData.FILL_BOTH));
                for (int i = 0; i < 5; i++) {
                        list.add("item" + i);
                }

                list.addSelectionListener(new SelectionAdapter() {
                        public void widgetSelected(SelectionEvent e) {
                                System.out.println("Selected e.item=" + e.item);
                        };
                        public void widgetDefaultSelected(SelectionEvent e) {
                                System.out.println("DefaultSelected e.item=" + e.item);
                        };
                });

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



Back to the top