Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 22.09 KB | None | 0 0
  1.   public static ManualTaskInformation getIhmInfo(Map<String, Object> infos,
  2.       List<ManuelTask> manualTasks, ManualTaskInformation manualTaskInformation)
  3.   {
  4.     Map<String, TicksViewerInfo> objectViewerMap = new HashMap<String, TicksViewerInfo>();
  5.     Map<String, TicksObjectInfo> objectInfoMap = new HashMap<String, TicksObjectInfo>();
  6.     manualTaskInformation.setNameViewerMap(objectViewerMap);
  7.     manualTaskInformation.setNameObjectMap(objectInfoMap);
  8.     for (ManuelTask manualTask : manualTasks)
  9.     {
  10.       if (manualTask.isIsForm())
  11.       {
  12.         List<String> widgetsCanBeEditable = PropManualTaskModelToForm.searchWidgetsCanBeEditable(manualTask);
  13.         CompositeInfo objectInfo = (CompositeInfo) JavaInfoProvider
  14.             .getJavaInfoOfFlowElement(manualTask, (IProject) infos.get(DiagramTransformationUtils.KEY_project));
  15.         if (objectInfo != null)
  16.         {
  17.           @SuppressWarnings("unchecked")
  18.           List<ImportDeclaration>  imports = objectInfo.getEditor().getAstUnit().imports();
  19.           for (ImportDeclaration o: imports)
  20.           {
  21.             if (o.getName().getFullyQualifiedName().endsWith("StackLayout"))
  22.             {
  23.               manualTaskInformation.setIsStackLayout(true);
  24.               break;
  25.             }
  26.            
  27.           }
  28.           // Rcuperation des viewer table et column
  29.           for (JavaInfo javaInfo : getJavaInfoFromForm(objectInfo))
  30.           {
  31.  
  32.             if (javaInfo instanceof ViewerInfo
  33.                 && javaInfo.getParent() instanceof TableInfo)
  34.             {
  35.               TicksTableViewerInfo tblVwr = new TicksTableViewerInfo();
  36.               tblVwr.setName(((TableInfo) javaInfo.getParent())
  37.                   .getVariableSupport().getName());
  38.               tblVwr.setViewerName(javaInfo.getVariableSupport().getName());
  39.               objectViewerMap.put(tblVwr.getName(), tblVwr);
  40.               try
  41.               {
  42.                 @SuppressWarnings("unchecked")
  43.                 TreeSet<String> object = (TreeSet<String>) ((CompositeInfo) javaInfo
  44.                     .getRootJava())
  45.                     .getEditor()
  46.                     .getAstUnit()
  47.                     .getProperty(
  48.                         "ASTNodeUtilities.getLocalMethodDeclaration.allMethods");
  49.  
  50.                 String getMethodName = "get"
  51.                     + StringUtils.upperFirstLetter(javaInfo
  52.                         .getVariableSupport().getName());
  53.                 if (!(object.contains(getMethodName)))
  54.                 {
  55.                   tblVwr.setGetterAccessible(false);
  56.                 }
  57.               }
  58.               catch (SecurityException e)
  59.               {
  60.                 tblVwr.setGetterAccessible(false);
  61.               }
  62.  
  63.             }
  64.             else if (javaInfo instanceof ViewerInfo
  65.                 && javaInfo.getParent() instanceof TreeInfo)
  66.             {
  67.               TicksTreeViewerInfo tblVwr = new TicksTreeViewerInfo();
  68.               tblVwr.setHasColumn(false);
  69.               tblVwr.setName(((TreeInfo) javaInfo.getParent())
  70.                   .getVariableSupport().getName());
  71.               tblVwr.setViewerName(javaInfo.getVariableSupport().getName());
  72.               objectViewerMap.put(tblVwr.getName(), tblVwr);
  73.               try
  74.               {
  75.                 @SuppressWarnings("unchecked")
  76.                 TreeSet<String> object = (TreeSet<String>) ((CompositeInfo) javaInfo
  77.                     .getRootJava())
  78.                     .getEditor()
  79.                     .getAstUnit()
  80.                     .getProperty(
  81.                         "ASTNodeUtilities.getLocalMethodDeclaration.allMethods");
  82.  
  83.                 String getMethodName = "get"
  84.                     + StringUtils.upperFirstLetter(javaInfo
  85.                         .getVariableSupport().getName());
  86.                 if (!(object.contains(getMethodName)))
  87.                 {
  88.                   tblVwr.setGetterAccessible(false);
  89.                 }
  90.               }
  91.               catch (SecurityException e)
  92.               {
  93.                 tblVwr.setGetterAccessible(false);
  94.               }
  95.  
  96.             }
  97.             else if (javaInfo instanceof ViewerColumnInfo
  98.                 && javaInfo.getParent() instanceof TableColumnInfo)
  99.             {
  100.               ViewerColumnInfo columnViewer = (ViewerColumnInfo) javaInfo;
  101.  
  102.               TicksTableColumnViewerInfo tblClmnVwr = new TicksTableColumnViewerInfo();
  103.               tblClmnVwr.setName(((ItemInfo) columnViewer.getParent())
  104.                   .getVariableSupport().getName());
  105.               tblClmnVwr.setViewerName(columnViewer.getVariableSupport()
  106.                   .getName());
  107.               tblClmnVwr
  108.                   .setParentViewerInfo((TicksTableViewerInfo) objectViewerMap
  109.                       .get(((TableInfo) (columnViewer.getParent().getParent()))
  110.                           .getVariableSupport().getName()));
  111.               objectViewerMap.put(tblClmnVwr.getName(), tblClmnVwr);
  112.               try
  113.               {
  114.                 @SuppressWarnings("unchecked")
  115.                 TreeSet<String> object = (TreeSet<String>) ((CompositeInfo) javaInfo
  116.                     .getRootJava())
  117.                     .getEditor()
  118.                     .getAstUnit()
  119.                     .getProperty(
  120.                         "ASTNodeUtilities.getLocalMethodDeclaration.allMethods");
  121.  
  122.                 String getMethodName = "get"
  123.                     + StringUtils.upperFirstLetter(javaInfo
  124.                         .getVariableSupport().getName());
  125.                 if (!(object.contains(getMethodName)))
  126.                 {
  127.                   tblClmnVwr.setGetterAccessible(false);
  128.                 }
  129.               }
  130.               catch (SecurityException e)
  131.               {
  132.                 tblClmnVwr.setGetterAccessible(false);
  133.               }
  134.               MethodInvocation miWithEditingSupport = javaInfo
  135.                       .getMethodInvocation("setWithEditingSupport(boolean)");
  136.               tblClmnVwr.setWithEditingSupportSet(miWithEditingSupport != null);
  137.             }
  138.             else if (javaInfo instanceof ViewerColumnInfo
  139.                 && javaInfo.getParent() instanceof TreeColumnInfo)
  140.             {
  141.               ViewerColumnInfo columnViewer = (ViewerColumnInfo) javaInfo;
  142.  
  143.               TicksTreeColumnViewerInfo tblClmnVwr = new TicksTreeColumnViewerInfo();
  144.               tblClmnVwr.setName(((ItemInfo) columnViewer.getParent())
  145.                   .getVariableSupport().getName());
  146.               tblClmnVwr.setViewerName(columnViewer.getVariableSupport()
  147.                   .getName());
  148.               TicksTreeViewerInfo parent = (TicksTreeViewerInfo) objectViewerMap
  149.                   .get(((TreeInfo) (columnViewer.getParent().getParent()))
  150.                       .getVariableSupport().getName());
  151.               tblClmnVwr.setParentViewerInfo(parent);
  152.               parent.setHasColumn(true);
  153.               objectViewerMap.put(tblClmnVwr.getName(), tblClmnVwr);
  154.               try
  155.               {
  156.                 @SuppressWarnings("unchecked")
  157.                 TreeSet<String> object = (TreeSet<String>) ((CompositeInfo) javaInfo
  158.                     .getRootJava())
  159.                     .getEditor()
  160.                     .getAstUnit()
  161.                     .getProperty(
  162.                         "ASTNodeUtilities.getLocalMethodDeclaration.allMethods");
  163.  
  164.                 String getMethodName = "get"
  165.                     + StringUtils.upperFirstLetter(javaInfo
  166.                         .getVariableSupport().getName());
  167.                 if (!(object.contains(getMethodName)))
  168.                 {
  169.                   tblClmnVwr.setGetterAccessible(false);
  170.                 }
  171.               }
  172.               catch (SecurityException e)
  173.               {
  174.                 tblClmnVwr.setGetterAccessible(false);
  175.               }
  176.               MethodInvocation miWithEditingSupport = javaInfo
  177.                       .getMethodInvocation("setWithEditingSupport(boolean)");
  178.               tblClmnVwr.setWithEditingSupportSet(miWithEditingSupport != null);
  179.             }
  180.             else if (javaInfo instanceof ComboViewerInfo)
  181.             {
  182.               ComboViewerInfo comboViewerInfo = (ComboViewerInfo) javaInfo;
  183.               TicksListViewerInfo ticksComboViewerInfo = new TicksListViewerInfo();
  184.               if (!(comboViewerInfo.toString().contains("READ_ONLY")))
  185.               {
  186.                 ticksComboViewerInfo.setIsEditable(Boolean.TRUE);
  187.               }
  188.               ticksComboViewerInfo.setIsCombo(Boolean.TRUE);
  189.               ticksComboViewerInfo.setName(((WidgetInfo) comboViewerInfo
  190.                   .getParent()).getVariableSupport().getName());
  191.               ticksComboViewerInfo.setViewerName(comboViewerInfo
  192.                   .getVariableSupport().getName());
  193.               objectViewerMap.put(ticksComboViewerInfo.getName(),
  194.                   ticksComboViewerInfo);
  195.             }
  196.             else if (javaInfo instanceof WrapperInfo)
  197.             {
  198.               TicksListViewerInfo ticksViewerInfo = new TicksListViewerInfo();
  199.               ticksViewerInfo.setName(((WidgetInfo) javaInfo.getParent())
  200.                   .getVariableSupport().getName());
  201.               ticksViewerInfo.setViewerName(javaInfo.getVariableSupport()
  202.                   .getName());
  203.               objectViewerMap.put(ticksViewerInfo.getName(), ticksViewerInfo);
  204.               try
  205.               {
  206.                 @SuppressWarnings("unchecked")
  207.                 TreeSet<String> object = (TreeSet<String>) ((CompositeInfo) javaInfo
  208.                     .getRootJava())
  209.                     .getEditor()
  210.                     .getAstUnit()
  211.                     .getProperty(
  212.                         "ASTNodeUtilities.getLocalMethodDeclaration.allMethods");
  213.  
  214.                 String getMethodName = "get"
  215.                     + StringUtils.upperFirstLetter(javaInfo
  216.                         .getVariableSupport().getName());
  217.                 if (!(object.contains(getMethodName)))
  218.                 {
  219.                   ticksViewerInfo.setGetterAccessible(false);
  220.                 }
  221.               }
  222.               catch (SecurityException e)
  223.               {
  224.                 ticksViewerInfo.setGetterAccessible(false);
  225.               }
  226.             }
  227.             else if (javaInfo instanceof WidgetInfo)
  228.             {
  229.               TicksObjectInfo toi = new TicksObjectInfo();
  230.  
  231.               MethodInvocation miRequired = javaInfo
  232.                   .getMethodInvocation("setRequired(boolean)");
  233.               MethodInvocation miWithMenu = javaInfo
  234.                   .getMethodInvocation("setWithMenu(boolean)");
  235.               MethodInvocation miValidationPattern = javaInfo
  236.                   .getMethodInvocation("setValidationPattern(java.lang.String)");
  237.               MethodInvocation miRevealCombo = javaInfo
  238.                   .getMethodInvocation("setRevealFirstElement(boolean)");
  239.               MethodInvocation miSelectionnable = javaInfo
  240.                       .getMethodInvocation("setSelectionnable(boolean)");
  241.  
  242.               toi.setComboFirstRealveal(miRevealCombo != null);
  243.               toi.setRequiredSet(miRequired != null);
  244.               toi.setWithMenuSet(miWithMenu != null);
  245.               toi.setValidationPatternSet(miValidationPattern != null);
  246.               toi.setSelectionnable(miSelectionnable != null);
  247.              
  248.               Class<?> cJavaInfo = javaInfo.getDescription().getCurrentClass();
  249.  
  250.               if (javaInfo instanceof TreeInfo)
  251.               {
  252.                 toi.setType(TicksObjectInfo.TREE_TYPE);
  253.               }
  254.               else if (javaInfo instanceof TableInfo)
  255.               {
  256.                 toi.setType(TicksObjectInfo.TABLE_TYPE);
  257.                 TableInfo ti = (TableInfo) javaInfo;
  258.                 for (TableColumnInfo tci : ti.getColumns())
  259.                 {
  260.                   MethodInvocation miRequired_col = tci
  261.                       .getMethodInvocation("setRequired(boolean)");
  262.                   MethodInvocation miValidationPattern_col = tci
  263.                       .getMethodInvocation("setValidationPattern(java.lang.String)");
  264.                   if (miRequired_col != null)
  265.                   {
  266.                     toi.setNestedRequiredSet(true);
  267.                   }
  268.                   if (miValidationPattern_col != null)
  269.                   {
  270.                     toi.setNestedValidationPatternSet(true);
  271.                   }
  272.                   toi.setNeedModifyListener(false);
  273.                 }
  274.               }
  275.               else if (javaInfo instanceof ButtonInfo)
  276.               {
  277.                 toi.setType(TicksObjectInfo.BUTTON_TYPE);
  278.               }
  279.               else if (cJavaInfo.toString().equalsIgnoreCase(DateTime.class.toString()))
  280.               {
  281.                 toi.setType(TicksObjectInfo.DATE_TYPE);
  282.                 toi.setValidationPatternSet(true);
  283.               }
  284.               else if (cJavaInfo.toString().equalsIgnoreCase(TextNumeric.class.toString()))
  285.               {
  286.                 toi.setType(TicksObjectInfo.TEXTNUMERIC_TYPE);
  287.                 toi.setValidationPatternSet(false);
  288.               }
  289.               else if (cJavaInfo.toString().equalsIgnoreCase(Spinner.class.toString()))
  290.               {
  291.                 toi.setType(TicksObjectInfo.SPINNER_TYPE);
  292.               }
  293.               else if (cJavaInfo.toString().equalsIgnoreCase(ImageViewer.class.toString()))
  294.               {
  295.                 toi.setType(TicksObjectInfo.IMAGEVIEWER_TYPE);
  296.               }
  297.               else if (cJavaInfo.toString().equalsIgnoreCase(Upload.class.toString()))
  298.               {
  299.                 toi.setType(TicksObjectInfo.UPLOAD_TYPE);
  300.                 toi.setValidationPatternSet(false);
  301.               }
  302.               else if (cJavaInfo.toString().equalsIgnoreCase(Download.class.toString()))
  303.               {
  304.                 toi.setType(TicksObjectInfo.DOWNLOAD_TYPE);
  305.                 toi.setValidationPatternSet(false);
  306.               }
  307.               else if (cJavaInfo.toString().equalsIgnoreCase(Link.class.toString()))
  308.               {
  309.                 toi.setType(TicksObjectInfo.LINK_TYPE);
  310.               }
  311.               else if (javaInfo instanceof TableColumnInfo)
  312.               {
  313.                 toi.setNeedModifyListener(false);
  314.               }
  315.               else if (javaInfo instanceof CompositeInfo)
  316.               {
  317.                 CompositeInfo ci = (CompositeInfo) javaInfo;
  318.                 if (ci.getDescription().getComponentClass().getName()
  319.                     .equals(org.eclipse.swt.browser.Browser.class.getName()))
  320.                 {
  321.                   toi.setType(TicksObjectInfo.BROWSER_TYPE);
  322.                 }
  323.                 if (ci
  324.                     .getDescription()
  325.                     .getComponentClass()
  326.                     .getName()
  327.                     .equals(
  328.                         fr.ticks.jface.viewers.PagingCompositeTable.class
  329.                             .getName())
  330.                     || ci
  331.                         .getDescription()
  332.                         .getComponentClass()
  333.                         .getName()
  334.                         .equals(
  335.                             fr.ticks.jface.viewers.PagingCompositeTree.class
  336.                                 .getName()))
  337.                 {
  338.                   toi.setType(TicksObjectInfo.PAGING_TYPE);
  339.                 }
  340.               }
  341.              
  342.               try
  343.               {
  344.                 @SuppressWarnings("unchecked")
  345.                 TreeSet<String> object = (TreeSet<String>) ((CompositeInfo) javaInfo
  346.                     .getRootJava())
  347.                     .getEditor()
  348.                     .getAstUnit()
  349.                     .getProperty(
  350.                         "ASTNodeUtilities.getLocalMethodDeclaration.allMethods");
  351.  
  352.                 String getMethodName = "get"
  353.                     + StringUtils.upperFirstLetter(javaInfo
  354.                         .getVariableSupport().getName());
  355.                 if (!(object.contains(getMethodName)))
  356.                 {
  357.                   toi.setGetterAccessible(false);
  358.                 }
  359.               }
  360.               catch (SecurityException e)
  361.               {
  362.                 toi.setGetterAccessible(false);
  363.               }
  364.  
  365.               if (javaInfo.getVariableSupport().getName() != null)
  366.               {
  367.                 objectInfoMap.put(javaInfo.getVariableSupport().getName(), toi);
  368.               }
  369.             }
  370.  
  371.           }
  372.  
  373.           TicksListViewerInfo listViewerInfo;
  374.           Map<String, IBpmnElementInformation> mapInfo;
  375.           String expression;
  376.           //Mise  jour des donnes de mapping
  377.           for (WidgetTypeDefinition widgetProperties : manualTask
  378.               .getWidgetProperties())
  379.           {
  380.             if (objectViewerMap.containsKey(widgetProperties.getWidgetName()))
  381.             {
  382.               TicksViewerInfo ticksViewerInfo = objectViewerMap
  383.                   .get(widgetProperties.getWidgetName());
  384.               if (ticksViewerInfo instanceof TicksTableViewerInfo)
  385.               {
  386.                 ((TicksTableViewerInfo) ticksViewerInfo)
  387.                     .setModelMapping(widgetProperties.getTypeElement());
  388.                 ((TicksTableViewerInfo) ticksViewerInfo)
  389.                     .setModelMappingVariable(NameUtils
  390.                         .getVariableName(widgetProperties.getTypeElement()));
  391.               }
  392.               else if (ticksViewerInfo instanceof TicksTreeViewerInfo)
  393.               {
  394.                 if (!((TicksTreeViewerInfo) ticksViewerInfo).getHasColumn())
  395.                 {
  396.                   mapInfo = new HashMap<String, IBpmnElementInformation>();
  397.                   mapInfo.put(manualTaskInformation.getName(),
  398.                       manualTaskInformation);
  399.                   ((TicksTreeViewerInfo) ticksViewerInfo)
  400.                       .setModelMapping(widgetProperties.getTypeElement());
  401.                   ((TicksTreeViewerInfo) ticksViewerInfo)
  402.                       .setModelMappingVariable(NameUtils
  403.                           .getVariableName(widgetProperties.getTypeElement()));
  404.                   ObjectInformation oi = new ObjectInformation(
  405.                       new ClassVariable(((TicksTreeViewerInfo) ticksViewerInfo)
  406.                           .getModelMapping(),
  407.                           ((TicksTreeViewerInfo) ticksViewerInfo)
  408.                               .getModelMappingVariable()));
  409.                   mapInfo.put(oi.getClassVariable().getClassName(), oi);
  410.                   ((TicksTreeViewerInfo) ticksViewerInfo)
  411.                       .setValueMapping(ExpressionUtils.getExpression(infos,
  412.                           null, widgetProperties.getMappingPrint().get(0), mapInfo));
  413.                 }
  414.                 else
  415.                 {
  416.                   ((TicksTreeViewerInfo) ticksViewerInfo)
  417.                       .setModelMapping(widgetProperties.getTypeElement());
  418.                   ((TicksTreeViewerInfo) ticksViewerInfo)
  419.                       .setModelMappingVariable(NameUtils
  420.                           .getVariableName(widgetProperties.getTypeElement()));
  421.                 }
  422.               }
  423.               else if (ticksViewerInfo instanceof TicksColumnViewerInfo
  424.                   && widgetProperties.getMappingPrint().size() > 0)
  425.               {
  426.                 mapInfo = new HashMap<String, IBpmnElementInformation>();
  427.                 mapInfo.put(manualTaskInformation.getName(),
  428.                     manualTaskInformation);
  429.                 ((TicksColumnViewerInfo) ticksViewerInfo).setWidgetEditionProperty(widgetProperties.getWidgetEditionProperty());
  430.                
  431.                
  432.                 ticksViewerInfo.setCanBeEditable(widgetsCanBeEditable.contains(ticksViewerInfo.getName()));
  433.                 ObjectInformation oi = null;
  434.  
  435.                 if (ticksViewerInfo instanceof TicksTableColumnViewerInfo)
  436.                 {
  437.                   oi = new ObjectInformation(new ClassVariable(
  438.                       ((TicksTableColumnViewerInfo) ticksViewerInfo)
  439.                           .getParentViewerInfo().getModelMapping(),
  440.                       ((TicksTableColumnViewerInfo) ticksViewerInfo)
  441.                           .getParentViewerInfo().getModelMappingVariable()));
  442.                 }
  443.                 else if (ticksViewerInfo instanceof TicksTreeColumnViewerInfo)
  444.                 {
  445.                   oi = new ObjectInformation(new ClassVariable(
  446.                       ((TicksTreeColumnViewerInfo) ticksViewerInfo)
  447.                           .getParentViewerInfo().getModelMapping(),
  448.                       ((TicksTreeColumnViewerInfo) ticksViewerInfo)
  449.                           .getParentViewerInfo().getModelMappingVariable()));
  450.                 }
  451.  
  452.                 mapInfo.put(oi.getClassVariable().getClassName(), oi);
  453.  
  454.                 expression = ExpressionUtils.getExpression(infos, null,
  455.                     widgetProperties.getMappingPrint().get(0), mapInfo);
  456.                 ((TicksColumnViewerInfo) ticksViewerInfo)
  457.                     .setValueMapping(expression);
  458.               }
  459.               else if (widgetProperties.getMappingPrint().size() > 0)
  460.               {
  461.                 listViewerInfo = (TicksListViewerInfo) ticksViewerInfo;
  462.                 listViewerInfo.setModelMapping(widgetProperties
  463.                     .getTypeElement());
  464.                 listViewerInfo.setModelMappingVariable(NameUtils
  465.                     .getVariableName(widgetProperties.getTypeElement()));
  466.  
  467.                 //                if (widgetProperties.getMappingPrint().get(0).indexOf('.') >= 0 || true)
  468.                 {
  469.                   ObjectInformation oi = new ObjectInformation(
  470.                       new ClassVariable(widgetProperties.getTypeElement(),
  471.                           listViewerInfo.getModelMappingVariable()));
  472.  
  473.                   mapInfo = new HashMap<String, IBpmnElementInformation>();
  474.                   mapInfo.put(manualTaskInformation.getName(),
  475.                       manualTaskInformation);
  476.                   mapInfo.put(oi.getClassVariable().getClassName(), oi);
  477.                  
  478.                   expression = ExpressionUtils.getExpression(infos, null,
  479.                       widgetProperties.getMappingPrint().get(0), mapInfo);
  480.                   listViewerInfo.setValueMapping(expression);
  481.                 }
  482.               }
  483.             }
  484.           }
  485.         }
  486.  
  487.       }
  488.     }
  489.     return manualTaskInformation;
  490.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement