001: /*******************************************************************************
002: * Copyright (c) 2005, 2007 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: * G&H Softwareentwicklung GmbH - internationalization implementation (bug 150933)
011: *******************************************************************************/package org.eclipse.pde.internal.build.tasks;
012:
013: import java.util.Locale;
014:
015: import org.apache.tools.ant.BuildException;
016: import org.apache.tools.ant.Task;
017:
018: public class JNLPGeneratorTask extends Task {
019:
020: private String feature;
021: private String jnlp = null;
022: private String codebase = null;
023: private String j2se;
024: private Locale locale = Locale.getDefault();
025: private boolean generateOfflineAllowed = true;
026: private String configs = null;
027:
028: /**
029: * The URL location of a feature.xml file. This can be either a jar: URL to the feature.xml,
030: * or a file: url to the feature.
031: * @param value
032: */
033: public void setFeature(String value) {
034: feature = value;
035: }
036:
037: /**
038: * The location the output jnlp file. The value may be null (or simply not set). If it is
039: * null then the output file will be placed beside the feature dir or jar (as appropriate)
040: * and its name will be derived from the feature id and version. If this is set
041: * it must be a file path. If it ends in a "/" or "\" then the output file is places in this
042: * directory with the file name derived as described. Finally, if the value is a file name,
043: * the output is placed in that file.
044: * @param value the location to write the output or null if the default
045: * computed location is to be used.
046: */
047: public void setJNLP(String value) {
048: jnlp = value;
049: }
050:
051: /**
052: * The codebase of the output. This shoudl be a URL that will be used as the
053: * root of all relative URLs in the output. Typically this is the root of the application
054: * deployment website.
055: * @param value the URL root of for the application content.
056: */
057: public void setCodebase(String value) {
058: codebase = value;
059: }
060:
061: /**
062: * The j2se spec of the output
063: * @param value the JNLP j2se spec to use in the output.
064: */
065: public void setJ2SE(String value) {
066: j2se = value;
067: }
068:
069: /**
070: * The locale in which the jnlp file generated should be translated into.
071: *The translation values are read from the feature_<locale>.properties file.
072: * @param the locale in which to generate the jnlp files.
073: * */
074: public void setLocale(String nlsString) {
075: String[] strings = nlsString.split("_"); //$NON-NLS-1$
076: if (nlsString.charAt(0) == '$')
077: return;
078:
079: if (strings != null) {
080: switch (strings.length) {
081: case 1:
082: locale = new Locale(strings[0]);
083: break;
084: case 2:
085: locale = new Locale(strings[0], strings[1]);
086: break;
087: case 3:
088: locale = new Locale(strings[0], strings[1], strings[2]);
089: break;
090: }
091: }
092: }
093:
094: public void execute() throws BuildException {
095: JNLPGenerator generator = new JNLPGenerator(feature, jnlp,
096: codebase, j2se, locale, generateOfflineAllowed, configs);
097: generator.process();
098: }
099:
100: public void setGenerateOfflineAllowed(String generateOfflineAllowed) {
101: if (generateOfflineAllowed.equalsIgnoreCase("false")) //$NON-NLS-1$
102: this .generateOfflineAllowed = false;
103: if (generateOfflineAllowed.equalsIgnoreCase("true")) //$NON-NLS-1$
104: this .generateOfflineAllowed = false;
105: }
106:
107: public void setConfigInfo(String configs) {
108: this.configs = configs;
109: }
110:
111: }
|