1 11 package org.eclipse.compare; 12 13 import java.util.ResourceBundle ; 14 import org.eclipse.jface.action.Action; 15 import org.eclipse.jface.dialogs.MessageDialog; 16 import org.eclipse.swt.widgets.Display; 17 import org.eclipse.swt.widgets.Shell; 18 19 import org.eclipse.compare.internal.CompareMessages; 20 import org.eclipse.compare.internal.CompareUIPlugin; 21 import org.eclipse.compare.internal.Utilities; 22 23 24 32 public class NavigationAction extends Action { 33 34 private boolean fNext; 35 private CompareEditorInput fCompareEditorInput; 36 37 38 43 public NavigationAction(boolean next) { 44 this(CompareUI.getResourceBundle(), next); 45 } 46 47 54 public NavigationAction(ResourceBundle bundle, boolean next) { 55 Utilities.initAction(this, bundle, next ? "action.Next." : "action.Previous."); fNext= next; 57 } 58 59 public void run() { 60 if (fCompareEditorInput != null) { 61 Object adapter= fCompareEditorInput.getAdapter(ICompareNavigator.class); 62 if (adapter instanceof ICompareNavigator) { 63 boolean atEnd= ((ICompareNavigator)adapter).selectChange(fNext); 64 Shell shell= CompareUIPlugin.getShell(); 65 if (atEnd && shell != null) { 66 67 Display display= shell.getDisplay(); 68 if (display != null) 69 display.beep(); 70 71 String title; 72 String message; 73 if (fNext) { 74 title= CompareMessages.CompareNavigator_atEnd_title; 75 message= CompareMessages.CompareNavigator_atEnd_message; 76 } else { 77 title= CompareMessages.CompareNavigator_atBeginning_title; 78 message= CompareMessages.CompareNavigator_atBeginning_message; 79 } 80 MessageDialog.openInformation(shell, title, message); 81 } 82 } 83 } 84 } 85 86 91 public void setCompareEditorInput(CompareEditorInput input) { 92 fCompareEditorInput= input; 93 } 94 } 95 | Popular Tags |