BrightSide Workbench Full Report + Source Code
issue/IssueLabel.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 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 package org.turro.dossier.zul.issue;
19 
20 import org.turro.string.Strings;
21 import org.turro.dossier.entity.Issue;
22 import org.turro.dossier.issue.IssueWrapper;
23 import org.turro.dossier.zul.menu.DossierMenu;
24 import org.turro.elephant.context.Application;
25 import org.turro.i18n.I_;
26 import org.zkoss.zk.ui.event.Event;
27 import org.zkoss.zk.ui.event.EventListener;
28 import org.zkoss.zk.ui.event.Events;
29 import org.zkoss.zk.ui.ext.AfterCompose;
30 import org.zkoss.zul.A;
31 
36 public class IssueLabel extends A implements AfterCompose {
37 
38  private Issue entity;
39 
40  public IssueLabel(Issue entity) {
41  setIssue(entity);
42  afterCompose();
43  }
44 
45  public IssueLabel() {
46  }
47 
48  public void setIssue(Issue issue) {
49  entity = issue;
50  setLabel(entity.getDescription());
51  if(Strings.isBlank(getLabel())) {
52  setLabel(I_.get("No description!"));
53  }
54  setImage("/_zul/images/issue.png");
55  }
56 
57  private void addClickListener() {
58  addEventListener(Events.ON_CLICK, new EventListener() {
59  @Override
60  public void onEvent(Event event) throws Exception {
61  DossierMenu.showIssue(entity.getId());
62  }
63  });
64  }
65 
66  @Override
67  public void afterCompose() {
69  IssueWrapper iw = new IssueWrapper(entity);
70  if(app.isInRole("issue:show") &&
71  (app.isInRole("issue:all") || iw.isFullParticipant())) {
72  addClickListener();
73  }
74  }
75 
76 }
static String get(String msg)
Definition: I_.java:41