BrightSide Workbench Full Report + Source Code
contacts/src/main/java/org/turro/zul/log/LogAnchor.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.zul.log;
19 
20 import org.turro.string.Strings;
21 import org.turro.entities.Entities;
22 import org.turro.entities.IElephantEntity;
23 import org.turro.i18n.I_;
24 import org.turro.menu.ElephantMenu;
25 import org.turro.plugin.log.ILogInfo;
26 import org.turro.zul.frame.Framework;
27 import org.zkoss.zk.ui.event.Event;
28 import org.zkoss.zk.ui.event.EventListener;
29 import org.zkoss.zk.ui.event.Events;
30 import org.zkoss.zul.A;
31 
36 //@ElephantPlugin(label="anchor")
37 @Deprecated
38 public class LogAnchor extends A implements ILogInfo {
39 
40  private Object entity;
41  private String path, pathName, name;
42 
43  @Override
44  public Object getEntity() {
45  return entity;
46  }
47 
48  @Override
49  public void setEntity(Object entity) {
50  this.entity = entity;
51  if(entity instanceof String) {
52  path = (String) entity;
53  } else {
55  path = iee.getPath();
56  pathName = iee.getName();
57  }
58  initializeButton();
59  }
60 
61  @Override
62  public String getName() {
63  return name;
64  }
65 
66  @Override
67  public void setName(String name) {
68  this.name = name;
69  initializeButton();
70  }
71 
72  private void initializeButton() {
73  if(!Strings.isBlank(name)) {
74  setImage("/_zul/images/log_contact.png");
75  setTooltiptext(I_.get("Log") + ": " + I_.get("Contact"));
76  } else {
77  setImage("/_zul/images/log.png");
78  setTooltiptext(I_.get("Log") + ": " + I_.get("Entity"));
79  }
80  addEventListener(Events.ON_CLICK, new EventListener() {
81  @Override
82  public void onEvent(Event event) throws Exception {
83  Framework.getCurrent().getDesktop().removeAttribute("logPath");
84  Framework.getCurrent().getDesktop().removeAttribute("logName");
85  if(!Strings.isBlank(path)) {
86  Framework.getCurrent().getDesktop().setAttribute("logPath", path);
87  } else if(!Strings.isBlank(name)) {
88  Framework.getCurrent().getDesktop().setAttribute("logName", name);
89  }
90  ElephantMenu.showModalZulFile(
91  "@" + (!Strings.isBlank(path) ? pathName : name),
92  "/log/logNavigator.zul", null);
93  }
94  });
95  }
96 }
static IElephantEntity getController(String path)
Definition: Entities.java:78
static String get(String msg)
Definition: I_.java:41