BrightSide Workbench Full Report + Source Code
TaskComposer.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2012 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.erp.task.logic;
20 
21 import org.turro.command.Command;
22 import org.turro.command.Context;
23 import org.turro.elephant.context.Application;
24 import org.turro.elephant.util.ZkossUtils;
25 import org.turro.erp.db.ErpPU;
26 import org.turro.erp.entity.Task;
27 import org.turro.erp.menu.ErpMenu;
28 import org.turro.jpa.composer.EntityComposer;
29 import org.turro.jpa.entity.DaoEntity;
30 import org.turro.zul.frame.Framework;
31 import org.zkoss.zk.ui.Component;
32 
37 public class TaskComposer extends EntityComposer<Task, Long> {
38 
39  @Override
40  protected String getAttributeName() {
41  return "task";
42  }
43 
44  @Override
45  protected Task getEntityInstance(Long id) {
46  if(id == null) {
47  entity = new Task();
48  entity.setName("");
49  } else {
50  entity = new ErpPU().find(Task.class, id);
51  }
52  return entity;
53  }
54 
55  @Override
56  protected DaoEntity getWrapperInstance(Component comp) {
59  Framework.getCurrent().setSelectedTooltiptext(entity.getFullDescription());
60  return w;
61  }
62 
63  @Override
64  public void afterSave() {
65  if(entity != null) {
67  }
68  }
69 
70  @Override
71  protected void doOnDelete() {
72  ZkossUtils.confirmDeletion(null, new Command() {
73  @Override
74  public Object execute(Context context) {
75  TaskComposer.super.doOnDelete();
76  return null;
77  }
78  });
79  }
80 
81  @Override
82  protected boolean shouldBeSaved() {
83  return !entity.isEmpty() && (entity.getId() == 0) || super.shouldBeSaved();
84  }
85 
86  @Override
87  protected boolean inSaveRole() {
88  return Application.getApplication().isInRole("erp-task:edit");
89  }
90 
91  @Override
92  protected boolean inDeleteRole() {
93  return Application.getApplication().isInRole("erp-task:delete");
94  }
95 
96 }
static void showTask(Task task)
Definition: ErpMenu.java:133
DaoEntity getWrapperInstance(Component comp)
static Framework getCurrent()
Definition: Framework.java:203
void setSelectedLabel(String text)
Definition: Framework.java:103
void setSelectedTooltiptext(String text)
Definition: Framework.java:107