Search in sources :

Example 1 with ProjectDTO

use of org.activityinfo.legacy.shared.model.ProjectDTO in project activityinfo by bedatadriven.

the class DbProjectGrid method createGridAndAddToContainer.

@Override
protected Grid<ProjectDTO> createGridAndAddToContainer(Store store) {
    grid = new Grid<ProjectDTO>((ListStore) store, createColumnModel());
    grid.setAutoExpandColumn("description");
    grid.setLoadMask(true);
    setLayout(new FitLayout());
    add(grid);
    return grid;
}
Also used : ProjectDTO(org.activityinfo.legacy.shared.model.ProjectDTO) ListStore(com.extjs.gxt.ui.client.store.ListStore) FitLayout(com.extjs.gxt.ui.client.widget.layout.FitLayout)

Example 2 with ProjectDTO

use of org.activityinfo.legacy.shared.model.ProjectDTO in project activityinfo by bedatadriven.

the class DbTargetEditor method onEdit.

@Override
protected void onEdit(final TargetDTO dto) {
    this.view.showAddDialog(dto, db, true, new FormDialogCallback() {

        @Override
        public void onValidated(final FormDialogTether dlg) {
            final Record record = store.getRecord(dto);
            service.execute(new UpdateEntity(dto, getChangedProperties(record)), dlg, new AsyncCallback<VoidResult>() {

                @Override
                public void onFailure(Throwable caught) {
                    Log.error("Failed to edit target. " + caught.getMessage(), caught);
                }

                @Override
                public void onSuccess(VoidResult result) {
                    if (record.get("partnerId") != null) {
                        PartnerDTO partner = db.getPartnerById((Integer) record.get("partnerId"));
                        dto.setPartner(partner);
                    } else {
                        dto.setPartner(null);
                    }
                    if (record.get("projectId") != null) {
                        ProjectDTO project = db.getProjectById((Integer) record.get("projectId"));
                        dto.setProject(project);
                    } else {
                        dto.setProject(null);
                    }
                    store.commitChanges();
                    eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
                    dlg.hide();
                }
            });
        }
    });
}
Also used : ProjectDTO(org.activityinfo.legacy.shared.model.ProjectDTO) FormDialogCallback(org.activityinfo.ui.client.page.common.dialog.FormDialogCallback) UpdateEntity(org.activityinfo.legacy.shared.command.UpdateEntity) VoidResult(org.activityinfo.legacy.shared.command.result.VoidResult) PartnerDTO(org.activityinfo.legacy.shared.model.PartnerDTO) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) FormDialogTether(org.activityinfo.ui.client.page.common.dialog.FormDialogTether) Record(com.extjs.gxt.ui.client.store.Record)

Example 3 with ProjectDTO

use of org.activityinfo.legacy.shared.model.ProjectDTO in project activityinfo by bedatadriven.

the class DbTargetEditor method onAdd.

@Override
protected void onAdd() {
    final TargetDTO newTarget = new TargetDTO();
    this.view.showAddDialog(newTarget, db, false, new FormDialogCallback() {

        @Override
        public void onValidated(final FormDialogTether dlg) {
            service.execute(new AddTarget(db.getId(), newTarget), dlg, new AsyncCallback<CreateResult>() {

                @Override
                public void onFailure(Throwable caught) {
                    MessageBox.alert(I18N.CONSTANTS.error(), I18N.CONSTANTS.errorOnServer(), null);
                }

                @Override
                public void onSuccess(CreateResult result) {
                    newTarget.setId(result.getNewId());
                    if (newTarget.get("partnerId") != null) {
                        PartnerDTO partner = db.getPartnerById((Integer) newTarget.get("partnerId"));
                        newTarget.setPartner(partner);
                    }
                    if (newTarget.get("projectId") != null) {
                        ProjectDTO project = db.getProjectById((Integer) newTarget.get("projectId"));
                        newTarget.setProject(project);
                    }
                    store.add(newTarget);
                    store.commitChanges();
                    eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
                    dlg.hide();
                }
            });
        }
    });
}
Also used : ProjectDTO(org.activityinfo.legacy.shared.model.ProjectDTO) FormDialogCallback(org.activityinfo.ui.client.page.common.dialog.FormDialogCallback) CreateResult(org.activityinfo.legacy.shared.command.result.CreateResult) PartnerDTO(org.activityinfo.legacy.shared.model.PartnerDTO) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) FormDialogTether(org.activityinfo.ui.client.page.common.dialog.FormDialogTether) AddTarget(org.activityinfo.legacy.shared.command.AddTarget) TargetDTO(org.activityinfo.legacy.shared.model.TargetDTO)

