Fixed 30054: Cleanup warnings in wad-generated code
authorStefan Hühner <stefan.huehner@openbravo.com>
Sun, 31 May 2015 13:33:21 +0200
changeset 26842 ada6ae238e94
parent 26841 cb3442689716
child 26843 1474b680f216
Fixed 30054: Cleanup warnings in wad-generated code

Goal is not to make wad-generated code nicer (as it should go away).
But instead to reduce the big number of eclipse warnings in it.
So they get out of the way when looking at warning in other code

Changes:
- remove java.util.Arrays & java.util.List imports and covered by existing
java.util.* import
- The other 'unused' code warnings are not so easy to fix so in context of wad
supress all 'unused' warnings in the srcAD files on class level.
As secondary change remove to existing more specific unused annotation
as they triggered warnings themselves (and are covered by the new one anyway)
- Remove private log4j Logger declaration. It shadows a similar one coming
inherited from HttpBaseServer. That one is defined as non-static via
this.getClass so is already of the instance we want (the concrete window-
servlet). That means logger functionally works as before (you can still
set i.e. debug level logging for individual servlet as before).
- in printPageEdit function a parameter was being assigned to in the function
quite often. Apparently those cannot be surpressed. After checking easy to fix
- All caller use just simple constant on every call.
- So add local variable on top of function and copy param value.
- Keep existing param name as variable name to reduce diff of generated code.

Together those reduce number of warnings in srcAD from hundreds down to just 14.
src-wad/src/org/openbravo/wad/javasource.javaxml
--- a/src-wad/src/org/openbravo/wad/javasource.javaxml	Sat May 30 20:59:23 2015 +0200
+++ b/src-wad/src/org/openbravo/wad/javasource.javaxml	Sun May 31 13:33:21 2015 +0200
@@ -49,15 +49,12 @@
 import javax.servlet.http.*;
 import java.util.*;
 import java.sql.Connection;
-import org.apache.log4j.Logger;
-import java.util.List;
-import java.util.Arrays;
 
+// Generated old code, not worth to make i.e. java imports perfect
+@SuppressWarnings("unused")
 public class <PARAMETER_TMP id="class">Almacen</PARAMETER_TMP> extends HttpSecureAppServlet {
   private static final long serialVersionUID = 1L;
   
-  private static Logger log4j = Logger.getLogger(<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>.class);
-  
   private static final String windowId = "<PARAMETER_TMP id="windowId">Almacen</PARAMETER_TMP>";
   private static final String tabId = "<PARAMETER_TMP id="tabId">Almacen</PARAMETER_TMP>";
   private static final String defaultTabView = "<PARAMETER_TMP id="defaultView">RELATION</PARAMETER_TMP>";
@@ -294,7 +291,6 @@
     } else if (vars.commandIn("EDIT")) {
 <PARAMETER_TMP id="parent">      String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP> = vars.getGlobalVariable("inp<PARENT_TMP id="keyParentINP">Almacen</PARENT_TMP>", windowId + "|<PARENT_TMP id="keyParent">Almacen</PARENT_TMP>");
 </PARAMETER_TMP>
-      @SuppressWarnings("unused") // In Expense Invoice tab this variable is not used, to be fixed
       String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = vars.getGlobalVariable("inp<KEY_TMP id="keyData">PosicionAlmacen</KEY_TMP>", windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>", "");
       vars.setSessionValue(tabId + "|<PARAMETER_TMP id="class">Almacen</PARAMETER_TMP>.view", "EDIT");
 <PARAMETERS_TMP id="NothasReference">
@@ -503,7 +499,6 @@
 </FIELDS_TMP>
 <FIELDS_TMP id="sectionActionButtons3">    } else if (vars.commandIn("SAVE_BUTTON<FIELD_TMP id="ButtonRealName3">button</FIELD_TMP><FIELD_TMP id="ProcessID3">button</FIELD_TMP>")) {
         String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP> = vars.getGlobalVariable("inpKey", windowId + "|<KEY_TMP id="key">PosicionAlmacen</KEY_TMP>", "");
-        @SuppressWarnings("unused")
         String str<FIELD_TMP id="ButtonName3">name</FIELD_TMP> = vars.getStringParameter("inp<FIELD_TMP id="ButtonName3">name</FIELD_TMP>");
         String strProcessing = vars.getStringParameter("inpprocessing");
         OBError myMessage = null;
@@ -959,10 +954,13 @@
     out.close();
   }
 
-  private void printPageEdit(HttpServletResponse response, HttpServletRequest request, VariablesSecureApp vars,boolean boolNew, String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP><PARAMETER_TMP id="parent">, String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, TableSQLData tableSQL)
+  private void printPageEdit(HttpServletResponse response, HttpServletRequest request, VariablesSecureApp vars,boolean _boolNew, String str<KEY_TMP id="key">PosicionAlmacen</KEY_TMP><PARAMETER_TMP id="parent">, String strP<PARENT_TMP id="keyParent">Almacen</PARENT_TMP></PARAMETER_TMP>, TableSQLData tableSQL)
     throws IOException, ServletException {
     if (log4j.isDebugEnabled()) log4j.debug("Output: edit");
     
+    // copy param to variable as will be modified later
+    boolean boolNew = _boolNew;
+
     HashMap&#60;String, String&#62; usedButtonShortCuts;
   <PARAMETER_TMP id="buttonFixed">
     HashMap&#60;String, String&#62; reservedButtonShortCuts;