コード例 #1
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();
 }
コード例 #2
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;
 }
コード例 #3
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();
 }
コード例 #4
0
 /**
  * Determine the editing language.
  *
  * @return The text shown, i18n.
  */
 public String getEditingLanguage(Panel panel) {
   String lang =
       (String) SessionManager.getPanelSession(panel).getAttribute(ATTR_EDITING_LANGUAGE);
   return lang == null ? LocaleManager.lookup().getDefaultLang() : lang;
 }
コード例 #5
0
 /** Defines the action to be taken when activating edit mode */
 public void activateNormalMode(Panel panel, CommandRequest request) throws Exception {
   super.activateNormalMode(panel, request);
   SessionManager.getPanelSession(panel).removeAttribute(ATTR_TEXT);
   SessionManager.getPanelSession(panel).removeAttribute(ATTR_EDITING_LANGUAGE);
 }
コード例 #6
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));
 }