@Override protected void setValue(Object element, Object value) { CatRateLinkEntity linkEntity = (CatRateLinkEntity) element; String valueStr = (String) value; try { linkEntity.setDefValue(Integer.valueOf(valueStr)); DbHelper.merge(linkEntity); viewer.update(element, null); } catch (Exception e) { Util.dbError(shell, e); } }
@Override protected void setValue(Object element, Object value) { if ((Integer) value > -1) { RateRbEntity rateEntity = rates.get((Integer) value); CatRateLinkEntity entity = (CatRateLinkEntity) element; try { entity.setRate(rateEntity); DbHelper.merge(entity); viewer.update(element, null); } catch (Exception e) { Util.dbError(shell, e); } } }
/** Добавление строки в таблицу. */ @SuppressWarnings({"unchecked"}) public void append() { EntityManager em = DbHelper.getEm(); Query query = em.createQuery("select r from RateRbEntity r"); List<RateRbEntity> rbEntities = query.getResultList(); if (rbEntities.size() == 0) { Util.warning( getShell(), "Внимание", "Сначала необходимо внести оценки в справочник оценок!"); return; } CatRateLinkEntity linkEntity = new CatRateLinkEntity(); linkEntity.setCat(catCurrent); linkEntity.setRate(rbEntities.get(0)); linkEntity.setDefValue(0); try { DbHelper.persist(linkEntity); entityList.add(linkEntity); } catch (Exception e) { Util.dbError(getShell(), e); } }
@Override protected Object getValue(Object element) { CatRateLinkEntity entity = (CatRateLinkEntity) element; return rates.indexOf(entity.getRate()); }
@Override protected Object getValue(Object element) { CatRateLinkEntity entity = (CatRateLinkEntity) element; Integer defValue = entity.getDefValue(); return String.valueOf(defValue); }
@Override public String getText(Object o) { CatRateLinkEntity entity = (CatRateLinkEntity) o; return String.valueOf(entity.getDefValue()); }
@Override public String getText(Object o) { CatRateLinkEntity entity = (CatRateLinkEntity) o; return entity.getRate().getName(); }