Search in sources :

Example 6 with IRepository

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());
    }
}
Also used : Action(javax.swing.Action) ICmd(com.servoy.j2db.cmd.ICmd) IRepository(com.servoy.j2db.persistence.IRepository) Solution(com.servoy.j2db.persistence.Solution)

Example 7 with IRepository

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;
}
Also used : IDataServer(com.servoy.j2db.dataprocessing.IDataServer) MessageEntry(com.servoy.j2db.persistence.I18NUtil.MessageEntry) IMessagesCallback(com.servoy.j2db.IMessagesCallback) I18NUtil(com.servoy.j2db.persistence.I18NUtil) IRepository(com.servoy.j2db.persistence.IRepository) TreeMap(java.util.TreeMap)

Example 8 with IRepository

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()]);
}
Also used : RootObjectMetaData(com.servoy.j2db.persistence.RootObjectMetaData) ArrayList(java.util.ArrayList) IRepository(com.servoy.j2db.persistence.IRepository) Pair(com.servoy.j2db.util.Pair)

Example 9 with IRepository

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());
}
Also used : IServiceProvider(com.servoy.j2db.IServiceProvider) IForm(com.servoy.j2db.IForm) Form(com.servoy.j2db.persistence.Form) WebForm(com.servoy.j2db.server.headlessclient.WebForm) IRepository(com.servoy.j2db.persistence.IRepository) FlattenedSolution(com.servoy.j2db.FlattenedSolution) Solution(com.servoy.j2db.persistence.Solution)

Aggregations

IRepository (com.servoy.j2db.persistence.IRepository)9 FlattenedSolution (com.servoy.j2db.FlattenedSolution)5 AbstractActiveSolutionHandler (com.servoy.j2db.AbstractActiveSolutionHandler)4 Solution (com.servoy.j2db.persistence.Solution)3 IApplicationServer (com.servoy.j2db.server.shared.IApplicationServer)3 IForm (com.servoy.j2db.IForm)2 Form (com.servoy.j2db.persistence.Form)2 SolutionMetaData (com.servoy.j2db.persistence.SolutionMetaData)2 WebForm (com.servoy.j2db.server.headlessclient.WebForm)2 Pair (com.servoy.j2db.util.Pair)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 TreeMap (java.util.TreeMap)2 FormController (com.servoy.j2db.FormController)1 IApplication (com.servoy.j2db.IApplication)1 IFormUIInternal (com.servoy.j2db.IFormUIInternal)1 IMessagesCallback (com.servoy.j2db.IMessagesCallback)1 IServiceProvider (com.servoy.j2db.IServiceProvider)1 IWebClientApplication (com.servoy.j2db.IWebClientApplication)1 ICmd (com.servoy.j2db.cmd.ICmd)1