IDEA-60471 remove platform chooser from android logcat

This commit is contained in:
Eugene Kudelevsky
2010-11-10 15:44:43 +03:00
parent ef490640af
commit a940dfbcae
3 changed files with 27 additions and 101 deletions
@@ -213,4 +213,5 @@ android.run.configuration.emulator.tab.title=Emulator
android.run.configuration.logcat.tab.title=Logcat
android.facet.settings.apk.path.label=APK path:
android.run.confguration.deploy.and.install.check.box=Deplo&y application
android.manifest.debuggable.attribute.not.true.warning=The manifest 'debuggable' attribute isn't set to 'true'.\nYou have to set it to true in order to debug on a device.\nWould you like to do it?
android.manifest.debuggable.attribute.not.true.warning=The manifest 'debuggable' attribute isn't set to 'true'.\nYou have to set it to true in order to debug on a device.\nWould you like to do it?
android.logcat.no.android.facets.error=There is no Android facets in the project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.android.logcat.AndroidLogcatToolWindowView">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" column-count="6" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="2" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="3" left="3" bottom="3" right="3"/>
<constraints>
<xy x="20" y="20" width="606" height="272"/>
@@ -10,7 +10,7 @@
<children>
<component id="c3a51" class="javax.swing.JComboBox" binding="myDeviceCombo">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="1" indent="0" use-parent-layout="false">
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="130" height="-1"/>
</grid>
</constraints>
@@ -18,7 +18,7 @@
</component>
<grid id="2aac1" binding="myConsoleWrapper" layout-manager="BorderLayout" hgap="1" vgap="2">
<constraints>
<grid row="1" column="0" row-span="1" col-span="6" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="5" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<background color="-1"/>
@@ -28,7 +28,7 @@
</grid>
<component id="799f3" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/AndroidBundle" key="android.logcat.device.label"/>
@@ -36,7 +36,7 @@
</component>
<component id="61fcc" class="javax.swing.JButton" binding="myClearLogButton">
<constraints>
<grid row="0" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/AndroidBundle" key="android.logcat.clear.log.button.title"/>
@@ -44,38 +44,12 @@
</component>
<hspacer id="b66a9">
<constraints>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<grid id="6b50f" binding="myAndroidPlatformPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="fe929" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/AndroidBundle" key="android.platform.label"/>
</properties>
</component>
<component id="52fd" class="org.jetbrains.android.sdk.AndroidPlatformsComboBox" binding="myAndroidPlatformsCombo" custom-create="true">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="130" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
</children>
</grid>
<grid id="8c9ae" binding="mySearchComponentWrapper" layout-manager="BorderLayout" hgap="0" vgap="0">
<constraints>
<grid row="0" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
@@ -13,34 +13,30 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.android.logcat;import com.android.ddmlib.AndroidDebugBridge;
package org.jetbrains.android.logcat;
import com.android.ddmlib.AndroidDebugBridge;
import com.android.ddmlib.IDevice;
import com.android.ddmlib.Log;
import com.intellij.CommonBundle;
import com.intellij.diagnostic.logging.LogConsoleBase;
import com.intellij.diagnostic.logging.LogFilterModel;
import com.intellij.facet.ProjectFacetManager;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.ActionPlaces;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.roots.libraries.LibraryTable;
import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Disposer;
import org.jetbrains.android.actions.AndroidEnableDdmsAction;
import org.jetbrains.android.ddms.AdbManager;
import org.jetbrains.android.ddms.AdbNotRespondingException;
import org.jetbrains.android.facet.AndroidFacet;
import org.jetbrains.android.sdk.AndroidPlatform;
import org.jetbrains.android.sdk.AndroidPlatformsComboBox;
import org.jetbrains.android.util.AndroidBundle;
import org.jetbrains.android.util.AndroidUtils;
import org.jetbrains.annotations.NotNull;
@@ -51,8 +47,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.Reader;
import java.util.HashSet;
import java.util.Set;
import java.util.List;
/**
* @author Eugene.Kudelevsky
@@ -64,8 +59,6 @@ public abstract class AndroidLogcatToolWindowView implements Disposable {
private JComboBox myDeviceCombo;
private JPanel myConsoleWrapper;
private JPanel myPanel;
private AndroidPlatformsComboBox myAndroidPlatformsCombo;
private JPanel myAndroidPlatformPanel;
private JButton myClearLogButton;
private JPanel mySearchComponentWrapper;
private volatile IDevice myDevice;
@@ -101,21 +94,6 @@ public abstract class AndroidLogcatToolWindowView implements Disposable {
});
}
private static Set<Library> getAndroidPlatformLibraries(Project project) {
ModuleManager manager = ModuleManager.getInstance(project);
Set<Library> result = new HashSet<Library>();
for (Module module : manager.getModules()) {
AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet != null) {
AndroidPlatform platform = facet.getConfiguration().getAndroidPlatform();
if (platform != null) {
result.add(platform.getLibrary());
}
}
}
return result;
}
private class MyLoggingReader extends AndroidLoggingReader {
@NotNull
protected Object getLock() {
@@ -132,23 +110,18 @@ public abstract class AndroidLogcatToolWindowView implements Disposable {
myProject = project;
Disposer.register(myProject, this);
final Set<Library> librarySet = getAndroidPlatformLibraries(project);
myAndroidPlatformsCombo.setFilter(new Condition<Library>() {
public boolean value(Library library) {
return librarySet.contains(library);
}
});
myAndroidPlatformsCombo.rebuildPlatforms();
if (myAndroidPlatformsCombo.getItemCount() > 0) {
myAndroidPlatformsCombo.setSelectedIndex(0);
List<AndroidFacet> facets = ProjectFacetManager.getInstance(project).getFacets(AndroidFacet.ID);
if (facets.size() == 0) {
Messages.showErrorDialog(project, AndroidBundle.message("android.logcat.no.android.facets.error"), CommonBundle.getErrorTitle());
return;
}
if (librarySet.size() < 2) {
if (librarySet.size() == 0) {
Messages.showErrorDialog(project, AndroidBundle.message("specify.platform.error"), CommonBundle.getErrorTitle());
return;
}
myAndroidPlatformPanel.setVisible(false);
AndroidFacet facet = facets.get(0);
AndroidPlatform platform = facet.getConfiguration().getAndroidPlatform();
if (platform == null) {
Messages.showErrorDialog(project, AndroidBundle.message("specify.platform.error"), CommonBundle.getErrorTitle());
return;
}
myDeviceCombo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
updateLogConsole();
@@ -222,7 +195,6 @@ public abstract class AndroidLogcatToolWindowView implements Disposable {
protected abstract boolean isActive();
public void activate() {
updatePlatforms();
updateDevices();
updateLogConsole();
if (myLogConsole != null) {
@@ -230,17 +202,6 @@ public abstract class AndroidLogcatToolWindowView implements Disposable {
}
}
private void updatePlatforms() {
Object selectedItem = myAndroidPlatformsCombo.getSelectedItem();
myAndroidPlatformsCombo.rebuildPlatforms();
if (selectedItem != null) {
myAndroidPlatformsCombo.setSelectedItem(selectedItem);
}
else if (myAndroidPlatformsCombo.getItemCount() > 0) {
myAndroidPlatformsCombo.setSelectedIndex(0);
}
}
private void updateLogConsole() {
IDevice device = (IDevice)myDeviceCombo.getSelectedItem();
if (myDevice != device) {
@@ -262,9 +223,9 @@ public abstract class AndroidLogcatToolWindowView implements Disposable {
}
private void updateDevices() {
AndroidPlatform platform = myAndroidPlatformsCombo.getSelectedPlatform();
if (platform != null) {
final AndroidDebugBridge debugBridge = platform.getSdk().getDebugBridge(myProject);
List<AndroidFacet> facets = ProjectFacetManager.getInstance(myProject).getFacets(AndroidFacet.ID);
if (facets.size() > 0) {
final AndroidDebugBridge debugBridge = facets.get(0).getDebugBridge();
if (debugBridge != null) {
IDevice[] devices;
try {
@@ -295,16 +256,6 @@ public abstract class AndroidLogcatToolWindowView implements Disposable {
return myPanel;
}
private void createUIComponents() {
final LibraryTable table = LibraryTablesRegistrar.getInstance().getLibraryTable();
myAndroidPlatformsCombo = new AndroidPlatformsComboBox(new Computable<LibraryTable.ModifiableModel>() {
@Override
public LibraryTable.ModifiableModel compute() {
return table.getModifiableModel();
}
}, null);
}
public void dispose() {
try {
AdbManager.run(new Runnable() {