Search in sources :

Example 1 with DataEntryPlace

use of org.activityinfo.client.page.entry.place.DataEntryPlace in project activityinfo by bedatadriven.

the class SearchPresenter method fromSitesList.

private List<RecentSiteModel> fromSitesList(List<SiteDTO> sites) {
    List<RecentSiteModel> result = new ArrayList<RecentSiteModel>();
    if (sites != null) {
        for (SiteDTO site : sites) {
            RecentSiteModel recent = null;
            if (schema != null) {
                ActivityDTO activity = schema.getActivityById(site.getActivityId());
                if (activity != null) {
                    recent = new RecentSiteModel(site);
                    recent.setActivityName(activity.getName());
                    recent.setActivityLink(PageStateSerializer.asLink(new DataEntryPlace(activity)));
                    recent.setDatabaseName(activity.getDatabase().getName() == null ? "[Database]" : activity.getDatabase().getName());
                }
            }
            if (recent != null) {
                result.add(recent);
            }
        }
    }
    return result;
}
Also used : DataEntryPlace(org.activityinfo.client.page.entry.place.DataEntryPlace) ArrayList(java.util.ArrayList) SiteDTO(org.activityinfo.shared.dto.SiteDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO)

Example 2 with DataEntryPlace

use of org.activityinfo.client.page.entry.place.DataEntryPlace in project activityinfo by bedatadriven.

the class DesignTest method testSaveOnNavigateAway.

@Test
public void testSaveOnNavigateAway() {
    // Dummy Data
    SchemaDTO schema = DTOs.pear();
    // Collaborator
    MockEventBus eventBus = new MockEventBus();
    // Collaborator
    DispatcherStub service = new DispatcherStub();
    service.setResult(GetSchema.class, schema);
    service.setResult(UpdateEntity.class, new VoidResult());
    // Collaborator
    DesignPresenter.View view = createNiceMock(DesignPresenter.View.class);
    replay(view);
    // Collaborator
    UIConstants constants = createNiceMock(UIConstants.class);
    replay(constants);
    DesignPresenter designer = new DesignPresenter(eventBus, service, new StateManagerStub(), view, constants);
    designer.go(schema.getDatabaseById(1));
    // Verify that following a change to the record, a save call
    // triggers an update command
    ActivityDTO activity = (ActivityDTO) ((TreeStore) designer.getStore()).getRootItems().get(0);
    Record record = designer.getStore().getRecord(activity);
    record.set("name", "New Name");
    designer.requestToNavigateAway(new DataEntryPlace(), new NavigationCallback() {

        @Override
        public void onDecided(boolean allowed) {
        }
    });
    UpdateEntity cmd = service.getLastExecuted(UpdateEntity.class);
    Assert.assertTrue(cmd.getChanges().containsKey("name"));
    Assert.assertEquals("New Name", cmd.getChanges().get("name"));
}
Also used : VoidResult(org.activityinfo.shared.command.result.VoidResult) UpdateEntity(org.activityinfo.shared.command.UpdateEntity) DispatcherStub(org.activityinfo.client.dispatch.DispatcherStub) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) SchemaDTO(org.activityinfo.shared.dto.SchemaDTO) TreeStore(com.extjs.gxt.ui.client.store.TreeStore) DataEntryPlace(org.activityinfo.client.page.entry.place.DataEntryPlace) MockEventBus(org.activityinfo.client.MockEventBus) NavigationCallback(org.activityinfo.client.page.NavigationCallback) Record(com.extjs.gxt.ui.client.store.Record) UIConstants(org.activityinfo.client.i18n.UIConstants) StateManagerStub(org.activityinfo.client.mock.StateManagerStub) Test(org.junit.Test)

Example 3 with DataEntryPlace

use of org.activityinfo.client.page.entry.place.DataEntryPlace in project activityinfo by bedatadriven.

the class SearchResultItem method setChilds.

public void setChilds(List<Axis> childList) {
    for (Axis axis : childList) {
        VerticalPanel panelAll = new VerticalPanel();
        HorizontalPanel panelChild = new HorizontalPanel();
        HorizontalPanel spacer = new HorizontalPanel();
        spacer.setWidth(20);
        panelChild.add(spacer);
        Image image = IconImageBundle.ICONS.activity().createImage();
        panelChild.add(image);
        panelAll.add(panelChild);
        EntityCategory activity = (EntityCategory) axis.getCategory();
        Hyperlink link = new Hyperlink(axis.getLabel(), PageStateSerializer.serialize(new DataEntryPlace(Filter.filter().onActivity(activity.getId()))));
        link.setStylePrimaryName("link");
        panelChild.add(link);
        for (Axis childAxis : axis.getChildren()) {
            HorizontalPanel panelIndicator = new HorizontalPanel();
            HorizontalPanel spacerIndicator = new HorizontalPanel();
            spacerIndicator.setWidth(40);
            panelIndicator.add(spacerIndicator);
            panelIndicator.add(IconImageBundle.ICONS.indicator().createImage());
            // Hyperlink linkIndicator = new Hyperlink(childAxis.getLabel(),
            // "site-grid/" +
            // ((EntityCategory)childAxis.getCategory()).getId());
            // linkIndicator.setStylePrimaryName("link");
            // panelIndicator.add(linkIndicator);
            LabelField labelIndicator = new LabelField(childAxis.getLabel());
            panelIndicator.add(labelIndicator);
            panelAll.add(panelIndicator);
            indicatorCount++;
        }
        activityCount++;
        childPanel.add(panelAll);
    }
}
Also used : VerticalPanel(com.extjs.gxt.ui.client.widget.VerticalPanel) DataEntryPlace(org.activityinfo.client.page.entry.place.DataEntryPlace) HorizontalPanel(com.extjs.gxt.ui.client.widget.HorizontalPanel) Image(com.google.gwt.user.client.ui.Image) EntityCategory(org.activityinfo.shared.report.content.EntityCategory) LabelField(com.extjs.gxt.ui.client.widget.form.LabelField) Axis(org.activityinfo.shared.report.content.PivotTableData.Axis) Hyperlink(com.google.gwt.user.client.ui.Hyperlink)

Aggregations

DataEntryPlace (org.activityinfo.client.page.entry.place.DataEntryPlace)3 ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)2 Record (com.extjs.gxt.ui.client.store.Record)1 TreeStore (com.extjs.gxt.ui.client.store.TreeStore)1 HorizontalPanel (com.extjs.gxt.ui.client.widget.HorizontalPanel)1 VerticalPanel (com.extjs.gxt.ui.client.widget.VerticalPanel)1 LabelField (com.extjs.gxt.ui.client.widget.form.LabelField)1 Hyperlink (com.google.gwt.user.client.ui.Hyperlink)1 Image (com.google.gwt.user.client.ui.Image)1 ArrayList (java.util.ArrayList)1 MockEventBus (org.activityinfo.client.MockEventBus)1 DispatcherStub (org.activityinfo.client.dispatch.DispatcherStub)1 UIConstants (org.activityinfo.client.i18n.UIConstants)1 StateManagerStub (org.activityinfo.client.mock.StateManagerStub)1 NavigationCallback (org.activityinfo.client.page.NavigationCallback)1 UpdateEntity (org.activityinfo.shared.command.UpdateEntity)1 VoidResult (org.activityinfo.shared.command.result.VoidResult)1 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)1 SiteDTO (org.activityinfo.shared.dto.SiteDTO)1 EntityCategory (org.activityinfo.shared.report.content.EntityCategory)1