use of name.abuchen.portfolio.ui.dialogs.DisplayTextDialog in project portfolio by buchen.
the class ErrorLogPart method createComposite.
@PostConstruct
public void createComposite(Composite parent, LogEntryCache cache) {
this.entries = cache.getEntries();
Composite container = new Composite(parent, SWT.NONE);
TreeColumnLayout layout = new TreeColumnLayout();
container.setLayout(layout);
logViewer = new TreeViewer(container, SWT.FULL_SELECTION);
TreeViewerColumn column = new TreeViewerColumn(logViewer, SWT.NONE);
column.getColumn().setText(Messages.ColumnDate);
layout.setColumnData(column.getColumn(), new ColumnPixelData(140));
column.setLabelProvider(new ColumnLabelProvider() {
private DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
@Override
public String getText(Object element) {
return dateFormat.format(((LogEntry) element).getDate());
}
});
column = new TreeViewerColumn(logViewer, SWT.NONE);
column.getColumn().setText(Messages.ColumnMessage);
layout.setColumnData(column.getColumn(), new ColumnPixelData(500));
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((LogEntry) element).getMessage();
}
@Override
public Image getImage(Object element) {
LogEntry entry = (LogEntry) element;
switch(entry.getSeverity()) {
case IStatus.ERROR:
return Images.ERROR.image();
case IStatus.WARNING:
return Images.WARNING.image();
default:
return Images.INFO.image();
}
}
});
logViewer.getTree().setHeaderVisible(true);
logViewer.getTree().setLinesVisible(true);
logViewer.setContentProvider(new LogEntryContentProvider());
logViewer.setInput(entries);
logViewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
LogEntry entry = (LogEntry) ((IStructuredSelection) event.getSelection()).getFirstElement();
DisplayTextDialog dialog = new DisplayTextDialog(Display.getCurrent().getActiveShell(), entry.getText());
dialog.open();
}
});
}
use of name.abuchen.portfolio.ui.dialogs.DisplayTextDialog in project portfolio by buchen.
the class CreateTextFromPDFHandler method execute.
@Execute
public void execute(@Named(IServiceConstants.ACTIVE_PART) MPart part, @Named(IServiceConstants.ACTIVE_SHELL) Shell shell) throws IOException {
FileDialog fileDialog = new FileDialog(shell, SWT.OPEN | SWT.SINGLE);
fileDialog.setText(Messages.PDFImportDebugTextExtraction);
fileDialog.setFilterNames(new String[] { Messages.PDFImportFilterName });
// $NON-NLS-1$
fileDialog.setFilterExtensions(new String[] { "*.pdf" });
fileDialog.open();
String fileName = fileDialog.getFileName();
if (fileName == null || fileName.isEmpty())
return;
try {
PDFInputFile inputFile = new PDFInputFile(new File(fileDialog.getFilterPath(), fileName));
inputFile.parse();
String text = MessageFormat.format(Messages.PDFImportDebugAuthor, inputFile.getAuthor());
// $NON-NLS-1$
text += "\nPDFBox Version: " + inputFile.getPDFBoxVersion().toString();
// $NON-NLS-1$
text += "\n-----------------------------------------\n";
// CRLF to spac; //$NON-NLS-1$ //$NON-NLS-2$
text += inputFile.getText().replace("\r", "");
new DisplayTextDialog(shell, text).open();
} catch (IOException e) {
PortfolioPlugin.log(e);
MessageDialog.openError(shell, Messages.LabelError, e.getMessage());
}
}
Aggregations