001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.spi.autoupdate;
043:
044: import java.net.URL;
045: import java.util.Locale;
046: import java.util.Set;
047: import java.util.jar.Manifest;
048: import org.netbeans.modules.autoupdate.updateprovider.LocalizationItem;
049: import org.netbeans.modules.autoupdate.updateprovider.FeatureItem;
050: import org.netbeans.modules.autoupdate.updateprovider.ModuleItem;
051: import org.netbeans.modules.autoupdate.updateprovider.NativeComponentItem;
052: import org.netbeans.modules.autoupdate.services.Trampoline;
053: import org.netbeans.modules.autoupdate.updateprovider.UpdateItemImpl;
054:
055: /** Represents a item of content provider by <code>UpdateProvider</code>. These items are exposed to
056: * Autoupdate infrastructure what works on them.
057: *
058: * @author Jiri Rechtacek
059: */
060: public final class UpdateItem {
061: static {
062: Trampoline.SPI = new TrampolineSPI();
063: }
064:
065: UpdateItemImpl impl;
066: UpdateItem original;
067:
068: /** Creates a new instance of UpdateItem */
069: UpdateItem(UpdateItemImpl item) {
070: impl = item;
071: item.setUpdateItem(this );
072: }
073:
074: /** Creates <code>UpdateItem/code> which represents NetBeans Module in Autoupdate infrastructure.
075: * UpdateItem is identify by <code>codeName</code> and <code>specificationVersion<code>.
076: *
077: * @param codeName code name of module
078: * @param specificationVersion specification version of module
079: * @param distribution URL to NBM file
080: * @param author name of module author or null
081: * @param downloadSize size of NBM file in bytes
082: * @param homepage homepage of module or null
083: * @param publishDate date of publish of item, in date format "yyyy/MM/dd"
084: * @param category name of category
085: * @param manifest <code>java.util.jar.Manifest</code> describes the module in NetBeans module system
086: * @param isEager says if the module is <code>eager</code> or not
087: * @param isAutoload says if the module is <code>autoload</code> or not
088: * @param needsRestart if true then IDE must be restarted after module installation
089: * @param isGlobal control if the module will be installed into the installation directory or into user's dir
090: * @param targetCluster name of cluster where new module will be installed if installation isGlobal
091: * @param license <code>UpdateLicense</code> represents license name and text of license agreement
092: * @return UpdateItem
093: */
094: public static final UpdateItem createModule(String codeName,
095: String specificationVersion, URL distribution,
096: String author, String downloadSize, String homepage,
097: String publishDate, String category, Manifest manifest,
098: Boolean isEager, Boolean isAutoload, Boolean needsRestart,
099: Boolean isGlobal, String targetCluster,
100: UpdateLicense license) {
101: ModuleItem item = new ModuleItem(codeName,
102: specificationVersion, distribution, author,
103: publishDate, downloadSize, homepage, category,
104: manifest, isEager, isAutoload, needsRestart, isGlobal,
105: targetCluster, license.impl);
106: return new UpdateItem(item);
107: }
108:
109: /** Creates <code>UpdateItem</code> which represents <code>Feature</code>, it's means group
110: * of NetBeans Modules. This <code>Feature</code> is handled in UI as atomic item.
111: * UpdateItem is identify by <code>codeName</code> and <code>specificationVersion<code>.
112: *
113: *
114: * @param codeName code name of feature
115: * @param specificationVersion specification version of feature
116: * @param dependencies dependencies to NetBeans modules on which is the feature based
117: * @param displayName display name
118: * @param description description
119: * @param category name of category
120: * @return UpdateItem
121: */
122: public static final UpdateItem createFeature(String codeName,
123: String specificationVersion, Set<String> dependencies,
124: String displayName, String description, String category) {
125: FeatureItem item = new FeatureItem(codeName,
126: specificationVersion, dependencies, displayName,
127: description, category);
128: return new UpdateItem(item);
129: }
130:
131: /** Creates <code>UpdateItem</code> which represents Native Component with own installer. This component
132: * can be visualized in UI as common item, when an user wants to install this component then
133: * own <code>CustomInstaller</code> is call back.
134: *
135: * @param codeName code name of the native component
136: * @param specificationVersion specification version of component
137: * @param dependencies dependencies to other <code>UpdateItem</code>
138: * @param downloadSize size of installation file in bytes
139: * @param displayName display name
140: * @param description description
141: * @param needsRestart if true then IDE must be restarted after component installation
142: * @param isGlobal control if the control will be installed into the installation directory or into user's dir
143: * @param targetCluster name of cluster where new module will be installed if installation isGlobal
144: * @param installer <code>CustomInstaller</code> call-back interface
145: * @param license <code>UpdateLicense</code> represents license name and text of license agreement
146: * @return <code>UpdateItem</code>
147: */
148: public static final UpdateItem createNativeComponent(
149: String codeName, String specificationVersion,
150: String downloadSize, Set<String> dependencies,
151: String displayName, String description,
152: Boolean needsRestart, Boolean isGlobal,
153: String targetCluster, CustomInstaller installer,
154: UpdateLicense license // XXX: useless now
155: ) {
156: NativeComponentItem item = new NativeComponentItem(false,
157: codeName, specificationVersion, downloadSize,
158: dependencies, displayName, description, needsRestart,
159: isGlobal, targetCluster, installer, null, null);
160: return new UpdateItem(item);
161: }
162:
163: /** Creates <code>UpdateItem</code> which represents Native Component with own installer. This component
164: * can be visualized in UI as common item, when an user wants to install this component then
165: * own <code>CustomInstaller</code> is call back.
166: *
167: * @param codeName code name of the native component
168: * @param specificationVersion specification version of component
169: * @param dependencies dependencies to other <code>UpdateItem</code>
170: * @param displayName display name
171: * @param description description
172: * @param uninstaller <code>CustomUninstaller</code> call-back interface
173: * @return <code>UpdateItem</code>
174: */
175: public static final UpdateItem createInstalledNativeComponent(
176: String codeName, String specificationVersion,
177: Set<String> dependencies, String displayName,
178: String description, CustomUninstaller uninstaller) {
179: NativeComponentItem item = new NativeComponentItem(true,
180: codeName, specificationVersion, null, dependencies,
181: displayName, description, null, null, null, null,
182: uninstaller, null);
183: return new UpdateItem(item);
184: }
185:
186: /** Creates <code>UpdateItem</code> which can localized NetBeans Module in given <code>Locale</code>.
187: *
188: * @param codeName code name of the module for localization
189: * @param specificationVersion specification version of localization
190: * @param moduleSpecificationVersion specification version of the module for localization
191: * @param locale locale
192: * @param branding branding
193: * @param localizedName localized name of module
194: * @param localizedDescription localized descripton of module
195: * @param category name of category
196: * @param distribution URL to NBM file
197: * @param needsRestart if true then IDE must be restarted after module installation
198: * @param isGlobal control if the module will be installed into the installation directory or into user's dir
199: * @param targetCluster name of cluster where new module will be installed if installation isGlobal
200: * @param license <code>UpdateLicense</code> represents license name and text of license agreement
201: * @return <code>UpdateItem</code>
202: */
203: public static final UpdateItem createLocalization(String codeName,
204: String specificationVersion,
205: String moduleSpecificationVersion, Locale locale,
206: String branding, String localizedName,
207: String localizedDescription, String category,
208: URL distribution, Boolean needsRestart, Boolean isGlobal,
209: String targetCluster, UpdateLicense license) {
210: LocalizationItem item = new LocalizationItem(codeName,
211: specificationVersion, distribution, locale, branding,
212: moduleSpecificationVersion, localizedName,
213: localizedDescription, category, needsRestart, isGlobal,
214: targetCluster, license.impl);
215: return new UpdateItem(item);
216: }
217:
218: }
|