use of de.janrufmonitor.repository.types.IWriteCallerRepository in project janrufmonitor by tbrandt77.
the class ConsoleImport method execute.
public void execute() throws Exception {
this.isExecuting = true;
if (this.getExecuteParams().length != 1) {
System.out.println("ERROR: Paramters are invalid. Please specify a valid module for installation.");
this.isExecuting = false;
return;
}
String filename = this.getExecuteParams()[0];
IImExporter imp = ImExportFactory.getInstance().getImporter("OldDatFileCallerImporter");
if (imp != null && imp instanceof ICallerImporter) {
((ICallerImporter) imp).setFilename(filename);
ICallerList cl = ((ICallerImporter) imp).doImport();
ICallerManager mgr = this.getRuntime().getCallerManagerFactory().getCallerManager("CallerDirectory");
if (mgr != null && mgr.isActive() && mgr.isSupported(IWriteCallerRepository.class)) {
((IWriteCallerRepository) mgr).setCaller(cl);
System.out.println("INFO: Successfully imported " + cl.size() + " caller entries.");
} else {
System.out.println("ERROR: Caller manager is missing.");
}
} else {
System.out.println("ERROR: import filter for DAT files is missing.");
}
this.isExecuting = false;
}
use of de.janrufmonitor.repository.types.IWriteCallerRepository in project janrufmonitor by tbrandt77.
the class AssignAction method run.
public void run() {
Viewer v = this.m_app.getApplication().getViewer();
if (v != null && v instanceof TableViewer) {
IStructuredSelection selection = (IStructuredSelection) v.getSelection();
if (!selection.isEmpty()) {
final ICall call = (ICall) selection.getFirstElement();
ICaller caller = call.getCaller();
final ICaller newCaller = openCallerWizard(caller);
if (newCaller != null) {
int l_status = SWT.NO;
if (!newCaller.getPhoneNumber().isClired()) {
int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
MessageBox messageBox = new MessageBox(new Shell(DisplayManager.getDefaultDisplay()), style);
messageBox.setMessage(getI18nManager().getString(getNamespace(), "setall", "label", getLanguage()));
l_status = messageBox.open();
}
final int status = l_status;
ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
try {
IRunnableWithProgress r = new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {
progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "assignprogress", "label", getLanguage()), IProgressMonitor.UNKNOWN);
progressMonitor.worked(1);
call.setCaller(newCaller);
if (status == SWT.NO && m_app.getController() instanceof IExtendedApplicationController) {
// added 2009/12/31: only update single entry
progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "assignprogress", "label", getLanguage()));
((IExtendedApplicationController) m_app.getController()).updateElement(call, false);
} else {
progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "assignall", "label", getLanguage()));
m_app.getController().updateElement(call);
}
progressMonitor.done();
}
};
pmd.setBlockOnOpen(false);
pmd.run(true, false, r);
// ModalContext.run(r, true, pmd.getProgressMonitor(),
// DisplayManager.getDefaultDisplay());
} catch (InterruptedException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
} catch (InvocationTargetException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
}
if (!newCaller.getPhoneNumber().isClired()) {
new SWTExecuter() {
protected void execute() {
int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
MessageBox messageBox = new MessageBox(new Shell(DisplayManager.getDefaultDisplay()), style);
messageBox.setMessage(getI18nManager().getString(getNamespace(), "addressbookconfirm", "label", getLanguage()));
if (messageBox.open() == SWT.YES) {
List cpms = getRuntime().getCallerManagerFactory().getTypedCallerManagers(IWriteCallerRepository.class);
ICallerManager cmgr = null;
for (int i = 0; i < cpms.size(); i++) {
cmgr = (ICallerManager) cpms.get(i);
if (cmgr.isActive() && cmgr.isSupported(IWriteCallerRepository.class))
((IWriteCallerRepository) cmgr).updateCaller(newCaller);
}
}
m_app.updateViews(true);
}
}.start();
} else {
m_app.updateViews(true);
}
// this.m_app.updateViews(true);
}
}
}
}
Aggregations