BrightSide Workbench Full Report + Source Code
IssueComposer.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2015 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.dossier.zul.issue;
20 
21 import org.turro.command.Command;
22 import org.turro.command.Context;
23 import org.turro.dossier.db.DossierPU;
24 import org.turro.dossier.entity.Dossier;
25 import org.turro.dossier.entity.Issue;
26 import org.turro.dossier.entity.IssuePriority;
27 import org.turro.dossier.entity.IssueResolution;
28 import org.turro.dossier.entity.IssueStatus;
29 import org.turro.dossier.entity.IssueType;
30 import org.turro.dossier.issue.IssueWrapper;
31 import org.turro.dossier.zul.menu.DossierMenu;
32 import org.turro.elephant.context.Application;
33 import org.turro.jpa.composer.EntityComposer;
34 import org.turro.jpa.entity.DaoEntity;
35 import org.turro.zul.frame.Framework;
36 import org.zkoss.zk.ui.Component;
37 import org.zkoss.zk.ui.Executions;
38 import org.zkoss.zk.ui.select.annotation.Listen;
39 
44 public class IssueComposer extends EntityComposer<Issue, Long> {
45 
46  @Listen("onClick = #addInfo")
47  public void onAddInfo() {
48  DossierMenu.addInformation(entity, new Command() {
49  @Override
50  public Object execute(Context context) {
52  DossierMenu.showIssue(entity.getId());
53  return null;
54  }
55  });
56  }
57 
58  @Listen("onClick = #addSub")
59  public void onAddSub() {
60  DossierMenu.addSubtask(entity, new Command() {
61  @Override
62  public Object execute(Context context) {
64  DossierMenu.showIssue(entity.getId());
65  return null;
66  }
67  });
68  }
69 
70  @Override
71  protected String getAttributeName() {
72  return "issue";
73  }
74 
75  @Override
76  protected Issue getEntityInstance(Long id) {
77  if(id == null) {
78  entity = new Issue();
79  Long dossierId = (Long) Executions.getCurrent().getDesktop().getAttribute("dossierId");
80  if(dossierId != null && dossierId > 0) {
81  entity.setDossier(new DossierPU().find(Dossier.class, dossierId));
82  }
83  entity.setType(IssueType.TYPE_TASK);
84  entity.setStatus(IssueStatus.STATUS_NEW);
87  entity.setIssueDate(new java.util.Date());
88  entity.setPublishable(true);
89  } else {
90  entity = new DossierPU().find(Issue.class, id);
91  }
92  return entity;
93  }
94 
95  @Override
96  protected DaoEntity getWrapperInstance(Component comp) {
100  return w;
101  }
102 
103  @Override
104  public void afterSave() {
105  if(entity != null) {
106  DossierMenu.showIssue(entity.getId());
107  }
108  }
109 
110  @Override
111  protected boolean shouldBeSaved() {
112  return false;
113  }
114 
115  @Override
116  protected boolean inSaveRole() {
117  return Application.getApplication().isInRole("issue:edit");
118  }
119 
120  @Override
121  protected boolean inDeleteRole() {
122  return Application.getApplication().isInRole("issue:delete");
123  }
124 
125 }
126 
DaoEntity getWrapperInstance(Component comp)
static void addSubtask(Issue issue, final Command command)
static void addInformation(Issue issue, final Command command)
static Framework getCurrent()
Definition: Framework.java:203
void setSelectedLabel(String text)
Definition: Framework.java:103
void setSelectedTooltiptext(String text)
Definition: Framework.java:107