Example 4 with ProjectDTO

use of org.activityinfo.legacy.shared.model.ProjectDTO in project activityinfo by bedatadriven.

the class DbTargetGrid method createColumnModel.

protected ColumnModel createColumnModel() {
    List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
    ColumnConfig projectColumn = new ColumnConfig("projectId", messages.project(), 150);
    projectColumn.setRenderer(new GridCellRenderer() {

        @Override
        public SafeHtml render(ModelData modelData, String s, ColumnData columnData, int i, int i1, ListStore listStore, Grid grid) {
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            Integer id = modelData.get(s);
            if (id != null) {
                ProjectDTO project = db.getProjectById(id);
                if (project != null) {
                    sb.appendEscaped(project.getName());
                }
            }
            return sb.toSafeHtml();
        }
    });
    ColumnConfig partnerColumn = new ColumnConfig("partnerId", messages.partner(), 150);
    partnerColumn.setRenderer(new GridCellRenderer() {

        @Override
        public SafeHtml render(ModelData modelData, String s, ColumnData columnData, int i, int i1, ListStore listStore, Grid grid) {
            SafeHtmlBuilder sb = new SafeHtmlBuilder();
            Integer id = modelData.get(s);
            if (id != null) {
                PartnerDTO partner = db.getPartnerById(id);
                if (partner != null) {
                    sb.appendEscaped(partner.getName());
                }
            }
            return sb.toSafeHtml();
        }
    });
    columns.add(new ColumnConfig("name", messages.name(), 150));
    columns.add(projectColumn);
    columns.add(partnerColumn);
    columns.add(new TimePeriodColumn("timePeriod", messages.timePeriod(), 300));
    return new ColumnModel(columns);
}
Also used : ProjectDTO(org.activityinfo.legacy.shared.model.ProjectDTO) ModelData(com.extjs.gxt.ui.client.data.ModelData) PartnerDTO(org.activityinfo.legacy.shared.model.PartnerDTO) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) ArrayList(java.util.ArrayList) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) ListStore(com.extjs.gxt.ui.client.store.ListStore) TimePeriodColumn(org.activityinfo.ui.client.page.common.columns.TimePeriodColumn)

Example 5 with ProjectDTO

use of org.activityinfo.legacy.shared.model.ProjectDTO in project activityinfo by bedatadriven.

the class AddProjectHandler method execute.

@Override
public CommandResult execute(AddProject cmd, User user) {
    Database db = em.find(Database.class, cmd.getDatabaseId());
    ProjectDTO from = cmd.getProjectDTO();
    Project project = new Project();
    project.setName(from.getName());
    project.setDescription(from.getDescription());
    project.setDatabase(db);
    db.setLastSchemaUpdate(new Date());
    em.persist(project);
    em.persist(db);
    db.getProjects().add(project);
    return new CreateResult(project.getId());
}
Also used : ProjectDTO(org.activityinfo.legacy.shared.model.ProjectDTO) Project(org.activityinfo.server.database.hibernate.entity.Project) AddProject(org.activityinfo.legacy.shared.command.AddProject) CreateResult(org.activityinfo.legacy.shared.command.result.CreateResult) Database(org.activityinfo.server.database.hibernate.entity.Database) Date(java.util.Date)

Aggregations

ProjectDTO (org.activityinfo.legacy.shared.model.ProjectDTO)11 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)4 PartnerDTO (org.activityinfo.legacy.shared.model.PartnerDTO)4 FormDialogCallback (org.activityinfo.ui.client.page.common.dialog.FormDialogCallback)4 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)3 FormDialogTether (org.activityinfo.ui.client.page.common.dialog.FormDialogTether)3 ListStore (com.extjs.gxt.ui.client.store.ListStore)2 AddProject (org.activityinfo.legacy.shared.command.AddProject)2 VoidResult (org.activityinfo.legacy.shared.command.result.VoidResult)2 SchemaDTO (org.activityinfo.legacy.shared.model.SchemaDTO)2 Test (org.junit.Test)2 ModelData (com.extjs.gxt.ui.client.data.ModelData)1 Record (com.extjs.gxt.ui.client.store.Record)1 FitLayout (com.extjs.gxt.ui.client.widget.layout.FitLayout)1 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)1 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1 AddTarget (org.activityinfo.legacy.shared.command.AddTarget)1