BrightSide Workbench Full Report + Source Code
ScheduleAnchor.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.scheduler.zul.entities;
19 
20 import org.turro.entities.Entities;
21 import org.turro.entities.IElephantEntity;
22 import org.turro.i18n.I_;
23 import org.turro.plugin.scheduler.ScheduledAction;
24 import org.turro.plugin.scheduler.ScheduledEdit;
25 import org.turro.scheduler.entities.ScheduledEntitySet;
26 import org.turro.zkoss.dialog.SelectionDialog;
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 public class ScheduleAnchor extends A {
37 
38  private Object entity;
39  private ScheduledEdit edit;
40  private String path, pathName;
41 
42  public Object getEntity() {
43  return entity;
44  }
45 
46  public void setEntity(Object entity) {
47  this.entity = entity;
48  if(entity instanceof ScheduledAction) {
50  path = iee.getPath();
51  pathName = iee.getName();
52  initializeButton();
53  } else {
54  setVisible(false);
55  }
56  }
57 
58  public void setEdit(ScheduledEdit edit) {
59  this.edit = edit;
60  }
61 
62  private void initializeButton() {
63  setImage("/_zul/images/scheduled.png");
64  addEventListener(Events.ON_CLICK, new EventListener() {
65  @Override
66  public void onEvent(Event event) throws Exception {
67  SelectionDialog.showComponent(getPage(), I_.get("Scheduled task"),
68  new TaskEdit(ScheduledEntitySet.getScheduledEntity(path), edit), "90%", "70%", null);
69  }
70  });
71  }
72 
73 }
static IElephantEntity getController(String path)
Definition: Entities.java:78
static String get(String msg)
Definition: I_.java:41
static ScheduledEntity getScheduledEntity(String path)
static void showComponent(Page page, String title, Component component, String width, String height, final Command command)