use of de.janrufmonitor.repository.ICallerManager in project janrufmonitor by tbrandt77.
the class GoogleContactsCallerManager method createFieldEditors.
protected void createFieldEditors() {
super.createFieldEditors();
BooleanFieldEditor bfe = new BooleanFieldEditor(getConfigNamespace() + SEPARATOR + "keepextension", this.m_i18n.getString(this.getNamespace(), "keepextension", "label", this.m_language), this.getFieldEditorParent());
addField(bfe);
final StringFieldEditor u = new StringFieldEditor(getConfigNamespace() + SEPARATOR + "user", this.m_i18n.getString(this.getNamespace(), "user", "label", this.m_language), this.getFieldEditorParent());
u.setEmptyStringAllowed(false);
addField(u);
final StringFieldEditor p = new StringFieldEditor(getConfigNamespace() + SEPARATOR + "password", this.m_i18n.getString(this.getNamespace(), "password", "label", this.m_language), this.getFieldEditorParent());
p.getTextControl(this.getFieldEditorParent()).setEchoChar('*');
addField(p);
final FieldEditor ffe = new FieldEditor("check-button", "", this.getFieldEditorParent()) {
public Button up;
protected void adjustForNumColumns(int arg0) {
}
protected void doFillIntoGrid(Composite c, int numCols) {
GridData gd = new GridData();
gd.horizontalAlignment = GridData.FILL;
gd.grabExcessHorizontalSpace = true;
gd.horizontalSpan = numCols - 1;
gd.widthHint = 200;
final II18nManager i18 = PIMRuntime.getInstance().getI18nManagerFactory().getI18nManager();
final String l = PIMRuntime.getInstance().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_LANGUAGE);
String text = i18.getString("ui.jface.configuration.pages.GoogleContactsCallerManager", "check", "label", l);
up = new Button(c, SWT.PUSH);
// new Label(c, SWT.NONE);
up.setText(text);
up.pack();
up.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ICallerManager cm = getRuntime().getCallerManagerFactory().getCallerManager(de.janrufmonitor.repository.GoogleContactsCallerManager.ID);
if (cm != null && cm instanceof de.janrufmonitor.repository.GoogleContactsCallerManager) {
try {
((de.janrufmonitor.repository.GoogleContactsCallerManager) cm).checkAuthentication(user, password);
MessageDialog.openInformation(new Shell(DisplayManager.getDefaultDisplay()), i18.getString("ui.jface.configuration.pages.GoogleContactsCallerManager", "success", "label", l), i18.getString("ui.jface.configuration.pages.GoogleContactsCallerManager", "success", "description", l));
return;
} catch (GoogleContactsLoginException ex) {
}
}
MessageDialog.openError(new Shell(DisplayManager.getDefaultDisplay()), i18.getString("ui.jface.configuration.pages.GoogleContactsCallerManager", "error", "label", l), i18.getString("ui.jface.configuration.pages.GoogleContactsCallerManager", "error", "description", l));
}
});
}
protected void doLoad() {
}
protected void doLoadDefault() {
}
protected void doStore() {
}
public int getNumberOfControls() {
return 1;
}
public void setEnabled(boolean enabled, Composite parent) {
super.setEnabled(enabled, parent);
if (up != null)
up.setEnabled(enabled);
}
};
ffe.setEnabled(false, getFieldEditorParent());
addField(ffe);
p.getTextControl(this.getFieldEditorParent()).addKeyListener(new KeyAdapter() {
public void keyReleased(org.eclipse.swt.events.KeyEvent e) {
password = p.getStringValue();
user = u.getStringValue();
ffe.setEnabled((user != null && password != null && user.length() > 0 && password.length() > 0), getFieldEditorParent());
}
});
u.getTextControl(this.getFieldEditorParent()).addKeyListener(new KeyAdapter() {
public void keyReleased(org.eclipse.swt.events.KeyEvent e) {
user = u.getStringValue();
password = p.getStringValue();
ffe.setEnabled((user != null && password != null && user.length() > 0 && password.length() > 0), getFieldEditorParent());
}
});
ComboFieldEditor cfe = new ComboFieldEditor(getConfigNamespace() + SEPARATOR + "mode", this.m_i18n.getString(this.getNamespace(), "mode", "label", this.m_language), new String[][] { { this.m_i18n.getString(this.getNamespace(), "mode1", "label", this.m_language), "1" }, { this.m_i18n.getString(this.getNamespace(), "mode2", "label", this.m_language), "2" } }, this.getFieldEditorParent());
addField(cfe);
bfe = new BooleanFieldEditor(getConfigNamespace() + SEPARATOR + "syncstart", this.m_i18n.getString(this.getNamespace(), "syncstart", "label", this.m_language), this.getFieldEditorParent());
addField(bfe);
}
use of de.janrufmonitor.repository.ICallerManager in project janrufmonitor by tbrandt77.
the class IsdnMoniCallImporter method doImport.
public ICallList doImport() {
this.m_callerList = null;
boolean doNotShowmessage = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty(this.getNamespace(), CFG_SHOW_ENTRY_WARNING).equalsIgnoreCase("true");
if (!doNotShowmessage) {
new SWTExecuter() {
protected void execute() {
String message = getI18nManager().getString(getNamespace(), "message", "description", getLanguage());
MessageDialogWithToggle d = MessageDialogWithToggle.openYesNoQuestion(new Shell(DisplayManager.getDefaultDisplay()), getI18nManager().getString(getNamespace(), "message", "label", getLanguage()), message, getI18nManager().getString(getNamespace(), "confirmmessage", "label", getLanguage()), false, null, null);
if (d.getReturnCode() == 2) {
m_callerList = getRuntime().getCallerFactory().createCallerList();
}
getRuntime().getConfigManagerFactory().getConfigManager().setProperty(getNamespace(), CFG_SHOW_ENTRY_WARNING, (d.getToggleState() ? "true" : "false"));
getRuntime().getConfigManagerFactory().getConfigManager().saveConfiguration();
isDialogFinished = true;
}
}.start();
} else {
isDialogFinished = true;
}
while (!isDialogFinished) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
}
}
Date startDate = new Date();
File db = new File(m_filename);
int size = (int) db.length() / 64;
size = Math.abs(size);
ThreadGroup g = new ThreadGroup("JAM- HeuerMigrator-ThreadGroup");
m_callList = getRuntime().getCallFactory().createCallList(size);
m_pnList = new ArrayList(size);
try {
FileReader dbReader = new FileReader(db);
BufferedReader bufReader = new BufferedReader(dbReader);
int i = 0;
while (bufReader.ready()) {
String line = bufReader.readLine();
if (line.indexOf("->") > 0) {
try {
Thread t = new Thread(g, new MigratorThread(this.m_callList, (this.m_callerList != null ? this.m_callerList : null), line, this.m_pnList));
t.setName("JAM-HeuerMigrator#" + (i++) + "-Thread-(non-deamon)");
t.start();
if (g.activeCount() > 100) {
Thread.sleep(1000);
}
} catch (Exception ex) {
this.m_logger.severe("Unexpected error during migration: " + ex);
}
}
}
bufReader.close();
dbReader.close();
} catch (FileNotFoundException ex) {
this.m_logger.warning("Cannot find call backup file " + m_filename);
return this.m_callList;
} catch (IOException ex) {
this.m_logger.severe("IOException on file " + m_filename);
return this.m_callList;
}
while (g.activeCount() > 0) {
try {
Thread.sleep(1000);
this.m_logger.info("Waiting for " + g.activeCount() + " Migrator threads.");
} catch (InterruptedException e) {
this.m_logger.severe(e.getMessage());
}
}
if (this.m_callerList != null) {
this.m_logger.info("Commiting detected callers to default caller manager.");
String cm = getRuntime().getConfigManagerFactory().getConfigManager().getProperty("ui.jface.application.editor.Editor", "repository");
ICallerManager cmg = this.getRuntime().getCallerManagerFactory().getCallerManager(cm);
if (cmg != null && cmg.isActive() && cmg.isSupported(IWriteCallerRepository.class)) {
((IWriteCallerRepository) cmg).setCaller(this.m_callerList);
}
}
Date endDate = new Date();
this.m_logger.info("Successfully imported call file " + m_filename);
this.m_logger.info("Found " + new Integer(this.m_callList.size()).toString() + " call items in " + new Float((endDate.getTime() - startDate.getTime()) / 1000).toString() + " secs.");
return m_callList;
}
use of de.janrufmonitor.repository.ICallerManager in project janrufmonitor by tbrandt77.
the class EditorController method _getRepository.
private ICallerManager _getRepository() {
String managerID = this.m_configuration.getProperty(CFG_REPOSITORY, "");
if (managerID.length() > 0) {
ICallerManager cm = this.getRuntime().getCallerManagerFactory().getCallerManager(managerID);
if (cm != null)
return cm;
}
this.m_logger.severe("CallerManager with ID " + managerID + " does not exist.");
return null;
}
use of de.janrufmonitor.repository.ICallerManager 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.repository.ICallerManager in project janrufmonitor by tbrandt77.
the class IdentifyAction method getAllActiveCallerManagers.
private List getAllActiveCallerManagers(IRuntime r, String ignoreManager) {
List allManagers = r.getCallerManagerFactory().getAllCallerManagers();
List activeManager = new ArrayList();
Object o = null;
ICallerManager cm = null;
for (int i = 0; i < allManagers.size(); i++) {
o = allManagers.get(i);
if (o != null && o instanceof ICallerManager) {
cm = (ICallerManager) o;
if (cm.isActive() && !cm.getManagerID().equalsIgnoreCase(ignoreManager) && !cm.getManagerID().equalsIgnoreCase("CountryDirectory")) {
activeManager.add(cm);
}
}
}
Collections.sort(activeManager, new RepositoryManagerComparator());
return activeManager;
}
Aggregations