hi all.
this is what I want to do
I created a single Tableviewer in postContruction, and the user load the data from an external XML file via a menu command.
but when I try to load data via a method in the class, the recovered viewer is null (the method is called from a new instance of the class).
and I have a NullPointerException
I tried to make a class as singleton with anotation @Singleton, but i can't get existing instance (
it's the basic approach look like, but it's been two days that I'm trying to fix without success.
can someone help me by telling me how to proceed.
thanks in advance
My viepart class
@Singleton
public class MyViewPart {
private TableViewer viewer;
@PostConstruct
public void createControls(Composite parent)
viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL
| SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
{ // my code here }
public void loadData(filename)()
{
// my code here
}
}
My Menu commande handler
public class LoadDataHandler {
@Execute
public void execute() {
Shell shell = new Shell(Display.getDefault());
DirectoryDialog dialog = new DirectoryDialog(shell);
String fileSelected = dialog.open();
MyViewPart data = new MyViewPart();
data.loadData(fileSelected);
}
}
[Updated on: Mon, 27 May 2013 16:17]
Report message to a moderator