use of de.janrufmonitor.framework.ICallerList in project janrufmonitor by tbrandt77.
the class EditorController method deleteElements.
public synchronized void deleteElements(Object list) {
if (list != null && list instanceof ICallerList) {
Map cms = new HashMap();
ICallerList tmplist = null;
ICaller c = null;
for (int i = 0; i < ((ICallerList) list).size(); i++) {
c = ((ICallerList) list).get(i);
IAttribute att = c.getAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER);
String cname = (att == null ? "all" : att.getValue());
if (cms.containsKey(cname)) {
tmplist = (ICallerList) cms.get(cname);
tmplist.add(c);
} else {
tmplist = this.getRuntime().getCallerFactory().createCallerList(1);
tmplist.add(c);
cms.put(cname, tmplist);
}
}
List managers = this.getActiveCallerManagers();
ICallerManager mgr = null;
for (int i = 0; i < managers.size(); i++) {
mgr = this.getRuntime().getCallerManagerFactory().getCallerManager((String) managers.get(i));
if (mgr != null) {
if (mgr.isSupported(IWriteCallerRepository.class)) {
tmplist = (ICallerList) cms.get("all");
if (tmplist != null) {
this.m_logger.info("removing " + tmplist.size() + " callers to manager: " + mgr.getManagerID());
((IWriteCallerRepository) mgr).removeCaller(tmplist);
}
tmplist = (ICallerList) cms.get(mgr.getManagerID());
if (tmplist != null) {
this.m_logger.info("removing " + tmplist.size() + " callers to manager: " + mgr.getManagerID());
((IWriteCallerRepository) mgr).removeCaller(tmplist);
}
}
}
}
}
}
use of de.janrufmonitor.framework.ICallerList in project janrufmonitor by tbrandt77.
the class DeleteAction 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()) {
Iterator i = selection.iterator();
ICallerList list = getRuntime().getCallerFactory().createCallerList();
Object o = null;
while (i.hasNext()) {
o = i.next();
if (o instanceof ICaller) {
list.add((ICaller) o);
}
}
if (list.size() > 0) {
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()))) {
this.m_app.getController().deleteElements(list);
this.m_app.getApplication().initializeController();
this.m_app.updateViews(true);
}
}
}
}
}
use of de.janrufmonitor.framework.ICallerList 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.ICallerList 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.ICallerList 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);
}
}
}
Aggregations