use of de.janrufmonitor.ui.jface.wizards.CallerCombineWizard in project janrufmonitor by tbrandt77.
the class CombineAction method run.
public void run() {
Viewer v = this.m_app.getApplication().getViewer();
if (v != null) {
IStructuredSelection selection = (IStructuredSelection) v.getSelection();
if (!selection.isEmpty()) {
Iterator i = selection.iterator();
ICallerList list = getRuntime().getCallerFactory().createCallerList();
ICallerList olist = getRuntime().getCallerFactory().createCallerList();
Object o = null;
while (i.hasNext()) {
o = i.next();
olist.add((ICaller) o);
if (o instanceof IMultiPhoneCaller) {
list.add((IMultiPhoneCaller) o);
} else if (o instanceof ICaller) {
list.add(getRuntime().getCallerFactory().toMultiPhoneCaller((ICaller) o));
}
}
if (list.size() < 2)
return;
Display display = DisplayManager.getDefaultDisplay();
Shell shell = new Shell(display);
WizardDialog.setDefaultImage(SWTImageManager.getInstance(this.getRuntime()).get(IJAMConst.IMAGE_KEY_PIM_ICON));
CallerCombineWizard callerWiz = new CallerCombineWizard(list);
WizardDialog dlg = new WizardDialog(shell, callerWiz);
dlg.open();
if (dlg.getReturnCode() == WizardDialog.OK) {
IMultiPhoneCaller c = callerWiz.getResult();
if (c != null) {
// remove merged contact from olist
ICaller ca, rmc = null;
for (int j = olist.size() - 1; j >= 0; j--) {
ca = olist.get(j);
if (ca.getUUID().equalsIgnoreCase(c.getUUID())) {
rmc = ca;
m_logger.info("Merged user detected: " + rmc);
}
}
if (rmc != null)
olist.remove(rmc);
this.m_app.getController().deleteElements(olist);
this.m_app.getController().updateElement(c);
this.m_app.updateViews(true);
}
}
}
}
}
Aggregations