use of org.eclipse.titanium.markers.export.XlsProblemExporter in project titan.EclipsePlug-ins by eclipse.
the class ExportProblems method doExportProblems.
private void doExportProblems() {
if (!(selection instanceof IStructuredSelection)) {
return;
}
final IStructuredSelection structSelection = (IStructuredSelection) selection;
if (structSelection.isEmpty()) {
return;
}
final Object firstElement = structSelection.getFirstElement();
if (!(firstElement instanceof IProject)) {
ErrorReporter.logError("The export problems command needs to be called on a project ");
return;
}
final IProject project = (IProject) firstElement;
final IPreferencesService preferencesService = Platform.getPreferencesService();
final boolean reportDebugInformation = preferencesService.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.DISPLAYDEBUGINFORMATION, true, null);
if (reportDebugInformation) {
TITANDebugConsole.println("Problem markers are to export from " + project.getName());
}
boolean write = false;
String fileName;
final Shell shell = Display.getCurrent().getActiveShell();
do {
final FileDialog dialog = new FileDialog(shell, SWT.SAVE);
dialog.setText("Export problem markers to xls");
dialog.setFilterExtensions(new String[] { "*.xls" });
final IPath path = project.getLocation();
if (path != null) {
dialog.setFilterPath(path.toPortableString());
}
final Calendar now = Calendar.getInstance();
dialog.setFileName("Problems--" + project.getName() + "--" + now.get(Calendar.YEAR) + "-" + (1 + now.get(Calendar.MONTH)) + "-" + now.get(Calendar.DAY_OF_MONTH));
fileName = dialog.open();
if (fileName != null) {
if (new File(fileName).exists()) {
write = MessageDialog.openConfirm(Display.getCurrent().getActiveShell(), "File exist", "This file already exists. Please confirm overwrite.");
} else {
write = true;
}
} else {
// User cancelled the file dialog, so we have nothing to do
return;
}
} while (!write);
final String fileName2 = fileName;
new ProjectAnalyzerJob("Exporting reported code smells") {
@Override
public IStatus doPostWork(final IProgressMonitor monitor) {
final BaseProblemExporter exporter = new XlsProblemExporter(getProject());
try {
exporter.exportMarkers(monitor, fileName2, Calendar.getInstance().getTime());
if (reportDebugInformation) {
TITANDebugConsole.println("Successfully exported markers to xls");
}
} catch (IOException e) {
ErrorReporter.logExceptionStackTrace("Error while exporting", e);
if (reportDebugInformation) {
TITANDebugConsole.println("Failed to write xls");
}
}
return Status.OK_STATUS;
}
}.quickSchedule(project);
}
use of org.eclipse.titanium.markers.export.XlsProblemExporter in project titan.EclipsePlug-ins by eclipse.
the class ExportAllCodeSmells method exportInformationForProject.
@Override
protected void exportInformationForProject(final String[] args, final IProject project, final IProgressMonitor monitor) {
final XlsProblemExporter exporter = new XlsProblemExporter(project);
try {
Date date;
if (args.length == 1) {
date = Calendar.getInstance().getTime();
} else {
date = new SimpleDateFormat("yyyy_MM_dd").parse(args[1]);
}
exporter.exportMarkers(monitor, args[0] + project.getName() + ".xls", date);
} catch (Exception e) {
ErrorReporter.logExceptionStackTrace("Error while exporting to excel " + args[0] + project.getName() + ".xls", e);
}
}
use of org.eclipse.titanium.markers.export.XlsProblemExporter in project titan.EclipsePlug-ins by eclipse.
the class ExportAllCodeSmellsForProject method exportInformationForProject.
@Override
protected void exportInformationForProject(final String[] args, final IProject project, final IProgressMonitor monitor) {
final XlsProblemExporter exporter = new XlsProblemExporter(project);
try {
Date date;
if (args.length == 2) {
date = Calendar.getInstance().getTime();
} else {
date = new SimpleDateFormat("yyyy_MM_dd").parse(args[2]);
}
exporter.exportMarkers(monitor, args[0] + project.getName() + ".xls", date);
} catch (Exception e) {
ErrorReporter.logExceptionStackTrace("Error while exporting to excel " + args[0] + project.getName() + ".xls", e);
}
}
Aggregations