Hi, I'm (very) new to RCP applications - so please bear with me.
I've got an application with three views in it. One of the views
contains a TreeView with a directory structure in it, another one
contains a TableViewer listing the contents of the current directory. At
the moment I'm registering a DoubleClickListener with the TreeViewer
itself, and calling a static method that invokes the action itself:
----------
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection sel = (IStructuredSelection) event
.getSelection();
selectedNode = (FolderNode) sel.getFirstElement();
System.out.println(selectedNode.getName());
IWorkbenchWindow window = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow();
UpdateCollectionViewAction.run(window);
}
});
----------
Here's the static method.
----------
public static void run(IWorkbenchWindow window) {
IWorkbenchPage page = window.getActivePage();
collectionView = (CollectionView) page.findView(CollectionView.ID);
collectionTable = collectionView.getViewer();
navView = (NavigationView) page.findView(NavigationView.ID);
folder = navView.getSelectedNode();
DocumentList.getInstance().clearDocumentList();
File parentFolder = folder.getFile();
File[] folderContent = parentFolder.listFiles();
for (int i = 1; i < folderContent.length; i++) {
if (folderContent[i].isFile()) {
Document document = new Document(folderContent[i].getName(),
folderContent[i].getAbsolutePath());
DocumentList.getInstance().addDocument(document);
}
}
collectionTable.refresh();
}
----------
This works, but it feels very, very dirty. Is there a more elegant way
of doing this?