BrightSide Workbench Full Report + Source Code
contacts/src/main/java/org/turro/zul/log/LogButton.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.Toolbarbutton;
31 
36 //@ElephantPlugin(label="button")
37 @Deprecated
38 public class LogButton extends Toolbarbutton 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 boolean _initialized;
73 
74  private void initializeButton() {
75  if(!Strings.isBlank(name)) {
76  setImage("/_zul/images/log_contact.png");
77  setTooltiptext(I_.get("Log") + ": " + I_.get("Contact"));
78  } else {
79  setImage("/_zul/images/log.png");
80  setTooltiptext(I_.get("Log") + ": " + I_.get("Entity"));
81  }
82  if(!_initialized) {
83  _initialized = true;
84  addEventListener(Events.ON_CLICK, new EventListener() {
85  @Override
86  public void onEvent(Event event) throws Exception {
87  Framework.getCurrent().getDesktop().removeAttribute("logPath");
88  Framework.getCurrent().getDesktop().removeAttribute("logName");
89  if(!Strings.isBlank(path)) {
90  Framework.getCurrent().getDesktop().setAttribute("logPath", path);
91  } else if(!Strings.isBlank(name)) {
92  Framework.getCurrent().getDesktop().setAttribute("logName", name);
93  }
94  ElephantMenu.showModalZulFile(
95  "@" + (!Strings.isBlank(path) ? pathName : name),
96  "/log/logNavigator.zul", null);
97  }
98  });
99  }
100  }
101 }
static IElephantEntity getController(String path)
Definition: Entities.java:78
static String get(String msg)
Definition: I_.java:41