1 11 package org.eclipse.ui.internal.editors.text; 12 13 import java.util.ArrayList ; 14 import java.util.List ; 15 16 import org.eclipse.core.runtime.Assert; 17 18 import org.eclipse.core.resources.IResource; 19 20 import org.eclipse.jface.action.Action; 21 22 import org.eclipse.ui.actions.RefreshAction; 23 import org.eclipse.ui.texteditor.ITextEditor; 24 import org.eclipse.ui.texteditor.IUpdate; 25 26 27 36 public class RefreshEditorAction extends Action implements IUpdate { 37 38 private ITextEditor fTextEditor; 39 40 public RefreshEditorAction(ITextEditor textEditor) { 41 Assert.isLegal(textEditor != null); 42 fTextEditor= textEditor; 43 update(); 44 } 45 46 49 public void run() { 50 final IResource resource= fTextEditor == null ? null : (IResource)fTextEditor.getEditorInput().getAdapter(IResource.class); 51 if (resource == null) 52 return; 53 54 RefreshAction impl= new RefreshAction(fTextEditor.getSite().getShell()) { 55 protected List getSelectedResources() { 56 List result= new ArrayList (1); 57 result.add(resource); 58 return result; 59 } 60 }; 61 impl.run(); 62 } 63 64 67 public void update() { 68 final IResource resource= fTextEditor == null ? null : (IResource)fTextEditor.getEditorInput().getAdapter(IResource.class); 69 setEnabled(resource != null); 70 } 71 72 } 73 | Popular Tags |