use of de.janrufmonitor.ui.jface.application.ITreeItemCallerData in project janrufmonitor by tbrandt77.
the class Etiquet method renderAsText.
public String renderAsText() {
if (this.m_o != null) {
if (this.m_o instanceof ICall) {
this.m_o = ((ICall) this.m_o).getCaller();
}
if (this.m_o instanceof ICaller) {
this.m_o = new TreeItemCallerData(((ICaller) this.m_o).getAttributes(), ((ICaller) this.m_o).getPhoneNumber());
}
if (this.m_o instanceof ITreeItemCallerData) {
IAttributeMap m = ((ITreeItemCallerData) m_o).getAttributes();
IPhonenumber pn = ((ITreeItemCallerData) m_o).getPhone();
if (m.contains(IMacAddressBookNumberMapping.MAPPING_ATTTRIBUTE_ID + pn.getTelephoneNumber())) {
IAttribute type = m.get(IMacAddressBookNumberMapping.MAPPING_ATTTRIBUTE_ID + pn.getTelephoneNumber());
if (type != null) {
return PIMRuntime.getInstance().getI18nManagerFactory().getI18nManager().getString(NAMESPACE, type.getValue(), "label", getLanguage());
}
}
}
}
return "";
}
use of de.janrufmonitor.ui.jface.application.ITreeItemCallerData in project janrufmonitor by tbrandt77.
the class ProviderLogo method renderAsImage.
public Image renderAsImage() {
if (this.m_o != null) {
if (this.m_o instanceof ICall) {
this.m_o = ((ICall) this.m_o).getCaller().getPhoneNumber();
}
if (this.m_o instanceof ICaller) {
this.m_o = ((ICaller) this.m_o).getPhoneNumber();
}
if (this.m_o instanceof ITreeItemCallerData) {
this.m_o = ((ITreeItemCallerData) this.m_o).getPhone();
}
if (this.m_o instanceof IPhonenumber) {
if (((IPhonenumber) this.m_o).isClired())
return null;
String key = "provider/" + ((IPhonenumber) this.m_o).getIntAreaCode() + "_" + ((IPhonenumber) this.m_o).getAreaCode() + ".jpg";
File logoFile = new File(PathResolver.getInstance(PIMRuntime.getInstance()).getImageDirectory() + key);
if (!logoFile.exists() || !logoFile.isFile()) {
key = "provider/" + ((IPhonenumber) this.m_o).getIntAreaCode() + ".jpg";
logoFile = new File(PathResolver.getInstance(PIMRuntime.getInstance()).getImageDirectory() + key);
if (!logoFile.exists() || !logoFile.isFile())
return null;
}
Image logo = SWTImageManager.getInstance(PIMRuntime.getInstance()).get(key);
if (logo == null) {
SWTImageManager.getInstance(PIMRuntime.getInstance()).loadImage(key, 40, 40);
logo = SWTImageManager.getInstance(PIMRuntime.getInstance()).get(key);
return logo;
}
return logo;
}
}
return null;
}
use of de.janrufmonitor.ui.jface.application.ITreeItemCallerData in project janrufmonitor by tbrandt77.
the class NumberType method renderAsText.
public String renderAsText() {
if (this.m_o != null) {
if (this.m_o instanceof ICall) {
this.m_o = ((ICall) this.m_o).getCaller();
}
if (this.m_o instanceof ICaller) {
this.m_o = new TreeItemCallerData(((ICaller) this.m_o).getAttributes(), ((ICaller) this.m_o).getPhoneNumber());
}
if (this.m_o instanceof ITreeItemCallerData) {
IAttributeMap m = ((ITreeItemCallerData) m_o).getAttributes();
IPhonenumber pn = ((ITreeItemCallerData) m_o).getPhone();
if (m.contains(IJAMConst.ATTRIBUTE_NAME_NUMBER_TYPE + pn.getTelephoneNumber())) {
IAttribute type = m.get(IJAMConst.ATTRIBUTE_NAME_NUMBER_TYPE + pn.getTelephoneNumber());
if (type != null) {
return PIMRuntime.getInstance().getI18nManagerFactory().getI18nManager().getString(NAMESPACE, type.getValue(), "label", getLanguage());
}
}
}
}
return "";
}
use of de.janrufmonitor.ui.jface.application.ITreeItemCallerData in project janrufmonitor by tbrandt77.
the class ClickDialAction 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) {
o = ((ICaller) o).getPhoneNumber();
}
if (o instanceof ITreeItemCallerData) {
o = ((ITreeItemCallerData) o).getPhone();
}
if (o instanceof IPhonenumber) {
if (((IPhonenumber) o).isClired())
return;
String dial = ((IPhonenumber) o).getTelephoneNumber();
if (!((IPhonenumber) o).getIntAreaCode().equalsIgnoreCase(this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_INTAREA))) {
dial = "00" + ((IPhonenumber) o).getIntAreaCode() + dial;
}
if (!dial.startsWith("0"))
dial = "0" + dial;
Properties config = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperties(FritzBoxMonitor.NAMESPACE);
String prefixes = getRuntime().getConfigManagerFactory().getConfigManager().getProperty(FritzBoxMonitor.NAMESPACE, "dialprefixes");
if ((prefixes != null && prefixes.length() > 0) || config.getProperty(CFG_CLICKDIAL, "50").equalsIgnoreCase("0")) {
DialerDialog id = new DialerDialog(new Shell(DisplayManager.getDefaultDisplay()), dial);
id.open();
} else {
// added 2010/03/06: check for dial prefix for outgoing calls
if (this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_DIAL_PREFIX).length() > 0) {
if (this.m_logger.isLoggable(Level.INFO))
this.m_logger.info("Using dial prefix: " + this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_DIAL_PREFIX));
dial = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_DIAL_PREFIX).trim() + dial;
}
String text = getI18nManager().getString(getNamespace(), "dial", "description", getLanguage());
text = StringUtils.replaceString(text, "{%1}", dial);
if (MessageDialog.openConfirm(new Shell(DisplayManager.getDefaultDisplay()), this.getI18nManager().getString(this.getNamespace(), "success", "label", this.getLanguage()), text)) {
FirmwareManager fwm = FirmwareManager.getInstance();
try {
if (!fwm.isLoggedIn())
fwm.login();
fwm.doCall(dial + "#", config.getProperty(CFG_CLICKDIAL, "50"));
try {
final String n = dial;
ModalContext.run(new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {
progressMonitor.done();
String text = getI18nManager().getString(getNamespace(), "success", "description", getLanguage());
text = StringUtils.replaceString(text, "{%1}", n);
MessageDialog.openInformation(new Shell(DisplayManager.getDefaultDisplay()), getI18nManager().getString(getNamespace(), "success", "label", getLanguage()), text);
}
}, false, m_app.getApplication().getStatusLineManager().getProgressMonitor(), m_app.getApplication().getShell().getDisplay());
} catch (InterruptedException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
} catch (InvocationTargetException e) {
this.m_logger.log(Level.SEVERE, e.getMessage(), e);
}
} catch (IOException e) {
this.m_logger.warning(e.toString());
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "faileddial", e));
} catch (FritzBoxLoginException e) {
this.m_logger.warning(e.toString());
} catch (DoCallException e) {
this.m_logger.warning(e.toString());
PropagationFactory.getInstance().fire(new Message(Message.ERROR, getNamespace(), "faileddial", e));
}
this.m_app.updateViews(false);
}
}
}
}
}
}
Aggregations