diff options
11 files changed, 153 insertions, 21 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/images/avd_manager.png b/eclipse/plugins/com.android.ide.eclipse.monitor/images/avd_manager.png Binary files differnew file mode 100644 index 0000000..f8a173c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.monitor/images/avd_manager.png diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/images/sdk_manager.png b/eclipse/plugins/com.android.ide.eclipse.monitor/images/sdk_manager.png Binary files differnew file mode 100644 index 0000000..08ffda8 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.monitor/images/sdk_manager.png diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/plugin.xml b/eclipse/plugins/com.android.ide.eclipse.monitor/plugin.xml index dfaf712..7a09eda 100644 --- a/eclipse/plugins/com.android.ide.eclipse.monitor/plugin.xml +++ b/eclipse/plugins/com.android.ide.eclipse.monitor/plugin.xml @@ -91,4 +91,30 @@ class="com.android.ide.eclipse.monitor.MonitorStartup"> </startup> </extension> + <extension + point="org.eclipse.ui.actionSets"> + <actionSet + id="monitor.actionSet.AvdSdkManager" + label="Android SDK and AVD Manager" + visible="true"> + <action + class="com.android.ide.eclipse.monitor.actions.AvdManagerAction" + icon="images/avd_manager.png" + id="com.android.ide.eclipse.monitor.avdmanager" + label="Android Virtual Device Manager" + menubarPath="Window/additions" + style="push" + toolbarPath="android_project"> + </action> + <action + class="com.android.ide.eclipse.monitor.actions.SdkManagerAction" + icon="images/sdk_manager.png" + id="com.android.ide.eclipse.monitor.sdkmanager" + label="Android SDK Manager" + menubarPath="Window/additions" + style="push" + toolbarPath="android_project"> + </action> + </actionSet> + </extension> </plugin> diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorApplication.java b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorApplication.java index c260240..9c66205 100644 --- a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorApplication.java +++ b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorApplication.java @@ -57,7 +57,7 @@ public class MonitorApplication implements IApplication { // exit with return code -1 return Integer.valueOf(-1); } - MonitorPlugin.getDefault().setSdkPath(sdkPath); + MonitorPlugin.getDefault().setSdkFolder(new File(sdkPath)); // install platform tools if necessary ILogger sdkLog = NullLogger.getLogger(); @@ -152,7 +152,7 @@ public class MonitorApplication implements IApplication { return false; } - SdkToolsLocator locator = new SdkToolsLocator(sdkLocation); + SdkToolsLocator locator = new SdkToolsLocator(new File(sdkLocation)); return locator.isValidInstallation() == SdkInstallStatus.VALID; } diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorPlugin.java b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorPlugin.java index ca2c292..a61eb4a 100644 --- a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorPlugin.java +++ b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorPlugin.java @@ -22,11 +22,13 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; +import java.io.File; + public class MonitorPlugin extends AbstractUIPlugin { public static final String PLUGIN_ID = "com.android.ide.eclipse.monitor"; //$NON-NLS-1$ private static MonitorPlugin sPlugin; private static final DdmsPreferenceStore sDdmsPreferenceStore = new DdmsPreferenceStore(); - private String mSdkPath; + private File mSdkFolder; @Override public void start(BundleContext context) throws Exception { @@ -53,11 +55,11 @@ public class MonitorPlugin extends AbstractUIPlugin { return sDdmsPreferenceStore; } - public void setSdkPath(String sdkPath) { - mSdkPath = sdkPath; + public void setSdkFolder(File sdkFolder) { + mSdkFolder = sdkFolder; } - public String getSdkPath() { - return mSdkPath; + public File getSdkFolder() { + return mSdkFolder; } } diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorStartup.java b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorStartup.java index 8f88e56..2de260e 100644 --- a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorStartup.java +++ b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorStartup.java @@ -21,7 +21,6 @@ import com.android.sdkstats.SdkStatsService; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.ui.IStartup; @@ -39,12 +38,12 @@ public class MonitorStartup implements IStartup { @Override protected IStatus run(IProgressMonitor monitor) { SdkStatsService stats = new SdkStatsService(); - String sdkPath = MonitorPlugin.getDefault().getSdkPath(); - if (sdkPath == null) { + File sdkFolder = MonitorPlugin.getDefault().getSdkFolder(); + if (sdkFolder == null) { return Status.OK_STATUS; } - String toolsPath = new Path(sdkPath).append(SdkConstants.FD_TOOLS).toString(); + String toolsPath = new File(sdkFolder, SdkConstants.FD_TOOLS).getAbsolutePath(); ping(stats, toolsPath); return Status.OK_STATUS; } diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/SdkLocationChooserDialog.java b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/SdkLocationChooserDialog.java index 76e2350..04f60c7 100644 --- a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/SdkLocationChooserDialog.java +++ b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/SdkLocationChooserDialog.java @@ -36,6 +36,8 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; +import java.io.File; + public class SdkLocationChooserDialog extends Dialog { private static final String TITLE = "Android Device Monitor"; private static final String DEFAULT_MESSAGE = "Provide the path to the Android SDK"; @@ -96,7 +98,7 @@ public class SdkLocationChooserDialog extends Dialog { } private void validateInstall() { - SdkToolsLocator locator = new SdkToolsLocator(mTextBox.getText()); + SdkToolsLocator locator = new SdkToolsLocator(new File(mTextBox.getText())); SdkInstallStatus status = locator.isValidInstallation(); if (status.isValid()) { mStatusLabel.setText(""); diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/SdkToolsLocator.java b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/SdkToolsLocator.java index 70c6ee3..64129d2 100644 --- a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/SdkToolsLocator.java +++ b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/SdkToolsLocator.java @@ -46,30 +46,30 @@ public class SdkToolsLocator { public static final String FN_HPROF_CONV = "hprof-conv" + PLATFORM_EXECUTABLE_EXTENSION; //$NON-NLS-1$ public static final String FN_TRACEVIEW = "traceview" + PLATFORM_SCRIPT_EXTENSION; //$NON-NLS-1$ - private final String mSdkPath; + private final File mSdkFolder; - public SdkToolsLocator(String sdkPath) { - mSdkPath = sdkPath; + public SdkToolsLocator(File sdkFolder) { + mSdkFolder = sdkFolder; } public String getAdbLocation() { - return getSdkPlatformToolsFolder() + SdkConstants.FN_ADB; + return new File(getSdkPlatformToolsFolder(), SdkConstants.FN_ADB).getAbsolutePath(); } public String getTraceViewLocation() { - return getSdkToolsFolder() + FN_TRACEVIEW; + return new File(getSdkToolsFolder(), FN_TRACEVIEW).getAbsolutePath(); } public String getHprofConvLocation() { - return getSdkToolsFolder() + FN_HPROF_CONV; + return new File(getSdkToolsFolder(), FN_HPROF_CONV).getAbsolutePath(); } private String getSdkToolsFolder() { - return mSdkPath + "/tools/"; //$NON-NLS-1$ + return new File(mSdkFolder, SdkConstants.FD_TOOLS).getAbsolutePath(); } private String getSdkPlatformToolsFolder() { - return mSdkPath + "/platform-tools/"; //$NON-NLS-1$ + return new File(mSdkFolder, SdkConstants.FD_PLATFORM_TOOLS).getAbsolutePath(); } public SdkInstallStatus isValidInstallation() { diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/ToolsLocator.java b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/ToolsLocator.java index ebee3c6..7597181 100644 --- a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/ToolsLocator.java +++ b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/ToolsLocator.java @@ -22,7 +22,7 @@ public class ToolsLocator implements IToolsLocator { private SdkToolsLocator mLocator; public ToolsLocator() { - mLocator = new SdkToolsLocator(MonitorPlugin.getDefault().getSdkPath()); + mLocator = new SdkToolsLocator(MonitorPlugin.getDefault().getSdkFolder()); } @Override diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/actions/AvdManagerAction.java b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/actions/AvdManagerAction.java new file mode 100644 index 0000000..2510bd3 --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/actions/AvdManagerAction.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.ide.eclipse.monitor.actions; + +public class AvdManagerAction extends SdkManagerAction { + @Override + protected String getAndroidBatArgument() { + return "avd"; + } +}
\ No newline at end of file diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/actions/SdkManagerAction.java b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/actions/SdkManagerAction.java new file mode 100644 index 0000000..573ed7c --- /dev/null +++ b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/actions/SdkManagerAction.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.ide.eclipse.monitor.actions; + +import com.android.SdkConstants; +import com.android.ide.eclipse.monitor.MonitorPlugin; + +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.dialogs.ErrorDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.eclipse.ui.PlatformUI; + +import java.io.File; +import java.io.IOException; + +public class SdkManagerAction implements IWorkbenchWindowActionDelegate { + @Override + public void run(IAction action) { + File sdk = MonitorPlugin.getDefault().getSdkFolder(); + if (sdk != null) { + File tools = new File(sdk, SdkConstants.FD_TOOLS); + File androidBat = new File(tools, SdkConstants.androidCmdName()); + if (androidBat.exists()) { + String[] cmd = new String[] { + androidBat.getAbsolutePath(), + getAndroidBatArgument(), + }; + try { + Runtime.getRuntime().exec(cmd); + } catch (IOException e) { + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (window != null) { + ErrorDialog.openError( + window.getShell(), + "Monitor", + "Error while launching SDK Manager", + new Status(Status.ERROR, + MonitorPlugin.PLUGIN_ID, + "Error while launching SDK Manager", + e)); + } + } + } + } + } + + protected String getAndroidBatArgument() { + return "sdk"; + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + } + + @Override + public void dispose() { + } + + @Override + public void init(IWorkbenchWindow window) { + } +} |
