1 11 package org.eclipse.ui.actions; 12 13 import org.eclipse.core.runtime.IAdaptable; 14 import org.eclipse.ui.IPerspectiveDescriptor; 15 import org.eclipse.ui.IWorkbenchWindow; 16 import org.eclipse.ui.WorkbenchException; 17 import org.eclipse.ui.internal.WorkbenchMessages; 18 import org.eclipse.ui.internal.misc.StatusUtil; 19 import org.eclipse.ui.statushandlers.StatusManager; 20 21 41 public class OpenNewPageMenu extends PerspectiveMenu { 42 private IAdaptable pageInput; 43 44 57 public OpenNewPageMenu(IWorkbenchWindow window) { 58 this(window, null); 59 } 60 61 68 public OpenNewPageMenu(IWorkbenchWindow window, IAdaptable input) { 69 super(window, "Open New Page Menu"); this.pageInput = input; 71 } 72 73 76 protected void run(IPerspectiveDescriptor desc) { 77 if (pageInput == null) { 79 StatusUtil.handleStatus( 80 WorkbenchMessages.OpenNewPageMenu_dialogTitle + ": " + WorkbenchMessages.OpenNewPageMenu_unknownPageInput, 82 StatusManager.SHOW); 83 return; 84 } 85 86 try { 88 getWindow().openPage(desc.getId(), pageInput); 89 } catch (WorkbenchException e) { 90 StatusUtil.handleStatus( 91 WorkbenchMessages.OpenNewPageMenu_dialogTitle + ": " + e.getMessage(), e, StatusManager.SHOW); 93 } 94 } 95 96 101 public void setPageInput(IAdaptable input) { 102 pageInput = input; 103 } 104 } 105 | Popular Tags |