use of de.janrufmonitor.framework.i18n.II18nManager 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.framework.i18n.II18nManager in project janrufmonitor by tbrandt77.
the class JournalBuilder method translate.
private static String translate(String text) {
II18nManager i18n = PIMRuntime.getInstance().getI18nManagerFactory().getI18nManager();
String prefix = "<!-- start_translate:";
String postfix = ":end_translate-->";
while (text.indexOf(prefix) >= 0) {
String token = text.substring(text.indexOf(prefix) + prefix.length(), text.indexOf(postfix));
String[] elements = token.split(",");
if (elements.length == 4) {
String translation = i18n.getString(elements[0], elements[1], elements[2], elements[3]);
text = StringUtils.replaceString(text, prefix + token + postfix, translation);
}
if (elements.length == 3) {
String translation = i18n.getString(elements[0], elements[1], "label", elements[2]);
text = StringUtils.replaceString(text, prefix + token + postfix, translation);
}
if (elements.length == 2) {
String translation = i18n.getString(IJAMConst.GLOBAL_NAMESPACE, elements[0], "label", elements[1]);
text = StringUtils.replaceString(text, prefix + token + postfix, translation);
}
}
return text;
}
use of de.janrufmonitor.framework.i18n.II18nManager in project janrufmonitor by tbrandt77.
the class I18nHandler method removeI18nData.
public void removeI18nData(Properties i18nData) {
try {
II18nManager i18n = PIMRuntime.getInstance().getI18nManagerFactory().getI18nManager();
Iterator iter = i18nData.keySet().iterator();
String key = null;
while (iter.hasNext()) {
key = (String) iter.next();
StringTokenizer st = new StringTokenizer(key, this.NAMESPACE_SEPARATOR);
String namespace = st.nextToken();
i18n.removeNamespace(namespace);
}
i18n.saveData();
} catch (NullPointerException ex) {
this.m_logger.severe("I18n entry is invalid: " + ex.getMessage());
} catch (NoSuchElementException ex) {
this.m_logger.severe("I18n entry is invalid: " + ex.getMessage());
}
}
use of de.janrufmonitor.framework.i18n.II18nManager in project janrufmonitor by tbrandt77.
the class I18nHandler method addI18nData.
public void addI18nData(Properties i18nData) {
try {
II18nManager i18n = PIMRuntime.getInstance().getI18nManagerFactory().getI18nManager();
Iterator iter = i18nData.keySet().iterator();
String key = null;
while (iter.hasNext()) {
key = (String) iter.next();
StringTokenizer st = new StringTokenizer(key, this.NAMESPACE_SEPARATOR);
String namespace = st.nextToken();
String parameter = st.nextToken();
String identifier = st.nextToken();
String language = st.nextToken();
String value = i18nData.getProperty(key);
i18n.setString(namespace, parameter, identifier, language, value);
}
i18n.saveData();
} catch (NullPointerException ex) {
this.m_logger.severe("I18n entry is invalid: " + ex.getMessage());
} catch (NoSuchElementException ex) {
this.m_logger.severe("I18n entry is invalid: " + ex.getMessage());
}
}
use of de.janrufmonitor.framework.i18n.II18nManager in project janrufmonitor by tbrandt77.
the class AutoUpdate method createFieldEditors.
protected void createFieldEditors() {
this.noDefaultAndApplyButton();
super.createFieldEditors();
FieldEditor bfe = new FieldEditor("check-button", "c", this.getFieldEditorParent()) {
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;
new Label(c, SWT.NONE);
II18nManager i18 = PIMRuntime.getInstance().getI18nManagerFactory().getI18nManager();
String l = PIMRuntime.getInstance().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_LANGUAGE);
String text = i18.getString("ui.jface.configuration.pages.AutoUpdate", "execute", "label", l);
Button up = new Button(c, SWT.PUSH);
up.setText(text);
up.pack();
up.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
ICommand c = getRuntime().getCommandFactory().getCommand("UpdatesCommand");
if (c != null && c.isExecutable()) {
try {
c.execute();
} catch (Exception ex) {
m_logger.log(Level.SEVERE, ex.getMessage(), ex);
}
}
}
});
}
protected void doLoad() {
}
protected void doLoadDefault() {
}
protected void doStore() {
}
public int getNumberOfControls() {
return 1;
}
};
addField(bfe);
}
Aggregations