Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » Problem with calling an external class from AbstractHandler
Problem with calling an external class from AbstractHandler [message #1007358] Tue, 05 February 2013 10:44 Go to previous message
birt user is currently offline birt user
Messages: 17
Registered: January 2013
Junior Member
I have an eclipse application with two classes:

import org.eclipse.ui.PlatformUI;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.SWT;

public class A extends org.eclipse.core.commands.AbstractHandler {

	public Object execute(ExecutionEvent event) throws ExecutionException {
		
		Listener buttonListener = new Listener() {
        	public void handleEvent(Event event) {
				// from inside handleEvent, I am unable to make any call to class B
				try {
					System.err.pritnln("constructor scenario");
					B myB = new B();

					System.err.println("non-static scenario");
					myB.nonStaticTest();

					System.err.println("static scenario");
					B.staticTest();
                                        System.err.println("end of static scenario");
				} catch (Exception e) {
					System.err.println("caught an exception");
				} finally {
					System.err.println("finally");
				}
			}
		};
                
                Display display = PlatformUI.getWorkbench().getDisplay();
                final Shell shell = new Shell(display, SWT.TITLE | SWT.MIN | SWT.CLOSE);
                Button myButton = new Button(shell, SWT.PUSH);
                myButton.addListener(SWT.Selection, buttonListener);
	}	
}

public class B {

public B() {
	System.err.println("constructor");
}

public static void staticTest() {
	System.err.println("static test");
}

public void nonStaticTest() {
	System.err.println("non-static test");
}

}


When I run the code as shown above, I get the following output:

constructor scenario
finally


I then commented out the constructor and non-static scenarios and ran the code. The output became:

static scenario
finally


I don't understand why eclipse won't execute the code in class B. Class A and class B are located in different .java files in the same package. No exception is ever thrown and the first line in each method is a print statement.

Does anyone have any ideas about why I can't call class B? I did try running a Project....Clean to do a clean build in eclipse, but it didn't help.
 
Read Message
Read Message
Read Message
Read Message
Previous Topic:Update site build replacing qualifier
Next Topic:Custom toolchain problem: Info: Nothing to build for
Goto Forum:
  


Current Time: Sat May 18 09:54:58 EDT 2013

Powered by FUDForum. Page generated in 0.02262 seconds