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;
}
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();
}
});
}
});
}
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();
}
});
}
});
}
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);
}
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());
}
Aggregations