Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static ManualTaskInformation getIhmInfo(Map<String, Object> infos,
- List<ManuelTask> manualTasks, ManualTaskInformation manualTaskInformation)
- {
- Map<String, TicksViewerInfo> objectViewerMap = new HashMap<String, TicksViewerInfo>();
- Map<String, TicksObjectInfo> objectInfoMap = new HashMap<String, TicksObjectInfo>();
- manualTaskInformation.setNameViewerMap(objectViewerMap);
- manualTaskInformation.setNameObjectMap(objectInfoMap);
- for (ManuelTask manualTask : manualTasks)
- {
- if (manualTask.isIsForm())
- {
- List<String> widgetsCanBeEditable = PropManualTaskModelToForm.searchWidgetsCanBeEditable(manualTask);
- CompositeInfo objectInfo = (CompositeInfo) JavaInfoProvider
- .getJavaInfoOfFlowElement(manualTask, (IProject) infos.get(DiagramTransformationUtils.KEY_project));
- if (objectInfo != null)
- {
- @SuppressWarnings("unchecked")
- List<ImportDeclaration> imports = objectInfo.getEditor().getAstUnit().imports();
- for (ImportDeclaration o: imports)
- {
- if (o.getName().getFullyQualifiedName().endsWith("StackLayout"))
- {
- manualTaskInformation.setIsStackLayout(true);
- break;
- }
- }
- // Rcuperation des viewer table et column
- for (JavaInfo javaInfo : getJavaInfoFromForm(objectInfo))
- {
- if (javaInfo instanceof ViewerInfo
- && javaInfo.getParent() instanceof TableInfo)
- {
- TicksTableViewerInfo tblVwr = new TicksTableViewerInfo();
- tblVwr.setName(((TableInfo) javaInfo.getParent())
- .getVariableSupport().getName());
- tblVwr.setViewerName(javaInfo.getVariableSupport().getName());
- objectViewerMap.put(tblVwr.getName(), tblVwr);
- try
- {
- @SuppressWarnings("unchecked")
- TreeSet<String> object = (TreeSet<String>) ((CompositeInfo) javaInfo
- .getRootJava())
- .getEditor()
- .getAstUnit()
- .getProperty(
- "ASTNodeUtilities.getLocalMethodDeclaration.allMethods");
- String getMethodName = "get"
- + StringUtils.upperFirstLetter(javaInfo
- .getVariableSupport().getName());
- if (!(object.contains(getMethodName)))
- {
- tblVwr.setGetterAccessible(false);
- }
- }
- catch (SecurityException e)
- {
- tblVwr.setGetterAccessible(false);
- }
- }
- else if (javaInfo instanceof ViewerInfo
- && javaInfo.getParent() instanceof TreeInfo)
- {
- TicksTreeViewerInfo tblVwr = new TicksTreeViewerInfo();
- tblVwr.setHasColumn(false);
- tblVwr.setName(((TreeInfo) javaInfo.getParent())
- .getVariableSupport().getName());
- tblVwr.setViewerName(javaInfo.getVariableSupport().getName());
- objectViewerMap.put(tblVwr.getName(), tblVwr);
- try
- {
- @SuppressWarnings("unchecked")
- TreeSet<String> object = (TreeSet<String>) ((CompositeInfo) javaInfo
- .getRootJava())
- .getEditor()
- .getAstUnit()
- .getProperty(
- "ASTNodeUtilities.getLocalMethodDeclaration.allMethods");
- String getMethodName = "get"
- + StringUtils.upperFirstLetter(javaInfo
- .getVariableSupport().getName());
- if (!(object.contains(getMethodName)))
- {
- tblVwr.setGetterAccessible(false);
- }
- }
- catch (SecurityException e)
- {
- tblVwr.setGetterAccessible(false);
- }
- }
- else if (javaInfo instanceof ViewerColumnInfo
- && javaInfo.getParent() instanceof TableColumnInfo)
- {
- ViewerColumnInfo columnViewer = (ViewerColumnInfo) javaInfo;
- TicksTableColumnViewerInfo tblClmnVwr = new TicksTableColumnViewerInfo();
- tblClmnVwr.setName(((ItemInfo) columnViewer.getParent())
- .getVariableSupport().getName());
- tblClmnVwr.setViewerName(columnViewer.getVariableSupport()
- .getName());
- tblClmnVwr
- .setParentViewerInfo((TicksTableViewerInfo) objectViewerMap
- .get(((TableInfo) (columnViewer.getParent().getParent()))
- .getVariableSupport().getName()));
- objectViewerMap.put(tblClmnVwr.getName(), tblClmnVwr);
- try
- {
- @SuppressWarnings("unchecked")
- TreeSet<String> object = (TreeSet<String>) ((CompositeInfo) javaInfo
- .getRootJava())
- .getEditor()
- .getAstUnit()
- .getProperty(
- "ASTNodeUtilities.getLocalMethodDeclaration.allMethods");
- String getMethodName = "get"
- + StringUtils.upperFirstLetter(javaInfo
- .getVariableSupport().getName());
- if (!(object.contains(getMethodName)))
- {
- tblClmnVwr.setGetterAccessible(false);
- }
- }
- catch (SecurityException e)
- {
- tblClmnVwr.setGetterAccessible(false);
- }
- MethodInvocation miWithEditingSupport = javaInfo
- .getMethodInvocation("setWithEditingSupport(boolean)");
- tblClmnVwr.setWithEditingSupportSet(miWithEditingSupport != null);
- }
- else if (javaInfo instanceof ViewerColumnInfo
- && javaInfo.getParent() instanceof TreeColumnInfo)
- {
- ViewerColumnInfo columnViewer = (ViewerColumnInfo) javaInfo;
- TicksTreeColumnViewerInfo tblClmnVwr = new TicksTreeColumnViewerInfo();
- tblClmnVwr.setName(((ItemInfo) columnViewer.getParent())
- .getVariableSupport().getName());
- tblClmnVwr.setViewerName(columnViewer.getVariableSupport()
- .getName());
- TicksTreeViewerInfo parent = (TicksTreeViewerInfo) objectViewerMap
- .get(((TreeInfo) (columnViewer.getParent().getParent()))
- .getVariableSupport().getName());
- tblClmnVwr.setParentViewerInfo(parent);
- parent.setHasColumn(true);
- objectViewerMap.put(tblClmnVwr.getName(), tblClmnVwr);
- try
- {
- @SuppressWarnings("unchecked")
- TreeSet<String> object = (TreeSet<String>) ((CompositeInfo) javaInfo
- .getRootJava())
- .getEditor()
- .getAstUnit()
- .getProperty(
- "ASTNodeUtilities.getLocalMethodDeclaration.allMethods");
- String getMethodName = "get"
- + StringUtils.upperFirstLetter(javaInfo
- .getVariableSupport().getName());
- if (!(object.contains(getMethodName)))
- {
- tblClmnVwr.setGetterAccessible(false);
- }
- }
- catch (SecurityException e)
- {
- tblClmnVwr.setGetterAccessible(false);
- }
- MethodInvocation miWithEditingSupport = javaInfo
- .getMethodInvocation("setWithEditingSupport(boolean)");
- tblClmnVwr.setWithEditingSupportSet(miWithEditingSupport != null);
- }
- else if (javaInfo instanceof ComboViewerInfo)
- {
- ComboViewerInfo comboViewerInfo = (ComboViewerInfo) javaInfo;
- TicksListViewerInfo ticksComboViewerInfo = new TicksListViewerInfo();
- if (!(comboViewerInfo.toString().contains("READ_ONLY")))
- {
- ticksComboViewerInfo.setIsEditable(Boolean.TRUE);
- }
- ticksComboViewerInfo.setIsCombo(Boolean.TRUE);
- ticksComboViewerInfo.setName(((WidgetInfo) comboViewerInfo
- .getParent()).getVariableSupport().getName());
- ticksComboViewerInfo.setViewerName(comboViewerInfo
- .getVariableSupport().getName());
- objectViewerMap.put(ticksComboViewerInfo.getName(),
- ticksComboViewerInfo);
- }
- else if (javaInfo instanceof WrapperInfo)
- {
- TicksListViewerInfo ticksViewerInfo = new TicksListViewerInfo();
- ticksViewerInfo.setName(((WidgetInfo) javaInfo.getParent())
- .getVariableSupport().getName());
- ticksViewerInfo.setViewerName(javaInfo.getVariableSupport()
- .getName());
- objectViewerMap.put(ticksViewerInfo.getName(), ticksViewerInfo);
- try
- {
- @SuppressWarnings("unchecked")
- TreeSet<String> object = (TreeSet<String>) ((CompositeInfo) javaInfo
- .getRootJava())
- .getEditor()
- .getAstUnit()
- .getProperty(
- "ASTNodeUtilities.getLocalMethodDeclaration.allMethods");
- String getMethodName = "get"
- + StringUtils.upperFirstLetter(javaInfo
- .getVariableSupport().getName());
- if (!(object.contains(getMethodName)))
- {
- ticksViewerInfo.setGetterAccessible(false);
- }
- }
- catch (SecurityException e)
- {
- ticksViewerInfo.setGetterAccessible(false);
- }
- }
- else if (javaInfo instanceof WidgetInfo)
- {
- TicksObjectInfo toi = new TicksObjectInfo();
- MethodInvocation miRequired = javaInfo
- .getMethodInvocation("setRequired(boolean)");
- MethodInvocation miWithMenu = javaInfo
- .getMethodInvocation("setWithMenu(boolean)");
- MethodInvocation miValidationPattern = javaInfo
- .getMethodInvocation("setValidationPattern(java.lang.String)");
- MethodInvocation miRevealCombo = javaInfo
- .getMethodInvocation("setRevealFirstElement(boolean)");
- MethodInvocation miSelectionnable = javaInfo
- .getMethodInvocation("setSelectionnable(boolean)");
- toi.setComboFirstRealveal(miRevealCombo != null);
- toi.setRequiredSet(miRequired != null);
- toi.setWithMenuSet(miWithMenu != null);
- toi.setValidationPatternSet(miValidationPattern != null);
- toi.setSelectionnable(miSelectionnable != null);
- Class<?> cJavaInfo = javaInfo.getDescription().getCurrentClass();
- if (javaInfo instanceof TreeInfo)
- {
- toi.setType(TicksObjectInfo.TREE_TYPE);
- }
- else if (javaInfo instanceof TableInfo)
- {
- toi.setType(TicksObjectInfo.TABLE_TYPE);
- TableInfo ti = (TableInfo) javaInfo;
- for (TableColumnInfo tci : ti.getColumns())
- {
- MethodInvocation miRequired_col = tci
- .getMethodInvocation("setRequired(boolean)");
- MethodInvocation miValidationPattern_col = tci
- .getMethodInvocation("setValidationPattern(java.lang.String)");
- if (miRequired_col != null)
- {
- toi.setNestedRequiredSet(true);
- }
- if (miValidationPattern_col != null)
- {
- toi.setNestedValidationPatternSet(true);
- }
- toi.setNeedModifyListener(false);
- }
- }
- else if (javaInfo instanceof ButtonInfo)
- {
- toi.setType(TicksObjectInfo.BUTTON_TYPE);
- }
- else if (cJavaInfo.toString().equalsIgnoreCase(DateTime.class.toString()))
- {
- toi.setType(TicksObjectInfo.DATE_TYPE);
- toi.setValidationPatternSet(true);
- }
- else if (cJavaInfo.toString().equalsIgnoreCase(TextNumeric.class.toString()))
- {
- toi.setType(TicksObjectInfo.TEXTNUMERIC_TYPE);
- toi.setValidationPatternSet(false);
- }
- else if (cJavaInfo.toString().equalsIgnoreCase(Spinner.class.toString()))
- {
- toi.setType(TicksObjectInfo.SPINNER_TYPE);
- }
- else if (cJavaInfo.toString().equalsIgnoreCase(ImageViewer.class.toString()))
- {
- toi.setType(TicksObjectInfo.IMAGEVIEWER_TYPE);
- }
- else if (cJavaInfo.toString().equalsIgnoreCase(Upload.class.toString()))
- {
- toi.setType(TicksObjectInfo.UPLOAD_TYPE);
- toi.setValidationPatternSet(false);
- }
- else if (cJavaInfo.toString().equalsIgnoreCase(Download.class.toString()))
- {
- toi.setType(TicksObjectInfo.DOWNLOAD_TYPE);
- toi.setValidationPatternSet(false);
- }
- else if (cJavaInfo.toString().equalsIgnoreCase(Link.class.toString()))
- {
- toi.setType(TicksObjectInfo.LINK_TYPE);
- }
- else if (javaInfo instanceof TableColumnInfo)
- {
- toi.setNeedModifyListener(false);
- }
- else if (javaInfo instanceof CompositeInfo)
- {
- CompositeInfo ci = (CompositeInfo) javaInfo;
- if (ci.getDescription().getComponentClass().getName()
- .equals(org.eclipse.swt.browser.Browser.class.getName()))
- {
- toi.setType(TicksObjectInfo.BROWSER_TYPE);
- }
- if (ci
- .getDescription()
- .getComponentClass()
- .getName()
- .equals(
- fr.ticks.jface.viewers.PagingCompositeTable.class
- .getName())
- || ci
- .getDescription()
- .getComponentClass()
- .getName()
- .equals(
- fr.ticks.jface.viewers.PagingCompositeTree.class
- .getName()))
- {
- toi.setType(TicksObjectInfo.PAGING_TYPE);
- }
- }
- try
- {
- @SuppressWarnings("unchecked")
- TreeSet<String> object = (TreeSet<String>) ((CompositeInfo) javaInfo
- .getRootJava())
- .getEditor()
- .getAstUnit()
- .getProperty(
- "ASTNodeUtilities.getLocalMethodDeclaration.allMethods");
- String getMethodName = "get"
- + StringUtils.upperFirstLetter(javaInfo
- .getVariableSupport().getName());
- if (!(object.contains(getMethodName)))
- {
- toi.setGetterAccessible(false);
- }
- }
- catch (SecurityException e)
- {
- toi.setGetterAccessible(false);
- }
- if (javaInfo.getVariableSupport().getName() != null)
- {
- objectInfoMap.put(javaInfo.getVariableSupport().getName(), toi);
- }
- }
- }
- TicksListViewerInfo listViewerInfo;
- Map<String, IBpmnElementInformation> mapInfo;
- String expression;
- //Mise jour des donnes de mapping
- for (WidgetTypeDefinition widgetProperties : manualTask
- .getWidgetProperties())
- {
- if (objectViewerMap.containsKey(widgetProperties.getWidgetName()))
- {
- TicksViewerInfo ticksViewerInfo = objectViewerMap
- .get(widgetProperties.getWidgetName());
- if (ticksViewerInfo instanceof TicksTableViewerInfo)
- {
- ((TicksTableViewerInfo) ticksViewerInfo)
- .setModelMapping(widgetProperties.getTypeElement());
- ((TicksTableViewerInfo) ticksViewerInfo)
- .setModelMappingVariable(NameUtils
- .getVariableName(widgetProperties.getTypeElement()));
- }
- else if (ticksViewerInfo instanceof TicksTreeViewerInfo)
- {
- if (!((TicksTreeViewerInfo) ticksViewerInfo).getHasColumn())
- {
- mapInfo = new HashMap<String, IBpmnElementInformation>();
- mapInfo.put(manualTaskInformation.getName(),
- manualTaskInformation);
- ((TicksTreeViewerInfo) ticksViewerInfo)
- .setModelMapping(widgetProperties.getTypeElement());
- ((TicksTreeViewerInfo) ticksViewerInfo)
- .setModelMappingVariable(NameUtils
- .getVariableName(widgetProperties.getTypeElement()));
- ObjectInformation oi = new ObjectInformation(
- new ClassVariable(((TicksTreeViewerInfo) ticksViewerInfo)
- .getModelMapping(),
- ((TicksTreeViewerInfo) ticksViewerInfo)
- .getModelMappingVariable()));
- mapInfo.put(oi.getClassVariable().getClassName(), oi);
- ((TicksTreeViewerInfo) ticksViewerInfo)
- .setValueMapping(ExpressionUtils.getExpression(infos,
- null, widgetProperties.getMappingPrint().get(0), mapInfo));
- }
- else
- {
- ((TicksTreeViewerInfo) ticksViewerInfo)
- .setModelMapping(widgetProperties.getTypeElement());
- ((TicksTreeViewerInfo) ticksViewerInfo)
- .setModelMappingVariable(NameUtils
- .getVariableName(widgetProperties.getTypeElement()));
- }
- }
- else if (ticksViewerInfo instanceof TicksColumnViewerInfo
- && widgetProperties.getMappingPrint().size() > 0)
- {
- mapInfo = new HashMap<String, IBpmnElementInformation>();
- mapInfo.put(manualTaskInformation.getName(),
- manualTaskInformation);
- ((TicksColumnViewerInfo) ticksViewerInfo).setWidgetEditionProperty(widgetProperties.getWidgetEditionProperty());
- ticksViewerInfo.setCanBeEditable(widgetsCanBeEditable.contains(ticksViewerInfo.getName()));
- ObjectInformation oi = null;
- if (ticksViewerInfo instanceof TicksTableColumnViewerInfo)
- {
- oi = new ObjectInformation(new ClassVariable(
- ((TicksTableColumnViewerInfo) ticksViewerInfo)
- .getParentViewerInfo().getModelMapping(),
- ((TicksTableColumnViewerInfo) ticksViewerInfo)
- .getParentViewerInfo().getModelMappingVariable()));
- }
- else if (ticksViewerInfo instanceof TicksTreeColumnViewerInfo)
- {
- oi = new ObjectInformation(new ClassVariable(
- ((TicksTreeColumnViewerInfo) ticksViewerInfo)
- .getParentViewerInfo().getModelMapping(),
- ((TicksTreeColumnViewerInfo) ticksViewerInfo)
- .getParentViewerInfo().getModelMappingVariable()));
- }
- mapInfo.put(oi.getClassVariable().getClassName(), oi);
- expression = ExpressionUtils.getExpression(infos, null,
- widgetProperties.getMappingPrint().get(0), mapInfo);
- ((TicksColumnViewerInfo) ticksViewerInfo)
- .setValueMapping(expression);
- }
- else if (widgetProperties.getMappingPrint().size() > 0)
- {
- listViewerInfo = (TicksListViewerInfo) ticksViewerInfo;
- listViewerInfo.setModelMapping(widgetProperties
- .getTypeElement());
- listViewerInfo.setModelMappingVariable(NameUtils
- .getVariableName(widgetProperties.getTypeElement()));
- // if (widgetProperties.getMappingPrint().get(0).indexOf('.') >= 0 || true)
- {
- ObjectInformation oi = new ObjectInformation(
- new ClassVariable(widgetProperties.getTypeElement(),
- listViewerInfo.getModelMappingVariable()));
- mapInfo = new HashMap<String, IBpmnElementInformation>();
- mapInfo.put(manualTaskInformation.getName(),
- manualTaskInformation);
- mapInfo.put(oi.getClassVariable().getClassName(), oi);
- expression = ExpressionUtils.getExpression(infos, null,
- widgetProperties.getMappingPrint().get(0), mapInfo);
- listViewerInfo.setValueMapping(expression);
- }
- }
- }
- }
- }
- }
- }
- return manualTaskInformation;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement