diff options
Diffstat (limited to 'platform/lang-impl/src/com/intellij/unscramble/AnalyzeStacktraceOnErrorAction.java')
-rw-r--r-- | platform/lang-impl/src/com/intellij/unscramble/AnalyzeStacktraceOnErrorAction.java | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/platform/lang-impl/src/com/intellij/unscramble/AnalyzeStacktraceOnErrorAction.java b/platform/lang-impl/src/com/intellij/unscramble/AnalyzeStacktraceOnErrorAction.java index e1de663c9418..d3385e88b4b1 100644 --- a/platform/lang-impl/src/com/intellij/unscramble/AnalyzeStacktraceOnErrorAction.java +++ b/platform/lang-impl/src/com/intellij/unscramble/AnalyzeStacktraceOnErrorAction.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,26 +19,28 @@ package com.intellij.unscramble; import com.intellij.diagnostic.IdeErrorsDialog; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.CommonDataKeys; -import com.intellij.openapi.actionSystem.DataContext; -import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.project.Project; /** * @author spleaner */ public class AnalyzeStacktraceOnErrorAction extends AnAction { + @Override + public void update(AnActionEvent e) { + Project project = e.getProject(); + String message = getMessage(e); + e.getPresentation().setEnabledAndVisible(project != null && message != null); + } @Override public void actionPerformed(AnActionEvent e) { - final DataContext dataContext = e.getDataContext(); - - final Project project = CommonDataKeys.PROJECT.getData(dataContext); - if (project == null) return; + Project project = e.getProject(); + String message = getMessage(e); + if (project == null || message == null) return; + AnalyzeStacktraceUtil.addConsole(project, null, "<Stacktrace>", message); + } - final String message = IdeErrorsDialog.CURRENT_TRACE_KEY.getData(dataContext); - if (message != null) { - AnalyzeStacktraceUtil.addConsole(project, null, "<Stacktrace>", message); - } + private static String getMessage(AnActionEvent e) { + return IdeErrorsDialog.CURRENT_TRACE_KEY.getData(e.getDataContext()); } }
\ No newline at end of file |