1 11 package org.eclipse.jdt.internal.debug.ui.console; 12 13 import org.eclipse.core.commands.AbstractHandler; 14 import org.eclipse.core.commands.ExecutionEvent; 15 import org.eclipse.core.commands.ExecutionException; 16 import org.eclipse.core.commands.IHandler; 17 import org.eclipse.jface.action.IToolBarManager; 18 import org.eclipse.ui.IWorkbench; 19 import org.eclipse.ui.PlatformUI; 20 import org.eclipse.ui.console.IConsole; 21 import org.eclipse.ui.console.IConsoleConstants; 22 import org.eclipse.ui.console.IConsolePageParticipant; 23 import org.eclipse.ui.console.actions.CloseConsoleAction; 24 import org.eclipse.ui.contexts.IContextActivation; 25 import org.eclipse.ui.contexts.IContextService; 26 import org.eclipse.ui.handlers.IHandlerActivation; 27 import org.eclipse.ui.handlers.IHandlerService; 28 import org.eclipse.ui.part.IPageBookViewPage; 29 30 33 public class JavaStackTracePageParticipant implements IConsolePageParticipant { 34 35 private CloseConsoleAction fCloseAction; 36 private FormatStackTraceActionDelegate fFormatAction; 37 private IHandlerActivation fHandlerActivation; 38 private IContextActivation fContextActivation; 39 40 43 public void init(IPageBookViewPage page, IConsole console) { 44 fCloseAction = new CloseConsoleAction(console); 45 46 IToolBarManager manager = page.getSite().getActionBars().getToolBarManager(); 47 manager.appendToGroup(IConsoleConstants.LAUNCH_GROUP, fCloseAction); 48 49 fFormatAction = new FormatStackTraceActionDelegate((JavaStackTraceConsole) console); 50 } 51 52 55 public void dispose() { 56 deactivated(); 57 } 58 59 62 public Object getAdapter(Class adapter) { 63 return null; 64 } 65 66 69 public void activated() { 70 IWorkbench workbench = PlatformUI.getWorkbench(); 72 IHandlerService handlerService = (IHandlerService) workbench.getAdapter(IHandlerService.class); 73 74 IHandler formatHandler = new AbstractHandler() { 75 public Object execute(ExecutionEvent event) throws ExecutionException { 76 fFormatAction.run(null); 77 return null; 78 } 79 }; 80 81 fHandlerActivation = handlerService.activateHandler("org.eclipse.jdt.ui.edit.text.java.format", formatHandler); 83 IContextService contextService = (IContextService) workbench.getAdapter(IContextService.class); 84 fContextActivation = contextService.activateContext("org.eclipse.jdt.ui.javaEditorScope"); } 86 87 90 public void deactivated() { 91 IWorkbench workbench = PlatformUI.getWorkbench(); 93 IHandlerService handlerService = (IHandlerService) workbench.getAdapter(IHandlerService.class); 94 handlerService.deactivateHandler(fHandlerActivation); 95 IContextService contextService = (IContextService) workbench.getAdapter(IContextService.class); 96 contextService.deactivateContext(fContextActivation); 97 } 98 99 } 100 | Popular Tags |