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 40 public class OpenNewWindowMenu extends PerspectiveMenu { 41 private IAdaptable pageInput; 42 43 56 public OpenNewWindowMenu(IWorkbenchWindow window) { 57 this(window, null); 58 } 59 60 67 public OpenNewWindowMenu(IWorkbenchWindow window, IAdaptable input) { 68 super(window, "Open New Page Menu"); this.pageInput = input; 70 } 71 72 75 protected void run(IPerspectiveDescriptor desc) { 76 if (pageInput == null) { 78 StatusUtil.handleStatus( 79 WorkbenchMessages.OpenNewWindowMenu_dialogTitle + ": " + WorkbenchMessages.OpenNewWindowMenu_unknownInput, 81 StatusManager.SHOW); 82 return; 83 } 84 85 try { 87 getWindow().getWorkbench().openWorkbenchWindow(desc.getId(), 88 pageInput); 89 } catch (WorkbenchException e) { 90 StatusUtil.handleStatus( 91 WorkbenchMessages.OpenNewWindowMenu_dialogTitle + ": " + e.getMessage(), e, StatusManager.SHOW); 93 } 94 } 95 96 101 public void setPageInput(IAdaptable input) { 102 pageInput = input; 103 } 104 } 105 | Popular Tags |