Package org.zanata.webtrans.client.presenter

Examples of org.zanata.webtrans.client.presenter.UserConfigHolder


    private AccountDAO accountDAO;

    @Override
    public LoadOptionsResult execute(LoadOptionsAction action,
            ExecutionContext context) throws ActionException {
        UserConfigHolder configHolder = new UserConfigHolder();
        HAccount account =
                accountDAO.findById(authenticatedAccount.getId(), true);
        Map<String, HAccountOption> options = account.getEditorOptions();
        HashMap<String, HAccountOption> filteredOptions =
                new HashMap<String, HAccountOption>();

        for (Entry<String, HAccountOption> entry : options.entrySet()) {
            // filter config according to prefix
            if (action.getPrefixes() != null && !action.getPrefixes().isEmpty()) {
                for (String prefix : action.getPrefixes()) {
                    if (entry.getKey().startsWith(prefix)) {
                        filteredOptions.put(entry.getKey(), entry.getValue());
                    }
                }
            } else {
                filteredOptions.put(entry.getKey(), entry.getValue());
            }
        }

        if (filteredOptions.containsKey(UserOptions.DisplayButtons
                .getPersistentName())) {
            configHolder.setDisplayButtons(filteredOptions.get(
                    UserOptions.DisplayButtons.getPersistentName())
                    .getValueAsBoolean());
        }

        if (filteredOptions.containsKey(UserOptions.EnterSavesApproved
                .getPersistentName())) {
            configHolder.setEnterSavesApproved(filteredOptions.get(
                    UserOptions.EnterSavesApproved.getPersistentName())
                    .getValueAsBoolean());
        }

        if (filteredOptions.containsKey(UserOptions.Navigation
                .getPersistentName())) {
            configHolder.setNavOption(NavOption.valueOf(filteredOptions.get(
                    UserOptions.Navigation.getPersistentName()).getValue()));
        }

        if (filteredOptions.containsKey(UserOptions.EditorPageSize
                .getPersistentName())) {
            configHolder.setEditorPageSize(filteredOptions.get(
                    UserOptions.EditorPageSize.getPersistentName())
                    .getValueAsInt());
        }

        if (filteredOptions.containsKey(UserOptions.ShowErrors
                .getPersistentName())) {
            configHolder.setShowError(filteredOptions.get(
                    UserOptions.ShowErrors.getPersistentName())
                    .getValueAsBoolean());
        }

        if (filteredOptions.containsKey(UserOptions.Themes.getPersistentName())) {
            configHolder.setDisplayTheme(ThemesOption.valueOf(filteredOptions
                    .get(UserOptions.Themes.getPersistentName()).getValue()));
        }

        if (filteredOptions.containsKey(UserOptions.UseCodeMirrorEditor
                .getPersistentName())) {
            configHolder.setUseCodeMirrorEditor(filteredOptions.get(
                    UserOptions.UseCodeMirrorEditor.getPersistentName())
                    .getValueAsBoolean());
        }

        if (filteredOptions.containsKey(UserOptions.TransMemoryDisplayMode
                .getPersistentName())) {
            configHolder.setTMDisplayMode(DiffMode.valueOf(filteredOptions.get(
                    UserOptions.TransMemoryDisplayMode.getPersistentName())
                    .getValue()));
        }

        if (filteredOptions.containsKey(UserOptions.DisplayTransMemory
                .getPersistentName())) {
            configHolder.setShowTMPanel(filteredOptions.get(
                    UserOptions.DisplayTransMemory.getPersistentName())
                    .getValueAsBoolean());
        }

        if (filteredOptions.containsKey(UserOptions.DisplayGlossary
                .getPersistentName())) {
            configHolder.setShowGlossaryPanel(filteredOptions.get(
                    UserOptions.DisplayGlossary.getPersistentName())
                    .getValueAsBoolean());
        }

        if (filteredOptions.containsKey(UserOptions.SelectedReferenceLang
                .getPersistentName())) {
            configHolder.setSelectedReferenceForSourceLang(filteredOptions.get(
                    UserOptions.SelectedReferenceLang.getPersistentName())
                    .getValue());
        }

        if (filteredOptions
                .containsKey(UserOptions.ShowOptionalTransUnitDetails
                        .getPersistentName())) {
            configHolder.setShowOptionalTransUnitDetails(filteredOptions.get(
                    UserOptions.ShowOptionalTransUnitDetails
                            .getPersistentName()).getValueAsBoolean());
        }

        if (filteredOptions.containsKey(UserOptions.TranslatedMessageFilter
                .getPersistentName())) {
            configHolder.setFilterByTranslated(filteredOptions.get(
                    UserOptions.TranslatedMessageFilter.getPersistentName())
                    .getValueAsBoolean());
        }

        if (filteredOptions.containsKey(UserOptions.FuzzyMessageFilter
                .getPersistentName())) {
            configHolder.setFilterByFuzzy(filteredOptions.get(
                    UserOptions.FuzzyMessageFilter.getPersistentName())
                    .getValueAsBoolean());
        }

        if (filteredOptions.containsKey(UserOptions.UntranslatedMessageFilter
                .getPersistentName())) {
            configHolder.setFilterByUntranslated(filteredOptions.get(
                    UserOptions.UntranslatedMessageFilter.getPersistentName())
                    .getValueAsBoolean());
        }

        if (filteredOptions.containsKey(UserOptions.DocumentListPageSize
                .getPersistentName())) {
            configHolder.setDocumentListPageSize(filteredOptions.get(
                    UserOptions.DocumentListPageSize.getPersistentName())
                    .getValueAsInt());
        }

        if (filteredOptions.containsKey(UserOptions.ShowSaveApprovedWarning
                .getPersistentName())) {
            configHolder.setShowSaveApprovedWarning(filteredOptions.get(
                    UserOptions.ShowSaveApprovedWarning.getPersistentName())
                    .getValueAsBoolean());
        }

        return new LoadOptionsResult(configHolder.getState());
    }
