1 11 package org.eclipse.ui.internal; 12 13 import org.eclipse.ui.IEditorPart; 14 import org.eclipse.ui.ISaveablePart; 15 import org.eclipse.ui.IWorkbenchWindow; 16 17 20 public class SaveAsAction extends BaseSaveAction { 21 22 27 public SaveAsAction(IWorkbenchWindow window) { 28 super(WorkbenchMessages.SaveAs_text, window); 29 setActionDefinitionId("org.eclipse.ui.file.saveAs"); setText(WorkbenchMessages.SaveAs_text); 31 setToolTipText(WorkbenchMessages.SaveAs_toolTip); 32 setId("saveAs"); window.getWorkbench().getHelpSystem().setHelp(this, 34 IWorkbenchHelpContextIds.SAVE_AS_ACTION); 35 setImageDescriptor(WorkbenchImages 36 .getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_SAVEAS_EDIT)); 37 setDisabledImageDescriptor(WorkbenchImages 38 .getImageDescriptor(IWorkbenchGraphicConstants.IMG_ETOOL_SAVEAS_EDIT_DISABLED)); 39 } 40 41 44 public void run() { 45 if (getWorkbenchWindow() == null) { 46 return; 48 } 49 53 ISaveablePart saveView = getSaveableView(); 54 if (saveView != null) { 55 saveView.doSaveAs(); 56 return; 57 } 58 59 60 IEditorPart editor = getActiveEditor(); 61 if (editor != null) { 62 editor.doSaveAs(); 63 } 64 } 65 66 69 protected void updateState() { 70 74 ISaveablePart saveView = getSaveableView(); 75 if (saveView != null) { 76 setEnabled(saveView.isSaveAsAllowed()); 77 return; 78 } 79 80 81 IEditorPart editor = getActiveEditor(); 82 setEnabled(editor != null && editor.isSaveAsAllowed()); 83 } 84 } 85 | Popular Tags |