1 11 package org.eclipse.ui.internal; 12 13 import org.eclipse.swt.SWT; 14 import org.eclipse.swt.widgets.Table; 15 import org.eclipse.swt.widgets.TableItem; 16 import org.eclipse.ui.IEditorReference; 17 import org.eclipse.ui.IWorkbenchWindow; 18 19 22 public class CycleEditorAction extends CyclePartAction { 23 24 29 public CycleEditorAction(IWorkbenchWindow window, boolean forward) { 30 super(window, forward); 31 updateState(); 32 } 33 34 protected void setText() { 35 if (forward) { 37 setText(WorkbenchMessages.CycleEditorAction_next_text); 38 setToolTipText(WorkbenchMessages.CycleEditorAction_next_toolTip); 39 getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp(this, 41 IWorkbenchHelpContextIds.CYCLE_EDITOR_FORWARD_ACTION); 42 setActionDefinitionId("org.eclipse.ui.window.nextEditor"); } else { 44 setText(WorkbenchMessages.CycleEditorAction_prev_text); 45 setToolTipText(WorkbenchMessages.CycleEditorAction_prev_toolTip); 46 getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp(this, 48 IWorkbenchHelpContextIds.CYCLE_EDITOR_BACKWARD_ACTION); 49 setActionDefinitionId("org.eclipse.ui.window.previousEditor"); } 51 } 52 53 56 public void updateState() { 57 WorkbenchPage page = (WorkbenchPage) getActivePage(); 58 if (page == null) { 59 setEnabled(false); 60 return; 61 } 62 setEnabled(page.getSortedEditors().length >= 1); 64 } 65 66 69 protected void addItems(Table table, WorkbenchPage page) { 70 IEditorReference refs[] = page.getSortedEditors(); 71 for (int i = refs.length - 1; i >= 0; i--) { 72 TableItem item = null; 73 item = new TableItem(table, SWT.NONE); 74 if (refs[i].isDirty()) { 75 item.setText("*" + refs[i].getTitle()); } else { 77 item.setText(refs[i].getTitle()); 78 } 79 item.setImage(refs[i].getTitleImage()); 80 item.setData(refs[i]); 81 } 82 } 83 84 87 protected String getTableHeader() { 88 return WorkbenchMessages.CycleEditorAction_header; 89 } 90 } 91 | Popular Tags |