View Full Code Here


        return configMap;
    }

    @Test
    public void testExecuteWithOptionsInDatabase() throws Exception {
        UserConfigHolder configHolder = new UserConfigHolder();
        configHolder.setShowError(true); // we change one default value
        SaveOptionsAction action =
                new SaveOptionsAction(generateConfigMap(configHolder));
        saveHandler.execute(action, null); // save some options first

        LoadOptionsResult result =
View Full Code Here

        for (ValidationAction action : validationMap.values()) {
            validationStates.put(action.getId(), action.getState());
        }

        callback.onSuccess(new ActivateWorkspaceResult(userWorkspaceContext,
                identity, new UserConfigHolder().getState(), validationStates));
        Log.info("EXIT DummyActivateWorkspaceCommand.execute()");
    }
View Full Code Here

    @BeforeMethod
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);
        contextHolder =
                new GetTransUnitActionContextHolder(new UserConfigHolder());
        configHolder = new UserConfigHolder();
        service =
                new HistoryEventHandlerService(eventBus, documentListPresenter,
                        appPresenter, searchResultsPresenter, contextHolder,
                        stateHolder, configHolder);
    }
View Full Code Here

    @BeforeMethod
    public void setUp() throws Exception {
        MockitoAnnotations.initMocks(this);

        pageModel = new SinglePageDataModelImpl();
        configHolder = new UserConfigHolder();
        navigationStateHolder = new ModalNavigationStateHolder(configHolder);
        GetTransUnitActionContextHolder contextHolder =
                new GetTransUnitActionContextHolder(configHolder);
        contextHolder.initContext(DOCUMENT, null, EditorFilter.ALL);
View Full Code Here

        for (TransUnit tu : tuList) {
            transIdStateMap.put(tu.getId(), tu.getStatus());
            idIndexList.add(tu.getId());
        }
        configHolder = new UserConfigHolder();
        navigationStateHolder = new ModalNavigationStateHolder(configHolder);
        navigationStateHolder.init(transIdStateMap, idIndexList);
    }
View Full Code Here

    @BeforeMethod
    public void beforeMethod() {
        MockitoAnnotations.initMocks(this);
        initData();
        UserConfigHolder configHolder = new UserConfigHolder();
        configHolder.setEditorPageSize(EDITOR_PAGE_SIZE);
        SinglePageDataModelImpl pageModel = new SinglePageDataModelImpl();
        ModalNavigationStateHolder navigationStateHolder =
                new ModalNavigationStateHolder(configHolder);
        contextHolder = new GetTransUnitActionContextHolder(configHolder);
        contextHolder.initContext(TestFixture.documentInfo(1, "a.pot"), null,
                null);
        service =
                new NavigationService(eventBus, dispatcher, configHolder,
                        mock(TableEditorMessages.class), pageModel,
                        navigationStateHolder, contextHolder, history);
        service.addPageDataChangeListener(pageDataChangeListener);

        verify(eventBus).addHandler(DocumentSelectionEvent.getType(), service);
        verify(eventBus).addHandler(NavTransUnitEvent.getType(), service);
        verify(eventBus).addHandler(EditorPageSizeChangeEvent.TYPE, service);

        pageModel.setData(data.subList(0, configHolder.getState()
                .getEditorPageSize()));
        navigationStateHolder.init(idStateMap, idIndexList);
        initContext =
                new GetTransUnitActionContext(TestFixture.documentInfo(1, ""))
                        .withCount(configHolder.getState()
                                .getEditorPageSize());
    }
View Full Code Here

                hProjectIteration);
        when(identity.hasPermission("modify-translation", hProject, hLocale))
                .thenReturn(true);
        when(identity.hasPermission("glossary-update", "")).thenReturn(true);
        LoadOptionsResult optionsResult =
                new LoadOptionsResult(new UserConfigHolder().getState());
        when(
                loadOptionsHandler.execute(isA(LoadOptionsAction.class),
                        any(ExecutionContext.class))).thenReturn(optionsResult);

        when(translationWorkspace.getWorkspaceContext()).thenReturn(
View Full Code Here

TOP

Related Classes of org.zanata.webtrans.client.presenter.UserConfigHolder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.