99import org .eclipse .core .runtime .IProgressMonitor ;
1010import org .eclipse .core .runtime .IStatus ;
1111import org .eclipse .core .runtime .Status ;
12+ import org .eclipse .core .runtime .jobs .IJobChangeEvent ;
13+ import org .eclipse .core .runtime .jobs .IJobChangeListener ;
1214import org .eclipse .core .runtime .jobs .Job ;
1315import org .eclipse .jface .dialogs .IDialogConstants ;
1416import org .eclipse .jface .dialogs .MessageDialog ;
@@ -36,6 +38,10 @@ public class UpdateCheck {
3638
3739 private final boolean isSilent ;
3840
41+ /**
42+ *
43+ * @param isSilent true, if notification should only be shown, if there is an update available
44+ */
3945 public UpdateCheck (boolean isSilent ) {
4046 this .isSilent = isSilent ;
4147 }
@@ -86,9 +92,9 @@ private static boolean needUpdateCheck() {
8692 return false ;
8793 }
8894
89- public static boolean startUpdateCheck (boolean isSilent ) {
95+ public static boolean startUpdateCheck () {
96+ // do not start another update check, if one is already running
9097 if (UpdateCheck .needUpdateCheck ()) {
91-
9298 String binaryPath = CppcheclipsePlugin .getConfigurationPreferenceStore ()
9399 .getString (IPreferenceConstants .P_BINARY_PATH );
94100 new UpdateCheck (true ).check (binaryPath );
@@ -123,7 +129,7 @@ protected IStatus run(IProgressMonitor monitor) {
123129 .format (new Date ()));
124130 configuration .save ();
125131 Display display = Display .getDefault ();
126- display .asyncExec (new UpdateCheckNotifier (newVersion ));
132+ display .syncExec (new UpdateCheckNotifier (newVersion ));
127133 } catch (Exception e ) {
128134 if (!isSilent ) {
129135 CppcheclipsePlugin
@@ -147,7 +153,7 @@ public UpdateCheckNotifier(Version newVersion) {
147153 public void run () {
148154 Shell shell = PlatformUI .getWorkbench ().getActiveWorkbenchWindow ()
149155 .getShell ();
150-
156+ // if no new version found, just display a dialog if not in silent mode
151157 if (newVersion == null ) {
152158 if (!isSilent ) {
153159 MessageDialog .openInformation (shell ,
@@ -201,7 +207,10 @@ public void run() {
201207 public Job check (String binaryPath ) {
202208 Job job = new UpdateCheckJob (binaryPath );
203209 job .setUser (true );
210+ // execute job asynchronously
204211 job .schedule ();
205212 return job ;
206213 }
214+
215+
207216}
0 commit comments