|
Re: File Browser in ViewPart or Editor? [message #550662 is a reply to message #550638] |
Wed, 04 August 2010 05:47 |
Shawn Spiars Messages: 22 Registered: July 2009 |
Junior Member |
|
|
ohanes.dadian@gmail.com wrote:
> I am implementing a file browser, in Eclipse RCP, using a TreeViewer.
> Would it be best to put it in an Editor or ViewPart. I ask because, I
> need to be able to pass the root path for the browser and do not know of
> a way to do so with a view. As views are not instantiated directly.
Editors are best when you want to edit something using the life-cycle of
clean, dirty, save. For your File Browser I would recommend using a
view. You can create a public method in your view and call it after
launching to initialize the TreeViewer. Here is an example:
private void openTreeView(String name, TreeNode root) {
IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();
try {
IViewPart part = page.showView(TreeView.ID, name,
IWorkbenchPage.VIEW_CREATE);
TreeView treeView = (TreeView)part;
treeView.initialize(name, root);
page.activate(part);
} catch (PartInitException e) {
logger.error("Error opening TreeView", e);
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.02035 seconds