use of de.janrufmonitor.framework.ICallList 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();
}
}
use of de.janrufmonitor.framework.ICallList in project janrufmonitor by tbrandt77.
the class ImportAction method run.
public void run(String[] filenames) {
try {
String filename = filenames[0];
TableViewer viewer = (TableViewer) this.m_app.getApplication().getViewer();
Cursor c = new Cursor(viewer.getTable().getDisplay(), SWT.CURSOR_WAIT);
if (!filename.endsWith(this.m_app.getApplication().getConfiguration().getProperty(CFG_OLD_JOURNAL, "ajournal.dat"))) {
File f = new File(filename);
String ext = f.getName();
IImExporter ie = ImExportFactory.getInstance().getImporterByExtension(ext);
if (ie == null && ext.lastIndexOf(".") >= 0) {
ext = "*" + ext.substring(ext.lastIndexOf("."));
ie = ImExportFactory.getInstance().getImporterByExtension(ext);
if (ie == null) {
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getI18nManager().getString(Journal.NAMESPACE, "title", "label", getLanguage()), new Exception(getI18nManager().getString(getNamespace(), "error", "description", getLanguage()))), "Tray");
new SWTExecuter() {
protected void execute() {
MessageDialog.openError(DisplayManager.getDefaultDisplay().getActiveShell(), getI18nManager().getString(getNamespace(), "error", "label", getLanguage()), getI18nManager().getString(getNamespace(), "error", "description", getLanguage()));
m_logger.warning("Import of data failed.");
}
}.start();
}
}
if (ie != null && ie.getMode() != IImExporter.CALL_MODE)
return;
final IImExporter imp = ie;
imp.setFilename(filename);
viewer.getTable().getShell().setCursor(c);
ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
try {
IRunnableWithProgress r = new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {
progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "importprogress", "label", getLanguage()), IProgressMonitor.UNKNOWN);
progressMonitor.worked(1);
final ICallList importedCalls = getRuntime().getCallFactory().createCallList();
if (imp.getMode() == IImExporter.CALL_MODE) {
importedCalls.add(((ICallImporter) imp).doImport());
m_app.getController().addElements(importedCalls);
}
if (importedCalls.size() > 0) {
final String msg = StringUtils.replaceString(getI18nManager().getString(getNamespace(), "success", "description", getLanguage()), "{%1}", Integer.toString(importedCalls.size()));
PropagationFactory.getInstance().fire(new Message(Message.INFO, getI18nManager().getString(Journal.NAMESPACE, "title", "label", getLanguage()), new Exception(msg)), "Tray");
new SWTExecuter() {
protected void execute() {
m_app.updateViews(true);
}
}.start();
} else {
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getI18nManager().getString(Journal.NAMESPACE, "title", "label", getLanguage()), new Exception(getI18nManager().getString(getNamespace(), "error", "description", getLanguage()))), "Tray");
new SWTExecuter() {
protected void execute() {
MessageDialog.openError(DisplayManager.getDefaultDisplay().getActiveShell(), getI18nManager().getString(getNamespace(), "error", "label", getLanguage()), getI18nManager().getString(getNamespace(), "error", "description", getLanguage()));
m_logger.warning("Import of data failed.");
// m_app.getController().addElements(importedCalls);
m_app.updateViews(true);
}
}.start();
}
progressMonitor.done();
}
};
pmd.setBlockOnOpen(false);
pmd.run(true, false, r);
// ModalContext.run(r, true,
// pmd.getProgressMonitor(),
// DisplayManager.getDefaultDisplay());
} catch (InterruptedException e) {
throw e;
} catch (InvocationTargetException e) {
throw e;
}
viewer.getTable().getShell().setCursor(null);
c.dispose();
} else {
// do ajournal.dat migration
int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
MessageBox messageBox = new MessageBox(new Shell(DisplayManager.getDefaultDisplay()), style);
messageBox.setMessage(this.getI18nManager().getString(this.getNamespace(), "migrationconfirm", "label", this.getLanguage()));
if (messageBox.open() == SWT.YES) {
viewer.getTable().getShell().setCursor(c);
IImExporter imp = ImExportFactory.getInstance().getImporter("OldDatFileCallImporter");
if (imp != null && (imp instanceof OldDatFileCallImporter)) {
((OldDatFileCallImporter) imp).setDatePattern(this.m_app.getApplication().getConfiguration().getProperty(CFG_OLD_DATE, "dd.MM.yyyy HH:mm:ss"));
((OldDatFileCallImporter) imp).setFilename(filename);
ICallList importedCalls = ((OldDatFileCallImporter) imp).doImport();
if (importedCalls != null) {
this.m_app.getController().addElements(importedCalls);
String msg = getI18nManager().getString(getNamespace(), "success", "description", getLanguage());
msg = StringUtils.replaceString(msg, "{%1}", Integer.toString(importedCalls.size()));
if (!suppressDialogs)
MessageDialog.openInformation(new Shell(DisplayManager.getDefaultDisplay()), getI18nManager().getString(getNamespace(), "success", "label", getLanguage()), msg);
m_app.updateViews(true);
}
}
viewer.getTable().getShell().setCursor(null);
c.dispose();
} else {
return;
}
}
} catch (Exception ex) {
this.m_logger.log(Level.SEVERE, ex.getMessage(), ex);
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "error", ex));
}
}
use of de.janrufmonitor.framework.ICallList in project janrufmonitor by tbrandt77.
the class JournalController method deleteElements.
public synchronized void deleteElements(Object list) {
if (list instanceof ICallList) {
ICallManager cm = this._getRepository();
if (cm != null && cm.isActive() && cm.isSupported(IWriteCallRepository.class)) {
((IWriteCallRepository) cm).removeCalls((ICallList) list);
this.m_data = null;
}
}
}
use of de.janrufmonitor.framework.ICallList in project janrufmonitor by tbrandt77.
the class JournalController method addElements.
public synchronized void addElements(Object list) {
if (list instanceof ICallList) {
ICallManager cm = this._getRepository();
if (cm != null && list != null && cm.isActive() && cm.isSupported(IWriteCallRepository.class)) {
((IWriteCallRepository) cm).setCalls((ICallList) list);
this.m_data = null;
}
}
}
use of de.janrufmonitor.framework.ICallList in project janrufmonitor by tbrandt77.
the class MsnColoringAction method run.
public void run() {
Viewer v = this.m_app.getApplication().getViewer();
if (v != null && v instanceof TableViewer) {
this.m_colors = null;
Table t = ((TableViewer) v).getTable();
ICallList cl = ((JournalController) this.m_app.getController()).getCallList();
ICall c = null;
Color color = null;
for (int i = 0, n = cl.size(); i < n; i++) {
c = cl.get(i);
color = this.getMsnColor(c.getMSN().getMSN());
if (color != null) {
t.getItem(i).setForeground(color);
}
}
}
}
Aggregations