diff options
-rw-r--r-- | sdkmanager/app/.classpath | 22 | ||||
-rw-r--r-- | sdkmanager/app/.project | 36 | ||||
-rw-r--r-- | sdkmanager/app/src/com/android/sdkmanager/CommandLineProcessor.java | 159 | ||||
-rw-r--r-- | sdkmanager/app/src/com/android/sdkmanager/Main.java | 140 | ||||
-rw-r--r-- | sdkmanager/app/src/com/android/sdkmanager/SdkCommandLine.java | 73 | ||||
-rw-r--r-- | sdkmanager/libs/sdkuilib/.classpath | 16 | ||||
-rw-r--r-- | sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/AvdSelector.java | 84 | ||||
-rwxr-xr-x | sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/repository/UpdaterWindow.java | 222 |
8 files changed, 504 insertions, 248 deletions
diff --git a/sdkmanager/app/.classpath b/sdkmanager/app/.classpath index cbd9d37..4f2e142 100644 --- a/sdkmanager/app/.classpath +++ b/sdkmanager/app/.classpath @@ -1,11 +1,11 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="src" path="tests"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry combineaccessrules="false" kind="src" path="/SdkLib"/> - <classpathentry combineaccessrules="false" kind="src" path="/AndroidPrefs"/> - <classpathentry combineaccessrules="false" kind="src" path="/SdkUiLib"/> - <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/> - <classpathentry kind="output" path="bin"/> -</classpath> +<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="tests"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/SdkLib"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/AndroidPrefs"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/SdkUiLib"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/sdkmanager/app/.project b/sdkmanager/app/.project index e12c17d..aa82db5 100644 --- a/sdkmanager/app/.project +++ b/sdkmanager/app/.project @@ -1,17 +1,19 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>SdkManager</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.jdt.core.javabuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.jdt.core.javanature</nature> - </natures> -</projectDescription> +<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>SdkManager</name>
+ <comment></comment>
+ <projects>
+ <project>SdkLib</project>
+ <project>SdkUiLib</project>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/sdkmanager/app/src/com/android/sdkmanager/CommandLineProcessor.java b/sdkmanager/app/src/com/android/sdkmanager/CommandLineProcessor.java index c20bfa4..4a3c16c 100644 --- a/sdkmanager/app/src/com/android/sdkmanager/CommandLineProcessor.java +++ b/sdkmanager/app/src/com/android/sdkmanager/CommandLineProcessor.java @@ -29,7 +29,7 @@ import java.util.Map.Entry; * <li>override it. * <li>pass an action array to the constructor. * <li>define flags for your actions. - * </ul> + * </ul> * <p/> * To use, call {@link #parseArgs(String[])} and then * call {@link #getValue(String, String, String)}. @@ -38,17 +38,17 @@ public class CommandLineProcessor { /** Internal verb name for internally hidden flags. */ public final static String GLOBAL_FLAG_VERB = "@@internal@@"; - + /** String to use when the verb doesn't need any object. */ public final static String NO_VERB_OBJECT = ""; - - /** The global help flag. */ + + /** The global help flag. */ public static final String KEY_HELP = "help"; /** The global verbose flag. */ public static final String KEY_VERBOSE = "verbose"; /** The global silent flag. */ public static final String KEY_SILENT = "silent"; - + /** Verb requested by the user. Null if none specified, which will be an error. */ private String mVerbRequested; /** Direct object requested by the user. Can be null. */ @@ -66,7 +66,7 @@ public class CommandLineProcessor { * </ul> */ private final String[][] mActions; - + private static final int ACTION_VERB_INDEX = 0; private static final int ACTION_OBJECT_INDEX = 1; private static final int ACTION_DESC_INDEX = 2; @@ -80,7 +80,7 @@ public class CommandLineProcessor { private final HashMap<String, Arg> mArguments = new HashMap<String, Arg>(); /** Logger */ private final ISdkLog mLog; - + public CommandLineProcessor(ISdkLog logger, String[][] actions) { mLog = logger; mActions = actions; @@ -95,7 +95,18 @@ public class CommandLineProcessor { "This help.", false); } - + + /** + * Indicates if this command-line can work when no verb is specified. + * The default is false, which generates an error when no verb/object is specified. + * Derived implementations can set this to true if they can deal with a lack + * of verb/action. + */ + public boolean acceptLackOfVerb() { + return false; + } + + //------------------ // Helpers to get flags values @@ -113,7 +124,7 @@ public class CommandLineProcessor { public boolean isHelpRequested() { return ((Boolean) getValue(GLOBAL_FLAG_VERB, NO_VERB_OBJECT, KEY_HELP)).booleanValue(); } - + /** Returns the verb name from the command-line. Can be null. */ public String getVerb() { return mVerbRequested; @@ -123,9 +134,9 @@ public class CommandLineProcessor { public String getDirectObject() { return mDirectObjectRequested; } - + //------------------ - + /** * Raw access to parsed parameter values. * <p/> @@ -133,10 +144,10 @@ public class CommandLineProcessor { * command line are returned first. Otherwise one with a non-null value is returned. * <p/> * Both a verb and a direct object filter can be specified. When they are non-null they limit - * the scope of the search. + * the scope of the search. * <p/> * If nothing has been found, return the last default value seen matching the filter. - * + * * @param verb The verb name, including {@link #GLOBAL_FLAG_VERB}. If null, all possible * verbs that match the direct object condition will be examined and the first * value set will be used. @@ -153,7 +164,7 @@ public class CommandLineProcessor { Arg arg = mArguments.get(key); return arg.getCurrentValue(); } - + Object lastDefault = null; for (Arg arg : mArguments.values()) { if (arg.getLongArg().equals(longFlagName)) { @@ -169,7 +180,7 @@ public class CommandLineProcessor { } } } - + return lastDefault; } @@ -191,7 +202,7 @@ public class CommandLineProcessor { * Parses the command-line arguments. * <p/> * This method will exit and not return if a parsing error arise. - * + * * @param args The arguments typically received by a main method. */ public void parseArgs(String[] args) { @@ -209,7 +220,7 @@ public class CommandLineProcessor { } else if (a.startsWith("-")) { arg = findShortArg(verb, directObject, a.substring(1)); } - + // No matching argument name found if (arg == null) { // Does it looks like a dashed parameter? @@ -217,7 +228,7 @@ public class CommandLineProcessor { if (verb == null || directObject == null) { // It looks like a dashed parameter and we don't have a a verb/object // set yet, the parameter was just given too early. - + needsHelp = String.format( "Flag '%1$s' is not a valid global flag. Did you mean to specify it after the verb/object name?", a); @@ -225,14 +236,14 @@ public class CommandLineProcessor { } else { // It looks like a dashed parameter and but it is unknown by this // verb-object combination - + needsHelp = String.format( "Flag '%1$s' is not valid for '%2$s %3$s'.", a, verb, directObject); return; } } - + if (verb == null) { // Fill verb first. Find it. for (String[] actionDesc : mActions) { @@ -241,7 +252,7 @@ public class CommandLineProcessor { break; } } - + // Error if it was not a valid verb if (verb == null) { needsHelp = String.format( @@ -249,7 +260,7 @@ public class CommandLineProcessor { a); return; } - + } else if (directObject == null) { // Then fill the direct object. Find it. for (String[] actionDesc : mActions) { @@ -266,20 +277,20 @@ public class CommandLineProcessor { } } } - + // Error if it was not a valid object for that verb if (directObject == null) { needsHelp = String.format( "Expected verb after global parameters but found '%1$s' instead.", a); return; - + } } } else if (arg != null) { // This argument was present on the command line arg.setInCommandLine(true); - + // Process keyword String error = null; if (arg.getMode().needsExtra()) { @@ -287,11 +298,11 @@ public class CommandLineProcessor { needsHelp = String.format("Missing argument for flag %1$s.", a); return; } - + error = arg.getMode().process(arg, args[i]); } else { error = arg.getMode().process(arg, null); - + // If we just toggled help, we want to exit now without printing any error. // We do this test here only when a Boolean flag is toggled since booleans // are the only flags that don't take parameters and help is a boolean. @@ -302,18 +313,18 @@ public class CommandLineProcessor { return; } } - + if (error != null) { needsHelp = String.format("Invalid usage for flag %1$s: %2$s.", a, error); return; } } } - + if (needsHelp == null) { - if (verb == null) { + if (verb == null && !acceptLackOfVerb()) { needsHelp = "Missing verb name."; - } else { + } else if (verb != null) { if (directObject == null) { // Make sure this verb has an optional direct object for (String[] actionDesc : mActions) { @@ -323,13 +334,13 @@ public class CommandLineProcessor { break; } } - + if (directObject == null) { needsHelp = String.format("Missing object name for verb '%1$s'.", verb); return; } } - + // Validate that all mandatory arguments are non-null for this action String missing = null; boolean plural = false; @@ -347,7 +358,7 @@ public class CommandLineProcessor { } } } - + if (missing != null) { needsHelp = String.format( "The %1$s %2$s must be defined for action '%3$s %4$s'", @@ -367,7 +378,7 @@ public class CommandLineProcessor { } } } - + /** * Finds an {@link Arg} given an action name and a long flag name. * @return The {@link Arg} found or null. @@ -409,23 +420,23 @@ public class CommandLineProcessor { /** * Prints the help/usage and exits. - * - * @param errorFormat Optional error message to print prior to usage using String.format + * + * @param errorFormat Optional error message to print prior to usage using String.format * @param args Arguments for String.format */ public void printHelpAndExit(String errorFormat, Object... args) { printHelpAndExitForAction(null /*verb*/, null /*directObject*/, errorFormat, args); } - + /** * Prints the help/usage and exits. - * + * * @param verb If null, displays help for all verbs. If not null, display help only * for that specific verb. In all cases also displays general usage and action list. * @param directObject If null, displays help for all verb objects. * If not null, displays help only for that specific action * In all cases also display general usage and action list. - * @param errorFormat Optional error message to print prior to usage using String.format + * @param errorFormat Optional error message to print prior to usage using String.format * @param args Arguments for String.format */ public void printHelpAndExitForAction(String verb, String directObject, @@ -433,7 +444,7 @@ public class CommandLineProcessor { if (errorFormat != null) { stderr(errorFormat, args); } - + /* * usage should fit in 80 columns * 12345678901234567890123456789012345678901234567890123456789012345678901234567890 @@ -448,14 +459,14 @@ public class CommandLineProcessor { if (verb == null || directObject == null) { stdout("\nValid actions are composed of a verb and an optional direct object:"); for (String[] action : mActions) { - + stdout("- %1$6s %2$-7s: %3$s", action[ACTION_VERB_INDEX], action[ACTION_OBJECT_INDEX], action[ACTION_DESC_INDEX]); } } - + for (String[] action : mActions) { if (verb == null || verb.equals(action[ACTION_VERB_INDEX])) { if (directObject == null || directObject.equals(action[ACTION_OBJECT_INDEX])) { @@ -468,7 +479,7 @@ public class CommandLineProcessor { } } } - + exit(); } @@ -480,12 +491,12 @@ public class CommandLineProcessor { for (Entry<String, Arg> entry : mArguments.entrySet()) { Arg arg = entry.getValue(); if (arg.getVerb().equals(verb) && arg.getDirectObject().equals(directObject)) { - + String value = ""; String required = ""; if (arg.isMandatory()) { required = " [required]"; - + } else { if (arg.getDefaultValue() instanceof String[]) { for (String v : (String[]) arg.getDefaultValue()) { @@ -504,7 +515,7 @@ public class CommandLineProcessor { value = " [Default: " + value + "]"; } } - + stdout(" -%1$s %2$-10s %3$s%4$s%5$s", arg.getShortArg(), "--" + arg.getLongArg(), @@ -514,14 +525,14 @@ public class CommandLineProcessor { numOptions++; } } - + if (numOptions == 0) { stdout(" No options"); } } //---- - + /** * The mode of an argument specifies the type of variable it represents, * whether an extra parameter is required after the flag and how to parse it. @@ -558,7 +569,7 @@ public class CommandLineProcessor { } } }, - + /** Argument value is a String. Default value is a String[]. */ ENUM { @Override @@ -574,7 +585,7 @@ public class CommandLineProcessor { arg.setCurrentValue(extra); return null; } - + if (desc.length() != 0) { desc.append(", "); } @@ -584,7 +595,7 @@ public class CommandLineProcessor { return String.format("'%1$s' is not one of %2$s", extra, desc.toString()); } }, - + /** Argument value is a String. Default value is a null. */ STRING { @Override @@ -597,7 +608,7 @@ public class CommandLineProcessor { return null; } }; - + /** * Returns true if this mode requires an extra parameter. */ @@ -605,9 +616,9 @@ public class CommandLineProcessor { /** * Processes the flag for this argument. - * + * * @param arg The argument being processed. - * @param extra The extra parameter. Null if {@link #needsExtra()} returned false. + * @param extra The extra parameter. Null if {@link #needsExtra()} returned false. * @return An error string or null if there's no error. */ public abstract String process(Arg arg, String extra); @@ -618,7 +629,7 @@ public class CommandLineProcessor { * Arguments must have a short version (one letter), a long version name and a description. * They can have a default value, or it can be null. * Depending on the {@link MODE}, the default value can be a Boolean, an Integer, a String - * or a String array (in which case the first item is the current by default.) + * or a String array (in which case the first item is the current by default.) */ static class Arg { /** Verb for that argument. Never null. */ @@ -644,9 +655,9 @@ public class CommandLineProcessor { /** * Creates a new argument flag description. - * + * * @param mode The {@link MODE} for the argument. - * @param mandatory True if this argument is mandatory for this action. + * @param mandatory True if this argument is mandatory for this action. * @param directObject The action name. Can be #NO_VERB_OBJECT or #INTERNAL_FLAG. * @param shortName The one-letter short argument name. Cannot be empty nor null. * @param longName The long argument name. Cannot be empty nor null. @@ -676,27 +687,27 @@ public class CommandLineProcessor { mCurrentValue = mDefaultValue; } } - + /** Return true if this argument is mandatory for this verb/directobject. */ public boolean isMandatory() { return mMandatory; } - + /** Returns the 1-letter short name of the argument, e.g. -v. */ public String getShortArg() { return mShortName; } - + /** Returns the long name of the argument, e.g. --verbose. */ public String getLongArg() { return mLongName; } - + /** Returns the description. Never null. */ public String getDescription() { return mDescription; } - + /** Returns the verb for that argument. Never null. */ public String getVerb() { return mVerb; @@ -706,12 +717,12 @@ public class CommandLineProcessor { public String getDirectObject() { return mDirectObject; } - + /** Returns the default value. Can be null. */ public Object getDefaultValue() { return mDefaultValue; } - + /** Returns the current value. Initially set to the default value. Can be null. */ public Object getCurrentValue() { return mCurrentValue; @@ -721,26 +732,26 @@ public class CommandLineProcessor { public void setCurrentValue(Object currentValue) { mCurrentValue = currentValue; } - + /** Returns the argument mode (type + process method). Never null. */ public MODE getMode() { return mMode; } - + /** Returns true if the argument has been used on the command line. */ public boolean isInCommandLine() { return mInCommandLine; } - + /** Sets if the argument has been used on the command line. */ public void setInCommandLine(boolean inCommandLine) { mInCommandLine = inCommandLine; } } - + /** * Internal helper to define a new argument for a give action. - * + * * @param mode The {@link MODE} for the argument. * @param verb The verb name. Can be #INTERNAL_VERB. * @param directObject The action name. Can be #NO_VERB_OBJECT or #INTERNAL_FLAG. @@ -756,11 +767,11 @@ public class CommandLineProcessor { String shortName, String longName, String description, Object defaultValue) { assert(mandatory || mode == MODE.BOOLEAN); // a boolean mode cannot be mandatory - + if (directObject == null) { directObject = NO_VERB_OBJECT; } - + String key = verb + "/" + directObject + "/" + longName; mArguments.put(key, new Arg(mode, mandatory, verb, directObject, shortName, longName, description, defaultValue)); @@ -777,7 +788,7 @@ public class CommandLineProcessor { /** * Prints a line to stdout. * This is protected so that it can be overridden in unit tests. - * + * * @param format The string to be formatted. Cannot be null. * @param args Format arguments. */ @@ -788,7 +799,7 @@ public class CommandLineProcessor { /** * Prints a line to stderr. * This is protected so that it can be overridden in unit tests. - * + * * @param format The string to be formatted. Cannot be null. * @param args Format arguments. */ diff --git a/sdkmanager/app/src/com/android/sdkmanager/Main.java b/sdkmanager/app/src/com/android/sdkmanager/Main.java index 5386c89..a5550b5 100644 --- a/sdkmanager/app/src/com/android/sdkmanager/Main.java +++ b/sdkmanager/app/src/com/android/sdkmanager/Main.java @@ -29,6 +29,7 @@ import com.android.sdklib.internal.avd.AvdManager.AvdInfo; import com.android.sdklib.internal.avd.HardwareProperties.HardwareProperty; import com.android.sdklib.internal.project.ProjectCreator; import com.android.sdklib.internal.project.ProjectCreator.OutputLevel; +import com.android.sdkuilib.repository.UpdaterWindow; import java.io.File; import java.io.IOException; @@ -46,11 +47,11 @@ class Main { /** Java property that defines the working directory. On Windows the current working directory * is actually the tools dir, in which case this is used to get the original CWD. */ private final static String WORKDIR = "com.android.sdkmanager.workdir"; - + private final static String[] BOOLEAN_YES_REPLIES = new String[] { "yes", "y" }; private final static String[] BOOLEAN_NO_REPLIES = new String[] { "no", "n" }; - - + + /** Path to the SDK folder. This is the parent of {@link #TOOLSDIR}. */ private String mSdkFolder; /** Logger object. Use this to print normal output, warnings or errors. */ @@ -65,7 +66,7 @@ class Main { public static void main(String[] args) { new Main().run(args); } - + /** * Runs the sdk manager app */ @@ -124,7 +125,7 @@ class Main { // for debugging, it's easier to override using the process environment toolsDirProp = System.getenv(TOOLSDIR); } - + if (toolsDirProp != null) { // got back a level for the SDK folder File tools; @@ -145,7 +146,7 @@ class Main { errorAndExit("The tools directory property is not set, please make sure you are executing %1$s", SdkConstants.androidCmdName()); } - + // We might get passed a property for the working directory // Either it is a valid directory and mWorkDir is set to it's absolute canonical value // or mWorkDir remains null. @@ -172,19 +173,19 @@ class Main { */ private void parseSdk() { mSdkManager = SdkManager.createManager(mSdkFolder, mSdkLog); - + if (mSdkManager == null) { errorAndExit("Unable to parse SDK content."); } } - + /** * Actually do an action... */ private void doAction() { String verb = mSdkCommandLine.getVerb(); String directObject = mSdkCommandLine.getDirectObject(); - + if (SdkCommandLine.VERB_LIST.equals(verb)) { // list action. if (SdkCommandLine.OBJECT_TARGET.equals(directObject)) { @@ -220,13 +221,28 @@ class Main { SdkCommandLine.OBJECT_PROJECT.equals(directObject)) { updateProject(); + } else if (verb == null && directObject == null) { + showMainWindow(); + } else { mSdkCommandLine.printHelpAndExit(null); } } /** - * Creates a new Android project based on command-line parameters + * Display the main SdkManager app window + */ + private void showMainWindow() { + try { + UpdaterWindow window = new UpdaterWindow(); + window.open(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * Creates a new Android project based on command-line parameters */ private void createProject() { // get the target and try to resolve it. @@ -237,7 +253,7 @@ class Main { SdkConstants.androidCmdName()); } IAndroidTarget target = targets[targetId - 1]; - + ProjectCreator creator = new ProjectCreator(mSdkFolder, mSdkCommandLine.isVerbose() ? OutputLevel.VERBOSE : mSdkCommandLine.isSilent() ? OutputLevel.SILENT : @@ -249,7 +265,7 @@ class Main { String projectName = mSdkCommandLine.getParamName(); String packageName = mSdkCommandLine.getParamProjectPackage(); String activityName = mSdkCommandLine.getParamProjectActivity(); - + if (projectName != null && !ProjectCreator.RE_PROJECT_NAME.matcher(projectName).matches()) { errorAndExit( @@ -285,7 +301,7 @@ class Main { } /** - * Updates an existing Android project based on command-line parameters + * Updates an existing Android project based on command-line parameters */ private void updateProject() { // get the target and try to resolve it. @@ -299,7 +315,7 @@ class Main { } target = targets[targetId - 1]; } - + ProjectCreator creator = new ProjectCreator(mSdkFolder, mSdkCommandLine.isVerbose() ? OutputLevel.VERBOSE : mSdkCommandLine.isSilent() ? OutputLevel.SILENT : @@ -307,7 +323,7 @@ class Main { mSdkLog); String projectDir = getProjectLocation(mSdkCommandLine.getParamLocationPath()); - + creator.updateProject(projectDir, target, mSdkCommandLine.getParamName()); @@ -316,12 +332,12 @@ class Main { /** * Adjusts the project location to make it absolute & canonical relative to the * working directory, if any. - * + * * @return The project absolute path relative to {@link #mWorkDir} or the original * newProjectLocation otherwise. */ private String getProjectLocation(String newProjectLocation) { - + // If the new project location is absolute, use it as-is File projectDir = new File(newProjectLocation); if (projectDir.isAbsolute()) { @@ -336,7 +352,7 @@ class Main { // Combine then and get an absolute canonical directory try { projectDir = new File(mWorkDir, newProjectLocation).getCanonicalFile(); - + return projectDir.getPath(); } catch (IOException e) { errorAndExit("Failed to combine working directory '%1$s' with project location '%2$s': %3$s", @@ -368,7 +384,7 @@ class Main { } mSdkLog.printf(" Based on Android %s (API level %d)\n", target.getApiVersionName(), target.getApiVersionNumber()); - + // display the optional libraries. IOptionalLibrary[] libraries = target.getOptionalLibraries(); if (libraries != null) { @@ -384,7 +400,7 @@ class Main { // get the target skins displaySkinList(target, " Skins: "); - + index++; } } @@ -405,7 +421,7 @@ class Main { first = false; } mSdkLog.printf(skin); - + if (skin.equals(defaultSkin)) { mSdkLog.printf(" (default)"); } @@ -415,7 +431,7 @@ class Main { mSdkLog.printf("no skins.\n"); } } - + /** * Displays the list of available AVDs. */ @@ -445,7 +461,7 @@ class Main { mSdkLog.printf(" Based on Android %s (API level %d)\n", target .getApiVersionName(), target.getApiVersionNumber()); } - + // display some extra values. Map<String, String> properties = info.getProperties(); if (properties != null) { @@ -495,7 +511,7 @@ class Main { // find a matching target int targetId = mSdkCommandLine.getParamTargetId(); IAndroidTarget target = null; - + if (targetId >= 1 && targetId <= mSdkManager.getTargets().length) { target = mSdkManager.getTargets()[targetId-1]; // target it is 1-based } else { @@ -508,14 +524,14 @@ class Main { AvdManager avdManager = new AvdManager(mSdkManager, mSdkLog); String avdName = mSdkCommandLine.getParamName(); - + if (!AvdManager.RE_AVD_NAME.matcher(avdName).matches()) { errorAndExit( "AVD name '%1$s' contains invalid characters.\nAllowed characters are: %2$s", avdName, AvdManager.CHARS_AVD_NAME); return; } - + AvdInfo info = avdManager.getAvd(avdName, false /*validAvdOnly*/); if (info != null) { if (removePrevious) { @@ -550,7 +566,7 @@ class Main { if (removePrevious) { oldAvdInfo = avdManager.getAvd(avdName, false /*validAvdOnly*/); } - + // Validate skin is either default (empty) or NNNxMMM or a valid skin name. String skin = mSdkCommandLine.getParamSkin(); if (skin != null && skin.length() == 0) { @@ -566,7 +582,7 @@ class Main { break; } } - + // Is it NNNxMMM? if (!valid) { valid = AvdManager.NUMERIC_SKIN_SIZE.matcher(skin).matches(); @@ -578,7 +594,7 @@ class Main { return; } } - + AvdInfo newAvdInfo = avdManager.createAvd(avdFolder, avdName, target, @@ -586,7 +602,7 @@ class Main { mSdkCommandLine.getParamSdCard(), hardwareConfig, removePrevious); - + } catch (AndroidLocationException e) { errorAndExit(e.getMessage()); } @@ -601,18 +617,18 @@ class Main { String avdName = mSdkCommandLine.getParamName(); AvdManager avdManager = new AvdManager(mSdkManager, mSdkLog); AvdInfo info = avdManager.getAvd(avdName, false /*validAvdOnly*/); - + if (info == null) { errorAndExit("There is no Android Virtual Device named '%s'.", avdName); return; } - + avdManager.deleteAvd(info, mSdkLog); } catch (AndroidLocationException e) { errorAndExit(e.getMessage()); } } - + /** * Moves an AVD. */ @@ -621,12 +637,12 @@ class Main { String avdName = mSdkCommandLine.getParamName(); AvdManager avdManager = new AvdManager(mSdkManager, mSdkLog); AvdInfo info = avdManager.getAvd(avdName, true /*validAvdOnly*/); - + if (info == null) { errorAndExit("There is no valid Android Virtual Device named '%s'.", avdName); return; } - + // This is a rename if there's a new name for the AVD String newName = mSdkCommandLine.getParamMoveNewName(); if (newName != null && newName.equals(info.getName())) { @@ -647,17 +663,17 @@ class Main { } } catch (IOException e) { // Fail to resolve canonical path. Fail now since a move operation might fail - // later and be harder to recover from. + // later and be harder to recover from. errorAndExit(e.getMessage()); return; } } - + if (newName == null && paramFolderPath == null) { mSdkLog.warning("Move operation aborted: same AVD name, same canonical data path"); return; } - + // If a rename was requested and no data move was requested, check if the original // data path is our default constructed from the AVD name. In this case we still want // to rename that folder too. @@ -674,12 +690,12 @@ class Main { newName + AvdManager.AVD_FOLDER_EXTENSION); paramFolderPath = f.getCanonicalPath(); } catch (IOException e) { - // Fail to resolve canonical path. Fail now rather than later. + // Fail to resolve canonical path. Fail now rather than later. errorAndExit(e.getMessage()); } } } - + // Check for conflicts if (newName != null) { if (avdManager.getAvd(newName, false /*validAvdOnly*/) != null) { @@ -699,7 +715,7 @@ class Main { "There is already a file or directory at '%s'.\nUse --path to specify a different data folder.", paramFolderPath); } - + avdManager.moveAvd(info, newName, paramFolderPath, mSdkLog); } catch (AndroidLocationException e) { errorAndExit(e.getMessage()); @@ -707,7 +723,7 @@ class Main { errorAndExit(e.getMessage()); } } - + /** * Updates a broken AVD. */ @@ -722,20 +738,20 @@ class Main { errorAndExit(e.getMessage()); } } - + /** * Prompts the user to setup a hardware config for a Platform-based AVD. - * @throws IOException + * @throws IOException */ private Map<String, String> promptForHardware(IAndroidTarget createTarget) throws IOException { byte[] readLineBuffer = new byte[256]; String result; String defaultAnswer = "no"; - + mSdkLog.printf("%s is a basic Android platform.\n", createTarget.getName()); mSdkLog.printf("Do you wish to create a custom hardware profile [%s]", defaultAnswer); - + result = readLine(readLineBuffer).trim(); // handle default: if (result.length() == 0) { @@ -746,17 +762,17 @@ class Main { // no custom config. return null; } - + mSdkLog.printf("\n"); // empty line - + // get the list of possible hardware properties File hardwareDefs = new File (mSdkFolder + File.separator + SdkConstants.OS_SDK_TOOLS_LIB_FOLDER, SdkConstants.FN_HARDWARE_INI); List<HardwareProperty> list = HardwareProperties.parseHardwareDefinitions(hardwareDefs, null /*sdkLog*/); - + HashMap<String, String> map = new HashMap<String, String>(); - + for (int i = 0 ; i < list.size() ;) { HardwareProperty property = list.get(i); @@ -768,13 +784,13 @@ class Main { } String defaultValue = property.getDefault(); - + if (defaultValue != null) { mSdkLog.printf("%s [%s]:", property.getName(), defaultValue); } else { mSdkLog.printf("%s (%s):", property.getName(), property.getType()); } - + result = readLine(readLineBuffer); if (result.length() == 0) { if (defaultValue != null) { @@ -784,7 +800,7 @@ class Main { } continue; } - + switch (property.getType()) { case BOOLEAN: try { @@ -816,13 +832,13 @@ class Main { i++; // valid reply, move to next property break; } - + mSdkLog.printf("\n"); // empty line } return map; } - + /** * Reads the line from the input stream. * @param buffer @@ -830,7 +846,7 @@ class Main { */ private String readLine(byte[] buffer) throws IOException { int count = System.in.read(buffer); - + // is the input longer than the buffer? if (count == buffer.length && buffer[count-1] != 10) { // create a new temp buffer @@ -838,7 +854,7 @@ class Main { // and read the rest String secondHalf = readLine(tempBuffer); - + // return a concat of both return new String(buffer, 0, count) + secondHalf; } @@ -847,16 +863,16 @@ class Main { while (count > 0 && (buffer[count-1] == '\r' || buffer[count-1] == '\n')) { count--; } - + return new String(buffer, 0, count); } - + /** * Returns the boolean value represented by the string. * @throws IOException If the value is not a boolean string. */ private boolean getBooleanReply(String reply) throws IOException { - + for (String valid : BOOLEAN_YES_REPLIES) { if (valid.equalsIgnoreCase(reply)) { return true; @@ -871,9 +887,9 @@ class Main { throw new IOException(String.format("%s is not a valid reply", reply)); } - + private void errorAndExit(String format, Object...args) { mSdkLog.error(null, format, args); System.exit(1); } -}
\ No newline at end of file +} diff --git a/sdkmanager/app/src/com/android/sdkmanager/SdkCommandLine.java b/sdkmanager/app/src/com/android/sdkmanager/SdkCommandLine.java index 36172e9..81f712c 100644 --- a/sdkmanager/app/src/com/android/sdkmanager/SdkCommandLine.java +++ b/sdkmanager/app/src/com/android/sdkmanager/SdkCommandLine.java @@ -72,7 +72,7 @@ public class SdkCommandLine extends CommandLineProcessor { { VERB_LIST, OBJECT_TARGET, "Lists existing targets.", OBJECT_TARGETS }, - + { VERB_CREATE, OBJECT_AVD, "Creates a new Android Virtual Device." }, { VERB_MOVE, OBJECT_AVD, @@ -81,58 +81,58 @@ public class SdkCommandLine extends CommandLineProcessor { "Deletes an Android Virtual Device." }, { VERB_UPDATE, OBJECT_AVD, "Updates an Android Virtual Device to match the folders of a new SDK." }, - + { VERB_CREATE, OBJECT_PROJECT, "Creates a new Android Project." }, { VERB_UPDATE, OBJECT_PROJECT, "Updates an Android Project (must have an AndroidManifest.xml)." }, }; - + public SdkCommandLine(ISdkLog logger) { super(logger, ACTIONS); // --- create avd --- - - define(MODE.STRING, false, + + define(MODE.STRING, false, VERB_CREATE, OBJECT_AVD, "p", KEY_PATH, "Location path of the directory where the new AVD will be created", null); - define(MODE.STRING, true, + define(MODE.STRING, true, VERB_CREATE, OBJECT_AVD, "n", KEY_NAME, "Name of the new AVD", null); - define(MODE.INTEGER, true, + define(MODE.INTEGER, true, VERB_CREATE, OBJECT_AVD, "t", KEY_TARGET_ID, "Target id of the new AVD", null); - define(MODE.STRING, false, + define(MODE.STRING, false, VERB_CREATE, OBJECT_AVD, "s", KEY_SKIN, "Skin of the new AVD", null); - define(MODE.STRING, false, + define(MODE.STRING, false, VERB_CREATE, OBJECT_AVD, "c", KEY_SDCARD, "Path to a shared SD card image, or size of a new sdcard for the new AVD", null); - define(MODE.BOOLEAN, false, + define(MODE.BOOLEAN, false, VERB_CREATE, OBJECT_AVD, "f", KEY_FORCE, "Force creation (override an existing AVD)", false); // --- delete avd --- - - define(MODE.STRING, true, + + define(MODE.STRING, true, VERB_DELETE, OBJECT_AVD, "n", KEY_NAME, "Name of the AVD to delete", null); // --- move avd --- - - define(MODE.STRING, true, + + define(MODE.STRING, true, VERB_MOVE, OBJECT_AVD, "n", KEY_NAME, "Name of the AVD to move or rename", null); - define(MODE.STRING, false, + define(MODE.STRING, false, VERB_MOVE, OBJECT_AVD, "r", KEY_RENAME, "New name of the AVD to rename", null); - define(MODE.STRING, false, + define(MODE.STRING, false, VERB_MOVE, OBJECT_AVD, "p", KEY_PATH, "New location path of the directory where to move the AVD", null); // --- update avd --- - - define(MODE.STRING, true, + + define(MODE.STRING, true, VERB_UPDATE, OBJECT_AVD, "n", KEY_NAME, "Name of the AVD to update", null); @@ -140,51 +140,56 @@ public class SdkCommandLine extends CommandLineProcessor { /* Disabled for ADT 0.9 / Cupcake SDK 1.5_r1 release. [bug #1795718]. This currently does not work, the alias build rules need to be fixed. - - define(MODE.ENUM, true, + + define(MODE.ENUM, true, VERB_CREATE, OBJECT_PROJECT, "m", KEY_MODE, "Project mode", new String[] { ARG_ACTIVITY, ARG_ALIAS }); */ - define(MODE.STRING, true, + define(MODE.STRING, true, VERB_CREATE, OBJECT_PROJECT, "p", KEY_PATH, "Location path of new project", null); - define(MODE.INTEGER, true, + define(MODE.INTEGER, true, VERB_CREATE, OBJECT_PROJECT, "t", KEY_TARGET_ID, "Target id of the new project", null); - define(MODE.STRING, true, + define(MODE.STRING, true, VERB_CREATE, OBJECT_PROJECT, "k", KEY_PACKAGE, "Package name", null); - define(MODE.STRING, true, + define(MODE.STRING, true, VERB_CREATE, OBJECT_PROJECT, "a", KEY_ACTIVITY, "Activity name", null); - define(MODE.STRING, false, + define(MODE.STRING, false, VERB_CREATE, OBJECT_PROJECT, "n", KEY_NAME, "Project name", null); // --- update project --- - define(MODE.STRING, true, + define(MODE.STRING, true, VERB_UPDATE, OBJECT_PROJECT, "p", KEY_PATH, "Location path of the project", null); - define(MODE.INTEGER, true, + define(MODE.INTEGER, true, VERB_UPDATE, OBJECT_PROJECT, "t", KEY_TARGET_ID, "Target id to set for the project", -1); - define(MODE.STRING, false, + define(MODE.STRING, false, VERB_UPDATE, OBJECT_PROJECT, "n", KEY_NAME, "Project name", null); } - + + @Override + public boolean acceptLackOfVerb() { + return true; + } + // -- some helpers for generic action flags - + /** Helper to retrieve the --path value. */ public String getParamLocationPath() { return ((String) getValue(null, null, KEY_PATH)); } - + /** Helper to retrieve the --target id value. */ public int getParamTargetId() { return ((Integer) getValue(null, null, KEY_TARGET_ID)).intValue(); @@ -194,7 +199,7 @@ public class SdkCommandLine extends CommandLineProcessor { public String getParamName() { return ((String) getValue(null, null, KEY_NAME)); } - + /** Helper to retrieve the --skin value. */ public String getParamSkin() { return ((String) getValue(null, null, KEY_SKIN)); @@ -204,7 +209,7 @@ public class SdkCommandLine extends CommandLineProcessor { public String getParamSdCard() { return ((String) getValue(null, null, KEY_SDCARD)); } - + /** Helper to retrieve the --force flag. */ public boolean getFlagForce() { return ((Boolean) getValue(null, null, KEY_FORCE)).booleanValue(); @@ -219,7 +224,7 @@ public class SdkCommandLine extends CommandLineProcessor { // -- some helpers for project action flags - + /** Helper to retrieve the --package value. */ public String getParamProjectPackage() { return ((String) getValue(null, OBJECT_PROJECT, KEY_PACKAGE)); diff --git a/sdkmanager/libs/sdkuilib/.classpath b/sdkmanager/libs/sdkuilib/.classpath index eb5af7e..5e78ee7 100644 --- a/sdkmanager/libs/sdkuilib/.classpath +++ b/sdkmanager/libs/sdkuilib/.classpath @@ -1,8 +1,8 @@ -<?xml version="1.0" encoding="UTF-8"?> -<classpath> - <classpathentry kind="src" path="src"/> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> - <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/ANDROID_SWT"/> - <classpathentry combineaccessrules="false" kind="src" path="/SdkLib"/> - <classpathentry kind="output" path="bin"/> -</classpath> +<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry exported="true" kind="con" path="org.eclipse.jdt.USER_LIBRARY/ANDROID_SWT"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/SdkLib"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/AvdSelector.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/AvdSelector.java index 2bf7593..44c7724 100644 --- a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/AvdSelector.java +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/AvdSelector.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 The Android Open Source Project + * Copyright (C) 2009 The Android Open Source Project * * Licensed under the Eclipse Public License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,7 @@ import org.eclipse.swt.widgets.TableItem; * and finally use {@link #getSelected()} to retrieve the selection. */ public final class AvdSelector { - + private AvdInfo[] mAvds; private SelectionListener mSelectionListener; private Table mTable; @@ -84,28 +84,28 @@ public final class AvdSelector { * This is invoked once when the button is created and cannot be changed later. */ public String label(); - + /** * This is invoked just after the selection has changed to update the "enabled" * state of the action. Implementation should use {@link AvdSelector#getSelected()}. */ public boolean isEnabled(); - /** + /** * Run the action, invoked when the button is clicked. - * + * * The caller's action is responsible for reloading the AVD list * using {@link AvdSelector#setAvds(AvdInfo[], IAndroidTarget)}. */ public void run(); } - + /** * Creates a new SDK Target Selector, and fills it with a list of {@link AvdInfo}, filtered * by a {@link IAndroidTarget}. * <p/>Only the {@link AvdInfo} able to run application developed for the given * {@link IAndroidTarget} will be displayed. - * + * * @param parent The parent composite where the selector will be added. * @param avds The list of AVDs. This is <em>not</em> copied, the caller must not modify. * It can be null. @@ -149,10 +149,10 @@ public final class AvdSelector { public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); mExtraAction.run(); - } + } }); } - + // create the table columns final TableColumn column0 = new TableColumn(mTable, SWT.NONE); column0.setText("AVD Name"); @@ -171,7 +171,7 @@ public final class AvdSelector { /** * Creates a new SDK Target Selector, and fills it with a list of {@link AvdInfo}. - * + * * @param parent The parent composite where the selector will be added. * @param avds The list of AVDs. This is <em>not</em> copied, the caller must not modify. * It can be null. @@ -187,7 +187,7 @@ public final class AvdSelector { /** * Creates a new SDK Target Selector, and fills it with a list of {@link AvdInfo}. - * + * * @param parent The parent composite where the selector will be added. * @param extraAction When non-null, displays an extra action button. * @param selectionMode One of {@link SelectionMode#SELECT} or {@link SelectionMode#CHECK} @@ -200,7 +200,7 @@ public final class AvdSelector { /** * Sets the table grid layout data. - * + * * @param heightHint If > 0, the height hint is set to the requested value. */ public void setTableHeightHint(int heightHint) { @@ -215,26 +215,26 @@ public final class AvdSelector { data.verticalAlignment = GridData.FILL; mTable.setLayoutData(data); } - + /** * Sets a new set of AVD, with an optional filter. * Tries to keep the selection. * <p/> * This must be called from the UI thread. - * - * + * + * * @param avds The list of AVDs. This is <em>not</em> copied, the caller must not modify. * It can be null. * @param filter An IAndroidTarget. If non-null, only AVD whose target are compatible with the * filter target will displayed an available for selection. */ public void setAvds(AvdInfo[] avds, IAndroidTarget filter) { - + AvdInfo selected = getSelected(); - + mAvds = avds; fillTable(mTable, filter); - + setSelection(selected); } @@ -256,19 +256,19 @@ public final class AvdSelector { * The {@link TableItem#getData()} contains an {@link IAndroidTarget}. * <p/> * It is recommended that the caller uses the {@link #getSelected()} method instead. - * + * * @param selectionListener The new listener or null to remove it. */ public void setSelectionListener(SelectionListener selectionListener) { mSelectionListener = selectionListener; } - + /** * Sets the current target selection. * <p/> * If the selection is actually changed, this will invoke the selection listener * (if any) with a null event. - * + * * @param target the target to be selected. Use null to deselect everything. * @return true if the target could be selected, false otherwise. */ @@ -288,7 +288,7 @@ public final class AvdSelector { } break; } - + index++; } else if (mSelectionMode == SelectionMode.CHECK){ @@ -304,21 +304,21 @@ public final class AvdSelector { } } } - + if (modified && mSelectionListener != null) { mSelectionListener.widgetSelected(null); } - + if (mExtraAction != null && mExtraActionButton != null) { mExtraActionButton.setEnabled(mExtraAction.isEnabled()); } - + return found; } /** * Returns the currently selected item. - * + * * @return The currently selected item or null. */ public AvdInfo getSelected() { @@ -342,7 +342,7 @@ public final class AvdSelector { * Enables the receiver if the argument is true, and disables it otherwise. * A disabled control is typically not selectable from the user interface * and draws with an inactive or "grayed" look. - * + * * @param enabled the new enabled state. */ public void setEnabled(boolean enabled) { @@ -366,7 +366,7 @@ public final class AvdSelector { @Override public void controlResized(ControlEvent e) { Rectangle r = table.getClientArea(); - column0.setWidth(r.width * 30 / 100); // 30% + column0.setWidth(r.width * 30 / 100); // 30% column1.setWidth(r.width * 45 / 100); // 45% column2.setWidth(r.width * 10 / 100); // 10% column3.setWidth(r.width * 15 / 100); // 15% @@ -382,7 +382,7 @@ public final class AvdSelector { private void setupSelectionListener(final Table table) { // Add a selection listener that will check/uncheck items when they are double-clicked table.addSelectionListener(new SelectionListener() { - + /** * Handles single-click selection on the table. * {@inheritDoc} @@ -397,7 +397,7 @@ public final class AvdSelector { if (mSelectionListener != null) { mSelectionListener.widgetSelected(e); } - + if (mExtraAction != null && mExtraActionButton != null) { mExtraActionButton.setEnabled(mExtraAction.isEnabled()); } @@ -406,9 +406,9 @@ public final class AvdSelector { /** * Handles double-click selection on the table. * Note that the single-click handler will probably already have been called. - * + * * On double-click, <em>always</em> check the table item. - * + * * {@inheritDoc} */ public void widgetDefaultSelected(SelectionEvent e) { @@ -424,7 +424,7 @@ public final class AvdSelector { if (mSelectionListener != null) { mSelectionListener.widgetDefaultSelected(e); } - + if (mExtraAction != null && mExtraActionButton != null) { mExtraActionButton.setEnabled(mExtraAction.isEnabled()); } @@ -437,7 +437,7 @@ public final class AvdSelector { private void enforceSingleSelection(TableItem item) { if (mSelectionMode == SelectionMode.SELECT) { // pass - + } else if (mSelectionMode == SelectionMode.CHECK) { if (item.getChecked()) { Table parentTable = item.getParent(); @@ -478,7 +478,7 @@ public final class AvdSelector { } } } - + if (table.getItemCount() == 0) { table.setEnabled(false); TableItem item = new TableItem(table, SWT.NONE); @@ -498,36 +498,36 @@ public final class AvdSelector { */ private void setupTooltip(final Table table) { /* - * Reference: + * Reference: * http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet125.java?view=markup */ - + final Listener listener = new Listener() { public void handleEvent(Event event) { - + switch(event.type) { case SWT.KeyDown: case SWT.MouseExit: case SWT.MouseDown: return; - + case SWT.MouseHover: updateDescription(table.getItem(new Point(event.x, event.y))); break; - + case SWT.Selection: if (event.item instanceof TableItem) { updateDescription((TableItem) event.item); } break; - + default: return; } } }; - + table.addListener(SWT.Dispose, listener); table.addListener(SWT.KeyDown, listener); table.addListener(SWT.MouseMove, listener); diff --git a/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/repository/UpdaterWindow.java b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/repository/UpdaterWindow.java new file mode 100755 index 0000000..57537d2 --- /dev/null +++ b/sdkmanager/libs/sdkuilib/src/com/android/sdkuilib/repository/UpdaterWindow.java @@ -0,0 +1,222 @@ +/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Eclipse Public License, Version 1.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.eclipse.org/org/documents/epl-v10.php
+ *
+ * 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.sdkuilib.repository;
+
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.TableTree;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+
+public class UpdaterWindow {
+
+ protected Shell mshlAndroidSdkUpdater;
+ private TabFolder tabFolder;
+ private TabItem mtbtmInstalledPackages;
+ private Composite compositeInst;
+ private TabItem mtbtmAvailablePackages;
+ private Composite compositeAvail;
+ private Text text;
+ private Button mbtnBrowse;
+ private Label mlblSdkLocation;
+ private Group mgrpDescription;
+ private Composite composite_3;
+ private Button mbtnUpdate;
+ private Button mbtnDelete;
+ private Button mbtnHomePage;
+ private Label placeholder1;
+ private Label placeholder2;
+ private Label mlblInstalledPackages;
+ private TableTree tableTree;
+ private Tree tree;
+ private Button mbtnRemoveSite;
+ private Button mbtnAddSite;
+ private Label placeholder3;
+ private Button mbtnRefresh;
+ private Button mbtnInstallSelected;
+ private Group mgrpDescription_1;
+ private Table table;
+ private TableColumn mtblclmnSummary;
+ private TableColumn mtblclmnApiLevel;
+ private TableColumn mtblclmnRevision;
+ private TreeColumn mtrclmnSummary;
+ private TreeColumn mtrclmnApiLevel;
+ private TreeColumn mtrclmnRevision;
+ private TreeColumn mtrclmnOs;
+ private TreeColumn mtrclmnInstalled;
+
+ /**
+ * Open the window.
+ * @wbp.parser.entryPoint
+ */
+ public void open() {
+ Display display = Display.getDefault();
+ createContents();
+ mshlAndroidSdkUpdater.open();
+ mshlAndroidSdkUpdater.layout();
+ while (!mshlAndroidSdkUpdater.isDisposed()) {
+ if (!display.readAndDispatch()) {
+ display.sleep();
+ }
+ }
+ }
+
+ /**
+ * Create contents of the window.
+ */
+ protected void createContents() {
+ mshlAndroidSdkUpdater = new Shell();
+ mshlAndroidSdkUpdater.setMinimumSize(new Point(200, 50));
+ mshlAndroidSdkUpdater.setLayout(new GridLayout(1, false));
+ mshlAndroidSdkUpdater.setSize(633, 433);
+ mshlAndroidSdkUpdater.setText("Android SDK Updater");
+
+ tabFolder = new TabFolder(mshlAndroidSdkUpdater, SWT.NONE);
+ tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
+
+ mtbtmInstalledPackages = new TabItem(tabFolder, SWT.NONE);
+ mtbtmInstalledPackages.setText("Installed Packages");
+
+ compositeInst = new Composite(tabFolder, SWT.NONE);
+ compositeInst.setLayout(new GridLayout(3, false));
+ mtbtmInstalledPackages.setControl(compositeInst);
+
+ mlblSdkLocation = new Label(compositeInst, SWT.NONE);
+ mlblSdkLocation.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+ mlblSdkLocation.setText("SDK Location:");
+
+ text = new Text(compositeInst, SWT.BORDER);
+ text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
+
+ mbtnBrowse = new Button(compositeInst, SWT.NONE);
+ mbtnBrowse.setText("Browse...");
+
+ mlblInstalledPackages = new Label(compositeInst, SWT.NONE);
+ mlblInstalledPackages.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1));
+ mlblInstalledPackages.setText("Installed Packages:");
+
+ TableViewer tableInstalledPackage = new TableViewer(compositeInst, SWT.BORDER | SWT.FULL_SELECTION);
+ table = tableInstalledPackage.getTable();
+ table.setHeaderVisible(true);
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));
+
+ mtblclmnSummary = new TableColumn(table, SWT.NONE);
+ mtblclmnSummary.setWidth(377);
+ mtblclmnSummary.setText("Summary");
+
+ mtblclmnApiLevel = new TableColumn(table, SWT.NONE);
+ mtblclmnApiLevel.setWidth(100);
+ mtblclmnApiLevel.setText("API Level");
+
+ mtblclmnRevision = new TableColumn(table, SWT.NONE);
+ mtblclmnRevision.setWidth(100);
+ mtblclmnRevision.setText("Revision");
+
+ mgrpDescription = new Group(compositeInst, SWT.NONE);
+ mgrpDescription.setText("Description");
+ mgrpDescription.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1));
+
+ composite_3 = new Composite(compositeInst, SWT.NONE);
+ composite_3.setLayout(new GridLayout(5, false));
+ composite_3.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
+
+ mbtnUpdate = new Button(composite_3, SWT.NONE);
+ mbtnUpdate.setText("Update...");
+
+ placeholder1 = new Label(composite_3, SWT.NONE);
+ placeholder1.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
+
+ mbtnDelete = new Button(composite_3, SWT.NONE);
+ mbtnDelete.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1));
+ mbtnDelete.setText("Delete...");
+
+ placeholder2 = new Label(composite_3, SWT.NONE);
+ placeholder2.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
+
+ mbtnHomePage = new Button(composite_3, SWT.NONE);
+ mbtnHomePage.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
+ mbtnHomePage.setText("Home Page...");
+
+ mtbtmAvailablePackages = new TabItem(tabFolder, SWT.NONE);
+ mtbtmAvailablePackages.setText("Available Packages");
+
+ compositeAvail = new Composite(tabFolder, SWT.NONE);
+ compositeAvail.setLayout(new GridLayout(5, false));
+ mtbtmAvailablePackages.setControl(compositeAvail);
+
+ CheckboxTreeViewer checkboxTreeAvailablePackages = new CheckboxTreeViewer(compositeAvail, SWT.BORDER);
+ tree = checkboxTreeAvailablePackages.getTree();
+ tree.setHeaderVisible(true);
+ tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 5, 1));
+
+ mtrclmnSummary = new TreeColumn(tree, SWT.NONE);
+ mtrclmnSummary.setWidth(289);
+ mtrclmnSummary.setText("Summary");
+
+ mtrclmnApiLevel = new TreeColumn(tree, SWT.NONE);
+ mtrclmnApiLevel.setWidth(66);
+ mtrclmnApiLevel.setText("API Level");
+
+ mtrclmnRevision = new TreeColumn(tree, SWT.NONE);
+ mtrclmnRevision.setWidth(63);
+ mtrclmnRevision.setText("Revision");
+
+ mtrclmnOs = new TreeColumn(tree, SWT.NONE);
+ mtrclmnOs.setWidth(100);
+ mtrclmnOs.setText("OS/Arch");
+
+ mtrclmnInstalled = new TreeColumn(tree, SWT.NONE);
+ mtrclmnInstalled.setWidth(59);
+ mtrclmnInstalled.setText("Installed");
+
+ mgrpDescription_1 = new Group(compositeAvail, SWT.NONE);
+ mgrpDescription_1.setText("Description");
+ mgrpDescription_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 5, 1));
+
+ mbtnAddSite = new Button(compositeAvail, SWT.NONE);
+ mbtnAddSite.setText("Add Site...");
+
+ mbtnRemoveSite = new Button(compositeAvail, SWT.NONE);
+ mbtnRemoveSite.setText("Delete Site...");
+
+ placeholder3 = new Label(compositeAvail, SWT.NONE);
+ placeholder3.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, false, 1, 1));
+
+ mbtnRefresh = new Button(compositeAvail, SWT.NONE);
+ mbtnRefresh.setText("Refresh");
+
+ mbtnInstallSelected = new Button(compositeAvail, SWT.NONE);
+ mbtnInstallSelected.setText("Install Selected");
+
+
+ }
+}
|