use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.
the class QuickImagePathAction method run.
public void run() {
Viewer v = this.m_app.getApplication().getViewer();
if (v != null && v instanceof Viewer) {
final IStructuredSelection selection = (IStructuredSelection) v.getSelection();
if (!selection.isEmpty()) {
Iterator i = selection.iterator();
ICallerList list = this.getRuntime().getCallerFactory().createCallerList(selection.size());
Object o = null;
while (i.hasNext()) {
o = i.next();
if (o instanceof ICaller) {
ICaller caller = ((ICaller) o);
if (this.hasCallerImage(caller)) {
File image = getCallerImageFile(caller);
if (image != null) {
if (!isCentralImageStore(caller)) {
String name = image.getName();
File image_in_store = new File(getCentralImageStorePath(), name);
if (!image_in_store.exists()) {
try {
FileInputStream fin = new FileInputStream(image);
FileOutputStream fout = new FileOutputStream(image_in_store);
if (m_logger.isLoggable(Level.INFO))
m_logger.info("Copiing " + image.getAbsolutePath() + " to " + image_in_store.getAbsolutePath());
Stream.copy(fin, fout, true);
setAttribute(caller, IJAMConst.ATTRIBUTE_NAME_IMAGEPATH, PathResolver.getInstance(getRuntime()).encode(image_in_store.getAbsolutePath()));
list.add(caller);
} catch (IOException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
}
} else {
m_logger.warning("Image file " + image_in_store.getAbsolutePath() + " already exists in central image store. File gets overwritten.");
try {
FileInputStream fin = new FileInputStream(image);
FileOutputStream fout = new FileOutputStream(image_in_store);
if (m_logger.isLoggable(Level.INFO))
m_logger.info("Copiing " + image.getAbsolutePath() + " to " + image_in_store.getAbsolutePath());
Stream.copy(fin, fout, true);
setAttribute(caller, IJAMConst.ATTRIBUTE_NAME_IMAGEPATH, PathResolver.getInstance(getRuntime()).encode(image_in_store.getAbsolutePath()));
list.add(caller);
} catch (IOException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
}
}
} else {
if (m_logger.isLoggable(Level.INFO))
m_logger.info("Image file " + image.getAbsolutePath() + " is already in central image store.");
}
} else {
m_logger.warning("Image file could not be copied to central image store. Image is not set.");
}
}
}
}
if (list.size() > 0) {
this.m_app.getController().updateElement(list);
}
m_app.updateViews(true);
}
}
}
use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.
the class CallerColoringAction method run.
public void run() {
Viewer v = this.m_app.getApplication().getViewer();
if (v != null && v instanceof TreeViewer) {
Tree t = ((TreeViewer) v).getTree();
ICallerList cl = ((EditorController) this.m_app.getController()).getCallerList();
ICaller c = null;
for (int i = 0, n = cl.size(); i < n; i++) {
c = cl.get(i);
Color color = this.getColor(c, t);
if (color != null) {
t.getItem(i).setForeground(color);
}
if (i % 2 == 0) {
t.getItem(i).setBackground(getIterationColor(t));
}
}
}
}
use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.
the class LastCalled method renderAsText.
public String renderAsText() {
if (this.m_o != null) {
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) {
IPhonenumber pn = ((ITreeItemCallerData) m_o).getPhone();
List cms = PIMRuntime.getInstance().getCallManagerFactory().getTypedCallManagers(IReadCallRepository.class);
if (cms.size() > 0) {
ICallManager cm = null;
for (int i = 0, j = cms.size(); i < j; i++) {
cm = (ICallManager) cms.get(i);
if (cm.isActive() && cm.isSupported(IReadCallRepository.class)) {
IFilter[] filters = new IFilter[] { new PhonenumberFilter(pn), new ItemCountFilter(1) };
ICallList cl = ((IReadCallRepository) cm).getCalls(filters, 1, 0);
cl.sort(0, false);
if (cl.size() > 0) {
ICall c = cl.get(0);
return getFormatter().parse(IJAMConst.GLOBAL_VARIABLE_CALLTIME, c.getDate());
}
}
}
}
}
}
return "";
}
use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.
the class GeoCodingAction method run.
public void run() {
Viewer v = this.m_app.getApplication().getViewer();
if (v != null && v instanceof Viewer) {
final IStructuredSelection selection = (IStructuredSelection) v.getSelection();
if (!selection.isEmpty()) {
Iterator i = selection.iterator();
ICallerList list = this.getRuntime().getCallerFactory().createCallerList(selection.size());
Object o = null;
while (i.hasNext()) {
o = i.next();
if (o instanceof ICaller) {
Point p = GeoCoder.getInstance().getCoordinates(((ICaller) o).getAttributes());
if (p != null) {
((ICaller) o).setAttribute(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_GEO_ACC, Integer.toString(p.getAccurance())));
((ICaller) o).setAttribute(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_GEO_LNG, Double.toString(p.getLongitude())));
((ICaller) o).setAttribute(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_GEO_LAT, Double.toString(p.getLatitude())));
list.add((ICaller) o);
}
}
}
if (list.size() > 0) {
this.m_app.getController().updateElement(list);
}
m_app.updateViews(true);
}
}
}
use of de.janrufmonitor.framework.ICaller in project janrufmonitor by tbrandt77.
the class NewAction method run.
public void run() {
Viewer v = this.m_app.getApplication().getViewer();
if (v != null && v instanceof TreeViewer) {
ICaller newCaller = openCallerWizard(null);
if (newCaller != null) {
ICallerList l = this.getRuntime().getCallerFactory().createCallerList(1);
l.add(newCaller);
this.m_app.getController().addElements(l);
this.m_app.updateViews(true);
}
}
}
Aggregations