use of de.janrufmonitor.ui.jface.application.rendering.ITableCellRenderer in project janrufmonitor by tbrandt77.
the class ExtendedBalloonDialog method prepareDialog.
private void prepareDialog(Composite c, Shell s) {
this.validConfiguration();
ContentMatrix m = null;
if (this.isCliredCaller()) {
m = new ContentMatrix(getDialogContentCLIR());
} else {
m = new ContentMatrix(getDialogContent());
}
String[][] matrix = m.getMatrix();
this.m_columnCount = m.getColCount(matrix);
c.setLayout(new GridLayout(this.m_columnCount, false));
int rowCount = m.getRowCount(matrix);
int colCount = m.getColCount(matrix);
for (int i = 0; i < rowCount; i++) {
for (int j = 0; j < colCount; j++) {
String element = (matrix[i][j].trim().length() > 0 ? matrix[i][j] : null);
Image img = null;
if (element != null) {
ITableCellRenderer tcr = getRenderer(element);
if (tcr != null) {
tcr.updateData(this.getCall());
img = tcr.renderAsImage();
if (img == null)
element = tcr.renderAsText();
} else {
element = Formatter.getInstance(this.getRuntime()).parse(element, this.getCall());
}
if (element.equalsIgnoreCase(matrix[i][j]))
element = "";
}
createLabel(c, m.getRowSpan(j, i, matrix), element, img, getLabelAttributes(getElementID((matrix[i][j].trim().length() > 0 ? matrix[i][j] : null))));
}
}
}
use of de.janrufmonitor.ui.jface.application.rendering.ITableCellRenderer in project janrufmonitor by tbrandt77.
the class ClipboardAction method run.
public void run() {
Viewer v = this.m_app.getApplication().getViewer();
if (v != null && v instanceof Viewer) {
IStructuredSelection selection = (IStructuredSelection) v.getSelection();
if (!selection.isEmpty()) {
Object o = selection.getFirstElement();
ITableCellRenderer tcr = RendererRegistry.getInstance().getRenderer("number");
if (tcr != null) {
tcr.updateData(o);
Clipboard cb = new Clipboard(DisplayManager.getDefaultDisplay());
String textData = tcr.renderAsText();
TextTransfer textTransfer = TextTransfer.getInstance();
cb.setContents(new Object[] { (textData != null ? textData : "") }, new Transfer[] { textTransfer });
}
}
}
}
use of de.janrufmonitor.ui.jface.application.rendering.ITableCellRenderer in project janrufmonitor by tbrandt77.
the class ClipboardAddressAction method run.
public void run() {
Viewer v = this.m_app.getApplication().getViewer();
if (v != null && v instanceof Viewer) {
IStructuredSelection selection = (IStructuredSelection) v.getSelection();
if (!selection.isEmpty()) {
Object o = selection.getFirstElement();
ITableCellRenderer tcr = RendererRegistry.getInstance().getRenderer("name");
if (tcr != null) {
tcr.updateData(o);
Clipboard cb = new Clipboard(DisplayManager.getDefaultDisplay());
String textData = tcr.renderAsText();
TextTransfer textTransfer = TextTransfer.getInstance();
cb.setContents(new Object[] { (textData != null ? textData : "") }, new Transfer[] { textTransfer });
}
}
}
}
use of de.janrufmonitor.ui.jface.application.rendering.ITableCellRenderer in project janrufmonitor by tbrandt77.
the class CsvFilter method doExport.
public boolean doExport() {
if (m_filename == null || m_filename.length() == 0)
return false;
try {
// get renderers
List renderer = new ArrayList();
String renderer_config = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty("ui.jface.application.journal.Journal", "renderer");
if (renderer_config != null && renderer_config.length() > 0) {
StringTokenizer s = new StringTokenizer(renderer_config, ",");
while (s.hasMoreTokens()) {
renderer.add(RendererRegistry.getInstance().getRenderer(s.nextToken()));
}
}
ITableCellRenderer t = null;
StringBuffer sb = new StringBuffer();
for (int i = 0, j = renderer.size(); i < j; i++) {
t = (ITableCellRenderer) renderer.get(i);
if (t == null) {
this.m_logger.severe("No renderer found for ID: " + (String) renderer.get(i));
this.m_logger.severe("Export to CSV format canceled...");
return false;
}
sb.append(t.getHeader());
sb.append(TOKEN);
}
sb.append(IJAMConst.CRLF);
ICall c = null;
String cellContent = null;
for (int i = 0, j = this.m_callList.size(); i < j; i++) {
c = this.m_callList.get(i);
for (int k = 0, m = renderer.size(); k < m; k++) {
t = (ITableCellRenderer) renderer.get(k);
t.updateData(c);
cellContent = t.renderAsText();
if (cellContent != null && cellContent.length() > 0) {
cellContent = StringUtils.replaceString(cellContent, IJAMConst.CRLF, " ");
sb.append(cellContent);
sb.append(TOKEN);
} else {
cellContent = t.renderAsImageID();
if (cellContent != null && cellContent.length() > 0) {
if (cellContent.indexOf(".") > -1)
cellContent = cellContent.substring(0, cellContent.indexOf("."));
}
sb.append(cellContent);
sb.append(TOKEN);
}
}
sb.append(IJAMConst.CRLF);
}
FileOutputStream fos = new FileOutputStream(m_filename);
ByteArrayInputStream in = new ByteArrayInputStream(sb.toString().getBytes());
Stream.copy(in, fos, true);
} catch (Exception e) {
this.m_logger.severe(e.getMessage());
return false;
} finally {
}
return true;
}
use of de.janrufmonitor.ui.jface.application.rendering.ITableCellRenderer in project janrufmonitor by tbrandt77.
the class PDFFilter method doExport.
public boolean doExport() {
Document document = new Document(PageSize.A4.rotate(), 20, 20, 20, 20);
document.addCreationDate();
document.addCreator("jAnrufmonitor");
try {
PdfWriter.getInstance(document, new FileOutputStream(this.m_filename));
document.open();
// get renderers
List renderer = new ArrayList();
String renderer_config = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty("ui.jface.application.journal.Journal", "renderer");
if (renderer_config != null && renderer_config.length() > 0) {
StringTokenizer s = new StringTokenizer(renderer_config, ",");
while (s.hasMoreTokens()) {
renderer.add(RendererRegistry.getInstance().getRenderer(s.nextToken()));
}
}
// get column width
float totalWidth = 0;
String[] cWidth = new String[renderer.size()];
for (int i = 0, j = renderer.size(); i < j; i++) {
cWidth[i] = getRuntime().getConfigManagerFactory().getConfigManager().getProperty("ui.jface.application.journal.Journal", "col_size_" + ((ITableCellRenderer) renderer.get(i)).getID());
if (cWidth[i] != null && cWidth[i].length() > 0) {
totalWidth += Float.parseFloat(cWidth[i]);
}
if (cWidth[i] != null && cWidth[i].length() == 0) {
cWidth[i] = "0";
}
}
float[] widths = new float[renderer.size()];
for (int i = 0, j = renderer.size(); i < j; i++) {
widths[i] = Float.parseFloat(cWidth[i]) / totalWidth;
}
PdfPTable table = new PdfPTable(widths);
table.setHeaderRows(1);
table.setWidthPercentage(100f);
ITableCellRenderer t = null;
PdfPCell cell = null;
for (int i = 0, j = renderer.size(); i < j; i++) {
t = (ITableCellRenderer) renderer.get(i);
if (t == null) {
this.m_logger.severe("No renderer found for ID: " + (String) renderer.get(i));
this.m_logger.severe("Export to PDF format canceled...");
return false;
}
cell = new PdfPCell(new Paragraph(t.getHeader()));
cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0));
table.addCell(cell);
}
ICall c = null;
String cellContent = null;
for (int i = 0, j = this.m_callList.size(); i < j; i++) {
c = this.m_callList.get(i);
for (int k = 0, m = renderer.size(); k < m; k++) {
t = (ITableCellRenderer) renderer.get(k);
t.updateData(c);
cellContent = t.renderAsText();
if (cellContent != null && cellContent.length() > 0) {
table.addCell(cellContent);
} else {
cellContent = t.renderAsImageID();
if (cellContent != null && cellContent.length() > 0) {
try {
if (cellContent.startsWith("db://")) {
InputStream in = ImageHandler.getInstance().getImageStream(c.getCaller());
if (in != null) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
Stream.copy(in, out, true);
in.close();
out.close();
Image pdfImage = Image.getInstance(out.toByteArray());
// pdfImage.scaleAbsolute(90.0f, 45.0f);
table.addCell(pdfImage);
} else {
table.addCell(" ");
}
} else if (new File(cellContent).exists()) {
Image pdfImage = Image.getInstance(cellContent);
table.addCell(pdfImage);
} else {
Image pdfImage = Image.getInstance(SWTImageManager.getInstance(PIMRuntime.getInstance()).getImagePath(cellContent));
table.addCell(pdfImage);
}
} catch (IOException e) {
this.m_logger.severe(e.getMessage());
table.addCell(" ");
}
} else
table.addCell(" ");
}
}
}
document.add(table);
} catch (DocumentException de) {
this.m_logger.severe(de.getMessage());
return false;
} catch (IOException ioe) {
this.m_logger.severe(ioe.getMessage());
return false;
} finally {
document.close();
}
return true;
}
Aggregations