1 11 12 13 package org.eclipse.ui.texteditor; 14 15 16 import org.eclipse.swt.SWT; 17 import org.eclipse.swt.custom.StyledText; 18 import org.eclipse.swt.events.HelpListener; 19 import org.eclipse.swt.graphics.Point; 20 import org.eclipse.swt.widgets.Event; 21 22 import org.eclipse.jface.action.Action; 23 import org.eclipse.jface.action.IMenuCreator; 24 import org.eclipse.jface.resource.ImageDescriptor; 25 import org.eclipse.jface.util.IPropertyChangeListener; 26 27 28 32 public class TextNavigationAction extends Action { 33 34 35 private StyledText fTextWidget; 36 37 private int fAction; 38 39 private String fActionId; 40 41 private String fActionDefinitionId; 42 43 44 49 public TextNavigationAction(StyledText textWidget, int action) { 50 fTextWidget= textWidget; 51 fAction= action; 52 } 53 54 59 protected StyledText getTextWidget() { 60 return fTextWidget; 61 } 62 63 66 public void run() { 67 Point selection= fTextWidget.getSelection(); 68 fTextWidget.invokeAction(fAction); 69 fireSelectionChanged(selection); 70 } 71 72 private void doFireSelectionChanged(Point selection) { 73 Event event= new Event(); 74 event.x= selection.x; 75 event.y= selection.y; 76 fTextWidget.notifyListeners(SWT.Selection, event); 77 } 78 79 85 protected void fireSelectionChanged() { 86 fireSelectionChanged(null); 87 } 88 89 96 protected void fireSelectionChanged(Point oldSelection) { 97 Point selection= fTextWidget.getSelection(); 98 if (oldSelection == null || !selection.equals(oldSelection)) 99 doFireSelectionChanged(selection); 100 } 101 102 105 public void runWithEvent(Event event) { 106 run(); 107 } 108 109 112 public void setActionDefinitionId(String id) { 113 fActionDefinitionId= id; 114 } 115 116 119 public String getActionDefinitionId() { 120 return fActionDefinitionId; 121 } 122 123 126 public void setId(String id) { 127 fActionId= id; 128 } 129 130 133 public String getId() { 134 return fActionId; 135 } 136 137 138 141 144 public void addPropertyChangeListener(IPropertyChangeListener listener) { 145 } 146 147 150 public int getAccelerator() { 151 return 0; 152 } 153 154 157 public String getDescription() { 158 return null; 159 } 160 161 164 public ImageDescriptor getDisabledImageDescriptor() { 165 return null; 166 } 167 168 171 public HelpListener getHelpListener() { 172 return null; 173 } 174 175 178 public ImageDescriptor getHoverImageDescriptor() { 179 return null; 180 } 181 182 185 public ImageDescriptor getImageDescriptor() { 186 return null; 187 } 188 189 192 public IMenuCreator getMenuCreator() { 193 return null; 194 } 195 196 199 public int getStyle() { 200 return 0; 201 } 202 203 206 public String getText() { 207 return null; 208 } 209 210 213 public String getToolTipText() { 214 return null; 215 } 216 217 220 public boolean isChecked() { 221 return false; 222 } 223 224 227 public boolean isEnabled() { 228 return true; 229 } 230 231 234 public void removePropertyChangeListener(IPropertyChangeListener listener) { 235 } 236 237 240 public void setAccelerator(int keycode) { 241 } 242 243 246 public void setChecked(boolean checked) { 247 } 248 249 252 public void setDescription(String text) { 253 } 254 255 258 public void setDisabledImageDescriptor(ImageDescriptor newImage) { 259 } 260 261 264 public void setEnabled(boolean enabled) { 265 } 266 267 270 public void setHelpListener(HelpListener listener) { 271 } 272 273 276 public void setHoverImageDescriptor(ImageDescriptor newImage) { 277 } 278 279 282 public void setImageDescriptor(ImageDescriptor newImage) { 283 } 284 285 288 public void setMenuCreator(IMenuCreator creator) { 289 } 290 291 294 public void setText(String text) { 295 } 296 297 300 public void setToolTipText(String text) { 301 } 302 } 303 | Popular Tags |