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.modules.autoupdate.services;
043:
044: import org.netbeans.modules.autoupdate.updateprovider.InstallInfo;
045: import org.netbeans.modules.autoupdate.updateprovider.LocalizationItem;
046: import java.util.Collections;
047: import java.util.List;
048: import org.netbeans.api.autoupdate.UpdateManager;
049: import org.openide.modules.ModuleInfo;
050: import org.openide.modules.SpecificationVersion;
051:
052: /**
053: *
054: * @author Jiri Rechtacek
055: */
056: public class LocalizationUpdateElementImpl extends UpdateElementImpl {
057: private String codeName;
058: private String displayName;
059: private SpecificationVersion specVersion;
060: private String description;
061: private String source;
062: private String author;
063: private String homepage;
064: private int downloadSize;
065: private String category;
066: private InstallInfo installInfo;
067: private LocalizationItem localizationItem;
068:
069: public LocalizationUpdateElementImpl(LocalizationItem item,
070: String providerName) {
071: super (item, providerName);
072: codeName = item.getCodeName();
073: specVersion = new SpecificationVersion(item
074: .getSpecificationVersion());
075: source = providerName;
076: installInfo = new InstallInfo(item);
077: displayName = item.getLocalizedModuleName();
078: description = item.getLocalizedModuleDescription();
079: category = item.getCategory();
080: this .localizationItem = item;
081: }
082:
083: public String getCodeName() {
084: return codeName;
085: }
086:
087: public String getDisplayName() {
088: return displayName;
089: }
090:
091: public SpecificationVersion getSpecificationVersion() {
092: return specVersion;
093: }
094:
095: public String getDescription() {
096: return description;
097: }
098:
099: public String getNotification() {
100: return null;
101: }
102:
103: public String getAuthor() {
104: return author;
105: }
106:
107: public String getHomepage() {
108: return homepage;
109: }
110:
111: public int getDownloadSize() {
112: return downloadSize;
113: }
114:
115: public String getSource() {
116: return source;
117: }
118:
119: public String getCategory() {
120: if (category != null) {
121: category = UpdateUnitFactory.UNSORTED_CATEGORY;
122: }
123: return category;
124: }
125:
126: public String getDate() {
127: return null;
128: }
129:
130: public String getLicence() {
131: return localizationItem.getAgreement();
132: }
133:
134: public InstallInfo getInstallInfo() {
135: return installInfo;
136: }
137:
138: public List<ModuleInfo> getModuleInfos() {
139: // XXX: localization vs. modules
140: return Collections.emptyList();
141: }
142:
143: public UpdateManager.TYPE getType() {
144: return UpdateManager.TYPE.LOCALIZATION;
145: }
146:
147: public boolean isEnabled() {
148: // XXX: how to detect if localization is enabled?
149: return false;
150: }
151:
152: public boolean isAutoload() {
153: return false;
154: }
155:
156: public boolean isEager() {
157: return false;
158: }
159:
160: public boolean isFixed() {
161: return false;
162: }
163:
164: public boolean equals(Object obj) {
165: if (obj == null)
166: return false;
167: if (getClass() != obj.getClass())
168: return false;
169: final LocalizationUpdateElementImpl other = (LocalizationUpdateElementImpl) obj;
170:
171: if (this .specVersion != other.specVersion
172: && (this .specVersion == null || !this .specVersion
173: .equals(other.specVersion)))
174: return false;
175: if (this .codeName != other.codeName
176: && (this .codeName == null || !this .codeName
177: .equals(other.codeName)))
178: return false;
179: return true;
180: }
181:
182: public int hashCode() {
183: int hash = 5;
184:
185: hash = 61
186: * hash
187: + (this .codeName != null ? this .codeName.hashCode() : 0);
188: hash = 61
189: * hash
190: + (this .specVersion != null ? this .specVersion
191: .hashCode() : 0);
192: return hash;
193: }
194:
195: }
|