BrightSide Workbench Full Report + Source Code
PluginChecker.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.plugin;
19 
20 import org.turro.reflection.ReflectionUtil;
21 
26 public class PluginChecker {
27 
28  private static final String[][] plugs = {
29 // { "icontact", "org.turro.contacts.util.DefaultContact" },
30 // { "iuser", "org.turro.plugin.contacts.UserAsContact" },
31  { "vcard", "org.turro.vcard.util.VCardPlugin" },
32  { "publication", "org.turro.publication.util.PublicationPlugin" },
33  { "acceptctrl", "org.turro.zul.acceptance.AcceptanceButton" },
34  { "tagitctrl", "org.turro.zul.tagit.TagItButton" },
35  { "tagitlabel", "org.turro.zul.tagit.TagItLabel" },
36  { "tagitnav", "org.turro.zul.tagit.TagItNavigator" },
37  { "dossier", "org.turro.dossier.util.DossierImpl" },
38  { "dossierctrl", "org.turro.dossier.zul.util.DossierInfoByPath" },
39  { "issue", "org.turro.dossier.util.IssueImpl" },
40  { "issuectrl", "org.turro.dossier.zul.util.IssueInfoByPath" },
41  { "logctrl", "org.turro.zul.log.LogButton" },
42  { "loganchor", "org.turro.zul.log.LogAnchor" },
43  { "logloader", "org.turro.contacts.log.LogLoader" },
44  { "schedulectrl", "org.turro.scheduler.zul.entities.ScheduleButton" },
45  { "scheduleanchor", "org.turro.scheduler.zul.entities.ScheduleAnchor" }
46  };
47 
48 // public static IContact getIContact(String id) {
49 // if(!Strings.isBlank(id)) {
50 // IContact ic = getIContact();
51 // if(ic != null) {
52 // ic.loadById(id);
53 // }
54 // return ic;
55 // } else {
56 // return null;
57 // }
58 // }
59 //
60 // public static IContact getIContact() {
61 // IContact ic = (IContact) get("icontact");
62 // if(ic == null) ic = (IContact) get("iuser");
63 // return ic;
64 // }
65 
66 // public static IContact getLoggedIContact(IConstructor constructor) {
67 // IContact contact = PluginChecker.getIContact();
68 // try {
69 // contact.loadLogged(Application.getFromConstructor(constructor));
70 // } catch(Exception ex) {}
71 // return contact;
72 // }
73 
74  public static Object get(String key) {
75  for(String p[] : plugs) {
76  if(key.equals(p[0])) {
77  return ReflectionUtil.instance(ReflectionUtil.classCheck(p[1]));
78  }
79  }
80  return null;
81  }
82 
83  public static boolean exists(String key) {
84  for(String p[] : plugs) {
85  if(key.equals(p[0])) {
86  return ReflectionUtil.classCheck(p[1]) != null;
87  }
88  }
89  return false;
90  }
91 
92  private PluginChecker() {
93  }
94 
95 }
static boolean exists(String key)