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.commands.ICommandService; 21 22 30 public class CycleEditorHandler extends CycleBaseHandler { 31 32 35 protected void addItems(Table table, WorkbenchPage page) { 36 IEditorReference refs[] = page.getSortedEditors(); 38 for (int i = refs.length - 1; i >= 0; i--) { 39 TableItem item = null; 40 item = new TableItem(table, SWT.NONE); 41 if (refs[i].isDirty()) { 42 item.setText("*" + refs[i].getTitle()); } else { 44 item.setText(refs[i].getTitle()); 45 } 46 item.setImage(refs[i].getTitleImage()); 47 item.setData(refs[i]); 48 } 49 } 50 51 54 protected ParameterizedCommand getBackwardCommand() { 55 final ICommandService commandService = (ICommandService) window.getWorkbench().getService(ICommandService.class); 56 final Command command = commandService.getCommand("org.eclipse.ui.window.previousEditor"); ParameterizedCommand commandBack = new ParameterizedCommand(command, null); 58 return commandBack; 59 } 60 61 64 protected ParameterizedCommand getForwardCommand() { 65 final ICommandService commandService = (ICommandService) window.getWorkbench().getService(ICommandService.class); 66 final Command command = commandService.getCommand("org.eclipse.ui.window.nextEditor"); ParameterizedCommand commandF = new ParameterizedCommand(command, null); 68 return commandF; 69 } 70 71 74 protected String getTableHeader() { 75 return WorkbenchMessages.CycleEditorAction_header; 77 } 78 79 } 80 | Popular Tags |