xlawrence    2005/10/28 10:41:42 CEST

  Modified files:
    core/src/java/org/jahia/gui HTMLToolBox.java 
  Log:
  created method "drawingchecks" to avoid duplicate code in beginActionMenu and 
endActionMenu. All the checks to see if we have to display the action menus and 
the fieldset should be put in that method
  
  Revision  Changes    Path
  1.31      +32 -73    jahia/core/src/java/org/jahia/gui/HTMLToolBox.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/gui/HTMLToolBox.java.diff?r1=1.30&r2=1.31&f=h
  
  
  
  Index: HTMLToolBox.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/core/src/java/org/jahia/gui/HTMLToolBox.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- HTMLToolBox.java  28 Oct 2005 08:24:10 -0000      1.30
  +++ HTMLToolBox.java  28 Oct 2005 08:41:42 -0000      1.31
  @@ -1049,32 +1049,10 @@
               final JspWriter out)
               throws IOException {
   
  -        if (! ProcessingContext.EDIT.equals(jParams.getOperationMode())) {
  -            // if we are not in edit mode we don't display the GUI
  +        if (! drawingChecks(contentObject)) {
               return;
           }
   
  -        try {
  -            if (contentObject == null) {
  -                // No object -> No menu...
  -                return;
  -            }
  -
  -            if (contentObject.getID() > 0 &&
  -                    ! contentObject.getACL().getPermission(jParams.getUser(),
  -                            JahiaBaseACL.WRITE_RIGHTS)) {
  -                // if the user doesn't have Write access on the object, 
don't display the GUI
  -                return;
  -            }
  -
  -            if (contentObject.getParent() != null && 
contentObject.getParent().isPicker()) {
  -                return;
  -            }
  -        } catch (JahiaException e) {
  -            logger.error(e.getMessage(), e);
  -            return;
  -        }
  -        
           final String menuID = beginAjaxMenu(contentObject, actionIcon,
                   useFieldSet, resourceBundle, labelKey, out);
           
  @@ -1083,10 +1061,9 @@
           props.put("resourceBundle", resourceBundle);
           props.put("lockIcon", lockIcon);
           
  -        BeanFactory bf = SpringContextSingleton.getInstance().getContext();
  +        final BeanFactory bf = 
SpringContextSingleton.getInstance().getContext();
           menuIdPropsBean menuIdProps = 
(menuIdPropsBean)bf.getBean("org.jahia.gui.menuIdPropsBean");
           menuIdProps.put(menuID, props);
  -
       }
       
       /**
  @@ -1113,54 +1090,31 @@
               final JspWriter out) instead
        */
       public void drawEndActionMenu(final ContentBean contentObject,
  -            final String lockIcon,
  -            final String actionIcon,
  -            final boolean useFieldSet,
  -            final String namePostFix,
  -            final String resourceBundle,
  -            final String labelKey,
  -            final JspWriter out)
  +                                  final String lockIcon,
  +                                  final String actionIcon,
  +                                  final boolean useFieldSet,
  +                                  final String namePostFix,
  +                                  final String resourceBundle,
  +                                  final String labelKey,
  +                                  final JspWriter out)
               throws IOException {
   
  -        if (!ProcessingContext.EDIT.equals(jParams.getOperationMode())) {
  -            // if we are not in edit mode we don't display the GUI
  -            return;
  -        }
  -
  -        if (contentObject == null) {
  -            // No object -> No menu...
  -            return;
  -        }
  -
  -        try {
  -            if (contentObject.getID() > 0 &&
  -                    ! contentObject.getACL().getPermission(jParams.getUser(),
  -                            JahiaBaseACL.WRITE_RIGHTS)) {
  -                // if the user doesn't have Write access on the object, 
don't display the GUI
  -                return;
  -            }
  -        } catch (Throwable t) {
  -            logger.error(t.getMessage(), t);
  -        }
  -
  -        if (contentObject.getParent() != null && 
contentObject.getParent().isPicker()) {
  -            return;
  -        }
  -
  -        endAjaxMenu(useFieldSet, out);
  +        if (drawingChecks(contentObject))
  +            endAjaxMenu(useFieldSet, out);
       }
  -    
  +
       /**
        * Generates the HTML for the end of the action menu, closing the
        * box around the content object if we started one.
  +     *
        * @param contentObject the content object for which to generate the
  -     * action menu
  -     * @param useFieldSet use to specify when an HTML field set box should
  -     *                    be generated around the content object
  -     * @param out the output JspWriter in which the HTML output will be
  -     *            generated.
  +     *                      action menu
  +     * @param useFieldSet   use to specify when an HTML field set box should
  +     *                      be generated around the content object
  +     * @param out           the output JspWriter in which the HTML output 
will be
  +     *                      generated.
        * @throws IOException thrown if there was an error while writing to
  -     * the output (such as a socket that's been disconnected).
  +     *                     the output (such as a socket that's been 
disconnected).
        */
       public void drawEndActionMenu(
               final ContentBean contentObject,
  @@ -1168,14 +1122,22 @@
               final JspWriter out)
               throws IOException {
   
  +        if (drawingChecks(contentObject))
  +            endAjaxMenu(useFieldSet, out);
  +    }
  +
  +    /**
  +     * Checks whether we must draw the action menu or not
  +     */
  +    private boolean drawingChecks(final ContentBean contentObject) {
           if (!ProcessingContext.EDIT.equals(jParams.getOperationMode())) {
               // if we are not in edit mode we don't display the GUI
  -            return;
  +            return false;
           }
   
           if (contentObject == null) {
               // No object -> No menu...
  -            return;
  +            return false;
           }
   
           try {
  @@ -1183,17 +1145,14 @@
                       ! contentObject.getACL().getPermission(jParams.getUser(),
                               JahiaBaseACL.WRITE_RIGHTS)) {
                   // if the user doesn't have Write access on the object, 
don't display the GUI
  -                return;
  +                return false;
               }
           } catch (Throwable t) {
               logger.error(t.getMessage(), t);
  +            return false;
           }
   
  -        if (contentObject.getParent() != null && 
contentObject.getParent().isPicker()) {
  -            return;
  -        }
  -
  -        endAjaxMenu(useFieldSet, out);
  +        return !(contentObject.getParent() != null && 
contentObject.getParent().isPicker());
       }
       
       /**
  

Reply via email to