Eclipse 3.0's Rich Client Platform
by Gene Sally


Listing One

public class CUserInterface {
    private Display m_display;
    public void go(String[] args) {
        m_display = new Display();
        Shell shell = new Shell(m_display);
        CAppDialog targetDialog = new CAppDialog(shell, null);
        // hopefully this will have a dispatch loop built in!
        targetDialog.setBlockOnOpen(true);
        targetDialog.open();
        m_display.dispose();
    }
    public static void main(String[] args) {
        CUserInterface userInterface = new CUserInterface();
        userInterface.go(args);
    }
}


Listing Two

ECLIPSE=/opt/eclipse/plugins
ECLIPSE_OS=linux
ECLIPSE_ARCH=x86
SWT=${ECLIPSE}/org.eclipse.swt.${ECLIPSE_WS}
                        _2.1.1/os/${ECLIPSE_OS}/${ECLIPSE_ARCH}
JDTCORE=${ECLIPSE}/org.eclipse.jdt.core_2.1.1/jdtcore.jar
WORKBENCH=${ECLIPSE}/org.eclipse.ui_2.1.1/workbench.jar
SWT2=${ECLIPSE}/org.eclipse.swt.${ECLIPSE_WS}
                       _2.1.1/ws/${ECLIPSE_WS}/swt.jar
LIBPATH=${ECLIPSE}/org.eclipse.swt.${ECLIPSE_WS}
                       _2.1.1/os/${ECLIPSE_OS}/${ECLIPSE_ARCH}
CLASSPATH=userinterface.jar;${SWT};${JDTCORE};${WORKBENCH};${SWT2}
ENTRYPOINT=CUserInterface

java -cp ${CLASSPATH} -Djava.library.path=${LIBPATH} ${ENTRYPOINT}

Listing Three

public class HelloWorldApplication implements IPlatformRunnable {
  public Object run(Object args) {
    Display helloDisplay = PlatformUI.createDisplay();
    WorkbenchAdvisor helloWorkbenchAdvisor = new HelloWorldWorkbenchAdvisor();
    try {
      int returnCode = PlatformUI.createAndRunWorkbench(helloDisplay,
                    helloWorkbenchAdvisor);
 ...
       }
    } finally {

      display.dispose();
    }
  }
}


Listing Four

public class HelloWorldWorkbenchAdvisor extends WorkbenchAdvisor {
    public String getInitialWindowPerspectiveId() {
        return "org.eclipse.ui.rcp.testapp.HelloWorldPerspective";
    }
    public void preWindowOpen(IWorkbenchWindowConfigurer configurer) {
        super.preWindowOpen(configurer);
        configurer.setInitialSize(new Point(500, 300));
        configurer.setTitle("Hello World");
    }
}

Listing Five

private void fillMenuBar(IWorkbenchWindow window, 
                                  IActionConfigurer configurer) {
    IMenuManager helpMenuBar = configurer.getmenuManager();
    helpMenuBar.add(createFileMenu(window));
    helpMenuBar.add(createViewMenu(window));
    // add more menus here, if necessary
}


Listing Six

public class HelloWorldPerspective implements IPerspectiveFactory {
    public HelloWorldPerspective() {
    }
    public void createInitialLayout(IPagelayout layout) {
        layout.setEditorAreaVisible(true);
        // creation of view class left as exercise for the reader
        layout.addView(...);
        layout....;
    }
}

Listing Seven

osgi.bundles = org.eclipse.core.runtime.start,
 org.eclipse.core.expressions, org.eclipse.help, \
  org.eclipse.jface, org.eclipse.osgi.services, org.eclipse.osgi, 
                            org.eclipse.swt, org.eclipse.swt.gtk, \
  org.eclipse.swt.carbon, org.eclipse.swt.gtk64, 
                     org.eclipse.swt.motif, org.eclipse.swt.photon,\
  org.eclipse.swt.win32, org.eclipse.ui.workbench, org.eclipse.ui, 
                            org.eclipse.ui.rcp.testapp.HelloWorld
eclipse.application = org.eclipse.ui.rcp.testapp.HelloWorld





2



