Search in sources :

Example 1 with ActivityDTO

use of org.activityinfo.shared.dto.ActivityDTO in project activityinfo by bedatadriven.

the class AddLockedPeriodDialog method initializeComponent.

private void initializeComponent() {
    setWidth(400);
    setHeight(280);
    setHeaderVisible(false);
    fieldsetContainer = new FieldSet();
    fieldsetContainer.setHeading(I18N.CONSTANTS.type());
    comboboxProjects = new ComboBox<ProjectDTO>();
    storeProjects = new ListStore<ProjectDTO>();
    comboboxProjects.setStore(storeProjects);
    comboboxProjects.setDisplayField("name");
    comboboxProjects.setForceSelection(true);
    comboboxProjects.setTriggerAction(TriggerAction.ALL);
    comboboxProjects.setEditable(false);
    comboboxActivities = new ComboBox<ActivityDTO>();
    storeActivities = new ListStore<ActivityDTO>();
    comboboxActivities.setStore(storeActivities);
    comboboxActivities.setDisplayField("name");
    comboboxActivities.setForceSelection(true);
    comboboxActivities.setTriggerAction(TriggerAction.ALL);
    comboboxActivities.setEditable(false);
    radiogroupContainer = new RadioGroup();
    radiogroupContainer.setFieldLabel(I18N.CONSTANTS.type());
    labelDatabase = new LabelField(I18N.CONSTANTS.database());
    labelDatabase.setWidth(100);
    labelDatabaseName = new LabelField();
    radioDatabase = new Radio();
    radioDatabase.setFieldLabel(I18N.CONSTANTS.database());
    radioDatabase.addListener(Events.Change, new Listener<FieldEvent>() {

        @Override
        public void handleEvent(FieldEvent be) {
        }
    });
    radiogroupContainer.add(radioDatabase);
    panelDatabase = new HorizontalPanel();
    panelDatabase.add(labelDatabase);
    panelDatabase.add(radioDatabase);
    panelDatabase.add(labelDatabaseName);
    fieldsetContainer.add(panelDatabase);
    radioActivity = new Radio();
    radioActivity.setFieldLabel(I18N.CONSTANTS.activity());
    labelActivity = new LabelField(I18N.CONSTANTS.activity());
    labelActivity.setWidth(100);
    panelActivity = new HorizontalPanel();
    panelActivity.add(labelActivity);
    panelActivity.add(radioActivity);
    panelActivity.add(comboboxActivities);
    fieldsetContainer.add(panelActivity);
    radiogroupContainer.add(radioActivity);
    radioProject = new Radio();
    radioProject.setFieldLabel(I18N.CONSTANTS.project());
    radioProject.addListener(Events.Change, new Listener<FieldEvent>() {

        @Override
        public void handleEvent(FieldEvent be) {
            comboboxProjects.setEnabled(radioProject.getValue());
        }
    });
    labelProject = new LabelField(I18N.CONSTANTS.project());
    labelProject.setWidth(100);
    panelProject = new HorizontalPanel();
    panelProject.add(labelProject);
    panelProject.add(radioProject);
    panelProject.add(comboboxProjects);
    fieldsetContainer.add(panelProject);
    radiogroupContainer.add(radioProject);
    add(fieldsetContainer);
    textfieldName = new TextField<String>();
    textfieldName.setFieldLabel(I18N.CONSTANTS.name());
    textfieldName.setAllowBlank(false);
    add(textfieldName);
    checkboxEnabled = new CheckBox();
    checkboxEnabled.setFieldLabel(I18N.CONSTANTS.enabledColumn());
    add(checkboxEnabled);
    datefieldFromDate = new DateField();
    datefieldFromDate.setFieldLabel(I18N.CONSTANTS.fromDate());
    datefieldFromDate.setAllowBlank(false);
    add(datefieldFromDate);
    datefieldToDate = new DateField();
    datefieldToDate.setFieldLabel(I18N.CONSTANTS.toDate());
    datefieldFromDate.setAllowBlank(false);
    add(datefieldToDate);
    radiogroupContainer.addListener(Events.Change, new Listener<FieldEvent>() {

        @Override
        public void handleEvent(FieldEvent be) {
            comboboxActivities.setAllowBlank(!radioActivity.getValue());
            comboboxProjects.setAllowBlank(!radioProject.getValue());
            comboboxActivities.clearInvalid();
            comboboxProjects.clearInvalid();
        }
    });
}
Also used : ProjectDTO(org.activityinfo.shared.dto.ProjectDTO) RadioGroup(com.extjs.gxt.ui.client.widget.form.RadioGroup) FieldEvent(com.extjs.gxt.ui.client.event.FieldEvent) Radio(com.extjs.gxt.ui.client.widget.form.Radio) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) FieldSet(com.extjs.gxt.ui.client.widget.form.FieldSet) CheckBox(com.extjs.gxt.ui.client.widget.form.CheckBox) HorizontalPanel(com.extjs.gxt.ui.client.widget.HorizontalPanel) DateField(com.extjs.gxt.ui.client.widget.form.DateField) LabelField(com.extjs.gxt.ui.client.widget.form.LabelField)

