use of org.erlide.cover.views.model.ICoverageObject in project erlide_eclipse by erlang.
the class RestoreAction method run.
@Override
public void run() {
final IPath location = Activator.getDefault().getStateLocation().append(SaveAction.DIR_NAME);
final File dir = location.toFile();
if (!dir.exists() && !dir.mkdir()) {
CoverageHelper.reportError("Can not save results!");
return;
}
// open dialog
final ElementListSelectionDialog resDialog = new ElementListSelectionDialog(shell, labelProvider);
resDialog.setElements(dir.listFiles());
resDialog.setTitle("Restoring results");
resDialog.setMessage("Select results to restore");
resDialog.open();
if (resDialog.getReturnCode() != Window.OK) {
return;
}
//
final File f = (File) resDialog.getFirstResult();
try (final ObjectInputStream objStream = new ObjectInputStream(new FileInputStream(f))) {
final Object obj = objStream.readObject();
StatsTreeModel.changeInstance((StatsTreeModel) obj);
StatsTreeModel.getInstance().setChanged(true);
viewer.setInput(StatsTreeModel.getInstance());
final ICoverageObject root = StatsTreeModel.getInstance().getRoot();
createModuleSet(root);
final Collection<ICoverageObject> col = root.getModules();
for (final ICoverageObject module : col) {
if (ifMarkAnnotations((ModuleStats) module)) {
((ModuleStats) module).couldBeMarked = true;
} else {
((ModuleStats) module).couldBeMarked = false;
}
}
EditorTracker.getInstance().addAnnotations();
} catch (final FileNotFoundException e) {
log.error("No such file");
ErlLogger.error(e);
CoverageHelper.reportError("Error while reading file");
} catch (final Exception e) {
log.error("Error while reading file");
ErlLogger.error(e);
CoverageHelper.reportError("Error while reading file");
}
}
use of org.erlide.cover.views.model.ICoverageObject in project erlide_eclipse by erlang.
the class StatsViewLabelProvider method getColumnText.
@Override
public String getColumnText(final Object element, final int columnIndex) {
final ICoverageObject statsEl = (ICoverageObject) element;
String text = "";
switch(columnIndex) {
case 0:
text = statsEl.getLabel();
break;
case 1:
text = Integer.toString(statsEl.getLinesCount());
break;
case 2:
text = Integer.toString(statsEl.getCoverCount());
break;
case 3:
text = String.format("%.2f ", statsEl.getPercentage()) + "%";
break;
default:
break;
}
return text;
}
Aggregations