use of org.eclipse.ui.actions.OpenFileAction in project sling by apache.
the class PackageExplorerOpenActionProvider method init.
@Override
public void init(ICommonActionExtensionSite site) {
super.init(site);
action = new OpenFileAction(getActivePage());
ICommonViewerWorkbenchSite workbenchSite = null;
if (site.getViewSite() instanceof ICommonViewerWorkbenchSite)
workbenchSite = (ICommonViewerWorkbenchSite) site.getViewSite();
if (workbenchSite != null) {
if (workbenchSite.getPart() != null && workbenchSite.getPart() instanceof IViewPart) {
IViewPart viewPart = (IViewPart) workbenchSite.getPart();
if (site.getStructuredViewer() instanceof TreeViewer) {
treeViewer = (TreeViewer) site.getStructuredViewer();
treeViewer.addSelectionChangedListener(action);
}
fInViewPart = true;
}
}
}
use of org.eclipse.ui.actions.OpenFileAction in project sling by apache.
the class PackageExplorerOpenActionProvider method fillActionBars.
@Override
public void fillActionBars(IActionBars actionBars) {
if (fInViewPart) {
ISelection selection = treeViewer.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection iss = (IStructuredSelection) selection;
if (iss.getFirstElement() instanceof JcrNode) {
final JcrNode node = (JcrNode) iss.getFirstElement();
final IFile file = node.getFileForEditor();
if (file != null) {
actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, new OpenFileAction(getActivePage()) {
@Override
public void run() {
try {
IDE.openEditor(getActivePage(), file, true);
} catch (PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
return;
}
}
// fOpenGroup.fillActionBars(actionBars);
//
// if (fOpenAndExpand == null && fOpenGroup.getOpenAction().isEnabled()) // TODO: is not updated!
// actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, fOpenGroup.getOpenAction());
// else if (fOpenAndExpand != null && fOpenAndExpand.isEnabled())
}
actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, action);
}
Aggregations