use of db.AddButtonLabelRenderer in project common by zenlunatics.
the class Meetings method _newViewDef.
// ------------------------------------------------------------------------
@Override
public ViewDef _newViewDef(String name, Site site) {
if (name.equals("meetings")) {
ViewDef view_def = new ViewDef(name) {
@Override
public View newView(Request request) {
View view = new View(this, request);
if (request.getParameter("db_mode") == View.Mode.EDIT_FORM.toString())
if (request.db.lookupInt("_owner_", "meetings", Integer.parseInt(view.getKeyValue()), -1) != request.getUser().getId())
view.setColumn(new Column("title").setIsReadOnly(true));
return view;
}
}.addInsertHook(this).addUpdateHook(this).setAccessPolicy(new RecordOwnerAccessPolicy() {
@Override
public boolean canUpdateRow(String from, int id, Request request) {
return true;
}
@Override
public boolean showEditButtonForRow(View view, Request request) {
return true;
}
}.add().delete().edit()).setRecordName("Meeting").setColumnNamesForm(new String[] { "title", "days", "_owner_" }).setColumnNamesTable(new String[] { "title" }).setColumn(new Column("days").setInputRenderer(new MeetingInputRenderer()).setLabelRenderer(new AddButtonLabelRenderer("meeting.addDay()"))).setColumn(new Column("_owner_").setDefaultToUserId().setIsHidden(true)).setColumn(new Column("title").setIsRequired(true)).addRelationshipDef(new OneToManyLink("meeting_people", "people_id"));
view_def.getViewTheme().setEditText("set times");
return view_def;
}
if (name.equals("meeting_people"))
return new ViewDef(name).setDialogModes(View.Mode.ADD_FORM).setRecordName("Person").setColumnNamesTable(new String[] { "color", "people_id" }).setColumn(new Column("color").setDisplayName("").setValueRenderer(new MeetingColorRenderer(), false)).setColumn(new Column("days").setInputRenderer(new MeetingInputRenderer()).setLabelRenderer(new AddButtonLabelRenderer("addDay()"))).setColumn(new LookupColumn("people_id", "people", "first,last").setDisplayName("Person"));
return null;
}
Aggregations