use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class AbstractTellowsImg method renderAsImage.
public Image renderAsImage() {
if (this.m_o != null) {
if (this.m_o instanceof ICall) {
this.m_o = ((ICall) this.m_o).getCaller();
}
if (this.m_o instanceof ICaller) {
if (((ICaller) this.m_o).getAttribute("tellows.scorePath") != null) {
IAttribute timg = ((ICaller) this.m_o).getAttribute("tellows.scorePath");
if (timg.getValue().length() > 0) {
try {
URL url = new URL(timg.getValue());
String tellowsImgName = new File(url.getFile()).getName();
File tellowsImgDir = new File(PathResolver.getInstance().getImageDirectory(), "tellows");
if (!tellowsImgDir.exists())
tellowsImgDir.mkdirs();
File tellowsImg = new File(tellowsImgDir, tellowsImgName);
if (!tellowsImg.exists()) {
URLConnection con = url.openConnection();
con.setRequestProperty("User-Agent", "jAnrufmonitor " + IJAMConst.VERSION_DISPLAY + " mit tellows Erweiterung");
con.connect();
Object o = con.getInputStream();
if (o instanceof InputStream) {
Stream.copy(new BufferedInputStream((InputStream) o), new FileOutputStream(tellowsImg), true);
}
}
if (tellowsImg.exists()) {
return this.getTellowsImage(new FileInputStream(tellowsImg));
}
} catch (MalformedURLException e) {
} catch (IOException e) {
Logger.getLogger(IJAMConst.DEFAULT_LOGGER).log(Level.WARNING, e.getLocalizedMessage(), e);
}
}
}
}
}
return null;
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class XlsFilter method doExport.
public boolean doExport() {
if (m_filename == null || m_filename.length() == 0)
return false;
WritableWorkbook wb = null;
try {
wb = Workbook.createWorkbook(new File(m_filename));
WritableSheet sheet = wb.createSheet("journal", 0);
// 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;
Label 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 XLS format canceled...");
return false;
}
cell = new Label(i, 0, t.getHeader());
sheet.addCell(cell);
}
int[] widths = new int[renderer.size()];
ICall c = null;
String cellContent = null;
for (int k = 0, i = 0, j = this.m_callList.size(); i < j; i++) {
try {
c = this.m_callList.get(i);
k = 0;
for (int m = renderer.size(); k < m; k++) {
t = (ITableCellRenderer) renderer.get(k);
t.updateData(c);
cellContent = t.renderAsText();
if (cellContent != null && cellContent.length() > 0) {
widths[k] = Math.max(widths[k], cellContent.length());
cell = new Label(k, i + 1, cellContent);
sheet.addCell(cell);
} else {
cellContent = t.renderAsImageID();
if (cellContent != null && cellContent.length() > 0) {
if (cellContent.indexOf(".") > -1)
cellContent = cellContent.substring(0, cellContent.indexOf("."));
widths[k] = Math.max(widths[k], cellContent.length());
cell = new Label(k, i + 1, cellContent);
} else
cell = new Label(k, i + 1, " ");
sheet.addCell(cell);
}
cell = null;
}
} catch (JxlWriteException e) {
this.m_logger.severe(e.getMessage());
this.m_logger.severe("Ignored data [" + (k + 1) + ", " + (i + 1) + "] for Excel export: " + cellContent);
}
}
// calculate width
for (int i = 0, j = renderer.size(); i < j; i++) {
sheet.setColumnView(i, widths[i]);
}
wb.write();
} catch (Exception e) {
this.m_logger.severe(e.getMessage());
return false;
} finally {
try {
if (wb != null)
wb.close();
} catch (WriteException ex) {
this.m_logger.severe(ex.getMessage());
return false;
} catch (IOException ex) {
this.m_logger.severe(ex.getMessage());
return false;
}
}
return true;
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class DurationStatsAction method getStatisticItems.
public List getStatisticItems() {
Properties stat = new Properties();
if (this.m_cl != null) {
String msn = null;
ICall c = null;
for (int i = 0; i < this.m_cl.size(); i++) {
c = this.m_cl.get(i);
msn = c.getMSN().getMSN();
if (this.m_cl.get(i).getMSN().getAdditional().length() > 0) {
msn += " (" + this.m_cl.get(i).getMSN().getAdditional() + ")";
}
String value = stat.getProperty(msn, "");
if (value.length() == 0) {
stat.setProperty(msn, Integer.toString(getDurationTime(c)));
stat.setProperty(msn + ".string", getDuration(getDurationTime(c)));
} else {
int val = new Integer(value).intValue();
val += getDurationTime(c);
stat.setProperty(msn, new Integer(val).toString());
stat.setProperty(msn + ".string", getDuration(val));
m_maxcount = Math.max(m_maxcount, val);
}
}
}
Iterator iter = stat.keySet().iterator();
List items = new ArrayList();
String msn = null;
while (iter.hasNext()) {
msn = (String) iter.next();
if (!msn.endsWith(".string")) {
String count = stat.getProperty(msn, "");
items.add(new String[] { msn, stat.getProperty(msn + ".string"), count });
}
}
Collections.sort(items, new StatisticComparator());
return items;
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class DeleteAction method run.
public void run() {
Viewer v = this.m_app.getApplication().getViewer();
if (v != null && v instanceof TableViewer) {
IStructuredSelection selection = (IStructuredSelection) v.getSelection();
if (!selection.isEmpty()) {
Iterator i = selection.iterator();
ICallList list = getRuntime().getCallFactory().createCallList();
Object o = null;
while (i.hasNext()) {
o = i.next();
if (o instanceof ICall) {
list.add((ICall) o);
}
}
if (list.size() > 0) {
if (MessageDialog.openConfirm(new Shell(DisplayManager.getDefaultDisplay()), this.getI18nManager().getString(this.getNamespace(), "delete", "label", this.getLanguage()), this.getI18nManager().getString(this.getNamespace(), "delete", "description", this.getLanguage()))) {
this.m_app.getController().deleteElements(list);
this.m_app.getApplication().initializeController();
this.m_app.updateViews(true);
}
}
}
}
}
use of de.janrufmonitor.framework.ICall in project janrufmonitor by tbrandt77.
the class HighlightAction method run.
public void run() {
long m_timestamp = -1;
try {
m_timestamp = Long.parseLong(this.m_app.getApplication().getConfiguration().getProperty(CFG_HIGHLIGHT_TIME, "0"));
} catch (Exception e) {
this.m_logger.warning("Cannot parse long value: " + e.getMessage());
}
// highlight is disabled
if (m_timestamp == -1)
return;
Viewer v = this.m_app.getApplication().getViewer();
if (v != null && v instanceof TableViewer) {
Table t = ((TableViewer) v).getTable();
ICallList cl = ((JournalController) this.m_app.getController()).getCallList();
ICall c = null;
Font itemFont = null;
for (int i = 0, n = cl.size(); i < n; i++) {
c = cl.get(i);
if (this.isHighlight(m_timestamp, c.getDate().getTime())) {
itemFont = t.getItem(i).getFont();
t.getItem(i).setFont(this.getBoldFont(itemFont));
}
}
this.m_app.getApplication().getConfiguration().setProperty(CFG_HIGHLIGHT_TIME, Long.toString(System.currentTimeMillis()));
this.m_app.getApplication().storeConfiguration();
}
}
Aggregations