use of com.servoy.j2db.persistence.IRepository in project servoy-client by Servoy.
the class CmdManager method propertyChange.
public void propertyChange(PropertyChangeEvent evt) {
String name = evt.getPropertyName();
if (// $NON-NLS-1$
"repository".equals(name)) {
final IRepository repository = (IRepository) evt.getNewValue();
// $NON-NLS-1$
Action cmdnewsolution = actions.get("cmdnewsolution");
if (cmdnewsolution != null)
cmdnewsolution.setEnabled(repository != null);
if (autoOpenSolutionSelectDialog) {
// $NON-NLS-1$
final Action cmdopensolution = actions.get("cmdopensolution");
if (cmdopensolution != null) {
application.invokeLater(new Runnable() {
public void run() {
cmdopensolution.setEnabled(repository != null);
if (repository != null) {
try {
if (repository.getRootObjectMetaDatasForType(IRepository.SOLUTIONS).length != 0 && application.getSolution() == null && (application.getFlattenedSolution() == null || !application.getFlattenedSolution().isLoadingSolution())) {
executeCmd((ICmd) cmdopensolution, null);
}
} catch (Exception ex) {
Debug.error(ex);
}
}
}
});
}
}
} else if (// $NON-NLS-1$
"solution".equals(name)) {
Solution solution = (Solution) evt.getNewValue();
ableFormRelatedBrowseActions(solution != null);
ableFormRelatedDataEditActions(solution != null);
undoAction.setEnabled(solution != null);
redoAction.setEnabled(solution != null);
// $NON-NLS-1$
Action cmdclose = actions.get("cmdclose");
if (cmdclose != null)
cmdclose.setEnabled(solution != null);
// $NON-NLS-1$
Action cmdsolutionsettings = actions.get("cmdsolutionsettings");
if (cmdsolutionsettings != null)
cmdsolutionsettings.setEnabled(solution != null);
// TODO:could be optimized by using fast method getFormCount
if (solution != null && application.getFlattenedSolution().getForms(false).hasNext()) {
ableFormRelatedActions(true);
} else {
ableFormRelatedActions(false);
}
} else if (// $NON-NLS-1$
"mode".equals(name)) {
int oldmode = ((Integer) evt.getOldValue()).intValue();
// $NON-NLS-1$
Action menuselectaction = actions.get("menuselectaction");
int mode = ((Integer) evt.getNewValue()).intValue();
switch(mode) {
case IModeManager.FIND_MODE:
break;
case IModeManager.PREVIEW_MODE:
break;
case IModeManager.EDIT_MODE:
default:
if (menuselectaction != null)
menuselectaction.setEnabled(true);
}
ableFormRelatedFindActions(mode == IModeManager.FIND_MODE);
// $NON-NLS-1$
Action cmdfindmode = actions.get("cmdfindmode");
if (cmdfindmode != null)
cmdfindmode.setEnabled(mode == IModeManager.EDIT_MODE);
if (mode == IModeManager.FIND_MODE) {
ableFormRelatedBrowseActions(false);
ableFormRelatedDataEditActions(true);
} else {
ableFormRelatedBrowseActions(mode == IModeManager.EDIT_MODE);
}
} else if (// $NON-NLS-1$
"formCreated".equals(name)) {
ableFormRelatedActions(evt.getNewValue() != null);
} else if (// $NON-NLS-1$
"undomanager".equals(name)) {
String sUndoRedo = (String) evt.getOldValue();
Boolean bValue = (Boolean) evt.getNewValue();
Action menuUndoRedo = actions.get(sUndoRedo);
if (menuUndoRedo != null)
menuUndoRedo.setEnabled(bValue.booleanValue());
}
}
use of com.servoy.j2db.persistence.IRepository 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;
}
use of com.servoy.j2db.persistence.IRepository in project servoy-client by Servoy.
the class TemplateGenerator method getStyles.
@SuppressWarnings("unchecked")
public static Pair<String, String>[] getStyles() throws RepositoryException, RemoteException {
List<Pair<String, String>> retval = new ArrayList<Pair<String, String>>();
IRepository repository = ApplicationServerRegistry.get().getLocalRepository();
RootObjectMetaData[] styleMetaDatas = repository.getRootObjectMetaDatasForType(IRepository.STYLES);
if (styleMetaDatas != null) {
for (RootObjectMetaData styleMetaData : styleMetaDatas) {
retval.add(new Pair<String, String>(styleMetaData.getName(), getStyleCSS(styleMetaData.getName())));
}
}
return retval.toArray(new Pair[retval.size()]);
}
use of com.servoy.j2db.persistence.IRepository in project servoy-client by Servoy.
the class TemplateGenerator method getFormHTMLAndCSS.
public static Pair<String, String> getFormHTMLAndCSS(int solution_id, int form_id) throws RepositoryException, RemoteException {
final IRepository repository = ApplicationServerRegistry.get().getLocalRepository();
Solution solution = (Solution) repository.getActiveRootObject(solution_id);
Form form = solution.getForm(form_id);
IServiceProvider sp = null;
if (WebClientSession.get() != null) {
sp = WebClientSession.get().getWebClient();
}
return getFormHTMLAndCSS(solution, form, sp, form.getName());
}
Aggregations