use of de.janrufmonitor.exception.Message in project janrufmonitor by tbrandt77.
the class AbstractTableApplication method updateViews.
public synchronized void updateViews(Object[] controllerdata, boolean reload) {
// refresh controll data
refreshController(reload);
if (controllerdata != null)
this.m_controller.generateElementArray(controllerdata);
final IFilterManager fm = this.getFilterManager();
if (fm != null && this.getConfiguration().getProperty(CFG_ENABLE_FILTER_VIEW, "true").equalsIgnoreCase("true")) {
IFilter[] f = fm.getFiltersFromString(this.getConfiguration().getProperty(CFG_FILTER, ""));
String activeFilter = this.getFilterLabel(fm, f);
// get all defined Filters from configuration
List l = new ArrayList();
l.add(new IFilter[0]);
IFilterManager jfm = getFilterManager();
Properties c = this.getConfiguration();
Iterator iter = c.keySet().iterator();
String key = null;
while (iter.hasNext()) {
key = (String) iter.next();
if (key.startsWith("filter_")) {
String filter = c.getProperty(key);
l.add(jfm.getFiltersFromString(filter));
}
}
// added 2015/04/03: added runtime filters
if (jfm.hasRuntimeFilters()) {
IFilter[][] rf = jfm.getRuntimeFilters();
if (rf != null && rf.length > 0) {
for (int i = 0; i < rf.length; i++) l.add(rf[i]);
}
}
// added 2015/04/01: sort filter list
Collections.sort(l, new Comparator() {
public int compare(Object f1, Object f2) {
if (f1 != null && f2 != null && f1 instanceof IFilter[] && f2 instanceof IFilter[]) {
return getFilterLabel(getFilterManager(), ((IFilter[]) f1)).toLowerCase().compareTo(getFilterLabel(getFilterManager(), ((IFilter[]) f2)).toLowerCase());
// if (((IFilter[])f1).length==((IFilter[])f2).length) {
// return (((IFilter[])f2)[0].toString().compareTo(((IFilter[])f1)[0].toString()));
// }
// if (((IFilter[])f1).length<((IFilter[])f2).length) return -1;
// return 1;
}
return 0;
}
});
String[] filters = new String[l.size()];
int select = -1;
String filterAlias = null;
for (int i = 0; i < l.size(); i++) {
// this.getFilterManager().getFiltersToLabelText((IFilter[]) l.get(i),45);
filterAlias = this.getFilterLabel(fm, (IFilter[]) l.get(i));
if (filterAlias.equalsIgnoreCase(activeFilter)) {
select = i;
}
filters[i] = filterAlias;
this.currentView.setData(filterAlias, (IFilter[]) l.get(i));
}
this.currentView.setItems(filters);
if (select == -1) {
getApplication().getConfiguration().setProperty(CFG_FILTER, fm.getFiltersToString((IFilter[]) l.get(0)));
getApplication().storeConfiguration();
select = 0;
}
this.currentView.select(select);
this.currentView.setVisibleItemCount((this.currentView.getItemCount() > 16 ? 16 : this.currentView.getItemCount()));
this.currentView.pack();
this.currentView.getParent().pack();
}
// update menu bar
if (this.getMenuBarManager() != null) {
Menu m = this.getMenuBarManager().getMenu();
this.setMenuItemStatus(m);
}
new SWTExecuter(false, getID() + "-BuildTableThread") {
protected void execute() {
final ThreadStatus ts = new ThreadStatus();
class WorkerSWTExecuter extends SWTExecuter {
public WorkerSWTExecuter(boolean sync, String name) {
super(sync, name);
}
public void execute() {
try {
Cursor c = new Cursor(((TableViewer) viewer).getTable().getDisplay(), SWT.CURSOR_WAIT);
Table table = ((TableViewer) viewer).getTable();
AbstractMenuBuilder mb = getMenuBuilder();
if (mb != null)
table.setMenu(mb.createPopupMenu(table));
table.getShell().setCursor(c);
long start = System.currentTimeMillis();
viewer.setInput(null);
viewer.setInput(m_controller);
// added: 2007/03/17: avoid dead lock in journal...
ts.setFinished(true);
table.setFocus();
table.setLinesVisible(getConfiguration().getProperty(CFG_SHOW_GRID, "true").equalsIgnoreCase("true"));
TableColumn[] columns = table.getColumns();
for (int i = 0; i < columns.length; i++) {
columns[i].setImage(null);
}
int sortcolumn = getOrderColumn(Integer.parseInt(getConfiguration().getProperty(CFG_ORDER, "0")));
if (sortcolumn > -1 && sortcolumn < columns.length) {
table.setSortColumn(columns[sortcolumn]);
if (getConfiguration().getProperty(CFG_DIRECTION, "false").equalsIgnoreCase("false")) {
table.setSortDirection(SWT.DOWN);
} else {
table.setSortDirection(SWT.UP);
}
}
// IAction action = getColoringAction();
// if (action!=null)
// action.run();
IAction action = getHightlightAction();
if (action != null)
action.run();
// set new title text...
String title_ext = getTitleExtension();
if (title_ext == null || title_ext.length() == 0)
table.getShell().setText(getI18nManager().getString(getNamespace(), "title", "label", getLanguage()));
else
table.getShell().setText(getI18nManager().getString(getNamespace(), "title", "label", getLanguage()) + " - " + title_ext);
table.getShell().setCursor(null);
c.dispose();
ts.setFinished(true);
if (lastMarkedRow > -1) {
table.setSelection(Math.min(lastMarkedRow, table.getItemCount()));
}
checkAmountOfEntries(start, System.currentTimeMillis());
} catch (Exception e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
if (ts != null)
ts.setFinished(true);
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "refresherror", e));
}
}
}
;
final WorkerSWTExecuter workerThread = new WorkerSWTExecuter(false, getID() + "-SetDataToTableThread");
if (getConfiguration().getProperty(AbstractTableApplication.CFG_SHOW_REFRESH_POPUP, "true").equalsIgnoreCase("true")) {
ProgressMonitorDialog pmd = new ProgressMonitorDialog(getShell());
try {
IRunnableWithProgress r = new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {
progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "refreshprogress", "label", getLanguage()), IProgressMonitor.UNKNOWN);
Thread t = new Thread() {
public void run() {
// preload data
try {
m_controller.getElementArray();
} catch (Exception ex) {
m_logger.log(Level.SEVERE, ex.getMessage(), ex);
}
}
};
t.setName("JAM-" + getID() + "#Preloader-Thread-(non-deamon)");
t.start();
Object repository = m_controller.getRepository();
do {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
}
if (repository instanceof ITracker) {
String msg = getI18nManager().getString(getNamespace(), "tracking", "label", getLanguage());
int leftover = Math.max(0, (((ITracker) repository).getTotal() - ((ITracker) repository).getCurrent()));
msg = StringUtils.replaceString(msg, "{%1}", Integer.toString(leftover));
progressMonitor.subTask(msg);
}
} while (t.isAlive());
workerThread.start();
while (!ts.isFinished()) {
try {
progressMonitor.worked(1);
Thread.sleep(100);
} catch (InterruptedException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
}
}
progressMonitor.done();
}
};
pmd.setBlockOnOpen(false);
pmd.run(true, false, r);
// ModalContext.run(r, true, pmd.getProgressMonitor(), DisplayManager.getDefaultDisplay());
} catch (InterruptedException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
} catch (InvocationTargetException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
}
} else {
workerThread.execute();
}
// refresh status line
String message = m_controller.countElements() + getI18nManager().getString(getNamespace(), "items", "label", getLanguage());
if (fm != null) {
IFilter[] f = fm.getFiltersFromString(getConfiguration().getProperty(CFG_FILTER, ""));
if (f != null && f.length > 0 && getConfiguration().getProperty(CFG_ENABLE_FILTER_VIEW, "true").equalsIgnoreCase("true")) {
message += getI18nManager().getString(getNamespace(), "items_filtered", "label", getLanguage());
}
getStatusLineManager().setMessage(message);
}
}
}.start();
}
use of de.janrufmonitor.exception.Message in project janrufmonitor by tbrandt77.
the class ThunderbirdTransformer method getCallers.
public ICallerList getCallers() {
ICallerList cl = PIMRuntime.getInstance().getCallerFactory().createCallerList();
if (this.m_filename == null)
return cl;
File f = new File(this.m_filename);
if (!f.exists() || !f.isFile()) {
this.m_logger.warning("Mozilla Thunderbird file " + this.m_filename + " does not exists.");
PropagationFactory.getInstance().fire(new Message(Message.INFO, ThunderbirdCallerManager.NAMESPACE, "nofile", new Exception("Sync Mozilla Thunderbird Adressbook...")));
return cl;
}
if (this.m_sync)
PropagationFactory.getInstance().fire(new Message(Message.INFO, ThunderbirdCallerManager.NAMESPACE, "sync", new Exception("Sync Mozilla Thunderbird Adressbook...")));
try {
List rawData = new ArrayList();
FileInputStream fis = new FileInputStream(f);
MorkDocument md = new MorkDocument(new InputStreamReader(fis));
List l = md.getRows();
Row r = null;
for (int i = 0, j = l.size(); i < j; i++) {
r = (Row) l.get(i);
rawData.add(r.getAliases());
}
l = md.getTables();
Table t = null;
for (int i = 0, j = l.size(); i < j; i++) {
t = (Table) l.get(i);
for (int k = 0; k < t.getRows().size(); k++) {
r = (Row) t.getRows().get(k);
rawData.add(r.getAliases());
}
}
fis.close();
this.m_total = rawData.size();
if (rawData.size() > 0) {
this.m_logger.info("Found " + rawData.size() + " Mozilla Thunderbird contacts.");
this.parseContacts(cl, rawData);
}
} catch (FileNotFoundException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
} catch (IOException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
}
this.m_logger.info(cl.size() + " contacts from Mozilla Thunderbird available.");
return cl;
}
use of de.janrufmonitor.exception.Message in project janrufmonitor by tbrandt77.
the class ScoreNumberTellows method run.
public void run() {
Viewer v = this.m_app.getApplication().getViewer();
if (v != null) {
IStructuredSelection selection = (IStructuredSelection) v.getSelection();
if (!selection.isEmpty()) {
Iterator iter = selection.iterator();
while (iter.hasNext()) {
Object o1 = iter.next();
Object o = null;
if (o1 instanceof ICall) {
o = ((ICall) o1).getCaller();
}
if (o1 instanceof ICaller) {
o = o1;
}
if (o != null) {
if (!((ICaller) o).getPhoneNumber().isClired() && !PhonenumberAnalyzer.getInstance(getRuntime()).isInternal(((ICaller) o).getPhoneNumber()) && (((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase("49") || ((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase("41") || ((ICaller) o).getPhoneNumber().getIntAreaCode().equalsIgnoreCase("43"))) {
final Object o2 = o1;
final Object o3 = o;
ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
try {
IRunnableWithProgress r = new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {
progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "scoring", "label", getLanguage()), IProgressMonitor.UNKNOWN);
progressMonitor.worked(1);
try {
IAttributeMap m = TellowsProxy.getInstance().getTellowsData(((ICaller) o3).getPhoneNumber().getTelephoneNumber(), ((ICaller) o3).getPhoneNumber().getIntAreaCode());
if (m.size() > 0) {
((ICaller) o3).getAttributes().addAll(m);
if (m_app.getController() instanceof IExtendedApplicationController)
((IExtendedApplicationController) m_app.getController()).updateElement(o2, false);
else
m_app.getController().updateElement(o2);
}
} catch (Exception e) {
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getRuntime().getI18nManagerFactory().getI18nManager().getString(NAMESPACE, "title", "label", getLanguage()), e), "Tray");
}
progressMonitor.done();
}
};
pmd.setBlockOnOpen(false);
pmd.run(true, false, r);
// ModalContext.run(r, true, pmd.getProgressMonitor(),
// DisplayManager.getDefaultDisplay());
} catch (InterruptedException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
} catch (InvocationTargetException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
}
}
}
}
this.m_app.updateViews(true);
}
}
}
use of de.janrufmonitor.exception.Message in project janrufmonitor by tbrandt77.
the class Tellows method receivedValidRule.
public void receivedValidRule(ICall aCall) {
// call is identified already
if (!PhonenumberAnalyzer.getInstance(getRuntime()).isInternal(aCall.getCaller().getPhoneNumber()) && !aCall.getCaller().getPhoneNumber().isClired()) {
if (!aCall.getCaller().getPhoneNumber().getIntAreaCode().equalsIgnoreCase("49") && !aCall.getCaller().getPhoneNumber().getIntAreaCode().equalsIgnoreCase("43") && !aCall.getCaller().getPhoneNumber().getIntAreaCode().equalsIgnoreCase("41")) {
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Country code not supported by tellows: 00" + aCall.getCaller().getPhoneNumber().getIntAreaCode());
return;
}
String num = aCall.getCaller().getPhoneNumber().getTelephoneNumber();
try {
IAttributeMap m = TellowsProxy.getInstance().getTellowsData(num, aCall.getCaller().getPhoneNumber().getIntAreaCode());
if (m.size() > 0) {
aCall.getCaller().getAttributes().addAll(m);
IEventBroker eventBroker = this.getRuntime().getEventBroker();
eventBroker.send(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_CALLMARKEDSPAM, aCall));
}
} catch (Exception e) {
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getRuntime().getI18nManagerFactory().getI18nManager().getString(NAMESPACE, "title", "label", getLanguage()), e), "Tray");
}
}
}
use of de.janrufmonitor.exception.Message in project janrufmonitor by tbrandt77.
the class Tellows method startup.
public void startup() {
super.startup();
IEventBroker eventBroker = this.getRuntime().getEventBroker();
eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_CALL));
eventBroker.register(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_OUTGOING_CALL));
eventBroker.register(this);
if (!this.isTellowsActivated()) {
eventBroker.unregister(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_CALL));
eventBroker.unregister(this, eventBroker.createEvent(IEventConst.EVENT_TYPE_IDENTIFIED_OUTGOING_CALL));
eventBroker.unregister(this);
this.m_logger.warning("No tellows API key found. Service will be stopped.");
String msg = getRuntime().getI18nManagerFactory().getI18nManager().getString(getNamespace(), "no_api_key", "description", getLanguage());
PropagationFactory.getInstance().fire(new Message(Message.WARNING, getRuntime().getI18nManagerFactory().getI18nManager().getString(NAMESPACE, "title", "label", getLanguage()), new Exception(msg)), "Tray");
} else
new URLRequester().go();
this.m_logger.info("Tellows is started ...");
}
Aggregations