mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
vcs: Refactoring - introduced new overload of "ProjectLevelVcsManager.addMessageToConsoleWindow()" to avoid unnecessary "ConsoleViewContentType" instances creation while printing messages to vcs console
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.vcs;
|
||||
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.lifecycle.PeriodicalTasksCloser;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
@@ -170,8 +171,11 @@ public abstract class ProjectLevelVcsManager {
|
||||
|
||||
public abstract boolean hasAnyMappings();
|
||||
|
||||
@Deprecated
|
||||
public abstract void addMessageToConsoleWindow(String message, TextAttributes attributes);
|
||||
|
||||
public abstract void addMessageToConsoleWindow(@Nullable String message, @NotNull ConsoleViewContentType contentType);
|
||||
|
||||
@NotNull
|
||||
public abstract VcsShowSettingOption getStandardOption(@NotNull VcsConfiguration.StandardOption option,
|
||||
@NotNull AbstractVcs vcs);
|
||||
|
||||
+13
-6
@@ -61,6 +61,7 @@ import com.intellij.ui.content.ContentFactory;
|
||||
import com.intellij.ui.content.ContentManager;
|
||||
import com.intellij.util.ContentUtilEx;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.Convertor;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
@@ -119,7 +120,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
|
||||
|
||||
private final Map<VcsBackgroundableActions, BackgroundableActionEnabledHandler> myBackgroundableActionHandlerMap;
|
||||
|
||||
private final List<Pair<String, TextAttributes>> myPendingOutput = new ArrayList<Pair<String, TextAttributes>>();
|
||||
private final List<Pair<String, ConsoleViewContentType>> myPendingOutput = ContainerUtil.newArrayList();
|
||||
|
||||
private final VcsHistoryCache myVcsHistoryCache;
|
||||
private final ContentRevisionCache myContentRevisionCache;
|
||||
@@ -389,8 +390,14 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
|
||||
return !myMappings.isEmpty();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void addMessageToConsoleWindow(final String message, final TextAttributes attributes) {
|
||||
addMessageToConsoleWindow(message, new ConsoleViewContentType("", attributes));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMessageToConsoleWindow(@Nullable final String message, @NotNull final ConsoleViewContentType contentType) {
|
||||
if (!Registry.is("vcs.showConsole")) {
|
||||
return;
|
||||
}
|
||||
@@ -405,11 +412,11 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
|
||||
if (myProject.isDisposed() || myProject.isDefault()) return;
|
||||
final ContentManager contentManager = getContentManager();
|
||||
if (contentManager == null) {
|
||||
myPendingOutput.add(Pair.create(message, attributes));
|
||||
myPendingOutput.add(Pair.create(message, contentType));
|
||||
}
|
||||
else {
|
||||
getOrCreateConsoleContent(contentManager);
|
||||
printToConsole(message, attributes);
|
||||
printToConsole(message, contentType);
|
||||
}
|
||||
}
|
||||
}, ModalityState.defaultModalityState());
|
||||
@@ -434,7 +441,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
|
||||
content.setDisposer(myConsoleDisposer);
|
||||
contentManager.addContent(content);
|
||||
|
||||
for (Pair<String, TextAttributes> pair : myPendingOutput) {
|
||||
for (Pair<String, ConsoleViewContentType> pair : myPendingOutput) {
|
||||
printToConsole(pair.first, pair.second);
|
||||
}
|
||||
myPendingOutput.clear();
|
||||
@@ -442,8 +449,8 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
|
||||
return content;
|
||||
}
|
||||
|
||||
private void printToConsole(@NotNull String message, @Nullable TextAttributes attributes) {
|
||||
myConsole.print(message + "\n", new ConsoleViewContentType("", attributes));
|
||||
private void printToConsole(@NotNull String message, @NotNull ConsoleViewContentType contentType) {
|
||||
myConsole.print(message + "\n", contentType);
|
||||
}
|
||||
|
||||
private void releaseConsole() {
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.diff.impl.patch.formove.FilePathComparator;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
@@ -376,19 +375,19 @@ public class GitVcs extends AbstractVcs<CommittedChangeList> {
|
||||
*/
|
||||
public void showMessages(@NotNull String message) {
|
||||
if (message.length() == 0) return;
|
||||
showMessage(message, ConsoleViewContentType.NORMAL_OUTPUT.getAttributes());
|
||||
showMessage(message, ConsoleViewContentType.NORMAL_OUTPUT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show message in the Version Control Console
|
||||
* @param message a message to show
|
||||
* @param style a style to use
|
||||
* @param contentType a style to use
|
||||
*/
|
||||
private void showMessage(@NotNull String message, final TextAttributes style) {
|
||||
private void showMessage(@NotNull String message, @NotNull ConsoleViewContentType contentType) {
|
||||
if (message.length() > MAX_CONSOLE_OUTPUT_SIZE) {
|
||||
message = message.substring(0, MAX_CONSOLE_OUTPUT_SIZE);
|
||||
}
|
||||
myVcsManager.addMessageToConsoleWindow(message, style);
|
||||
myVcsManager.addMessageToConsoleWindow(message, contentType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -428,7 +427,7 @@ public class GitVcs extends AbstractVcs<CommittedChangeList> {
|
||||
final String reason = (e.getCause() != null ? e.getCause() : e).getMessage();
|
||||
String message = GitBundle.message("vcs.unable.to.run.git", executable, reason);
|
||||
if (!myProject.isDefault()) {
|
||||
showMessage(message, ConsoleViewContentType.SYSTEM_OUTPUT.getAttributes());
|
||||
showMessage(message, ConsoleViewContentType.SYSTEM_OUTPUT);
|
||||
}
|
||||
VcsBalloonProblemNotifier.showOverVersionControlView(myProject, message, MessageType.ERROR);
|
||||
}
|
||||
@@ -448,14 +447,14 @@ public class GitVcs extends AbstractVcs<CommittedChangeList> {
|
||||
*/
|
||||
public void showCommandLine(final String cmdLine) {
|
||||
SimpleDateFormat f = new SimpleDateFormat("HH:mm:ss.SSS");
|
||||
showMessage(f.format(new Date()) + ": " + cmdLine, ConsoleViewContentType.SYSTEM_OUTPUT.getAttributes());
|
||||
showMessage(f.format(new Date()) + ": " + cmdLine, ConsoleViewContentType.SYSTEM_OUTPUT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows error message in the Version Control Console
|
||||
*/
|
||||
public void showErrorMessages(final String line) {
|
||||
showMessage(line, ConsoleViewContentType.ERROR_OUTPUT.getAttributes());
|
||||
showMessage(line, ConsoleViewContentType.ERROR_OUTPUT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -107,7 +107,7 @@ public class HgVFSListener extends VcsVFSListener {
|
||||
catch (final VcsException ex) {
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
public void run() {
|
||||
((HgVcs)myVcs).showMessageInConsole(ex.getMessage(), ConsoleViewContentType.ERROR_OUTPUT.getAttributes());
|
||||
((HgVcs)myVcs).showMessageInConsole(ex.getMessage(), ConsoleViewContentType.ERROR_OUTPUT);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// limitations under the License.
|
||||
package org.zmlx.hg4idea;
|
||||
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.ide.BrowserUtil;
|
||||
import com.intellij.notification.Notification;
|
||||
import com.intellij.notification.NotificationListener;
|
||||
@@ -21,7 +22,6 @@ import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.diff.impl.patch.formove.FilePathComparator;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
@@ -363,11 +363,11 @@ public class HgVcs extends AbstractVcs<CommittedChangeList> {
|
||||
return globalSettings;
|
||||
}
|
||||
|
||||
public void showMessageInConsole(String message, final TextAttributes style) {
|
||||
public void showMessageInConsole(@NotNull String message, @NotNull ConsoleViewContentType contentType) {
|
||||
if (message.length() > MAX_CONSOLE_OUTPUT_SIZE) {
|
||||
message = message.substring(0, MAX_CONSOLE_OUTPUT_SIZE);
|
||||
}
|
||||
myVcsManager.addMessageToConsoleWindow(message, style);
|
||||
myVcsManager.addMessageToConsoleWindow(message, contentType);
|
||||
}
|
||||
|
||||
public HgExecutableValidator getExecutableValidator() {
|
||||
|
||||
@@ -204,7 +204,7 @@ public class HgCommandExecutor {
|
||||
}
|
||||
if (!myIsSilent) {
|
||||
LOG.info(cmdString);
|
||||
myVcs.showMessageInConsole(cmdString, ConsoleViewContentType.NORMAL_OUTPUT.getAttributes());
|
||||
myVcs.showMessageInConsole(cmdString, ConsoleViewContentType.NORMAL_OUTPUT);
|
||||
}
|
||||
else {
|
||||
LOG.debug(cmdString);
|
||||
@@ -223,7 +223,7 @@ public class HgCommandExecutor {
|
||||
else if (!myOutputAlwaysSuppressed) {
|
||||
if (!myIsSilent && myShowOutput) {
|
||||
LOG.info(result.getRawOutput());
|
||||
myVcs.showMessageInConsole(result.getRawOutput(), ConsoleViewContentType.SYSTEM_OUTPUT.getAttributes());
|
||||
myVcs.showMessageInConsole(result.getRawOutput(), ConsoleViewContentType.SYSTEM_OUTPUT);
|
||||
}
|
||||
else {
|
||||
LOG.debug(result.getRawOutput());
|
||||
@@ -238,7 +238,7 @@ public class HgCommandExecutor {
|
||||
}
|
||||
if (!myIsSilent) {
|
||||
LOG.info(result.getRawError());
|
||||
myVcs.showMessageInConsole(result.getRawError(), ConsoleViewContentType.ERROR_OUTPUT.getAttributes());
|
||||
myVcs.showMessageInConsole(result.getRawError(), ConsoleViewContentType.ERROR_OUTPUT);
|
||||
}
|
||||
else {
|
||||
LOG.debug(result.getRawError());
|
||||
|
||||
Reference in New Issue
Block a user