private UploaderPlugin load(SmallModuleEntry sme, int cnt) { synchronized (sme) { if (sme.up != null) { if (!sme.up.intitalized()) { ReactiveThread rt = sme.up.rt; if (rt == null) { if (cnt > 3) return sme.up; return load(sme, cnt + 1); } try { waitTill(rt, 3000, 100, 1d); } catch (InterruptedException ex) { } } return sme.up; } UploaderPlugin up = new UploaderPlugin(sme, updateLocation); sme.up = up; } final Content c = upui.addContent(sme.getName()); try { sme.up.create(c); } catch (Exception a) { System.out.println("for plugin " + sme.getName()); a.printStackTrace(); c.done(); return null; // if this happens, the check box should get unchecked // map.remove(entry.getKey()); //<< this is not going to work } return load(sme, cnt + 1); }
private void updateIndex() throws Exception { final Content c = upui.addContent("Updating list of supported file host"); final ReactiveThread rt1 = ReactiveThread.create( new Runnable() { @Override public void run() { try { HttpUtil.update( "http://www.neembuu.com/uploader/updates/v3.1/update.zip", updateLocation.resolve("update.zip"), c); ReactiveThread.get().updateProgress(0.7d); ZipFSClassLoader.quickExtract(updateLocation.resolve("update.zip")); CheckMajorUpdate cu = new CheckMajorUpdate(updateLocation, sun); cu.check(); } catch (Exception a) { throw new IllegalStateException(a); } } }, new CompletionCallback() { @Override public void completed(ReactiveThread rt) { c.done(); } @Override public void canceled(ReactiveThread rt) { c.done(); } @Override public void progressed(ReactiveThread rt) { c.setProgress(rt.getProgress()); } }); rt1.start(); if (!waitTill(rt1, 20 * 1000, 300, 0.6)) { rt1.cancel(); } }