1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
public class OpenViewAction extends Action {
private final IWorkbenchWindow window;
private int instanceNum = 0;
private final String viewId;
public OpenViewAction(IWorkbenchWindow window, String label, String viewId) {
this.window = window;
this.viewId = viewId;
setText(label);
setId(ICommandIds.CMD_OPEN);
setActionDefinitionId(ICommandIds.CMD_OPEN);
setImageDescriptor(simpleexplorer.Activator.getImageDescriptor("/icons/sample2.gif"));
}
public void run() {
if(window != null) {
try {
window.getActivePage().showView(viewId, Integer.toString(instanceNum++), IWorkbenchPage.VIEW_ACTIVATE);
} catch (PartInitException e) {
MessageDialog.openError(window.getShell(), "Error", "Error opening view:" + e.getMessage());
}
}
}
} |