use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.
the class ChangeAction 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) {
o = ((ICall) o).getCaller();
}
if (o instanceof ICaller) {
if (((ICaller) o).getPhoneNumber().isClired())
return;
IAttribute att = ((ICaller) o).getAttribute(SoundConst.ATTRIBUTE_USER_SOUNDFILE);
if (att == null) {
att = this.getRuntime().getCallerFactory().createAttribute(SoundConst.ATTRIBUTE_USER_SOUNDFILE, "");
}
// Create the dialog
WizardDialog.setDefaultImage(SWTImageManager.getInstance(this.getRuntime()).get(IJAMConst.IMAGE_KEY_PIM_ICON));
SoundDataWizard sdoW = new SoundDataWizard(att.getValue());
WizardDialog dlg = new WizardDialog(new Shell(DisplayManager.getDefaultDisplay()), sdoW);
dlg.open();
if (dlg.getReturnCode() == WizardDialog.OK) {
att.setValue(sdoW.getResult());
((ICaller) o).setAttribute(att);
this.m_app.getController().updateElement(o);
this.m_app.updateViews(false);
}
}
}
}
}
use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.
the class DefaultCallDialogService method receivedValidRule.
public void receivedValidRule(final ICall aCall) {
ICaller theCaller = aCall.getCaller();
if (theCaller != null) {
this.m_logger.info("Opening new dialog instance...");
final long ms = System.currentTimeMillis();
this.m_logger.fine("Time measure in ms (init): " + (System.currentTimeMillis() - ms));
new SWTExecuter(true, this.getID()) {
protected void execute() {
if (m_configuration.getProperty(CFG_BALLOON, "false").equalsIgnoreCase("false")) {
m_logger.fine("Time measure in ms (SWTExecuter): " + (System.currentTimeMillis() - ms));
Dialog j = new Dialog(m_configuration, aCall);
m_logger.fine("Time measure in ms (SWTExecuter.open() - before): " + (System.currentTimeMillis() - ms));
j.open();
m_logger.fine("Time measure in ms (SWTExecuter.open() - after): " + (System.currentTimeMillis() - ms));
j = null;
} else {
m_logger.fine("Time measure in ms (SWTExecuter): " + (System.currentTimeMillis() - ms));
ExtendedBalloonDialog j = new ExtendedBalloonDialog(m_configuration, aCall);
try {
Thread.sleep(getDelay());
} catch (InterruptedException e) {
}
j.createDialog();
m_logger.fine("Time measure in ms (SWTExecuter.open() - before): " + (System.currentTimeMillis() - ms));
j.open();
m_logger.fine("Time measure in ms (SWTExecuter.open() - after): " + (System.currentTimeMillis() - ms));
j = null;
}
}
}.start();
this.m_logger.fine("Time measure in ms (end): " + (System.currentTimeMillis() - ms));
} else {
this.m_logger.warning("Dialog not opened due to invalid caller data.");
}
}
use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.
the class AbstractFilterManager method getFiltersToLabelText.
public String getFiltersToLabelText(IFilter[] f, int shorten) {
if (f != null && f.length > 0) {
boolean processedCaller = false;
StringBuffer sb = new StringBuffer();
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_limit", "label", this.getLanguage()));
for (int i = 0; i < f.length; i++) {
IFilter f1 = f[i];
if (f1.getType().equals(FilterType.CIP)) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_cip", "label", this.getLanguage()));
sb.append(this.getRuntime().getCipManager().getCipLabel(((CipFilter) f1).getCip(), this.getLanguage()));
if ((i + 1) < f.length)
sb.append(", ");
}
if (f1.getType().equals(FilterType.MSN)) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_msn", "label", this.getLanguage()));
IMsn[] m = ((MsnFilter) f1).getMsn();
for (int k = 0, l = m.length; k < l; k++) {
sb.append(m[k].getMSN());
m[k].setAdditional(this.getRuntime().getMsnManager().getMsnLabel(m[k]));
if (m[k].getAdditional().length() > 0) {
sb.append(" (" + m[k].getAdditional() + ")");
}
if ((k + 1) < l)
sb.append(", ");
}
if ((i + 1) < f.length)
sb.append(", ");
}
if (f1.getType().equals(FilterType.DATE)) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_date", "label", this.getLanguage()));
if (((DateFilter) f1).getTimeframe() == -1) {
Date d1 = ((DateFilter) f1).getDateFrom();
Date d2 = ((DateFilter) f1).getDateTo();
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
sb.append("[");
sb.append(sdf.format(d2));
sb.append(" - ");
if (d1 != null)
sb.append(sdf.format(d1));
else {
sb.append(this.getI18nManager().getString(this.getNamespace(), "today", "label", this.getLanguage()));
}
sb.append("]");
if ((i + 1) < f.length)
sb.append(", ");
} else {
sb.append("[");
sb.append(this.getI18nManager().getString(this.getNamespace(), Long.toString(((DateFilter) f1).getTimeframe()), "label", this.getLanguage()));
sb.append("]");
if ((i + 1) < f.length)
sb.append(", ");
}
}
if (f1.getType().equals(FilterType.YEAR)) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_date", "label", this.getLanguage()));
sb.append("[");
sb.append(((YearFilter) f1).getYear());
sb.append("]");
if ((i + 1) < f.length)
sb.append(", ");
}
if (f1.getType().equals(FilterType.MONTH_YEAR)) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_date", "label", this.getLanguage()));
sb.append("[");
sb.append(((MonthYearFilter) f1).getYear());
sb.append(".");
sb.append((((MonthYearFilter) f1).getMonth() > 9 ? ((MonthYearFilter) f1).getMonth() : "0" + ((MonthYearFilter) f1).getMonth()));
sb.append("]");
if ((i + 1) < f.length)
sb.append(", ");
}
if (f1.getType().equals(FilterType.CALLER) && !processedCaller) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_caller", "label", this.getLanguage()));
if ((i + 1) < f.length && !processedCaller)
sb.append(", ");
processedCaller = true;
}
if (f1.getType().equals(FilterType.PHONENUMBER)) {
PhonenumberFilter cf = ((PhonenumberFilter) f1);
IPhonenumber pnc = getRuntime().getCallerFactory().createPhonenumber(cf.getPhonenumber().getIntAreaCode(), cf.getPhonenumber().getAreaCode(), "0000000000");
ICaller c = Identifier.identifyDefault(getRuntime(), pnc);
if (c != null) {
IAttribute city = c.getAttribute(IJAMConst.ATTRIBUTE_NAME_CITY);
if (city != null && city.getValue().trim().length() > 0) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_area", "label", this.getLanguage()).substring(2));
sb.append(city.getValue().trim());
sb.append(" (0");
sb.append(cf.getPhonenumber().getAreaCode());
sb.append(")");
if ((i + 1) < f.length)
sb.append(", ");
continue;
}
}
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_intarea", "label", this.getLanguage()));
sb.append("00" + cf.getPhonenumber().getIntAreaCode());
if (cf.getPhonenumber().getAreaCode().trim().length() > 0) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_area", "label", this.getLanguage()));
sb.append("0" + cf.getPhonenumber().getAreaCode().trim());
}
if ((i + 1) < f.length)
sb.append(", ");
}
if (f1.getType().equals(FilterType.ITEMCOUNT)) {
ItemCountFilter cf = ((ItemCountFilter) f1);
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_itemcount", "label", this.getLanguage()));
sb.append(cf.getLimit());
if ((i + 1) < f.length)
sb.append(", ");
}
if (f1.getType().equals(FilterType.ATTRIBUTE)) {
AttributeFilter cf = ((AttributeFilter) f1);
IAttributeMap m = cf.getAttributeMap();
if (m != null && m.size() > 0) {
Iterator it = m.iterator();
IAttribute a = null;
while (it.hasNext()) {
a = (IAttribute) it.next();
if (a.getName().equalsIgnoreCase(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS)) {
sb.append(this.getI18nManager().getString(this.getNamespace(), a.getValue(), "label", this.getLanguage()));
} else if (a.getName().equalsIgnoreCase(IJAMConst.ATTRIBUTE_NAME_CATEGORY)) {
sb.append(this.getI18nManager().getString(this.getNamespace(), a.getName(), "label", this.getLanguage()));
sb.append(a.getValue());
} else {
sb.append(this.getI18nManager().getString(this.getNamespace(), a.getName(), "label", this.getLanguage()));
}
if (it.hasNext())
sb.append(", ");
}
}
if ((i + 1) < f.length)
sb.append(", ");
}
if (f1.getType().equals(FilterType.CHARACTER)) {
CharacterFilter cf = ((CharacterFilter) f1);
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_" + cf.getAttributeName(), "label", this.getLanguage()));
sb.append("[");
sb.append(cf.getCharacter().toUpperCase());
sb.append("...]");
if ((i + 1) < f.length)
sb.append(", ");
}
}
String s = sb.toString();
if (s.trim().endsWith(","))
s = s.trim().substring(0, s.trim().length() - 1);
if (shorten > -1 && shorten < s.length()) {
return s.substring(0, Math.min(shorten, s.length())) + "...";
}
if (s.trim().length() > 0)
return s;
}
return this.getI18nManager().getString(this.getNamespace(), "view_all", "label", this.getLanguage());
}
use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.
the class TableCellModifier method modify.
public void modify(Object element, String column, Object value) {
if (element instanceof Item)
element = ((Item) element).getData();
ITableCellRenderer r = RendererRegistry.getInstance().getRenderer(column);
if (r instanceof ITableAttributeCellEditorRenderer && ((ITableAttributeCellEditorRenderer) r).getAttribute() != null) {
if (element instanceof ICall) {
ICall c = ((ICall) element);
IAttribute cAtt = c.getAttribute(((ITableAttributeCellEditorRenderer) r).getAttribute().getName());
if (cAtt != null && value instanceof String) {
if (cAtt.getValue().equalsIgnoreCase((String) value)) {
return;
}
}
IAttribute att = ((ITableAttributeCellEditorRenderer) r).getAttribute();
((ITableAttributeCellEditorRenderer) r).applyAttributeChanges(c, att, value);
if (this.m_ac.getController() instanceof IExtendedApplicationController) {
((IExtendedApplicationController) this.m_ac.getController()).updateElement(c, false);
} else {
this.m_ac.getController().updateElement(c);
}
}
if (element instanceof ICaller) {
ICaller c = ((ICaller) element);
IAttribute cAtt = c.getAttribute(((ITableAttributeCellEditorRenderer) r).getAttribute().getName());
if (cAtt != null && value instanceof String) {
if (cAtt.getValue().equalsIgnoreCase((String) value)) {
return;
}
}
IAttribute att = ((ITableAttributeCellEditorRenderer) r).getAttribute();
((ITableAttributeCellEditorRenderer) r).applyAttributeChanges(c, att, value);
if (this.m_ac.getController() instanceof IExtendedApplicationController) {
((IExtendedApplicationController) this.m_ac.getController()).updateElement(c, false);
} else {
this.m_ac.getController().updateElement(c);
}
}
}
this.m_v.refresh();
}
use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.
the class ChangeAction method run.
public void run() {
Viewer v = this.m_app.getApplication().getViewer();
if (v != null && v instanceof TreeViewer) {
IStructuredSelection selection = (IStructuredSelection) v.getSelection();
if (!selection.isEmpty()) {
if (selection.getFirstElement() instanceof IMultiPhoneCaller) {
ICaller caller = (IMultiPhoneCaller) selection.getFirstElement();
ICaller newCaller = openCallerWizard(caller);
if (newCaller != null) {
// ICallerList list = this.getRuntime().getCallerFactory().createCallerList(1);
// list.add(caller);
// this.m_app.getController().deleteElements(list);
//
// list.clear();
// list.add(newCaller);
//
// this.m_app.getController().addElements(list);
ICallerList list = this.getRuntime().getCallerFactory().createCallerList(1);
list.add(newCaller);
this.m_app.getController().updateElement(list);
this.m_app.updateViews(true);
}
} else if (selection.getFirstElement() instanceof ICaller) {
ICaller caller = (ICaller) selection.getFirstElement();
ICaller newCaller = openCallerWizard(caller);
if (newCaller != null) {
ICallerList list = this.getRuntime().getCallerFactory().createCallerList(1);
list.add(caller);
this.m_app.getController().deleteElements(list);
list.clear();
list.add(newCaller);
this.m_app.getController().addElements(list);
this.m_app.updateViews(true);
}
}
}
}
}
Aggregations