Example 2 with ActivityDTO

use of org.activityinfo.shared.dto.ActivityDTO in project activityinfo by bedatadriven.

the class TargetIndicatorView method createGridAndAddToContainer.

@Override
protected Grid<ModelData> createGridAndAddToContainer(Store store) {
    final TreeStore treeStore = (TreeStore) store;
    tree = new EditorTreeGrid<ModelData>(treeStore, createColumnModel());
    tree.setAutoExpandColumn("name");
    tree.setSelectionModel(new ImprovedCellTreeGridSelectionModel<ModelData>());
    tree.setClicksToEdit(EditorGrid.ClicksToEdit.ONE);
    tree.setLoadMask(true);
    tree.setStateId("TargetValueGrid" + db.getId());
    tree.setIconProvider(new ModelIconProvider<ModelData>() {

        @Override
        public AbstractImagePrototype getIcon(ModelData model) {
            if (model instanceof ActivityDTO) {
                return IconImageBundle.ICONS.activity();
            } else if (model instanceof TargetValueDTO) {
                return IconImageBundle.ICONS.indicator();
            } else if (model instanceof Link) {
                return IconImageBundle.ICONS.folder();
            } else {
                return null;
            }
        }
    });
    addBeforeEditListener();
    addAfterEditListener();
    add(tree, new BorderLayoutData(Style.LayoutRegion.CENTER));
    return tree;
}
Also used : AbstractImagePrototype(com.google.gwt.user.client.ui.AbstractImagePrototype) ModelData(com.extjs.gxt.ui.client.data.ModelData) TreeStore(com.extjs.gxt.ui.client.store.TreeStore) BorderLayoutData(com.extjs.gxt.ui.client.widget.layout.BorderLayoutData) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) TargetValueDTO(org.activityinfo.shared.dto.TargetValueDTO) Link(org.activityinfo.client.page.common.nav.Link)

Example 3 with ActivityDTO

use of org.activityinfo.shared.dto.ActivityDTO in project activityinfo by bedatadriven.

the class LockedPeriodsPresenter method go.

@Override
public void go(UserDatabaseDTO db) {
    parentModel = db;
    ArrayList<LockedPeriodDTO> items = new ArrayList<LockedPeriodDTO>(db.getLockedPeriods());
    for (ActivityDTO activity : db.getActivities()) {
        if (activity.getLockedPeriods() != null && activity.getLockedPeriods().size() > 0) {
            items.addAll(activity.getLockedPeriods());
        }
    }
    for (ProjectDTO project : db.getProjects()) {
        if (project.getLockedPeriods() != null && project.getLockedPeriods().size() > 0) {
            items.addAll(project.getLockedPeriods());
        }
    }
    view.setItems(items);
    if (items.size() > 0) {
        view.setValue(items.get(0));
    }
    view.setParent(parentModel);
}
Also used : ProjectDTO(org.activityinfo.shared.dto.ProjectDTO) ArrayList(java.util.ArrayList) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) LockedPeriodDTO(org.activityinfo.shared.dto.LockedPeriodDTO)

Example 4 with ActivityDTO

use of org.activityinfo.shared.dto.ActivityDTO in project activityinfo by bedatadriven.

the class LockedPeriodsPresenter method onCreate.

