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.api.autoupdate;
043:
044: import org.netbeans.spi.autoupdate.*;
045: import java.io.IOException;
046: import java.net.URL;
047: import java.util.List;
048: import org.netbeans.api.autoupdate.UpdateManager.TYPE;
049: import org.netbeans.api.progress.ProgressHandle;
050: import org.netbeans.modules.autoupdate.services.UpdateUnitProviderImpl;
051:
052: /**<code>UpdateUnitProvider</code> providers <code>UpdateUnit</code>. The units
053: * are build of the of SPI <code>UpdateProvider</code>.
054: *
055: * @see UpdateProvider
056: * @author Jiri Rechtacek
057: */
058: public final class UpdateUnitProvider {
059: public static enum CATEGORY {
060: STANDARD, COMMUNITY, BETA
061: }
062:
063: UpdateUnitProviderImpl impl;
064:
065: UpdateUnitProvider(UpdateUnitProviderImpl impl) {
066: this .impl = impl;
067: }
068:
069: /** Name of provider, this name is used by Autoupdate infrastructure for manimulating
070: * of providers.
071: *
072: * @return name of provider
073: */
074: public String getName() {
075: return impl.getName();
076: }
077:
078: /** Display name of provider. This display name can be visualized in UI.
079: *
080: * @return display name of provider
081: */
082: public String getDisplayName() {
083: return impl.getDisplayName();
084: }
085:
086: /** Sets the display name of the provider. This name can be presented
087: * to users in UI.
088: *
089: * @param name
090: */
091: public void setDisplayName(String name) {
092: impl.setDisplayName(name);
093: }
094:
095: /** Description of provider. This description can be visualized in UI.
096: *
097: * @return description of provider or null
098: */
099: public String getDescription() {
100: return impl.getDescription();
101: }
102:
103: public CATEGORY getCategory() {
104: return impl.getCategory();
105: }
106:
107: /** It's special support for <code>UpdateProvider</code> based on Autoupdate Catalog.
108: * It's most kind of Update Providers and have a special support in UI.
109: *
110: * @return URL of provider URL or null if and only if the UpdateProvider doesn't based of Autoupdate Catalog
111: */
112: public URL getProviderURL() {
113: return impl.getProviderURL();
114: }
115:
116: /** Modified URL of URL-based provider. If the UpdateProvider doesn't support URL then the method has no affect.
117: *
118: * @param url new URL
119: */
120: public void setProviderURL(URL url) {
121: impl.setProviderURL(url);
122: }
123:
124: /** Returns <code>java.util.List</code> of <code>UpdateUnit</code> build of the content of the
125: * provider.
126: *
127: * @return list of UpdateUnit
128: */
129: public List<UpdateUnit> getUpdateUnits() {
130: return impl.getUpdateUnits();
131: }
132:
133: /** Returns <code>java.util.List</code> of <code>UpdateUnit</code> build of the content of the
134: * provider.
135: *
136: * @param types returns <code>UpdateUnit</code>s contain only given types, e.g. modules for <code>MODULE</code> type.
137: * If types is <code>null</code> or null then returns default types
138: * @return list of UpdateUnit
139: */
140: public List<UpdateUnit> getUpdateUnits(TYPE... types) {
141: return impl.getUpdateUnits(types);
142: }
143:
144: /** Make refresh of content of the provider. The content can be read from
145: * a cache. The <code>force</code> parameter forces reading content from
146: * remote server.
147: *
148: * @param handle started ProgressHandle or null
149: * @param force if true then forces to reread the content from server
150: * @return true if refresh succeed
151: * @throws java.io.IOException when any network problem appreared
152: */
153: public boolean refresh(ProgressHandle handle, boolean force)
154: throws IOException {
155: return impl.refresh(handle, force);
156: }
157:
158: /** Returns <code>true</code> if the provider is automatically checked and its <code>UpdateUnit</code> are
159: * returned from <code>UpdateManager</code>
160: *
161: * @return enable flag
162: */
163: public boolean isEnabled() {
164: return impl.isEnabled();
165: }
166:
167: /** Sets the enable flag.
168: *
169: * @see #isEnabled
170: * @param state
171: */
172: public void setEnable(boolean state) {
173: impl.setEnable(state);
174: }
175:
176: }
|