Пример #1
0
 /**
  * Determine the text being shown for given panel.
  *
  * @param panel
  * @return The text shown, i18n.
  */
 public Map getHtmlCode(Panel panel) {
   PanelSession pSession = SessionManager.getPanelSession(panel);
   Map m = (Map) pSession.getAttribute(ATTR_TEXT);
   if (m != null) return m;
   HTMLText text = load(panel.getInstance());
   if (text != null) return text.getText();
   try {
     HTMLText textToCreate = new HTMLText();
     textToCreate.setPanelInstance(panel.getInstance());
     Locale[] locales = LocaleManager.lookup().getPlatformAvailableLocales();
     for (int i = 0; i < locales.length; i++) {
       Locale locale = locales[i];
       ResourceBundle i18n =
           localeManager.getBundle("org.jboss.dashboard.ui.panel.advancedHTML.messages", locale);
       textToCreate.setText(locale.getLanguage(), i18n.getString("defaultContent"));
     }
     textToCreate.save();
   } catch (Exception e) {
     log.error("Error creating empty text for panel: ", e);
   }
   text = load(panel.getInstance());
   if (text != null) return text.getText();
   log.error("Current HTML code is null for panel " + panel);
   return null;
 }
Пример #2
0
 public CommandResponse actionSaveChanges(Panel panel, CommandRequest request) throws Exception {
   String currentText = request.getRequestObject().getParameter(PARAMETER_HTML);
   Map m = (Map) SessionManager.getPanelSession(panel).getAttribute(ATTR_TEXT);
   HTMLText text = load(panel.getInstance());
   for (Iterator it = m.keySet().iterator(); it.hasNext(); ) {
     String lang = (String) it.next();
     String val = (String) m.get(lang);
     text.setText(lang, val);
   }
   text.setText(getEditingLanguage(panel), currentText);
   text.save();
   activateNormalMode(panel, request);
   return new ShowPanelPage();
 }
Пример #3
0
 public CommandResponse actionChangeEditingLanguage(Panel panel, CommandRequest request)
     throws Exception {
   String currentText = request.getRequestObject().getParameter(PARAMETER_HTML);
   Map text = (Map) SessionManager.getPanelSession(panel).getAttribute(ATTR_TEXT);
   if (text == null) {
     text = toEditableObject(load(panel.getInstance()));
     SessionManager.getPanelSession(panel).setAttribute(ATTR_TEXT, text);
   }
   text.put(getEditingLanguage(panel), currentText);
   SessionManager.getPanelSession(panel).setAttribute(ATTR_TEXT, text);
   String paramLang = request.getRequestObject().getParameter(PARAMETER_EDITING_LANG);
   SessionManager.getPanelSession(panel).setAttribute(ATTR_EDITING_LANGUAGE, paramLang);
   return new ShowPanelPage();
 }
Пример #4
0
 /** Defines the action to be taken when activating edit mode */
 public void activateEditMode(Panel panel, CommandRequest request) throws Exception {
   super.activateEditMode(panel, request);
   HTMLText text = load(panel.getInstance());
   SessionManager.getPanelSession(panel).setAttribute(ATTR_TEXT, toEditableObject(text));
 }
 protected boolean isPanelOk(Panel panel) {
   if (panel == null) return false;
   if (panel.getInstance() == null) return false;
   if (panel.getProvider() == null) return false;
   return true;
 }