mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
action to save current file only (IDEA-98513)
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package com.intellij.ide.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class SaveDocumentAction extends AnAction {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
Document doc = getDocument(e);
|
||||
if (doc != null) {
|
||||
FileDocumentManager.getInstance().saveDocument(doc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
e.getPresentation().setEnabled(getDocument(e) != null);
|
||||
}
|
||||
|
||||
private static Document getDocument(AnActionEvent e) {
|
||||
Editor editor = e.getData(PlatformDataKeys.EDITOR);
|
||||
return editor != null ? editor.getDocument() : null;
|
||||
}
|
||||
}
|
||||
@@ -1367,3 +1367,6 @@ action.TabList.description=Show dropdown with the list of all tabs in single-row
|
||||
|
||||
action.FillParagraph.text=Fill Paragraph
|
||||
action.FillParagraph.description=Reformat string literal or comment to fit maximum width (usually 80)
|
||||
|
||||
action.SaveDocument.text=Save Document
|
||||
action.SaveDocument.description=Saves only the file opened in the current editor
|
||||
|
||||
@@ -616,5 +616,7 @@
|
||||
<action id="DecrementWindowHeight" class="com.intellij.ide.actions.WindowAction$DecrementHeight" use-shortcut-of="ResizeToolWindowUp"/>
|
||||
|
||||
<action id="ExportTestResults" class="com.intellij.execution.testframework.export.ExportTestResultsAction" icon="AllIcons.Actions.Export"/>
|
||||
|
||||
<action id="SaveDocument" class="com.intellij.ide.actions.SaveDocumentAction"/>
|
||||
</actions>
|
||||
</component>
|
||||
|
||||
Reference in New Issue
Block a user