Skip to content

Commit

Permalink
Add update centre notifications to Check for Updates dialog when no u…
Browse files Browse the repository at this point in the history
…pdates available.
  • Loading branch information
neilcsmith-net committed Oct 11, 2022
1 parent c3146e0 commit 8c00bce
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ ValidationWarningPanel_ACD=N/A
UninstallUnitWizard_Title=Plugin Installer
LazyOperationDescriptionStep_NoUpdates_Title=<h3>Your application is up to date!</h3>
LazyOperationDescriptionStep_NoUpdates=There are no updates available.
LazyOperationDescriptionStep_Notifications_Title=<h3>Notifications</h3>
LazyOperationDescriptionStep_NoUpdatesWithProblems_Title=<h3>Checking for updates failed.</h3>
LazyOperationDescriptionStep_NoUpdatesWithProblems=Check your network connection, verify that your proxy settings<br>are configured correctly, or try again later.
LazyOperationDescriptionStep_FindUpdates_Title=<b>Checking for updates.</b><br>Please wait while the installer checks for available updates.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.stream.Collectors;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
Expand All @@ -34,6 +35,8 @@
import org.netbeans.api.autoupdate.UpdateElement;
import org.netbeans.api.autoupdate.UpdateManager;
import org.netbeans.api.autoupdate.UpdateUnit;
import org.netbeans.api.autoupdate.UpdateUnitProvider;
import org.netbeans.api.autoupdate.UpdateUnitProviderFactory;
import org.netbeans.modules.autoupdate.ui.Utilities;
import org.netbeans.modules.autoupdate.ui.actions.AutoupdateCheckScheduler;
import org.netbeans.modules.autoupdate.ui.actions.Installer;
Expand Down Expand Up @@ -119,7 +122,8 @@ public Component getComponent() {

@SuppressWarnings("unchecked")
private void checkRealUpdates () {
final Collection<String> problems=new ArrayList<String>();
final Collection<String> problems = new ArrayList<>();
final List<String> notifications = new ArrayList<>();
checkRealUpdatesTask = Installer.RP.post (new Runnable () {
@Override
public void run () {
Expand Down Expand Up @@ -167,6 +171,14 @@ public void run () {
}
});
}
} else {
for (UpdateUnitProvider p :
UpdateUnitProviderFactory.getDefault().getUpdateUnitProviders(true)) {
String desc = p.getDescription();
if (desc != null && desc.contains("<a name=\"autoupdate_catalog_parser\"")) {
notifications.add(desc);
}
}
}
}
});
Expand All @@ -186,25 +198,31 @@ public void taskFinished (Task task) {
@Override
public void run() {
JPanel body;
if(problems==null || problems.isEmpty())
{
body = new OperationDescriptionPanel (
getBundle ("LazyOperationDescriptionStep_NoUpdates_Title"), // NOI18N
getBundle ("LazyOperationDescriptionStep_NoUpdates"), // NOI18N
"", "",
false);
}
else
{
body = new OperationDescriptionPanel (
getBundle ("LazyOperationDescriptionStep_NoUpdatesWithProblems_Title"), // NOI18N
getBundle ("LazyOperationDescriptionStep_NoUpdatesWithProblems"), // NOI18N
"", "",
false);
if (problems.isEmpty()) {
if (notifications.isEmpty()) {
body = new OperationDescriptionPanel(
getBundle("LazyOperationDescriptionStep_NoUpdates_Title"), // NOI18N
getBundle("LazyOperationDescriptionStep_NoUpdates"), // NOI18N
"", "",
false);
} else {
String content = notifications.stream().collect(Collectors.joining("<br><br>"));
body = new OperationDescriptionPanel(
getBundle("LazyOperationDescriptionStep_Notifications_Title"), // NOI18N
content, // NOI18N
"", "",
false);
}
} else {
body = new OperationDescriptionPanel(
getBundle("LazyOperationDescriptionStep_NoUpdatesWithProblems_Title"), // NOI18N
getBundle("LazyOperationDescriptionStep_NoUpdatesWithProblems"), // NOI18N
"", "",
false);
}
component.setBody (body);
component.setWaitingState (false);
fireChange ();
component.setBody(body);
component.setWaitingState(false);
fireChange();
}
}
checkRealUpdatesTask.addTaskListener (new TLAndR());
Expand Down

0 comments on commit 8c00bce

Please sign in to comment.