[830] | 1 | package de.dass_it.vanhelsing.gui;
|
---|
| 2 |
|
---|
[856] | 3 |
|
---|
| 4 |
|
---|
| 5 | import javax.faces.application.FacesMessage;
|
---|
| 6 | import javax.faces.application.FacesMessage.Severity;
|
---|
[848] | 7 | import javax.faces.context.FacesContext;
|
---|
[856] | 8 | import javax.faces.model.SelectItem;
|
---|
| 9 | import java.util.ResourceBundle;
|
---|
[857] | 10 | import java.util.Locale;
|
---|
[832] | 11 |
|
---|
[848] | 12 |
|
---|
[856] | 13 |
|
---|
[832] | 14 | //import org.apache.log4j.Logger;
|
---|
| 15 |
|
---|
[830] | 16 | /*
|
---|
| 17 | * Helper class to encapsulate common bean methods.
|
---|
| 18 | * Managed beans will extend this class either directly or
|
---|
| 19 | * via a data structure helper class like TreeNavigation
|
---|
| 20 | */
|
---|
| 21 | public class BeanUtil {
|
---|
[832] | 22 | //Logging
|
---|
| 23 |
|
---|
| 24 | //protected final Logger logger = Logger.getLogger(this.getClass());
|
---|
| 25 |
|
---|
| 26 | //Messagebundles
|
---|
[857] | 27 | public static String getProperty(String key){
|
---|
| 28 | String s = PropertyBundle.getProperty(key);
|
---|
| 29 | return s;
|
---|
| 30 | }
|
---|
[856] | 31 |
|
---|
[857] | 32 | public static String[] getProperties(String key){
|
---|
| 33 | String[] suffix = {"ref", "type", "required", "def"};
|
---|
| 34 | String[] bundle = new String[4];
|
---|
| 35 | for (int i = 0; i < 4; i++) {
|
---|
| 36 | bundle[i] = BeanUtil.getProperty(key+"."+suffix[i]);
|
---|
| 37 | }
|
---|
| 38 | return bundle;
|
---|
| 39 | }
|
---|
| 40 | //getRenderer returns rendererType based on properties
|
---|
| 41 | public static String getRenderer(String type, String key){
|
---|
| 42 | String daemon = "director";
|
---|
| 43 | String res = "inputText";
|
---|
| 44 | if (type.startsWith("SD")){
|
---|
| 45 | daemon = "storagedaemon";
|
---|
| 46 | }
|
---|
| 47 | if (type.startsWith("FD")){
|
---|
| 48 | daemon = "filedaemon";
|
---|
| 49 | }
|
---|
| 50 | type = type.toLowerCase();
|
---|
| 51 | key = key.toLowerCase();
|
---|
| 52 | String result[] = getProperties((daemon+"."+type+"."+key));
|
---|
| 53 | if (result[1].equals("boolean")){
|
---|
| 54 | return "radioGroup";
|
---|
| 55 | }
|
---|
| 56 | if (!(result[0].equals("0"))){
|
---|
| 57 | return "selectOneMenu";
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | return res;
|
---|
| 61 | }
|
---|
[856] | 62 | //Statusmeldungen an den Client
|
---|
| 63 | public static void setInfoMessage(String client, String message){
|
---|
| 64 | FacesContext.getCurrentInstance().addMessage(client, new FacesMessage(FacesMessage.SEVERITY_INFO, message, message));
|
---|
| 65 | }
|
---|
| 66 | public static void setErrorMessage(String client, String message){
|
---|
| 67 | FacesContext.getCurrentInstance().addMessage(client, new FacesMessage(FacesMessage.SEVERITY_ERROR, message, message));
|
---|
| 68 | }
|
---|
[832] | 69 |
|
---|
| 70 | //Linkout to Bacula documentation
|
---|
| 71 | //ListItemsConfigView
|
---|
| 72 | //ListItemsTopologyView
|
---|
| 73 | //ListItemsJobSchedule
|
---|
[848] | 74 |
|
---|
| 75 | //GetParameterFromContext
|
---|
| 76 | public static String getRequestParameter(String name){
|
---|
| 77 | return (String) FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get(name);
|
---|
| 78 | }
|
---|
[856] | 79 |
|
---|
[830] | 80 | }
|
---|