BrightSide Workbench Full Report + Source Code
elephant-dossier/src/main/java/org/turro/issue/wizard/DescriptionPanel.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.issue.wizard;
20 
21 import org.turro.string.Strings;
22 import org.turro.auth.Authentication;
23 import org.turro.dossier.dossier.DossierCombobox;
24 import org.turro.dossier.entity.IssueParticipant;
25 import org.turro.dossier.issue.IssueWrapper;
26 import org.turro.dossier.zul.dossier.DossierVersionListbox;
27 import org.turro.dossier.zul.issue.GroupingCombobox;
28 import org.turro.dossier.zul.issue.IssuePriorityListbox;
29 import org.turro.dossier.zul.issue.IssueTypeListbox;
30 import org.turro.elephant.context.Application;
31 import org.turro.i18n.I_;
32 import org.turro.registry.BooleanChange;
33 import org.turro.registry.ChangeCategory;
34 import org.turro.registry.EnumChange;
35 import org.turro.registry.StringChange;
36 import org.turro.registry.UniqueString;
37 import org.turro.zkoss.wizard.WizardPanelComposer;
38 import org.zkoss.zul.Checkbox;
39 import org.zkoss.zul.Textbox;
40 
45 public class DescriptionPanel extends WizardPanelComposer {
46 
47  private Textbox name;
48  private IssueTypeListbox type;
49  private GroupingCombobox grouping;
50  private IssuePriorityListbox priority;
51  private DossierCombobox dossier;
52  private DossierVersionListbox version;
53  private Checkbox publishable, milestone;
54 
55  @Override
56  public boolean doEnter() {
59  dossier.setObjectValue(iw.issue.getDossier());
60  dossier.setReadonly(!app.isInRole("issue:dossier"));
61  version.setDossier(dossier.getObjectValue());
62  if(iw.issue.getVersion() != null) {
63  version.setObjectValue(iw.issue.getVersion());
64  }
65  name.setValue(iw.issue.getDescription());
66  type.setObjectValue(iw.issue.getType());
67  grouping.setObjectValue(iw.issue.getGrouping());
68  priority.setObjectValue(iw.issue.getPriority());
69  publishable.setChecked(iw.issue.isPublishable());
70  milestone.setChecked(iw.issue.isMilestone());
71  return true;
72  }
73 
74  @Override
75  public boolean doLeave(boolean forwards) {
76  ChangeCategory issueCat = new ChangeCategory(2, I_.get("Changes"));
78  ChangeCategory cc = new ChangeCategory(4, I_.get("Participants"));
80  IssueWrapper wrapper = new IssueWrapper(iw.issue);
81  iw.changes.addChange(new StringChange(issueCat, I_.get("Dossier"),
82  iw.issue.getDossier() != null ? iw.issue.getDossier().getDescription() : "",
83  dossier.getObjectValue() != null ? dossier.getObjectValue().getDescription() : ""));
84  iw.issue.setDossier(dossier.getObjectValue());
85  iw.changes.addChange(new StringChange(issueCat, I_.get("Version"),
86  iw.issue.getVersion() == null ? null : iw.issue.getVersion().getVersionId(),
87  version.getObjectValue() == null ? null : version.getObjectValue().getVersionId()));
88  iw.issue.setVersion(version.getObjectValue());
89  iw.changes.addChange(new StringChange(issueCat, I_.get("Description"),
90  iw.issue.getDescription(), name.getValue()));
91  iw.issue.setDescription(name.getValue());
92  iw.changes.addChange(new EnumChange(issueCat, I_.get("Type"),
93  iw.issue.getType(), type.getObjectValue()));
94  iw.issue.setType(type.getObjectValue());
95  iw.changes.addChange(new StringChange(issueCat, I_.get("Grouping"),
96  iw.issue.getGrouping(), grouping.getObjectValue()));
97  iw.issue.setGrouping(grouping.getObjectValue());
98  iw.changes.addChange(new EnumChange(issueCat, I_.get("Priority"),
99  iw.issue.getPriority(), priority.getObjectValue()));
100  iw.issue.setPriority(priority.getObjectValue());
101  iw.changes.addChange(new BooleanChange(issueCat, I_.get("Publishable"),
102  iw.issue.isPublishable(), publishable.isChecked()));
103  iw.issue.setPublishable(publishable.isChecked());
104  iw.changes.addChange(new BooleanChange(issueCat, I_.get("Milestone"),
105  iw.issue.isMilestone(), milestone.isChecked()));
106  iw.issue.setMilestone(milestone.isChecked());
107  if(!wrapper.hasReporter()) {
109  iw.changes.addChange(new UniqueString(cc, I_.byKey(ip.getRole().toString()), ip.getName()));
110  }
111  if(!wrapper.hasResponsible()) {
112  IssueParticipant ip = null;
113  if(app.isInRole("issue:participants")) {
114  //if can see participants
116  } else if(iw.issue.getDossier() != null) {
117  // otherwise, assign responsible to the first owner encountered
119  }
120  iw.changes.addChange(new UniqueString(cc, I_.byKey(ip.getRole().toString()), ip.getName()));
121  }
122  return !forwards || (
123  iw.issue.getDossier() != null &&
124  !Strings.isBlank(iw.issue.getDescription()));
125  }
126 
127  public void onChange$dossier() {
128  version.setDossier(dossier.getObjectValue());
129  }
130 
131 }
void setPublishable(boolean publishable)
Definition: Issue.java:218
void setMilestone(boolean milestone)
Definition: Issue.java:194
void setType(IssueType type)
Definition: Issue.java:295
IssuePriority getPriority()
Definition: Issue.java:206
void setDescription(String description)
Definition: Issue.java:154
IssueParticipant addReporter(Object contact)
Definition: Issue.java:397
void setVersion(DossierVersion version)
Definition: Issue.java:335
void setDossier(Dossier dossier)
Definition: Issue.java:162
void setPriority(IssuePriority priority)
Definition: Issue.java:210
IssueParticipant addResponsible(Object contact)
Definition: Issue.java:403
DossierVersion getVersion()
Definition: Issue.java:331
void setGrouping(String grouping)
Definition: Issue.java:263
static String byKey(String key)
Definition: I_.java:83
static String get(String msg)
Definition: I_.java:41