diff --git a/plugins/android/resources/messages/AndroidBundle.properties b/plugins/android/resources/messages/AndroidBundle.properties index 6e7666944d41..9336260646ca 100644 --- a/plugins/android/resources/messages/AndroidBundle.properties +++ b/plugins/android/resources/messages/AndroidBundle.properties @@ -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? \ No newline at end of file +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 \ No newline at end of file diff --git a/plugins/android/src/org/jetbrains/android/logcat/AndroidLogcatToolWindowView.form b/plugins/android/src/org/jetbrains/android/logcat/AndroidLogcatToolWindowView.form index 182776198619..852e0928f778 100644 --- a/plugins/android/src/org/jetbrains/android/logcat/AndroidLogcatToolWindowView.form +++ b/plugins/android/src/org/jetbrains/android/logcat/AndroidLogcatToolWindowView.form @@ -1,6 +1,6 @@
- + @@ -10,7 +10,7 @@ - + @@ -18,7 +18,7 @@ - + @@ -28,7 +28,7 @@ - + @@ -36,7 +36,7 @@ - + @@ -44,38 +44,12 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/plugins/android/src/org/jetbrains/android/logcat/AndroidLogcatToolWindowView.java b/plugins/android/src/org/jetbrains/android/logcat/AndroidLogcatToolWindowView.java index f09c19223c27..11e4ab671443 100644 --- a/plugins/android/src/org/jetbrains/android/logcat/AndroidLogcatToolWindowView.java +++ b/plugins/android/src/org/jetbrains/android/logcat/AndroidLogcatToolWindowView.java @@ -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 getAndroidPlatformLibraries(Project project) { - ModuleManager manager = ModuleManager.getInstance(project); - Set result = new HashSet(); - 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 librarySet = getAndroidPlatformLibraries(project); - myAndroidPlatformsCombo.setFilter(new Condition() { - public boolean value(Library library) { - return librarySet.contains(library); - } - }); - myAndroidPlatformsCombo.rebuildPlatforms(); - if (myAndroidPlatformsCombo.getItemCount() > 0) { - myAndroidPlatformsCombo.setSelectedIndex(0); + List 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 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() { - @Override - public LibraryTable.ModifiableModel compute() { - return table.getModifiableModel(); - } - }, null); - } - public void dispose() { try { AdbManager.run(new Runnable() {