1 11 12 package org.eclipse.ui.internal; 13 14 import org.eclipse.core.commands.Command; 15 import org.eclipse.core.commands.ParameterizedCommand; 16 import org.eclipse.swt.SWT; 17 import org.eclipse.swt.widgets.Table; 18 import org.eclipse.swt.widgets.TableItem; 19 import org.eclipse.ui.IEditorReference; 20 import org.eclipse.ui.IWorkbenchPartReference; 21 import org.eclipse.ui.commands.ICommandService; 22 23 32 public class CycleViewHandler extends CycleBaseHandler { 33 34 37 protected void addItems(Table table, WorkbenchPage page) { 38 IWorkbenchPartReference refs[] = page.getSortedParts(); 40 boolean includeEditor = true; 41 42 for (int i = refs.length - 1; i >= 0; i--) { 43 if (refs[i] instanceof IEditorReference) { 44 if (includeEditor) { 45 IEditorReference activeEditor = (IEditorReference) refs[i]; 46 TableItem item = new TableItem(table, SWT.NONE); 47 item.setText(WorkbenchMessages.CyclePartAction_editor); 48 item.setImage(activeEditor.getTitleImage()); 49 item.setData(activeEditor); 50 includeEditor = false; 51 } 52 } else { 53 TableItem item = new TableItem(table, SWT.NONE); 54 item.setText(refs[i].getTitle()); 55 item.setImage(refs[i].getTitleImage()); 56 item.setData(refs[i]); 57 } 58 } 59 } 60 61 64 protected ParameterizedCommand getBackwardCommand() { 65 final ICommandService commandService = (ICommandService) window.getWorkbench().getService(ICommandService.class); 67 final Command command = commandService.getCommand("org.eclipse.ui.window.previousView"); ParameterizedCommand commandBack = new ParameterizedCommand(command, null); 69 return commandBack; 70 } 71 72 75 protected ParameterizedCommand getForwardCommand() { 76 final ICommandService commandService = (ICommandService) window.getWorkbench().getService(ICommandService.class); 78 final Command command = commandService.getCommand("org.eclipse.ui.window.nextView"); ParameterizedCommand commandF = new ParameterizedCommand(command, null); 80 return commandF; 81 } 82 83 86 protected String getTableHeader() { 87 return WorkbenchMessages.CyclePartAction_header; 89 } 90 91 } 92 | Popular Tags |