use of org.netbeans.api.autoupdate.OperationContainer in project netbeans-rcp-lite by outersky.
the class LazyOperationDescriptionStep method checkRealUpdates.
@SuppressWarnings("unchecked")
private void checkRealUpdates() {
final Collection<String> problems = new ArrayList<String>();
checkRealUpdatesTask = Installer.RP.post(new Runnable() {
@Override
public void run() {
final Collection<UpdateElement> updateElementsForStore = new HashSet<UpdateElement>();
final Collection<UpdateElement> updates = AutoupdateCheckScheduler.checkUpdateElements(operationType, problems, forceReload, updateElementsForStore);
hasUpdates = updates != null && !updates.isEmpty();
if (hasUpdates) {
assert wd != null : "WizardDescriptor must found!";
OperationContainer oc = OperationType.UPDATE == operationType ? OperationContainer.createForUpdate() : OperationContainer.createForInstall();
boolean allOk = true;
InstallUnitWizardModel model = new InstallUnitWizardModel(operationType, oc);
for (UpdateElement el : updates) {
UpdateUnit uu = el.getUpdateUnit();
if (UpdateManager.TYPE.CUSTOM_HANDLED_COMPONENT == uu.getType()) {
allOk &= model.getCustomHandledContainer().canBeAdded(uu, el);
} else {
allOk &= oc.canBeAdded(uu, el);
}
}
hasUpdates = hasUpdates && allOk;
if (allOk) {
for (UpdateElement el : updates) {
UpdateUnit uu = el.getUpdateUnit();
if (UpdateManager.TYPE.CUSTOM_HANDLED_COMPONENT == uu.getType()) {
model.getCustomHandledContainer().add(el);
} else {
oc.add(el);
}
}
model.getBaseContainer().listAll();
final WizardDescriptor.Iterator<WizardDescriptor> panels = new InstallUnitWizardIterator(model, true);
// call InstallUnitWizardIterator.compactPanels outside AWT
((InstallUnitWizardIterator) panels).hasNext();
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
wd.setPanelsAndSettings(panels, wd);
fireChange();
LazyUnit.storeUpdateElements(operationType, updateElementsForStore);
}
});
}
}
}
});
class TLAndR implements TaskListener, Runnable {
@Override
public void taskFinished(Task task) {
task.removeTaskListener(this);
if (!hasUpdates) {
installModel = Collections.EMPTY_SET;
new InstallUnitWizardModel(null, null).modifyOptionsForDoClose(wd);
canClose = true;
LazyUnit.storeLazyUnits(operationType, installModel);
EventQueue.invokeLater(this);
}
}
@Override
public void run() {
JPanel body;
if (problems == null || problems.isEmpty()) {
body = new OperationDescriptionPanel(// NOI18N
getBundle("LazyOperationDescriptionStep_NoUpdates_Title"), // NOI18N
getBundle("LazyOperationDescriptionStep_NoUpdates"), "", "", false);
} else {
body = new OperationDescriptionPanel(// NOI18N
getBundle("LazyOperationDescriptionStep_NoUpdatesWithProblems_Title"), // NOI18N
getBundle("LazyOperationDescriptionStep_NoUpdatesWithProblems"), "", "", false);
}
component.setBody(body);
component.setWaitingState(false);
fireChange();
}
}
checkRealUpdatesTask.addTaskListener(new TLAndR());
}
use of org.netbeans.api.autoupdate.OperationContainer in project netbeans-rcp-lite by outersky.
the class OperationWizardModel method addRequiredElements.
private void addRequiredElements(Set<UpdateElement> elems) {
OperationContainer baseContainer = getBaseContainer();
OperationContainer customContainer = getCustomHandledContainer();
OperationContainer installContainer = getInstallContainer();
for (UpdateElement el : elems) {
if (el == null || el.getUpdateUnit() == null) {
Logger.getLogger(OperationWizardModel.class.getName()).log(Level.INFO, "UpdateElement " + el + " cannot be null" + (el == null ? "" : " or UpdateUnit " + el.getUpdateUnit() + " cannot be null"));
continue;
}
if (UpdateManager.TYPE.CUSTOM_HANDLED_COMPONENT == el.getUpdateUnit().getType()) {
customContainer.add(el);
} else if (baseContainer.canBeAdded(el.getUpdateUnit(), el)) {
baseContainer.add(el);
} else if (installContainer != null && installContainer.canBeAdded(el.getUpdateUnit(), el)) {
installContainer.add(el);
}
}
}
Aggregations