mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-80976 fix 'clear log before launch' option
This commit is contained in:
@@ -96,6 +96,7 @@ public class AndroidLogcatToolWindowFactory implements ToolWindowFactory {
|
||||
|
||||
final Content logcatContent =
|
||||
contentManager.getFactory().createContent(contentPanel, AndroidBundle.message("android.logcat.tab.title"), false);
|
||||
logcatContent.putUserData(AndroidLogcatToolWindowView.ANDROID_LOGCAT_VIEW_KEY, view);
|
||||
logcatContent.setDisposer(view);
|
||||
logcatContent.setCloseable(false);
|
||||
logcatContent.setPreferredFocusableComponent(contentPanel);
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Splitter;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.ui.CollectionListModel;
|
||||
import com.intellij.ui.components.JBList;
|
||||
@@ -64,6 +65,7 @@ import java.util.regex.PatternSyntaxException;
|
||||
public abstract class AndroidLogcatToolWindowView implements Disposable {
|
||||
private static final Logger LOG = Logger.getInstance("#org.jetbrains.android.logcat.AndroidLogcatToolWindowView");
|
||||
static final String EMPTY_CONFIGURED_FILTER = "All messages";
|
||||
public static final Key<AndroidLogcatToolWindowView> ANDROID_LOGCAT_VIEW_KEY = Key.create("ANDROID_LOGCAT_VIEW_KEY");
|
||||
|
||||
private final Project myProject;
|
||||
private JComboBox myDeviceCombo;
|
||||
@@ -252,7 +254,7 @@ public abstract class AndroidLogcatToolWindowView implements Disposable {
|
||||
Disposer.register(this, myLogConsole);
|
||||
myClearLogButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
IDevice device = (IDevice)myDeviceCombo.getSelectedItem();
|
||||
IDevice device = getSelectedDevice();
|
||||
if (device != null) {
|
||||
AndroidLogcatUtil.clearLogcat(project, device);
|
||||
myLogConsole.clear();
|
||||
@@ -328,7 +330,7 @@ public abstract class AndroidLogcatToolWindowView implements Disposable {
|
||||
}
|
||||
|
||||
private void updateLogConsole() {
|
||||
IDevice device = (IDevice)myDeviceCombo.getSelectedItem();
|
||||
IDevice device = getSelectedDevice();
|
||||
if (myDevice != device) {
|
||||
synchronized (myLock) {
|
||||
myDevice = device;
|
||||
@@ -364,6 +366,11 @@ public abstract class AndroidLogcatToolWindowView implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public IDevice getSelectedDevice() {
|
||||
return (IDevice)myDeviceCombo.getSelectedItem();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static AndroidPlatform getAndroidPlatform(@NotNull Project project) {
|
||||
List<AndroidFacet> facets = ProjectFacetManager.getInstance(project).getFacets(AndroidFacet.ID);
|
||||
|
||||
@@ -238,7 +238,7 @@ public abstract class AndroidRunConfigurationBase extends ModuleBasedConfigurati
|
||||
AndroidApplicationLauncher applicationLauncher = getApplicationLauncher(facet);
|
||||
if (applicationLauncher != null) {
|
||||
return new AndroidRunningState(env, facet, targetChooser, computeCommandLine(), aPackage, applicationLauncher,
|
||||
depModule2PackageName, supportMultipleDevices()) {
|
||||
depModule2PackageName, supportMultipleDevices(), CLEAR_LOGCAT) {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
|
||||
@@ -49,11 +49,17 @@ import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.wm.ToolWindow;
|
||||
import com.intellij.openapi.wm.ToolWindowManager;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.xdebugger.DefaultDebugProcessHandler;
|
||||
import org.jetbrains.android.facet.AndroidFacet;
|
||||
import org.jetbrains.android.facet.AndroidRootUtil;
|
||||
import org.jetbrains.android.facet.AvdsNotSupportedException;
|
||||
import org.jetbrains.android.logcat.AndroidLogcatToolWindowFactory;
|
||||
import org.jetbrains.android.logcat.AndroidLogcatToolWindowView;
|
||||
import org.jetbrains.android.logcat.AndroidLogcatUtil;
|
||||
import org.jetbrains.android.sdk.AndroidSdkUtils;
|
||||
import org.jetbrains.android.util.AndroidBundle;
|
||||
import org.jetbrains.android.util.AndroidOutputReceiver;
|
||||
@@ -119,6 +125,7 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
|
||||
private Runnable myRestarter;
|
||||
private TargetChooser myTargetChooser;
|
||||
private final boolean mySupportMultipleDevices;
|
||||
private final boolean myClearLogcatBeforeStart;
|
||||
|
||||
public void setDebugMode(boolean debugMode) {
|
||||
myDebugMode = debugMode;
|
||||
@@ -274,7 +281,8 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
|
||||
@NotNull String packageName,
|
||||
AndroidApplicationLauncher applicationLauncher,
|
||||
Map<AndroidFacet, String> additionalFacet2PackageName,
|
||||
boolean supportMultipleDevices) throws ExecutionException {
|
||||
boolean supportMultipleDevices,
|
||||
boolean clearLogcatBeforeStart) throws ExecutionException {
|
||||
myFacet = facet;
|
||||
myCommandLine = commandLine;
|
||||
|
||||
@@ -290,6 +298,7 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
|
||||
myPackageName = packageName;
|
||||
myTargetPackageName = packageName;
|
||||
myAdditionalFacet2PackageName = additionalFacet2PackageName;
|
||||
myClearLogcatBeforeStart = clearLogcatBeforeStart;
|
||||
}
|
||||
|
||||
public void setDeploy(boolean deploy) {
|
||||
@@ -606,6 +615,10 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
|
||||
}
|
||||
|
||||
private boolean prepareAndStartApp(IDevice device) {
|
||||
if (myClearLogcatBeforeStart) {
|
||||
clearLogcatAndConsole(getModule().getProject(), device);
|
||||
}
|
||||
|
||||
message("Target device: " + getDevicePresentableName(device), STDOUT);
|
||||
try {
|
||||
if (myDeploy) {
|
||||
@@ -649,6 +662,22 @@ public abstract class AndroidRunningState implements RunProfileState, AndroidDeb
|
||||
}
|
||||
}
|
||||
|
||||
protected static void clearLogcatAndConsole(@NotNull Project project, @NotNull IDevice device) {
|
||||
final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(AndroidLogcatToolWindowFactory.TOOL_WINDOW_ID);
|
||||
if (toolWindow == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Content content : toolWindow.getContentManager().getContents()) {
|
||||
final AndroidLogcatToolWindowView view = content.getUserData(AndroidLogcatToolWindowView.ANDROID_LOGCAT_VIEW_KEY);
|
||||
|
||||
if (view != null && device == view.getSelectedDevice()) {
|
||||
view.getLogConsole().clear();
|
||||
}
|
||||
}
|
||||
AndroidLogcatUtil.clearLogcat(project, device);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getDevicePresentableName(IDevice device) {
|
||||
StringBuilder deviceMessageBuilder = new StringBuilder();
|
||||
|
||||
Reference in New Issue
Block a user