public void update(final AnActionEvent e) { boolean enabled = isEnabled(myVirtualFile); if (myVirtualFile != null) { FileMode mode = modeFromFile(myVirtualFile); if (mode == null) { mode = FileMode.auto(); } e.getPresentation().setText(mode.getDisplayName()); } e.getPresentation().setEnabled(enabled); }
@Nullable("returns null if filemode cannot be determined from content") public static FileMode modeFromFile(final VirtualFile virtualFile) { if (virtualFile == null) { return null; } final Document document = FileDocumentManager.getInstance().getDocument(virtualFile); if (document == null) { return null; } return FileMode.defaultMode(); }
public DefaultActionGroup createGroup(boolean showClear) { DefaultActionGroup group = new DefaultActionGroup(); // FileMode mode = myVirtualFile == null ? null : modeFromFile(myVirtualFile); if (showClear) { group.add(new ClearThisFileModeAction(myVirtualFile)); } fileModeActions(group, myVirtualFile, FileMode.all()); // DefaultActionGroup more = new DefaultActionGroup("more", true); // group.add(more); // fileModeActions(more, myVirtualFile, FileMode.all()); return group; }
public void actionPerformed(final AnActionEvent e) { chosen(myFile, FileMode.defaultMode()); }