Search in sources :

Example 1 with FormStore

use of org.activityinfo.ui.client.store.FormStore in project activityinfo by bedatadriven.

the class FormInputViewModelTest method hiddenSubForm.

/**
 * Test the ViewModel for when the user does not have access to a referenced sub form.
 */
@Test
public void hiddenSubForm() {
    FormClass parentForm = new FormClass(ResourceId.valueOf("PARENT_FORM"));
    parentForm.addField(ResourceId.valueOf("F1")).setLabel("What is your name?").setType(TextType.SIMPLE);
    parentForm.addField(ResourceId.valueOf("F2")).setLabel("What are your secrets?").setType(new SubFormReferenceType(ResourceId.valueOf("SECRET_FORM")));
    FormTreeBuilder treeBuilder = new FormTreeBuilder(new FormMetadataProvider() {

        @Override
        public FormMetadata getFormMetadata(ResourceId formId) {
            if (formId.equals(parentForm.getId())) {
                return FormMetadata.of(1, parentForm, FormPermissions.owner());
            } else {
                return FormMetadata.forbidden(formId);
            }
        }
    });
    FormTree formTree = treeBuilder.queryTree(parentForm.getId());
    FormStore formStore = EasyMock.createMock(FormStore.class);
    EasyMock.replay(formStore);
    FormInputViewModelBuilder viewModelBuilder = new FormInputViewModelBuilder(formStore, formTree, new TestingActivePeriodMemory());
    FormInputViewModel viewModel = viewModelBuilder.build(new FormInputModel(new RecordRef(parentForm.getId(), ResourceId.valueOf("R1"))));
}
Also used : FormMetadataProvider(org.activityinfo.model.formTree.FormMetadataProvider) RecordRef(org.activityinfo.model.type.RecordRef) FormInputModel(org.activityinfo.ui.client.input.model.FormInputModel) FormTreeBuilder(org.activityinfo.model.formTree.FormTreeBuilder) FormMetadata(org.activityinfo.model.form.FormMetadata) SubFormReferenceType(org.activityinfo.model.type.subform.SubFormReferenceType) FormTree(org.activityinfo.model.formTree.FormTree) ResourceId(org.activityinfo.model.resource.ResourceId) FormClass(org.activityinfo.model.form.FormClass) TestingFormStore(org.activityinfo.ui.client.store.TestingFormStore) FormStore(org.activityinfo.ui.client.store.FormStore) Test(org.junit.Test)

Example 2 with FormStore

use of org.activityinfo.ui.client.store.FormStore in project activityinfo by bedatadriven.

the class AppEntryPoint method onModuleLoad.

@Override
public void onModuleLoad() {
    LOGGER.info("user.agent = " + System.getProperty("user.agent"));
    LOGGER.info("gxt.user.agent = " + System.getProperty("gxt.user.agent"));
    LOGGER.info("gxt.device = " + System.getProperty("gxt.device"));
    Icons.INSTANCE.ensureInjected();
    AppCache appCache = new AppCache();
    AppCacheMonitor3 monitor = new AppCacheMonitor3(appCache);
    monitor.start();
    EventBus eventBus = new SimpleEventBus();
    PlaceController placeController = new PlaceController(eventBus);
    ConnectionListener connectionListener = new ConnectionListener();
    connectionListener.start();
    ActivityInfoClientAsync client = new ActivityInfoClientAsyncImpl(findServerUrl());
    HttpStore httpStore = new HttpStore(connectionListener.getOnline(), client, Scheduler.get());
    OfflineStore offlineStore = new OfflineStore(httpStore, IDBFactoryImpl.create());
    FormStore formStore = new FormStoreImpl(httpStore, offlineStore, Scheduler.get());
    LocalStorage storage = LocalStorage.create();
    Viewport viewport = new Viewport();
    AppFrame appFrame = new AppFrame(appCache, httpStore, offlineStore);
    ActivityMapper activityMapper = new AppActivityMapper(formStore, storage);
    ActivityManager activityManager = new ActivityManager(activityMapper, eventBus);
    activityManager.setDisplay(appFrame.getDisplayWidget());
    AppPlaceHistoryMapper historyMapper = new AppPlaceHistoryMapper();
    PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper);
    historyHandler.register(placeController, eventBus, DEFAULT_PLACE);
    // Start synchronizer...
    RecordSynchronizer synchronizer = new RecordSynchronizer(httpStore, offlineStore);
    viewport.add(appFrame);
    RootLayoutPanel.get().add(viewport);
    historyHandler.handleCurrentHistory();
}
Also used : FormStoreImpl(org.activityinfo.ui.client.store.FormStoreImpl) OfflineStore(org.activityinfo.ui.client.store.offline.OfflineStore) PlaceController(com.google.gwt.place.shared.PlaceController) Viewport(com.sencha.gxt.widget.core.client.container.Viewport) SimpleEventBus(com.google.web.bindery.event.shared.SimpleEventBus) EventBus(com.google.web.bindery.event.shared.EventBus) ConnectionListener(org.activityinfo.ui.client.store.http.ConnectionListener) ActivityInfoClientAsyncImpl(org.activityinfo.api.client.ActivityInfoClientAsyncImpl) ActivityManager(com.google.gwt.activity.shared.ActivityManager) PlaceHistoryHandler(com.google.gwt.place.shared.PlaceHistoryHandler) RecordSynchronizer(org.activityinfo.ui.client.store.offline.RecordSynchronizer) ActivityMapper(com.google.gwt.activity.shared.ActivityMapper) LocalStorage(org.activityinfo.storage.LocalStorage) SimpleEventBus(com.google.web.bindery.event.shared.SimpleEventBus) HttpStore(org.activityinfo.ui.client.store.http.HttpStore) AppFrame(org.activityinfo.ui.client.chrome.AppFrame) FormStore(org.activityinfo.ui.client.store.FormStore) ActivityInfoClientAsync(org.activityinfo.api.client.ActivityInfoClientAsync)

Aggregations

FormStore (org.activityinfo.ui.client.store.FormStore)2 ActivityManager (com.google.gwt.activity.shared.ActivityManager)1 ActivityMapper (com.google.gwt.activity.shared.ActivityMapper)1 PlaceController (com.google.gwt.place.shared.PlaceController)1 PlaceHistoryHandler (com.google.gwt.place.shared.PlaceHistoryHandler)1 EventBus (com.google.web.bindery.event.shared.EventBus)1 SimpleEventBus (com.google.web.bindery.event.shared.SimpleEventBus)1 Viewport (com.sencha.gxt.widget.core.client.container.Viewport)1 ActivityInfoClientAsync (org.activityinfo.api.client.ActivityInfoClientAsync)1 ActivityInfoClientAsyncImpl (org.activityinfo.api.client.ActivityInfoClientAsyncImpl)1 FormClass (org.activityinfo.model.form.FormClass)1 FormMetadata (org.activityinfo.model.form.FormMetadata)1 FormMetadataProvider (org.activityinfo.model.formTree.FormMetadataProvider)1 FormTree (org.activityinfo.model.formTree.FormTree)1 FormTreeBuilder (org.activityinfo.model.formTree.FormTreeBuilder)1 ResourceId (org.activityinfo.model.resource.ResourceId)1 RecordRef (org.activityinfo.model.type.RecordRef)1 SubFormReferenceType (org.activityinfo.model.type.subform.SubFormReferenceType)1 LocalStorage (org.activityinfo.storage.LocalStorage)1 AppFrame (org.activityinfo.ui.client.chrome.AppFrame)1