/** * Tries to get the current selected favorite as object. */ public F getCurrentFavorite() { if (StringUtils.isEmpty(selected) == true) { return null; } final UserPrefDO userPref = userPrefDao.getUserPref(userPrefArea, selected); if (userPref != null) { final F favorite = newFavoriteInstance(null); userPrefDao.fillFromUserPrefParameters(userPref, favorite); return favorite; } return null; }
/** * Adds the object fields as parameters to the given userPref. Fields without the annotation UserPrefParameter will be * ignored. * * @param userPref * @param obj * @see #fillFromUserPrefParameters(UserPrefDO, Object) */ public void addUserPrefParameters(final UserPrefDO userPref, final Object obj) { addUserPrefParameters(userPref, obj.getClass(), obj); }
public void setValueObject(final UserPrefEntryDO userPrefEntry, final Object value) { userPrefEntry.setValue(convertParameterValueToString(value)); updateParameterValueObject(userPrefEntry); }
UserPrefDO userPref = createUserPref(user, UserPrefArea.TIMESHEET_TEMPLATE, "test"); TimesheetDO timesheet = createTimesheet(user2, task, "Micromata", "Wrote a test case..."); userPrefDao.addUserPrefParameters(userPref, timesheet); assertFalse(userPrefDao.doesParameterNameAlreadyExist(null, user, UserPrefArea.TIMESHEET_TEMPLATE, "test")); final Serializable id = userPrefDao.save(userPref); assertTrue(userPrefDao.doesParameterNameAlreadyExist(null, user, UserPrefArea.TIMESHEET_TEMPLATE, "test")); assertFalse(userPrefDao.doesParameterNameAlreadyExist((Integer) id, user, UserPrefArea.TIMESHEET_TEMPLATE, "test")); userPref = userPrefDao.getById(id); assertEquals(5, userPref.getUserPrefEntries().size()); // user, task, kost2, location, description. UserPrefEntryDO entry = it.next(); assertUserPrefEntry(entry, "user", PFUserDO.class, user2.getId().toString(), "user", null, "1"); userPrefDao.updateParameterValueObject(entry); assertEquals(user2.getId(), ((PFUserDO) entry.getValueAsObject()).getId()); entry = it.next(); assertUserPrefEntry(entry, "task", TaskDO.class, task.getId().toString(), "task", null, "2"); userPrefDao.updateParameterValueObject(entry); assertEquals(task.getId(), ((TaskDO) entry.getValueAsObject()).getId()); entry = it.next(); userPrefDao.fillFromUserPrefParameters(userPref, timesheet); assertEquals(user2.getId(), timesheet.getUserId()); assertEquals(task.getId(), timesheet.getTaskId()); assertEquals("Wrote a test case...", timesheet.getDescription()); userPref.getUserPrefEntry("location").setValue("At home"); userPrefDao.update(userPref); String[] names = userPrefDao.getPrefNames(UserPrefArea.TIMESHEET_TEMPLATE); assertEquals(1, names.length);
/** * Fill object fields from the parameters of the given userPref. * * @param userPref * @param obj * @see #addUserPrefParameters(UserPrefDO, Object) */ public void fillFromUserPrefParameters(final UserPrefDO userPref, final Object obj) { fillFromUserPrefParameters(userPref, obj, false); }
parentPage.userPrefDao.addUserPrefParameters(data, data.getArea()); fs.addHelpIcon(getString(param.getTooltipI18nKey())); parentPage.userPrefDao.updateParameterValueObject(param); if (PFUserDO.class.isAssignableFrom(param.getType()) == true) { final UserSelectPanel userSelectPanel = new UserSelectPanel(fs.newChildId(),
private LabelValueChoiceRenderer<String> createRenderer() { final String[] entries = userPrefDao.getPrefNames(userPrefArea); final LabelValueChoiceRenderer<String> renderer = new LabelValueChoiceRenderer<String>(); for (final String entry : entries) { renderer.addValue(entry, entry); } renderer.addValue(ADD_NEW_ENTRY, getString("userPref.favorite.create")); return renderer; }
@Override public void validate(final IValidatable<String> validatable) { if (data.getArea() == null) { return; } final String value = validatable.getValue(); if (parentPage.userPrefDao.doesParameterNameAlreadyExist(data.getId(), data.getUser(), data.getArea(), value)) { name.error(getString("userPref.error.nameDoesAlreadyExist")); } } });
public TimesheetTemplateObject getTimesheetTemplateObject(final UserPrefDO userPrefDO) { if (userPrefDO == null) { return null; } final TimesheetTemplateObject template = new TimesheetTemplateObject(); final TimesheetDO timesheet = new TimesheetDO(); userPrefDao.fillFromUserPrefParameters(userPrefDO, timesheet); template.setName(userPrefDO.getName()); template.setDescription(timesheet.getDescription()); template.setLocation(timesheet.getLocation()); final UserObject user = PFUserDOConverter.getUserObject(timesheet.getUser()); if (user != null) { template.setUser(user); } final TaskObject task = taskDOConverter.getTaskObject(timesheet.getTask()); if (task != null) { template.setTask(task); } final Cost2Object cost2 = kost2DOConverter.getCost2Object(timesheet.getKost2()); if (cost2 != null) { template.setCost2(cost2); } return template; } }
final String[] templateNames = userPrefDao.getPrefNames(UserPrefArea.TIMESHEET_TEMPLATE); if (templateNames != null && templateNames.length > 0) {
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected void onSelectionChanged(final String newSelection) { if (StringUtils.isNotEmpty(newSelection) == true) { // Fill fields with selected template values: final UserPrefDO userPref = userPrefDao.getUserPref(ToDoPlugin.USER_PREF_AREA, newSelection); if (userPref != null) { userPrefDao.fillFromUserPrefParameters(userPref, data); } templateName = ""; // Mark all form components as model changed. visitFormComponents(new IVisitor() { @Override public void component(final Object object, final IVisit visit) { final FormComponent<?> fc = (FormComponent<?>) object; fc.modelChanged(); visit.dontGoDeeper(); } }); } } };
/** * Adds the fields of the bean type represented by the given area as parameters to the given userPref. Fields without * the annotation UserPrefParameter will be ignored. * * @param userPref * @param area * @see #fillFromUserPrefParameters(UserPrefDO, Object) */ public void addUserPrefParameters(final UserPrefDO userPref, final UserPrefArea area) { addUserPrefParameters(userPref, area.getBeanType(), null); }
if (isNew() == true) { final String[] templateNames = userPrefDao.getPrefNames(ToDoPlugin.USER_PREF_AREA); if (templateNames != null && templateNames.length > 0) {
final UserPrefDO userPref = userPrefDao.getUserPref(UserPrefArea.TIMESHEET_TEMPLATE, newSelection); if (userPref != null) { data.setKost2(null).setTask(null); userPrefDao.fillFromUserPrefParameters(userPref, data, true); recentUserPref = userPref; locationTextField.modelChanged();
private UserPrefDO initUserPref(final UserPrefDO userPref, final UserPrefArea area, final Object object) { userPref.setArea(area); userPref.setUser(ThreadLocalUserContext.getUser()); if (object != null) { userPrefDao.addUserPrefParameters(userPref, object); } else { userPrefDao.addUserPrefParameters(userPref, area); } return userPref; }