mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup
This commit is contained in:
@@ -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.
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.diagnostic.logging;
|
||||
|
||||
import com.intellij.openapi.ui.ComponentContainer;
|
||||
@@ -36,6 +35,7 @@ public abstract class AdditionalTabComponent extends JPanel implements Component
|
||||
protected AdditionalTabComponent() {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract String getTabTitle();
|
||||
|
||||
@Nullable
|
||||
|
||||
+5
-4
@@ -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.
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: Anna.Kozlova
|
||||
@@ -23,8 +22,10 @@
|
||||
package com.intellij.execution.configurations;
|
||||
|
||||
import com.intellij.diagnostic.logging.AdditionalTabComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface AdditionalTabComponentManager {
|
||||
void addAdditionalTabComponent(AdditionalTabComponent component, final String id);
|
||||
void removeAdditionalTabComponent(AdditionalTabComponent component);
|
||||
void addAdditionalTabComponent(@NotNull AdditionalTabComponent component, @NotNull String id);
|
||||
|
||||
void removeAdditionalTabComponent(@NotNull AdditionalTabComponent component);
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.diagnostic.logging;
|
||||
|
||||
@Deprecated
|
||||
/**
|
||||
* User: anna
|
||||
* Date: 01-Feb-2006
|
||||
|
||||
@@ -249,6 +249,7 @@ public abstract class LogConsoleBase extends AdditionalTabComponent implements L
|
||||
activate();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getTabTitle() {
|
||||
return myTitle;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.intellij.diagnostic.logging;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -44,7 +44,7 @@ public abstract class LogConsoleImpl extends LogConsoleBase {
|
||||
@NotNull File file,
|
||||
@NotNull Charset charset,
|
||||
long skippedContents,
|
||||
String title,
|
||||
@NotNull String title,
|
||||
final boolean buildInActions) {
|
||||
this(project, file, charset, skippedContents, title, buildInActions, GlobalSearchScope.allScope(project));
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public abstract class LogConsoleImpl extends LogConsoleBase {
|
||||
@NotNull File file,
|
||||
@NotNull Charset charset,
|
||||
long skippedContents,
|
||||
String title,
|
||||
@NotNull String title,
|
||||
final boolean buildInActions,
|
||||
final GlobalSearchScope searchScope) {
|
||||
super(project, getReader(file, charset, skippedContents), title, buildInActions, new DefaultLogFilterModel(project),
|
||||
@@ -64,27 +64,30 @@ public abstract class LogConsoleImpl extends LogConsoleBase {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Reader getReader(@NotNull final File file, @NotNull final Charset charset, final long skippedContents) {
|
||||
Reader reader = null;
|
||||
private static Reader getReader(@NotNull File file, @NotNull Charset charset, long skippedContents) {
|
||||
try {
|
||||
try {
|
||||
final FileInputStream inputStream = new FileInputStream(file);
|
||||
reader = new BufferedReader(new InputStreamReader(inputStream, charset));
|
||||
if (file.length() >= skippedContents) { //do not skip forward
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
inputStream.skip(skippedContents);
|
||||
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
|
||||
FileInputStream inputStream = new FileInputStream(file);
|
||||
//do not skip forward
|
||||
if (file.length() >= skippedContents) {
|
||||
long skipped = 0;
|
||||
while (skipped < skippedContents) {
|
||||
skipped += inputStream.skip(skippedContents - skipped);
|
||||
}
|
||||
}
|
||||
return new BufferedReader(new InputStreamReader(inputStream, charset));
|
||||
}
|
||||
catch (FileNotFoundException ignored) {
|
||||
if (FileUtil.createIfDoesntExist(file)) {
|
||||
reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), charset));
|
||||
if (FileUtilRt.createIfNotExists(file)) {
|
||||
return new BufferedReader(new InputStreamReader(new FileInputStream(file), charset));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (Throwable ignored) {
|
||||
reader = null;
|
||||
return null;
|
||||
}
|
||||
return reader;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,9 +107,10 @@ public abstract class LogConsoleImpl extends LogConsoleBase {
|
||||
return null;
|
||||
}
|
||||
|
||||
final long length = myFile.length();
|
||||
long length = myFile.length();
|
||||
if (length < myOldLength) {
|
||||
reader.close();
|
||||
//noinspection IOResourceOpenedButNotSafelyClosed
|
||||
reader = new BufferedReader(new InputStreamReader(new FileInputStream(myFile), myCharset));
|
||||
}
|
||||
myOldLength = length;
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public interface LogConsoleManager extends AdditionalTabComponentManager {
|
||||
void addLogConsole(String name, String path, @NotNull Charset charset, long skippedContent, @NotNull RunConfigurationBase runConfiguration);
|
||||
void addLogConsole(@NotNull String name, @NotNull String path, @NotNull Charset charset, long skippedContent, @NotNull RunConfigurationBase runConfiguration);
|
||||
|
||||
void removeLogConsole(final String pathOrId);
|
||||
void removeLogConsole(@NotNull String pathOrId);
|
||||
}
|
||||
|
||||
@@ -28,21 +28,18 @@ import com.intellij.ui.content.Content;
|
||||
import com.intellij.ui.content.ContentManagerAdapter;
|
||||
import com.intellij.ui.content.ContentManagerEvent;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import gnu.trove.THashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.Reader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class LogConsoleManagerBase implements LogConsoleManager, Disposable {
|
||||
private final Project myProject;
|
||||
|
||||
private final Map<AdditionalTabComponent, Content> myAdditionalContent = new HashMap<AdditionalTabComponent, Content>();
|
||||
|
||||
private final Map<AdditionalTabComponent, Content> myAdditionalContent = new THashMap<AdditionalTabComponent, Content>();
|
||||
private final GlobalSearchScope mySearchScope;
|
||||
|
||||
protected LogConsoleManagerBase(@NotNull Project project, @NotNull GlobalSearchScope searchScope) {
|
||||
@@ -50,18 +47,13 @@ public abstract class LogConsoleManagerBase implements LogConsoleManager, Dispos
|
||||
mySearchScope = searchScope;
|
||||
}
|
||||
|
||||
protected final Project getProject() {
|
||||
return myProject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLogConsole(final String name, final String path, @NotNull Charset charset, final long skippedContent, @NotNull RunConfigurationBase runConfiguration) {
|
||||
public void addLogConsole(@NotNull String name, @NotNull String path, @NotNull Charset charset, long skippedContent, @NotNull RunConfigurationBase runConfiguration) {
|
||||
addLogConsole(name, path, charset, skippedContent, getDefaultIcon(), runConfiguration);
|
||||
}
|
||||
|
||||
public void addLogConsole(final String name, final String path, @NotNull Charset charset, final long skippedContent, Icon icon, @Nullable RunProfile runProfile) {
|
||||
doAddLogConsole(new LogConsoleImpl(myProject, new File(path), charset, skippedContent, name, false, mySearchScope) {
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return isConsoleActive(path);
|
||||
@@ -69,23 +61,7 @@ public abstract class LogConsoleManagerBase implements LogConsoleManager, Dispos
|
||||
}, path, icon, runProfile);
|
||||
}
|
||||
|
||||
public void addLogConsole(String name, Reader reader, final String id, Icon icon, @Nullable RunProfile runProfile) {
|
||||
doAddLogConsole(new LogConsoleBase(myProject,
|
||||
reader,
|
||||
name,
|
||||
false,
|
||||
new DefaultLogFilterModel(myProject), mySearchScope) {
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return isConsoleActive(id);
|
||||
}
|
||||
}, id, icon, runProfile);
|
||||
}
|
||||
|
||||
private void doAddLogConsole(final LogConsoleBase log,
|
||||
final String id,
|
||||
Icon icon, @Nullable RunProfile runProfile) {
|
||||
private void doAddLogConsole(@NotNull final LogConsoleBase log, String id, Icon icon, @Nullable RunProfile runProfile) {
|
||||
if (runProfile instanceof RunConfigurationBase) {
|
||||
((RunConfigurationBase)runProfile).customizeLogConsole(log);
|
||||
}
|
||||
@@ -106,33 +82,28 @@ public abstract class LogConsoleManagerBase implements LogConsoleManager, Dispos
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLogConsole(final String path) {
|
||||
final Content content = getUi().findContent(path);
|
||||
public void removeLogConsole(@NotNull String path) {
|
||||
Content content = getUi().findContent(path);
|
||||
if (content != null) {
|
||||
final LogConsoleBase log = (LogConsoleBase)content.getComponent();
|
||||
removeAdditionalTabComponent(log);
|
||||
removeAdditionalTabComponent((LogConsoleBase)content.getComponent());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAdditionalTabComponent(final AdditionalTabComponent tabComponent, final String id) {
|
||||
public void addAdditionalTabComponent(@NotNull AdditionalTabComponent tabComponent, @NotNull String id) {
|
||||
addAdditionalTabComponent(tabComponent, id, getDefaultIcon());
|
||||
}
|
||||
|
||||
public Content addAdditionalTabComponent(final AdditionalTabComponent tabComponent, String id, Icon icon) {
|
||||
final Content logContent = createLogContent(tabComponent, id, icon);
|
||||
public Content addAdditionalTabComponent(@NotNull AdditionalTabComponent tabComponent, @NotNull String id, @Nullable Icon icon) {
|
||||
Content logContent = getUi().createContent(id, (ComponentWithActions)tabComponent, tabComponent.getTabTitle(), icon,
|
||||
tabComponent.getPreferredFocusableComponent());
|
||||
myAdditionalContent.put(tabComponent, logContent);
|
||||
getUi().addContent(logContent);
|
||||
return logContent;
|
||||
}
|
||||
|
||||
protected Content createLogContent(AdditionalTabComponent tabComponent, String id, Icon icon) {
|
||||
return getUi().createContent(id, (ComponentWithActions)tabComponent, tabComponent.getTabTitle(), icon,
|
||||
tabComponent.getPreferredFocusableComponent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAdditionalTabComponent(AdditionalTabComponent component) {
|
||||
public void removeAdditionalTabComponent(@NotNull AdditionalTabComponent component) {
|
||||
Disposer.dispose(component);
|
||||
final Content content = myAdditionalContent.remove(component);
|
||||
if (!getUi().isDisposed()) {
|
||||
|
||||
@@ -18,8 +18,6 @@ package com.intellij.diagnostic.logging;
|
||||
import com.intellij.execution.configurations.LogFileOptions;
|
||||
import com.intellij.execution.configurations.RunConfigurationBase;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Conditions;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -32,7 +30,7 @@ import java.util.TreeMap;
|
||||
public class LogFilesManager {
|
||||
private final LogConsoleManager myManager;
|
||||
|
||||
public LogFilesManager(@NotNull final Project project, @NotNull LogConsoleManager manager, @NotNull Disposable parentDisposable) {
|
||||
public LogFilesManager(@NotNull LogConsoleManager manager) {
|
||||
myManager = manager;
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ public abstract class RunTab implements DataProvider, Disposable {
|
||||
if (runConfiguration instanceof RunConfigurationBase && processHandler != null) {
|
||||
RunConfigurationBase configuration = (RunConfigurationBase)runConfiguration;
|
||||
if (myManager == null) {
|
||||
myManager = new LogFilesManager(myProject, getLogConsoleManager(), contentDescriptor);
|
||||
myManager = new LogFilesManager(getLogConsoleManager());
|
||||
}
|
||||
myManager.addLogConsoles(configuration, processHandler);
|
||||
OutputFileUtil.attachDumpListener(configuration, processHandler, console);
|
||||
|
||||
+2
@@ -29,6 +29,7 @@ import com.intellij.openapi.fileTypes.FileTypeEditorHighlighterProviders;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -107,6 +108,7 @@ public class HighlightingOutputConsole extends AdditionalTabComponent implements
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getTabTitle() {
|
||||
return TAB_TITLE;
|
||||
}
|
||||
|
||||
+19
-23
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.intellij.lang.xpath.xslt.run;
|
||||
|
||||
import com.intellij.diagnostic.logging.DebuggerLogConsoleManager;
|
||||
import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.Executor;
|
||||
import com.intellij.execution.configurations.*;
|
||||
@@ -140,32 +139,29 @@ public final class XsltRunConfiguration extends LocatableConfigurationBase imple
|
||||
return state;
|
||||
}
|
||||
|
||||
//invoke before run/debug tabs are shown.
|
||||
//Should be overriden to add additional tabs for run/debug toolwindow
|
||||
@Override
|
||||
public void createAdditionalTabComponents(final AdditionalTabComponentManager manager, ProcessHandler startedProcess) {
|
||||
if (myOutputType == OutputType.CONSOLE) {
|
||||
final HighlightingOutputConsole console = new HighlightingOutputConsole(getProject(), myFileType);
|
||||
if (myOutputType == OutputType.CONSOLE) {
|
||||
final HighlightingOutputConsole console = new HighlightingOutputConsole(getProject(), myFileType);
|
||||
|
||||
final List<XsltRunnerExtension> extensions = XsltRunnerExtension.getExtensions(this, manager instanceof DebuggerLogConsoleManager);
|
||||
boolean consoleTabAdded = false;
|
||||
for (XsltRunnerExtension extension : extensions) {
|
||||
if (extension.createTabs(getProject(), manager, console, startedProcess)) {
|
||||
consoleTabAdded = true;
|
||||
}
|
||||
}
|
||||
if (!consoleTabAdded) {
|
||||
manager.addAdditionalTabComponent(console, console.getTabTitle()); // TODO: verify parameter
|
||||
}
|
||||
|
||||
final OutputTabAdapter listener = new OutputTabAdapter(startedProcess, console);
|
||||
|
||||
if (startedProcess.isStartNotified()) {
|
||||
listener.startNotified(new ProcessEvent(startedProcess));
|
||||
} else {
|
||||
startedProcess.addProcessListener(listener);
|
||||
}
|
||||
boolean consoleTabAdded = false;
|
||||
for (XsltRunnerExtension extension : XsltRunnerExtension.getExtensions(this, false /* doesn't matter, xslt debugger uses own flag */)) {
|
||||
if (extension.createTabs(getProject(), manager, console, startedProcess)) {
|
||||
consoleTabAdded = true;
|
||||
}
|
||||
}
|
||||
if (!consoleTabAdded) {
|
||||
manager.addAdditionalTabComponent(console, console.getTabTitle()); // TODO: verify parameter
|
||||
}
|
||||
|
||||
final OutputTabAdapter listener = new OutputTabAdapter(startedProcess, console);
|
||||
if (startedProcess.isStartNotified()) {
|
||||
listener.startNotified(new ProcessEvent(startedProcess));
|
||||
}
|
||||
else {
|
||||
startedProcess.addProcessListener(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
@@ -1,6 +1,7 @@
|
||||
package org.intellij.plugins.xsltDebugger.ui;
|
||||
|
||||
import com.intellij.diagnostic.logging.AdditionalTabComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -16,6 +17,7 @@ abstract class AbstractTabComponent extends AdditionalTabComponent {
|
||||
myTabTitle = tabTitle;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getTabTitle() {
|
||||
return myTabTitle;
|
||||
|
||||
Reference in New Issue
Block a user