BrightSide Workbench Full Report + Source Code
IssueAttachTree.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.attach;
19 
20 import org.turro.attach.entity.Attachment;
21 import org.turro.attach.zul.control.AttachmentControl;
22 import org.turro.attach.zul.navigator.AttachNavigatorListener;
23 import org.turro.dossier.entity.Issue;
24 import org.turro.dossier.issue.IssueMail;
25 import org.turro.i18n.I_;
26 import org.turro.registry.ChangeCategory;
27 import org.turro.registry.Changes;
28 import org.turro.registry.StringChange;
29 import org.zkoss.zk.ui.ext.AfterCompose;
30 
35 public class IssueAttachTree extends AttachmentControl implements AfterCompose, AttachNavigatorListener {
36 
37  private Issue issue;
38  private Changes changes;
39 
40  public void setIssue(Issue issue) {
41  this.issue = issue;
42  super.setEntity(issue);
43  }
44 
45  public Changes getChanges() {
46  return changes;
47  }
48 
49  public void setChanges(Changes changes) {
50  this.changes = changes;
51  }
52 
53  @Override
54  public void afterCompose() {
55  super.afterCompose();
56  initialiaze();
57  }
58 
59  @Override
60  public void uploadDone(Attachment file) {
61  if(changes != null) {
62  ChangeCategory cc = new ChangeCategory(3, I_.get("Attachments"));
63  changes.addChange(new StringChange(cc, I_.get("Upload"), file.getFileName(), null, true));
64  } else {
65  new IssueMail(changes, issue, 0, 0, 0).sendMail();
66  }
67  }
68 
69  @Override
70  public void downloadDone(Attachment file) {
71  }
72 
73  @Override
74  public void deleteDone(Attachment file) {
75  if(changes != null) {
76  ChangeCategory cc = new ChangeCategory(3, I_.get("Attachments"));
77  changes.addChange(new StringChange(cc, I_.get("Delete"), file.getFileName(), null));
78  }
79  }
80 
81  private boolean initialized = false;
82 
83  private void initialiaze() {
84  if(issue != null && !initialized && getTreeFolder() != null) {
86  initialized = true;
87  }
88  }
89 
90 }
void setAttachListener(AttachNavigatorListener listener)
static String get(String msg)
Definition: I_.java:41