@Override
public void onCreate(CreateEvent event) {
    view.getCreatingMonitor().beforeRequest();
    final LockedPeriodDTO lockedPeriod = view.getValue();
    CreateLockedPeriod lockUserDatabase = new CreateLockedPeriod(lockedPeriod);
    if (lockedPeriod.getParent() instanceof ActivityDTO) {
        lockUserDatabase.setActivityId(lockedPeriod.getParent().getId());
    }
    if (lockedPeriod.getParent() instanceof ProjectDTO) {
        lockUserDatabase.setProjectId(lockedPeriod.getParent().getId());
    }
    if (lockedPeriod.getParent() instanceof UserDatabaseDTO) {
        lockUserDatabase.setUserDatabaseId(lockedPeriod.getParent().getId());
    }
    service.execute(lockUserDatabase, new AsyncCallback<CreateResult>() {

        @Override
        public void onFailure(Throwable caught) {
            view.getCreatingMonitor().onServerError();
            MessageBox.alert(I18N.CONSTANTS.error(), I18N.CONSTANTS.errorOnServer() + "\n\n" + caught.getMessage(), null);
        }

        @Override
        public void onSuccess(CreateResult result) {
            // Update the Id for the child instance
            lockedPeriod.setId(result.getNewId());
            // Tell the view there's a new kid on the block
            view.create(lockedPeriod);
            // Actually add the lock to it's parent
            lockedPeriod.getParent().getLockedPeriods().add(lockedPeriod);
        }
    });
}
Also used : ProjectDTO(org.activityinfo.shared.dto.ProjectDTO) CreateResult(org.activityinfo.shared.command.result.CreateResult) UserDatabaseDTO(org.activityinfo.shared.dto.UserDatabaseDTO) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) CreateLockedPeriod(org.activityinfo.shared.command.CreateLockedPeriod) LockedPeriodDTO(org.activityinfo.shared.dto.LockedPeriodDTO)

Example 5 with ActivityDTO

use of org.activityinfo.shared.dto.ActivityDTO in project activityinfo by bedatadriven.

the class TargetIndicatorPresenter method fillStore.

private void fillStore() {
    Map<String, Link> categories = new HashMap<String, Link>();
    for (ActivityDTO activity : db.getActivities()) {
        if (activity.getCategory() != null) {
            Link actCategoryLink = categories.get(activity.getCategory());
            if (actCategoryLink == null) {
                actCategoryLink = createCategoryLink(activity, categories);
                categories.put(activity.getCategory(), actCategoryLink);
                treeStore.add(actCategoryLink, false);
            }
            treeStore.add(actCategoryLink, activity, false);
            addIndicatorLinks(activity, activity);
        } else {
            treeStore.add(activity, false);
            addIndicatorLinks(activity, activity);
        }
    }
}
Also used : HashMap(java.util.HashMap) ActivityDTO(org.activityinfo.shared.dto.ActivityDTO) Link(org.activityinfo.client.page.common.nav.Link)

Aggregations

ActivityDTO (org.activityinfo.shared.dto.ActivityDTO)44 SchemaDTO (org.activityinfo.shared.dto.SchemaDTO)20 GetSchema (org.activityinfo.shared.command.GetSchema)15 UserDatabaseDTO (org.activityinfo.shared.dto.UserDatabaseDTO)13 Test (org.junit.Test)13 AttributeGroupDTO (org.activityinfo.shared.dto.AttributeGroupDTO)9 IndicatorDTO (org.activityinfo.shared.dto.IndicatorDTO)9 SiteDTO (org.activityinfo.shared.dto.SiteDTO)8 CreateResult (org.activityinfo.shared.command.result.CreateResult)6 ModelData (com.extjs.gxt.ui.client.data.ModelData)5 AttributeDTO (org.activityinfo.shared.dto.AttributeDTO)5 ProjectDTO (org.activityinfo.shared.dto.ProjectDTO)5 TreeStore (com.extjs.gxt.ui.client.store.TreeStore)4 ColumnConfig (com.extjs.gxt.ui.client.widget.grid.ColumnConfig)3 ColumnData (com.extjs.gxt.ui.client.widget.grid.ColumnData)3 HashMap (java.util.HashMap)3 MockEventBus (org.activityinfo.client.MockEventBus)3 DispatcherStub (org.activityinfo.client.dispatch.DispatcherStub)3 UIConstants (org.activityinfo.client.i18n.UIConstants)3 StateManagerStub (org.activityinfo.client.mock.StateManagerStub)3