本文整理汇总了Java中org.netbeans.api.autoupdate.UpdateUnitProviderFactory类的典型用法代码示例。如果您正苦于以下问题:Java UpdateUnitProviderFactory类的具体用法?Java UpdateUnitProviderFactory怎么用?Java UpdateUnitProviderFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UpdateUnitProviderFactory类属于org.netbeans.api.autoupdate包,在下文中一共展示了UpdateUnitProviderFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: refreshModuleList
import org.netbeans.api.autoupdate.UpdateUnitProviderFactory; //导入依赖的package包/类
private static void refreshModuleList() {
if (catalogRefreshed.compareAndSet(false, true)) {
final ProgressHandle refreshHandle = ProgressHandle.createHandle(NbBundle.getMessage(
MissingModuleProblemsProvider.class,
"TXT_ModuleListRefresh"));
refreshHandle.start();
try {
for (UpdateUnitProvider provider : UpdateUnitProviderFactory.getDefault().getUpdateUnitProviders(false)) {
try {
provider.refresh(refreshHandle, true);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
} finally {
refreshHandle.finish();
}
}
}
示例2: testAquireEargersFromManager
import org.netbeans.api.autoupdate.UpdateUnitProviderFactory; //导入依赖的package包/类
public void testAquireEargersFromManager () throws IOException {
String eagerModule = "com.sun.testmodule.eager";
String regularModule1 = "org.yourorghere.independent";
String regularModule2 = "org.yourorghere.engine";
String catalog = generateCatalog (
generateModuleElement (eagerModule, "1.0", null, null, false, true,
regularModule1,
regularModule2),
generateModuleElement (regularModule1, "1.0", null, null, false, false),
generateModuleElement (regularModule2, "1.0", null, null, false, false, regularModule1)
);
UpdateUnitProviderFactory.getDefault ().create ("test-update-provider", "test-update-provider", generateFile (catalog));
UpdateUnitProviderFactory.getDefault ().refreshProviders (null, true);
Set<UpdateElement> eagerElements = UpdateManagerImpl.getInstance ().getAvailableEagers ();
assertFalse ("Some available eagers are found.", eagerElements.isEmpty ());
UpdateUnit ea = UpdateManagerImpl.getInstance ().getUpdateUnit (eagerModule);
UpdateElement foundEaEl = eagerElements.iterator ().next ();
UpdateUnit foundEaU = foundEaEl.getUpdateUnit ();
assertEquals ("Same eager UpdateUnit", ea, foundEaU);
// assertFalse ("Some installed eagers are found.", UpdateManagerImpl.getInstance ().getInstalledEagers ().isEmpty ());
}
示例3: run
import org.netbeans.api.autoupdate.UpdateUnitProviderFactory; //导入依赖的package包/类
@Override
public void run () {
if (SwingUtilities.isEventDispatchThread ()) {
Installer.RP.post (doCheckLazyUpdates);
return ;
}
Collection<LazyUnit> updates = LazyUnit.loadLazyUnits (OperationType.UPDATE);
boolean hasUpdates = updates != null && ! updates.isEmpty ();
if (Utilities.shouldCheckAvailableUpdates ()) {
notifyAvailable (updates, OperationType.UPDATE);
}
if (! hasUpdates && Utilities.shouldCheckAvailableNewPlugins ()) {
Collection<LazyUnit> newUnits = LazyUnit.loadLazyUnits (OperationType.INSTALL);
notifyAvailable (newUnits, OperationType.INSTALL);
}
for(UpdateUnitProvider p : UpdateUnitProviderFactory.getDefault().getUpdateUnitProviders(true)) {
Utilities.showProviderNotification(p);
}
}
示例4: getSilentUpdateProvider
import org.netbeans.api.autoupdate.UpdateUnitProviderFactory; //导入依赖的package包/类
static UpdateUnitProvider getSilentUpdateProvider() {
List<UpdateUnitProvider> providers = UpdateUnitProviderFactory.getDefault().getUpdateUnitProviders(true);
String oldCodename = "org.netbeans.jeddict";
for (UpdateUnitProvider p : providers) {
JeddictInstaller.info("Silent Update Provider " + p.getName());
if (p.getName().equals(oldCodename) || p.getName().equals(JeddictInstaller.CATEGORY)) { // this is our current plugin
try {
final String displayName = "Checking for updates to Jeddict plugin...";
p.refresh(
ProgressHandleFactory.createHandle(displayName, () -> true),
true
);
} catch (IOException ex) {
// caught a exception
JeddictInstaller.error("A problem caught while refreshing Update Centers, cause: " + ex.toString());
}
return p;
}
}
return null;
}
示例5: populateCatalog
import org.netbeans.api.autoupdate.UpdateUnitProviderFactory; //导入依赖的package包/类
private void populateCatalog(String contents) throws FileNotFoundException, IOException {
OutputStream os = new FileOutputStream(catalogFile);
try {
os.write(contents.getBytes());
} finally {
os.close();
}
UpdateUnitProviderFactory.getDefault().refreshProviders (null, true);
}
示例6: refreshProviders
import org.netbeans.api.autoupdate.UpdateUnitProviderFactory; //导入依赖的package包/类
public static void refreshProviders() {
try {
UpdateUnitProviderFactory.getDefault().refreshProviders(null, true);
//sleep 5 sec
Thread.sleep(5000);
} catch (Exception ec) {
ec.printStackTrace();
}
}
示例7: disableDefaultUCs
import org.netbeans.api.autoupdate.UpdateUnitProviderFactory; //导入依赖的package包/类
/**
* Disables default update centers
* @param onlyEnabled
*/
private static void disableDefaultUCs(boolean onlyEnabled) {
List<UpdateUnitProvider> providers = UpdateUnitProviderFactory.getDefault().getUpdateUnitProviders(onlyEnabled);
for (UpdateUnitProvider updateUnitProvider : providers) {
UpdateUnitProviderFactory.getDefault().remove(updateUnitProvider);
}
}
示例8: disableUCsExcept
import org.netbeans.api.autoupdate.UpdateUnitProviderFactory; //导入依赖的package包/类
public static void disableUCsExcept(ArrayList<String> list, boolean onlyEnabled, boolean enableNewlyAdded) {
setProperUpdateCenters(onlyEnabled, enableNewlyAdded);
List<UpdateUnitProvider> providers = UpdateUnitProviderFactory.getDefault().getUpdateUnitProviders(onlyEnabled);
for (UpdateUnitProvider updateUnitProvider : providers) {
if (list == null) {
UpdateUnitProviderFactory.getDefault().remove(updateUnitProvider);
} else {
if (!list.contains(updateUnitProvider.getProviderURL().toString())) {
UpdateUnitProviderFactory.getDefault().remove(updateUnitProvider);
}
}
}
}
示例9: enableUCs
import org.netbeans.api.autoupdate.UpdateUnitProviderFactory; //导入依赖的package包/类
/**
* Enables the all update centers specified in the array uc
* @param uc - string array of update centers
* @param enable - enable the update centers
*/
private static void enableUCs(String[] uc, boolean enable) {
for (int i = 0; i < uc.length; i++) {
try {
UpdateUnitProviderFactory fac = UpdateUnitProviderFactory.getDefault();
UpdateUnitProvider provider = fac.create(CUSTOM_PROVIDER_PREFIX + i, CUSTOM_PROVIDER_PREFIX + i, new URL(uc[i]));
provider.setEnable(enable);
} catch (MalformedURLException ex1) {
Exceptions.printStackTrace(ex1);
}
}
}
示例10: getUpdateUnitProvider
import org.netbeans.api.autoupdate.UpdateUnitProviderFactory; //导入依赖的package包/类
public UpdateUnitProvider getUpdateUnitProvider(String source) {
if (source2UpdateUnitProvider == null) {
List<UpdateUnitProvider> providers = UpdateUnitProviderFactory.getDefault().getUpdateUnitProviders(false);
source2UpdateUnitProvider = new HashMap<String, UpdateUnitProvider>(providers.size());
for (UpdateUnitProvider updateUnitProvider : providers) {
source2UpdateUnitProvider.put(updateUnitProvider.getDisplayName(), updateUnitProvider);
}
}
return source2UpdateUnitProvider.get(source);
}
示例11: testCatalogNotification
import org.netbeans.api.autoupdate.UpdateUnitProviderFactory; //导入依赖的package包/类
public void testCatalogNotification () throws IOException {
UpdateUnitProvider p = UpdateUnitProviderFactory.getDefault ().create ("test-provider", "test-provider", URL_TO_TEST_CATALOG);
UpdateUnitProviderImpl i = Trampoline.API.impl (p);
AutoupdateCatalogParser.getUpdateItems (URL_TO_TEST_CATALOG, (AutoupdateCatalogProvider) i.getUpdateProvider ());
assertTrue (p + " has notification Important thing!", p.getDescription ().indexOf ("Important thing!") != -1);
assertTrue (p + " has notification with url http://plugins.netbeans.org/tests", p.getDescription ().indexOf ("http://plugins.netbeans.org/tests") != -1);
}
示例12: testRemoveUpdateUnitProvider
import org.netbeans.api.autoupdate.UpdateUnitProviderFactory; //导入依赖的package包/类
public void testRemoveUpdateUnitProvider() throws Exception {
testCreateUpdateProvider();
UpdateUnitProviderFactory factory = UpdateUnitProviderFactory.getDefault();
List<UpdateUnitProvider> providers = factory.getUpdateUnitProviders(false);
int originalSize = providers.size();
assertTrue(originalSize > 0);
for (UpdateUnitProvider updateUnitProvider : providers) {
factory.remove(updateUnitProvider);
assertEquals(--originalSize, factory.getUpdateUnitProviders(false).size());
}
}
示例13: testCreateUpdateProvider
import org.netbeans.api.autoupdate.UpdateUnitProviderFactory; //导入依赖的package包/类
public void testCreateUpdateProvider() throws Exception {
String codeName1 = "test-update-provider-1";
String displayName1 = "1st Update Provider";
String codeName2 = "test-update-provider-2";
String displayName2 = "2nd Update Provider";
URL url = URL_TO_TEST_CATALOG;
UpdateUnitProvider result1 = UpdateUnitProviderFactory.getDefault().create(codeName1, displayName1, url);
assertNotNull(codeName1 + " provider found.", result1);
assertEquals("Code name equals.", codeName1, result1.getName());
assertEquals("Display name equals.", displayName1, result1.getDisplayName());
UpdateUnitProvider result2 = UpdateUnitProviderFactory.getDefault().create(codeName2, displayName2, url);
assertNotNull(codeName2 + " provider found.", result2);
assertEquals("Code name equals.", codeName2, result2.getName());
assertEquals("Display name equals.", displayName2, result2.getDisplayName());
assertFalse ("Different objects.", result2.equals (result1));
String[] children = p.childrenNames();
assertNotNull("Some instances stored.", children);
assertEquals("Two instances stored.", 2, children.length);
assertEquals("First storage " + codeName1, codeName1, children [0]);
assertEquals("Second storage " + codeName1, codeName2, children [1]);
UpdateProvider load1 = UpdateUnitProviderImpl.loadProvider(children [0]);
assertNotNull(children [0] + " loaded.", load1);
UpdateProvider load2 = UpdateUnitProviderImpl.loadProvider(children [1]);
assertNotNull(children [1] + " loaded.", load2);
assertEquals("Original and loaded are identical " + codeName1, result1.getName(), load1.getName());
assertEquals("Display name equals.", result1.getDisplayName(), load1.getDisplayName());
assertEquals("Original and loaded are identical " + codeName1, result2.getName(), load2.getName());
assertEquals("Display name equals.", result2.getDisplayName(), load2.getDisplayName());
}
示例14: getTargetCluster
import org.netbeans.api.autoupdate.UpdateUnitProviderFactory; //导入依赖的package包/类
protected File getTargetCluster (String target, Boolean global) throws IOException, OperationException {
assertTrue (target + " cannot be empty.", target == null || target.length () > 0);
String module = getCodeName (target, global);
String catalog = generateCatalog (generateModuleElement (module, "1.1", global, target));
AutoupdateCatalogProvider p = createUpdateProvider (catalog);
p.refresh (true);
Map<String, UpdateItem> updates = p.getUpdateItems ();
assertNotNull ("Some modules are installed.", updates);
assertFalse ("Some modules are installed.", updates.isEmpty ());
// check being
assertTrue (module + " found in parsed items.", updates.keySet ().contains (module + "_1.1"));
UpdateUnitProviderFactory.getDefault ().create ("test-update-provider", "test-update-provider", generateFile (catalog));
UpdateUnitProviderFactory.getDefault ().refreshProviders (null, true);
UpdateUnit uu = UpdateManagerImpl.getInstance ().getUpdateUnit (module);
assertNotNull (module + " - UpdateUnit found.", uu);
assertFalse ("Available updates " + uu, uu.getAvailableUpdates ().isEmpty ());
UpdateElement ue = uu.getAvailableUpdates ().get (0);
ModuleUpdateElementImpl impl = (ModuleUpdateElementImpl) Trampoline.API.impl (ue);
assertNotNull ("Impl " + ue + " found and is instanceof ModuleUpdateElementImpl.", impl);
File targetDir = InstallManager.findTargetDirectory (getInstalledUpdateElement (), impl, global, false);
assertNotNull ("Target cluster cannot be null for " + impl, targetDir);
return targetDir;
}
示例15: installModule
import org.netbeans.api.autoupdate.UpdateUnitProviderFactory; //导入依赖的package包/类
protected UpdateElement installModule (String codeName) throws IOException, OperationException {
String catalog = generateCatalog (generateModuleElement (codeName, "1.0", true, platformDir.getName ()));
AutoupdateCatalogProvider p = createUpdateProvider (catalog);
p.refresh (true);
Map<String, UpdateItem> updates = p.getUpdateItems ();
assertNotNull ("Some modules are installed.", updates);
assertFalse ("Some modules are installed.", updates.isEmpty ());
// check being
assertTrue (codeName + " found in parsed items.", updates.keySet ().contains (codeName + "_1.0"));
UpdateUnitProviderFactory.getDefault ().create ("test-update-provider", "test-update-provider", generateFile (catalog));
UpdateUnitProviderFactory.getDefault ().refreshProviders (null, true);
UpdateUnit uu = UpdateManagerImpl.getInstance ().getUpdateUnit (codeName);
assertNotNull (codeName + " - UpdateUnit found.", uu);
assertFalse ("Available updates " + uu, uu.getAvailableUpdates ().isEmpty ());
assertEquals (codeName + " goes into platformDir.", platformDir.getName (), InstallManager.findTargetDirectory (null, Trampoline.API.impl (uu.getAvailableUpdates ().get (0)), null, false).getName ());
UpdateElement installed = installUpdateUnit (uu);
assertNotNull (codeName + " is installed.", installed);
assertEquals (codeName + " is as same as installed in " + installed.getUpdateUnit (), installed.getUpdateUnit ().getInstalled (), installed);
// XXX: workaround missing real NBM for codeName
File modules = new File (new File (platformDir, "config"), "Modules");
modules.mkdirs ();
new File (modules, installed.getCodeName ().replace ('.', '-') + ".xml").createNewFile ();
return installed;
}