1 11 12 package org.eclipse.ui.internal.registry; 13 14 import org.eclipse.core.commands.AbstractHandler; 15 import org.eclipse.core.commands.ExecutionEvent; 16 import org.eclipse.core.commands.ExecutionException; 17 import org.eclipse.core.runtime.IStatus; 18 import org.eclipse.ui.IWorkbenchPage; 19 import org.eclipse.ui.IWorkbenchWindow; 20 import org.eclipse.ui.PartInitException; 21 import org.eclipse.ui.handlers.HandlerUtil; 22 import org.eclipse.ui.internal.misc.StatusUtil; 23 import org.eclipse.ui.statushandlers.StatusManager; 24 25 30 public final class ShowViewHandler extends AbstractHandler { 31 32 36 private final String viewId; 37 38 45 public ShowViewHandler(final String viewId) { 46 this.viewId = viewId; 47 } 48 49 public final Object execute(final ExecutionEvent event) 50 throws ExecutionException { 51 final IWorkbenchWindow activeWorkbenchWindow = HandlerUtil 52 .getActiveWorkbenchWindowChecked(event); 53 54 final IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage(); 55 if (activePage == null) { 56 return null; 57 } 58 59 try { 60 activePage.showView(viewId); 61 } catch (PartInitException e) { 62 IStatus status = StatusUtil 63 .newStatus(e.getStatus(), e.getMessage()); 64 StatusManager.getManager().handle(status, StatusManager.SHOW); 65 } 66 67 return null; 68 } 69 } 70 | Popular Tags |