BrightSide Workbench Full Report + Source Code
RelatedPathsControl.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.zul.relpaths;
20 
21 import org.turro.contacts.RelatedPaths;
22 import org.turro.entities.Entities;
23 import org.turro.relpaths.RelatedPathsUtil;
24 import org.zkoss.zk.ui.HtmlBasedComponent;
25 import org.zkoss.zk.ui.event.Event;
26 import org.zkoss.zk.ui.event.EventListener;
27 import org.zkoss.zk.ui.event.Events;
28 import org.zkoss.zk.ui.ext.AfterCompose;
29 import org.zkoss.zul.Vlayout;
30 
35 @Deprecated
36 public class RelatedPathsControl extends Vlayout implements AfterCompose {
37 
38  private String entityPath;
39  private boolean allowMultiple = false, atRight = true;
40  private IAddRelatedPaths newControl = null;
41 
42  public String getEntityPath() {
43  return entityPath;
44  }
45 
46  public void setEntityPath(String entityPath) {
47  this.entityPath = entityPath;
48  }
49 
50  public void setEntity(Object entity) {
52  }
53 
54  public void setNewControl(IAddRelatedPaths newControl) {
55  this.newControl = newControl;
56  }
57 
58  public void setAllowMultiple(boolean allowMultiple) {
59  this.allowMultiple = allowMultiple;
60  }
61 
62  @Override
63  public void afterCompose() {
64  showRelations();
65  addEventListener(Events.ON_CHANGE, new EventListener<Event>() {
66  @Override
67  public void onEvent(Event event) throws Exception {
68  showRelations();
69  }
70  });
71  }
72 
73  private void showRelations() {
74  getChildren().clear();
75  HtmlBasedComponent tmpCtrl = (newControl != null ? newControl.getControl(this) : null);
76  for(RelatedPaths rp : RelatedPathsUtil.destinations(entityPath)) {
77  if(!allowMultiple) tmpCtrl = null;
78  appendChild(new RelatedPathsLine(rp, true, (atRight ? tmpCtrl : null)));
79  tmpCtrl = null;
80  }
81  for(RelatedPaths rp : RelatedPathsUtil.origins(entityPath)) {
82  if(!allowMultiple) tmpCtrl = null;
83  appendChild(new RelatedPathsLine(rp, false, (atRight ? tmpCtrl : null)));
84  tmpCtrl = null;
85  }
86  if(tmpCtrl != null) {
87  appendChild(tmpCtrl);
88  if(tmpCtrl instanceof AfterCompose) {
89  ((AfterCompose) tmpCtrl).afterCompose();
90  }
91  }
92  }
93 
94 }
static IElephantEntity getController(String path)
Definition: Entities.java:78
void setNewControl(IAddRelatedPaths newControl)