Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » singleton part (make Editor as singleton )
singleton part [message #1060685] Mon, 27 May 2013 15:22
AIT YAHIA Idir is currently offline AIT YAHIA Idir
Messages: 2
Registered: April 2013
Junior Member
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

Previous Topic:Eclipse 4.2 (Helios) taking long time to open in Fedora 18
Goto Forum:
  


Current Time: Mon May 27 22:49:50 EDT 2013

Powered by FUDForum. Page generated in 0.02519 seconds