mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
SSR: better problem notification (part of fix for IDEA-141767)
This commit is contained in:
+3
-19
@@ -1,24 +1,9 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.structuralsearch.impl.matcher.predicates;
|
||||
|
||||
import com.intellij.notification.NotificationGroup;
|
||||
import com.intellij.notification.NotificationType;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.structuralsearch.SSRBundle;
|
||||
import com.intellij.structuralsearch.plugin.ui.UIUtil;
|
||||
|
||||
/**
|
||||
* @author Bas Leijdekkers
|
||||
@@ -27,7 +12,6 @@ public class ScriptLog {
|
||||
|
||||
public static final String SCRIPT_LOG_VAR_NAME = "__log__";
|
||||
|
||||
private static final NotificationGroup myEventLog = NotificationGroup.logOnlyGroup(SSRBundle.message("structural.search.title"));
|
||||
private final Project myProject;
|
||||
|
||||
public ScriptLog(Project project) {
|
||||
@@ -56,6 +40,6 @@ public class ScriptLog {
|
||||
break;
|
||||
}
|
||||
}
|
||||
myEventLog.createNotification(location + String.valueOf(message), type).notify(myProject);
|
||||
UIUtil.SSR_NOTIFICATION_GROUP.createNotification(location + String.valueOf(message), type).notify(myProject);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ public class ScriptSupport {
|
||||
File scriptFile = new File(text);
|
||||
GroovyShell shell = new GroovyShell();
|
||||
try {
|
||||
script = scriptFile.exists() ? shell.parse(scriptFile) : shell.parse(text, name + "_script.groovy");
|
||||
script = scriptFile.exists() ? shell.parse(scriptFile) : shell.parse(text, name + ".groovy");
|
||||
} catch (Exception ex) {
|
||||
Logger.getInstance(getClass().getName()).error(ex);
|
||||
throw new RuntimeException(ex);
|
||||
|
||||
+13
-19
@@ -5,15 +5,12 @@ import com.intellij.find.FindManager;
|
||||
import com.intellij.find.FindProgressIndicator;
|
||||
import com.intellij.find.FindSettings;
|
||||
import com.intellij.find.impl.FindManagerImpl;
|
||||
import com.intellij.notification.NotificationGroup;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.util.AbstractProgressIndicatorExBase;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.util.Factory;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.wm.ToolWindowId;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
@@ -21,7 +18,6 @@ import com.intellij.structuralsearch.*;
|
||||
import com.intellij.structuralsearch.plugin.StructuralSearchPlugin;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usages.*;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.Processor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -29,6 +25,7 @@ public class SearchCommand {
|
||||
protected final SearchContext mySearchContext;
|
||||
protected final Configuration myConfiguration;
|
||||
private MatchingProcess process;
|
||||
private FindUsagesProcessPresentation myProcessPresentation;
|
||||
|
||||
public SearchCommand(Configuration configuration, SearchContext searchContext) {
|
||||
myConfiguration = configuration;
|
||||
@@ -46,11 +43,11 @@ public class SearchCommand {
|
||||
presentation.setOpenInNewTab(FindSettings.getInstance().isShowResultsInSeparateView());
|
||||
context.configure(presentation);
|
||||
|
||||
final FindUsagesProcessPresentation processPresentation = new FindUsagesProcessPresentation(presentation);
|
||||
processPresentation.setShowNotFoundMessage(true);
|
||||
processPresentation.setShowPanelIfOnlyOneUsage(true);
|
||||
myProcessPresentation = new FindUsagesProcessPresentation(presentation);
|
||||
myProcessPresentation.setShowNotFoundMessage(true);
|
||||
myProcessPresentation.setShowPanelIfOnlyOneUsage(true);
|
||||
|
||||
processPresentation.setProgressIndicatorFactory(
|
||||
myProcessPresentation.setProgressIndicatorFactory(
|
||||
new Factory<ProgressIndicator>() {
|
||||
@Override
|
||||
public ProgressIndicator create() {
|
||||
@@ -78,7 +75,7 @@ public class SearchCommand {
|
||||
findUsages(processor);
|
||||
}
|
||||
},
|
||||
processPresentation,
|
||||
myProcessPresentation,
|
||||
presentation,
|
||||
new UsageViewManager.UsageViewStateListener() {
|
||||
@Override
|
||||
@@ -88,8 +85,7 @@ public class SearchCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void findingUsagesFinished(final UsageView usageView) {
|
||||
}
|
||||
public void findingUsagesFinished(final UsageView usageView) {}
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -157,9 +153,9 @@ public class SearchCommand {
|
||||
info = new UsageInfo(match);
|
||||
}
|
||||
|
||||
Usage usage = new UsageInfo2UsageAdapter(info);
|
||||
processor.process(usage);
|
||||
final Usage usage = new UsageInfo2UsageAdapter(info);
|
||||
foundUsage(result, usage);
|
||||
processor.process(usage);
|
||||
++count;
|
||||
}
|
||||
};
|
||||
@@ -168,12 +164,10 @@ public class SearchCommand {
|
||||
new Matcher(mySearchContext.getProject()).findMatches(sink, myConfiguration.getMatchOptions());
|
||||
}
|
||||
catch (final StructuralSearchException e) {
|
||||
final Alarm alarm = new Alarm();
|
||||
alarm.addRequest(
|
||||
() -> NotificationGroup.toolWindowGroup("Structural Search", ToolWindowId.FIND)
|
||||
.createNotification(SSRBundle.message("problem", e.getMessage()), MessageType.ERROR).notify(mySearchContext.getProject()),
|
||||
100, ModalityState.NON_MODAL
|
||||
);
|
||||
myProcessPresentation.setShowNotFoundMessage(false);
|
||||
UIUtil.SSR_NOTIFICATION_GROUP.createNotification(SSRBundle.message("problem", e.getMessage()), MessageType.ERROR)
|
||||
.setImportant(true)
|
||||
.notify(mySearchContext.getProject());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.structuralsearch.plugin.ui;
|
||||
|
||||
import com.intellij.codeInsight.template.TemplateContextType;
|
||||
@@ -6,6 +6,7 @@ import com.intellij.codeInsight.template.impl.TemplateEditorUtil;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.IdeTooltip;
|
||||
import com.intellij.ide.IdeTooltipManager;
|
||||
import com.intellij.notification.NotificationGroup;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
@@ -18,6 +19,7 @@ import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.wm.ToolWindowId;
|
||||
import com.intellij.structuralsearch.MatchOptions;
|
||||
import com.intellij.structuralsearch.MatchVariableConstraint;
|
||||
import com.intellij.structuralsearch.SSRBundle;
|
||||
@@ -41,6 +43,9 @@ public class UIUtil {
|
||||
private static final String MODIFY_EDITOR_CONTENT = SSRBundle.message("modify.editor.content.command.name");
|
||||
@NonNls private static final String SS_GROUP = "structuralsearchgroup";
|
||||
|
||||
public static final NotificationGroup SSR_NOTIFICATION_GROUP =
|
||||
NotificationGroup.toolWindowGroup(SSRBundle.message("structural.search.title") + 2, ToolWindowId.FIND);
|
||||
|
||||
@NotNull
|
||||
public static Editor createEditor(Document doc, final Project project, boolean editable, @Nullable TemplateContextType contextType) {
|
||||
return createEditor(doc, project, editable, false, contextType);
|
||||
|
||||
@@ -245,7 +245,7 @@ predefined.configuration.class.with.parameterless.constructors=classes with para
|
||||
predefined.configuration.static.fields.without.final=static fields that are not final
|
||||
groovy.script.error=Groovy Script execution error: {0}
|
||||
template.problem=Structural Search Inspection problem in template ''{0}''
|
||||
problem=Structural Search problem: {0}
|
||||
problem=Structural Search: {0}
|
||||
complete.match.variable.name=Complete Match
|
||||
predefined.configuration.sample.method.invokation.with.constant.argument=sample method invocation with constant argument
|
||||
predefined.configuration.interfaces.having.no.descendants=interface that is not implemented or extended
|
||||
|
||||
Reference in New Issue
Block a user