use of de.janrufmonitor.service.comment.api.IComment in project janrufmonitor by tbrandt77.
the class OldImportAction method doImport.
private synchronized void doImport(List fileList) {
this.m_logger.info("Starting import of " + fileList.size() + " comments.");
for (int i = 0; i < fileList.size(); i++) {
File f = (File) fileList.get(i);
String number = f.getName().substring(1, f.getName().indexOf("."));
IPhonenumber pn = this.getRuntime().getCallerFactory().createPhonenumber(number);
try {
ICaller c = Identifier.identifyDefault(PIMRuntime.getInstance(), pn);
ICommentCaller cc = null;
if (this.getHandler().hasCommentCaller(c)) {
cc = this.getHandler().getCommentCaller(c);
} else {
cc = this.getHandler().createCommentCaller(c);
}
IComment comment = this.getHandler().createComment();
String content = this.getCommentContent(new FileInputStream(f));
comment.setText(content);
comment.setDate(new Date(f.lastModified()));
cc.addComment(comment);
this.getHandler().setCommentCaller(cc);
} catch (FileNotFoundException e) {
this.m_logger.severe(e.toString() + ": " + e.getMessage());
} catch (IOException e) {
this.m_logger.severe(e.toString() + ": " + e.getMessage());
}
}
}
use of de.janrufmonitor.service.comment.api.IComment in project janrufmonitor by tbrandt77.
the class PDFCreator method createPdf.
public void createPdf() {
Document document = new Document(PageSize.A4);
document.addCreationDate();
document.addCreator("jAnrufmonitor");
try {
PdfWriter.getInstance(document, new FileOutputStream(this.m_file));
document.open();
document.add(new Paragraph(this.getI18nManager().getString(getNamespce(), "pdftitle", "label", getLanguage()), FontFactory.getFont(FontFactory.HELVETICA, 16f, Font.BOLD | Font.UNDERLINE)));
document.add(new Paragraph(" "));
String msg = "";
ITableCellRenderer tcr = RendererRegistry.getInstance().getRenderer("name");
if (tcr != null) {
tcr.updateData(m_cc.getCaller());
msg += tcr.renderAsText();
}
tcr = RendererRegistry.getInstance().getRenderer("number");
if (tcr != null) {
tcr.updateData(m_cc.getCaller());
msg += "\n" + tcr.renderAsText() + "\n";
}
document.add(new Paragraph(msg));
document.add(new Paragraph(" "));
List comments = m_cc.getComments();
Collections.sort(comments, new CommentComparator());
IComment c = null;
PdfPTable table = new PdfPTable(1);
table.setWidthPercentage(100f);
PdfPCell cp = null;
Paragraph pp = null;
Color iterateColor1 = new Color(0xDD, 0xDD, 0xDD);
Color iterateColor2 = new Color(0xFF, 0xFF, 0xFF);
for (int i = 0; i < comments.size(); i++) {
cp = new PdfPCell();
cp.setBackgroundColor((i % 2 == 0 ? iterateColor1 : iterateColor2));
pp = new Paragraph();
Paragraph p = new Paragraph();
c = (IComment) comments.get(i);
IAttribute att = c.getAttributes().get(IComment.COMMENT_ATTRIBUTE_SUBJECT);
if (att != null && att.getValue().length() > 0) {
p.add(new Chunk(this.getI18nManager().getString(getNamespce(), "pdfsubject", "label", getLanguage()), FontFactory.getFont(FontFactory.HELVETICA, 14f, Font.BOLD)));
p.add(new Chunk(att.getValue(), FontFactory.getFont(FontFactory.HELVETICA, 14f, Font.BOLD)));
pp.add(p);
p = new Paragraph();
}
p.add(new Chunk(this.getI18nManager().getString(getNamespce(), "pdfdate", "label", getLanguage()), FontFactory.getFont(FontFactory.HELVETICA, 12f, Font.BOLD)));
p.add(new Chunk(getFormatter().parse(IJAMConst.GLOBAL_VARIABLE_CALLTIME, c.getDate())));
pp.add(p);
p = new Paragraph();
p.add(new Chunk(this.getI18nManager().getString(getNamespce(), "pdfstatus", "label", getLanguage()), FontFactory.getFont(FontFactory.HELVETICA, 12f, Font.BOLD)));
p.add(new Chunk(c.getAttributes().get(IComment.COMMENT_ATTRIBUTE_STATUS).getValue()));
pp.add(p);
att = c.getAttributes().get(IComment.COMMENT_ATTRIBUTE_FOLLOWUP);
if (att != null && att.getValue().equalsIgnoreCase(IJAMConst.ATTRIBUTE_VALUE_YES)) {
p = new Paragraph();
Chunk cu = new Chunk(this.getI18nManager().getString(getNamespce(), "pdffollowup", "label", getLanguage()), FontFactory.getFont(FontFactory.HELVETICA, 12f, Font.BOLD));
cu.setBackground(new Color(0xFF, 0xFF, 0x00));
p.add(cu);
pp.add(p);
}
pp.add(new Paragraph(" "));
p = new Paragraph(c.getText());
pp.add(p);
cp.addElement(pp);
table.addCell(cp);
}
document.add(table);
} catch (DocumentException de) {
this.m_logger.severe(de.getMessage());
} catch (IOException ioe) {
this.m_logger.severe(ioe.getMessage());
} finally {
document.close();
}
}
use of de.janrufmonitor.service.comment.api.IComment in project janrufmonitor by tbrandt77.
the class CommentCallerHandler method getCommentCallerFromHierarchy.
private ICommentCaller getCommentCallerFromHierarchy(ICaller caller) {
String callerDirectoryName = this.getCommentRoot() + this.getCommentLocation(caller.getPhoneNumber());
File callerDir = new File(callerDirectoryName);
if (callerDir.exists()) {
ICommentCaller commentCaller = this.createCommentCaller(caller);
File[] comments = callerDir.listFiles(new FileFilter() {
public boolean accept(File pathname) {
if (pathname.getAbsolutePath().endsWith(getCommentFilenameExtension())) {
return true;
}
return false;
}
});
for (int i = 0; i < comments.length; i++) {
IComment comment = this.createComment(comments[i]);
// TODO: removed due to performance reasons
// File attachmentFolder = new File(callerDirectoryName + comment.getID());
// if (attachmentFolder.exists()) {
// File[] attachments = attachmentFolder.listFiles();
// for (int j=0;j<attachments.length;j++) {
// IAttachment attachment = this.createAttachment(attachments[j]);
// comment.addAttachment(attachment);
// }
// }
commentCaller.addComment(comment);
}
return commentCaller;
}
this.m_logger.info("Comments for caller " + caller.toString() + " does not exist.");
return null;
}
use of de.janrufmonitor.service.comment.api.IComment in project janrufmonitor by tbrandt77.
the class ChangeAction method run.
public void run() {
Viewer v = this.m_app.getApplication().getViewer();
if (v != null) {
IStructuredSelection selection = (IStructuredSelection) v.getSelection();
if (!selection.isEmpty()) {
Object o = selection.getFirstElement();
if (o instanceof IComment) {
Object callableObject = null;
if (this.m_app instanceof Comment) {
callableObject = ((Comment) this.m_app).getCallableObject();
}
CommentDialog cd = new CommentDialog(DisplayManager.getDefaultDisplay().getActiveShell(), ((IComment) o), callableObject);
int result = cd.open();
if (result == CommentDialog.OK) {
IComment c = cd.getResult();
this.m_app.getController().updateElement(c);
this.m_app.updateViews(true);
}
}
}
}
}
Aggregations