Skip to content

Commit 3e0f656

Browse files
committed
packs: reports added to the Problems window
1 parent c1aa0dd commit 3e0f656

File tree

4 files changed

+75
-14
lines changed

4 files changed

+75
-14
lines changed

ilg.gnuarmeclipse.packs/src/ilg/gnuarmeclipse/packs/Utils.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
import javax.xml.parsers.DocumentBuilderFactory;
3333
import javax.xml.parsers.ParserConfigurationException;
3434

35+
import org.eclipse.core.resources.IMarker;
36+
import org.eclipse.core.resources.ResourcesPlugin;
37+
import org.eclipse.core.runtime.CoreException;
3538
import org.eclipse.core.runtime.IProgressMonitor;
3639
import org.eclipse.ui.console.MessageConsoleStream;
3740
import org.w3c.dom.Document;
@@ -365,4 +368,49 @@ public static void makeFolderReadOnlyRecursive(File folder) {
365368
}
366369
}
367370

371+
public static String reportError(String message) {
372+
373+
try {
374+
IMarker marker = ResourcesPlugin.getWorkspace().getRoot()
375+
.createMarker(IMarker.PROBLEM);
376+
marker.setAttribute(IMarker.MESSAGE, message);
377+
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
378+
marker.setAttribute(IMarker.LOCATION, "-");
379+
} catch (CoreException e) {
380+
System.out.println(message);
381+
}
382+
383+
return message;
384+
}
385+
386+
public static String reportWarning(String message) {
387+
388+
try {
389+
IMarker marker = ResourcesPlugin.getWorkspace().getRoot()
390+
.createMarker(IMarker.PROBLEM);
391+
marker.setAttribute(IMarker.MESSAGE, message);
392+
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
393+
marker.setAttribute(IMarker.LOCATION, "-");
394+
} catch (CoreException e) {
395+
System.out.println(message);
396+
}
397+
398+
return message;
399+
}
400+
401+
public static String reportInfo(String message) {
402+
403+
try {
404+
IMarker marker = ResourcesPlugin.getWorkspace().getRoot()
405+
.createMarker(IMarker.PROBLEM);
406+
marker.setAttribute(IMarker.MESSAGE, message);
407+
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
408+
marker.setAttribute(IMarker.LOCATION, "-");
409+
} catch (CoreException e) {
410+
System.out.println(message);
411+
}
412+
413+
return message;
414+
}
415+
368416
}

ilg.gnuarmeclipse.packs/src/ilg/gnuarmeclipse/packs/handlers/RefreshHandler.java

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ private IStatus myRun(IProgressMonitor monitor) {
142142
workUnits++;
143143

144144
} else {
145-
m_out.println("Repo type \"" + type + "\" not supported.");
145+
m_out.println(Utils.reportWarning("Repo type \"" + type
146+
+ "\" not supported."));
146147
}
147148
}
148149

@@ -188,7 +189,7 @@ private IStatus myRun(IProgressMonitor monitor) {
188189
// m_out.println("Error: " + e.toString());
189190
} catch (Exception e) {
190191
Activator.log(e);
191-
m_out.println("Failed: " + e.toString());
192+
m_out.println(Utils.reportError(e.toString()));
192193
}
193194

194195
IStatus status;
@@ -207,8 +208,8 @@ private IStatus myRun(IProgressMonitor monitor) {
207208
duration = 1;
208209
}
209210

210-
m_out.println("Refresh packs job completed in " + (duration + 500)
211-
/ 1000 + "s.");
211+
m_out.println(Utils.reportInfo("Refresh packs completed in "
212+
+ (duration + 500) / 1000 + "s."));
212213

213214
status = Status.OK_STATUS;
214215
}
@@ -230,10 +231,9 @@ private void readCmsisIndex(String indexUrl, List<String[]> pdscList) {
230231
return;
231232

232233
} catch (FileNotFoundException e) {
233-
m_out.println("Failed: " + e.toString());
234+
m_out.println(Utils.reportError("File not found: " + e.getMessage()));
234235
} catch (Exception e) {
235-
Activator.log(e);
236-
m_out.println("Failed: " + e.toString());
236+
m_out.println(Utils.reportError(e.toString()));
237237
}
238238

