use of com.servoy.j2db.IMessagesCallback in project servoy-client by Servoy.
the class I18NPanel method initI18NMessagesModel.
private void initI18NMessagesModel(String searchKey) {
if (i18NMessagesModel != null) {
String filterColumn = null;
String[] filterValue = null;
if (application instanceof IMessagesCallback) {
filterColumn = ((IMessagesCallback) application).getI18NColumnNameFilter();
filterValue = ((IMessagesCallback) application).getI18NColumnValueFilter();
}
Collection<I18NMessagesModelEntry> messages = i18NMessagesModel.getMessages(searchKey, filterColumn, filterValue, application.getFoundSetManager(), false, null);
Object selLang = "<unknown>";
if (languagesCombo.getSelectedItem() != null)
selLang = ((Object[]) languagesCombo.getSelectedItem())[1];
String[] columns = null;
if (endUser) {
columns = new String[] { Messages.getString("servoy.i18nPanel.key"), Messages.getString("servoy.i18nPanel.default"), Messages.getString("servoy.i18nPanel.locale") + " (" + selLang + ")" };
} else {
columns = new String[] { Messages.getString("servoy.i18nPanel.key"), Messages.getString("servoy.i18nPanel.default"), Messages.getString("servoy.i18nPanel.locale") + " (" + selLang + ")", "" };
}
messageModel = new DefaultTableModel(columns, 0) {
private static final long serialVersionUID = 1L;
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return (columnIndex == 3 && !Messages.invalidConnection && !Messages.noConnection);
}
};
for (I18NMessagesModelEntry entry : messages) {
messageModel.addRow(new Object[] { entry.key, entry.defaultvalue, entry.localeValue, "" });
}
}
}
use of com.servoy.j2db.IMessagesCallback in project servoy-client by Servoy.
the class I18NPanel method createOrUpdateKey.
/**
* @param newKey
* @param string
* @param string2
*/
private boolean createOrUpdateKey(String newKey, String referenceValue, String localeValue) {
boolean operationPerformed = false;
if (// $NON-NLS-1$
Messages.invalidConnection || Messages.noConnection || referenceValue == null || "".equals(referenceValue))
// false
return operationPerformed;
String i18nDataSource = DataSourceUtils.getI18NDataSource(application.getSolution(), application.getSettings());
if (i18nDataSource == null) {
// $NON-NLS-1$
throw new IllegalStateException("Can't create key when there is no (valid) servername/tablename for messages");
}
String serverName = DataSourceUtils.getDataSourceServerName(i18nDataSource);
String tableName = DataSourceUtils.getDataSourceTableName(i18nDataSource);
String filterName = null;
String[] filterValue = null;
if (application instanceof IMessagesCallback) {
filterName = ((IMessagesCallback) application).getI18NColumnNameFilter();
filterValue = ((IMessagesCallback) application).getI18NColumnValueFilter();
}
if (Messages.customMessageLoader != null) {
try {
TreeMap<String, MessageEntry> messages = Messages.customMessageLoader.readMessages(serverName, tableName);
adjustMessagesMap(newKey, referenceValue, localeValue, messages);
Messages.customMessageLoader.save(serverName, tableName, messages);
operationPerformed = true;
} catch (Exception e) {
Debug.error("exception when inserting/updating i18n key: " + newKey);
Debug.error(e);
// throw new RuntimeException(e);
}
} else {
IDataServer dataServer = application.getDataServer();
IRepository repository = application.getRepository();
try {
TreeMap<String, MessageEntry> repositoryMessages = I18NUtil.loadSortedMessagesFromRepository(repository, dataServer, application.getClientID(), serverName, tableName, filterName, filterValue, application.getFoundSetManager());
TreeMap<String, MessageEntry> messages = new TreeMap<String, I18NUtil.MessageEntry>(repositoryMessages);
adjustMessagesMap(newKey, referenceValue, localeValue, messages);
I18NUtil.writeMessagesToRepository(serverName, tableName, repository, dataServer, application.getClientID(), messages, false, false, repositoryMessages, filterName, filterValue, application.getFoundSetManager());
operationPerformed = true;
} catch (Exception e) {
Debug.error("exception when inserting new i18n key: " + newKey);
Debug.error(e);
// throw new RuntimeException(e);
}
}
return operationPerformed;
}
Aggregations