use of de.janrufmonitor.ui.jface.application.IExtendedApplicationController 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.ui.jface.application.IExtendedApplicationController in project janrufmonitor by tbrandt77.
the class TamMessageDelete method run.
public void run() {
Viewer v = this.m_app.getApplication().getViewer();
if (v != null) {
IStructuredSelection selection = (IStructuredSelection) v.getSelection();
if (!selection.isEmpty()) {
Object o = selection.getFirstElement();
if (o instanceof ICall) {
if (((ICall) o).getAttributes().contains("fritzbox.tamurl")) {
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()))) {
((ICall) o).getAttributes().remove("fritzbox.tamurl");
((ICall) o).getAttributes().remove("fritzbox.tamduration");
if (m_app.getController() instanceof IExtendedApplicationController) {
((IExtendedApplicationController) m_app.getController()).updateElement(((ICall) o), false);
} else {
m_app.getController().updateElement(((ICall) o));
}
this.m_app.updateViews(true);
}
} else {
new SWTExecuter() {
protected void execute() {
int style = SWT.APPLICATION_MODAL | SWT.OK;
MessageBox messageBox = new MessageBox(new Shell(DisplayManager.getDefaultDisplay()), style);
messageBox.setMessage(getI18nManager().getString(getNamespace(), "notam", "label", getLanguage()));
messageBox.open();
}
}.start();
return;
}
}
}
}
}
use of de.janrufmonitor.ui.jface.application.IExtendedApplicationController in project janrufmonitor by tbrandt77.
the class AssignAction 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()) {
final ICall call = (ICall) selection.getFirstElement();
ICaller caller = call.getCaller();
final ICaller newCaller = openCallerWizard(caller);
if (newCaller != null) {
int l_status = SWT.NO;
if (!newCaller.getPhoneNumber().isClired()) {
int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
MessageBox messageBox = new MessageBox(new Shell(DisplayManager.getDefaultDisplay()), style);
messageBox.setMessage(getI18nManager().getString(getNamespace(), "setall", "label", getLanguage()));
l_status = messageBox.open();
}
final int status = l_status;
ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
try {
IRunnableWithProgress r = new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {
progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "assignprogress", "label", getLanguage()), IProgressMonitor.UNKNOWN);
progressMonitor.worked(1);
call.setCaller(newCaller);
if (status == SWT.NO && m_app.getController() instanceof IExtendedApplicationController) {
// added 2009/12/31: only update single entry
progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "assignprogress", "label", getLanguage()));
((IExtendedApplicationController) m_app.getController()).updateElement(call, false);
} else {
progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "assignall", "label", getLanguage()));
m_app.getController().updateElement(call);
}
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);
}
if (!newCaller.getPhoneNumber().isClired()) {
new SWTExecuter() {
protected void execute() {
int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
MessageBox messageBox = new MessageBox(new Shell(DisplayManager.getDefaultDisplay()), style);
messageBox.setMessage(getI18nManager().getString(getNamespace(), "addressbookconfirm", "label", getLanguage()));
if (messageBox.open() == SWT.YES) {
List cpms = getRuntime().getCallerManagerFactory().getTypedCallerManagers(IWriteCallerRepository.class);
ICallerManager cmgr = null;
for (int i = 0; i < cpms.size(); i++) {
cmgr = (ICallerManager) cpms.get(i);
if (cmgr.isActive() && cmgr.isSupported(IWriteCallerRepository.class))
((IWriteCallerRepository) cmgr).updateCaller(newCaller);
}
}
m_app.updateViews(true);
}
}.start();
} else {
m_app.updateViews(true);
}
// this.m_app.updateViews(true);
}
}
}
}
use of de.janrufmonitor.ui.jface.application.IExtendedApplicationController in project janrufmonitor by tbrandt77.
the class ReIdentifyAction 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()) {
final ICall call = (ICall) selection.getFirstElement();
ICaller caller = call.getCaller();
if (caller.getPhoneNumber().isClired()) {
new SWTExecuter() {
protected void execute() {
int style = SWT.APPLICATION_MODAL | SWT.OK;
MessageBox messageBox = new MessageBox(new Shell(DisplayManager.getDefaultDisplay()), style);
messageBox.setMessage(getI18nManager().getString(getNamespace(), "clir", "label", getLanguage()));
messageBox.open();
}
}.start();
return;
}
List cms = getAllActiveCallerManagers(getRuntime());
if (cms.size() == 0) {
new SWTExecuter() {
protected void execute() {
int style = SWT.APPLICATION_MODAL | SWT.OK;
MessageBox messageBox = new MessageBox(new Shell(DisplayManager.getDefaultDisplay()), style);
messageBox.setMessage(getI18nManager().getString(getNamespace(), "nocms", "label", getLanguage()));
messageBox.open();
}
}.start();
return;
}
caller = Identifier.identify(getRuntime(), caller.getPhoneNumber(), cms);
if (caller == null) {
new SWTExecuter() {
protected void execute() {
int style = SWT.APPLICATION_MODAL | SWT.OK;
MessageBox messageBox = new MessageBox(new Shell(DisplayManager.getDefaultDisplay()), style);
messageBox.setMessage(getI18nManager().getString(getNamespace(), "notidentified", "label", getLanguage()));
messageBox.open();
}
}.start();
return;
}
final ICaller newCaller = openCallerWizard(caller);
if (newCaller != null) {
int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
MessageBox messageBox = new MessageBox(DisplayManager.getDefaultDisplay().getActiveShell(), style);
messageBox.setMessage(getI18nManager().getString(getNamespace(), "setall", "label", getLanguage()));
final int status = messageBox.open();
ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
try {
IRunnableWithProgress r = new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {
progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "assignprogress", "label", getLanguage()), IProgressMonitor.UNKNOWN);
progressMonitor.worked(1);
call.setCaller(newCaller);
processModifierServices(call);
if (status == SWT.NO && m_app.getController() instanceof IExtendedApplicationController) {
// added 2009/12/31: only update single entry
progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "assignprogress", "label", getLanguage()));
((IExtendedApplicationController) m_app.getController()).updateElement(call, false);
} else {
progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "assignall", "label", getLanguage()));
m_app.getController().updateElement(call);
}
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);
}
}
}
}
Aggregations