239239
return;
@@ -294,6 +294,9 @@ private void aggregateCmsis(Map<String, Object> repo) {
294294

295295
// If local file does not exist, create it
296296
Utils.copyFile(sourceUrl, cachedFile, m_out, null);
297+
298+
Utils.reportInfo("Pack " + pdscName + " v" + pdscVersion
299+
+ " cached.");
297300
}
298301

299302
if (cachedFile.exists()) {
@@ -302,12 +305,14 @@ private void aggregateCmsis(Map<String, Object> repo) {
302305
parser.parsePdscContent(pdscName, pdscVersion, contentRoot);
303306

304307
} else {
305-
m_out.println("Missing \"" + cachedFile + "\", ignored");
308+
m_out.println(Utils.reportWarning("Missing \"" + cachedFile
309+
+ "\", ignored"));
306310
return;
307311
}
308312

309313
} catch (Exception e) {
310-
m_out.println("Failed with \"" + e.getMessage() + "\", ignored");
314+
m_out.println(Utils.reportWarning("Failed with \""
315+
+ e.getMessage() + "\", ignored"));
311316
return;
312317
}
313318

@@ -330,7 +335,7 @@ private void aggregateCmsis(Map<String, Object> repo) {
330335
m_out.println("File \"" + file.getPath() + "\" written.");
331336

332337
} catch (IOException e) {
333-
m_out.println("Failed: " + e.toString());
338+
m_out.println(Utils.reportError(e.toString()));
334339
}
335340
}
336341
}
@@ -348,9 +353,11 @@ private void cacheXcdlContent(Map<String, Object> repo) {
348353
m_monitor.worked(1);
349354

350355
} catch (MalformedURLException e) {
351-
m_out.println("Failed: " + e.toString());
356+
m_out.println(Utils.reportError(e.toString()));
357+
} catch (FileNotFoundException e) {
358+
m_out.println(Utils.reportError("File not found: " + e.getMessage()));
352359
} catch (IOException e) {
353-
m_out.println("Failed: " + e.toString());
360+
m_out.println(Utils.reportError(e.toString()));
354361
}
355362
}
356363
}

ilg.gnuarmeclipse.packs/src/ilg/gnuarmeclipse/packs/jobs/InstallJob.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ protected IStatus run(IProgressMonitor monitor) {
140140
versionNode.setBooleanProperty(Property.INSTALLED, true);
141141

142142
} catch (IOException e) {
143-
m_out.println("Error " + e);
143+
m_out.println(Utils.reportError(e.toString()));
144144
}
145145
}
146146

@@ -232,6 +232,8 @@ private void installPack(Node versionNode) throws IOException {
232232
copyFile(packUrl, archiveFileDownload);
233233

234234
archiveFileDownload.renameTo(archiveFile);
235+
236+
Utils.reportInfo("Pack " + archiveName + " downloaded.");
235237
} else {
236238
m_monitor.worked((int) archiveFile.length());
237239
}
@@ -252,6 +254,8 @@ private void installPack(Node versionNode) throws IOException {
252254

253255
Utils.makeFolderReadOnlyRecursive(destRelPath.toFile());
254256

257+
Utils.reportInfo("Pack " + archiveName + " installed.");
258+
255259
m_out.println("All files write protected.");
256260
}
257261

ilg.gnuarmeclipse.packs/src/ilg/gnuarmeclipse/packs/jobs/RemoveJob.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ protected IStatus run(IProgressMonitor monitor) {
129129
// Add it to the list for final notifications
130130
removedPacksList.add(versionNode);
131131

132+
Utils.reportInfo("Pack " + packFullName + " removed.");
133+
132134
} catch (IOException e) {
133-
m_out.println(e.getMessage());
135+
m_out.println(Utils.reportError(e.getMessage()));
134136
break;
135137
}
136138
}

0 commit comments

Comments
 (0)