Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

E4/SWT/Running the demos

< E4

Historical Document: Flex+SWT is no longer supported

These instructions assume that you have already downloaded and installed the SWT ActionScript development tools. If you have not, please follow these directions before continuing.

The SWT port for Flex consists of the Adobe Flex environment (the ActionScript compiler), the SWT ActionScript development tools plugins (which provides the tools needed to build, launch and debug Java code in a Flash player) and the Eclipse target environment (the running plugins, the SWT port itself and example code). NOTE: That the both the tools and the port are in the pre-alpha stage. You are living on the bleeding edge. Good luck!

Setup Flex environment:

  1. Download and install the Adobe Open Source Flex SDK (available from http://opensource.adobe.com). NOTE: The path where you install the Flex SDK must contain no spaces. This is due to a bug in FCSH.
  2. Verify that your Flex install works by opening a command prompt, changing to the Flex SDK bin directory, typing "mxmlc" and hitting Enter. If you get a message like the following, you will need to add a JAVA_HOME environment variable that points to the home dir or edit the bin/jvm.config file in the Flex SDK.
  Error: could not find JRE
  Error: could not find Java 2 Runtime Environment.

Setup the Flex tools:

  1. Shut down the Eclipse build which has the SWT ActionScript tools installed. If you do not have an Eclipse build with the SWT ActionScript tools already installed, follow these directions before continuing.
  2. Update your eclipse.ini file and add another line at the end, -Dflex.sdk=<your path to the installed sdk> Note: Make sure you don't edit the command line (for example in a launch shortcut) as it overrides the .ini file and loses the Flex settings.
  3. Make sure that you are using at least a 1.5 JRE to run Eclipse as the ActionScript tools plugin requires it.
  4. Create a new Eclipse Workspace. NOTE: The path where you create the workspace must contain no spaces. This is due to a bug in FCSH.

Setup the Eclipse target environment

  1. Turn off auto build ('Project' -> 'Build Automatically')
  2. Download the SWT source zip from the latest download page (The zip is named org.eclipse.swt.e4.flex-incubation-I[timestamp].zip).
  3. Import this zip into your project ('File' -> 'Import' -> 'General' -> 'Existing Projects into Workspace' -> 'Select archive file').
  4. Add a new ActionScript VM. ('Window' -> 'Preferences' -> 'Java>Installed JREs').
    1. Click Add...
    2. Select ActionScript VM, click next.
    3. Click Directory... and browse to either your Firefox or IE install directory.
    4. Click OK.
    5. Click Finish

Get the demos

  1. Connect to dev.eclipse.org:/cvsroot/eclipse and browse to the e4 project. Check out the org.eclipse.e4.swt.releng project (located under the releng folder) into your workspace.
  2. Select the "e4.swt.as.demo.psf", right click and select Import Project Set... (If prompted for username:password, you should use anonymous:anonymous).
  3. Change the .classpath_flex to .classpath for the org.eclipse.swt.examples project. (Note that in order to see the classpath files, you have to either do this in the Navigator view or turn off the resources filter in the Packages Explorer by clicking on the drop down arrow menu in the top right hand corner of the package explorer, selecting Filters and unchecking *.resources).
  4. Turn on Build Automatically (You can watch the build progress in the ActionScript Build Console, available from the Console view)
  5. You can run any of the demos from org.eclipse.swt.e4.examples by clicking on them and Selecting "Run As>ActionScript Application". Note that for the Flickr example, you must select static linking in the launch configuration dialog.

Setup a sample SWT ActionScript project from scratch

 Note that this assumes you have gone through the steps above.
  1. Create a Java Project.
  2. Add the ActionScript nature to the project "Select Project>Popup Menu>Action Script Tools>Toggle Nature".
  3. Add the org.eclipse.swt project to the Java Build Path projects tab.
  4. Change the execution environment of the project JRE container to J2AS-1.5
  5. Add this class, save and Run as ActionScript Application
public class Main {
	public static void main(String[] args) {
		Display display = new Display();
		Shell shell = new Shell(display);
		shell.setLayout(new GridLayout(1, false));
		Button b = new Button(shell, SWT.PUSH);
		b.setText("Push");
		shell.pack();
		shell.open();
                //NOTE: no event loop for now
	}
}

Get the latest SWT source

  1. Create a workspace variable in Linked Resources preference page ('Preferences' -> 'Workspace' -> 'Linked Resources'). The variable should be called WORKSPACE and point to the root of your Eclipse workspace.
  2. Connect to dev.eclipse.org:/cvsroot/eclipse and browse to the e4 project. Check out the org.eclipse.e4.swt.releng project (located under the releng folder) into your workspace.
  3. Select the "e4.swt.as.source.psf", right click and select Import Project Set... (If prompted for username:password, you should use anonymous:anonymous).
  4. Change the .classpath_flex to .classpath for the "org.eclipse.swt" and "org.eclipse.swt.e4.jcl" projects. (Note that in order to see the classpath files, you have to either do this in the Navigator view or turn off the resources filter in the Packages Explorer by clicking on the drop down arrow menu in the top right hand corner of the package explorer, selecting Filters and unchecking *.resources).
  5. Replace the contents of the the .project file in the "org.eclipse.swt" project with the contents in the .project_e4 file.
  6. Refresh the workspace to pick up the links.
  7. Perform a clean on the workspace (Project>Clean...)

Deploy project to a server

  1. To deploy a project to a server, right click on the class in the project that contains main, and select Export>ActionScript>Deploy ActionScript Project.
  2. Click Next. If you have selected a class that contains a main in it, both the Project Name field and the Main tab field should be filled out. If not, you can either type in the name of your main class or click on the Search button to find all classes in your project that contain a main. Once both fields are filled out, click Next.
  3. Select the root directory of your server.
  4. Choose which options you want (static linking, crossdomain.xml and/or theme file) and click Finish. (Note: To use the crossdomain option, you must specify the URL where your crossdomain.xml resides. To use the theme option, you must specify the location of the CSS file).

Back to the top