[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.rcp] Re: open file action ...

KarSc wrote:
Hi all



I would like to add to my RCP application, in the FILE menu, the "open file ..." menu item and hook it with the open action from the main view i have got .



I have done this for the SAVE action





From ActionBarAdvisor



saveAction = ActionFactory.SAVE.create(window);

        register(saveAction);





and managed to hook the real action from the view with the menu button ...



what shall I do for the OPEN FILE?



Thanks for any help

Kar




Hi, here's a sample. Hope it helps.. ;)

public class OpenAction extends Action{

	final IWorkbench workbench = YOURUIPlugin.getDefault().getWorkbench();

	public OpenAction(){
		super("Open", YOURUIPlugin.getImageDescriptor("/icons/open.png"));	
	}

	public void run(){
		final Shell shell = workbench.getActiveWorkbenchWindow().getShell();
		FileDialog dialog = new FileDialog(shell, SWT.OPEN);
		String path = dialog.open();
		if(!FileManager.getInstance().isOpen(path) && path != null){
			try{
				__Do what you want__
				
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}