BrightSide Workbench Full Report + Source Code
IssueRow.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.dossier.entity.Issue;
21 import org.turro.dossier.entity.IssueStatus;
22 import org.turro.dossier.entity.IssueType;
23 import org.turro.dossier.issue.IssueWrapper;
24 import org.turro.dossier.zul.attach.IssueAttachTree;
25 import org.turro.dossier.zul.dossier.DossierLabel;
26 import org.turro.elephant.context.Application;
27 import org.turro.elephant.util.Messages;
28 import org.turro.i18n.I_;
29 import org.turro.log.SystemLogType;
30 import org.turro.log.SystemLogger;
31 import org.turro.registry.Changes;
32 import org.turro.zkoss.dialog.SelectionDialog;
33 import org.turro.zkoss.label.LabelExtended;
34 import org.turro.zkoss.label.LabelTypes;
35 import org.turro.zul.frame.Framework;
36 import org.zkoss.lang.Strings;
37 import org.zkoss.zk.ui.event.Event;
38 import org.zkoss.zk.ui.event.EventListener;
39 import org.zkoss.zk.ui.event.Events;
40 import org.zkoss.zul.*;
41 
46 public class IssueRow extends Row {
47 
48  @Override
49  public void setValue(Object value) {
50  super.setValue(value);
51 
52  final IssueWrapper wissue = (IssueWrapper) getValue();
53 
54  Hlayout hbox = new Hlayout();
55  appendChild(hbox);
56 
57  Image img = new Image(wissue.getTimmingImage());
58  hbox.appendChild(img);
59  Label label = new Label(wissue.getIssue().getId() + "");
60  hbox.appendChild(label);
61 
62  Vlayout vbox = new Vlayout();
63  appendChild(vbox);
64 
65  hbox = new Hlayout();
66  hbox.setSclass("z-valign-middle");
67  hbox.setValign("middle");
68  vbox.appendChild(hbox);
69 
70  img = new Image(wissue.getAlarmImage());
71  if(!Strings.isBlank(img.getSrc())) {
72  hbox.appendChild(img);
73  }
74  img = new Image(wissue.getPriorityImage());
75  if(!Strings.isBlank(img.getSrc())) {
76  hbox.appendChild(img);
77  }
78 
79  hbox.appendChild(new IssueLabel(wissue.getIssue()));
80 
81  if(wissue.getIssue().getVersion() != null) {
82  hbox.appendChild(LabelTypes.getTinyLabel(wissue.getIssue().getVersion().getVersionString()));
83  }
84 
85  hbox.appendChild(new Space());
86  hbox.appendChild(new AddInformation(wissue.getIssue()) {
87  @Override
88  protected void refreshBase() {
89  IssueRow.this.getChildren().clear();
90  IssueRow.this.setValue(wissue);
91  }
92  });
93 
94  if(wissue.getIssue().getDossier() != null) {
95  DossierLabel dl = new DossierLabel(wissue.getIssue().getDossier(), true);
96  dl.setSclass("softLabel");
97  vbox.appendChild(dl);
98  }
99 
100  if(IssueType.TYPE_DOCUMENT.equals(wissue.getIssue().getType())) {
101  //DocumentBox box = new DocumentBox();
102  Toolbarbutton a = new Toolbarbutton(I_.get("Attachments"), "/_zul/images/clip.png");
103  a.addEventListener(Events.ON_CLICK, new EventListener() {
104  @Override
105  public void onEvent(Event event) throws Exception {
106  IssueAttachTree iat = new IssueAttachTree();
107  iat.setEntity(wissue.getIssue());
108  iat.setChanges(new Changes());
109  SelectionDialog.showComponent(getPage(), I_.get("Attachments"),
110  iat, "80%", "80%", null);
111  }
112  });
113  //box.appendChild(a);
114  //box.setPath(DossierPU.getObjectPath(wissue.getIssue()));
115  vbox.appendChild(a);
116  //box.afterCompose();
117  }
118 
119  LabelExtended lext;
120 
121  if(!wissue.canStartBySources()) {
122  for(String s : wissue.getWaitingReason()) {
123  lext = new LabelExtended();
124  lext.setStyle("color:#444;font-size:11px;");
125  lext.setValue(s);
126  lext.setMaxChars(70);
127  lext.setShowTooltip(true);
128  vbox.appendChild(lext);
129  }
130  }
131 
132  lext = new LabelExtended();
133  lext.setDate(wissue.getIssue().getIssueDate());
134  appendChild(lext);
135 
136  lext = new LabelExtended();
137  lext.setDate(wissue.getIssue().getStartDate());
138  appendChild(lext);
139 
140  lext = new LabelExtended();
141  lext.setDate(wissue.getIssue().getDelivery());
142  appendChild(lext);
143 
144  lext = new LabelExtended();
145  lext.setDate(wissue.getIssue().getControlDate());
146  appendChild(lext);
147 
148  vbox = new Vlayout();
149  appendChild(vbox);
150 
151  lext = new LabelExtended();
152  lext.setStyle("color:navy");
153  lext.setResourceValue(wissue.getIssue().getType().toString());
154  vbox.appendChild(lext);
155 
156  lext = new LabelExtended();
157  lext.setResourceValue(wissue.getIssue().getStatus().toString());
158  vbox.appendChild(lext);
159 
160  if(wissue.getIssue().getStatus().isFinished()) {
161  lext = new LabelExtended();
162  lext.setStyle("color:gray");
163  lext.setResourceValue(wissue.getIssue().getResolution().toString());
164  vbox.appendChild(lext);
165  }
166 
167  if(Application.getApplication().isInRole("issue:delete")) {
168  img = new Image("/_zul/images/edit-delete.png");
169  img.setStyle("cursor:pointer");
170  img.addEventListener(Events.ON_CLICK, new EventListener() {
171  @Override
172  public void onEvent(Event event) throws Exception {
173  Messages.confirmDeletion().show(() -> {
174  SystemLogger.getInstance().doLog(SystemLogType.LOG_INFO, wissue.getIssue(), "deleted",
175  wissue.getIssue().getId() + " - " + wissue.getIssue().getDescription());
176  wissue.delete();
177  Framework.getCurrent().invalidateSelected();
178  });
179  }
180 
181  });
182  appendChild(img);
183  }
184 
185  if(value instanceof IssueWrapper) {
186  Issue i = ((IssueWrapper) value).getIssue();
187  if(i.getStatus() == IssueStatus.STATUS_NEW) {
188  setStyle("background-color: #f5eeee");
189  } else if(i.getStatus() == IssueStatus.STATUS_INCOMPLETE) {
190  setStyle("background-color: #f8eeee");
191  } else if(i.getStatus() == IssueStatus.STATUS_STARTED) {
192  setStyle("background-color: #fffff0");
193  } else if(i.getStatus() == IssueStatus.STATUS_REOPENED) {
194  setStyle("background-color: #f0f9e0");
195  } else if(i.getStatus() == IssueStatus.STATUS_RESOLVED) {
196  setStyle("background-color: #e0f5ee");
197  } else if(i.getStatus() == IssueStatus.STATUS_FROZEN) {
198  setStyle("background-color: #a0f5f5");
199  } else if(i.getStatus() == IssueStatus.STATUS_REUNION) {
200  setStyle("background-color: #e5e5a0");
201  } else if(i.getStatus() == IssueStatus.STATUS_CLOSED) {
202  setStyle("background-color: #ffffff");
203  }
204  }
205  }
206 
207 }
DossierVersion getVersion()
Definition: Issue.java:331
static Label getTinyLabel(String value)
Definition: LabelTypes.java:34