From: liana.bakradze Date: Thu, 3 Sep 2015 12:31:51 +0000 (+0300) Subject: EDU-409 Show Preview action does nothing for non-text files (e.g.pictures) X-Git-Tag: phpstorm/142.4543~18 X-Git-Url: https://git.jetbrains.org/?p=idea%2Fcommunity.git;a=commitdiff_plain;h=4f9e386d6b2cb1babd2bd41926a89914a7821df1;hp=73593d0d3559b810c7fe7db948b2e33df1373322;ds=sidebyside EDU-409 Show Preview action does nothing for non-text files (e.g.pictures) --- diff --git a/python/educational/course-creator/src/com/jetbrains/edu/coursecreator/actions/CCShowPreview.java b/python/educational/course-creator/src/com/jetbrains/edu/coursecreator/actions/CCShowPreview.java index 9d461e54c1af..ac02e7648b07 100644 --- a/python/educational/course-creator/src/com/jetbrains/edu/coursecreator/actions/CCShowPreview.java +++ b/python/educational/course-creator/src/com/jetbrains/edu/coursecreator/actions/CCShowPreview.java @@ -31,6 +31,7 @@ import com.intellij.openapi.project.DumbModePermission; import com.intellij.openapi.project.DumbService; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.FrameWrapper; +import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiDirectory; @@ -54,7 +55,7 @@ public class CCShowPreview extends DumbAwareAction { private static final Logger LOG = Logger.getInstance(CCShowPreview.class.getName()); public CCShowPreview() { - super("Show Preview","Show preview", null); + super("Show Preview","Show Preview", null); } @Override @@ -63,12 +64,10 @@ public class CCShowPreview extends DumbAwareAction { return; } Presentation presentation = e.getPresentation(); - presentation.setEnabled(false); - presentation.setVisible(false); + presentation.setEnabledAndVisible(false); final PsiFile file = CommonDataKeys.PSI_FILE.getData(e.getDataContext()); if (file != null && file.getName().contains(".answer")) { - presentation.setEnabled(true); - presentation.setVisible(true); + presentation.setEnabledAndVisible(true); } } @@ -99,6 +98,9 @@ public class CCShowPreview extends DumbAwareAction { if (taskFile == null) { return; } + if (taskFile.getAnswerPlaceholders().isEmpty()) { + Messages.showInfoMessage("Preview is available for task files with answer placeholders only", "No Preview for This File"); + } final TaskFile taskFileCopy = new TaskFile(); TaskFile.copy(taskFile, taskFileCopy); final String taskFileName = CCProjectService.getRealTaskFileName(file.getVirtualFile().getName());