BrightSide Workbench Full Report + Source Code
elephant/src/main/java/org/turro/plugin/command/CalendarEventPlugin.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2013 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.plugin.command;
20 
21 import java.util.Collection;
22 import java.util.Date;
23 import java.util.HashMap;
24 import java.util.Map;
25 import org.turro.action.DefaultPlugin;
26 import org.turro.action.Plugins;
27 import org.turro.plugin.contacts.IContact;
28 
33 public abstract class CalendarEventPlugin extends DefaultPlugin {
34 
35  public static final int
36  CREATE = 1, // click or drag on empty cell
37  EDIT = 2, // click on occupied cell
38  UPDATE = 3; // drag on occupied cell
39 
40  @Override
41  public String getName() {
42  return "CalendarEvent";
43  }
44 
45  @Override
46  public boolean stopPropagating() {
47  return false;
48  }
49 
50  public IContact getContact() {
51  return (IContact) params.get("contact");
52  }
53 
54  public Date getOldFrom() {
55  return (Date) params.get("oldFrom");
56  }
57 
58  public Date getOldTo() {
59  return (Date) params.get("oldTo");
60  }
61 
62  public Date getFrom() {
63  return (Date) params.get("from");
64  }
65 
66  public Date getTo() {
67  return (Date) params.get("to");
68  }
69 
70  public String getPath() {
71  return (String) params.get("path");
72  }
73 
74  public Integer getMode() {
75  return (Integer) params.get("mode");
76  }
77 
78  @Override
79  public void execute() {
80  executePlugin();
81  }
82 
83  protected abstract void executePlugin();
84 
85  public static Collection<Object> getCalendarEventFor(IContact contact,
86  Date oldFrom, Date oldTo, Date from, Date to, String path, int mode) {
87  Map<String, Object> args = new HashMap<>();
88  args.put("contact", contact);
89  args.put("oldFrom", oldFrom);
90  args.put("oldTo", oldTo);
91  args.put("from", from);
92  args.put("to", to);
93  args.put("path", path);
94  args.put("mode", mode);
95  args = Plugins.execute("CalendarEvent", args);
96  return args.values();
97  }
98 
99 }
100 
static Map< String, Object > execute(String name, Map params)
Definition: Plugins.java:44
static Collection< Object > getCalendarEventFor(IContact contact, Date oldFrom, Date oldTo, Date from, Date to, String path, int mode)