diff -r f5125b13096d nbi/engine/native/launcher/unix/i18n/launcher.properties --- a/nbi/engine/native/launcher/unix/i18n/launcher.properties Thu Sep 18 21:27:27 2008 +0400 +++ b/nbi/engine/native/launcher/unix/i18n/launcher.properties Fri Sep 19 14:06:45 2008 +0400 @@ -52,6 +52,7 @@ nlu.jvm.search=Searching for JVM on the system... nlu.msg.usage=\nUsage: +nlu.msg.usage.more=\nMore options: nlu.arg.javahome=\t{0}\t\tUsing java from for running application nlu.arg.verbose=\t{0}\t\tUse verbose output nlu.arg.output=\t{0}\t\tRedirect all output to file @@ -63,6 +64,7 @@ nlu.arg.locale=\t{0}\t\tOverride default locale with specified nlu.arg.silent=\t{0}\t\tRun installer silently nlu.arg.help=\t{0}\t\tShow this help +nlu.arg.help.more=\t{0}\t\tShow more options nlu.java.application.name.macosx=NetBeans IDE Installer diff -r f5125b13096d nbi/engine/native/launcher/unix/src/launcher.sh --- a/nbi/engine/native/launcher/unix/src/launcher.sh Thu Sep 18 21:27:27 2008 +0400 +++ b/nbi/engine/native/launcher/unix/src/launcher.sh Fri Sep 19 14:06:45 2008 +0400 @@ -44,6 +44,7 @@ ARG_CLASSPATHA="--classpath-append" ARG_CLASSPATHP="--classpath-prepend" ARG_HELP="--help" +ARG_HELP_MORE="--more" ARG_SILENT="--silent" ARG_NOSPACECHECK="--nospacecheck" ARG_LOCALE="--locale" @@ -53,6 +54,7 @@ SILENT_MODE=0 EXTRACT_ONLY=0 SHOW_HELP_ONLY=0 +SHOW_HELP_MORE_ONLY=0 LOCAL_OVERRIDDEN=0 APPEND_CP= PREPEND_CP= @@ -104,7 +106,9 @@ MSG_ARG_LOCALE="nlu.arg.locale" MSG_ARG_SILENT="nlu.arg.silent" MSG_ARG_HELP="nlu.arg.help" +MSG_ARG_HELP_MORE="nlu.arg.help.more" MSG_USAGE="nlu.msg.usage" +MSG_USAGE_MORE="nlu.msg.usage.more" isSymlink= @@ -117,7 +121,13 @@ setLauncherLocale debugLauncherArguments "$@" if [ 1 -eq $SHOW_HELP_ONLY ] ; then - showHelp + showHelp + fi + if [ 1 -eq $SHOW_HELP_MORE_ONLY ] ; then + showHelpMore + fi + if [ 1 -eq $SHOW_HELP_ONLY ] || [ 1 -eq $SHOW_HELP_MORE_ONLY ] ; then + exitProgram $ERROR_OK fi message "$MSG_STARTING" @@ -159,7 +169,7 @@ } isLauncherCommandArgument() { case "$1" in - $ARG_VERBOSE | $ARG_NOSPACECHECK | $ARG_OUTPUT | $ARG_HELP | $ARG_JAVAHOME | $ARG_TEMPDIR | $ARG_EXTRACT | $ARG_SILENT | $ARG_LOCALE | $ARG_CLASSPATHP | $ARG_CLASSPATHA) + $ARG_VERBOSE | $ARG_NOSPACECHECK | $ARG_OUTPUT | $ARG_HELP | $ARG_HELP_MORE | $ARG_JAVAHOME | $ARG_TEMPDIR | $ARG_EXTRACT | $ARG_SILENT | $ARG_LOCALE | $ARG_CLASSPATHP | $ARG_CLASSPATHA) echo 1 ;; *) @@ -191,6 +201,9 @@ ;; $ARG_HELP) SHOW_HELP_ONLY=1 + ;; + $ARG_HELP_MORE) + SHOW_HELP_MORE_ONLY=1 ;; $ARG_JAVAHOME) if [ -n "$2" ] ; then @@ -543,8 +556,31 @@ out "$msg9" out "$msg10" out "$msg11" - exitProgram $ERROR_OK + if [ $HELP_MORE_OPTIONS_NUMBER -ne 0 ] ; then + msg12=`message "$MSG_ARG_HELP_MORE $ARG_HELP_MORE"` + out "$msg12" + fi } + +showHelpMore() { + if [ $HELP_MORE_OPTIONS_NUMBER -ne 0 ] ; then + msg=`message "$MSG_USAGE_MORE"` + out "$msg" + moreOptionCounter=0 + while [ $moreOptionCounter -lt $HELP_MORE_OPTIONS_NUMBER ] ; do + msgKey="$""HELP_MORE_OPTION_"$moreOptionCounter"_NAME" + msgKeyResolved=`eval "echo \"$msgKey\""` + + msgArg="$""HELP_MORE_OPTION_"$moreOptionCounter"_ARG" + msgArgResolved=`eval "echo \"$msgArg\""` + + resolvedMessage=`message "$msgKeyResolved $msgArgResolved"` + out "$resolvedMessage" + moreOptionCounter=`expr "$moreOptionCounter" + 1` + done + fi +} + exitProgram() { if [ 0 -eq $EXTRACT_ONLY ] ; then diff -r f5125b13096d nbi/engine/native/launcher/windows/dist/nlw.exe Binary file nbi/engine/native/launcher/windows/dist/nlw.exe has changed diff -r f5125b13096d nbi/engine/native/launcher/windows/i18n/launcher.properties --- a/nbi/engine/native/launcher/windows/i18n/launcher.properties Thu Sep 18 21:27:27 2008 +0400 +++ b/nbi/engine/native/launcher/windows/i18n/launcher.properties Fri Sep 19 14:06:45 2008 +0400 @@ -57,7 +57,9 @@ nlw.arg.locale={0} \n\tOverride system default locale with nlw.arg.silent={0} \n\tRun installer silently nlw.arg.help={0}\n\tShow help message - +nlw.arg.help.more={0}\n\tShow more options +nlw.msg.usage=\nUsage:\n +nlw.msg.usage.more=\nMore Options:\n nlw.msg.create.tmpdir=Creating temporary directory ... nlw.msg.extract=Extracting data ... diff -r f5125b13096d nbi/engine/native/launcher/windows/src/ExtractUtils.c --- a/nbi/engine/native/launcher/windows/src/ExtractUtils.c Thu Sep 18 21:27:27 2008 +0400 +++ b/nbi/engine/native/launcher/windows/src/ExtractUtils.c Fri Sep 19 14:06:45 2008 +0400 @@ -553,6 +553,43 @@ } } +void loadMoreOptionsMap(LauncherProperties * props) { + DWORD i=0; + DWORD j=0; + //read number of locales + + DWORD numberOfMoreOptions = 0; + + readNumberWithDebug(props, &numberOfMoreOptions, "number of more options"); + if(!isOK(props)) return; + if(numberOfMoreOptions == 0) { + props->status = ERROR_INTEGRITY; + return ; + } + props->moreOptionsHelpNumber = numberOfMoreOptions; + props->moreOptionsHelpArgs = newppWCHAR(props->moreOptionsHelpNumber); + props->moreOptionsHelpKeys = newppChar(props->moreOptionsHelpNumber); + writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Iterating...", 1); + for(i=0; isOK(props) && imoreOptionsHelpArgs[i] = NULL; + writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... reading arg", 1); + sprintf(propName, "argument name %2ld", i); + readStringWithDebugW(props, & (props->moreOptionsHelpArgs[i]), propName); + FREE(propName); + if(!isOK(props)) return; + + props->moreOptionsHelpKeys[i] = NULL; + writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... reading key", 1); + propName = newpChar(20); + sprintf(propName, "key name %2ld", i); + readStringWithDebugA(props, & (props->moreOptionsHelpKeys[i]), propName); + FREE(propName); + } + writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... more option loaded", 1); +} + LauncherResource * newLauncherResource() { LauncherResource * file = (LauncherResource *) LocalAlloc(LPTR, sizeof(LauncherResource)); file->path=NULL; diff -r f5125b13096d nbi/engine/native/launcher/windows/src/ExtractUtils.h --- a/nbi/engine/native/launcher/windows/src/ExtractUtils.h Thu Sep 18 21:27:27 2008 +0400 +++ b/nbi/engine/native/launcher/windows/src/ExtractUtils.h Fri Sep 19 14:06:45 2008 +0400 @@ -51,7 +51,7 @@ void skipStub(LauncherProperties * props); void loadI18NStrings(LauncherProperties * props); - + void loadMoreOptionsMap(LauncherProperties * props); WCHARList * newWCHARList(DWORD number) ; void readLauncherProperties(LauncherProperties * props); void freeWCHARList(WCHARList ** plist); diff -r f5125b13096d nbi/engine/native/launcher/windows/src/Launcher.c --- a/nbi/engine/native/launcher/windows/src/Launcher.c Thu Sep 18 21:27:27 2008 +0400 +++ b/nbi/engine/native/launcher/windows/src/Launcher.c Fri Sep 19 14:06:45 2008 +0400 @@ -49,7 +49,7 @@ #include "ExtractUtils.h" #include "Main.h" -const DWORD NUMBER_OF_HELP_ARGUMENTS = 11; +const DWORD NUMBER_OF_HELP_ARGUMENTS = 12; const DWORD READ_WRITE_BUFSIZE = 65536; const WCHAR * outputFileArg = L"--output"; const WCHAR * javaArg = L"--javahome"; @@ -59,6 +59,7 @@ const WCHAR * classPathAppend = L"--classpath-append"; const WCHAR * extractArg = L"--extract"; const WCHAR * helpArg = L"--help"; +const WCHAR * moreArg = L"--more"; const WCHAR * helpOtherArg = L"/?"; const WCHAR * silentArg = L"--silent"; const WCHAR * nospaceCheckArg = L"--nospacecheck"; @@ -163,6 +164,17 @@ if(!isOK(props)) { writeMessageA(props, OUTPUT_LEVEL_NORMAL, 1, "Error! Can`t load i18n strings!!", 1); + showErrorW(props, INTEGRITY_ERROR_PROP, 1, props->exeName); + } +} + +void loadMoreOptions(LauncherProperties *props) { + // load localized messages + writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "Loading more help options.", 1); + loadMoreOptionsMap(props); + + if(!isOK(props)) { + writeMessageA(props, OUTPUT_LEVEL_NORMAL, 1, "Error! Can`t load more options!!", 1); showErrorW(props, INTEGRITY_ERROR_PROP, 1, props->exeName); } } @@ -717,12 +729,33 @@ } DWORD isOnlyHelp(LauncherProperties * props) { - if(argumentExists(props, helpArg, 1) || argumentExists(props, helpOtherArg, 1)) { - - WCHARList * help = newWCHARList(NUMBER_OF_HELP_ARGUMENTS); - DWORD counter = 0; - WCHAR * helpString = NULL; - + DWORD helpArgExist = argumentExists(props, helpArg, 1); + DWORD helpOtherArgExist = argumentExists(props, helpArg, 1); + DWORD moreArgExist = argumentExists(props, moreArg, 1); + DWORD numberOfArgs = 0; + DWORD counter = 0; + WCHAR * helpString = NULL; + WCHARList * help = NULL; + + if (!helpArgExist && !helpOtherArgExist && !moreArgExist) { + return 0; + } + + writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... loading help strings", 1); + + if (helpArgExist) { + numberOfArgs += NUMBER_OF_HELP_ARGUMENTS - ((props->moreOptionsHelpNumber == 0) ? 1 : 0) + 1; + } + if (moreArgExist) { + numberOfArgs += props->moreOptionsHelpNumber + 1; + } + + help = newWCHARList(numberOfArgs); + + counter = 0; + if (helpArgExist) { + writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... loading main help strings", 1); + help->items[counter++] = formatMessageW(getI18nProperty(props, MSG_USAGE), 0); help->items[counter++] = formatMessageW(getI18nProperty(props, ARG_JAVA_PROP), 1, javaArg); help->items[counter++] = formatMessageW(getI18nProperty(props, ARG_TMP_PROP), 1, tempdirArg); help->items[counter++] = formatMessageW(getI18nProperty(props, ARG_EXTRACT_PROP), 1, extractArg); @@ -734,17 +767,26 @@ help->items[counter++] = formatMessageW(getI18nProperty(props, ARG_LOCALE_PROP), 1, localeArg); help->items[counter++] = formatMessageW(getI18nProperty(props, ARG_SILENT_PROP), 1, silentArg); help->items[counter++] = formatMessageW(getI18nProperty(props, ARG_HELP_PROP), 1, helpArg); - - - for(counter=0;counteritems[counter]), NEW_LINE); + if (props->moreOptionsHelpNumber != 0) { + help->items[counter++] = formatMessageW(getI18nProperty(props, ARG_MORE_PROP), 1, moreArg); } - freeWCHARList(&help); - showMessageW(props, helpString, 0); - FREE(helpString); - return 1; } - return 0; + if (moreArgExist) { + DWORD i = 0; + help->items[counter++] = formatMessageW(getI18nProperty(props, MSG_USAGE_MORE),0); + writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... loading more help strings", 1); + for (i = 0; i < props->moreOptionsHelpNumber; i++) { + help->items[counter++] = formatMessageW(getI18nProperty(props, props->moreOptionsHelpKeys[i]), 1, props->moreOptionsHelpArgs[i]); + } + } + writeMessageA(props, OUTPUT_LEVEL_DEBUG, 0, "... creating full help message", 1); + for (counter = 0; counter < numberOfArgs; counter++) { + helpString = appendStringW(appendStringW(helpString, help->items[counter]), NEW_LINE); + } + freeWCHARList(&help); + showMessageW(props, helpString, 0); + FREE(helpString); + return 1; } DWORD isSilent(LauncherProperties * props) { @@ -785,6 +827,8 @@ props->jvmArguments = NULL; props->appArguments = NULL; + props->moreOptionsHelpKeys = NULL; + props->moreOptionsHelpArgs = NULL; props->extractOnly = 0; props->mainClass = NULL; props->testJVMClass = NULL; @@ -856,6 +900,13 @@ writeMessageA(*props, OUTPUT_LEVEL_DEBUG, 0, "Closing launcher properties", 1); freeWCHARList(& ( (*props)->appArguments)); freeWCHARList(& ( (*props)->jvmArguments)); + + for(i=0;i<(*props)->moreOptionsHelpNumber;i++) { + FREE((*props)->moreOptionsHelpArgs[i]); + FREE((*props)->moreOptionsHelpKeys[i]); + } + FREE((*props)->moreOptionsHelpArgs); + FREE((*props)->moreOptionsHelpKeys); FREE((*props)->mainClass); FREE((*props)->testJVMClass); @@ -934,6 +985,9 @@ loadLocalizationStrings(props); if(!isOK(props) || isTerminated(props)) return; + loadMoreOptions(props); + if(!isOK(props) || isTerminated(props)) return; + if(isOnlyHelp(props)) return; setProgressTitleString(props, getI18nProperty(props, MSG_PROGRESS_TITLE)); diff -r f5125b13096d nbi/engine/native/launcher/windows/src/Main.c --- a/nbi/engine/native/launcher/windows/src/Main.c Thu Sep 18 21:27:27 2008 +0400 +++ b/nbi/engine/native/launcher/windows/src/Main.c Fri Sep 19 14:06:45 2008 +0400 @@ -462,7 +462,7 @@ result = newpWCHAR(totalLength + 1); va_start(ap, varArgsNumber); - wvsprintfW(result, message, ap); + _snwprintf(result, totalLength, message, ap); va_end(ap); writeMessageW(props, OUTPUT_LEVEL_DEBUG, 0, result, 1); if(!isSilent(props)) { diff -r f5125b13096d nbi/engine/native/launcher/windows/src/StringUtils.c --- a/nbi/engine/native/launcher/windows/src/StringUtils.c Thu Sep 18 21:27:27 2008 +0400 +++ b/nbi/engine/native/launcher/windows/src/StringUtils.c Fri Sep 19 14:06:45 2008 +0400 @@ -68,6 +68,7 @@ const char * ARG_LOCALE_PROP = "nlw.arg.locale"; const char * ARG_SILENT_PROP = "nlw.arg.silent"; const char * ARG_HELP_PROP = "nlw.arg.help"; +const char * ARG_MORE_PROP = "nlw.arg.help.more"; const char * MSG_CREATE_TMPDIR = "nlw.msg.create.tmpdir"; const char * MSG_EXTRACT_DATA = "nlw.msg.extract"; @@ -77,6 +78,8 @@ const char * MSG_TITLE = "nlw.msg.title"; const char * MSG_MESSAGEBOX_TITLE = "nlw.msg.messagebox.title"; const char * MSG_PROGRESS_TITLE = "nlw.msg.progress.title"; +const char * MSG_USAGE = "nlw.msg.usage"; +const char * MSG_USAGE_MORE = "nlw.msg.usage.more"; const char * EXIT_BUTTON_PROP = "nlw.msg.button.error" ; const char * MAIN_WINDOW_TITLE = "nlw.msg.main.title" ; @@ -198,6 +201,12 @@ return L"Can`t run prepare bundled JVM"; } else if(lstrcmpA(name, BUNDLED_JVM_VERIFY_ERROR_PROP)==0) { return L"Can`t run verify bundled JVM"; + } else if(lstrcmpA(name, ARG_MORE_PROP)==0) { + return L"%s Get more options help"; + } else if(lstrcmpA(name, MSG_USAGE)==0) { + return L"Usage:"; + } else if(lstrcmpA(name, MSG_USAGE_MORE)==0) { + return L"More Options:"; } return NULL; } diff -r f5125b13096d nbi/engine/native/launcher/windows/src/StringUtils.h --- a/nbi/engine/native/launcher/windows/src/StringUtils.h Thu Sep 18 21:27:27 2008 +0400 +++ b/nbi/engine/native/launcher/windows/src/StringUtils.h Fri Sep 19 14:06:45 2008 +0400 @@ -67,6 +67,7 @@ extern const char * ARG_LOCALE_PROP; extern const char * ARG_SILENT_PROP; extern const char * ARG_HELP_PROP; +extern const char * ARG_MORE_PROP; extern const char * MSG_CREATE_TMPDIR; extern const char * MSG_EXTRACT_DATA; extern const char * MSG_JVM_SEARCH; @@ -77,6 +78,8 @@ extern const char * MSG_PROGRESS_TITLE; extern const char * EXIT_BUTTON_PROP; extern const char * MAIN_WINDOW_TITLE; +extern const char * MSG_USAGE; +extern const char * MSG_USAGE_MORE; #define FREE(x) { \ if((x)!=NULL) {\ diff -r f5125b13096d nbi/engine/native/launcher/windows/src/Types.h --- a/nbi/engine/native/launcher/windows/src/Types.h Thu Sep 18 21:27:27 2008 +0400 +++ b/nbi/engine/native/launcher/windows/src/Types.h Fri Sep 19 14:06:45 2008 +0400 @@ -131,6 +131,10 @@ WCHAR * classpath; WCHAR * mainClass; + char ** moreOptionsHelpKeys; + WCHAR ** moreOptionsHelpArgs; + DWORD moreOptionsHelpNumber; + JavaProperties * java; WCHAR * command; WCHAR * exePath; diff -r f5125b13096d nbi/engine/src/org/netbeans/installer/utils/cli/CLIHandler.java --- a/nbi/engine/src/org/netbeans/installer/utils/cli/CLIHandler.java Thu Sep 18 21:27:27 2008 +0400 +++ b/nbi/engine/src/org/netbeans/installer/utils/cli/CLIHandler.java Fri Sep 19 14:06:45 2008 +0400 @@ -63,7 +63,7 @@ public void proceed() { if (args.hasNext()) { LogManager.log("... parsing arguments : " + args.toString()); // NOI18N - List list = getOptions(); + List list = getAvailableOptions(); while (args.hasNext()) { final String currentArg = args.next(); @@ -87,14 +87,14 @@ } } - private List getOptions() { + public static List getAvailableOptions() { List list = new ArrayList(); loadDefaultOptions(list); loadAdditionalOptions(list); return list; } - private void loadDefaultOptions(List list) { + private static void loadDefaultOptions(List list) { list.add(new BundlePropertiesOption()); list.add(new CreateBundleOption()); list.add(new ForceInstallOption()); @@ -115,7 +115,7 @@ list.add(new UserdirOption()); } - private void loadAdditionalOptions(List list) { + private static void loadAdditionalOptions(List list) { InputStream is = ResourceUtils.getResource(OPTIONS_LIST); if (is != null) { LogManager.log(ErrorLevel.MESSAGE, "... loading additional CLI option classes, if necessary"); diff -r f5125b13096d nbi/engine/src/org/netbeans/installer/utils/cli/CLIOption.java --- a/nbi/engine/src/org/netbeans/installer/utils/cli/CLIOption.java Thu Sep 18 21:27:27 2008 +0400 +++ b/nbi/engine/src/org/netbeans/installer/utils/cli/CLIOption.java Fri Sep 19 14:06:45 2008 +0400 @@ -33,10 +33,17 @@ * the option applies only if the new code is made subject to such option by the * copyright holder. */ - package org.netbeans.installer.utils.cli; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.MissingResourceException; +import java.util.ResourceBundle; import org.netbeans.installer.utils.LogManager; +import org.netbeans.installer.utils.ResourceUtils; import org.netbeans.installer.utils.StringUtils; import org.netbeans.installer.utils.exceptions.CLIOptionException; @@ -50,6 +57,9 @@ "parsing command line parameter \"{0}\"";//NOI18N protected static final String UNARY_ARG_VALUE = Boolean.toString(true); // NOI18N + protected static final String BUNDLE_KEY_PREFIX = "O.help.";//NOI18N + + private Map helpMessageMap; public void init() { LogManager.logIndent(StringUtils.format( @@ -60,6 +70,40 @@ } public void finish() { LogManager.unindent(); // NOI18N + } + + public Map getHelpMessages() { + if(helpMessageMap!=null) { + return helpMessageMap; + } + final String key = getHelpKey(); + helpMessageMap = new HashMap(); + + if (key != null) { + final List localesList = new ArrayList (); + for(Locale locale : Locale.getAvailableLocales()) { + localesList.add(locale); + } + localesList.add(new Locale(StringUtils.EMPTY_STRING)); + for (Locale loc : localesList) { + try { + final String bundleName = getClass().getPackage().getName() + ResourceUtils.BUNDLE_FILE_SUFFIX; + ResourceBundle bundle = ResourceBundle.getBundle(bundleName, loc, getClass().getClassLoader()); + if (bundle.getLocale().equals(loc)) { + final String message = bundle.getString(key); + if (message != null) { + helpMessageMap.put(loc, message); + } + } + } catch (MissingResourceException e) { + } + } + } + return helpMessageMap; + } + + public String getHelpKey() { + return BUNDLE_KEY_PREFIX + getClass().getSimpleName().toLowerCase(Locale.ENGLISH).replaceAll("option$",""); } public void validateOptions(CLIArgumentsList arguments) throws CLIOptionException { diff -r f5125b13096d nbi/engine/src/org/netbeans/installer/utils/cli/options/Bundle.properties --- a/nbi/engine/src/org/netbeans/installer/utils/cli/options/Bundle.properties Thu Sep 18 21:27:27 2008 +0400 +++ b/nbi/engine/src/org/netbeans/installer/utils/cli/options/Bundle.properties Fri Sep 19 14:06:45 2008 +0400 @@ -51,3 +51,22 @@ O.warning.bad.registry.arg=Required parameter missing for command line argument "{0}".\nShould be "{0} ". O.warning.bad.properties.arg=Required parameter missing for command line argument "{0}".\nShould be "{0} ". O.warning.bad.bundle.properties.arg=Required parameter missing for command line argument "{0}".\nShould be "{0} ". + +O.help.lookandfeel=\tUse specific Look&Feel +#O.help.target= +#O.help.locale=[_[_]] +O.help.state=\nUse specified options file together with --silent option +#O.help.createbundle=\nCreate new bundle at the specified path +#O.help.bundleproperties= +#O.help.properties= +#O.help.platform=\nCreate bundle for the specified platform +#O.help.registry= +O.help.userdir= +#O.help.nospacecheck=Disable free space check +#O.help.forceinstall=Force install +#O.help.forceuninstall=Force uninstall +#O.help.suggestinstall=Suggest install +#O.help.suggestuninstall=Suggest uninstall +#O.help.silent=Run silently +O.help.record=\nPath to the file where the parameters would be stored +O.help.ignorelock=Ignore lock file existance on starting diff -r f5125b13096d nbi/engine/src/org/netbeans/installer/utils/system/launchers/LauncherProperties.java --- a/nbi/engine/src/org/netbeans/installer/utils/system/launchers/LauncherProperties.java Thu Sep 18 21:27:27 2008 +0400 +++ b/nbi/engine/src/org/netbeans/installer/utils/system/launchers/LauncherProperties.java Fri Sep 19 14:06:45 2008 +0400 @@ -42,8 +42,10 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; +import java.util.Enumeration; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.PropertyResourceBundle; import org.netbeans.installer.utils.FileUtils; import org.netbeans.installer.utils.LogManager; @@ -62,7 +64,7 @@ protected List jvms; protected List otherResources; - protected HashMap i18nMap; + private HashMap > i18nMap; protected LauncherResource testJVMFile; protected File outputFile; protected boolean addExtenstion; @@ -95,7 +97,7 @@ compatibleJava = new ArrayList (); jvmArguments = new ArrayList (); appArguments = new ArrayList (); - i18nMap = new HashMap (); + i18nMap = new HashMap >(); jars = new ArrayList (); jvms = new ArrayList (); otherResources = new ArrayList (); @@ -202,7 +204,7 @@ public void setTestJVMClass(String testClass) { this.testJVMClass = testClass; } - HashMap getI18nMap() { + public HashMap > getI18nMap() { return i18nMap; } @@ -224,18 +226,25 @@ return loc; } - private PropertyResourceBundle getBundle(File file) throws IOException { + private HashMap getBundle(File file) throws IOException { return getBundle(file.getPath(), new FileInputStream(file)); } - private PropertyResourceBundle getBundle(String dest, InputStream is) throws IOException { + private HashMap getBundle(String dest, InputStream is) throws IOException { if(is==null) { throw new IOException(ResourceUtils.getString(LauncherProperties.class, ERROR_CANNOT_LOAD_BUNDLE_KEY, dest)); //NOI18N } try { - return new PropertyResourceBundle(is); + PropertyResourceBundle bundle = new PropertyResourceBundle(is); + Enumeration en = bundle.getKeys(); + HashMap map = new HashMap (); + while(en.hasMoreElements()) { + String key = en.nextElement(); + map.put(key, bundle.getString(key)); + } + return map; } catch (IOException ex) { throw new IOException(ResourceUtils.getString(LauncherProperties.class, ERROR_CANNOT_LOAD_BUNDLE_KEY, dest)); //NOI18N @@ -250,10 +259,10 @@ // resources should be in form of /// private void loadPropertiesMap(String [] resources) throws IOException { - i18nMap.clear(); + clearI18NMap(); for(String resource: resources) { - String loc = getLocaleName(ResourceUtils.getResourceFileName(resource)); - i18nMap.put(loc, getBundle(resource, ResourceUtils.getResource(resource))); + String loc = getLocaleName(ResourceUtils.getResourceFileName(resource)); + i18nMap.put(StringUtils.parseLocale(loc), getBundle(resource, ResourceUtils.getResource(resource))); } } private void loadPropertiesMap(List resources) throws IOException { @@ -287,12 +296,18 @@ return files; } + private void clearI18NMap() { + for(Locale locale : i18nMap.keySet()) { + i18nMap.get(locale).clear(); + } + i18nMap.clear(); + } private void loadPropertiesMap(File [] files) throws IOException { - i18nMap.clear(); + clearI18NMap(); for(File f: files) { String loc = getLocaleName(f.getName()); LogManager.log("Adding bundle with locale [" + loc + "] using file " + f); - i18nMap.put(loc,getBundle(f)); + i18nMap.put(StringUtils.parseLocale(loc),getBundle(f)); } } private static final String ERROR_CANNOT_LOAD_BUNDLE_KEY = diff -r f5125b13096d nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/CommonLauncher.java --- a/nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/CommonLauncher.java Thu Sep 18 21:27:27 2008 +0400 +++ b/nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/CommonLauncher.java Fri Sep 19 14:06:45 2008 +0400 @@ -44,7 +44,12 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.Enumeration; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; import java.util.jar.Attributes; import java.util.jar.JarEntry; import java.util.jar.JarFile; @@ -55,6 +60,8 @@ import org.netbeans.installer.utils.StreamUtils; import org.netbeans.installer.utils.StringUtils; import org.netbeans.installer.utils.applications.JavaUtils; +import org.netbeans.installer.utils.cli.CLIHandler; +import org.netbeans.installer.utils.cli.CLIOption; import org.netbeans.installer.utils.helper.EngineResources; import org.netbeans.installer.utils.helper.ErrorLevel; import org.netbeans.installer.utils.helper.JavaCompatibleProperties; @@ -70,6 +77,8 @@ */ public abstract class CommonLauncher extends Launcher { private static final int BUF_SIZE = 102400; + + protected static final String ENGINE_OPTION_PREFIX = "engine.option.message."; protected CommonLauncher(LauncherProperties pr) { super(pr); @@ -132,6 +141,48 @@ return addString(fos, builder.toString() , isUnicode); } + protected List getEngineHelpOptions() { + List optionsWithHelp = new ArrayList (); + + for(CLIOption option : CLIHandler.getAvailableOptions()) { + if(!option.getHelpMessages().isEmpty()) { + optionsWithHelp.add(option); + } + } + return optionsWithHelp; + } + + abstract protected String getEngineOptionStringFormatted(String message); + + protected HashMap> getFullI18nMap() { + HashMap> fullMap = new HashMap>(); + Set availableLocales = new HashSet(); + availableLocales.addAll(getI18nMap().keySet()); + for (CLIOption option : getEngineHelpOptions()) { + availableLocales.addAll(option.getHelpMessages().keySet()); + } + + for (Locale locale : availableLocales) { + HashMap newMap = new HashMap(); + + HashMap locmap = getI18nMap().get(locale); + if (locmap != null) { // if launcher strings exist for this locale + for (String key : locmap.keySet()) { + if (locmap.get(key) != null) { + newMap.put(key, locmap.get(key)); + } + } + } + for (CLIOption option : getEngineHelpOptions()) { + String message = option.getHelpMessages().get(locale); + if (message != null) { // if CLIOption strings exist for this locale + newMap.put(ENGINE_OPTION_PREFIX + option.getHelpKey(), getEngineOptionStringFormatted(message)); + } + } + fullMap.put(locale, newMap); + } + return fullMap; + } protected void checkAllParameters() throws IOException { checkBundledJars(); @@ -150,7 +201,7 @@ // i18n properties suffix LogManager.log(ErrorLevel.DEBUG, "Check i18n..."); String suffix = getI18NResourcePrefix(); - if(i18nMap.isEmpty() && suffix!=null) { + if(getI18nMap().isEmpty() && suffix!=null) { // load from engine`s entries list LogManager.log("... i18n properties were not set. using default from resources"); InputStream is = ResourceUtils.getResource(EngineResources.ENGINE_CONTENTS_LIST); diff -r f5125b13096d nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/ExeLauncher.java --- a/nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/ExeLauncher.java Thu Sep 18 21:27:27 2008 +0400 +++ b/nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/ExeLauncher.java Fri Sep 19 14:06:45 2008 +0400 @@ -43,14 +43,19 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.Enumeration; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Locale; +import java.util.Map; import java.util.MissingResourceException; import java.util.PropertyResourceBundle; +import java.util.Set; import org.netbeans.installer.utils.FileUtils; import org.netbeans.installer.utils.LogManager; import org.netbeans.installer.utils.ResourceUtils; import org.netbeans.installer.utils.StringUtils; +import org.netbeans.installer.utils.cli.CLIOption; import org.netbeans.installer.utils.helper.JavaCompatibleProperties; import org.netbeans.installer.utils.helper.Version; import org.netbeans.installer.utils.system.launchers.LauncherProperties; @@ -121,6 +126,8 @@ LogManager.log("Adding i18n..."); //NOI18N addI18NStrings(fos); + LogManager.log("Adding engine options help..."); //NOI18N + addEngineOptionsHelp(fos); // jvm args addData(fos,jvmArguments, true); LogManager.log("JVM Arguments: " + //NOI18N @@ -247,39 +254,43 @@ addData(fos); // fill with some chars } } + + @Override + protected String getEngineOptionStringFormatted(String message) { + return "{0}\t" + message; + } private void addI18NStrings(FileOutputStream fos) throws IOException { - addNumber(fos, i18nMap.size()); // number of locales + HashMap > i18nStrings = getFullI18nMap(); + addNumber(fos, i18nStrings.size()); // number of locales - PropertyResourceBundle defaultBundle = i18nMap.get(""); + HashMap defaultBundle = i18nStrings.get(new Locale(StringUtils.EMPTY_STRING)); //properties names List props = new LinkedList (); - Enumeration en = defaultBundle.getKeys(); - long numberOfProperties = 0; - while(en.hasMoreElements()) { - en.nextElement(); - numberOfProperties++; - } - addNumber(fos,numberOfProperties); // number of properties - String propertyName; - en = defaultBundle.getKeys(); - while(en.hasMoreElements()) { - propertyName = en.nextElement(); + addNumber(fos,defaultBundle.keySet().size()); // number of properties + + for(String propertyName : defaultBundle.keySet()) { props.add(propertyName); addData(fos, propertyName, false); // save property name as ascii } + addData(fos, defaultBundle, null, new Locale(StringUtils.EMPTY_STRING), props); + i18nStrings.remove(new Locale(StringUtils.EMPTY_STRING)); + Locale [] locales = i18nStrings.keySet().toArray(new Locale[] {}); - addData(fos, defaultBundle, null, StringUtils.EMPTY_STRING, props); - i18nMap.remove(StringUtils.EMPTY_STRING); - Object [] locales = i18nMap.keySet().toArray(); - - for(int i=0;i list = getEngineHelpOptions(); + addNumber(fos, list.size()); //NOI18N + for(CLIOption option : list){ + addData(fos, option.getName(), true); + addData(fos, ENGINE_OPTION_PREFIX + option.getHelpKey(), false); + } + } private void addJavaCompatibleProperties(FileOutputStream fos) throws IOException { LogManager.log("Total compatible java properties : " + compatibleJava.size()); //NOI18N LogManager.indent(); @@ -374,18 +385,18 @@ } } - private void addData(FileOutputStream fos, PropertyResourceBundle bundle, PropertyResourceBundle backupBundle, String localeName, List propertiesNames) throws IOException { - String propertyName; - String localizedString; - addData(fos, localeName, true); - Enumeration en = bundle.getKeys(); - for(int i=0;i bundle, HashMap backupBundle, Locale localeName, List propertiesNames) throws IOException { + addData(fos, localeName.toString(), true); + for(String key : propertiesNames) { String str = null; try { - str = bundle.getString(propertiesNames.get(i)); + str = bundle.get(key); + if(str==null) { + str = backupBundle.get(key); + } } catch (MissingResourceException e) { if(backupBundle!=null) { - str = backupBundle.getString(propertiesNames.get(i)); + str = backupBundle.get(key); } } str = changeJavaPropertyCounter(str); diff -r f5125b13096d nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/JarLauncher.java --- a/nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/JarLauncher.java Thu Sep 18 21:27:27 2008 +0400 +++ b/nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/JarLauncher.java Fri Sep 19 14:06:45 2008 +0400 @@ -111,6 +111,11 @@ protected String getI18NResourcePrefix() { return null; } + + @Override + protected String getEngineOptionStringFormatted(String message) { + return "{0} " + message; + } public String [] getExecutionCommand() { File javaLocation = null; diff -r f5125b13096d nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/ShLauncher.java --- a/nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/ShLauncher.java Thu Sep 18 21:27:27 2008 +0400 +++ b/nbi/engine/src/org/netbeans/installer/utils/system/launchers/impl/ShLauncher.java Fri Sep 19 14:06:45 2008 +0400 @@ -44,13 +44,18 @@ import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.Enumeration; +import java.util.HashMap; import java.util.List; +import java.util.Locale; +import java.util.Map; import java.util.PropertyResourceBundle; +import java.util.Set; import org.netbeans.installer.utils.FileUtils; import org.netbeans.installer.utils.LogManager; import org.netbeans.installer.utils.ResourceUtils; import org.netbeans.installer.utils.StreamUtils; import org.netbeans.installer.utils.StringUtils; +import org.netbeans.installer.utils.cli.CLIOption; import org.netbeans.installer.utils.helper.JavaCompatibleProperties; import org.netbeans.installer.utils.helper.Version; import org.netbeans.installer.utils.system.launchers.LauncherProperties; @@ -145,6 +150,7 @@ addShInitialComment(sb); addPossibleJavaLocations(sb); addI18NStrings(sb); + addEngineOptionsHelp(sb); addTestJVMFile(sb); addClasspathJars(sb); addJavaCompatible(sb); @@ -449,7 +455,8 @@ } private void addI18NStrings(StringBuilder sb) throws IOException { - Object [] locales = i18nMap.keySet().toArray(); + HashMap > i18nStrings = getFullI18nMap(); + Locale [] locales = i18nStrings.keySet().toArray(new Locale [] {}); addNumberVariable(sb,"LAUNCHER_LOCALES_NUMBER",locales.length); //NOI18N for(int i=0;i allKeys = i18nStrings.get(new Locale("")).keySet(); + for(Locale locale : locales) { sb.append("getLocalizedMessage_" + locale + "() {" + SH_LINE_SEPARATOR ); sb.append(SH_INDENT + "arg=$1" + SH_LINE_SEPARATOR ); sb.append(SH_INDENT + "shift" + SH_LINE_SEPARATOR ); sb.append(SH_INDENT + "case $arg in" + SH_LINE_SEPARATOR ); - PropertyResourceBundle rb = i18nMap.get(locales[i]); - Enumeration en = rb.getKeys(); - while(en.hasMoreElements()) { - String name = en.nextElement(); - String value = rb.getString(name); + HashMap rb = i18nStrings.get(locale); + HashMap defaultBundle = i18nStrings.get(new Locale("")); + + for(String name : allKeys){ + String value = rb.get(name); + if(value==null) { + value = defaultBundle.get(name); + } + sb.append(SH_INDENT + "\"" + name + "\")" + SH_LINE_SEPARATOR); String printString = value; - if(locale==null || locale.equals("")) { + if(locale==null || locale.equals(new Locale(""))) { printString = escapeChars(changePropertyCounterStyle(printString)); } else { printString = getUTF8(printString, true); @@ -489,6 +500,26 @@ nextLine(sb); } + } + + @Override + protected String getEngineOptionStringFormatted(String message) { + return "\t{0}\t" + message; + } + + private void addEngineOptionsHelp(StringBuilder sb) throws IOException { + nextLine(sb); + List list = getEngineHelpOptions(); + addNumberVariable(sb, "HELP_MORE_OPTIONS_NUMBER", list.size()); //NOI18N + int counter = 0; + for(CLIOption option : list){ + addStringVariable(sb, "HELP_MORE_OPTION_" + counter + "_NAME", + ENGINE_OPTION_PREFIX + option.getHelpKey()); + addStringVariable(sb, "HELP_MORE_OPTION_" + counter + "_ARG", + option.getName()); + counter++; + } + nextLine(sb); } private void addShInitialComment(StringBuilder sb) throws IOException { nextLine(sb);