use of de.janrufmonitor.exception.Message in project janrufmonitor by tbrandt77.
the class GoogleContactsCallerManager method getCallers.
public ICallerList getCallers(IFilter filter) {
try {
if (filter != null && filter.getType().equals(FilterType.ATTRIBUTE)) {
IAttributeMap m = ((AttributeFilter) filter).getAttributeMap();
if (m.contains(IJAMConst.ATTRIBUTE_NAME_CATEGORY)) {
IAttribute a = m.get(IJAMConst.ATTRIBUTE_NAME_CATEGORY);
return getProxy().getContacts(a.getValue());
}
}
if (filter != null && filter.getType().equals(FilterType.CHARACTER)) {
ICallerList cl = getProxy().getContacts(null);
this.applyFilters(cl, new IFilter[] { filter });
return cl;
}
return getProxy().getContacts(null);
} catch (GoogleContactsException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "loginerror", e));
}
return getRuntime().getCallerFactory().createCallerList();
}
use of de.janrufmonitor.exception.Message in project janrufmonitor by tbrandt77.
the class HttpCallManager method getCalls.
public synchronized ICallList getCalls(IFilter[] filters, int count, int offset, ISearchTerm[] searchTerms) {
if (!this.isConnected()) {
this.m_logger.warning("Client is not yet connected with the server.");
return this.getRuntime().getCallFactory().createCallList();
}
IRequester r = this.getRequester(new CallListGetHandler(this.getCallManager(), filters, searchTerms));
IHttpResponse resp = r.request();
String xml = this.getXmlContent(resp);
this.handleRequester(resp, r);
if (xml != null && xml.length() > 0) {
ICallList l = XMLSerializer.toCallList(xml);
if (l != null)
return l;
this.m_logger.warning("Calllist from remote host was empty.");
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "empty", new Exception("CallList from server has either a wrong format, contains forbidden characters or was empty.")));
}
return this.getRuntime().getCallFactory().createCallList();
}
use of de.janrufmonitor.exception.Message in project janrufmonitor by tbrandt77.
the class GosCommand method asyncExecute.
public void asyncExecute() {
try {
WizardDialog.setDefaultImage(SWTImageManager.getInstance(this.getRuntime()).get(IJAMConst.IMAGE_KEY_PIM_ICON));
GosWizard gccw = new GosWizard();
WizardDialog dlg = new WizardDialog(new Shell(DisplayManager.getDefaultDisplay()), gccw);
dlg.open();
if (dlg.getReturnCode() == WizardDialog.OK) {
}
} catch (Throwable t) {
t.printStackTrace();
this.m_logger.severe(t.getMessage() + " : " + t.toString());
PropagationFactory.getInstance().fire(new Message(Message.ERROR, this.getNamespace(), t.toString().toLowerCase(), t));
} finally {
this.isExecuting = false;
}
}
use of de.janrufmonitor.exception.Message in project janrufmonitor by tbrandt77.
the class ExportAction method run.
public void run() {
try {
FileDialog dialog = new FileDialog(new Shell(DisplayManager.getDefaultDisplay()), SWT.SAVE);
dialog.setText(this.getI18nManager().getString(this.getNamespace(), "title", "label", this.getLanguage()));
List ids = ImExportFactory.getInstance().getAllExporterIds(IImExporter.CALLER_MODE);
String[] filternames = new String[ids.size()];
String[] extensions = new String[ids.size()];
IImExporter ie = null;
for (int i = 0; i < ids.size(); i++) {
ie = ImExportFactory.getInstance().getExporter((String) ids.get(i));
filternames[i] = ie.getFilterName();
extensions[i] = ie.getExtension();
}
dialog.setFilterNames(filternames);
dialog.setFilterExtensions(extensions);
String filter = getRuntime().getConfigManagerFactory().getConfigManager().getProperty(getNamespace(), "lastopeneddir");
if (filter == null || filter.length() == 0 || !new File(filter).exists())
filter = PathResolver.getInstance(getRuntime()).getDataDirectory();
dialog.setFilterPath(filter);
final String filename = dialog.open();
if (filename == null)
return;
filter = new File(filename).getParentFile().getAbsolutePath();
getRuntime().getConfigManagerFactory().getConfigManager().setProperty(getNamespace(), "lastopeneddir", filter);
String ext = "";
for (int i = 0; i < ids.size(); i++) {
final IImExporter exp = ImExportFactory.getInstance().getExporter((String) ids.get(i));
ext = exp.getExtension().substring(1);
if (filename.toLowerCase().endsWith(ext) && exp.getMode() == IImExporter.CALLER_MODE) {
try {
ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
IRunnableWithProgress r = new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {
progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "exportprogress", "label", getLanguage()), IProgressMonitor.UNKNOWN);
((ICallerExporter) exp).setCallerList(((EditorController) m_app.getController()).getCallerList());
exp.setFilename(filename);
if (((ICallerExporter) exp).doExport()) {
progressMonitor.done();
PropagationFactory.getInstance().fire(new Message(Message.INFO, getI18nManager().getString(Editor.NAMESPACE, "title", "label", getLanguage()), new Exception(getI18nManager().getString(getNamespace(), "success", "description", getLanguage()))), "Tray");
} else {
progressMonitor.done();
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("Export of contacts failed.");
}
}.start();
}
}
};
pmd.setBlockOnOpen(false);
pmd.run(true, false, r);
} catch (InterruptedException e) {
throw e;
} catch (InvocationTargetException e) {
throw e;
}
// m_app.updateViews(false);
}
}
} 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.exception.Message in project janrufmonitor by tbrandt77.
the class AbstractTreeTableApplication 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) {
IFilter[] f = fm.getFiltersFromString(this.getConfiguration().getProperty(CFG_FILTER, ""));
String activeFilter = this.getFilterManager().getFiltersToLabelText(f, 45);
// get all defined Filters from configuration
List l = new ArrayList();
l.add(new IFilter[0]);
final 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));
}
}
// 2009/01/10: added sorting of filters
Collections.sort(l, new Comparator() {
public int compare(Object o1, Object o2) {
if (o1 instanceof IFilter[] && o2 instanceof IFilter[]) {
return jfm.getFiltersToLabelText((IFilter[]) o1, 45).compareToIgnoreCase(jfm.getFiltersToLabelText((IFilter[]) o2, 45));
}
return 0;
}
});
String[] filters = new String[l.size()];
int select = -1;
String filterAlias = null;
for (int i = 0; i < l.size(); i++) {
filterAlias = jfm.getFiltersToLabelText((IFilter[]) l.get(i), 45);
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, jfm.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
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(((TreeViewer) viewer).getTree().getDisplay(), SWT.CURSOR_WAIT);
Tree tree = ((TreeViewer) viewer).getTree();
AbstractMenuBuilder mb = getMenuBuilder();
if (mb != null)
tree.setMenu(mb.createPopupMenu(tree));
tree.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);
tree.setFocus();
tree.setLinesVisible(getConfiguration().getProperty(CFG_SHOW_GRID, "true").equalsIgnoreCase("true"));
TreeColumn[] columns = tree.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) {
tree.setSortColumn(columns[sortcolumn]);
if (getConfiguration().getProperty(CFG_DIRECTION, "false").equalsIgnoreCase("false")) {
tree.setSortDirection(SWT.DOWN);
} else {
tree.setSortDirection(SWT.UP);
}
}
IAction action = getColoringAction();
if (action != null)
action.run();
action = getHightlightAction();
if (action != null)
action.run();
// set new title text...
String title_ext = getTitleExtension();
if (title_ext == null || title_ext.length() == 0)
tree.getShell().setText(getI18nManager().getString(getNamespace(), "title", "label", getLanguage()));
else
tree.getShell().setText(getI18nManager().getString(getNamespace(), "title", "label", getLanguage()) + " - " + title_ext);
tree.getShell().setCursor(null);
c.dispose();
ts.setFinished(true);
if (lastMarkedTreeItem > -1 && tree.getItemCount() > 0) {
TreeItem item = tree.getItem(Math.min(lastMarkedTreeItem, tree.getItemCount() - 1));
if (item != null) {
tree.setSelection(item);
tree.showSelection();
}
}
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) {
message += getI18nManager().getString(getNamespace(), "items_filtered", "label", getLanguage());
}
getStatusLineManager().setMessage(message);
}
}
}.start();
}
Aggregations