diff options
Diffstat (limited to 'plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core')
95 files changed, 8693 insertions, 8693 deletions
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.classpath b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.classpath index b862a296d38..eca7bdba8f0 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.classpath +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.classpath @@ -1,7 +1,7 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.settings/org.eclipse.jdt.core.prefs b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.settings/org.eclipse.jdt.core.prefs index a0d51c8b4db..43d10874e2c 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.settings/org.eclipse.jdt.core.prefs +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/.settings/org.eclipse.jdt.core.prefs @@ -1,295 +1,295 @@ -eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.8
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.8
-org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
-org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
-org.eclipse.jdt.core.formatter.alignment_for_assignment=0
-org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
-org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
-org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
-org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
-org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
-org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
-org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
-org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
-org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
-org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
-org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
-org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
-org.eclipse.jdt.core.formatter.blank_lines_after_package=1
-org.eclipse.jdt.core.formatter.blank_lines_before_field=0
-org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
-org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
-org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
-org.eclipse.jdt.core.formatter.blank_lines_before_method=1
-org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
-org.eclipse.jdt.core.formatter.blank_lines_before_package=0
-org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
-org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
-org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
-org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
-org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
-org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
-org.eclipse.jdt.core.formatter.comment.format_block_comments=true
-org.eclipse.jdt.core.formatter.comment.format_header=false
-org.eclipse.jdt.core.formatter.comment.format_html=true
-org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
-org.eclipse.jdt.core.formatter.comment.format_line_comments=true
-org.eclipse.jdt.core.formatter.comment.format_source_code=true
-org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
-org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
-org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
-org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
-org.eclipse.jdt.core.formatter.comment.line_length=260
-org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
-org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
-org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
-org.eclipse.jdt.core.formatter.compact_else_if=true
-org.eclipse.jdt.core.formatter.continuation_indentation=2
-org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
-org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
-org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
-org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
-org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
-org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
-org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
-org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
-org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
-org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
-org.eclipse.jdt.core.formatter.indent_empty_lines=false
-org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
-org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
-org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
-org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
-org.eclipse.jdt.core.formatter.indentation.size=4
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
-org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
-org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
-org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
-org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
-org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
-org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
-org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
-org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
-org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
-org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
-org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
-org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
-org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
-org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
-org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
-org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
-org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
-org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
-org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
-org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
-org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
-org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
-org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
-org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
-org.eclipse.jdt.core.formatter.join_lines_in_comments=false
-org.eclipse.jdt.core.formatter.join_wrapped_lines=false
-org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
-org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
-org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
-org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
-org.eclipse.jdt.core.formatter.lineSplit=260
-org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
-org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
-org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
-org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=5
-org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
-org.eclipse.jdt.core.formatter.tabulation.char=tab
-org.eclipse.jdt.core.formatter.tabulation.size=4
-org.eclipse.jdt.core.formatter.use_on_off_tags=false
-org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
-org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
-org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
-org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
+eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=260 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=false +org.eclipse.jdt.core.formatter.join_wrapped_lines=false +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=260 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=5 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/META-INF/MANIFEST.MF b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/META-INF/MANIFEST.MF index dde61b8c331..6e971d565d2 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/META-INF/MANIFEST.MF +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/META-INF/MANIFEST.MF @@ -1,23 +1,23 @@ -Manifest-Version: 1.0
-Export-Package: org.eclipse.papyrus.emf.facet.efacet.core,
- org.eclipse.papyrus.emf.facet.efacet.core.exception,
- org.eclipse.papyrus.emf.facet.efacet.core.internal.exported,
- org.eclipse.papyrus.emf.facet.efacet.core.internal.incubatingapi,
- org.eclipse.papyrus.emf.facet.efacet.core.internal.query,
- org.eclipse.papyrus.emf.facet.efacet.core.query
-Require-Bundle: org.eclipse.papyrus.emf.facet.efacet.catalog;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
- org.eclipse.papyrus.emf.facet.util.emf.core;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
- org.eclipse.emf.edit;bundle-version="[2.12.0,3.0.0)";visibility:=reexport,
- org.eclipse.papyrus.emf.facet.efacet.metamodel;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
- org.eclipse.core.resources;bundle-version="[3.11.0,4.0.0)";visibility:=reexport,
- org.eclipse.papyrus.emf.facet.efacet;bundle-version="[1.2.0,2.0.0)";visibility:=reexport,
- org.eclipse.papyrus.emf.facet.util.emf.ui;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.papyrus.emf.facet.util.pde.core;bundle-version="[1.2.0,2.0.0)"
-Bundle-Vendor: %Bundle-Vendor
-Bundle-ActivationPolicy: lazy
-Bundle-Version: 2.0.0.qualifier
-Bundle-Name: %Bundle-Name
-Bundle-Activator: org.eclipse.papyrus.emf.facet.efacet.core.internal.Activator
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.papyrus.emf.facet.efacet.core;singleton:=true
-Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Manifest-Version: 1.0 +Export-Package: org.eclipse.papyrus.emf.facet.efacet.core, + org.eclipse.papyrus.emf.facet.efacet.core.exception, + org.eclipse.papyrus.emf.facet.efacet.core.internal.exported, + org.eclipse.papyrus.emf.facet.efacet.core.internal.incubatingapi, + org.eclipse.papyrus.emf.facet.efacet.core.internal.query, + org.eclipse.papyrus.emf.facet.efacet.core.query +Require-Bundle: org.eclipse.papyrus.emf.facet.efacet.catalog;bundle-version="[1.2.0,2.0.0)";visibility:=reexport, + org.eclipse.papyrus.emf.facet.util.emf.core;bundle-version="[1.2.0,2.0.0)";visibility:=reexport, + org.eclipse.emf.edit;bundle-version="[2.12.0,3.0.0)";visibility:=reexport, + org.eclipse.papyrus.emf.facet.efacet.metamodel;bundle-version="[1.2.0,2.0.0)";visibility:=reexport, + org.eclipse.core.resources;bundle-version="[3.11.0,4.0.0)";visibility:=reexport, + org.eclipse.papyrus.emf.facet.efacet;bundle-version="[1.2.0,2.0.0)";visibility:=reexport, + org.eclipse.papyrus.emf.facet.util.emf.ui;bundle-version="[2.0.0,3.0.0)", + org.eclipse.papyrus.emf.facet.util.pde.core;bundle-version="[1.2.0,2.0.0)" +Bundle-Vendor: %Bundle-Vendor +Bundle-ActivationPolicy: lazy +Bundle-Version: 2.0.0.qualifier +Bundle-Name: %Bundle-Name +Bundle-Activator: org.eclipse.papyrus.emf.facet.efacet.core.internal.Activator +Bundle-ManifestVersion: 2 +Bundle-SymbolicName: org.eclipse.papyrus.emf.facet.efacet.core;singleton:=true +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/OSGI-INF/l10n/bundle.properties b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/OSGI-INF/l10n/bundle.properties index 31e39f5dcde..246bc6da7da 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/OSGI-INF/l10n/bundle.properties +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/OSGI-INF/l10n/bundle.properties @@ -1,17 +1,17 @@ -###########################################################################
-# Copyright (c) 2011, 2012 Mia-Software.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
-# Nicolas Guyomar (Mia-Software) - Bug 339899 - everything must be externalized before UI freeze
-###########################################################################
-#Properties file for org.eclipse.papyrus.emf.facet.efacet.core
-Bundle-Vendor = Eclipse Modeling Project
-Bundle-Name = Papyrus EMF Facet Core
-queryEvaluatorRegistration.extension-point.name = QueryEvaluatorRegistration
+########################################################################### +# Copyright (c) 2011, 2012 Mia-Software. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet +# Nicolas Guyomar (Mia-Software) - Bug 339899 - everything must be externalized before UI freeze +########################################################################### +#Properties file for org.eclipse.papyrus.emf.facet.efacet.core +Bundle-Vendor = Eclipse Modeling Project +Bundle-Name = Papyrus EMF Facet Core +queryEvaluatorRegistration.extension-point.name = QueryEvaluatorRegistration derivedTypedElementImplementationRegistration.extension-point.name = Derived Typed Element Evaluator Registration
\ No newline at end of file diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/about.html b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/about.html index 05cdf47ada9..66a46a1ce73 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/about.html +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/about.html @@ -1,28 +1,28 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
-<title>About</title>
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>January 10, 2011</p>
-<h3>License</h3>
-
-<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
-indicated below, the Content is provided to you under the terms and conditions of the
-Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
-at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
-For purposes of the EPL, "Program" will mean the Content.</p>
-
-<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
-being redistributed by another party ("Redistributor") and different terms and conditions may
-apply to your use of any object code in the Content. Check the Redistributor's license that was
-provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
-indicated below, the terms and conditions of the EPL still apply to any source code in the Content
-and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
-
-</body>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> +<title>About</title> +</head> +<body lang="EN-US"> +<h2>About This Content</h2> + +<p>January 10, 2011</p> +<h3>License</h3> + +<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise +indicated below, the Content is provided to you under the terms and conditions of the +Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available +at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>. +For purposes of the EPL, "Program" will mean the Content.</p> + +<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is +being redistributed by another party ("Redistributor") and different terms and conditions may +apply to your use of any object code in the Content. Check the Redistributor's license that was +provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise +indicated below, the terms and conditions of the EPL still apply to any source code in the Content +and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p> + +</body> </html>
\ No newline at end of file diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/build.properties b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/build.properties index f7d2767d4da..ce9ad44285a 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/build.properties +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/build.properties @@ -1,21 +1,21 @@ -###########################################################################
-# Copyright (c) 2011 Mia-Software.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
-# Nicolas Guyomar (Mia-Software) - Bug 339899 - everything must be externalized before UI freeze
-###########################################################################
-source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- OSGI-INF/,\
- about.html,\
- plugin.xml,\
- schema/
-src.includes = about.html
+########################################################################### +# Copyright (c) 2011 Mia-Software. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet +# Nicolas Guyomar (Mia-Software) - Bug 339899 - everything must be externalized before UI freeze +########################################################################### +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + OSGI-INF/,\ + about.html,\ + plugin.xml,\ + schema/ +src.includes = about.html diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/plugin.xml b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/plugin.xml index f0bc35fc9ad..f952aaecfb0 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/plugin.xml +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/plugin.xml @@ -1,45 +1,45 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.4"?>
-
-<!--
- Copyright (c) 2011 Mia-Software.
-
- All rights reserved. This program and the accompanying materials
- are made available under the terms of the Eclipse Public License v1.0
- which accompanies this distribution, and is available at
- http://www.eclipse.org/legal/epl-v10.html
-
- Contributors:
- Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
- Nicolas Guyomar (Mia-Software) - Bug 339899 - everything must be externalized before UI freeze
- Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
- Olivier Remaud (Soft-Maint) - Bug 369824 - Add a simple way to return string literal constants from a customization query
- Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
- Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- -->
-
-<plugin>
- <extension-point id="org.eclipse.papyrus.emf.facet.efacet.core.query.evaluatorregistration" name="%queryEvaluatorRegistration.extension-point.name" schema="schema/org.eclipse.emf.facet.efacet.core.query.evaluatorregistration.exsd"/>
- <extension-point id="derivedTypedElementImplementationRegistration" name="%derivedTypedElementImplementationRegistration.extension-point.name" schema="schema/derivedTypedElementImplementationRegistration.exsd"/>
- <extension-point id="queryImplementationRegistration" name="EMF Facet Query implementation registration" schema="schema/queryImplementationRegistration.exsd"/>
- <extension-point id="org.eclipse.papyrus.emf.facet.efacet.core.internal.resolver" name="Resolver" schema="schema/internal.resolver.exsd"/>
-
- <extension point="org.eclipse.papyrus.emf.facet.util.emf.core.catalogmanager">
- <catalog class="org.eclipse.papyrus.emf.facet.efacet.core.internal.catalog.EFacetCatalogManager"/>
- <catalog class="org.eclipse.papyrus.emf.facet.efacet.core.internal.catalog.EFacetCatalogManager2"/>
- </extension>
-
- <extension point="org.eclipse.papyrus.emf.facet.efacet.core.queryImplementationRegistration">
- <queryImplementationRegistration class="org.eclipse.papyrus.emf.facet.efacet.core.internal.query.NavigationQueryImplementationFactory"/>
- <queryImplementationRegistration class="org.eclipse.papyrus.emf.facet.efacet.core.internal.query.IsOneOfQueryImplementationFactory"/>
- <queryImplementationRegistration class="org.eclipse.papyrus.emf.facet.efacet.core.internal.query.StringLiteralQueryImplementationFactory"/>
- <queryImplementationRegistration class="org.eclipse.papyrus.emf.facet.efacet.core.internal.query.FalseLiteralQueryImplementationFactory"/>
- <queryImplementationRegistration class="org.eclipse.papyrus.emf.facet.efacet.core.internal.query.TrueLiteralQueryImplementationFactory"/>
- <queryImplementationRegistration class="org.eclipse.papyrus.emf.facet.efacet.core.internal.query.NullLiteralQueryImplementationFactory"/>
- <queryImplementationRegistration class="org.eclipse.papyrus.emf.facet.efacet.core.internal.query.EObjectLiteralQueryImplementationFactory"/>
- <queryImplementationRegistration class="org.eclipse.papyrus.emf.facet.efacet.core.internal.query.FloatLiteralQueryImplementationFactory"/>
- <queryImplementationRegistration class="org.eclipse.papyrus.emf.facet.efacet.core.internal.query.IntegerLiteralQueryImplementationFactory"/>
- <queryImplementationRegistration class="org.eclipse.papyrus.emf.facet.efacet.core.internal.query.OperationCallQueryImplementationFactory"/>
- </extension>
-</plugin>
+<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> + +<!-- + Copyright (c) 2011 Mia-Software. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + which accompanies this distribution, and is available at + http://www.eclipse.org/legal/epl-v10.html + + Contributors: + Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet + Nicolas Guyomar (Mia-Software) - Bug 339899 - everything must be externalized before UI freeze + Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2 + Olivier Remaud (Soft-Maint) - Bug 369824 - Add a simple way to return string literal constants from a customization query + Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>) + Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + --> + +<plugin> + <extension-point id="org.eclipse.papyrus.emf.facet.efacet.core.query.evaluatorregistration" name="%queryEvaluatorRegistration.extension-point.name" schema="schema/org.eclipse.emf.facet.efacet.core.query.evaluatorregistration.exsd"/> + <extension-point id="derivedTypedElementImplementationRegistration" name="%derivedTypedElementImplementationRegistration.extension-point.name" schema="schema/derivedTypedElementImplementationRegistration.exsd"/> + <extension-point id="queryImplementationRegistration" name="EMF Facet Query implementation registration" schema="schema/queryImplementationRegistration.exsd"/> + <extension-point id="org.eclipse.papyrus.emf.facet.efacet.core.internal.resolver" name="Resolver" schema="schema/internal.resolver.exsd"/> + + <extension point="org.eclipse.papyrus.emf.facet.util.emf.core.catalogmanager"> + <catalog class="org.eclipse.papyrus.emf.facet.efacet.core.internal.catalog.EFacetCatalogManager"/> + <catalog class="org.eclipse.papyrus.emf.facet.efacet.core.internal.catalog.EFacetCatalogManager2"/> + </extension> + + <extension point="org.eclipse.papyrus.emf.facet.efacet.core.queryImplementationRegistration"> + <queryImplementationRegistration class="org.eclipse.papyrus.emf.facet.efacet.core.internal.query.NavigationQueryImplementationFactory"/> + <queryImplementationRegistration class="org.eclipse.papyrus.emf.facet.efacet.core.internal.query.IsOneOfQueryImplementationFactory"/> + <queryImplementationRegistration class="org.eclipse.papyrus.emf.facet.efacet.core.internal.query.StringLiteralQueryImplementationFactory"/> + <queryImplementationRegistration class="org.eclipse.papyrus.emf.facet.efacet.core.internal.query.FalseLiteralQueryImplementationFactory"/> + <queryImplementationRegistration class="org.eclipse.papyrus.emf.facet.efacet.core.internal.query.TrueLiteralQueryImplementationFactory"/> + <queryImplementationRegistration class="org.eclipse.papyrus.emf.facet.efacet.core.internal.query.NullLiteralQueryImplementationFactory"/> + <queryImplementationRegistration class="org.eclipse.papyrus.emf.facet.efacet.core.internal.query.EObjectLiteralQueryImplementationFactory"/> + <queryImplementationRegistration class="org.eclipse.papyrus.emf.facet.efacet.core.internal.query.FloatLiteralQueryImplementationFactory"/> + <queryImplementationRegistration class="org.eclipse.papyrus.emf.facet.efacet.core.internal.query.IntegerLiteralQueryImplementationFactory"/> + <queryImplementationRegistration class="org.eclipse.papyrus.emf.facet.efacet.core.internal.query.OperationCallQueryImplementationFactory"/> + </extension> +</plugin> diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/derivedTypedElementImplementationRegistration.exsd b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/derivedTypedElementImplementationRegistration.exsd index ee936a0449b..a3777c2c0a2 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/derivedTypedElementImplementationRegistration.exsd +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/derivedTypedElementImplementationRegistration.exsd @@ -1,127 +1,127 @@ -<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.papyrus.emf.facet.efacet.core" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.eclipse.papyrus.emf.facet.efacet.core" id="derivedTypedElementImplementationRegistration" name="Derived Typed Element Evaluator Registration"/>
- </appinfo>
- <documentation>
- Allow the registration of an IderivedTypedElementImplementationFactory, that instantiates IDerivedTypedElementImplementation that conform to the EMF Facet framework.
-The IDerivedTypedElementImplementation provides an implementation for a given type of queries (e.g. Java queries, OCL queries, ...)
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element deprecated="true" replacement="queryImplementationRegistration" />
- </appinfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="derivedTypedElementImplementationRegistration" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="derivedTypedElementImplementationRegistration">
- <annotation>
- <appinfo>
- <meta.element deprecated="true"/>
- </appinfo>
- </annotation>
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- Provides an implementation for a IDerivedTypedElementImplementationFactory, which instantiates IDerivedTypedElementImplementation for a given type of queries.
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.emf.facet.efacet.core.query.IDerivedTypedElementImplementationFactory"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- 0.2.0
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="examples"/>
- </appinfo>
- <documentation>
- <pre>
- <extension point="org.eclipse.papyrus.emf.facet.efacet.core.derivedTypedElementImplementationRegistration">
- <derivedTypedElementImplementationRegistration
- class="org.eclipse.papyrus.emf.facet.efacet.core.tests.internal.DummyQueryEvaluatorFactory">
- </derivedTypedElementImplementationRegistration>
- </extension>
-</pre>
- </documentation>
- </annotation>
-
-
- <annotation>
- <appinfo>
- <meta.section type="implementation"/>
- </appinfo>
- <documentation>
- <p>
-See plug-ins:
-<ul>
-<li>org.eclipse.papyrus.emf.facet.query.java.core
-</ul>
-</p>
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="copyright"/>
- </appinfo>
- <documentation>
- Copyright (c) 2011 Mia-Software.
-
- All rights reserved. This program and the accompanying materials
- are made available under the terms of the Eclipse Public License v1.0
- which accompanies this distribution, and is available at
- http://www.eclipse.org/legal/epl-v10.html
-
-Contributors:
- Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
- </documentation>
- </annotation>
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.papyrus.emf.facet.efacet.core" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appinfo> + <meta.schema plugin="org.eclipse.papyrus.emf.facet.efacet.core" id="derivedTypedElementImplementationRegistration" name="Derived Typed Element Evaluator Registration"/> + </appinfo> + <documentation> + Allow the registration of an IderivedTypedElementImplementationFactory, that instantiates IDerivedTypedElementImplementation that conform to the EMF Facet framework. +The IDerivedTypedElementImplementation provides an implementation for a given type of queries (e.g. Java queries, OCL queries, ...) + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appinfo> + <meta.element deprecated="true" replacement="queryImplementationRegistration" /> + </appinfo> + </annotation> + <complexType> + <sequence> + <element ref="derivedTypedElementImplementationRegistration" minOccurs="1" maxOccurs="unbounded"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appinfo> + <meta.attribute translatable="true"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="derivedTypedElementImplementationRegistration"> + <annotation> + <appinfo> + <meta.element deprecated="true"/> + </appinfo> + </annotation> + <complexType> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + Provides an implementation for a IDerivedTypedElementImplementationFactory, which instantiates IDerivedTypedElementImplementation for a given type of queries. + </documentation> + <appinfo> + <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.emf.facet.efacet.core.query.IDerivedTypedElementImplementationFactory"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appinfo> + <meta.section type="since"/> + </appinfo> + <documentation> + 0.2.0 + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="examples"/> + </appinfo> + <documentation> + <pre> + <extension point="org.eclipse.papyrus.emf.facet.efacet.core.derivedTypedElementImplementationRegistration"> + <derivedTypedElementImplementationRegistration + class="org.eclipse.papyrus.emf.facet.efacet.core.tests.internal.DummyQueryEvaluatorFactory"> + </derivedTypedElementImplementationRegistration> + </extension> +</pre> + </documentation> + </annotation> + + + <annotation> + <appinfo> + <meta.section type="implementation"/> + </appinfo> + <documentation> + <p> +See plug-ins: +<ul> +<li>org.eclipse.papyrus.emf.facet.query.java.core +</ul> +</p> + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="copyright"/> + </appinfo> + <documentation> + Copyright (c) 2011 Mia-Software. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + which accompanies this distribution, and is available at + http://www.eclipse.org/legal/epl-v10.html + +Contributors: + Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2 + </documentation> + </annotation> + +</schema> diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/internal.resolver.exsd b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/internal.resolver.exsd index bf42c96a2a6..38908f00936 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/internal.resolver.exsd +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/internal.resolver.exsd @@ -1,108 +1,108 @@ -<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.papyrus.emf.facet.efacet.core" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.eclipse.papyrus.emf.facet.efacet.core" id="internal.resolver" name="Resolver"/>
- </appinfo>
- <documentation>
- This is an internal extension point. It must only be used by EMF Facet's components.
-
-This extension allows to plug specific behavior in to the facet components. It has been created avoid to have dependences from the main EMF Facet components to the aggregate components.
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="resolver"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="resolver">
- <complexType>
- <attribute name="class" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.emf.facet.efacet.core.internal.exported.IResolver"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- 0.2
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="examples"/>
- </appinfo>
- <documentation>
- <extension
- point="org.eclipse.papyrus.emf.facet.efacet.core.internal.resolver">
- <resolver
- class="org.eclipse.papyrus.emf.facet.aggregate.metamodel.notgenerated.internal.Resolver">
- </resolver>
- </extension>
- </documentation>
- </annotation>
-
-
-
- <annotation>
- <appinfo>
- <meta.section type="copyright"/>
- </appinfo>
- <documentation>
- Copyright (c) 2012 CEA-LIST.
-All rights reserved. This program and the accompanying materials
-are made available under the terms of the Eclipse Public License v1.0
-which accompanies this distribution, and is available at
-http://www.eclipse.org/legal/epl-v10.html
-
-Contributors:
- Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
- </documentation>
- </annotation>
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.papyrus.emf.facet.efacet.core" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appinfo> + <meta.schema plugin="org.eclipse.papyrus.emf.facet.efacet.core" id="internal.resolver" name="Resolver"/> + </appinfo> + <documentation> + This is an internal extension point. It must only be used by EMF Facet's components. + +This extension allows to plug specific behavior in to the facet components. It has been created avoid to have dependences from the main EMF Facet components to the aggregate components. + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appinfo> + <meta.element /> + </appinfo> + </annotation> + <complexType> + <sequence> + <element ref="resolver"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appinfo> + <meta.attribute translatable="true"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="resolver"> + <complexType> + <attribute name="class" type="string"> + <annotation> + <documentation> + + </documentation> + <appinfo> + <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.emf.facet.efacet.core.internal.exported.IResolver"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appinfo> + <meta.section type="since"/> + </appinfo> + <documentation> + 0.2 + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="examples"/> + </appinfo> + <documentation> + <extension + point="org.eclipse.papyrus.emf.facet.efacet.core.internal.resolver"> + <resolver + class="org.eclipse.papyrus.emf.facet.aggregate.metamodel.notgenerated.internal.Resolver"> + </resolver> + </extension> + </documentation> + </annotation> + + + + <annotation> + <appinfo> + <meta.section type="copyright"/> + </appinfo> + <documentation> + Copyright (c) 2012 CEA-LIST. +All rights reserved. This program and the accompanying materials +are made available under the terms of the Eclipse Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/epl-v10.html + +Contributors: + Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>) + </documentation> + </annotation> + +</schema> diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/org.eclipse.emf.facet.efacet.core.query.evaluatorregistration.exsd b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/org.eclipse.emf.facet.efacet.core.query.evaluatorregistration.exsd index 847dcf985ab..d1b73cd4374 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/org.eclipse.emf.facet.efacet.core.query.evaluatorregistration.exsd +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/org.eclipse.emf.facet.efacet.core.query.evaluatorregistration.exsd @@ -1,95 +1,95 @@ -<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.papyrus.emf.facet.efacet.core.query.evaluatorregistration" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.eclipse.papyrus.emf.facet.efacet.core.query.evaluatorregistration" id="evaluatorregistration" name="QueryEvaluatorRegistration"/>
- </appinfo>
- <documentation>
- Allow the registration of a queryEvaluatorFactory.
-This factory allows the user to create queryEvaluators conform to the EMF Facet framework.
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="queryEvaluatorRegistration" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="queryEvaluatorRegistration">
- <complexType>
- <attribute name="class" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryEvaluatorFactory"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- 0.1.0
- </documentation>
- </annotation>
-
-
-
-
- <annotation>
- <appinfo>
- <meta.section type="copyright"/>
- </appinfo>
- <documentation>
- Copyright (c) 2011 Mia-Software.
-
- All rights reserved. This program and the accompanying materials
- are made available under the terms of the Eclipse Public License v1.0
- which accompanies this distribution, and is available at
- http://www.eclipse.org/legal/epl-v10.html
-
-Contributors:
- - Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
- </documentation>
- </annotation>
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.papyrus.emf.facet.efacet.core.query.evaluatorregistration" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appinfo> + <meta.schema plugin="org.eclipse.papyrus.emf.facet.efacet.core.query.evaluatorregistration" id="evaluatorregistration" name="QueryEvaluatorRegistration"/> + </appinfo> + <documentation> + Allow the registration of a queryEvaluatorFactory. +This factory allows the user to create queryEvaluators conform to the EMF Facet framework. + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appinfo> + <meta.element /> + </appinfo> + </annotation> + <complexType> + <sequence> + <element ref="queryEvaluatorRegistration" minOccurs="1" maxOccurs="unbounded"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appinfo> + <meta.attribute translatable="true"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="queryEvaluatorRegistration"> + <complexType> + <attribute name="class" type="string"> + <annotation> + <documentation> + + </documentation> + <appinfo> + <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryEvaluatorFactory"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appinfo> + <meta.section type="since"/> + </appinfo> + <documentation> + 0.1.0 + </documentation> + </annotation> + + + + + <annotation> + <appinfo> + <meta.section type="copyright"/> + </appinfo> + <documentation> + Copyright (c) 2011 Mia-Software. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + which accompanies this distribution, and is available at + http://www.eclipse.org/legal/epl-v10.html + +Contributors: + - Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet + </documentation> + </annotation> + +</schema> diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/queryImplementationRegistration.exsd b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/queryImplementationRegistration.exsd index 7d5a45cc173..383b1259acb 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/queryImplementationRegistration.exsd +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/schema/queryImplementationRegistration.exsd @@ -1,122 +1,122 @@ -<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.papyrus.emf.facet.efacet.core" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.eclipse.papyrus.emf.facet.efacet.core" id="queryImplementationRegistration" name="EMF Facet Query Implementation Registration"/>
- </appinfo>
- <documentation>
- Used to register an IQueryImplementationFactory, that creates instances of IQueryImplementation. The IQueryImplementation provides an implementation for a given type of queries (e.g. Java queries, OCL queries, ...)
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="queryImplementationRegistration" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute translatable="true"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="queryImplementationRegistration">
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- Provides an implementation for an IQueryImplementationFactory, which instantiates IQueryImplementation for a given type of queries.
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- 0.2.0
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="examples"/>
- </appinfo>
- <documentation>
- <pre>
- <extension point="org.eclipse.papyrus.emf.facet.efacet.core.queryImplementationRegistration">
- <queryImplementationRegistration
- class="org.eclipse.papyrus.emf.facet.efacet.core.tests.internal.DummyQueryEvaluatorFactory">
- </queryImplementationRegistration>
- </extension>
-</pre>
- </documentation>
- </annotation>
-
-
- <annotation>
- <appinfo>
- <meta.section type="implementation"/>
- </appinfo>
- <documentation>
- <p>
-See plug-ins:
-<ul>
-<li>org.eclipse.papyrus.emf.facet.query.java.core
-</ul>
-</p>
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="copyright"/>
- </appinfo>
- <documentation>
- Copyright (c) 2011, 2012 Mia-Software.
-
- All rights reserved. This program and the accompanying materials
- are made available under the terms of the Eclipse Public License v1.0
- which accompanies this distribution, and is available at
- http://www.eclipse.org/legal/epl-v10.html
-
-Contributors:
- Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
- Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- </documentation>
- </annotation>
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.papyrus.emf.facet.efacet.core" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appinfo> + <meta.schema plugin="org.eclipse.papyrus.emf.facet.efacet.core" id="queryImplementationRegistration" name="EMF Facet Query Implementation Registration"/> + </appinfo> + <documentation> + Used to register an IQueryImplementationFactory, that creates instances of IQueryImplementation. The IQueryImplementation provides an implementation for a given type of queries (e.g. Java queries, OCL queries, ...) + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appinfo> + <meta.element /> + </appinfo> + </annotation> + <complexType> + <sequence> + <element ref="queryImplementationRegistration" minOccurs="1" maxOccurs="unbounded"/> + </sequence> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appinfo> + <meta.attribute translatable="true"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="queryImplementationRegistration"> + <complexType> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + Provides an implementation for an IQueryImplementationFactory, which instantiates IQueryImplementation for a given type of queries. + </documentation> + <appinfo> + <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appinfo> + <meta.section type="since"/> + </appinfo> + <documentation> + 0.2.0 + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="examples"/> + </appinfo> + <documentation> + <pre> + <extension point="org.eclipse.papyrus.emf.facet.efacet.core.queryImplementationRegistration"> + <queryImplementationRegistration + class="org.eclipse.papyrus.emf.facet.efacet.core.tests.internal.DummyQueryEvaluatorFactory"> + </queryImplementationRegistration> + </extension> +</pre> + </documentation> + </annotation> + + + <annotation> + <appinfo> + <meta.section type="implementation"/> + </appinfo> + <documentation> + <p> +See plug-ins: +<ul> +<li>org.eclipse.papyrus.emf.facet.query.java.core +</ul> +</p> + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="copyright"/> + </appinfo> + <documentation> + Copyright (c) 2011, 2012 Mia-Software. + + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + which accompanies this distribution, and is available at + http://www.eclipse.org/legal/epl-v10.html + +Contributors: + Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2 + Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + </documentation> + </annotation> + +</schema> diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IDerivedTypedElementManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IDerivedTypedElementManager.java index dfbaefe063c..2ff89b4dd70 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IDerivedTypedElementManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IDerivedTypedElementManager.java @@ -1,172 +1,172 @@ -/**
- * Copyright (c) 2011, 2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
- * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
- * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
- * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- */
-package org.eclipse.papyrus.emf.facet.efacet.core;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EOperation;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.DerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult;
-
-/**
- * Used to evaluate derived typed elements through their queries.
- *
- * @since 0.2
- */
-public interface IDerivedTypedElementManager {
- IDerivedTypedElementManager INSTANCE = new DerivedTypedElementManager();
-
- /**
- * Evaluates a derived typed element on a model element.
- * <p>
- * <b>Note:</b> this method does not return a typed result, and it does not check the result type. Use {@link IDerivedTypedElementManager#evaluateSingleValued(DerivedTypedElement, EObject, List, Class)
- * evaluateSingleValued} or {@link IDerivedTypedElementManager#evaluateMultiValued(DerivedTypedElement, EObject, List, Class)
- * evaluateMultiValued} instead if you want a typed and type-checked result.
- *
- * @param derivedTE
- * the derived typed element to evaluate
- * @param source
- * the model element on which the derived typed element must be
- * evaluated
- * @param parameterValues
- * the arguments of the derived typed element (in the case of a {@link FacetOperation}; can be <code>null</code> if there are
- * no parameters)
- * @return the derived typed element result: a single Object in the case of
- * a single-valued derived typed element, or a List in the case of a
- * multi-valued derived typed element.
- * @throws DerivedTypedElementException
- * <ul>
- * <li>in case of error in the derived typed element</li> <li>in case of error when evaluating the derived typed element</li>
- * </ul>
- */
- Object evaluate(DerivedTypedElement derivedTE, EObject source,
- List<ParameterValue> parameterValues, IFacetManager facetManager)
- throws DerivedTypedElementException;
-
- /**
- * Evaluates a query on a model element. Calling this method is discouraged. You should evaluate a {@link DerivedTypedElement}s (which contains a query) instead of trying to evaluate a {@link Query} directly.
- * Since the source type, return type and multiplicity of a query are carried by the {@link DerivedTypedElement} that normally contains it, this method doesn't check the source type, return type or multiplicity.
- *
- * @param query
- * the query to evaluate
- * @param source
- * the model element on which the query must be evaluated
- * @param parameterValues
- * the arguments of the query (in the case of a query for a {@link FacetOperation}; can be <code>null</code> if there are no parameters)
- * @return the query result: may be a single Object or a List.
- * @throws DerivedTypedElementException
- * if the evaluation failed
- */
- Object evaluate(Query query, EObject source, List<ParameterValue> parameterValues, IFacetManager facetManager)
- throws DerivedTypedElementException;
-
- /**
- * Evaluates a single valued derived typed element on a model element.
- *
- * @param derivedTE
- * the derived typed element to evaluate
- * @param source
- * the model element on which the derived typed element is
- * evaluated
- * @param parameterValues
- * the arguments of the derived typed element (in the case of a {@link FacetOperation}; can be <code>null</code> if there are
- * no parameters)
- * @param resultType
- * the type that the returned value must have
- * @return the result of the evaluation
- * @throws DerivedTypedElementException
- * <ul>
- * <li>in case of error in the derived typed element</li>
- * <li>in case of error when evaluating the derived typed element</li>
- * <li>
- * if the effective return type does not match the expected type</li>
- * </ul>
- */
- <T> T evaluateSingleValued(DerivedTypedElement derivedTE, EObject source,
- List<ParameterValue> parameterValues, Class<T> resultType,
- IFacetManager facetManager) throws DerivedTypedElementException;
-
- /**
- * Evaluates a multi-valued derived typed element on a model element.
- *
- * @param derivedTypedElement
- * the derived typed element to evaluate
- * @param source
- * the model element on which the derived typed element must be
- * evaluated
- * @param parameterValues
- * the arguments of the derived typed element (in the case of a {@link FacetOperation}; can be <code>null</code> if there are
- * no parameters)
- * @param resultType
- * the type that the returned value must have
- * @return the result of the evaluation
- * @throws DerivedTypedElementException
- * <ul>
- * <li>in case of error in the derived typed element</li>
- * <li>in case of error when evaluating the derived typed element</li>
- * <li>if the effective return type does not match the expected type</li>
- * </ul>
- */
- <T> List<T> evaluateMultiValued(DerivedTypedElement derivedTE,
- EObject source, List<ParameterValue> parameterValues,
- Class<T> resultType, IFacetManager facetManager)
- throws DerivedTypedElementException;
-
- /**
- * Evaluates a derived typed element on a list of model elements in a single
- * call.
- *
- * @param derivedTE
- * the derived typed element to evaluate
- * @param sources
- * the model elements on which the derived typed element must be
- * evaluated
- * @param parameterValues
- * the arguments of the derived typed element (in the case of a {@link FacetOperation}; can be <code>null</code> if there are
- * no parameters)
- * @param resultType
- * the expected type of the returned list:
- * <ul>
- * <li> {@link DerivedTypedElementEObjectResult} if the {@link DerivedTypedElement} is a single-valued {@link EReference} or {@link EOperation} that returns EObjects
- * <li>{@link DerivedTypedElementEObjectListResult} if the {@link DerivedTypedElement} is a multi-valued {@link EReference} or {@link EOperation} that returns EObjects
- * <li>{@link DerivedTypedElementPrimitiveTypeResult} if the {@link DerivedTypedElement} is a single-valued {@link EAttribute} or {@link EOperation} that returns a primitive type value
- * <li>{@link DerivedTypedElementPrimitiveTypeListResult} if the {@link DerivedTypedElement} is a multi-valued {@link EAttribute} or {@link EOperation} that returns a list of primitive type values
- * </ul>
- * @return one derived typed element result for each source element that was
- * evaluated
- * @throws DerivedTypedElementException
- * <ul>
- * <li>in case of error in the derived typed element. <b>Note</b>: an error that happens when evaluating the derived typed element on any of the given sources is not thrown but stored in the corresponding element result.</li>
- * <li>if the effective return type does not match the expected type</li>
- * </ul>
- */
- <T extends ETypedElementResult> List<T> batchEvaluate(
- DerivedTypedElement derivedTE,
- Collection<? extends EObject> sources,
- List<ParameterValue> parameterValues, Class<T> resultType,
- IFacetManager facetManager) throws DerivedTypedElementException;
-}
+/** + * Copyright (c) 2011, 2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet + * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values. + * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel + * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2 + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet. + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + */ +package org.eclipse.papyrus.emf.facet.efacet.core; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.DerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult; + +/** + * Used to evaluate derived typed elements through their queries. + * + * @since 0.2 + */ +public interface IDerivedTypedElementManager { + IDerivedTypedElementManager INSTANCE = new DerivedTypedElementManager(); + + /** + * Evaluates a derived typed element on a model element. + * <p> + * <b>Note:</b> this method does not return a typed result, and it does not check the result type. Use {@link IDerivedTypedElementManager#evaluateSingleValued(DerivedTypedElement, EObject, List, Class) + * evaluateSingleValued} or {@link IDerivedTypedElementManager#evaluateMultiValued(DerivedTypedElement, EObject, List, Class) + * evaluateMultiValued} instead if you want a typed and type-checked result. + * + * @param derivedTE + * the derived typed element to evaluate + * @param source + * the model element on which the derived typed element must be + * evaluated + * @param parameterValues + * the arguments of the derived typed element (in the case of a {@link FacetOperation}; can be <code>null</code> if there are + * no parameters) + * @return the derived typed element result: a single Object in the case of + * a single-valued derived typed element, or a List in the case of a + * multi-valued derived typed element. + * @throws DerivedTypedElementException + * <ul> + * <li>in case of error in the derived typed element</li> <li>in case of error when evaluating the derived typed element</li> + * </ul> + */ + Object evaluate(DerivedTypedElement derivedTE, EObject source, + List<ParameterValue> parameterValues, IFacetManager facetManager) + throws DerivedTypedElementException; + + /** + * Evaluates a query on a model element. Calling this method is discouraged. You should evaluate a {@link DerivedTypedElement}s (which contains a query) instead of trying to evaluate a {@link Query} directly. + * Since the source type, return type and multiplicity of a query are carried by the {@link DerivedTypedElement} that normally contains it, this method doesn't check the source type, return type or multiplicity. + * + * @param query + * the query to evaluate + * @param source + * the model element on which the query must be evaluated + * @param parameterValues + * the arguments of the query (in the case of a query for a {@link FacetOperation}; can be <code>null</code> if there are no parameters) + * @return the query result: may be a single Object or a List. + * @throws DerivedTypedElementException + * if the evaluation failed + */ + Object evaluate(Query query, EObject source, List<ParameterValue> parameterValues, IFacetManager facetManager) + throws DerivedTypedElementException; + + /** + * Evaluates a single valued derived typed element on a model element. + * + * @param derivedTE + * the derived typed element to evaluate + * @param source + * the model element on which the derived typed element is + * evaluated + * @param parameterValues + * the arguments of the derived typed element (in the case of a {@link FacetOperation}; can be <code>null</code> if there are + * no parameters) + * @param resultType + * the type that the returned value must have + * @return the result of the evaluation + * @throws DerivedTypedElementException + * <ul> + * <li>in case of error in the derived typed element</li> + * <li>in case of error when evaluating the derived typed element</li> + * <li> + * if the effective return type does not match the expected type</li> + * </ul> + */ + <T> T evaluateSingleValued(DerivedTypedElement derivedTE, EObject source, + List<ParameterValue> parameterValues, Class<T> resultType, + IFacetManager facetManager) throws DerivedTypedElementException; + + /** + * Evaluates a multi-valued derived typed element on a model element. + * + * @param derivedTypedElement + * the derived typed element to evaluate + * @param source + * the model element on which the derived typed element must be + * evaluated + * @param parameterValues + * the arguments of the derived typed element (in the case of a {@link FacetOperation}; can be <code>null</code> if there are + * no parameters) + * @param resultType + * the type that the returned value must have + * @return the result of the evaluation + * @throws DerivedTypedElementException + * <ul> + * <li>in case of error in the derived typed element</li> + * <li>in case of error when evaluating the derived typed element</li> + * <li>if the effective return type does not match the expected type</li> + * </ul> + */ + <T> List<T> evaluateMultiValued(DerivedTypedElement derivedTE, + EObject source, List<ParameterValue> parameterValues, + Class<T> resultType, IFacetManager facetManager) + throws DerivedTypedElementException; + + /** + * Evaluates a derived typed element on a list of model elements in a single + * call. + * + * @param derivedTE + * the derived typed element to evaluate + * @param sources + * the model elements on which the derived typed element must be + * evaluated + * @param parameterValues + * the arguments of the derived typed element (in the case of a {@link FacetOperation}; can be <code>null</code> if there are + * no parameters) + * @param resultType + * the expected type of the returned list: + * <ul> + * <li> {@link DerivedTypedElementEObjectResult} if the {@link DerivedTypedElement} is a single-valued {@link EReference} or {@link EOperation} that returns EObjects + * <li>{@link DerivedTypedElementEObjectListResult} if the {@link DerivedTypedElement} is a multi-valued {@link EReference} or {@link EOperation} that returns EObjects + * <li>{@link DerivedTypedElementPrimitiveTypeResult} if the {@link DerivedTypedElement} is a single-valued {@link EAttribute} or {@link EOperation} that returns a primitive type value + * <li>{@link DerivedTypedElementPrimitiveTypeListResult} if the {@link DerivedTypedElement} is a multi-valued {@link EAttribute} or {@link EOperation} that returns a list of primitive type values + * </ul> + * @return one derived typed element result for each source element that was + * evaluated + * @throws DerivedTypedElementException + * <ul> + * <li>in case of error in the derived typed element. <b>Note</b>: an error that happens when evaluating the derived typed element on any of the given sources is not thrown but stored in the corresponding element result.</li> + * <li>if the effective return type does not match the expected type</li> + * </ul> + */ + <T extends ETypedElementResult> List<T> batchEvaluate( + DerivedTypedElement derivedTE, + Collection<? extends EObject> sources, + List<ParameterValue> parameterValues, Class<T> resultType, + IFacetManager facetManager) throws DerivedTypedElementException; +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IEFacetManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IEFacetManager.java index b44565ea7f3..a24fc9b5930 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IEFacetManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IEFacetManager.java @@ -1,86 +1,86 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
- * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
- */
-package org.eclipse.papyrus.emf.facet.efacet.core;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.efacet.ParameterValue;
-import org.eclipse.papyrus.emf.facet.efacet.Query;
-import org.eclipse.papyrus.emf.facet.efacet.QueryContext;
-import org.eclipse.papyrus.emf.facet.efacet.QueryResult;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.QueryException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.EFacetManager;
-
-/**
- * This interface allows the user to use the EMF Facet API for Query and Facet.
- *
- * @deprecated use {@link IDerivedTypedElementManager} with the new eFacet2 metamodel (https://bugs.eclipse.org/bugs/show_bug.cgi?id=381225)
- */
-@Deprecated
-public interface IEFacetManager {
- IEFacetManager INSTANCE = new EFacetManager();
-
- /**
- * This method is used to evaluate the given {@link Query} on the given {@link EObject} taking
- * into consideration some {@link ParameterValue}
- */
- QueryResult evaluate(final Query query, final EObject eObject,
- final List<ParameterValue> parameterValues);
-
- /**
- * This method is used to evaluate the given {@link Query} on the given {@link EObject}
- */
- QueryResult evaluate(final Query query, final EObject eObject);
-
- /**
- * This method is equivalent to {@link IEFacetManager#evaluate(Query, EObject, List)} but rather
- * than return the errors into a {@link QueryResult} instance, it throws an exception.
- *
- * @param eObject
- * The query evaluation context
- * @return The query result.
- * @throws QueryException
- */
- Object basicEvaluate(final Query query, final EObject eObject,
- final List<ParameterValue> parameterValues) throws QueryException;
-
- /**
- * This method is equivalent to {@link IEFacetManager#evaluate(Query, EObject)} but rather than
- * return the errors into a {@link QueryResult} instance, it throws an exception.
- *
- * @param eObject
- * The query evaluation context
- * @return The query result.
- * @throws QueryException
- */
- Object basicEvaluate(final Query query, final EObject eObject)
- throws QueryException;
-
- /**
- * Evaluate the query on a set of models and model elements described by the <code>queryContext</code> parameter.
- *
- * The query is evaluated on each contextually referred model element and on each element of a
- * contextually referred model.
- *
- * @param queryContext
- * The query evaluation context described by a QueryContext instance.
- * @param parameterValues
- * The query parameter values.
- * @return A list of QueryResult (one per evaluation)
- * @throws QueryException
- */
- List<QueryResult> evaluate(final Query query,
- final QueryContext queryContext,
- final List<ParameterValue> parameterValues) throws QueryException;
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet + * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels + */ +package org.eclipse.papyrus.emf.facet.efacet.core; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.efacet.Query; +import org.eclipse.papyrus.emf.facet.efacet.QueryContext; +import org.eclipse.papyrus.emf.facet.efacet.QueryResult; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.QueryException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.EFacetManager; + +/** + * This interface allows the user to use the EMF Facet API for Query and Facet. + * + * @deprecated use {@link IDerivedTypedElementManager} with the new eFacet2 metamodel (https://bugs.eclipse.org/bugs/show_bug.cgi?id=381225) + */ +@Deprecated +public interface IEFacetManager { + IEFacetManager INSTANCE = new EFacetManager(); + + /** + * This method is used to evaluate the given {@link Query} on the given {@link EObject} taking + * into consideration some {@link ParameterValue} + */ + QueryResult evaluate(final Query query, final EObject eObject, + final List<ParameterValue> parameterValues); + + /** + * This method is used to evaluate the given {@link Query} on the given {@link EObject} + */ + QueryResult evaluate(final Query query, final EObject eObject); + + /** + * This method is equivalent to {@link IEFacetManager#evaluate(Query, EObject, List)} but rather + * than return the errors into a {@link QueryResult} instance, it throws an exception. + * + * @param eObject + * The query evaluation context + * @return The query result. + * @throws QueryException + */ + Object basicEvaluate(final Query query, final EObject eObject, + final List<ParameterValue> parameterValues) throws QueryException; + + /** + * This method is equivalent to {@link IEFacetManager#evaluate(Query, EObject)} but rather than + * return the errors into a {@link QueryResult} instance, it throws an exception. + * + * @param eObject + * The query evaluation context + * @return The query result. + * @throws QueryException + */ + Object basicEvaluate(final Query query, final EObject eObject) + throws QueryException; + + /** + * Evaluate the query on a set of models and model elements described by the <code>queryContext</code> parameter. + * + * The query is evaluated on each contextually referred model element and on each element of a + * contextually referred model. + * + * @param queryContext + * The query evaluation context described by a QueryContext instance. + * @param parameterValues + * The query parameter values. + * @return A list of QueryResult (one per evaluation) + * @throws QueryException + */ + List<QueryResult> evaluate(final Query query, + final QueryContext queryContext, + final List<ParameterValue> parameterValues) throws QueryException; +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetAction.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetAction.java index ae5d8f16d41..03f8ef056c4 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetAction.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetAction.java @@ -1,134 +1,134 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Guyomar (Mia-Software) - Bug 338813 - [EMF Facet Framework] basic Facet actions
- * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
- */
-package org.eclipse.papyrus.emf.facet.efacet.core;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.ecore.EOperation;
-import org.eclipse.emf.ecore.EParameter;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.emf.facet.efacet.Facet;
-import org.eclipse.papyrus.emf.facet.efacet.FacetAttribute;
-import org.eclipse.papyrus.emf.facet.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.FacetReference;
-import org.eclipse.papyrus.emf.facet.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.FacetActionImpl;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.incubatingapi.IFacetActions2;
-import org.eclipse.papyrus.emf.facet.util.emf.core.exception.InvalidFacetSetException;
-
-/**
- * This interface contains methods declaration to deal with {@link Facet} and {@link FacetSet}.
- *
- * @since 0.1
- * @noimplement
- * @noextend
- * @deprecated use {@link IFacetActions2} with the new eFacet2 metamodel (https://bugs.eclipse.org/bugs/show_bug.cgi?id=381226)
- */
-@Deprecated
-public interface IFacetAction {
-
- IFacetAction INSTANCE = new FacetActionImpl();
-
- /**
- * Add the given facetSet to the given facetSet model file, which will be created
- *
- * @param facetSet
- * the facetSet to be created. Cannot be <code>null</code>
- * @param project
- * the new file in which the facetSet has to be created. Cannot be <code>null</code>,
- * and cannot already exist
- * @since 0.2
- */
- void createFacetSet(FacetSet facetSet, IFile file) throws IOException,
- InvalidFacetSetException;
-
- /**
- * Add the given {@link Facet} to the given {@link FacetSet}
- *
- * @param facetSet
- * the parent facetSet, cannot be null
- * @param facet
- * the {@link Facet}, cannot be null, or contained by a resource
- * @param editingDomain
- * the editing domain needed to perform the Add EMF command, cannot be null
- */
- Facet createFacetInFacetSet(FacetSet facetSet, Facet facet,
- EditingDomain editingDomain);
-
- /**
- * Add the given {@link FacetAttribute} to the given {@link Facet}
- *
- * @param facet
- * the parent {@link Facet}, cannot be null
- * @param facetAttribute
- * the {@link FacetAttribute}, cannot be null, or contained by a resource
- * @param editingDomain
- * the editing domain needed to perform the Add Emf command, cannot be null
- */
- void addAttributeInFacet(Facet facet, FacetAttribute facetAttribute,
- EditingDomain editingDomain);
-
- /**
- * Add the given {@link FacetReference} to the given {@link Facet}
- *
- * @param facet
- * the parent {@link Facet}, cannot be null
- * @param facetReference
- * the {@link FacetReference}, cannot be null, or contained by a resource
- * @param editingDomain
- * the editing domain needed to perform the Add Emf command, cannot be null
- */
- void addReferenceInFacet(Facet facet, FacetReference facetReference,
- EditingDomain editingDomain);
-
- /**
- * Add a new {@link FacetOperation} to the given {@link Facet}
- *
- * @param facet
- * the parent {@link Facet}, cannot be null
- * @param facetOperation
- * the new {@link FacetOperation}, cannot be null, or contained by a resource
- * @param editingDomain
- * the editing domain needed to perform the Add Emf command, cannot be null
- */
- void addOperationInFacet(Facet facet, FacetOperation facetOperation,
- EditingDomain editingDomain);
-
- /**
- * Add a new {@link EParameter} to the given {@link FacetOperation}
- *
- * @param operation
- * the parent {@link EOperation}
- * @param parameter
- * the new {@link EParameter}
- * @param editingDomain
- * the editing domain needed to perform the Add Emf command, cannot be null
- */
- void addParameterInOperation(FacetOperation operation,
- EParameter parameter, EditingDomain editingDomain);
-
- /**
- * Set the given URI to the given {@link FacetSet}
- *
- * @param facetSet
- * the {@link FacetSet} to be modified
- * @param nsUri
- * the Uri
- * @param editingDomain
- * the editing domain needed to perform the Set Emf command, cannot be null
- */
- void setFacetSetNsUri(FacetSet facetSet, String nsUri,
- EditingDomain editingDomain);
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Guyomar (Mia-Software) - Bug 338813 - [EMF Facet Framework] basic Facet actions + * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels + */ +package org.eclipse.papyrus.emf.facet.efacet.core; + +import java.io.IOException; + +import org.eclipse.core.resources.IFile; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EParameter; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.emf.facet.efacet.Facet; +import org.eclipse.papyrus.emf.facet.efacet.FacetAttribute; +import org.eclipse.papyrus.emf.facet.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.FacetReference; +import org.eclipse.papyrus.emf.facet.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.FacetActionImpl; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.incubatingapi.IFacetActions2; +import org.eclipse.papyrus.emf.facet.util.emf.core.exception.InvalidFacetSetException; + +/** + * This interface contains methods declaration to deal with {@link Facet} and {@link FacetSet}. + * + * @since 0.1 + * @noimplement + * @noextend + * @deprecated use {@link IFacetActions2} with the new eFacet2 metamodel (https://bugs.eclipse.org/bugs/show_bug.cgi?id=381226) + */ +@Deprecated +public interface IFacetAction { + + IFacetAction INSTANCE = new FacetActionImpl(); + + /** + * Add the given facetSet to the given facetSet model file, which will be created + * + * @param facetSet + * the facetSet to be created. Cannot be <code>null</code> + * @param project + * the new file in which the facetSet has to be created. Cannot be <code>null</code>, + * and cannot already exist + * @since 0.2 + */ + void createFacetSet(FacetSet facetSet, IFile file) throws IOException, + InvalidFacetSetException; + + /** + * Add the given {@link Facet} to the given {@link FacetSet} + * + * @param facetSet + * the parent facetSet, cannot be null + * @param facet + * the {@link Facet}, cannot be null, or contained by a resource + * @param editingDomain + * the editing domain needed to perform the Add EMF command, cannot be null + */ + Facet createFacetInFacetSet(FacetSet facetSet, Facet facet, + EditingDomain editingDomain); + + /** + * Add the given {@link FacetAttribute} to the given {@link Facet} + * + * @param facet + * the parent {@link Facet}, cannot be null + * @param facetAttribute + * the {@link FacetAttribute}, cannot be null, or contained by a resource + * @param editingDomain + * the editing domain needed to perform the Add Emf command, cannot be null + */ + void addAttributeInFacet(Facet facet, FacetAttribute facetAttribute, + EditingDomain editingDomain); + + /** + * Add the given {@link FacetReference} to the given {@link Facet} + * + * @param facet + * the parent {@link Facet}, cannot be null + * @param facetReference + * the {@link FacetReference}, cannot be null, or contained by a resource + * @param editingDomain + * the editing domain needed to perform the Add Emf command, cannot be null + */ + void addReferenceInFacet(Facet facet, FacetReference facetReference, + EditingDomain editingDomain); + + /** + * Add a new {@link FacetOperation} to the given {@link Facet} + * + * @param facet + * the parent {@link Facet}, cannot be null + * @param facetOperation + * the new {@link FacetOperation}, cannot be null, or contained by a resource + * @param editingDomain + * the editing domain needed to perform the Add Emf command, cannot be null + */ + void addOperationInFacet(Facet facet, FacetOperation facetOperation, + EditingDomain editingDomain); + + /** + * Add a new {@link EParameter} to the given {@link FacetOperation} + * + * @param operation + * the parent {@link EOperation} + * @param parameter + * the new {@link EParameter} + * @param editingDomain + * the editing domain needed to perform the Add Emf command, cannot be null + */ + void addParameterInOperation(FacetOperation operation, + EParameter parameter, EditingDomain editingDomain); + + /** + * Set the given URI to the given {@link FacetSet} + * + * @param facetSet + * the {@link FacetSet} to be modified + * @param nsUri + * the Uri + * @param editingDomain + * the editing domain needed to perform the Set Emf command, cannot be null + */ + void setFacetSetNsUri(FacetSet facetSet, String nsUri, + EditingDomain editingDomain); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetActions.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetActions.java index 0471fd04423..e6d2adc6630 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetActions.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetActions.java @@ -1,45 +1,45 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
- */
-package org.eclipse.papyrus.emf.facet.efacet.core;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.FacetActionsImpl;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.util.emf.core.exception.InvalidFacetSetException;
-
-/**
- * This interface contains methods to create {@link FacetSet}s.
- *
- * @since 0.3
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface IFacetActions {
-
- IFacetActions INSTANCE = new FacetActionsImpl();
-
- /**
- * Add the given facetSet to the given facetSet model file, which will be
- * created
- *
- * @param facetSet
- * the facetSet to be created. Cannot be <code>null</code>
- * @param file
- * the new file in which the facetSet has to be created. Cannot
- * be <code>null</code>, and cannot already exist
- */
- void saveFacetSet(FacetSet facetSet, IFile file) throws IOException,
- InvalidFacetSetException;
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors + */ +package org.eclipse.papyrus.emf.facet.efacet.core; + +import java.io.IOException; + +import org.eclipse.core.resources.IFile; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.FacetActionsImpl; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.util.emf.core.exception.InvalidFacetSetException; + +/** + * This interface contains methods to create {@link FacetSet}s. + * + * @since 0.3 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface IFacetActions { + + IFacetActions INSTANCE = new FacetActionsImpl(); + + /** + * Add the given facetSet to the given facetSet model file, which will be + * created + * + * @param facetSet + * the facetSet to be created. Cannot be <code>null</code> + * @param file + * the new file in which the facetSet has to be created. Cannot + * be <code>null</code>, and cannot already exist + */ + void saveFacetSet(FacetSet facetSet, IFile file) throws IOException, + InvalidFacetSetException; + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetCommandFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetCommandFactory.java index d655fe78c98..ec0d7bafe21 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetCommandFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetCommandFactory.java @@ -1,193 +1,193 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
- * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
- */
-package org.eclipse.papyrus.emf.facet.efacet.core;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EParameter;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-
-/**
- * This interface provide a command factory. A command modify the editingDomain.
- *
- * @since 0.3
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface IFacetCommandFactory {
-
- /**
- * Create the command to add a FacetSet (facetSet) to an existing FacetSet
- * (parent).
- *
- * @param parent
- * the parent of the facetSet to add.
- * @param facetSet
- * the facetSet to add.
- * @return the command.
- */
- Command createFacetSetInFacetSetCommand(FacetSet parent, FacetSet facetSet);
-
- /**
- * Create the command to add a Facet (facet) to an existing FacetSet
- * (parent).
- *
- * @param parent
- * the parent of the facet to add.
- * @param facet
- * the facet to add.
- * @return the command.
- */
- Command createFacetInFacetSetCommand(FacetSet parent, Facet facet);
-
- /**
- * Create the command to add an Attribute (facetAttrbute) to an existing
- * Facet (parent).
- *
- * @param parent
- * the parent of the attribute to add.
- * @param facetAttrbute
- * the attribute to add.
- * @return the command.
- */
- Command createEditFacetStructuralFeatureCommand(
- final DerivedTypedElement feature, final Facet container,
- final String name, final int lowerBd, final int upperBd,
- final EClassifier type, final boolean ordered,
- final boolean unique, final Query query, final boolean volatilee,
- final boolean change, final boolean derived,
- final boolean transientt);
-
- /**
- * Create the command to add a Reference (facetReference) to an existing
- * Facet (parent).
- *
- * @param parent
- * the parent of the reference to add.
- * @param facetReference
- * the reference to add.
- * @return the command.
- */
- Command createAddReferenceInFacetCommand(Facet parent,
- FacetReference facetReference);
-
- /**
- * Create the command to add an Operation (FacetOperation) to an existing
- * Facet (parent).
- *
- * @param parent
- * the parent of the operation to add.
- * @param facetOperation
- * the operation to add.
- * @return the command.
- */
- Command createAddOperationInFacetCommand(Facet parent,
- FacetOperation facetOperation);
-
- /**
- * Create the command to add a Parameter (operationParameter) to an existing
- * Operation (parent).
- *
- * @param parent
- * the parent of the operation to add.
- * @param facetOperation
- * the operation to add.
- * @return the command.
- */
- Command createAddParameterInOperationCommand(FacetOperation parent,
- EParameter opeParameter);
-
- /**
- * Create the command to change the owner of an element.
- *
- * @param element
- * @param newOwner
- * @return
- */
- Command createChangeOwnerCommand(Object element, Object newOwner);
-
- /**
- * Create the command to change the attributes of a FacetSet.
- *
- * @param initialElement
- * @param newElement
- * @param newElement
- * @return
- */
- Command createEditFacetSetCommand(final FacetSet editedFacetSet,
- final FacetSet container, final String name);
-
- /**
- * Create the command to change the attributes of a Facet.
- *
- * @param initialElement
- * @param newElement
- * @return
- */
- Command createEditFacetCommand(Facet facet, FacetSet container,
- String name, ETypedElement conformance, EClass extendEClass,
- FacetSet extendedFacetSet);
-
- /**
- * Create the command to change the attributes of a FacetAttribute.
- *
- * @param initialElement
- * @param newElement
- * @return
- */
- Command createSetFacetAttributeCommand(final Facet initialContainer,
- final FacetAttribute initialElement,
- final FacetAttribute newElement);
-
- /**
- * Create the command to change the attributes of a FacetReference.
- *
- * @param initialElement
- * @param newElement
- * @return
- */
- Command createSetFacetReferenceCommand(final Facet initialContainer,
- final FacetReference initialElement,
- final FacetReference newElement);
-
- /**
- * Create the command to change the attributes of a FacetOperation.
- *
- * @param initialElement
- * @param newElement
- * @return
- */
- Command createEditFacetOperationCommand(DerivedTypedElement dte,
- Facet facetContainer, String name, int lowerBound, int upperBound,
- EClassifier type, boolean ordered, boolean unique, Query query);
-
- /**
- * Create the command to change the attributes of a FacetAttribute.
- *
- * @param initialElement
- * @param newElement
- * @return
- */
- Command createEditOperationParameterCommand(EParameter parameter,
- FacetOperation container, String name, int lowerBound,
- int upperBound, EClassifier type, boolean ordered, boolean unique);
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors + * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors + */ +package org.eclipse.papyrus.emf.facet.efacet.core; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EParameter; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; + +/** + * This interface provide a command factory. A command modify the editingDomain. + * + * @since 0.3 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface IFacetCommandFactory { + + /** + * Create the command to add a FacetSet (facetSet) to an existing FacetSet + * (parent). + * + * @param parent + * the parent of the facetSet to add. + * @param facetSet + * the facetSet to add. + * @return the command. + */ + Command createFacetSetInFacetSetCommand(FacetSet parent, FacetSet facetSet); + + /** + * Create the command to add a Facet (facet) to an existing FacetSet + * (parent). + * + * @param parent + * the parent of the facet to add. + * @param facet + * the facet to add. + * @return the command. + */ + Command createFacetInFacetSetCommand(FacetSet parent, Facet facet); + + /** + * Create the command to add an Attribute (facetAttrbute) to an existing + * Facet (parent). + * + * @param parent + * the parent of the attribute to add. + * @param facetAttrbute + * the attribute to add. + * @return the command. + */ + Command createEditFacetStructuralFeatureCommand( + final DerivedTypedElement feature, final Facet container, + final String name, final int lowerBd, final int upperBd, + final EClassifier type, final boolean ordered, + final boolean unique, final Query query, final boolean volatilee, + final boolean change, final boolean derived, + final boolean transientt); + + /** + * Create the command to add a Reference (facetReference) to an existing + * Facet (parent). + * + * @param parent + * the parent of the reference to add. + * @param facetReference + * the reference to add. + * @return the command. + */ + Command createAddReferenceInFacetCommand(Facet parent, + FacetReference facetReference); + + /** + * Create the command to add an Operation (FacetOperation) to an existing + * Facet (parent). + * + * @param parent + * the parent of the operation to add. + * @param facetOperation + * the operation to add. + * @return the command. + */ + Command createAddOperationInFacetCommand(Facet parent, + FacetOperation facetOperation); + + /** + * Create the command to add a Parameter (operationParameter) to an existing + * Operation (parent). + * + * @param parent + * the parent of the operation to add. + * @param facetOperation + * the operation to add. + * @return the command. + */ + Command createAddParameterInOperationCommand(FacetOperation parent, + EParameter opeParameter); + + /** + * Create the command to change the owner of an element. + * + * @param element + * @param newOwner + * @return + */ + Command createChangeOwnerCommand(Object element, Object newOwner); + + /** + * Create the command to change the attributes of a FacetSet. + * + * @param initialElement + * @param newElement + * @param newElement + * @return + */ + Command createEditFacetSetCommand(final FacetSet editedFacetSet, + final FacetSet container, final String name); + + /** + * Create the command to change the attributes of a Facet. + * + * @param initialElement + * @param newElement + * @return + */ + Command createEditFacetCommand(Facet facet, FacetSet container, + String name, ETypedElement conformance, EClass extendEClass, + FacetSet extendedFacetSet); + + /** + * Create the command to change the attributes of a FacetAttribute. + * + * @param initialElement + * @param newElement + * @return + */ + Command createSetFacetAttributeCommand(final Facet initialContainer, + final FacetAttribute initialElement, + final FacetAttribute newElement); + + /** + * Create the command to change the attributes of a FacetReference. + * + * @param initialElement + * @param newElement + * @return + */ + Command createSetFacetReferenceCommand(final Facet initialContainer, + final FacetReference initialElement, + final FacetReference newElement); + + /** + * Create the command to change the attributes of a FacetOperation. + * + * @param initialElement + * @param newElement + * @return + */ + Command createEditFacetOperationCommand(DerivedTypedElement dte, + Facet facetContainer, String name, int lowerBound, int upperBound, + EClassifier type, boolean ordered, boolean unique, Query query); + + /** + * Create the command to change the attributes of a FacetAttribute. + * + * @param initialElement + * @param newElement + * @return + */ + Command createEditOperationParameterCommand(EParameter parameter, + FacetOperation container, String name, int lowerBound, + int upperBound, EClassifier type, boolean ordered, boolean unique); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetCommandFactoryFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetCommandFactoryFactory.java index 11092a0f212..eca4bdcd576 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetCommandFactoryFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetCommandFactoryFactory.java @@ -1,25 +1,25 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
- */
-package org.eclipse.papyrus.emf.facet.efacet.core;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.FacetCommandFactoryFactory;
-
-/**
- * @since 0.3
- */
-public interface IFacetCommandFactoryFactory {
-
- IFacetCommandFactoryFactory DEFAULT = new FacetCommandFactoryFactory();
-
- IFacetCommandFactory createCommandFactory(EditingDomain editingDomain);
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors + */ +package org.eclipse.papyrus.emf.facet.efacet.core; + +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.FacetCommandFactoryFactory; + +/** + * @since 0.3 + */ +public interface IFacetCommandFactoryFactory { + + IFacetCommandFactoryFactory DEFAULT = new FacetCommandFactoryFactory(); + + IFacetCommandFactory createCommandFactory(EditingDomain editingDomain); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetManager.java index e31d68eac11..aaf1c13dc29 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetManager.java @@ -1,236 +1,236 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Mia-Software
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
- * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
- * Olivier Remaud (Soft-Maint) - Bug 361794 - [Restructuring] EMF Facet customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Thomas Cicognani (Soft-Maint) - Bug 416221 - New methods to get references in FacetManager API
- * Thomas Cicognani (Soft-Maint) - Bug 420193 - Listener on FacetManager
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EOperation;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.FacetManagerException;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult;
-
-/**
- * This interface allows clients to use the EMF Facet API to get and set the values of virtually
- * added {@link EReference}s and {@link EAttribute}s, and invoke {@link EOperation}s.
- * <p>
- * Derived {@link FacetAttribute}s and {@link FacetReference}s are computed by queries, whereas non-derived {@link FacetAttribute}s and {@link EAttribute}s and {@link EReference}s and {@link FacetReference}s are stored in the serialization {@link Resource}
- * specified in the {@link IFacetManagerFactory} that created this {@link IFacetManager}.
- *
- * @since 0.2
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface IFacetManager {
-
- /**
- * Serialize the model containing the structural feature instances.
- */
- void saveStructuralFeatureInstanceModel() throws FacetManagerException;
-
- /**
- * Returns whether the given model element conforms to the given Facet
- *
- * @param eObject
- * the model element
- * @param facet
- * the Facet the applicability of which is being tested
- * @throws FacetManagerException
- * if there is an error evaluating the Facet's conformance typed element
- * @return whether the given model element should be seen as an instance of the given Facet
- */
- boolean isConforming(final EObject eObject, final Facet facet)
- throws FacetManagerException;
-
- /**
- * Set the value of the given {@link EStructuralFeature} on the given {@link EObject} to the given {@link Object} value.
- *
- * @param eObject
- * the model element whose feature must be set
- * @param structuralFeature
- * the feature to set
- * @param newValue
- * the new value
- * @param editingDomain
- * @throws FacetManagerException
- * <ul>
- * <li>if the eObject doesn't conform to the Facet of the given attribute (in the case of a FacetAttribute)</li>
- * <li>if the Facet of the given attribute is not applicable to the given eObject (in the case of a FacetAttribute)</li>
- * <li>
- * if there is an error evaluating the Facet's conformance typed element</li>
- * </ul>
- */
- void set(EObject eObject, EStructuralFeature structuralFeature,
- Object newValue, EditingDomain editingDomain)
- throws FacetManagerException;
-
- /**
- * Evaluate the given {@link EOperation} of the given {@link EObject}. The
- * returned value has to be of the given expectedType {@link Class}
- *
- * @param eObject
- * the model element on which the operation is evaluated
- * @param operation
- * the operation to evaluate
- * @param resultType
- * the expected type of the returned value; if the effective type
- * is not compatible, an UnmatchingExpectedTypeException will be
- * thrown
- * @param arguments
- * the values of the parameters of the EOperation that is
- * evaluated: they must match both in size, types and
- * multiplicity
- * @return the return value of the operation
- * @throws FacetManagerException
- * <ul>
- * <li>if the effective type does not match the expected type</li>
- * <li>in case of an error in the query that returns the value (can only happen in the case of a FacetOperation)</li>
- * <li>in case of an error when delegating to the Ecore reflexive API (if the given EOperation is not a FacetOperation)</li>
- * <li>if the eObject doesn't conform to the Facet of the given operation (in the case of a FacetOperation)</li>
- * <li>if the Facet of the given operation is not applicable to the given eObject (in the case of a FacetOperation)</li>
- * <li>if there is an error evaluating the Facet's conformance typed element</li>
- * <li>if the given actual parameters don't match the EOperation's formal parameters</li>
- * </ul>
- */
- <T> T invoke(EObject eObject, EOperation operation,
- Class<T> resultType, EditingDomain editingDomain,
- Object... arguments) throws FacetManagerException;
-
- /**
- * Invoke the given {@link EOperation} on each element of the given
- * collection of {@link EObject}s.
- *
- * @param eObjects
- * the model elements on which the operation is evaluated
- * @param operation
- * the operation to evaluate
- * @param arguments
- * the values of the parameters of the EOperation that is
- * evaluated: they must match both in size, types and
- * multiplicity
- * @return the list of results, one for each model element of the given <code>eObjects</code>
- * @throws FacetManagerException
- * <ul>
- * <li>in case of an error when delegating to the Ecore reflexive API (if the given EOperation is not a FacetOperation)</li>
- * <li>
- * in case of an error in the derived typed element that returns the value</li>
- * </ul>
- */
- List<ETypedElementResult> batchInvoke(Collection<EObject> eObjects,
- EOperation operation, Object... arguments)
- throws FacetManagerException;
-
- /**
- * This method returns the list of loaded facet sets.
- *
- * @return a modifiable list of all FacetSets that
- * constitute the working context of the FacetManager
- */
- List<FacetSet> getManagedFacetSets();
-
- /** @return the resourceSet used to manage the facet models. */
- ResourceSet getResourceSet();
-
- <T> T getOrInvoke(EObject element, ETypedElement query, Class<T> aClass)
- throws FacetManagerException;
-
- <T> List<T> getOrInvokeMultiValued(EObject eObject, ETypedElement feature,
- Class<T> aClass) throws FacetManagerException;
-
- <T> List<ETypedElementResult> batchGetOrInvoke(Collection<EObject> sources,
- ETypedElement query, Class<T> aClass) throws FacetManagerException;
-
- /**
- * Get virtual references from an EObject. References must be defined in a
- * FacetSet
- *
- * @param eObject
- * Model element
- * @return All not duplicated virtual references
- * @throws FacetManagerException
- * @since 0.4
- */
- Set<EReference> getReferences(EObject eObject) throws FacetManagerException;
-
- /**
- * Get virtual attributes from an EObject. References must be defined in a
- * FacetSet
- *
- * @param eObject
- * Model element
- * @return All not duplicated virtual attributes
- * @throws FacetManagerException
- * @since 0.4
- */
- Set<EAttribute> getAttributes(EObject eObject) throws FacetManagerException;
-
- /**
- * Get virtual references and attributes from an EObject. References must be
- * defined in a FacetSet
- *
- * @param eObject
- * Model element
- * @return All not duplicated virtual references and attributes
- * @throws FacetManagerException
- * @since 0.4
- */
- Set<EStructuralFeature> getStructuralFeature(EObject eObject)
- throws FacetManagerException;
-
- /**
- * Adds a listener to this manager that will be notified when this manager's
- * state changes.
- *
- * @param listener
- * The listener to be added
- * @since 0.4
- */
- void addListener(IFacetManagerListener listener);
-
- /**
- * Removes a listener from this manager.
- *
- * @param listener
- * The listener to be removed
- * @since 0.4
- */
- void removeListener(IFacetManagerListener listener);
-
- /**
- * @param eObject
- * @param classs
- * @return
- */
- <T extends ETypedElement> List<T> getETypedElements(EObject eObject, Class<T> classs) throws FacetManagerException;
-
-
-
-}
+/******************************************************************************* + * Copyright (c) 2011, 2012 Mia-Software + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values. + * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel + * Olivier Remaud (Soft-Maint) - Bug 361794 - [Restructuring] EMF Facet customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet. + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Thomas Cicognani (Soft-Maint) - Bug 416221 - New methods to get references in FacetManager API + * Thomas Cicognani (Soft-Maint) - Bug 420193 - Listener on FacetManager + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core; + +import java.util.Collection; +import java.util.List; +import java.util.Set; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.FacetManagerException; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult; + +/** + * This interface allows clients to use the EMF Facet API to get and set the values of virtually + * added {@link EReference}s and {@link EAttribute}s, and invoke {@link EOperation}s. + * <p> + * Derived {@link FacetAttribute}s and {@link FacetReference}s are computed by queries, whereas non-derived {@link FacetAttribute}s and {@link EAttribute}s and {@link EReference}s and {@link FacetReference}s are stored in the serialization {@link Resource} + * specified in the {@link IFacetManagerFactory} that created this {@link IFacetManager}. + * + * @since 0.2 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface IFacetManager { + + /** + * Serialize the model containing the structural feature instances. + */ + void saveStructuralFeatureInstanceModel() throws FacetManagerException; + + /** + * Returns whether the given model element conforms to the given Facet + * + * @param eObject + * the model element + * @param facet + * the Facet the applicability of which is being tested + * @throws FacetManagerException + * if there is an error evaluating the Facet's conformance typed element + * @return whether the given model element should be seen as an instance of the given Facet + */ + boolean isConforming(final EObject eObject, final Facet facet) + throws FacetManagerException; + + /** + * Set the value of the given {@link EStructuralFeature} on the given {@link EObject} to the given {@link Object} value. + * + * @param eObject + * the model element whose feature must be set + * @param structuralFeature + * the feature to set + * @param newValue + * the new value + * @param editingDomain + * @throws FacetManagerException + * <ul> + * <li>if the eObject doesn't conform to the Facet of the given attribute (in the case of a FacetAttribute)</li> + * <li>if the Facet of the given attribute is not applicable to the given eObject (in the case of a FacetAttribute)</li> + * <li> + * if there is an error evaluating the Facet's conformance typed element</li> + * </ul> + */ + void set(EObject eObject, EStructuralFeature structuralFeature, + Object newValue, EditingDomain editingDomain) + throws FacetManagerException; + + /** + * Evaluate the given {@link EOperation} of the given {@link EObject}. The + * returned value has to be of the given expectedType {@link Class} + * + * @param eObject + * the model element on which the operation is evaluated + * @param operation + * the operation to evaluate + * @param resultType + * the expected type of the returned value; if the effective type + * is not compatible, an UnmatchingExpectedTypeException will be + * thrown + * @param arguments + * the values of the parameters of the EOperation that is + * evaluated: they must match both in size, types and + * multiplicity + * @return the return value of the operation + * @throws FacetManagerException + * <ul> + * <li>if the effective type does not match the expected type</li> + * <li>in case of an error in the query that returns the value (can only happen in the case of a FacetOperation)</li> + * <li>in case of an error when delegating to the Ecore reflexive API (if the given EOperation is not a FacetOperation)</li> + * <li>if the eObject doesn't conform to the Facet of the given operation (in the case of a FacetOperation)</li> + * <li>if the Facet of the given operation is not applicable to the given eObject (in the case of a FacetOperation)</li> + * <li>if there is an error evaluating the Facet's conformance typed element</li> + * <li>if the given actual parameters don't match the EOperation's formal parameters</li> + * </ul> + */ + <T> T invoke(EObject eObject, EOperation operation, + Class<T> resultType, EditingDomain editingDomain, + Object... arguments) throws FacetManagerException; + + /** + * Invoke the given {@link EOperation} on each element of the given + * collection of {@link EObject}s. + * + * @param eObjects + * the model elements on which the operation is evaluated + * @param operation + * the operation to evaluate + * @param arguments + * the values of the parameters of the EOperation that is + * evaluated: they must match both in size, types and + * multiplicity + * @return the list of results, one for each model element of the given <code>eObjects</code> + * @throws FacetManagerException + * <ul> + * <li>in case of an error when delegating to the Ecore reflexive API (if the given EOperation is not a FacetOperation)</li> + * <li> + * in case of an error in the derived typed element that returns the value</li> + * </ul> + */ + List<ETypedElementResult> batchInvoke(Collection<EObject> eObjects, + EOperation operation, Object... arguments) + throws FacetManagerException; + + /** + * This method returns the list of loaded facet sets. + * + * @return a modifiable list of all FacetSets that + * constitute the working context of the FacetManager + */ + List<FacetSet> getManagedFacetSets(); + + /** @return the resourceSet used to manage the facet models. */ + ResourceSet getResourceSet(); + + <T> T getOrInvoke(EObject element, ETypedElement query, Class<T> aClass) + throws FacetManagerException; + + <T> List<T> getOrInvokeMultiValued(EObject eObject, ETypedElement feature, + Class<T> aClass) throws FacetManagerException; + + <T> List<ETypedElementResult> batchGetOrInvoke(Collection<EObject> sources, + ETypedElement query, Class<T> aClass) throws FacetManagerException; + + /** + * Get virtual references from an EObject. References must be defined in a + * FacetSet + * + * @param eObject + * Model element + * @return All not duplicated virtual references + * @throws FacetManagerException + * @since 0.4 + */ + Set<EReference> getReferences(EObject eObject) throws FacetManagerException; + + /** + * Get virtual attributes from an EObject. References must be defined in a + * FacetSet + * + * @param eObject + * Model element + * @return All not duplicated virtual attributes + * @throws FacetManagerException + * @since 0.4 + */ + Set<EAttribute> getAttributes(EObject eObject) throws FacetManagerException; + + /** + * Get virtual references and attributes from an EObject. References must be + * defined in a FacetSet + * + * @param eObject + * Model element + * @return All not duplicated virtual references and attributes + * @throws FacetManagerException + * @since 0.4 + */ + Set<EStructuralFeature> getStructuralFeature(EObject eObject) + throws FacetManagerException; + + /** + * Adds a listener to this manager that will be notified when this manager's + * state changes. + * + * @param listener + * The listener to be added + * @since 0.4 + */ + void addListener(IFacetManagerListener listener); + + /** + * Removes a listener from this manager. + * + * @param listener + * The listener to be removed + * @since 0.4 + */ + void removeListener(IFacetManagerListener listener); + + /** + * @param eObject + * @param classs + * @return + */ + <T extends ETypedElement> List<T> getETypedElements(EObject eObject, Class<T> classs) throws FacetManagerException; + + + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetManagerFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetManagerFactory.java index 30e3bf8050d..a28c217e366 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetManagerFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetManagerFactory.java @@ -1,51 +1,51 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia-Software
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
- * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.FacetManagerFactory;
-
-/**
- * Factory for {@link IFacetManager}.
- *
- * @since 0.2
- */
-public interface IFacetManagerFactory {
-
- /**
- * The singleton instance of the factory.
- */
- IFacetManagerFactory DEFAULT = new FacetManagerFactory();
-
- /**
- * Create an {@link IFacetManager}.
- *
- * @param resource
- * the {@link Resource} in which virtual {@link EStructuralFeature}s are serialized.
- * Can be null if no EStructuralFeature provided a Facet are used.
- */
- IFacetManager getOrCreateFacetManager(Resource resource);
-
- /**
- * Create an {@link IFacetManager}.
- *
- * @param resourceSet
- * the resourceSet which will be used to manage the facet models.
- *
- */
- IFacetManager getOrCreateFacetManager(ResourceSet resourceSet);
-}
+/******************************************************************************* + * Copyright (c) 2011 Mia-Software + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values. + * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core; + +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.FacetManagerFactory; + +/** + * Factory for {@link IFacetManager}. + * + * @since 0.2 + */ +public interface IFacetManagerFactory { + + /** + * The singleton instance of the factory. + */ + IFacetManagerFactory DEFAULT = new FacetManagerFactory(); + + /** + * Create an {@link IFacetManager}. + * + * @param resource + * the {@link Resource} in which virtual {@link EStructuralFeature}s are serialized. + * Can be null if no EStructuralFeature provided a Facet are used. + */ + IFacetManager getOrCreateFacetManager(Resource resource); + + /** + * Create an {@link IFacetManager}. + * + * @param resourceSet + * the resourceSet which will be used to manage the facet models. + * + */ + IFacetManager getOrCreateFacetManager(ResourceSet resourceSet); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetManagerListener.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetManagerListener.java index d3da1619351..8967ddeda03 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetManagerListener.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetManagerListener.java @@ -1,27 +1,27 @@ -/*******************************************************************************
- * Copyright (c) 2013 Mia-Maint
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Thomas Cicognani (Soft-Maint) - Bug 420193 - Listener on FacetManager
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core;
-
-/**
- * This interface allows clients to manage listeners added on the {@link IFacetManager}
- *
- * @since 0.4
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface IFacetManagerListener {
-
- /**
- * Notifies that the {@link IFacetManager} has changed.
- */
- void facetManagerChanged();
-
-}
+/******************************************************************************* + * Copyright (c) 2013 Mia-Maint + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Thomas Cicognani (Soft-Maint) - Bug 420193 - Listener on FacetManager + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core; + +/** + * This interface allows clients to manage listeners added on the {@link IFacetManager} + * + * @since 0.4 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface IFacetManagerListener { + + /** + * Notifies that the {@link IFacetManager} has changed. + */ + void facetManagerChanged(); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetSetCatalogManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetSetCatalogManager.java index 4e658188180..3f26e67f3d9 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetSetCatalogManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetSetCatalogManager.java @@ -1,26 +1,26 @@ -/*******************************************************************************
- * Copyright (c) 2012 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core;
-
-import java.util.Collection;
-
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-
-/**
- * @since 0.2
- */
-public interface IFacetSetCatalogManager {
-
- Collection<FacetSet> getRegisteredFacetSets();
-
- void registerFacetSet(FacetSet facetSet);
-}
+/******************************************************************************* + * Copyright (c) 2012 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core; + +import java.util.Collection; + +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; + +/** + * @since 0.2 + */ +public interface IFacetSetCatalogManager { + + Collection<FacetSet> getRegisteredFacetSets(); + + void registerFacetSet(FacetSet facetSet); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetSetCatalogManagerFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetSetCatalogManagerFactory.java index eee5e3f11eb..c7c9d6be20f 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetSetCatalogManagerFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/IFacetSetCatalogManagerFactory.java @@ -1,26 +1,26 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.efacet.core;
-
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.FacetCatalogManagerFactory;
-
-/**
- * @since 0.2
- */
-public interface IFacetSetCatalogManagerFactory {
-
- IFacetSetCatalogManagerFactory DEFAULT = new FacetCatalogManagerFactory();
-
- IFacetSetCatalogManager getOrCreateFacetSetCatalogManager(ResourceSet resourceSet);
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.efacet.core; + +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.FacetCatalogManagerFactory; + +/** + * @since 0.2 + */ +public interface IFacetSetCatalogManagerFactory { + + IFacetSetCatalogManagerFactory DEFAULT = new FacetCatalogManagerFactory(); + + IFacetSetCatalogManager getOrCreateFacetSetCatalogManager(ResourceSet resourceSet); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/exception/DerivedTypedElementException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/exception/DerivedTypedElementException.java index 7f2436f5eca..3b58727cd24 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/exception/DerivedTypedElementException.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/exception/DerivedTypedElementException.java @@ -1,41 +1,41 @@ -/**
- * Copyright (c) 2009 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - initial API and implementation
- * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.exception;
-
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
-
-/**
- * This exception is raised when something is wrong with a query, and there is not a more specific
- * sub-class to describe the error (e.g. {@link DerivedTypedElementEvaluationException} )
- *
- * @since 0.2
- */
-public class DerivedTypedElementException extends Exception {
-
- // This class is a copy of :
- // org.eclipse.papyrus.emf.facet.infra.query.core.exception.ModelQueryException
-
- private static final long serialVersionUID = -3203874059325745157L;
-
- public DerivedTypedElementException(final String message) {
- super(message);
- }
-
- public DerivedTypedElementException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- public DerivedTypedElementException(final Throwable cause) {
- super(cause);
- }
-
-}
+/** + * Copyright (c) 2009 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - initial API and implementation + * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2 + */ +package org.eclipse.papyrus.emf.facet.efacet.core.exception; + +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException; + +/** + * This exception is raised when something is wrong with a query, and there is not a more specific + * sub-class to describe the error (e.g. {@link DerivedTypedElementEvaluationException} ) + * + * @since 0.2 + */ +public class DerivedTypedElementException extends Exception { + + // This class is a copy of : + // org.eclipse.papyrus.emf.facet.infra.query.core.exception.ModelQueryException + + private static final long serialVersionUID = -3203874059325745157L; + + public DerivedTypedElementException(final String message) { + super(message); + } + + public DerivedTypedElementException(final String message, final Throwable cause) { + super(message, cause); + } + + public DerivedTypedElementException(final Throwable cause) { + super(cause); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/exception/FacetManagerException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/exception/FacetManagerException.java index 5d509a548e2..3ff4bba3fe5 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/exception/FacetManagerException.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/exception/FacetManagerException.java @@ -1,37 +1,37 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.exception;
-
-/**
- * @since 0.2
- */
-public class FacetManagerException extends Exception {
-
- private static final long serialVersionUID = -4670132391244495825L;
-
- public FacetManagerException() {
- super();
- }
-
- public FacetManagerException(final String message) {
- super(message);
- }
-
- public FacetManagerException(final Throwable cause) {
- super(cause);
- }
-
- public FacetManagerException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + */ +package org.eclipse.papyrus.emf.facet.efacet.core.exception; + +/** + * @since 0.2 + */ +public class FacetManagerException extends Exception { + + private static final long serialVersionUID = -4670132391244495825L; + + public FacetManagerException() { + super(); + } + + public FacetManagerException(final String message) { + super(message); + } + + public FacetManagerException(final Throwable cause) { + super(cause); + } + + public FacetManagerException(final String message, final Throwable cause) { + super(message, cause); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/exception/QueryException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/exception/QueryException.java index c5a45f63fad..caa2684fd7d 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/exception/QueryException.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/exception/QueryException.java @@ -1,39 +1,39 @@ -/**
- * Copyright (c) 2009 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - initial API and implementation
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.exception;
-
-/**
- * This exception is raised when something is wrong with a query, and there is not a more specific
- * sub-class to describe the error (e.g. {@link QueryExecutionException} )
- *
- * @deprecated replaced by {@link DerivedTypedElementException}
- */
-@Deprecated
-public class QueryException extends Exception {
-
- // This class is a copy of :
- // org.eclipse.papyrus.emf.facet.infra.query.core.exception.ModelQueryException
-
- private static final long serialVersionUID = -3203874059325745157L;
-
- public QueryException(final String message) {
- super(message);
- }
-
- public QueryException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- public QueryException(final Throwable cause) {
- super(cause);
- }
-
-}
+/** + * Copyright (c) 2009 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - initial API and implementation + */ +package org.eclipse.papyrus.emf.facet.efacet.core.exception; + +/** + * This exception is raised when something is wrong with a query, and there is not a more specific + * sub-class to describe the error (e.g. {@link QueryExecutionException} ) + * + * @deprecated replaced by {@link DerivedTypedElementException} + */ +@Deprecated +public class QueryException extends Exception { + + // This class is a copy of : + // org.eclipse.papyrus.emf.facet.infra.query.core.exception.ModelQueryException + + private static final long serialVersionUID = -3203874059325745157L; + + public QueryException(final String message) { + super(message); + } + + public QueryException(final String message, final Throwable cause) { + super(message, cause); + } + + public QueryException(final Throwable cause) { + super(cause); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/exception/QueryExecutionException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/exception/QueryExecutionException.java index 7c18d819d63..4ee547d31b3 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/exception/QueryExecutionException.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/exception/QueryExecutionException.java @@ -1,41 +1,41 @@ -/**
- * Copyright (c) 2009 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - initial API and implementation
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.exception;
-
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
-
-/**
- * This exception occurs when something goes wrong during the execution of a
- * query.
- *
- * @deprecated replaced by {@link DerivedTypedElementEvaluationException} cf.
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=374678
- */
-@Deprecated
-public class QueryExecutionException extends QueryException {
- // This class is a copy of
- // org.eclipse.papyrus.emf.facet.infra.query.core.ModelQueryExecutionException
-
- private static final long serialVersionUID = -8464252257666617685L;
-
- public QueryExecutionException(final String message) {
- super(message);
- }
-
- public QueryExecutionException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- public QueryExecutionException(final Throwable cause) {
- super(cause);
- }
-
-}
+/** + * Copyright (c) 2009 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - initial API and implementation + */ +package org.eclipse.papyrus.emf.facet.efacet.core.exception; + +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException; + +/** + * This exception occurs when something goes wrong during the execution of a + * query. + * + * @deprecated replaced by {@link DerivedTypedElementEvaluationException} cf. + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=374678 + */ +@Deprecated +public class QueryExecutionException extends QueryException { + // This class is a copy of + // org.eclipse.papyrus.emf.facet.infra.query.core.ModelQueryExecutionException + + private static final long serialVersionUID = -8464252257666617685L; + + public QueryExecutionException(final String message) { + super(message); + } + + public QueryExecutionException(final String message, final Throwable cause) { + super(message, cause); + } + + public QueryExecutionException(final Throwable cause) { + super(cause); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/exception/QueryTypeCheckingException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/exception/QueryTypeCheckingException.java index 133ff6cfefc..fd939c41dc0 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/exception/QueryTypeCheckingException.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/exception/QueryTypeCheckingException.java @@ -1,36 +1,36 @@ -/**
- * Copyright (c) 2009 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - initial API and implementation
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.exception;
-
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementTypeCheckingException;
-
-/**
- * This exception occurs when the type of a query result is not the one expected
- *
- * @deprecated replaced by {@link DerivedTypedElementTypeCheckingException}
- */
-@Deprecated
-public class QueryTypeCheckingException extends QueryException {
-
- private static final long serialVersionUID = -9064274334817642819L;
-
- public QueryTypeCheckingException(final String message) {
- super(message);
- }
-
- public QueryTypeCheckingException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- public QueryTypeCheckingException(final Throwable cause) {
- super(cause);
- }
-}
+/** + * Copyright (c) 2009 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - initial API and implementation + */ +package org.eclipse.papyrus.emf.facet.efacet.core.exception; + +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementTypeCheckingException; + +/** + * This exception occurs when the type of a query result is not the one expected + * + * @deprecated replaced by {@link DerivedTypedElementTypeCheckingException} + */ +@Deprecated +public class QueryTypeCheckingException extends QueryException { + + private static final long serialVersionUID = -9064274334817642819L; + + public QueryTypeCheckingException(final String message) { + super(message); + } + + public QueryTypeCheckingException(final String message, final Throwable cause) { + super(message, cause); + } + + public QueryTypeCheckingException(final Throwable cause) { + super(cause); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/Activator.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/Activator.java index 86f703da092..8055e4d406e 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/Activator.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/Activator.java @@ -1,46 +1,46 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal;
-
-import org.eclipse.core.runtime.Plugin;
-import org.osgi.framework.BundleContext;
-
-public class Activator extends Plugin {
-
- private static BundleContext context;
-
- static BundleContext getContext() {
- return Activator.context;
- }
-
- @Override
- public void start(final BundleContext bundleContext) throws Exception {
- super.start(bundleContext);
- Activator.context = bundleContext;
- Activator.plugin = this;
- }
-
- @Override
- public void stop(final BundleContext bundleContext) throws Exception {
- Activator.context = null;
- Activator.plugin = null;
- super.stop(bundleContext);
- }
-
- // The shared instance
- private static Activator plugin;
-
- public static Plugin getDefault() {
- return Activator.plugin;
- }
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal; + +import org.eclipse.core.runtime.Plugin; +import org.osgi.framework.BundleContext; + +public class Activator extends Plugin { + + private static BundleContext context; + + static BundleContext getContext() { + return Activator.context; + } + + @Override + public void start(final BundleContext bundleContext) throws Exception { + super.start(bundleContext); + Activator.context = bundleContext; + Activator.plugin = this; + } + + @Override + public void stop(final BundleContext bundleContext) throws Exception { + Activator.context = null; + Activator.plugin = null; + super.stop(bundleContext); + } + + // The shared instance + private static Activator plugin; + + public static Plugin getDefault() { + return Activator.plugin; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/CastUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/CastUtils.java index 8fe0abd16fd..ac00439c123 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/CastUtils.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/CastUtils.java @@ -1,86 +1,86 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Mia-Software
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
- * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
- * Grégoire Dupé (Mia-Software) - Bug 361612 - [Restructuring] New core for new version of the Facet metamodel
- * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal;
-
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.UnmatchingExpectedTypeException;
-
-public final class CastUtils {
-
- private CastUtils() {
- // Must no be used.
- }
-
- /**
- * Cast the given value to a List of the given type
- *
- * @param value
- * the list
- * @param expectedType
- * the expected type of the list elements
- * @param checkType
- * whether to check the type of each element in the given list; should be <code>true</code> if the list comes from outside the framework, and <code>false</code> if the list is managed by the framework (and so already
- * checked)
- * @return the cast list
- * @throws UnmatchingExpectedTypeException
- */
- @SuppressWarnings("unchecked")
- // @SuppressWarnings("unchecked") The cast is checked by the both if statement.
- public static <T> List<T> castToExpectedListType(final Object value, final Class<T> expectedType, final boolean checkType)
- throws UnmatchingExpectedTypeException {
- List<T> newList = new LinkedList<T>();
- if (value instanceof List) {
- newList = (List<T>) value;
- } else {
- newList.add((T) value);
- }
- final List<T> list = newList;
- if (checkType) {
- checkTypeOfAllListElements(list, expectedType);
- }
- return list;
- }
-
- @SuppressWarnings("unchecked")
- // @SuppressWarnings("unchecked") This method is used to isolate unsafe cast.
- public static <T> T castToExpectedType(final Object value, final Class<T> expectedType)
- throws UnmatchingExpectedTypeException {
- try {
- return (T) value;
- } catch (ClassCastException e) {
- throw new UnmatchingExpectedTypeException("Type mismatch. Expected: " + //$NON-NLS-1$
- expectedType.getClass().getName() + ", got " + value.getClass().getName(), e); //$NON-NLS-1$);
- }
- }
-
- public static void checkTypeOfAllListElements(final List<?> list, final Class<?> expectedType) throws UnmatchingExpectedTypeException {
- if (expectedType == null) {
- // null means match everything
- return;
- }
- final Iterator<?> iterator = list.iterator();
- int index = -1;
- while (iterator.hasNext()) {
- final Object object = iterator.next();
- index++;
- if (object != null && !expectedType.isInstance(object)) {
- throw new UnmatchingExpectedTypeException("Type mismatch at index " + index, expectedType, object); //$NON-NLS-1$
- }
- }
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2011, 2012 Mia-Software + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values. + * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel + * Grégoire Dupé (Mia-Software) - Bug 361612 - [Restructuring] New core for new version of the Facet metamodel + * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.UnmatchingExpectedTypeException; + +public final class CastUtils { + + private CastUtils() { + // Must no be used. + } + + /** + * Cast the given value to a List of the given type + * + * @param value + * the list + * @param expectedType + * the expected type of the list elements + * @param checkType + * whether to check the type of each element in the given list; should be <code>true</code> if the list comes from outside the framework, and <code>false</code> if the list is managed by the framework (and so already + * checked) + * @return the cast list + * @throws UnmatchingExpectedTypeException + */ + @SuppressWarnings("unchecked") + // @SuppressWarnings("unchecked") The cast is checked by the both if statement. + public static <T> List<T> castToExpectedListType(final Object value, final Class<T> expectedType, final boolean checkType) + throws UnmatchingExpectedTypeException { + List<T> newList = new LinkedList<T>(); + if (value instanceof List) { + newList = (List<T>) value; + } else { + newList.add((T) value); + } + final List<T> list = newList; + if (checkType) { + checkTypeOfAllListElements(list, expectedType); + } + return list; + } + + @SuppressWarnings("unchecked") + // @SuppressWarnings("unchecked") This method is used to isolate unsafe cast. + public static <T> T castToExpectedType(final Object value, final Class<T> expectedType) + throws UnmatchingExpectedTypeException { + try { + return (T) value; + } catch (ClassCastException e) { + throw new UnmatchingExpectedTypeException("Type mismatch. Expected: " + //$NON-NLS-1$ + expectedType.getClass().getName() + ", got " + value.getClass().getName(), e); //$NON-NLS-1$); + } + } + + public static void checkTypeOfAllListElements(final List<?> list, final Class<?> expectedType) throws UnmatchingExpectedTypeException { + if (expectedType == null) { + // null means match everything + return; + } + final Iterator<?> iterator = list.iterator(); + int index = -1; + while (iterator.hasNext()) { + final Object object = iterator.next(); + index++; + if (object != null && !expectedType.isInstance(object)) { + throw new UnmatchingExpectedTypeException("Type mismatch at index " + index, expectedType, object); //$NON-NLS-1$ + } + } + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/DerivedTypedElementManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/DerivedTypedElementManager.java index 2e2fce862a7..d2f4cb5bb10 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/DerivedTypedElementManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/DerivedTypedElementManager.java @@ -1,878 +1,878 @@ -/**
- * Copyright (c) 2011, 2012, 2013 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
- * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
- * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
- * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
- * Gregoire Dupe (Mia-Software) - Bug 418885 - ETypedElementSwitchQuery implemented using a deprecated query evaluator extension point
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal;
-
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementTypeCheckingException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.UnmatchingExpectedTypeException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.query.DerivedTypedElementImplementationFactoryRegistry;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.query.QueryImplementationFactoryRegistry;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.query.QueryUtils;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IDerivedTypedElementImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-
-public class DerivedTypedElementManager implements IDerivedTypedElementManager {
-
- public Object evaluate(final DerivedTypedElement derivedTypedElement,
- final EObject source, final List<ParameterValue> parameterValues,
- final IFacetManager facetManager)
- throws DerivedTypedElementException {
- Object result;
- if (derivedTypedElement.isMany()) {
- result = evaluateMultiValued(derivedTypedElement, source, parameterValues, null, facetManager);
- } else {
- result = evaluateSingleValued(derivedTypedElement, source, parameterValues, null, facetManager);
- }
- return result;
- }
-
- public Object evaluate(final Query query, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager)
- throws DerivedTypedElementException {
- final IQueryImplementation evaluator = QueryImplementationFactoryRegistry.INSTANCE.getEvaluatorFor(query, this);
- final DerivedTypedElement derivedTE = QueryUtils.getOwningDerivedTypedElement(query);
- Object result;
- try {
- result = evaluator.getValue(query, derivedTE, source, parameterValues, facetManager);
- } catch (Exception e) {
- throw new DerivedTypedElementEvaluationException(e);
- }
- return result;
- }
-
- public <T> T evaluateSingleValued(final DerivedTypedElement derivedTypedElement,
- final EObject source, final List<ParameterValue> parameterValues, final Class<T> expectedType, final IFacetManager facetManager)
- throws DerivedTypedElementException {
- if (derivedTypedElement.isMany()) {
- throw new IllegalArgumentException("This method doesn't accept a multi-valued derived typed element."); //$NON-NLS-1$
- }
-
- Query query = derivedTypedElement.getQuery();
- if (query == null) {
- throw new DerivedTypedElementException("The given derived typed element doesn't contain a query"); //$NON-NLS-1$
- }
- Object queryResult = evaluate(derivedTypedElement, source, parameterValues, facetManager, query);
-
- // expectedResultType == null means match everything
- // And a null value for queryResult matches any type
- if (expectedType != null && queryResult != null && !expectedType.isInstance(queryResult)) {
- Exception e1 = new UnmatchingExpectedTypeException("The derived typed element did not evaluate to the expected type", expectedType, queryResult); //$NON-NLS-1$
- throw new DerivedTypedElementException(e1);
- }
- // just checked
- @SuppressWarnings("unchecked")
- T typedQueryResult = (T) queryResult;
- return typedQueryResult;
- }
-
- public <T> List<T> evaluateMultiValued(final DerivedTypedElement derivedTypedElement,
- final EObject source, final List<ParameterValue> parameterValues, final Class<T> expectedType, final IFacetManager facetManager)
- throws DerivedTypedElementException {
- if (!derivedTypedElement.isMany()) {
- throw new IllegalArgumentException("This method doesn't accept a single-valued derived typed element."); //$NON-NLS-1$
- }
-
- Query query = derivedTypedElement.getQuery();
- if (query == null) {
- throw new DerivedTypedElementException("The given derived typed element doesn't contain a query"); //$NON-NLS-1$
- }
- Object queryResult = evaluate(derivedTypedElement, source, parameterValues, facetManager, query);
- queryResult = setAsList(queryResult);
- List<T> result;
- if (queryResult instanceof List<?>) {
- List<?> queryListResult = (List<?>) queryResult;
- for (Object queryResultElement : queryListResult) {
- // expectedType == null means match everything
- // And a null queryResultElement for queryResult matches any type
- if (expectedType != null && queryResultElement != null && !expectedType.isInstance(queryResultElement)) {
- Exception e1 = new UnmatchingExpectedTypeException("The derived typed element did not evaluate to the expected type"); //$NON-NLS-1$
- throw new DerivedTypedElementException(e1);
- }
- }
- // just checked
- @SuppressWarnings("unchecked")
- List<T> typedQueryListResult = (List<T>) queryListResult;
- result = typedQueryListResult;
- } else {
- throw new DerivedTypedElementException("The given multi-valued derived typed element did not evaluate to a List."); //$NON-NLS-1$
- }
- return result;
- }
-
- protected Object evaluate(final DerivedTypedElement derivedTE, final EObject source, final List<ParameterValue> parameterValues,
- final IFacetManager facetManager, final Query query) throws DerivedTypedElementException {
- Object queryResult;
- IQueryImplementation evaluator = null;
- IDerivedTypedElementImplementation evaluator2 = null;
- try {
- evaluator = QueryImplementationFactoryRegistry.INSTANCE.getEvaluatorFor(query, this);
- } catch (DerivedTypedElementException exc) {
- final String message = String.format("%s will try to use a deprected implementation", //$NON-NLS-1$
- this.getClass().getName());
- Logger.logError(exc, message, Activator.getDefault());
- evaluator2 = DerivedTypedElementImplementationFactoryRegistry.INSTANCE.getEvaluatorFor(query, this);
- }
- if (evaluator == null) {
- queryResult = evaluateAndCheck(derivedTE, source, parameterValues, evaluator2, facetManager);
- } else {
- queryResult = evaluateAndCheck(derivedTE.getQuery(), source, parameterValues, evaluator, facetManager);
- }
- return queryResult;
- }
-
- /** @deprecated support for the deprecated {@link IDerivedTypedElementImplementation} */
- @Deprecated
- private static Object evaluateAndCheck(final DerivedTypedElement derivedTE, final EObject source,
- final List<ParameterValue> parameterValues, final IDerivedTypedElementImplementation evaluator, final IFacetManager facetManager)
- throws DerivedTypedElementException {
- Query query = derivedTE.getQuery();
- checkQuery(query, source);
- Object result;
- try {
- result = evaluator.getValue(derivedTE, source, parameterValues, facetManager);
- } catch (Throwable e) {
- if (e instanceof DerivedTypedElementEvaluationException) {
- throw (DerivedTypedElementEvaluationException) e;
- }
- throw new DerivedTypedElementEvaluationException(e);
- }
- // result = setAsList(result);
- // gdupe: I don't understand why the result is wrapped in a list
- checkResult(query, result, evaluator.getCheckResultType(),
- isPrimitive(QueryUtils.getReturnType(query)));
- return result;
- }
-
- private static Object evaluateAndCheck(final Query query, final EObject source, final List<ParameterValue> parameterValues,
- final IQueryImplementation evaluator, final IFacetManager facetManager)
- throws DerivedTypedElementException {
- checkQuery(query, source);
- Object result;
- try {
- result = evaluator.getValue(query, QueryUtils.getOwningDerivedTypedElement(query), source, parameterValues, facetManager);
- } catch (Throwable e) {
- if (e instanceof DerivedTypedElementEvaluationException) {
- throw (DerivedTypedElementEvaluationException) e;
- }
- throw new DerivedTypedElementEvaluationException(e);
- }
- checkResult(query, result, evaluator.isCheckResultType(), isPrimitive(QueryUtils.getReturnType(query)));
- return result;
- }
-
- private static void checkQuery(final Query query, final EObject source) throws DerivedTypedElementException {
- if (query == null) {
- throw new IllegalArgumentException("query cannot be null"); //$NON-NLS-1$
- }
-
- EClassifier sourceType = QueryUtils.getSourceType(query);
- if (sourceType == null && source != null) {
- throw new DerivedTypedElementException("the query's sourceType is null and the source is not null"); //$NON-NLS-1$
- }
-
- // a null value for eObject matches any type
- if (sourceType != null && source != null && !sourceType.isInstance(source)) {
- StringBuffer message = new StringBuffer();
- message.append("Wrong source type (for " + QueryUtils.getQueryDescription(query) + "): '"); //$NON-NLS-1$ //$NON-NLS-2$
- message.append(source.eClass().getName());
- message.append("' found; expected '"); //$NON-NLS-1$
- message.append(sourceType.getName());
- message.append("'."); //$NON-NLS-1$
- throw new DerivedTypedElementTypeCheckingException(message.toString());
- }
- }
-
- // public List<? extends AbstractDerivedTypedElementResult> evaluate(final DerivedTypedElement
- // derivedTypedElement, final Collection<EObject> sources,
- // final List<ParameterValue> parameterValues) throws DerivedTypedElementException {
- // if (derivedTypedElement.isMany()) {
- // try {
- // return evaluateSingleValued(derivedTypedElement, sources, parameterValues, null);
- // } catch (UnmatchingExpectedTypeException e) {
- // // should never happen
- // throw new IllegalStateException("Unexpected error"); //$NON-NLS-1$
- // }
- // } else {
- // try {
- // return evaluateMultiValued(derivedTypedElement, sources, parameterValues, null);
- // } catch (UnmatchingExpectedTypeException e) {
- // // should never happen
- // throw new IllegalStateException("Unexpected error"); //$NON-NLS-1$
- // }
- // }
- // }
-
-
- // batch evaluation disabled : Bug 365429 - DerivedTypedElementManager : re-implement batch evaluation
-
- public <T extends ETypedElementResult> List<T> batchEvaluate(final DerivedTypedElement derivedTypedElement,
- final Collection<? extends EObject> sources, final List<ParameterValue> parameterValues, final Class<T> expectedType, final IFacetManager facetManager)
- throws DerivedTypedElementException {
-
- throw new UnsupportedOperationException("not implemented yet"); //$NON-NLS-1$
-
- // if (derivedTypedElement == null) {
- // throw new IllegalArgumentException("The given derived typed element must not be null"); //$NON-NLS-1$
- // }
- //
- // List<T> abstractResultList;
- //
- // Query query = derivedTypedElement.getQuery();
- // if (query == null) {
- // throw new DerivedTypedElementException("The given derived typed element doesn't contain a query"); //$NON-NLS-1$
- // }
- // EClassifier eType = derivedTypedElement.getEType();
- // if (eType == null) {
- // throw new DerivedTypedElementException("The given derived typed element has a null type"); //$NON-NLS-1$
- // }
- // IDerivedTypedElementImplementation evaluator = DerivedTypedElementImplementationFactoryRegistry.INSTANCE.getEvaluatorFor(query);
- // if (evaluator == null) {
- // throw new DerivedTypedElementEvaluationException("No evaluator was found for a query of type " + query.getClass().getName()); //$NON-NLS-1$
- // }
- //
- // final boolean primitiveType = isPrimitive(eType);
- //
- // // if the evaluator implements multiple evaluation itself, then use it
- // if (evaluator instanceof IDerivedTypedElementCollectionImplementation) {
- // IDerivedTypedElementCollectionImplementation collectionEvaluator = (IDerivedTypedElementCollectionImplementation) evaluator;
- // if (derivedTypedElement.isMany()) {
- // if (primitiveType) {
- // if (expectedType != DerivedTypedElementPrimitiveTypeListResult.class) {
- // throw new UnmatchingExpectedTypeException("The derivedTypedElement is multi-valued, and its type is primitive, " + //$NON-NLS-1$
- // "so expectedType must be " + DerivedTypedElementPrimitiveTypeListResult.class.getSimpleName()); //$NON-NLS-1$
- // }
- // List<DerivedTypedElementPrimitiveTypeListResult<?>> listResultList = batchEvaluateMultiValuedPrimitiveDerivedTypedElementWithCollectionEvaluator(
- // derivedTypedElement, sources, parameterValues, collectionEvaluator);
- // // we just checked the type parameter T through expectedType
- // @SuppressWarnings("unchecked")
- // List<T> castList = (List<T>) listResultList;
- // abstractResultList = castList;
- // } else {
- // if (expectedType != DerivedTypedElementEObjectListResult.class) {
- // throw new UnmatchingExpectedTypeException("The derivedTypedElement is multi-valued, and it returns model elements, " + //$NON-NLS-1$
- // "so expectedType must be " + DerivedTypedElementEObjectListResult.class.getSimpleName()); //$NON-NLS-1$
- // }
- // List<DerivedTypedElementEObjectListResult<?>> listResultList = batchEvaluateMultiValuedEObjectDerivedTypedElementWithCollectionEvaluator(
- // derivedTypedElement, sources, parameterValues, collectionEvaluator);
- // // we just checked the type parameter T through expectedType
- // @SuppressWarnings("unchecked")
- // List<T> castList = (List<T>) listResultList;
- // abstractResultList = castList;
- // }
- // } else {
- // if (primitiveType) {
- // if (expectedType != DerivedTypedElementPrimitiveTypeResult.class) {
- // throw new UnmatchingExpectedTypeException("The derivedTypedElement is single-valued, and its type is primitive, " + //$NON-NLS-1$
- // "so expectedType must be " + DerivedTypedElementPrimitiveTypeResult.class.getSimpleName()); //$NON-NLS-1$
- // }
- // List<DerivedTypedElementPrimitiveTypeResult<?>> resultList = batchEvaluateSingleValuedPrimitiveDerivedTypedElementWithCollectionEvaluator(
- // derivedTypedElement, sources, parameterValues, collectionEvaluator);
- // // we just checked the type parameter T through expectedType
- // @SuppressWarnings("unchecked")
- // List<T> castList = (List<T>) resultList;
- // abstractResultList = castList;
- // } else {
- // if (expectedType != DerivedTypedElementEObjectResult.class) {
- // throw new UnmatchingExpectedTypeException("The derivedTypedElement is single-valued, and it returns a model element, " + //$NON-NLS-1$
- // "so expectedType must be " + DerivedTypedElementEObjectResult.class.getSimpleName()); //$NON-NLS-1$
- // }
- // List<DerivedTypedElementEObjectResult<?>> resultList = batchEvaluateSingleValuedEObjectDerivedTypedElementWithCollectionEvaluator(
- // derivedTypedElement, sources, parameterValues, collectionEvaluator);
- // // we just checked the type parameter T through expectedType
- // @SuppressWarnings("unchecked")
- // List<T> castList = (List<T>) resultList;
- // abstractResultList = castList;
- // }
- // }
- //
- // } else {
- // // otherwise, do multiple evaluation by calling the evaluator's
- // // single evaluation multiple times
- //
- // if (derivedTypedElement.isMany()) {
- // if (primitiveType) {
- // if (expectedType != DerivedTypedElementPrimitiveTypeListResult.class) {
- // throw new UnmatchingExpectedTypeException("The derivedTypedElement is multi-valued, and its type is primitive, " + //$NON-NLS-1$
- // "so expectedType must be " + DerivedTypedElementPrimitiveTypeListResult.class.getSimpleName()); //$NON-NLS-1$
- // }
- // List<DerivedTypedElementPrimitiveTypeListResult<?>> listResultList = batchEvaluateMultiValuedPrimitiveDerivedTypedElementWithSimpleEvaluator(
- // derivedTypedElement, sources, parameterValues, evaluator);
- // @SuppressWarnings("unchecked")
- // List<T> castList = (List<T>) listResultList;
- // abstractResultList = castList;
- // } else {
- // if (expectedType != DerivedTypedElementEObjectListResult.class) {
- // throw new UnmatchingExpectedTypeException("The derivedTypedElement is multi-valued, and it returns model elements, " + //$NON-NLS-1$
- // "so expectedType must be " + DerivedTypedElementEObjectListResult.class.getSimpleName()); //$NON-NLS-1$
- // }
- // List<DerivedTypedElementEObjectListResult<?>> listResultList = batchEvaluateMultiValuedEObjectDerivedTypedElementWithSimpleEvaluator(
- // derivedTypedElement, sources, parameterValues, evaluator);
- // @SuppressWarnings("unchecked")
- // List<T> castList = (List<T>) listResultList;
- // abstractResultList = castList;
- // }
- // } else {
- // if (primitiveType) {
- // if (expectedType != DerivedTypedElementPrimitiveTypeResult.class) {
- // throw new UnmatchingExpectedTypeException("The derivedTypedElement is single-valued, and its type is primitive, " + //$NON-NLS-1$
- // "so expectedType must be " + DerivedTypedElementPrimitiveTypeResult.class.getSimpleName()); //$NON-NLS-1$
- // }
- // List<DerivedTypedElementPrimitiveTypeResult<?>> resultList = batchEvaluateSingleValuedPrimitiveDerivedTypedElementWithSimpleCollectionEvaluator(
- // derivedTypedElement, sources, parameterValues, evaluator);
- // @SuppressWarnings("unchecked")
- // List<T> castList = (List<T>) resultList;
- // abstractResultList = castList;
- // } else {
- // if (expectedType != DerivedTypedElementEObjectResult.class) {
- // throw new UnmatchingExpectedTypeException("The derivedTypedElement is single-valued, and it returns a model element, " + //$NON-NLS-1$
- // "so expectedType must be " + DerivedTypedElementEObjectResult.class.getSimpleName()); //$NON-NLS-1$
- // }
- // List<DerivedTypedElementEObjectResult<?>> resultList = batchEvaluateSingleValuedEObjectDerivedTypedElementWithSimpleCollectionEvaluator(
- // derivedTypedElement, sources, parameterValues, null);
- // @SuppressWarnings("unchecked")
- // List<T> castList = (List<T>) resultList;
- // abstractResultList = castList;
- // }
- // }
- // }
- // return abstractResultList;
- }
-
- // private static List<DerivedTypedElementPrimitiveTypeListResult<?>> batchEvaluateMultiValuedPrimitiveDerivedTypedElementWithCollectionEvaluator(
- // final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues,
- // final IDerivedTypedElementCollectionImplementation collectionEvaluator)
- // throws DerivedTypedElementException {
- //
- // List<? extends AbstractDerivedTypedElementResult> listResultList = collectionEvaluator
- // .getValues(derivedTypedElement, sources, parameterValues);
- //
- // // check the return type from the evaluator in order to be able to cast safely
- // for (int index = 0; index < listResultList.size(); index++) {
- // AbstractDerivedTypedElementResult elementResult = listResultList.get(index);
- // if (elementResult instanceof DerivedTypedElementPrimitiveTypeListResult<?>) {
- // DerivedTypedElementPrimitiveTypeListResult<?> derivedTypedElementPrimitiveTypeListResult = (DerivedTypedElementPrimitiveTypeListResult<?>) elementResult;
- // checkResult(derivedTypedElement.getQuery(), derivedTypedElementPrimitiveTypeListResult.getResultList(),
- // collectionEvaluator.getCheckResultType());
- // } else {
- // throw new DerivedTypedElementEvaluationException(ErrorHandlingUtils.buildWrongTypeMessage(
- // "Wrong element type at index " + index + " in the result from the evaluator: " + collectionEvaluator.getClass().getName(), //$NON-NLS-1$//$NON-NLS-2$
- // DerivedTypedElementPrimitiveTypeListResult.class, elementResult));
- // }
- // }
- //
- // // just checked
- // @SuppressWarnings("unchecked")
- // List<DerivedTypedElementPrimitiveTypeListResult<?>> result = (List<DerivedTypedElementPrimitiveTypeListResult<?>>) listResultList;
- // return result;
- // }
- //
- // private static List<DerivedTypedElementEObjectListResult<?>> batchEvaluateMultiValuedEObjectDerivedTypedElementWithCollectionEvaluator(
- // final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues,
- // final IDerivedTypedElementCollectionImplementation collectionEvaluator)
- // throws DerivedTypedElementException {
- // List<? extends AbstractDerivedTypedElementResult> listResultList = collectionEvaluator
- // .getValues(derivedTypedElement, sources, parameterValues);
- //
- // // check the return type from the evaluator in order to be able to cast safely
- // for (int index = 0; index < listResultList.size(); index++) {
- // AbstractDerivedTypedElementResult elementResult = listResultList.get(index);
- // if (elementResult instanceof DerivedTypedElementEObjectListResult<?>) {
- // DerivedTypedElementEObjectListResult<?> derivedTypedElementEObjectListResult = (DerivedTypedElementEObjectListResult<?>) elementResult;
- // checkResult(derivedTypedElement.getQuery(), derivedTypedElementEObjectListResult.getResultList(),
- // collectionEvaluator.getCheckResultType());
- // } else {
- // throw new DerivedTypedElementEvaluationException(ErrorHandlingUtils.buildWrongTypeMessage(
- // "Wrong element type at index " + index + " in the result from the evaluator: " + collectionEvaluator.getClass().getName(), //$NON-NLS-1$//$NON-NLS-2$
- // DerivedTypedElementEObjectListResult.class, elementResult));
- // }
- // }
- //
- // // just checked
- // @SuppressWarnings("unchecked")
- // List<DerivedTypedElementEObjectListResult<?>> result = (List<DerivedTypedElementEObjectListResult<?>>) listResultList;
- // return result;
- // }
- //
- // private static List<DerivedTypedElementPrimitiveTypeResult<?>> batchEvaluateSingleValuedPrimitiveDerivedTypedElementWithCollectionEvaluator(
- // final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues,
- // final IDerivedTypedElementCollectionImplementation collectionEvaluator)
- // throws DerivedTypedElementException {
- //
- // return null;
- // }
- //
- // private static List<DerivedTypedElementEObjectResult<?>> batchEvaluateSingleValuedEObjectDerivedTypedElementWithCollectionEvaluator(
- // final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues,
- // final IDerivedTypedElementCollectionImplementation collectionEvaluator) throws DerivedTypedElementException {
- //
- // return null;
- // }
- //
- // private static List<DerivedTypedElementPrimitiveTypeListResult<?>> batchEvaluateMultiValuedPrimitiveDerivedTypedElementWithSimpleEvaluator(
- // final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues,
- // final IDerivedTypedElementImplementation evaluator) {
- //
- // Query query = derivedTypedElement.getQuery();
- //
- // List<DerivedTypedElementPrimitiveTypeListResult<?>> listResultList = new ArrayList<DerivedTypedElementPrimitiveTypeListResult<?>>();
- // for (EObject eObject : sources) {
- // DerivedTypedElementPrimitiveTypeListResult<Object> primitiveTypeListResult = EFacetFactory.eINSTANCE
- // .createDerivedTypedElementPrimitiveTypeListResult();
- //
- // Throwable error = null;
- // try {
- // primitiveTypeListResult.setSource(eObject);
- // primitiveTypeListResult.setDerivedTypedElement(derivedTypedElement);
- // setParameterValues(primitiveTypeListResult.getParameterValues(), parameterValues);
- // checkSourceType(query.getSourceType(), query, eObject);
- // } catch (Throwable e) {
- // error = e;
- // }
- // if (error != null) {
- // primitiveTypeListResult.setException(error);
- // } else {
- // try {
- // Object evaluationResult = evaluator.getValue(derivedTypedElement, eObject, parameterValues);
- // checkResult(query, evaluationResult, evaluator.getCheckResultType());
- // // checked by checkResult
- // Collection<?> evaluationResultCollection = (Collection<?>) evaluationResult;
- // for (Object object : evaluationResultCollection) {
- // primitiveTypeListResult.getResultList().add(object);
- // }
- // } catch (Throwable e) {
- // primitiveTypeListResult.setException(e);
- // }
- // }
- // listResultList.add(primitiveTypeListResult);
- //
- // }
- // return listResultList;
- // }
- //
- // private static List<DerivedTypedElementEObjectListResult<?>> batchEvaluateMultiValuedEObjectDerivedTypedElementWithSimpleEvaluator(
- // final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues,
- // final IDerivedTypedElementImplementation evaluator) {
- // Query query = derivedTypedElement.getQuery();
- //
- // List<DerivedTypedElementEObjectListResult<?>> listResultList = new ArrayList<DerivedTypedElementEObjectListResult<?>>();
- // for (EObject eObject : sources) {
- // DerivedTypedElementEObjectListResult<EObject> eObjectListResult = EFacetFactory.eINSTANCE
- // .createDerivedTypedElementEObjectListResult();
- //
- // Throwable error = null;
- // try {
- // eObjectListResult.setSource(eObject);
- // eObjectListResult.setDerivedTypedElement(derivedTypedElement);
- // setParameterValues(eObjectListResult.getParameterValues(), parameterValues);
- // checkSourceType(query.getSourceType(), query, eObject);
- // } catch (Throwable e) {
- // error = e;
- // }
- // if (error != null) {
- // eObjectListResult.setException(error);
- // } else {
- // try {
- // Object evaluationResult = evaluator.getValue(derivedTypedElement, eObject, parameterValues);
- // checkResult(query, evaluationResult, evaluator.getCheckResultType(), false);
- // // checked by checkResult
- // @SuppressWarnings("unchecked")
- // Collection<? extends EObject> evaluationResultCollection = (Collection<? extends EObject>) evaluationResult;
- // for (EObject e : evaluationResultCollection) {
- // eObjectListResult.getResultList().add(e);
- // }
- // } catch (Throwable e) {
- // eObjectListResult.setException(e);
- // }
- // }
- // listResultList.add(eObjectListResult);
- //
- // }
- // return listResultList;
- // }
- //
- // private static List<DerivedTypedElementPrimitiveTypeResult<?>> batchEvaluateSingleValuedPrimitiveDerivedTypedElementWithSimpleCollectionEvaluator(
- // final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues,
- // final IDerivedTypedElementImplementation evaluator)
- // throws DerivedTypedElementException {
- //
- // return null;
- // }
- //
- // private static List<DerivedTypedElementEObjectResult<?>> batchEvaluateSingleValuedEObjectDerivedTypedElementWithSimpleCollectionEvaluator(
- // final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues,
- // final IDerivedTypedElementImplementation evaluator)
- // throws DerivedTypedElementException {
- //
- // return null;
- // }
-
- // public <T> List<DerivedTypedElementListResult<T>> evaluateMultiValued(final DerivedTypedElement derivedTypedElement,
- // final Collection<? extends EObject> sources, final List<ParameterValue> parameterValues,
- // final Class<T> expectedType)
- // throws DerivedTypedElementException, UnmatchingExpectedTypeException {
- // if (!derivedTypedElement.isMany()) {
- // throw new IllegalArgumentException("This method doesn't accept a single-valued derived typed element."); //$NON-NLS-1$
- // }
- //
- // Query query = derivedTypedElement.getQuery();
- // if (query == null) {
- // throw new DerivedTypedElementException("The given derived typed element doesn't contain a query"); //$NON-NLS-1$
- // }
- // IDerivedTypedElementImplementation evaluator =
- // DerivedTypedElementImplementationFactoryRegistry.INSTANCE.getEvaluatorFor(query);
- //
- // List<?> queryResult = batchEvaluateAndCheck(derivedTypedElement, sources, parameterValues,
- // evaluator);
- // // Java doesn't support co- or contra-variance on generics,
- // // so we can't return the right type
- // @SuppressWarnings("unchecked")
- // List<DerivedTypedElementListResult<T>> multiResultList =
- // (List<DerivedTypedElementListResult<T>>) queryResult;
- //
- // // check each result element in each result list
- // if (expectedType != null) {
- // int sourceIndex = 0;
- // for (DerivedTypedElementListResult<?> derivedTypedElementResult : multiResultList) {
- // EList<?> resultList = derivedTypedElementResult.getResultList();
- // int index = 0;
- // for (Object resultElement : resultList) {
- // // a null value for resultElement matches any type
- // if (resultElement != null && !expectedType.isInstance(resultElement)) {
- // throw new UnmatchingExpectedTypeException(
- // "The element at index " + index + " in the list that resulted from the evaluation of the multi-valued " //$NON-NLS-1$ //$NON-NLS-2$
- // + "derived typed element does not match the expected type " //$NON-NLS-1$
- // + "for the source element at index " + sourceIndex, expectedType, resultElement); //$NON-NLS-1$
- // }
- // index++;
- // }
- // sourceIndex++;
- // }
- // }
- // return multiResultList;
- // }
- //
- // private static List<?> batchEvaluateAndCheck(final DerivedTypedElement derivedTypedElement,
- // final Collection<EObject> eObjects,
- // final List<ParameterValue> parameterValues, final IDerivedTypedElementImplementation
- // evaluator)
- // throws DerivedTypedElementException {
- // List<?> result;
- //
- // Query query = derivedTypedElement.getQuery();
- // if (query == null) {
- // throw new IllegalArgumentException("the query cannot be null"); //$NON-NLS-1$
- // }
- //
- // EClassifier sourceType = query.getSourceType();
- //
- // final boolean primitiveType = derivedTypedElement instanceof EAttribute;
- //
- // if (derivedTypedElement.isMany()) {
- // if (evaluator instanceof IDerivedTypedElementCollectionImplementation) {
- // IDerivedTypedElementCollectionImplementation collectionEvaluator =
- // (IDerivedTypedElementCollectionImplementation) evaluator;
- // // List<? extends AbstractDerivedTypedElementResult> listResultList =
- // // collectionEvaluator
- // // .getValues(derivedTypedElement, eObjects, parameterValues);
- // // int index = 0;
- // // for (AbstractDerivedTypedElementResult listResult : listResultList) {
- // // EList<?> resultList;
- // // if (primitiveType && listResult instanceof
- // // DerivedTypedElementPrimitiveTypeListResult<?>) {
- // // DerivedTypedElementPrimitiveTypeListResult<?> primitiveListResult =
- // // (DerivedTypedElementPrimitiveTypeListResult<?>) listResult;
- // // resultList = primitiveListResult.getResultList();
- // // } else if (!primitiveType && listResult instanceof
- // // DerivedTypedElementEObjectListResult<?>) {
- // // DerivedTypedElementEObjectListResult<?> eObjectListResult =
- // // (DerivedTypedElementEObjectListResult<?>) listResult;
- // // resultList = eObjectListResult.getResultList();
- // // } else {
- // // throw new DerivedTypedElementEvaluationException(
- // // "Wrong element type at index " + index + " in the result from the evaluator " + collectionEvaluator.getClass().getName()); //$NON-NLS-1$//$NON-NLS-2$
- // // }
- // // checkResult(query, resultList, evaluator.getCheckResultType());
- // // index++;
- // // }
- // // result = listResultList;
- // } else {
- //
- // // List<AbstractDerivedTypedElementResult> listResultList = new
- // // ArrayList<AbstractDerivedTypedElementResult>();
- // // for (EObject eObject : eObjects) {
- // // AbstractDerivedTypedElementResult listResult;
- // // List<?> resultList;
- // // if (primitiveType) {
- // // DerivedTypedElementPrimitiveTypeListResult<?> primitiveTypeListResult =
- // // EFacetFactory.eINSTANCE
- // // .createDerivedTypedElementPrimitiveTypeListResult();
- // // listResult = primitiveTypeListResult;
- // // resultList = primitiveTypeListResult.getResultList();
- // // } else {
- // // DerivedTypedElementEObjectListResult<?> eObjectTypeListResult =
- // // EFacetFactory.eINSTANCE
- // // .createDerivedTypedElementEObjectListResult();
- // // listResult = eObjectTypeListResult;
- // // resultList = eObjectTypeListResult.getResultList();
- // // }
- // //
- // // Throwable error = null;
- // // try {
- // // listResult.setSource(eObject);
- // // listResult.setDerivedTypedElement(derivedTypedElement);
- // // setParameterValues(listResult.getParameterValues(), parameterValues);
- // // checkSourceType(sourceType, query, eObject);
- // // } catch (Throwable e) {
- // // error = e;
- // // }
- // // if (error != null) {
- // // listResult.setException(error);
- // // } else {
- // // try {
- // // Object evaluationResult = evaluator.getValue(derivedTypedElement, eObject,
- // // parameterValues);
- // // checkResult(query, evaluationResult, evaluator.getCheckResultType());
- // // // checked by checkResult
- // // Collection<?> evaluationResultCollection = (Collection<?>) evaluationResult;
- // // for (Object object : evaluationResultCollection) {
- // // resultList.add(object);
- // // }
- // // } catch (Throwable e) {
- // // listResult.setException(e);
- // // }
- // // }
- // // listResultList.add(listResult);
- // //
- // // }
- // // result = listResultList;
- //
- // }
- // } else {
- // // if the evaluator implements multiple evaluation itself, then use it
- // if (evaluator instanceof IDerivedTypedElementCollectionImplementation) {
- // IDerivedTypedElementCollectionImplementation collectionEvaluator =
- // (IDerivedTypedElementCollectionImplementation) evaluator;
- // List<? extends AbstractDerivedTypedElementResult> singleResultList = collectionEvaluator
- // .getValues(derivedTypedElement, eObjects, parameterValues);
- // int index = 0;
- // for (AbstractDerivedTypedElementResult singleResult : singleResultList) {
- // Object resultElement;
- // if (primitiveType && singleResult instanceof DerivedTypedElementPrimitiveTypeResult<?>) {
- // DerivedTypedElementPrimitiveTypeResult<?> primitiveResult =
- // (DerivedTypedElementPrimitiveTypeResult<?>) singleResult;
- // resultElement = primitiveResult.getResult();
- // } else if (!primitiveType && singleResult instanceof DerivedTypedElementEObjectResult<?>) {
- // DerivedTypedElementEObjectResult<?> eObjectResult = (DerivedTypedElementEObjectResult<?>)
- // singleResult;
- // resultElement = eObjectResult.getResult();
- // } else {
- // throw new DerivedTypedElementEvaluationException(
- // "Wrong element type at index " + index + " in the result from the evaluator " + collectionEvaluator.getClass().getName()); //$NON-NLS-1$//$NON-NLS-2$
- // }
- // checkResult(query, result, evaluator.getCheckResultType());
- // index++;
- // }
- // } else {
- // // otherwise, do multiple evaluation by calling the evaluator's
- // // single evaluation multiple times
- // List<DerivedTypedElementResult<?>> resultList = new
- // ArrayList<DerivedTypedElementResult<?>>();
- // for (EObject eObject : eObjects) {
- // DerivedTypedElementResult<Object> singleResult =
- // EFacetFactory.eINSTANCE.createDerivedTypedElementResult();
- // Throwable error = null;
- // try {
- // singleResult.setSource(eObject);
- // singleResult.setDerivedTypedElement(derivedTypedElement);
- // setParameterValues(singleResult.getParameterValues(), parameterValues);
- // checkSourceType(sourceType, query, eObject);
- // } catch (Throwable e) {
- // error = e;
- // }
- // if (error != null) {
- // singleResult.setException(error);
- // } else {
- // try {
- // Object evaluationResult = evaluator.getValue(derivedTypedElement, eObject, parameterValues);
- // checkResult(query, evaluationResult, evaluator.getCheckResultType());
- // singleResult.setResult(evaluationResult);
- // } catch (Throwable e) {
- // singleResult.setException(e);
- // }
- // }
- // resultList.add(singleResult);
- // }
- // result = resultList;
- // }
- // }
- //
- // return result;
- // }
-
- // private static void checkSourceType(final EClassifier sourceType, final Query query, final EObject eObject)
- // throws DerivedTypedElementException {
- // if (sourceType != null) {
- // // a null value for eObject matches any type
- // if (eObject != null && !sourceType.isInstance(eObject)) {
- // StringBuffer message = new StringBuffer();
- // message.append("Wrong source type (for " + QueryUtils.getQueryDescription(query) + "): '"); //$NON-NLS-1$ //$NON-NLS-2$
- // message.append(eObject.eClass().getName());
- // message.append("' found; expected '"); //$NON-NLS-1$
- // message.append(sourceType.getName());
- // message.append("'."); //$NON-NLS-1$
- // throw new DerivedTypedElementTypeCheckingException(message.toString());
- // }
- // } else {
- // if (eObject != null) {
- // throw new DerivedTypedElementException("the query's sourceType is null and the source is not null"); //$NON-NLS-1$
- // }
- // }
- // }
- //
- // private static void setParameterValues(final EList<ParameterValue> target, final List<ParameterValue> parameterValues) {
- // if (parameterValues != null) {
- // for (ParameterValue parameterValue : parameterValues) {
- // if (parameterValue == null) {
- // throw new IllegalArgumentException("null parameter value"); //$NON-NLS-1$
- // }
- // // containment link -> we need to copy since we can have the same
- // // parameter for several results
- // target.add(EcoreUtil.copy(parameterValue));
- // }
- // }
- // }
-
- private static final void checkResult(final Query query, final Object result,
- final boolean checkResultType, final boolean primitive) throws DerivedTypedElementTypeCheckingException {
- if (QueryUtils.isMany(query)) {
- if (!(result instanceof Collection<?>)) {
- String strResult;
- if (result == null) {
- strResult = "null"; //$NON-NLS-1$
- } else {
- strResult = "an instance of " + result.getClass().getName(); //$NON-NLS-1$
- }
- throw new DerivedTypedElementTypeCheckingException(
- "A collection is expected as result. The result is " //$NON-NLS-1$
- + strResult + " (on " + QueryUtils.getQueryDescription(query) + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (checkResultType) {
- for (Object collectionElement : (Collection<?>) result) {
- if (collectionElement != null
- && !(QueryUtils.getReturnType(query)
- .isInstance(collectionElement))) {
- throw new DerivedTypedElementTypeCheckingException(
- "Wrong result collection element type: " + collectionElement.getClass().getName() //$NON-NLS-1$
- + "(" + QueryUtils.getReturnType(query).getName() + " is expected) " //$NON-NLS-1$ //$NON-NLS-2$
- + " on " + QueryUtils.getQueryDescription(query)); //$NON-NLS-1$
- }
- }
- } else if (!primitive) {
- // at least check that EObjects are returned
- for (Object collectionElement : (Collection<?>) result) {
- if (collectionElement != null && !(collectionElement instanceof EObject)) {
- throw new DerivedTypedElementTypeCheckingException(
- "Wrong result collection element type: " + collectionElement.getClass().getName() //$NON-NLS-1$
- + "(an instance of " + EObject.class.getName() + " is expected) " //$NON-NLS-1$ //$NON-NLS-2$
- + " on " + QueryUtils.getQueryDescription(query)); //$NON-NLS-1$
- }
- }
- }
- } else {
- if (result instanceof Collection<?>) {
- throw new DerivedTypedElementTypeCheckingException("A " //$NON-NLS-1$
- + QueryUtils.getSourceType(query).getName()
- + " instance is expected as result. The result is: " //$NON-NLS-1$
- + result + " (on " + QueryUtils.getQueryDescription(query) + ")"); //$NON-NLS-1$//$NON-NLS-2$
- }
- if (checkResultType) {
- if (result != null && !(QueryUtils.getReturnType(query).isInstance(result))) {
- throw new DerivedTypedElementTypeCheckingException("Wrong result type: " //$NON-NLS-1$
- + result.getClass().getName()
- + " is returned while " //$NON-NLS-1$
- + QueryUtils.getReturnType(query).getInstanceClassName()
- + " is expected." + " (on " + QueryUtils.getQueryDescription(query) + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- } else if (!primitive) {
- // at least check that an EObject is returned
- if (result != null && !(result instanceof EObject)) {
- throw new DerivedTypedElementTypeCheckingException(
- "Wrong result collection element type: " + result.getClass().getName() //$NON-NLS-1$
- + "(an instance of " + EObject.class.getName() + " is expected) " //$NON-NLS-1$ //$NON-NLS-2$
- + " on " + QueryUtils.getQueryDescription(query)); //$NON-NLS-1$
- }
- }
- }
- }
-
- private static boolean isPrimitive(final EClassifier eType) {
- final boolean primitiveType;
- if (eType instanceof EDataType) {
- primitiveType = true;
- } else if (eType instanceof EClass) {
- primitiveType = false;
- } else {
- throw new IllegalArgumentException("unhandled derived typed element type: " + eType.getName()); //$NON-NLS-1$
- }
- return primitiveType;
- }
-
- /**
- * Transform the element in parameter in list (if necessary).
- *
- * @param element
- * the element to transform
- * @return a list.
- */
- protected static List<Object> setAsList(final Object element) {
- List<Object> newList = new LinkedList<Object>();
- if (element instanceof List) {
- @SuppressWarnings("unchecked")
- // @SuppressWarnings("unchecked") the cast is safe because were
- // casting a List to a List<Object>
- final List<Object> tmpList = (List<Object>) element;
- newList = tmpList;
- } else if (element instanceof Collection) {
- //Bug 526899
- Collection<?> result = (Collection<?>)element;
- newList.addAll(result);
- } else {
- newList.add(element);
- }
- return newList;
- }
-
-}
+/** + * Copyright (c) 2011, 2012, 2013 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet + * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values. + * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel + * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2 + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet. + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors + * Gregoire Dupe (Mia-Software) - Bug 418885 - ETypedElementSwitchQuery implemented using a deprecated query evaluator extension point + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal; + +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementTypeCheckingException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.UnmatchingExpectedTypeException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.query.DerivedTypedElementImplementationFactoryRegistry; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.query.QueryImplementationFactoryRegistry; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.query.QueryUtils; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IDerivedTypedElementImplementation; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult; +import org.eclipse.papyrus.emf.facet.util.core.Logger; + +public class DerivedTypedElementManager implements IDerivedTypedElementManager { + + public Object evaluate(final DerivedTypedElement derivedTypedElement, + final EObject source, final List<ParameterValue> parameterValues, + final IFacetManager facetManager) + throws DerivedTypedElementException { + Object result; + if (derivedTypedElement.isMany()) { + result = evaluateMultiValued(derivedTypedElement, source, parameterValues, null, facetManager); + } else { + result = evaluateSingleValued(derivedTypedElement, source, parameterValues, null, facetManager); + } + return result; + } + + public Object evaluate(final Query query, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager) + throws DerivedTypedElementException { + final IQueryImplementation evaluator = QueryImplementationFactoryRegistry.INSTANCE.getEvaluatorFor(query, this); + final DerivedTypedElement derivedTE = QueryUtils.getOwningDerivedTypedElement(query); + Object result; + try { + result = evaluator.getValue(query, derivedTE, source, parameterValues, facetManager); + } catch (Exception e) { + throw new DerivedTypedElementEvaluationException(e); + } + return result; + } + + public <T> T evaluateSingleValued(final DerivedTypedElement derivedTypedElement, + final EObject source, final List<ParameterValue> parameterValues, final Class<T> expectedType, final IFacetManager facetManager) + throws DerivedTypedElementException { + if (derivedTypedElement.isMany()) { + throw new IllegalArgumentException("This method doesn't accept a multi-valued derived typed element."); //$NON-NLS-1$ + } + + Query query = derivedTypedElement.getQuery(); + if (query == null) { + throw new DerivedTypedElementException("The given derived typed element doesn't contain a query"); //$NON-NLS-1$ + } + Object queryResult = evaluate(derivedTypedElement, source, parameterValues, facetManager, query); + + // expectedResultType == null means match everything + // And a null value for queryResult matches any type + if (expectedType != null && queryResult != null && !expectedType.isInstance(queryResult)) { + Exception e1 = new UnmatchingExpectedTypeException("The derived typed element did not evaluate to the expected type", expectedType, queryResult); //$NON-NLS-1$ + throw new DerivedTypedElementException(e1); + } + // just checked + @SuppressWarnings("unchecked") + T typedQueryResult = (T) queryResult; + return typedQueryResult; + } + + public <T> List<T> evaluateMultiValued(final DerivedTypedElement derivedTypedElement, + final EObject source, final List<ParameterValue> parameterValues, final Class<T> expectedType, final IFacetManager facetManager) + throws DerivedTypedElementException { + if (!derivedTypedElement.isMany()) { + throw new IllegalArgumentException("This method doesn't accept a single-valued derived typed element."); //$NON-NLS-1$ + } + + Query query = derivedTypedElement.getQuery(); + if (query == null) { + throw new DerivedTypedElementException("The given derived typed element doesn't contain a query"); //$NON-NLS-1$ + } + Object queryResult = evaluate(derivedTypedElement, source, parameterValues, facetManager, query); + queryResult = setAsList(queryResult); + List<T> result; + if (queryResult instanceof List<?>) { + List<?> queryListResult = (List<?>) queryResult; + for (Object queryResultElement : queryListResult) { + // expectedType == null means match everything + // And a null queryResultElement for queryResult matches any type + if (expectedType != null && queryResultElement != null && !expectedType.isInstance(queryResultElement)) { + Exception e1 = new UnmatchingExpectedTypeException("The derived typed element did not evaluate to the expected type"); //$NON-NLS-1$ + throw new DerivedTypedElementException(e1); + } + } + // just checked + @SuppressWarnings("unchecked") + List<T> typedQueryListResult = (List<T>) queryListResult; + result = typedQueryListResult; + } else { + throw new DerivedTypedElementException("The given multi-valued derived typed element did not evaluate to a List."); //$NON-NLS-1$ + } + return result; + } + + protected Object evaluate(final DerivedTypedElement derivedTE, final EObject source, final List<ParameterValue> parameterValues, + final IFacetManager facetManager, final Query query) throws DerivedTypedElementException { + Object queryResult; + IQueryImplementation evaluator = null; + IDerivedTypedElementImplementation evaluator2 = null; + try { + evaluator = QueryImplementationFactoryRegistry.INSTANCE.getEvaluatorFor(query, this); + } catch (DerivedTypedElementException exc) { + final String message = String.format("%s will try to use a deprected implementation", //$NON-NLS-1$ + this.getClass().getName()); + Logger.logError(exc, message, Activator.getDefault()); + evaluator2 = DerivedTypedElementImplementationFactoryRegistry.INSTANCE.getEvaluatorFor(query, this); + } + if (evaluator == null) { + queryResult = evaluateAndCheck(derivedTE, source, parameterValues, evaluator2, facetManager); + } else { + queryResult = evaluateAndCheck(derivedTE.getQuery(), source, parameterValues, evaluator, facetManager); + } + return queryResult; + } + + /** @deprecated support for the deprecated {@link IDerivedTypedElementImplementation} */ + @Deprecated + private static Object evaluateAndCheck(final DerivedTypedElement derivedTE, final EObject source, + final List<ParameterValue> parameterValues, final IDerivedTypedElementImplementation evaluator, final IFacetManager facetManager) + throws DerivedTypedElementException { + Query query = derivedTE.getQuery(); + checkQuery(query, source); + Object result; + try { + result = evaluator.getValue(derivedTE, source, parameterValues, facetManager); + } catch (Throwable e) { + if (e instanceof DerivedTypedElementEvaluationException) { + throw (DerivedTypedElementEvaluationException) e; + } + throw new DerivedTypedElementEvaluationException(e); + } + // result = setAsList(result); + // gdupe: I don't understand why the result is wrapped in a list + checkResult(query, result, evaluator.getCheckResultType(), + isPrimitive(QueryUtils.getReturnType(query))); + return result; + } + + private static Object evaluateAndCheck(final Query query, final EObject source, final List<ParameterValue> parameterValues, + final IQueryImplementation evaluator, final IFacetManager facetManager) + throws DerivedTypedElementException { + checkQuery(query, source); + Object result; + try { + result = evaluator.getValue(query, QueryUtils.getOwningDerivedTypedElement(query), source, parameterValues, facetManager); + } catch (Throwable e) { + if (e instanceof DerivedTypedElementEvaluationException) { + throw (DerivedTypedElementEvaluationException) e; + } + throw new DerivedTypedElementEvaluationException(e); + } + checkResult(query, result, evaluator.isCheckResultType(), isPrimitive(QueryUtils.getReturnType(query))); + return result; + } + + private static void checkQuery(final Query query, final EObject source) throws DerivedTypedElementException { + if (query == null) { + throw new IllegalArgumentException("query cannot be null"); //$NON-NLS-1$ + } + + EClassifier sourceType = QueryUtils.getSourceType(query); + if (sourceType == null && source != null) { + throw new DerivedTypedElementException("the query's sourceType is null and the source is not null"); //$NON-NLS-1$ + } + + // a null value for eObject matches any type + if (sourceType != null && source != null && !sourceType.isInstance(source)) { + StringBuffer message = new StringBuffer(); + message.append("Wrong source type (for " + QueryUtils.getQueryDescription(query) + "): '"); //$NON-NLS-1$ //$NON-NLS-2$ + message.append(source.eClass().getName()); + message.append("' found; expected '"); //$NON-NLS-1$ + message.append(sourceType.getName()); + message.append("'."); //$NON-NLS-1$ + throw new DerivedTypedElementTypeCheckingException(message.toString()); + } + } + + // public List<? extends AbstractDerivedTypedElementResult> evaluate(final DerivedTypedElement + // derivedTypedElement, final Collection<EObject> sources, + // final List<ParameterValue> parameterValues) throws DerivedTypedElementException { + // if (derivedTypedElement.isMany()) { + // try { + // return evaluateSingleValued(derivedTypedElement, sources, parameterValues, null); + // } catch (UnmatchingExpectedTypeException e) { + // // should never happen + // throw new IllegalStateException("Unexpected error"); //$NON-NLS-1$ + // } + // } else { + // try { + // return evaluateMultiValued(derivedTypedElement, sources, parameterValues, null); + // } catch (UnmatchingExpectedTypeException e) { + // // should never happen + // throw new IllegalStateException("Unexpected error"); //$NON-NLS-1$ + // } + // } + // } + + + // batch evaluation disabled : Bug 365429 - DerivedTypedElementManager : re-implement batch evaluation + + public <T extends ETypedElementResult> List<T> batchEvaluate(final DerivedTypedElement derivedTypedElement, + final Collection<? extends EObject> sources, final List<ParameterValue> parameterValues, final Class<T> expectedType, final IFacetManager facetManager) + throws DerivedTypedElementException { + + throw new UnsupportedOperationException("not implemented yet"); //$NON-NLS-1$ + + // if (derivedTypedElement == null) { + // throw new IllegalArgumentException("The given derived typed element must not be null"); //$NON-NLS-1$ + // } + // + // List<T> abstractResultList; + // + // Query query = derivedTypedElement.getQuery(); + // if (query == null) { + // throw new DerivedTypedElementException("The given derived typed element doesn't contain a query"); //$NON-NLS-1$ + // } + // EClassifier eType = derivedTypedElement.getEType(); + // if (eType == null) { + // throw new DerivedTypedElementException("The given derived typed element has a null type"); //$NON-NLS-1$ + // } + // IDerivedTypedElementImplementation evaluator = DerivedTypedElementImplementationFactoryRegistry.INSTANCE.getEvaluatorFor(query); + // if (evaluator == null) { + // throw new DerivedTypedElementEvaluationException("No evaluator was found for a query of type " + query.getClass().getName()); //$NON-NLS-1$ + // } + // + // final boolean primitiveType = isPrimitive(eType); + // + // // if the evaluator implements multiple evaluation itself, then use it + // if (evaluator instanceof IDerivedTypedElementCollectionImplementation) { + // IDerivedTypedElementCollectionImplementation collectionEvaluator = (IDerivedTypedElementCollectionImplementation) evaluator; + // if (derivedTypedElement.isMany()) { + // if (primitiveType) { + // if (expectedType != DerivedTypedElementPrimitiveTypeListResult.class) { + // throw new UnmatchingExpectedTypeException("The derivedTypedElement is multi-valued, and its type is primitive, " + //$NON-NLS-1$ + // "so expectedType must be " + DerivedTypedElementPrimitiveTypeListResult.class.getSimpleName()); //$NON-NLS-1$ + // } + // List<DerivedTypedElementPrimitiveTypeListResult<?>> listResultList = batchEvaluateMultiValuedPrimitiveDerivedTypedElementWithCollectionEvaluator( + // derivedTypedElement, sources, parameterValues, collectionEvaluator); + // // we just checked the type parameter T through expectedType + // @SuppressWarnings("unchecked") + // List<T> castList = (List<T>) listResultList; + // abstractResultList = castList; + // } else { + // if (expectedType != DerivedTypedElementEObjectListResult.class) { + // throw new UnmatchingExpectedTypeException("The derivedTypedElement is multi-valued, and it returns model elements, " + //$NON-NLS-1$ + // "so expectedType must be " + DerivedTypedElementEObjectListResult.class.getSimpleName()); //$NON-NLS-1$ + // } + // List<DerivedTypedElementEObjectListResult<?>> listResultList = batchEvaluateMultiValuedEObjectDerivedTypedElementWithCollectionEvaluator( + // derivedTypedElement, sources, parameterValues, collectionEvaluator); + // // we just checked the type parameter T through expectedType + // @SuppressWarnings("unchecked") + // List<T> castList = (List<T>) listResultList; + // abstractResultList = castList; + // } + // } else { + // if (primitiveType) { + // if (expectedType != DerivedTypedElementPrimitiveTypeResult.class) { + // throw new UnmatchingExpectedTypeException("The derivedTypedElement is single-valued, and its type is primitive, " + //$NON-NLS-1$ + // "so expectedType must be " + DerivedTypedElementPrimitiveTypeResult.class.getSimpleName()); //$NON-NLS-1$ + // } + // List<DerivedTypedElementPrimitiveTypeResult<?>> resultList = batchEvaluateSingleValuedPrimitiveDerivedTypedElementWithCollectionEvaluator( + // derivedTypedElement, sources, parameterValues, collectionEvaluator); + // // we just checked the type parameter T through expectedType + // @SuppressWarnings("unchecked") + // List<T> castList = (List<T>) resultList; + // abstractResultList = castList; + // } else { + // if (expectedType != DerivedTypedElementEObjectResult.class) { + // throw new UnmatchingExpectedTypeException("The derivedTypedElement is single-valued, and it returns a model element, " + //$NON-NLS-1$ + // "so expectedType must be " + DerivedTypedElementEObjectResult.class.getSimpleName()); //$NON-NLS-1$ + // } + // List<DerivedTypedElementEObjectResult<?>> resultList = batchEvaluateSingleValuedEObjectDerivedTypedElementWithCollectionEvaluator( + // derivedTypedElement, sources, parameterValues, collectionEvaluator); + // // we just checked the type parameter T through expectedType + // @SuppressWarnings("unchecked") + // List<T> castList = (List<T>) resultList; + // abstractResultList = castList; + // } + // } + // + // } else { + // // otherwise, do multiple evaluation by calling the evaluator's + // // single evaluation multiple times + // + // if (derivedTypedElement.isMany()) { + // if (primitiveType) { + // if (expectedType != DerivedTypedElementPrimitiveTypeListResult.class) { + // throw new UnmatchingExpectedTypeException("The derivedTypedElement is multi-valued, and its type is primitive, " + //$NON-NLS-1$ + // "so expectedType must be " + DerivedTypedElementPrimitiveTypeListResult.class.getSimpleName()); //$NON-NLS-1$ + // } + // List<DerivedTypedElementPrimitiveTypeListResult<?>> listResultList = batchEvaluateMultiValuedPrimitiveDerivedTypedElementWithSimpleEvaluator( + // derivedTypedElement, sources, parameterValues, evaluator); + // @SuppressWarnings("unchecked") + // List<T> castList = (List<T>) listResultList; + // abstractResultList = castList; + // } else { + // if (expectedType != DerivedTypedElementEObjectListResult.class) { + // throw new UnmatchingExpectedTypeException("The derivedTypedElement is multi-valued, and it returns model elements, " + //$NON-NLS-1$ + // "so expectedType must be " + DerivedTypedElementEObjectListResult.class.getSimpleName()); //$NON-NLS-1$ + // } + // List<DerivedTypedElementEObjectListResult<?>> listResultList = batchEvaluateMultiValuedEObjectDerivedTypedElementWithSimpleEvaluator( + // derivedTypedElement, sources, parameterValues, evaluator); + // @SuppressWarnings("unchecked") + // List<T> castList = (List<T>) listResultList; + // abstractResultList = castList; + // } + // } else { + // if (primitiveType) { + // if (expectedType != DerivedTypedElementPrimitiveTypeResult.class) { + // throw new UnmatchingExpectedTypeException("The derivedTypedElement is single-valued, and its type is primitive, " + //$NON-NLS-1$ + // "so expectedType must be " + DerivedTypedElementPrimitiveTypeResult.class.getSimpleName()); //$NON-NLS-1$ + // } + // List<DerivedTypedElementPrimitiveTypeResult<?>> resultList = batchEvaluateSingleValuedPrimitiveDerivedTypedElementWithSimpleCollectionEvaluator( + // derivedTypedElement, sources, parameterValues, evaluator); + // @SuppressWarnings("unchecked") + // List<T> castList = (List<T>) resultList; + // abstractResultList = castList; + // } else { + // if (expectedType != DerivedTypedElementEObjectResult.class) { + // throw new UnmatchingExpectedTypeException("The derivedTypedElement is single-valued, and it returns a model element, " + //$NON-NLS-1$ + // "so expectedType must be " + DerivedTypedElementEObjectResult.class.getSimpleName()); //$NON-NLS-1$ + // } + // List<DerivedTypedElementEObjectResult<?>> resultList = batchEvaluateSingleValuedEObjectDerivedTypedElementWithSimpleCollectionEvaluator( + // derivedTypedElement, sources, parameterValues, null); + // @SuppressWarnings("unchecked") + // List<T> castList = (List<T>) resultList; + // abstractResultList = castList; + // } + // } + // } + // return abstractResultList; + } + + // private static List<DerivedTypedElementPrimitiveTypeListResult<?>> batchEvaluateMultiValuedPrimitiveDerivedTypedElementWithCollectionEvaluator( + // final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues, + // final IDerivedTypedElementCollectionImplementation collectionEvaluator) + // throws DerivedTypedElementException { + // + // List<? extends AbstractDerivedTypedElementResult> listResultList = collectionEvaluator + // .getValues(derivedTypedElement, sources, parameterValues); + // + // // check the return type from the evaluator in order to be able to cast safely + // for (int index = 0; index < listResultList.size(); index++) { + // AbstractDerivedTypedElementResult elementResult = listResultList.get(index); + // if (elementResult instanceof DerivedTypedElementPrimitiveTypeListResult<?>) { + // DerivedTypedElementPrimitiveTypeListResult<?> derivedTypedElementPrimitiveTypeListResult = (DerivedTypedElementPrimitiveTypeListResult<?>) elementResult; + // checkResult(derivedTypedElement.getQuery(), derivedTypedElementPrimitiveTypeListResult.getResultList(), + // collectionEvaluator.getCheckResultType()); + // } else { + // throw new DerivedTypedElementEvaluationException(ErrorHandlingUtils.buildWrongTypeMessage( + // "Wrong element type at index " + index + " in the result from the evaluator: " + collectionEvaluator.getClass().getName(), //$NON-NLS-1$//$NON-NLS-2$ + // DerivedTypedElementPrimitiveTypeListResult.class, elementResult)); + // } + // } + // + // // just checked + // @SuppressWarnings("unchecked") + // List<DerivedTypedElementPrimitiveTypeListResult<?>> result = (List<DerivedTypedElementPrimitiveTypeListResult<?>>) listResultList; + // return result; + // } + // + // private static List<DerivedTypedElementEObjectListResult<?>> batchEvaluateMultiValuedEObjectDerivedTypedElementWithCollectionEvaluator( + // final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues, + // final IDerivedTypedElementCollectionImplementation collectionEvaluator) + // throws DerivedTypedElementException { + // List<? extends AbstractDerivedTypedElementResult> listResultList = collectionEvaluator + // .getValues(derivedTypedElement, sources, parameterValues); + // + // // check the return type from the evaluator in order to be able to cast safely + // for (int index = 0; index < listResultList.size(); index++) { + // AbstractDerivedTypedElementResult elementResult = listResultList.get(index); + // if (elementResult instanceof DerivedTypedElementEObjectListResult<?>) { + // DerivedTypedElementEObjectListResult<?> derivedTypedElementEObjectListResult = (DerivedTypedElementEObjectListResult<?>) elementResult; + // checkResult(derivedTypedElement.getQuery(), derivedTypedElementEObjectListResult.getResultList(), + // collectionEvaluator.getCheckResultType()); + // } else { + // throw new DerivedTypedElementEvaluationException(ErrorHandlingUtils.buildWrongTypeMessage( + // "Wrong element type at index " + index + " in the result from the evaluator: " + collectionEvaluator.getClass().getName(), //$NON-NLS-1$//$NON-NLS-2$ + // DerivedTypedElementEObjectListResult.class, elementResult)); + // } + // } + // + // // just checked + // @SuppressWarnings("unchecked") + // List<DerivedTypedElementEObjectListResult<?>> result = (List<DerivedTypedElementEObjectListResult<?>>) listResultList; + // return result; + // } + // + // private static List<DerivedTypedElementPrimitiveTypeResult<?>> batchEvaluateSingleValuedPrimitiveDerivedTypedElementWithCollectionEvaluator( + // final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues, + // final IDerivedTypedElementCollectionImplementation collectionEvaluator) + // throws DerivedTypedElementException { + // + // return null; + // } + // + // private static List<DerivedTypedElementEObjectResult<?>> batchEvaluateSingleValuedEObjectDerivedTypedElementWithCollectionEvaluator( + // final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues, + // final IDerivedTypedElementCollectionImplementation collectionEvaluator) throws DerivedTypedElementException { + // + // return null; + // } + // + // private static List<DerivedTypedElementPrimitiveTypeListResult<?>> batchEvaluateMultiValuedPrimitiveDerivedTypedElementWithSimpleEvaluator( + // final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues, + // final IDerivedTypedElementImplementation evaluator) { + // + // Query query = derivedTypedElement.getQuery(); + // + // List<DerivedTypedElementPrimitiveTypeListResult<?>> listResultList = new ArrayList<DerivedTypedElementPrimitiveTypeListResult<?>>(); + // for (EObject eObject : sources) { + // DerivedTypedElementPrimitiveTypeListResult<Object> primitiveTypeListResult = EFacetFactory.eINSTANCE + // .createDerivedTypedElementPrimitiveTypeListResult(); + // + // Throwable error = null; + // try { + // primitiveTypeListResult.setSource(eObject); + // primitiveTypeListResult.setDerivedTypedElement(derivedTypedElement); + // setParameterValues(primitiveTypeListResult.getParameterValues(), parameterValues); + // checkSourceType(query.getSourceType(), query, eObject); + // } catch (Throwable e) { + // error = e; + // } + // if (error != null) { + // primitiveTypeListResult.setException(error); + // } else { + // try { + // Object evaluationResult = evaluator.getValue(derivedTypedElement, eObject, parameterValues); + // checkResult(query, evaluationResult, evaluator.getCheckResultType()); + // // checked by checkResult + // Collection<?> evaluationResultCollection = (Collection<?>) evaluationResult; + // for (Object object : evaluationResultCollection) { + // primitiveTypeListResult.getResultList().add(object); + // } + // } catch (Throwable e) { + // primitiveTypeListResult.setException(e); + // } + // } + // listResultList.add(primitiveTypeListResult); + // + // } + // return listResultList; + // } + // + // private static List<DerivedTypedElementEObjectListResult<?>> batchEvaluateMultiValuedEObjectDerivedTypedElementWithSimpleEvaluator( + // final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues, + // final IDerivedTypedElementImplementation evaluator) { + // Query query = derivedTypedElement.getQuery(); + // + // List<DerivedTypedElementEObjectListResult<?>> listResultList = new ArrayList<DerivedTypedElementEObjectListResult<?>>(); + // for (EObject eObject : sources) { + // DerivedTypedElementEObjectListResult<EObject> eObjectListResult = EFacetFactory.eINSTANCE + // .createDerivedTypedElementEObjectListResult(); + // + // Throwable error = null; + // try { + // eObjectListResult.setSource(eObject); + // eObjectListResult.setDerivedTypedElement(derivedTypedElement); + // setParameterValues(eObjectListResult.getParameterValues(), parameterValues); + // checkSourceType(query.getSourceType(), query, eObject); + // } catch (Throwable e) { + // error = e; + // } + // if (error != null) { + // eObjectListResult.setException(error); + // } else { + // try { + // Object evaluationResult = evaluator.getValue(derivedTypedElement, eObject, parameterValues); + // checkResult(query, evaluationResult, evaluator.getCheckResultType(), false); + // // checked by checkResult + // @SuppressWarnings("unchecked") + // Collection<? extends EObject> evaluationResultCollection = (Collection<? extends EObject>) evaluationResult; + // for (EObject e : evaluationResultCollection) { + // eObjectListResult.getResultList().add(e); + // } + // } catch (Throwable e) { + // eObjectListResult.setException(e); + // } + // } + // listResultList.add(eObjectListResult); + // + // } + // return listResultList; + // } + // + // private static List<DerivedTypedElementPrimitiveTypeResult<?>> batchEvaluateSingleValuedPrimitiveDerivedTypedElementWithSimpleCollectionEvaluator( + // final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues, + // final IDerivedTypedElementImplementation evaluator) + // throws DerivedTypedElementException { + // + // return null; + // } + // + // private static List<DerivedTypedElementEObjectResult<?>> batchEvaluateSingleValuedEObjectDerivedTypedElementWithSimpleCollectionEvaluator( + // final DerivedTypedElement derivedTypedElement, final Collection<EObject> sources, final List<ParameterValue> parameterValues, + // final IDerivedTypedElementImplementation evaluator) + // throws DerivedTypedElementException { + // + // return null; + // } + + // public <T> List<DerivedTypedElementListResult<T>> evaluateMultiValued(final DerivedTypedElement derivedTypedElement, + // final Collection<? extends EObject> sources, final List<ParameterValue> parameterValues, + // final Class<T> expectedType) + // throws DerivedTypedElementException, UnmatchingExpectedTypeException { + // if (!derivedTypedElement.isMany()) { + // throw new IllegalArgumentException("This method doesn't accept a single-valued derived typed element."); //$NON-NLS-1$ + // } + // + // Query query = derivedTypedElement.getQuery(); + // if (query == null) { + // throw new DerivedTypedElementException("The given derived typed element doesn't contain a query"); //$NON-NLS-1$ + // } + // IDerivedTypedElementImplementation evaluator = + // DerivedTypedElementImplementationFactoryRegistry.INSTANCE.getEvaluatorFor(query); + // + // List<?> queryResult = batchEvaluateAndCheck(derivedTypedElement, sources, parameterValues, + // evaluator); + // // Java doesn't support co- or contra-variance on generics, + // // so we can't return the right type + // @SuppressWarnings("unchecked") + // List<DerivedTypedElementListResult<T>> multiResultList = + // (List<DerivedTypedElementListResult<T>>) queryResult; + // + // // check each result element in each result list + // if (expectedType != null) { + // int sourceIndex = 0; + // for (DerivedTypedElementListResult<?> derivedTypedElementResult : multiResultList) { + // EList<?> resultList = derivedTypedElementResult.getResultList(); + // int index = 0; + // for (Object resultElement : resultList) { + // // a null value for resultElement matches any type + // if (resultElement != null && !expectedType.isInstance(resultElement)) { + // throw new UnmatchingExpectedTypeException( + // "The element at index " + index + " in the list that resulted from the evaluation of the multi-valued " //$NON-NLS-1$ //$NON-NLS-2$ + // + "derived typed element does not match the expected type " //$NON-NLS-1$ + // + "for the source element at index " + sourceIndex, expectedType, resultElement); //$NON-NLS-1$ + // } + // index++; + // } + // sourceIndex++; + // } + // } + // return multiResultList; + // } + // + // private static List<?> batchEvaluateAndCheck(final DerivedTypedElement derivedTypedElement, + // final Collection<EObject> eObjects, + // final List<ParameterValue> parameterValues, final IDerivedTypedElementImplementation + // evaluator) + // throws DerivedTypedElementException { + // List<?> result; + // + // Query query = derivedTypedElement.getQuery(); + // if (query == null) { + // throw new IllegalArgumentException("the query cannot be null"); //$NON-NLS-1$ + // } + // + // EClassifier sourceType = query.getSourceType(); + // + // final boolean primitiveType = derivedTypedElement instanceof EAttribute; + // + // if (derivedTypedElement.isMany()) { + // if (evaluator instanceof IDerivedTypedElementCollectionImplementation) { + // IDerivedTypedElementCollectionImplementation collectionEvaluator = + // (IDerivedTypedElementCollectionImplementation) evaluator; + // // List<? extends AbstractDerivedTypedElementResult> listResultList = + // // collectionEvaluator + // // .getValues(derivedTypedElement, eObjects, parameterValues); + // // int index = 0; + // // for (AbstractDerivedTypedElementResult listResult : listResultList) { + // // EList<?> resultList; + // // if (primitiveType && listResult instanceof + // // DerivedTypedElementPrimitiveTypeListResult<?>) { + // // DerivedTypedElementPrimitiveTypeListResult<?> primitiveListResult = + // // (DerivedTypedElementPrimitiveTypeListResult<?>) listResult; + // // resultList = primitiveListResult.getResultList(); + // // } else if (!primitiveType && listResult instanceof + // // DerivedTypedElementEObjectListResult<?>) { + // // DerivedTypedElementEObjectListResult<?> eObjectListResult = + // // (DerivedTypedElementEObjectListResult<?>) listResult; + // // resultList = eObjectListResult.getResultList(); + // // } else { + // // throw new DerivedTypedElementEvaluationException( + // // "Wrong element type at index " + index + " in the result from the evaluator " + collectionEvaluator.getClass().getName()); //$NON-NLS-1$//$NON-NLS-2$ + // // } + // // checkResult(query, resultList, evaluator.getCheckResultType()); + // // index++; + // // } + // // result = listResultList; + // } else { + // + // // List<AbstractDerivedTypedElementResult> listResultList = new + // // ArrayList<AbstractDerivedTypedElementResult>(); + // // for (EObject eObject : eObjects) { + // // AbstractDerivedTypedElementResult listResult; + // // List<?> resultList; + // // if (primitiveType) { + // // DerivedTypedElementPrimitiveTypeListResult<?> primitiveTypeListResult = + // // EFacetFactory.eINSTANCE + // // .createDerivedTypedElementPrimitiveTypeListResult(); + // // listResult = primitiveTypeListResult; + // // resultList = primitiveTypeListResult.getResultList(); + // // } else { + // // DerivedTypedElementEObjectListResult<?> eObjectTypeListResult = + // // EFacetFactory.eINSTANCE + // // .createDerivedTypedElementEObjectListResult(); + // // listResult = eObjectTypeListResult; + // // resultList = eObjectTypeListResult.getResultList(); + // // } + // // + // // Throwable error = null; + // // try { + // // listResult.setSource(eObject); + // // listResult.setDerivedTypedElement(derivedTypedElement); + // // setParameterValues(listResult.getParameterValues(), parameterValues); + // // checkSourceType(sourceType, query, eObject); + // // } catch (Throwable e) { + // // error = e; + // // } + // // if (error != null) { + // // listResult.setException(error); + // // } else { + // // try { + // // Object evaluationResult = evaluator.getValue(derivedTypedElement, eObject, + // // parameterValues); + // // checkResult(query, evaluationResult, evaluator.getCheckResultType()); + // // // checked by checkResult + // // Collection<?> evaluationResultCollection = (Collection<?>) evaluationResult; + // // for (Object object : evaluationResultCollection) { + // // resultList.add(object); + // // } + // // } catch (Throwable e) { + // // listResult.setException(e); + // // } + // // } + // // listResultList.add(listResult); + // // + // // } + // // result = listResultList; + // + // } + // } else { + // // if the evaluator implements multiple evaluation itself, then use it + // if (evaluator instanceof IDerivedTypedElementCollectionImplementation) { + // IDerivedTypedElementCollectionImplementation collectionEvaluator = + // (IDerivedTypedElementCollectionImplementation) evaluator; + // List<? extends AbstractDerivedTypedElementResult> singleResultList = collectionEvaluator + // .getValues(derivedTypedElement, eObjects, parameterValues); + // int index = 0; + // for (AbstractDerivedTypedElementResult singleResult : singleResultList) { + // Object resultElement; + // if (primitiveType && singleResult instanceof DerivedTypedElementPrimitiveTypeResult<?>) { + // DerivedTypedElementPrimitiveTypeResult<?> primitiveResult = + // (DerivedTypedElementPrimitiveTypeResult<?>) singleResult; + // resultElement = primitiveResult.getResult(); + // } else if (!primitiveType && singleResult instanceof DerivedTypedElementEObjectResult<?>) { + // DerivedTypedElementEObjectResult<?> eObjectResult = (DerivedTypedElementEObjectResult<?>) + // singleResult; + // resultElement = eObjectResult.getResult(); + // } else { + // throw new DerivedTypedElementEvaluationException( + // "Wrong element type at index " + index + " in the result from the evaluator " + collectionEvaluator.getClass().getName()); //$NON-NLS-1$//$NON-NLS-2$ + // } + // checkResult(query, result, evaluator.getCheckResultType()); + // index++; + // } + // } else { + // // otherwise, do multiple evaluation by calling the evaluator's + // // single evaluation multiple times + // List<DerivedTypedElementResult<?>> resultList = new + // ArrayList<DerivedTypedElementResult<?>>(); + // for (EObject eObject : eObjects) { + // DerivedTypedElementResult<Object> singleResult = + // EFacetFactory.eINSTANCE.createDerivedTypedElementResult(); + // Throwable error = null; + // try { + // singleResult.setSource(eObject); + // singleResult.setDerivedTypedElement(derivedTypedElement); + // setParameterValues(singleResult.getParameterValues(), parameterValues); + // checkSourceType(sourceType, query, eObject); + // } catch (Throwable e) { + // error = e; + // } + // if (error != null) { + // singleResult.setException(error); + // } else { + // try { + // Object evaluationResult = evaluator.getValue(derivedTypedElement, eObject, parameterValues); + // checkResult(query, evaluationResult, evaluator.getCheckResultType()); + // singleResult.setResult(evaluationResult); + // } catch (Throwable e) { + // singleResult.setException(e); + // } + // } + // resultList.add(singleResult); + // } + // result = resultList; + // } + // } + // + // return result; + // } + + // private static void checkSourceType(final EClassifier sourceType, final Query query, final EObject eObject) + // throws DerivedTypedElementException { + // if (sourceType != null) { + // // a null value for eObject matches any type + // if (eObject != null && !sourceType.isInstance(eObject)) { + // StringBuffer message = new StringBuffer(); + // message.append("Wrong source type (for " + QueryUtils.getQueryDescription(query) + "): '"); //$NON-NLS-1$ //$NON-NLS-2$ + // message.append(eObject.eClass().getName()); + // message.append("' found; expected '"); //$NON-NLS-1$ + // message.append(sourceType.getName()); + // message.append("'."); //$NON-NLS-1$ + // throw new DerivedTypedElementTypeCheckingException(message.toString()); + // } + // } else { + // if (eObject != null) { + // throw new DerivedTypedElementException("the query's sourceType is null and the source is not null"); //$NON-NLS-1$ + // } + // } + // } + // + // private static void setParameterValues(final EList<ParameterValue> target, final List<ParameterValue> parameterValues) { + // if (parameterValues != null) { + // for (ParameterValue parameterValue : parameterValues) { + // if (parameterValue == null) { + // throw new IllegalArgumentException("null parameter value"); //$NON-NLS-1$ + // } + // // containment link -> we need to copy since we can have the same + // // parameter for several results + // target.add(EcoreUtil.copy(parameterValue)); + // } + // } + // } + + private static final void checkResult(final Query query, final Object result, + final boolean checkResultType, final boolean primitive) throws DerivedTypedElementTypeCheckingException { + if (QueryUtils.isMany(query)) { + if (!(result instanceof Collection<?>)) { + String strResult; + if (result == null) { + strResult = "null"; //$NON-NLS-1$ + } else { + strResult = "an instance of " + result.getClass().getName(); //$NON-NLS-1$ + } + throw new DerivedTypedElementTypeCheckingException( + "A collection is expected as result. The result is " //$NON-NLS-1$ + + strResult + " (on " + QueryUtils.getQueryDescription(query) + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + } + if (checkResultType) { + for (Object collectionElement : (Collection<?>) result) { + if (collectionElement != null + && !(QueryUtils.getReturnType(query) + .isInstance(collectionElement))) { + throw new DerivedTypedElementTypeCheckingException( + "Wrong result collection element type: " + collectionElement.getClass().getName() //$NON-NLS-1$ + + "(" + QueryUtils.getReturnType(query).getName() + " is expected) " //$NON-NLS-1$ //$NON-NLS-2$ + + " on " + QueryUtils.getQueryDescription(query)); //$NON-NLS-1$ + } + } + } else if (!primitive) { + // at least check that EObjects are returned + for (Object collectionElement : (Collection<?>) result) { + if (collectionElement != null && !(collectionElement instanceof EObject)) { + throw new DerivedTypedElementTypeCheckingException( + "Wrong result collection element type: " + collectionElement.getClass().getName() //$NON-NLS-1$ + + "(an instance of " + EObject.class.getName() + " is expected) " //$NON-NLS-1$ //$NON-NLS-2$ + + " on " + QueryUtils.getQueryDescription(query)); //$NON-NLS-1$ + } + } + } + } else { + if (result instanceof Collection<?>) { + throw new DerivedTypedElementTypeCheckingException("A " //$NON-NLS-1$ + + QueryUtils.getSourceType(query).getName() + + " instance is expected as result. The result is: " //$NON-NLS-1$ + + result + " (on " + QueryUtils.getQueryDescription(query) + ")"); //$NON-NLS-1$//$NON-NLS-2$ + } + if (checkResultType) { + if (result != null && !(QueryUtils.getReturnType(query).isInstance(result))) { + throw new DerivedTypedElementTypeCheckingException("Wrong result type: " //$NON-NLS-1$ + + result.getClass().getName() + + " is returned while " //$NON-NLS-1$ + + QueryUtils.getReturnType(query).getInstanceClassName() + + " is expected." + " (on " + QueryUtils.getQueryDescription(query) + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + } else if (!primitive) { + // at least check that an EObject is returned + if (result != null && !(result instanceof EObject)) { + throw new DerivedTypedElementTypeCheckingException( + "Wrong result collection element type: " + result.getClass().getName() //$NON-NLS-1$ + + "(an instance of " + EObject.class.getName() + " is expected) " //$NON-NLS-1$ //$NON-NLS-2$ + + " on " + QueryUtils.getQueryDescription(query)); //$NON-NLS-1$ + } + } + } + } + + private static boolean isPrimitive(final EClassifier eType) { + final boolean primitiveType; + if (eType instanceof EDataType) { + primitiveType = true; + } else if (eType instanceof EClass) { + primitiveType = false; + } else { + throw new IllegalArgumentException("unhandled derived typed element type: " + eType.getName()); //$NON-NLS-1$ + } + return primitiveType; + } + + /** + * Transform the element in parameter in list (if necessary). + * + * @param element + * the element to transform + * @return a list. + */ + protected static List<Object> setAsList(final Object element) { + List<Object> newList = new LinkedList<Object>(); + if (element instanceof List) { + @SuppressWarnings("unchecked") + // @SuppressWarnings("unchecked") the cast is safe because were + // casting a List to a List<Object> + final List<Object> tmpList = (List<Object>) element; + newList = tmpList; + } else if (element instanceof Collection) { + //Bug 526899 + Collection<?> result = (Collection<?>)element; + newList.addAll(result); + } else { + newList.add(element); + } + return newList; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/DerivedTypedElementUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/DerivedTypedElementUtils.java index 33cd52f0842..b9adbf7ca6a 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/DerivedTypedElementUtils.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/DerivedTypedElementUtils.java @@ -1,70 +1,70 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia-Software
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
- * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
- * Grégoire Dupé (Mia-Software) - Bug 361612 - [Restructuring] New core for new version of the Facet metamodel
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EOperation;
-import org.eclipse.emf.ecore.EParameter;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.UnmatchingExpectedTypeException;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.EFacetFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
-
-public final class DerivedTypedElementUtils {
-
- private DerivedTypedElementUtils() {
- // Must not be used
- }
-
- private static <T> List<ParameterValue> createAndCheckOperationParameterValues(final EOperation operation,
- final Object... arguments) throws UnmatchingExpectedTypeException {
- final EList<EParameter> operationParameters = operation.getEParameters();
- // Begin precondition checking
- if (arguments.length > 0
- && operationParameters.size() != arguments.length) {
- throw new IllegalArgumentException("Facet operation '" + operation.getName() + //$NON-NLS-1$
- "' expects " + operationParameters.size() + " parameters. Got " + arguments.length); //$NON-NLS-1$ //$NON-NLS-2$
- }
- // End precondition checking
- final List<ParameterValue> parameterValues = new ArrayList<ParameterValue>();
- for (int i = 0; i < arguments.length; i++) {
- final Object argument = arguments[i];
- final EParameter eParameter = operationParameters.get(i);
- // Begin precondition checking
- EmfUtils.checkAssignment(argument, eParameter);
- // End precondition checking
- final ParameterValue parameterValue = EFacetFactory.eINSTANCE.createParameterValue();
- parameterValue.setParameter(eParameter);
- parameterValue.setValue(argument);
- parameterValues.add(parameterValue);
- }
- return parameterValues;
- }
-
- public static Object evaluate(final EObject eObject, final EOperation operation, final IFacetManager facetManager, final Object... arguments) throws UnmatchingExpectedTypeException,
- DerivedTypedElementException {
- Object result;
- final List<ParameterValue> parameterValues = DerivedTypedElementUtils.createAndCheckOperationParameterValues(operation, arguments);
- result = IDerivedTypedElementManager.INSTANCE.evaluate((FacetOperation) operation, eObject, parameterValues, facetManager);
- return result;
- }
-}
+/******************************************************************************* + * Copyright (c) 2011 Mia-Software + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values. + * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel + * Grégoire Dupé (Mia-Software) - Bug 361612 - [Restructuring] New core for new version of the Facet metamodel + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>) + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EParameter; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.UnmatchingExpectedTypeException; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.EFacetFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; + +public final class DerivedTypedElementUtils { + + private DerivedTypedElementUtils() { + // Must not be used + } + + private static <T> List<ParameterValue> createAndCheckOperationParameterValues(final EOperation operation, + final Object... arguments) throws UnmatchingExpectedTypeException { + final EList<EParameter> operationParameters = operation.getEParameters(); + // Begin precondition checking + if (arguments.length > 0 + && operationParameters.size() != arguments.length) { + throw new IllegalArgumentException("Facet operation '" + operation.getName() + //$NON-NLS-1$ + "' expects " + operationParameters.size() + " parameters. Got " + arguments.length); //$NON-NLS-1$ //$NON-NLS-2$ + } + // End precondition checking + final List<ParameterValue> parameterValues = new ArrayList<ParameterValue>(); + for (int i = 0; i < arguments.length; i++) { + final Object argument = arguments[i]; + final EParameter eParameter = operationParameters.get(i); + // Begin precondition checking + EmfUtils.checkAssignment(argument, eParameter); + // End precondition checking + final ParameterValue parameterValue = EFacetFactory.eINSTANCE.createParameterValue(); + parameterValue.setParameter(eParameter); + parameterValue.setValue(argument); + parameterValues.add(parameterValue); + } + return parameterValues; + } + + public static Object evaluate(final EObject eObject, final EOperation operation, final IFacetManager facetManager, final Object... arguments) throws UnmatchingExpectedTypeException, + DerivedTypedElementException { + Object result; + final List<ParameterValue> parameterValues = DerivedTypedElementUtils.createAndCheckOperationParameterValues(operation, arguments); + result = IDerivedTypedElementManager.INSTANCE.evaluate((FacetOperation) operation, eObject, parameterValues, facetManager); + return result; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/EFacetManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/EFacetManager.java index 4b8a1fae0dd..7ce6f58e243 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/EFacetManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/EFacetManager.java @@ -1,197 +1,197 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
- * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.papyrus.emf.facet.efacet.EFacetFactory;
-import org.eclipse.papyrus.emf.facet.efacet.ParameterValue;
-import org.eclipse.papyrus.emf.facet.efacet.Query;
-import org.eclipse.papyrus.emf.facet.efacet.QueryContext;
-import org.eclipse.papyrus.emf.facet.efacet.QueryResult;
-import org.eclipse.papyrus.emf.facet.efacet.core.IEFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.QueryException;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.QueryTypeCheckingException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.query.QueryEvaluatorFactoryRegistry;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryEvaluator;
-
-/** @deprecated replaced by {@link DerivedTypedElementManager} */
-@Deprecated
-public final class EFacetManager implements IEFacetManager {
-
- /**
- * This method looks for a valid evaluator for the query and calls it to perform its
- * basicEvaluate
- */
- public Object basicEvaluate(final Query query, final EObject eObject,
- final List<ParameterValue> parameterValues) throws QueryException {
- IQueryEvaluator evaluator = QueryEvaluatorFactoryRegistry.INSTANCE.getEvaluatorFor(query);
- evaluator.startEvaluate();
- Object result = evaluateAndCheck(query, eObject, parameterValues, evaluator);
- evaluator.endEvaluate();
- return result;
- }
-
- private Object evaluateAndCheck(final Query query, final EObject eObject,
- final List<ParameterValue> parameterValues, final IQueryEvaluator evaluator)
- throws QueryException {
-
- if (!query.getScope().isInstance(eObject)) {
- StringBuffer message = new StringBuffer();
- message.append("Wrong context type (for query " + toString() + "): "); //$NON-NLS-1$ //$NON-NLS-2$
- message.append(eObject.eClass().getName());
- message.append(" found; expected scopes are {"); //$NON-NLS-1$
- message.append(query.getScope().getName());
- message.append("}"); //$NON-NLS-1$
- QueryTypeCheckingException e = new QueryTypeCheckingException(message.toString());
- throw e;
- }
- Object result = evaluator.basicEvaluate(query, eObject, parameterValues);
- checkResult(query, result, evaluator.getCheckResultType());
- return result;
- }
-
- /**
- * This method is equivalent to {@link EFacetManager#basicEvaluate(Query, EObject, List)} with
- * no query parameters.
- */
- public final Object basicEvaluate(final Query query, final EObject eObject)
- throws QueryException {
- return basicEvaluate(query, eObject, null);
- }
-
- /**
- * This method is used to evaluate the given {@link Query} on the given {@link EObject} taking
- * into consideration some {@link ParameterValue}s
- */
- public final QueryResult evaluate(final Query query, final EObject context,
- final List<ParameterValue> parameterValues) {
- QueryResult queryResult = EFacetFactory.eINSTANCE.createQueryResult();
- try {
- queryResult.setSource(context);
- queryResult.setResult(basicEvaluate(query, context, parameterValues));
- } catch (Exception e) {
- queryResult.setException(e);
- }
- return queryResult;
- }
-
- /**
- * Evaluate the query on a set of models and model elements described by the context parameter.
- *
- * The query is evaluated on each contextually referred model element and on each element of a
- * contextually referred model.
- *
- * @param queryContext
- * The query evaluation context described by a QueryContext instance.
- * @param parameterValues
- * The query parameter values.
- * @return A list of QueryResult (one per evaluation)
- * @throws QueryException
- */
- public final synchronized List<QueryResult> evaluate(final Query query,
- final QueryContext queryContext, final List<ParameterValue> parameterValues)
- throws QueryException {
- List<QueryResult> resultList = new ArrayList<QueryResult>();
- IQueryEvaluator evaluator = QueryEvaluatorFactoryRegistry.INSTANCE.getEvaluatorFor(query);
- try {
- evaluator.startEvaluate();
- for (EObject eObject : queryContext.getSelectedModelElements()) {
- QueryResult queryResult = executeQuery(query, parameterValues, eObject, evaluator);
- resultList.add(queryResult);
- }
- for (Resource resource : queryContext.getSelectedModels()) {
- TreeIterator<EObject> treeIterator = resource.getAllContents();
- while (treeIterator.hasNext()) {
- EObject eObject = treeIterator.next();
- QueryResult queryResult = executeQuery(query, parameterValues, eObject,
- evaluator);
- resultList.add(queryResult);
- }
- }
- } finally {
- evaluator.endEvaluate();
- }
- return resultList;
- }
-
- /**
- * This method is used to evaluate the given {@link Query} on the given {@link EObject}
- */
- public final QueryResult evaluate(final Query query, final EObject eObject) {
- QueryResult queryResult = evaluate(query, eObject, null);
- return queryResult;
- }
-
- private final QueryResult executeQuery(final Query query,
- final List<ParameterValue> parameterValues, final EObject eObject,
- final IQueryEvaluator evaluator) {
- QueryResult queryResult = EFacetFactory.eINSTANCE.createQueryResult();
- queryResult.setSource(eObject);
- try {
- Object result = evaluateAndCheck(query, eObject, parameterValues, evaluator);
- queryResult.setResult(result);
- } catch (QueryException e) {
- queryResult.setException(e);
- }
- return queryResult;
- }
-
- private final void checkResult(final Query query, final Object object,
- final boolean checkResultType) throws QueryTypeCheckingException {
- if (query.getUpperBound() > 1 || query.getUpperBound() == -1) {
- if (!(object instanceof Collection<?>)) {
- throw new QueryTypeCheckingException(
- "A collection is expected as result. The result is: " //$NON-NLS-1$
- + object + " (on " + toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- for (Object collectionElement : (Collection<?>) object) {
- if (checkResultType) {
- if (!(query.getEType().isInstance(collectionElement))) {
- QueryTypeCheckingException e = new QueryTypeCheckingException(
- "Wrong result collection element type (" //$NON-NLS-1$
- + query.getEType().getName() + " is expected): " //$NON-NLS-1$
- + collectionElement + " (on " //$NON-NLS-1$
- + toString() + ")"); //$NON-NLS-1$
- throw e;
- }
- }
- }
- } else {
- if (object instanceof Collection<?>) {
- throw new QueryTypeCheckingException("A " //$NON-NLS-1$
- + query.getEType().getName()
- + " instance is expected as result. The result is: " //$NON-NLS-1$
- + object + " (on " + toString() + ")"); //$NON-NLS-1$//$NON-NLS-2$
- }
- if (checkResultType) {
- if (!(query.getEType().isInstance(object))) {
- if (object != null) {
- throw new QueryTypeCheckingException("Wrong result type: " //$NON-NLS-1$
- + object.getClass().getName()
- + " is returned while " //$NON-NLS-1$
- + query.getEType().getInstanceClassName()
- + " is expected." + " (on " + toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- }
- }
- }
- }
-
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet + * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.papyrus.emf.facet.efacet.EFacetFactory; +import org.eclipse.papyrus.emf.facet.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.efacet.Query; +import org.eclipse.papyrus.emf.facet.efacet.QueryContext; +import org.eclipse.papyrus.emf.facet.efacet.QueryResult; +import org.eclipse.papyrus.emf.facet.efacet.core.IEFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.QueryException; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.QueryTypeCheckingException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.query.QueryEvaluatorFactoryRegistry; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryEvaluator; + +/** @deprecated replaced by {@link DerivedTypedElementManager} */ +@Deprecated +public final class EFacetManager implements IEFacetManager { + + /** + * This method looks for a valid evaluator for the query and calls it to perform its + * basicEvaluate + */ + public Object basicEvaluate(final Query query, final EObject eObject, + final List<ParameterValue> parameterValues) throws QueryException { + IQueryEvaluator evaluator = QueryEvaluatorFactoryRegistry.INSTANCE.getEvaluatorFor(query); + evaluator.startEvaluate(); + Object result = evaluateAndCheck(query, eObject, parameterValues, evaluator); + evaluator.endEvaluate(); + return result; + } + + private Object evaluateAndCheck(final Query query, final EObject eObject, + final List<ParameterValue> parameterValues, final IQueryEvaluator evaluator) + throws QueryException { + + if (!query.getScope().isInstance(eObject)) { + StringBuffer message = new StringBuffer(); + message.append("Wrong context type (for query " + toString() + "): "); //$NON-NLS-1$ //$NON-NLS-2$ + message.append(eObject.eClass().getName()); + message.append(" found; expected scopes are {"); //$NON-NLS-1$ + message.append(query.getScope().getName()); + message.append("}"); //$NON-NLS-1$ + QueryTypeCheckingException e = new QueryTypeCheckingException(message.toString()); + throw e; + } + Object result = evaluator.basicEvaluate(query, eObject, parameterValues); + checkResult(query, result, evaluator.getCheckResultType()); + return result; + } + + /** + * This method is equivalent to {@link EFacetManager#basicEvaluate(Query, EObject, List)} with + * no query parameters. + */ + public final Object basicEvaluate(final Query query, final EObject eObject) + throws QueryException { + return basicEvaluate(query, eObject, null); + } + + /** + * This method is used to evaluate the given {@link Query} on the given {@link EObject} taking + * into consideration some {@link ParameterValue}s + */ + public final QueryResult evaluate(final Query query, final EObject context, + final List<ParameterValue> parameterValues) { + QueryResult queryResult = EFacetFactory.eINSTANCE.createQueryResult(); + try { + queryResult.setSource(context); + queryResult.setResult(basicEvaluate(query, context, parameterValues)); + } catch (Exception e) { + queryResult.setException(e); + } + return queryResult; + } + + /** + * Evaluate the query on a set of models and model elements described by the context parameter. + * + * The query is evaluated on each contextually referred model element and on each element of a + * contextually referred model. + * + * @param queryContext + * The query evaluation context described by a QueryContext instance. + * @param parameterValues + * The query parameter values. + * @return A list of QueryResult (one per evaluation) + * @throws QueryException + */ + public final synchronized List<QueryResult> evaluate(final Query query, + final QueryContext queryContext, final List<ParameterValue> parameterValues) + throws QueryException { + List<QueryResult> resultList = new ArrayList<QueryResult>(); + IQueryEvaluator evaluator = QueryEvaluatorFactoryRegistry.INSTANCE.getEvaluatorFor(query); + try { + evaluator.startEvaluate(); + for (EObject eObject : queryContext.getSelectedModelElements()) { + QueryResult queryResult = executeQuery(query, parameterValues, eObject, evaluator); + resultList.add(queryResult); + } + for (Resource resource : queryContext.getSelectedModels()) { + TreeIterator<EObject> treeIterator = resource.getAllContents(); + while (treeIterator.hasNext()) { + EObject eObject = treeIterator.next(); + QueryResult queryResult = executeQuery(query, parameterValues, eObject, + evaluator); + resultList.add(queryResult); + } + } + } finally { + evaluator.endEvaluate(); + } + return resultList; + } + + /** + * This method is used to evaluate the given {@link Query} on the given {@link EObject} + */ + public final QueryResult evaluate(final Query query, final EObject eObject) { + QueryResult queryResult = evaluate(query, eObject, null); + return queryResult; + } + + private final QueryResult executeQuery(final Query query, + final List<ParameterValue> parameterValues, final EObject eObject, + final IQueryEvaluator evaluator) { + QueryResult queryResult = EFacetFactory.eINSTANCE.createQueryResult(); + queryResult.setSource(eObject); + try { + Object result = evaluateAndCheck(query, eObject, parameterValues, evaluator); + queryResult.setResult(result); + } catch (QueryException e) { + queryResult.setException(e); + } + return queryResult; + } + + private final void checkResult(final Query query, final Object object, + final boolean checkResultType) throws QueryTypeCheckingException { + if (query.getUpperBound() > 1 || query.getUpperBound() == -1) { + if (!(object instanceof Collection<?>)) { + throw new QueryTypeCheckingException( + "A collection is expected as result. The result is: " //$NON-NLS-1$ + + object + " (on " + toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ + } + for (Object collectionElement : (Collection<?>) object) { + if (checkResultType) { + if (!(query.getEType().isInstance(collectionElement))) { + QueryTypeCheckingException e = new QueryTypeCheckingException( + "Wrong result collection element type (" //$NON-NLS-1$ + + query.getEType().getName() + " is expected): " //$NON-NLS-1$ + + collectionElement + " (on " //$NON-NLS-1$ + + toString() + ")"); //$NON-NLS-1$ + throw e; + } + } + } + } else { + if (object instanceof Collection<?>) { + throw new QueryTypeCheckingException("A " //$NON-NLS-1$ + + query.getEType().getName() + + " instance is expected as result. The result is: " //$NON-NLS-1$ + + object + " (on " + toString() + ")"); //$NON-NLS-1$//$NON-NLS-2$ + } + if (checkResultType) { + if (!(query.getEType().isInstance(object))) { + if (object != null) { + throw new QueryTypeCheckingException("Wrong result type: " //$NON-NLS-1$ + + object.getClass().getName() + + " is returned while " //$NON-NLS-1$ + + query.getEType().getInstanceClassName() + + " is expected." + " (on " + toString() + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + + } + } + } + } + }
\ No newline at end of file diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/EmfUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/EmfUtils.java index 21936ec5d5c..454d998e2aa 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/EmfUtils.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/EmfUtils.java @@ -1,103 +1,103 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia-Software
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
- * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
- * Grégoire Dupé (Mia-Software) - Bug 361612 - [Restructuring] New core for new version of the Facet metamodel
- * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
- * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.emf.common.util.BasicEList;
-import org.eclipse.emf.ecore.ENamedElement;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EOperation;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.UnmatchingExpectedTypeException;
-
-public final class EmfUtils {
-
- private EmfUtils() {
- // Must not be used
- }
-
- public static void checkAssignment(final Object value, final ETypedElement eTypedElement)
- throws UnmatchingExpectedTypeException {
- final String typedElementName = getTypeElementDescription(eTypedElement);
- // Begin checking precondition
- if (eTypedElement.getEType() == null) {
- throw new IllegalArgumentException(typedElementName + " has a null type"); //$NON-NLS-1$
- }
- // End checking precondition
- if (value == null && (eTypedElement.getLowerBound() > 0)) {
- throw new IllegalArgumentException(
- "The assigned value cannot be null for " + typedElementName + " because multiplicity is " + eTypedElement.getLowerBound() + ".." + eTypedElement.getUpperBound()); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- }
- if (value != null) {
- if (eTypedElement.getUpperBound() == 1) {
- if (!eTypedElement.getEType().isInstance(value)) {
- throw new IllegalArgumentException(
- "Type mismatch for " + EcoreUtil.getURI(eTypedElement) + ": expected '" + eTypedElement.getEType().getName() + "' but got '" + value.getClass().getName() + "'."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
- } else { // expect a list for multiplicity-many
- if (!(value instanceof List<?>)) {
- throw new IllegalArgumentException("Type mismatch for " + typedElementName + "': expected a List because the parameter is multiplicity-many. But got a " + //$NON-NLS-1$ //$NON-NLS-2$
- value.getClass().getName() + "'."); //$NON-NLS-1$
- }
- final List<?> argumentList = (List<?>) value;
- try {
- CastUtils.checkTypeOfAllListElements(argumentList, eTypedElement.getEType().getInstanceClass());
- // FIXME What happens if we use a not generated meta-model ?
- } catch (UnmatchingExpectedTypeException e) {
- throw new UnmatchingExpectedTypeException(
- "Type mismatch for an element of the list value " + typedElementName, e); //$NON-NLS-1$
- }
- }
- }
- }
-
- private static String getTypeElementDescription(final ETypedElement eTypedElement) {
- String containerName = ""; //$NON-NLS-1$
- if (eTypedElement.eContainer() instanceof ENamedElement) {
- final ENamedElement namedContainer = (ENamedElement) eTypedElement.eContainer();
- containerName = "the " + namedContainer.eClass().getName() + " named '" + namedContainer.getName() + "'"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- }
- return "the " + eTypedElement.eClass().getName() + " named '" + eTypedElement.getName() + "' in " + containerName; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public static Object ecoreInvoke(final EObject eObject, final EOperation operation, final Object... arguments) throws InvocationTargetException {
- // delegate to Ecore
- final BasicEList<Object> operationParams = new BasicEList<Object>();
- for (Object param : arguments) {
- operationParams.add(param);
- }
- return eObject.eInvoke(operation, operationParams);
- }
-
- public static <T> T checkAssignment(final EStructuralFeature eStructuralFeature, final Class<T> expectedType, final Object value)
- throws UnmatchingExpectedTypeException {
- if (eStructuralFeature.isMany() && expectedType != null) {
- if (expectedType != Object.class
- && !Collection.class.isAssignableFrom(expectedType)) {
- throw new UnmatchingExpectedTypeException("The required eStructuralFeature is multi-valued, so expectedType must be a subtype of Collection."); //$NON-NLS-1$
- }
- if (!expectedType.isInstance(value)) {
- throw new UnmatchingExpectedTypeException("The derived typed element did not evaluate to the expected type", Collection.class, value); //$NON-NLS-1$
- }
- }
- return CastUtils.castToExpectedType(value, expectedType);
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2011 Mia-Software + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values. + * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel + * Grégoire Dupé (Mia-Software) - Bug 361612 - [Restructuring] New core for new version of the Facet metamodel + * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>) + * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal; + +import java.lang.reflect.InvocationTargetException; +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.ecore.ENamedElement; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.UnmatchingExpectedTypeException; + +public final class EmfUtils { + + private EmfUtils() { + // Must not be used + } + + public static void checkAssignment(final Object value, final ETypedElement eTypedElement) + throws UnmatchingExpectedTypeException { + final String typedElementName = getTypeElementDescription(eTypedElement); + // Begin checking precondition + if (eTypedElement.getEType() == null) { + throw new IllegalArgumentException(typedElementName + " has a null type"); //$NON-NLS-1$ + } + // End checking precondition + if (value == null && (eTypedElement.getLowerBound() > 0)) { + throw new IllegalArgumentException( + "The assigned value cannot be null for " + typedElementName + " because multiplicity is " + eTypedElement.getLowerBound() + ".." + eTypedElement.getUpperBound()); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ + } + if (value != null) { + if (eTypedElement.getUpperBound() == 1) { + if (!eTypedElement.getEType().isInstance(value)) { + throw new IllegalArgumentException( + "Type mismatch for " + EcoreUtil.getURI(eTypedElement) + ": expected '" + eTypedElement.getEType().getName() + "' but got '" + value.getClass().getName() + "'."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + } + } else { // expect a list for multiplicity-many + if (!(value instanceof List<?>)) { + throw new IllegalArgumentException("Type mismatch for " + typedElementName + "': expected a List because the parameter is multiplicity-many. But got a " + //$NON-NLS-1$ //$NON-NLS-2$ + value.getClass().getName() + "'."); //$NON-NLS-1$ + } + final List<?> argumentList = (List<?>) value; + try { + CastUtils.checkTypeOfAllListElements(argumentList, eTypedElement.getEType().getInstanceClass()); + // FIXME What happens if we use a not generated meta-model ? + } catch (UnmatchingExpectedTypeException e) { + throw new UnmatchingExpectedTypeException( + "Type mismatch for an element of the list value " + typedElementName, e); //$NON-NLS-1$ + } + } + } + } + + private static String getTypeElementDescription(final ETypedElement eTypedElement) { + String containerName = ""; //$NON-NLS-1$ + if (eTypedElement.eContainer() instanceof ENamedElement) { + final ENamedElement namedContainer = (ENamedElement) eTypedElement.eContainer(); + containerName = "the " + namedContainer.eClass().getName() + " named '" + namedContainer.getName() + "'"; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ + } + return "the " + eTypedElement.eClass().getName() + " named '" + eTypedElement.getName() + "' in " + containerName; //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ + } + + public static Object ecoreInvoke(final EObject eObject, final EOperation operation, final Object... arguments) throws InvocationTargetException { + // delegate to Ecore + final BasicEList<Object> operationParams = new BasicEList<Object>(); + for (Object param : arguments) { + operationParams.add(param); + } + return eObject.eInvoke(operation, operationParams); + } + + public static <T> T checkAssignment(final EStructuralFeature eStructuralFeature, final Class<T> expectedType, final Object value) + throws UnmatchingExpectedTypeException { + if (eStructuralFeature.isMany() && expectedType != null) { + if (expectedType != Object.class + && !Collection.class.isAssignableFrom(expectedType)) { + throw new UnmatchingExpectedTypeException("The required eStructuralFeature is multi-valued, so expectedType must be a subtype of Collection."); //$NON-NLS-1$ + } + if (!expectedType.isInstance(value)) { + throw new UnmatchingExpectedTypeException("The derived typed element did not evaluate to the expected type", Collection.class, value); //$NON-NLS-1$ + } + } + return CastUtils.castToExpectedType(value, expectedType); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetActionImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetActionImpl.java index a1612133b9a..5187727b62f 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetActionImpl.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetActionImpl.java @@ -1,201 +1,201 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Guyomar (Mia-Software) - Bug 338813 - [EMF Facet Framework] basic Facet actions
- * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EParameter;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.edit.command.AddCommand;
-import org.eclipse.emf.edit.command.SetCommand;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.emf.facet.efacet.EFacetPackage;
-import org.eclipse.papyrus.emf.facet.efacet.Facet;
-import org.eclipse.papyrus.emf.facet.efacet.FacetAttribute;
-import org.eclipse.papyrus.emf.facet.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.FacetReference;
-import org.eclipse.papyrus.emf.facet.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetAction;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager;
-import org.eclipse.papyrus.emf.facet.util.emf.core.exception.InvalidFacetSetException;
-import org.eclipse.papyrus.emf.facet.util.pde.core.internal.exported.BuildPropertiesUtils;
-
-/** @deprecated */
-@Deprecated
-public class FacetActionImpl implements IFacetAction {
-
- public Facet createFacetInFacetSet(final FacetSet facetSet, final Facet facet,
- final EditingDomain editingDomain) {
-
- if (facetSet == null) {
- throw new IllegalArgumentException("The given FacetSet cannot be null"); //$NON-NLS-1$
- }
- if (facet == null) {
- throw new IllegalArgumentException("The given Facet cannot be null"); //$NON-NLS-1$
- }
- if (facet.eResource() != null || facet.eContainer() != null) {
- throw new IllegalArgumentException("The given Facet cannot be contained by a resource"); //$NON-NLS-1$
- }
- if (editingDomain == null) {
- throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$
- }
-
- // If the current editingDomain's resourceSet does not contain the facetSet resource, then
- // we need to add it so that we can edit the facetSet
- if (!editingDomain.getResourceSet().getResources().contains(facetSet.eResource())) {
- editingDomain.getResourceSet().getResources().add(facetSet.eResource());
- }
-
- Command command = new AddCommand(editingDomain, facetSet,
- EFacetPackage.eINSTANCE.getFacetSet_Facets(), facet);
- editingDomain.getCommandStack().execute(command);
- return facet;
- }
-
- public void addAttributeInFacet(final Facet facet, final FacetAttribute facetAttribute,
- final EditingDomain editingDomain) {
-
- if (facet == null) {
- throw new IllegalArgumentException("The given Facet cannot be null"); //$NON-NLS-1$
- }
- if (facetAttribute == null) {
- throw new IllegalArgumentException("The given FacetAttribute cannot be null"); //$NON-NLS-1$
- }
- if (facetAttribute.eResource() != null || facetAttribute.eContainer() != null) {
- throw new IllegalArgumentException("The given FacetAttribute cannot be contained by a resource"); //$NON-NLS-1$
- }
- if (editingDomain == null) {
- throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$
- }
-
- Command command = new AddCommand(editingDomain, facet,
- EFacetPackage.eINSTANCE.getFacet_FacetElements(), facetAttribute);
- editingDomain.getCommandStack().execute(command);
- }
-
- public void addReferenceInFacet(final Facet facet, final FacetReference facetReference,
- final EditingDomain editingDomain) {
- if (facet == null) {
- throw new IllegalArgumentException("The given Facet cannot be null."); //$NON-NLS-1$
- }
- if (facetReference == null) {
- throw new IllegalArgumentException("The given FacetReference cannot be null"); //$NON-NLS-1$
- }
- if (facetReference.eResource() != null || facetReference.eContainer() != null) {
- throw new IllegalArgumentException("The given FacetReference cannot be contained by a resource"); //$NON-NLS-1$
- }
- if (editingDomain == null) {
- throw new IllegalArgumentException("The given EditingDomain cannot be null."); //$NON-NLS-1$
- }
-
- Command command = new AddCommand(editingDomain, facet,
- EFacetPackage.eINSTANCE.getFacet_FacetElements(), facetReference);
- editingDomain.getCommandStack().execute(command);
- }
-
- public void addOperationInFacet(final Facet facet, final FacetOperation facetOperation,
- final EditingDomain editingDomain) {
- if (editingDomain == null) {
- throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$
- }
- if (facetOperation == null) {
- throw new IllegalArgumentException("The given FacetOperation cannot be null"); //$NON-NLS-1$
- }
- if (facetOperation.eResource() != null || facetOperation.eContainer() != null) {
- throw new IllegalArgumentException("The given FacetOperation cannot be contained by a resource"); //$NON-NLS-1$
- }
- if (facet == null) {
- throw new IllegalArgumentException("The given Facet cannot be null"); //$NON-NLS-1$
- }
-
- Command command = new AddCommand(editingDomain, facet,
- EFacetPackage.eINSTANCE.getFacet_FacetElements(), facetOperation);
- editingDomain.getCommandStack().execute(command);
- }
-
- public void setFacetSetNsUri(final FacetSet facetSet, final String nsUri,
- final EditingDomain editingDomain) {
- if (editingDomain == null) {
- throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$
- }
- if (facetSet == null) {
- throw new IllegalArgumentException("The given FacetSet cannot be null"); //$NON-NLS-1$
- }
- Command command = new SetCommand(editingDomain, facetSet,
- EcorePackage.eINSTANCE.getEPackage_NsURI(), nsUri);
- editingDomain.getCommandStack().execute(command);
- }
-
- public void addParameterInOperation(final FacetOperation operation, final EParameter parameter,
- final EditingDomain editingDomain) {
- if (operation == null) {
- throw new IllegalArgumentException("The given FacetOperation cannot be null"); //$NON-NLS-1$
- }
- if (parameter == null) {
- throw new IllegalArgumentException("The given EParameter cannot be null"); //$NON-NLS-1$
- }
- if (parameter.eResource() != null || parameter.eContainer() != null) {
- throw new IllegalArgumentException("The given EParameter cannot be contained by a resource"); //$NON-NLS-1$
- }
- if (editingDomain == null) {
- throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$
- }
-
- Command command = new AddCommand(editingDomain, operation,
- EcorePackage.eINSTANCE.getEOperation_EParameters(), parameter);
- editingDomain.getCommandStack().execute(command);
- }
-
- public void createFacetSet(final FacetSet facetSet, final IFile file) throws IOException,
- InvalidFacetSetException {
- if (facetSet == null) {
- throw new IllegalArgumentException("The given FacetSet cannot be null"); //$NON-NLS-1$
- }
- if (file == null) {
- throw new IllegalArgumentException("The given IFile cannot be null"); //$NON-NLS-1$
- }
- if (file.exists()) {
- throw new IllegalArgumentException("The given IFile already exists"); //$NON-NLS-1$
- }
-
- // Create a resource set
- ResourceSet resourceSet = new ResourceSetImpl();
-
- // Get the URI of the model file.
- URI fileURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
-
- // Create a resource for this file.
- Resource resource = resourceSet.createResource(fileURI);
-
- // Add the facetSet the resource contents.
- resource.getContents().add(facetSet);
-
- // Save the contents of the resource to the file system.
- resource.save(null);
-
- try {
- BuildPropertiesUtils.addToBuild(file);
- } catch (Exception e) {
- Logger.logError(e, "Error adding file " + file.getFullPath() //$NON-NLS-1$
- + " to the build.properties", Activator.getDefault()); //$NON-NLS-1$
- }
- ICatalogSetManager.INSTANCE.registerModelDeclaration(file);
- }
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Guyomar (Mia-Software) - Bug 338813 - [EMF Facet Framework] basic Facet actions + * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal; + +import java.io.IOException; + +import org.eclipse.core.resources.IFile; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EParameter; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.edit.command.AddCommand; +import org.eclipse.emf.edit.command.SetCommand; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.emf.facet.efacet.EFacetPackage; +import org.eclipse.papyrus.emf.facet.efacet.Facet; +import org.eclipse.papyrus.emf.facet.efacet.FacetAttribute; +import org.eclipse.papyrus.emf.facet.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.FacetReference; +import org.eclipse.papyrus.emf.facet.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetAction; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager; +import org.eclipse.papyrus.emf.facet.util.emf.core.exception.InvalidFacetSetException; +import org.eclipse.papyrus.emf.facet.util.pde.core.internal.exported.BuildPropertiesUtils; + +/** @deprecated */ +@Deprecated +public class FacetActionImpl implements IFacetAction { + + public Facet createFacetInFacetSet(final FacetSet facetSet, final Facet facet, + final EditingDomain editingDomain) { + + if (facetSet == null) { + throw new IllegalArgumentException("The given FacetSet cannot be null"); //$NON-NLS-1$ + } + if (facet == null) { + throw new IllegalArgumentException("The given Facet cannot be null"); //$NON-NLS-1$ + } + if (facet.eResource() != null || facet.eContainer() != null) { + throw new IllegalArgumentException("The given Facet cannot be contained by a resource"); //$NON-NLS-1$ + } + if (editingDomain == null) { + throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$ + } + + // If the current editingDomain's resourceSet does not contain the facetSet resource, then + // we need to add it so that we can edit the facetSet + if (!editingDomain.getResourceSet().getResources().contains(facetSet.eResource())) { + editingDomain.getResourceSet().getResources().add(facetSet.eResource()); + } + + Command command = new AddCommand(editingDomain, facetSet, + EFacetPackage.eINSTANCE.getFacetSet_Facets(), facet); + editingDomain.getCommandStack().execute(command); + return facet; + } + + public void addAttributeInFacet(final Facet facet, final FacetAttribute facetAttribute, + final EditingDomain editingDomain) { + + if (facet == null) { + throw new IllegalArgumentException("The given Facet cannot be null"); //$NON-NLS-1$ + } + if (facetAttribute == null) { + throw new IllegalArgumentException("The given FacetAttribute cannot be null"); //$NON-NLS-1$ + } + if (facetAttribute.eResource() != null || facetAttribute.eContainer() != null) { + throw new IllegalArgumentException("The given FacetAttribute cannot be contained by a resource"); //$NON-NLS-1$ + } + if (editingDomain == null) { + throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$ + } + + Command command = new AddCommand(editingDomain, facet, + EFacetPackage.eINSTANCE.getFacet_FacetElements(), facetAttribute); + editingDomain.getCommandStack().execute(command); + } + + public void addReferenceInFacet(final Facet facet, final FacetReference facetReference, + final EditingDomain editingDomain) { + if (facet == null) { + throw new IllegalArgumentException("The given Facet cannot be null."); //$NON-NLS-1$ + } + if (facetReference == null) { + throw new IllegalArgumentException("The given FacetReference cannot be null"); //$NON-NLS-1$ + } + if (facetReference.eResource() != null || facetReference.eContainer() != null) { + throw new IllegalArgumentException("The given FacetReference cannot be contained by a resource"); //$NON-NLS-1$ + } + if (editingDomain == null) { + throw new IllegalArgumentException("The given EditingDomain cannot be null."); //$NON-NLS-1$ + } + + Command command = new AddCommand(editingDomain, facet, + EFacetPackage.eINSTANCE.getFacet_FacetElements(), facetReference); + editingDomain.getCommandStack().execute(command); + } + + public void addOperationInFacet(final Facet facet, final FacetOperation facetOperation, + final EditingDomain editingDomain) { + if (editingDomain == null) { + throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$ + } + if (facetOperation == null) { + throw new IllegalArgumentException("The given FacetOperation cannot be null"); //$NON-NLS-1$ + } + if (facetOperation.eResource() != null || facetOperation.eContainer() != null) { + throw new IllegalArgumentException("The given FacetOperation cannot be contained by a resource"); //$NON-NLS-1$ + } + if (facet == null) { + throw new IllegalArgumentException("The given Facet cannot be null"); //$NON-NLS-1$ + } + + Command command = new AddCommand(editingDomain, facet, + EFacetPackage.eINSTANCE.getFacet_FacetElements(), facetOperation); + editingDomain.getCommandStack().execute(command); + } + + public void setFacetSetNsUri(final FacetSet facetSet, final String nsUri, + final EditingDomain editingDomain) { + if (editingDomain == null) { + throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$ + } + if (facetSet == null) { + throw new IllegalArgumentException("The given FacetSet cannot be null"); //$NON-NLS-1$ + } + Command command = new SetCommand(editingDomain, facetSet, + EcorePackage.eINSTANCE.getEPackage_NsURI(), nsUri); + editingDomain.getCommandStack().execute(command); + } + + public void addParameterInOperation(final FacetOperation operation, final EParameter parameter, + final EditingDomain editingDomain) { + if (operation == null) { + throw new IllegalArgumentException("The given FacetOperation cannot be null"); //$NON-NLS-1$ + } + if (parameter == null) { + throw new IllegalArgumentException("The given EParameter cannot be null"); //$NON-NLS-1$ + } + if (parameter.eResource() != null || parameter.eContainer() != null) { + throw new IllegalArgumentException("The given EParameter cannot be contained by a resource"); //$NON-NLS-1$ + } + if (editingDomain == null) { + throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$ + } + + Command command = new AddCommand(editingDomain, operation, + EcorePackage.eINSTANCE.getEOperation_EParameters(), parameter); + editingDomain.getCommandStack().execute(command); + } + + public void createFacetSet(final FacetSet facetSet, final IFile file) throws IOException, + InvalidFacetSetException { + if (facetSet == null) { + throw new IllegalArgumentException("The given FacetSet cannot be null"); //$NON-NLS-1$ + } + if (file == null) { + throw new IllegalArgumentException("The given IFile cannot be null"); //$NON-NLS-1$ + } + if (file.exists()) { + throw new IllegalArgumentException("The given IFile already exists"); //$NON-NLS-1$ + } + + // Create a resource set + ResourceSet resourceSet = new ResourceSetImpl(); + + // Get the URI of the model file. + URI fileURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true); + + // Create a resource for this file. + Resource resource = resourceSet.createResource(fileURI); + + // Add the facetSet the resource contents. + resource.getContents().add(facetSet); + + // Save the contents of the resource to the file system. + resource.save(null); + + try { + BuildPropertiesUtils.addToBuild(file); + } catch (Exception e) { + Logger.logError(e, "Error adding file " + file.getFullPath() //$NON-NLS-1$ + + " to the build.properties", Activator.getDefault()); //$NON-NLS-1$ + } + ICatalogSetManager.INSTANCE.registerModelDeclaration(file); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetActions2Impl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetActions2Impl.java index deacdd79318..6894b1de4d2 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetActions2Impl.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetActions2Impl.java @@ -1,227 +1,227 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Guyomar (Mia-Software) - Bug 338813 - [EMF Facet Framework] basic Facet actions
- * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
- * Gregoire Dupe (Mia-Software) - Bug 362087 - [Deprecated] org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EParameter;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.emf.edit.command.AddCommand;
-import org.eclipse.emf.edit.command.SetCommand;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.incubatingapi.IFacetActions2;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.EFacetPackage;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager2;
-import org.eclipse.papyrus.emf.facet.util.emf.core.exception.InvalidFacetSetException;
-import org.eclipse.papyrus.emf.facet.util.pde.core.internal.exported.BuildPropertiesUtils;
-
-public class FacetActions2Impl implements IFacetActions2 {
-
- public void saveFacetSet(final FacetSet facetSet, final IFile file) throws IOException,
- InvalidFacetSetException {
- if (facetSet == null) {
- throw new IllegalArgumentException("The given FacetSet cannot be null"); //$NON-NLS-1$
- }
- if (file == null) {
- throw new IllegalArgumentException("The given IFile cannot be null"); //$NON-NLS-1$
- }
- if (file.exists()) {
- throw new IllegalArgumentException("The given IFile already exists"); //$NON-NLS-1$
- }
-
- // Create a resource set
- ResourceSet resourceSet = new ResourceSetImpl();
-
- // Get the URI of the model file.
- URI fileURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
-
- // Create a resource for this file.
- Resource resource = resourceSet.createResource(fileURI);
-
- // Add the facetSet the resource contents.
- resource.getContents().add(facetSet);
-
- // Save the contents of the resource to the file system.
- resource.save(null);
-
- try {
- BuildPropertiesUtils.addToBuild(file);
- } catch (Exception e) {
- Logger.logError(e, "Error adding file " + file.getFullPath() //$NON-NLS-1$
- + " to the build.properties", Activator.getDefault()); //$NON-NLS-1$
- }
- ICatalogSetManager2.INSTANCE.registerModelDeclaration(file);
- }
-
- public Facet createFacetInFacetSet(final FacetSet facetSet, final Facet facet,
- final EditingDomain editingDomain) {
- Command command = createCreateFacetInFacetSetCommand(facetSet, facet, editingDomain);
- // If the current editingDomain's resourceSet does not contain the facetSet resource, then
- // we need to add it so that we can edit the facetSet
- if (!editingDomain.getResourceSet().getResources().contains(facetSet.eResource())) {
- editingDomain.getResourceSet().getResources().add(facetSet.eResource());
- }
- editingDomain.getCommandStack().execute(command);
- return facet;
- }
-
- public Command createCreateFacetInFacetSetCommand(final FacetSet facetSet, final Facet facet,
- final EditingDomain editingDomain) {
- if (facetSet == null) {
- throw new IllegalArgumentException("The given FacetSet cannot be null"); //$NON-NLS-1$
- }
- if (facet == null) {
- throw new IllegalArgumentException("The given Facet cannot be null"); //$NON-NLS-1$
- }
- if (facet.eResource() != null || facet.eContainer() != null) {
- throw new IllegalArgumentException("The given Facet cannot be contained by a resource"); //$NON-NLS-1$
- }
- if (editingDomain == null) {
- throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$
- }
-
- return AddCommand.create(editingDomain, facetSet,
- EcorePackage.eINSTANCE.getEPackage_EClassifiers(), facet);
- }
-
- public void addAttributeInFacet(final Facet facet, final FacetAttribute facetAttribute,
- final EditingDomain editingDomain) {
- Command command = createAddAttributeInFacetCommand(facet, facetAttribute, editingDomain);
- editingDomain.getCommandStack().execute(command);
- }
-
- public Command createAddAttributeInFacetCommand(final Facet facet,
- final FacetAttribute facetAttribute, final EditingDomain editingDomain) {
- if (facet == null) {
- throw new IllegalArgumentException("The given Facet cannot be null"); //$NON-NLS-1$
- }
- if (facetAttribute == null) {
- throw new IllegalArgumentException("The given FacetAttribute cannot be null"); //$NON-NLS-1$
- }
- if (facetAttribute.eResource() != null || facetAttribute.eContainer() != null) {
- throw new IllegalArgumentException("The given FacetAttribute cannot be contained by a resource"); //$NON-NLS-1$
- }
- if (editingDomain == null) {
- throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$
- }
-
- return AddCommand.create(editingDomain, facet,
- EFacetPackage.eINSTANCE.getFacet_FacetElements(), facetAttribute);
- }
-
- public void addReferenceInFacet(final Facet facet, final FacetReference facetReference,
- final EditingDomain editingDomain) {
- Command command = createAddReferenceInFacetCommand(facet, facetReference, editingDomain);
- editingDomain.getCommandStack().execute(command);
- }
-
- public Command createAddReferenceInFacetCommand(final Facet facet,
- final FacetReference facetReference, final EditingDomain editingDomain) {
- if (facet == null) {
- throw new IllegalArgumentException("The given Facet cannot be null."); //$NON-NLS-1$
- }
- if (facetReference == null) {
- throw new IllegalArgumentException("The given FacetReference cannot be null"); //$NON-NLS-1$
- }
- if (facetReference.eResource() != null || facetReference.eContainer() != null) {
- throw new IllegalArgumentException("The given FacetReference cannot be contained by a resource"); //$NON-NLS-1$
- }
- if (editingDomain == null) {
- throw new IllegalArgumentException("The given EditingDomain cannot be null."); //$NON-NLS-1$
- }
-
- return AddCommand.create(editingDomain, facet,
- EFacetPackage.eINSTANCE.getFacet_FacetElements(), facetReference);
- }
-
- public void addOperationInFacet(final Facet facet, final FacetOperation facetOperation,
- final EditingDomain editingDomain) {
- Command command = createAddOperationInFacetCommand(facet, facetOperation, editingDomain);
- editingDomain.getCommandStack().execute(command);
- }
-
- public Command createAddOperationInFacetCommand(final Facet facet,
- final FacetOperation facetOperation, final EditingDomain editingDomain) {
- if (editingDomain == null) {
- throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$
- }
- if (facetOperation == null) {
- throw new IllegalArgumentException("The given FacetOperation cannot be null"); //$NON-NLS-1$
- }
- if (facetOperation.eResource() != null || facetOperation.eContainer() != null) {
- throw new IllegalArgumentException("The given FacetOperation cannot be contained by a resource"); //$NON-NLS-1$
- }
- if (facet == null) {
- throw new IllegalArgumentException("The given Facet cannot be null"); //$NON-NLS-1$
- }
-
- return AddCommand.create(editingDomain, facet,
- EFacetPackage.eINSTANCE.getFacet_FacetOperations(), facetOperation);
- }
-
- public void addParameterInOperation(final FacetOperation operation, final EParameter parameter,
- final EditingDomain editingDomain) {
- Command command = createAddParameterInOperationCommand(operation, parameter, editingDomain);
- editingDomain.getCommandStack().execute(command);
- }
-
- public Command createAddParameterInOperationCommand(final FacetOperation operation,
- final EParameter parameter, final EditingDomain editingDomain) {
- if (operation == null) {
- throw new IllegalArgumentException("The given FacetOperation cannot be null"); //$NON-NLS-1$
- }
- if (parameter == null) {
- throw new IllegalArgumentException("The given EParameter cannot be null"); //$NON-NLS-1$
- }
- if (parameter.eResource() != null || parameter.eContainer() != null) {
- throw new IllegalArgumentException("The given EParameter cannot be contained by a resource"); //$NON-NLS-1$
- }
- if (editingDomain == null) {
- throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$
- }
-
- return AddCommand.create(editingDomain, operation,
- EcorePackage.eINSTANCE.getEOperation_EParameters(), parameter);
- }
-
- public void setFacetSetNsUri(final FacetSet facetSet, final String nsUri,
- final EditingDomain editingDomain) {
- Command command = createSetFacetSetNsUriCommand(facetSet, nsUri, editingDomain);
- editingDomain.getCommandStack().execute(command);
- }
-
- public Command createSetFacetSetNsUriCommand(final FacetSet facetSet, final String nsUri,
- final EditingDomain editingDomain) {
- if (editingDomain == null) {
- throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$
- }
- if (facetSet == null) {
- throw new IllegalArgumentException("The given FacetSet cannot be null"); //$NON-NLS-1$
- }
- return SetCommand.create(editingDomain, facetSet,
- EcorePackage.eINSTANCE.getEPackage_NsURI(), nsUri);
- }
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Guyomar (Mia-Software) - Bug 338813 - [EMF Facet Framework] basic Facet actions + * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel + * Gregoire Dupe (Mia-Software) - Bug 362087 - [Deprecated] org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal; + +import java.io.IOException; + +import org.eclipse.core.resources.IFile; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EParameter; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.edit.command.AddCommand; +import org.eclipse.emf.edit.command.SetCommand; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.incubatingapi.IFacetActions2; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.EFacetPackage; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager2; +import org.eclipse.papyrus.emf.facet.util.emf.core.exception.InvalidFacetSetException; +import org.eclipse.papyrus.emf.facet.util.pde.core.internal.exported.BuildPropertiesUtils; + +public class FacetActions2Impl implements IFacetActions2 { + + public void saveFacetSet(final FacetSet facetSet, final IFile file) throws IOException, + InvalidFacetSetException { + if (facetSet == null) { + throw new IllegalArgumentException("The given FacetSet cannot be null"); //$NON-NLS-1$ + } + if (file == null) { + throw new IllegalArgumentException("The given IFile cannot be null"); //$NON-NLS-1$ + } + if (file.exists()) { + throw new IllegalArgumentException("The given IFile already exists"); //$NON-NLS-1$ + } + + // Create a resource set + ResourceSet resourceSet = new ResourceSetImpl(); + + // Get the URI of the model file. + URI fileURI = URI.createPlatformResourceURI(file.getFullPath().toString(), true); + + // Create a resource for this file. + Resource resource = resourceSet.createResource(fileURI); + + // Add the facetSet the resource contents. + resource.getContents().add(facetSet); + + // Save the contents of the resource to the file system. + resource.save(null); + + try { + BuildPropertiesUtils.addToBuild(file); + } catch (Exception e) { + Logger.logError(e, "Error adding file " + file.getFullPath() //$NON-NLS-1$ + + " to the build.properties", Activator.getDefault()); //$NON-NLS-1$ + } + ICatalogSetManager2.INSTANCE.registerModelDeclaration(file); + } + + public Facet createFacetInFacetSet(final FacetSet facetSet, final Facet facet, + final EditingDomain editingDomain) { + Command command = createCreateFacetInFacetSetCommand(facetSet, facet, editingDomain); + // If the current editingDomain's resourceSet does not contain the facetSet resource, then + // we need to add it so that we can edit the facetSet + if (!editingDomain.getResourceSet().getResources().contains(facetSet.eResource())) { + editingDomain.getResourceSet().getResources().add(facetSet.eResource()); + } + editingDomain.getCommandStack().execute(command); + return facet; + } + + public Command createCreateFacetInFacetSetCommand(final FacetSet facetSet, final Facet facet, + final EditingDomain editingDomain) { + if (facetSet == null) { + throw new IllegalArgumentException("The given FacetSet cannot be null"); //$NON-NLS-1$ + } + if (facet == null) { + throw new IllegalArgumentException("The given Facet cannot be null"); //$NON-NLS-1$ + } + if (facet.eResource() != null || facet.eContainer() != null) { + throw new IllegalArgumentException("The given Facet cannot be contained by a resource"); //$NON-NLS-1$ + } + if (editingDomain == null) { + throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$ + } + + return AddCommand.create(editingDomain, facetSet, + EcorePackage.eINSTANCE.getEPackage_EClassifiers(), facet); + } + + public void addAttributeInFacet(final Facet facet, final FacetAttribute facetAttribute, + final EditingDomain editingDomain) { + Command command = createAddAttributeInFacetCommand(facet, facetAttribute, editingDomain); + editingDomain.getCommandStack().execute(command); + } + + public Command createAddAttributeInFacetCommand(final Facet facet, + final FacetAttribute facetAttribute, final EditingDomain editingDomain) { + if (facet == null) { + throw new IllegalArgumentException("The given Facet cannot be null"); //$NON-NLS-1$ + } + if (facetAttribute == null) { + throw new IllegalArgumentException("The given FacetAttribute cannot be null"); //$NON-NLS-1$ + } + if (facetAttribute.eResource() != null || facetAttribute.eContainer() != null) { + throw new IllegalArgumentException("The given FacetAttribute cannot be contained by a resource"); //$NON-NLS-1$ + } + if (editingDomain == null) { + throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$ + } + + return AddCommand.create(editingDomain, facet, + EFacetPackage.eINSTANCE.getFacet_FacetElements(), facetAttribute); + } + + public void addReferenceInFacet(final Facet facet, final FacetReference facetReference, + final EditingDomain editingDomain) { + Command command = createAddReferenceInFacetCommand(facet, facetReference, editingDomain); + editingDomain.getCommandStack().execute(command); + } + + public Command createAddReferenceInFacetCommand(final Facet facet, + final FacetReference facetReference, final EditingDomain editingDomain) { + if (facet == null) { + throw new IllegalArgumentException("The given Facet cannot be null."); //$NON-NLS-1$ + } + if (facetReference == null) { + throw new IllegalArgumentException("The given FacetReference cannot be null"); //$NON-NLS-1$ + } + if (facetReference.eResource() != null || facetReference.eContainer() != null) { + throw new IllegalArgumentException("The given FacetReference cannot be contained by a resource"); //$NON-NLS-1$ + } + if (editingDomain == null) { + throw new IllegalArgumentException("The given EditingDomain cannot be null."); //$NON-NLS-1$ + } + + return AddCommand.create(editingDomain, facet, + EFacetPackage.eINSTANCE.getFacet_FacetElements(), facetReference); + } + + public void addOperationInFacet(final Facet facet, final FacetOperation facetOperation, + final EditingDomain editingDomain) { + Command command = createAddOperationInFacetCommand(facet, facetOperation, editingDomain); + editingDomain.getCommandStack().execute(command); + } + + public Command createAddOperationInFacetCommand(final Facet facet, + final FacetOperation facetOperation, final EditingDomain editingDomain) { + if (editingDomain == null) { + throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$ + } + if (facetOperation == null) { + throw new IllegalArgumentException("The given FacetOperation cannot be null"); //$NON-NLS-1$ + } + if (facetOperation.eResource() != null || facetOperation.eContainer() != null) { + throw new IllegalArgumentException("The given FacetOperation cannot be contained by a resource"); //$NON-NLS-1$ + } + if (facet == null) { + throw new IllegalArgumentException("The given Facet cannot be null"); //$NON-NLS-1$ + } + + return AddCommand.create(editingDomain, facet, + EFacetPackage.eINSTANCE.getFacet_FacetOperations(), facetOperation); + } + + public void addParameterInOperation(final FacetOperation operation, final EParameter parameter, + final EditingDomain editingDomain) { + Command command = createAddParameterInOperationCommand(operation, parameter, editingDomain); + editingDomain.getCommandStack().execute(command); + } + + public Command createAddParameterInOperationCommand(final FacetOperation operation, + final EParameter parameter, final EditingDomain editingDomain) { + if (operation == null) { + throw new IllegalArgumentException("The given FacetOperation cannot be null"); //$NON-NLS-1$ + } + if (parameter == null) { + throw new IllegalArgumentException("The given EParameter cannot be null"); //$NON-NLS-1$ + } + if (parameter.eResource() != null || parameter.eContainer() != null) { + throw new IllegalArgumentException("The given EParameter cannot be contained by a resource"); //$NON-NLS-1$ + } + if (editingDomain == null) { + throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$ + } + + return AddCommand.create(editingDomain, operation, + EcorePackage.eINSTANCE.getEOperation_EParameters(), parameter); + } + + public void setFacetSetNsUri(final FacetSet facetSet, final String nsUri, + final EditingDomain editingDomain) { + Command command = createSetFacetSetNsUriCommand(facetSet, nsUri, editingDomain); + editingDomain.getCommandStack().execute(command); + } + + public Command createSetFacetSetNsUriCommand(final FacetSet facetSet, final String nsUri, + final EditingDomain editingDomain) { + if (editingDomain == null) { + throw new IllegalArgumentException("The given EditingDomain cannot be null"); //$NON-NLS-1$ + } + if (facetSet == null) { + throw new IllegalArgumentException("The given FacetSet cannot be null"); //$NON-NLS-1$ + } + return SetCommand.create(editingDomain, facetSet, + EcorePackage.eINSTANCE.getEPackage_NsURI(), nsUri); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetActionsImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetActionsImpl.java index 5a466d94403..5d03055eb78 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetActionsImpl.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetActionsImpl.java @@ -1,77 +1,77 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetActions;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.papyrus.emf.facet.util.core.internal.Activator;
-import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager2;
-import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManagerFactory;
-import org.eclipse.papyrus.emf.facet.util.emf.core.exception.InvalidFacetSetException;
-import org.eclipse.papyrus.emf.facet.util.pde.core.internal.exported.BuildPropertiesUtils;
-
-/**
- * Concrete implementation of {@link IFacetActions}.
- */
-public class FacetActionsImpl implements IFacetActions {
-
- public void saveFacetSet(final FacetSet facetSet, final IFile file)
- throws IOException, InvalidFacetSetException {
- if (facetSet == null) {
- throw new IllegalArgumentException("The given FacetSet cannot be null"); //$NON-NLS-1$
- }
- if (file == null) {
- throw new IllegalArgumentException("The given IFile cannot be null"); //$NON-NLS-1$
- }
- if (file.exists()) {
- throw new IllegalArgumentException("The given IFile already exists"); //$NON-NLS-1$
- }
-
- // Create a resource set
- final ResourceSet resourceSet = new ResourceSetImpl();
-
- // Get the URI of the model file.
- final URI fileURI = URI.createPlatformResourceURI(file.getFullPath()
- .toString(), true);
-
- // Create a resource for this file.
- final Resource resource = resourceSet.createResource(fileURI);
-
- // Add the facetSet the resource contents.
- resource.getContents().add(facetSet);
-
- // Save the contents of the resource to the file system.
- resource.save(null);
-
- try {
- BuildPropertiesUtils.addToBuild(file);
- } catch (final Exception e) {
- Logger.logError(e, "Error adding file " + file.getFullPath() //$NON-NLS-1$
- + " to the build.properties", Activator.getDefault()); //$NON-NLS-1$
- }
-
- final ICatalogSetManager2 catalogSetManager = ICatalogSetManagerFactory.DEFAULT
- .createICatalogSetManager(resourceSet);
- catalogSetManager.registerModelDeclaration(file);
-
- // ICatalogSetManager.INSTANCE.registerModelDeclaration(file);
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal; + +import java.io.IOException; + +import org.eclipse.core.resources.IFile; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetActions; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.papyrus.emf.facet.util.core.internal.Activator; +import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager2; +import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManagerFactory; +import org.eclipse.papyrus.emf.facet.util.emf.core.exception.InvalidFacetSetException; +import org.eclipse.papyrus.emf.facet.util.pde.core.internal.exported.BuildPropertiesUtils; + +/** + * Concrete implementation of {@link IFacetActions}. + */ +public class FacetActionsImpl implements IFacetActions { + + public void saveFacetSet(final FacetSet facetSet, final IFile file) + throws IOException, InvalidFacetSetException { + if (facetSet == null) { + throw new IllegalArgumentException("The given FacetSet cannot be null"); //$NON-NLS-1$ + } + if (file == null) { + throw new IllegalArgumentException("The given IFile cannot be null"); //$NON-NLS-1$ + } + if (file.exists()) { + throw new IllegalArgumentException("The given IFile already exists"); //$NON-NLS-1$ + } + + // Create a resource set + final ResourceSet resourceSet = new ResourceSetImpl(); + + // Get the URI of the model file. + final URI fileURI = URI.createPlatformResourceURI(file.getFullPath() + .toString(), true); + + // Create a resource for this file. + final Resource resource = resourceSet.createResource(fileURI); + + // Add the facetSet the resource contents. + resource.getContents().add(facetSet); + + // Save the contents of the resource to the file system. + resource.save(null); + + try { + BuildPropertiesUtils.addToBuild(file); + } catch (final Exception e) { + Logger.logError(e, "Error adding file " + file.getFullPath() //$NON-NLS-1$ + + " to the build.properties", Activator.getDefault()); //$NON-NLS-1$ + } + + final ICatalogSetManager2 catalogSetManager = ICatalogSetManagerFactory.DEFAULT + .createICatalogSetManager(resourceSet); + catalogSetManager.registerModelDeclaration(file); + + // ICatalogSetManager.INSTANCE.registerModelDeclaration(file); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetCatalogManagerFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetCatalogManagerFactory.java index a6c235b6178..6387d4ea760 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetCatalogManagerFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetCatalogManagerFactory.java @@ -1,30 +1,30 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal;
-
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetSetCatalogManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetSetCatalogManagerFactory;
-import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManagerFactory;
-
-public class FacetCatalogManagerFactory implements IFacetSetCatalogManagerFactory {
-
- public IFacetSetCatalogManager getOrCreateFacetSetCatalogManager(
- final ResourceSet resourceSet) {
- return ICatalogSetManagerFactory.DEFAULT
- .createICatalogSetManager(resourceSet)
- .getCatalogManagerByType(IFacetSetCatalogManager.class)
- .get(0);
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal; + +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetSetCatalogManager; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetSetCatalogManagerFactory; +import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManagerFactory; + +public class FacetCatalogManagerFactory implements IFacetSetCatalogManagerFactory { + + public IFacetSetCatalogManager getOrCreateFacetSetCatalogManager( + final ResourceSet resourceSet) { + return ICatalogSetManagerFactory.DEFAULT + .createICatalogSetManager(resourceSet) + .getCatalogManagerByType(IFacetSetCatalogManager.class) + .get(0); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetCommandFactoryFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetCommandFactoryFactory.java index 39048805318..b9c7a7bc24a 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetCommandFactoryFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetCommandFactoryFactory.java @@ -1,25 +1,25 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetCommandFactory;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetCommandFactoryFactory;
-
-public class FacetCommandFactoryFactory implements IFacetCommandFactoryFactory {
-
- public IFacetCommandFactory createCommandFactory(
- final EditingDomain editingDomain) {
- return new FacetCommandFactoryImpl(editingDomain);
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal; + +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetCommandFactory; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetCommandFactoryFactory; + +public class FacetCommandFactoryFactory implements IFacetCommandFactoryFactory { + + public IFacetCommandFactory createCommandFactory( + final EditingDomain editingDomain) { + return new FacetCommandFactoryImpl(editingDomain); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetCommandFactoryImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetCommandFactoryImpl.java index 660efea176e..43ffd950dc5 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetCommandFactoryImpl.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetCommandFactoryImpl.java @@ -1,497 +1,497 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors
- * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.ENamedElement;
-import org.eclipse.emf.ecore.EParameter;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.edit.command.AddCommand;
-import org.eclipse.emf.edit.command.SetCommand;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetCommandFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.EFacetPackage;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.util.emf.core.command.EmfCommandUtils;
-
-/**
- * Concrete implementation of {@link IFacetCommandFactory}.
- */
-public class FacetCommandFactoryImpl implements IFacetCommandFactory {
-
- private static final String VALUE_NOT_NULL = "The given value cannot be null"; //$NON-NLS-1$
- private static final String PARENT_NOT_NULL = "The given parent cannot be null"; //$NON-NLS-1$
- private static final Object NAME = "name"; //$NON-NLS-1$
- private static final Object LOWER_BOUND = "lowerBound"; //$NON-NLS-1$
- private static final Object UPPER_BOUND = "upperBound"; //$NON-NLS-1$
- private static final Object VOLATILE = "volatile"; //$NON-NLS-1$
- private static final Object CHANGEABLE = "changeable"; //$NON-NLS-1$
- private static final Object DERIVED = "derived"; //$NON-NLS-1$
- private static final Object TRANSIENT = "transient"; //$NON-NLS-1$
- private static final Object ORDERED = "ordered"; //$NON-NLS-1$
- private static final Object UNIQUE = "unique"; //$NON-NLS-1$
- private final EditingDomain editingDomain;
-
- public FacetCommandFactoryImpl(final EditingDomain editingDomain) {
- this.editingDomain = editingDomain;
- }
-
- /**
- * Create an {@link AddCommand} to add the element to the owner.
- *
- * @param owner
- * the owner.
- * @param element
- * the element to add.
- * @return the command.
- */
- private Command createAddCommand(final Object owner, final Object element) {
-
- if (owner == null) {
- throw new IllegalArgumentException("The given owner cannot be null"); //$NON-NLS-1$
- }
-
- if (element == null) {
- throw new IllegalArgumentException("The given element cannot be null"); //$NON-NLS-1$
- }
-
- return AddCommand.create(this.editingDomain, owner,
- getEStructuralFeature(element), element);
- }
-
- /**
- * Create an {@link SetCommand} to add the element to the owner.
- *
- * @param initialObject
- * the owner.
- * @param newObject
- * the element to add.
- * @return the command.
- */
- public Command createSetCommand(final Object initialObject,
- final Object feature, final Object newValue) {
-
- if (initialObject == null) {
- throw new IllegalArgumentException("The given owner cannot be null"); //$NON-NLS-1$
- }
-
- if (feature == null) {
- throw new IllegalArgumentException("The given feature cannot be null"); //$NON-NLS-1$
- }
-
- if (newValue == null) {
- throw new IllegalArgumentException("The given newValue cannot be null"); //$NON-NLS-1$
- }
-
- return SetCommand.create(this.editingDomain, initialObject, feature,
- newValue);
- }
-
- /**
- * Return the {@link EStructuralFeature} for a given element.
- *
- * @param element
- * the element.
- * @return the eStructuralFeature for the element.
- */
- private static EStructuralFeature getEStructuralFeature(final Object element) {
- EStructuralFeature result = null;
- if (element instanceof FacetSet) {
- result = EcorePackage.eINSTANCE.getEPackage_ESubpackages();
- } else if (element instanceof Facet) {
- result = EcorePackage.eINSTANCE.getEPackage_EClassifiers();
- } else if ((element instanceof FacetAttribute)
- || (element instanceof FacetReference)) {
- result = EFacetPackage.eINSTANCE.getFacet_FacetElements();
- } else if (element instanceof FacetOperation) {
- result = EFacetPackage.eINSTANCE.getFacet_FacetOperations();
- }
- return result;
-
- }
-
- public Command createFacetSetInFacetSetCommand(final FacetSet owner,
- final FacetSet facetSet) {
- return createAddCommand(owner, facetSet);
- }
-
- public Command createFacetInFacetSetCommand(final FacetSet parent,
- final Facet facet) {
- return createAddCommand(parent, facet);
- }
-
- public Command createEditFacetStructuralFeatureCommand(
- final DerivedTypedElement feature, final Facet container,
- final String name, final int lowerBound, final int upperBound,
- final EClassifier type, final boolean ordered,
- final boolean unique, final Query query, final boolean volatilee,
- final boolean change, final boolean derived,
- final boolean transientt) {
- if (feature == null) {
- throw new IllegalArgumentException("The parameter facetOperation must not be null"); //$NON-NLS-1$
- }
- final List<Command> commands = new ArrayList<Command>();
- if (feature.eContainer() != container) {
- final Command command = new AddCommand(this.editingDomain,
- container,
- EFacetPackage.eINSTANCE.getFacet_FacetElements(), feature);
- commands.add(command);
- }
- if (feature instanceof EStructuralFeature) {
- final EStructuralFeature structuralFeature = (EStructuralFeature) feature;
- if (structuralFeature.isVolatile() != volatilee) {
- final Command command = new SetCommand(this.editingDomain,
- structuralFeature,
- EcorePackage.eINSTANCE.getEStructuralFeature_Volatile(),
- Boolean.valueOf(volatilee));
- commands.add(command);
- }
- if (structuralFeature.isChangeable() != change) {
- final Command command = new SetCommand(this.editingDomain,
- structuralFeature,
- EcorePackage.eINSTANCE
- .getEStructuralFeature_Changeable(),
- Boolean.valueOf(change));
- commands.add(command);
- }
- if (structuralFeature.isDerived() != derived) {
- final Command command = new SetCommand(this.editingDomain,
- structuralFeature,
- EcorePackage.eINSTANCE.getEStructuralFeature_Derived(),
- Boolean.valueOf(ordered));
- commands.add(command);
- }
- if (structuralFeature.isTransient() != transientt) {
- final Command command = new SetCommand(this.editingDomain,
- structuralFeature,
- EcorePackage.eINSTANCE
- .getEStructuralFeature_Transient(),
- Boolean.valueOf(unique));
- commands.add(command);
- }
- }
- commands.add(createEditDerivedTypeElementCommand(feature,
- name, lowerBound, upperBound, type, ordered, unique, query));
- return EmfCommandUtils.createResult(commands, "edit facet structural feature"); //$NON-NLS-1$
- }
-
- public Command createAddOperationInFacetCommand(final Facet parent,
- final FacetOperation facetOperation) {
- return createAddCommand(parent, facetOperation);
- }
-
- public Command createAddReferenceInFacetCommand(final Facet parent,
- final FacetReference facetReference) {
- return createAddCommand(parent, facetReference);
- }
-
- public Command createAddParameterInOperationCommand(
- final FacetOperation parent, final EParameter opParameter) {
- return createAddCommand(parent, opParameter);
- }
-
- public Command createChangeOwnerCommand(final Object element,
- final Object newOwner) {
- if (element == null) {
- throw new IllegalArgumentException("The given element cannot be null"); //$NON-NLS-1$
- }
- if (newOwner == null) {
- throw new IllegalArgumentException("The given element cannot be null"); //$NON-NLS-1$
- }
- return createAddCommand(newOwner, element);
- }
-
- public Command createEditFacetSetCommand(final FacetSet editedFacetSet,
- final FacetSet container, final String name) {
- if (editedFacetSet == null) {
- throw new IllegalArgumentException("The parameter 'editedFacetSet' must not be null"); //$NON-NLS-1$
- }
- final List<Command> commands = new ArrayList<Command>();
- commands.add(createEditENamedElementcommand(editedFacetSet, name));
- if (editedFacetSet.eContainer() != container) {
- final Command command = new AddCommand(this.editingDomain,
- container,
- EcorePackage.eINSTANCE.getEPackage_ESubpackages(),
- editedFacetSet);
- commands.add(command);
- }
- return EmfCommandUtils.createResult(commands, "Edit FacetSet"); //$NON-NLS-1$
- }
-
- public Command createEditFacetCommand(final Facet facet,
- final FacetSet container, final String name,
- final ETypedElement conformance, final EClass extendMetaclass,
- final FacetSet extendedFacetSet) {
- final List<Command> commands = new ArrayList<Command>();
- commands.add(createEditENamedElementcommand(facet, name));
- if (facet.eContainer() != container) {
- final Command command = new AddCommand(this.editingDomain,
- container,
- EcorePackage.eINSTANCE.getEPackage_EClassifiers(), facet);
- commands.add(command);
- }
- if (facet.getConformanceTypedElement() != conformance) {
- final Command command = new SetCommand(this.editingDomain, facet,
- EFacetPackage.eINSTANCE.getFacet_ConformanceTypedElement(),
- conformance);
- commands.add(command);
- }
- if (extendedFacetSet != null
- && (facet.getExtendedFacets().isEmpty() || facet
- .getExtendedFacets().get(0) != extendedFacetSet)) {
- final Command command = new SetCommand(this.editingDomain,
- facet,
- EFacetPackage.eINSTANCE.getFacet_ExtendedFacets(),
- Collections.singletonList(extendedFacetSet));
- commands.add(command);
- }
- if (facet.getExtendedMetaclass() != extendMetaclass) {
- final Command command = new SetCommand(this.editingDomain, facet,
- EFacetPackage.eINSTANCE.getFacet_ExtendedMetaclass(),
- extendMetaclass);
- commands.add(command);
- }
- return EmfCommandUtils.createResult(commands, "Edit Facet"); //$NON-NLS-1$
- }
-
- private Command createEditENamedElementcommand(
- final ENamedElement namedElement, final String name) {
- if (namedElement == null) {
- throw new IllegalArgumentException("The parameter 'editedFacetSet' must not be null"); //$NON-NLS-1$
- }
- final List<Command> commands = new ArrayList<Command>();
- if (namedElement.getName() != name) {
- final Command command = new SetCommand(this.editingDomain,
- namedElement,
- EcorePackage.eINSTANCE.getENamedElement_Name(), name);
- commands.add(command);
- }
- return EmfCommandUtils.createResult(commands, "Edit NamedElement"); //$NON-NLS-1$
- }
-
- public Command createSetFacetAttributeCommand(final Facet initialContainer,
- final FacetAttribute initialElement, final FacetAttribute newElement) {
- if (initialElement == null) {
- throw new IllegalArgumentException(PARENT_NOT_NULL);
- }
- if (newElement == null) {
- throw new IllegalArgumentException(VALUE_NOT_NULL);
- }
- final CompoundCommand commands = new CompoundCommand();
- final List<EAttribute> facetAttributes = EFacetPackage.eINSTANCE
- .getFacetAttribute().getEAllAttributes();
- setEStructuralFeatureAttributes(initialElement, newElement, commands,
- facetAttributes);
- setETypedElementAttributes(initialElement, newElement, commands,
- facetAttributes);
- final Command changeOwner = createChangeOwnerCommand(newElement,
- initialContainer);
- commands.append(changeOwner);
- return commands;
- }
-
- public Command createSetFacetReferenceCommand(final Facet initialContainer,
- final FacetReference initialElement, final FacetReference newElement) {
- if (initialElement == null) {
- throw new IllegalArgumentException(PARENT_NOT_NULL);
- }
- if (newElement == null) {
- throw new IllegalArgumentException(VALUE_NOT_NULL);
- }
- final CompoundCommand commands = new CompoundCommand();
- final List<EAttribute> facetReferences = EFacetPackage.eINSTANCE
- .getFacetReference().getEAllAttributes();
- setEStructuralFeatureAttributes(initialElement, newElement, commands,
- facetReferences);
- setETypedElementAttributes(initialElement, newElement, commands,
- facetReferences);
- final Command changeOwner = createChangeOwnerCommand(newElement, initialContainer);
- commands.append(changeOwner);
- return commands;
- }
-
- public Command createEditFacetOperationCommand(
- final FacetOperation facetOperation, final Facet container,
- final String name, final int lowerBound, final int upperBound,
- final EClassifier type, final boolean ordered,
- final boolean unique, final Query query) {
- if (facetOperation == null) {
- throw new IllegalArgumentException("The parameter facetOperation must not be null"); //$NON-NLS-1$
- }
- final List<Command> commands = new ArrayList<Command>();
- if (facetOperation.eContainer() != container) {
- final Command command = new AddCommand(this.editingDomain,
- container,
- EFacetPackage.eINSTANCE.getFacet_FacetOperations(),
- facetOperation);
- commands.add(command);
- }
- commands.add(createEditDerivedTypeElementCommand(facetOperation, name,
- lowerBound, upperBound, type, ordered, unique, query));
- return EmfCommandUtils.createResult(commands, "Edit facet operation"); //$NON-NLS-1$
- }
-
- private Command createEditDerivedTypeElementCommand(
- final DerivedTypedElement dte, final String name,
- final int lowerBound, final int upperBound, final EClassifier type,
- final boolean ordered, final boolean unique, final Query query) {
- if (dte == null) {
- throw new IllegalArgumentException("The parameter facetOperation must not be null"); //$NON-NLS-1$
- }
- final List<Command> commands = new ArrayList<Command>();
- commands.add(createEditETypedElementCommand(dte, name, lowerBound,
- upperBound, type, ordered, unique));
- if (dte.getQuery() != query) {
- final Command command = new SetCommand(this.editingDomain, dte,
- EFacetPackage.eINSTANCE.getDerivedTypedElement_Query(),
- query);
- commands.add(command);
- }
- return EmfCommandUtils.createResult(commands, "Edit derived typed element"); //$NON-NLS-1$
- }
-
- private Command createEditETypedElementCommand(
- final ETypedElement typedElement, final String name,
- final int lowerBound, final int upperBound, final EClassifier type,
- final boolean ordered, final boolean unique) {
- final List<Command> commands = new ArrayList<Command>();
- commands.add(createEditENamedElementcommand(typedElement, name));
- if (typedElement.getLowerBound() != lowerBound) {
- final Command command = new SetCommand(this.editingDomain,
- typedElement,
- EcorePackage.eINSTANCE.getETypedElement_LowerBound(),
- Integer.valueOf(lowerBound));
- commands.add(command);
- }
- if (typedElement.getUpperBound() != upperBound) {
- final Command command = new SetCommand(this.editingDomain,
- typedElement,
- EcorePackage.eINSTANCE.getETypedElement_UpperBound(),
- Integer.valueOf(upperBound));
- commands.add(command);
- }
- if (typedElement.isOrdered() != ordered) {
- final Command command = new SetCommand(this.editingDomain,
- typedElement,
- EcorePackage.eINSTANCE.getETypedElement_Ordered(),
- Boolean.valueOf(ordered));
- commands.add(command);
- }
- if (typedElement.isUnique() != unique) {
- final Command command = new SetCommand(this.editingDomain,
- typedElement,
- EcorePackage.eINSTANCE.getETypedElement_Unique(),
- Boolean.valueOf(unique));
- commands.add(command);
- }
- if (typedElement.getEType() != type) {
- final Command command = new SetCommand(this.editingDomain,
- typedElement,
- EcorePackage.eINSTANCE.getETypedElement_EType(), type);
- commands.add(command);
- }
- return EmfCommandUtils.createResult(commands, "Edit ETypedElement"); //$NON-NLS-1$
- }
-
- public Command createEditOperationParameterCommand(
- final EParameter parameter, final FacetOperation facetOperation,
- final String name, final int lowerBound, final int upperBound,
- final EClassifier type, final boolean ordered, final boolean unique) {
- if (parameter == null) {
- throw new IllegalArgumentException("The parameter parameter must not be null"); //$NON-NLS-1$
- }
- final List<Command> commands = new ArrayList<Command>();
- commands.add(createEditETypedElementCommand(parameter, name,
- lowerBound, upperBound, type, ordered, unique));
- return EmfCommandUtils.createResult(commands, "Edit operation parameter"); //$NON-NLS-1$
- }
-
- private void setEStructuralFeatureAttributes(
- final EStructuralFeature initialElement,
- final EStructuralFeature newElement,
- final CompoundCommand commands,
- final List<EAttribute> facetOperations) {
- for (final EAttribute attribute : facetOperations) {
- if (attribute.getName().equals(TRANSIENT)) {
- commands.append(createSetCommand(initialElement, attribute,
- Boolean.valueOf(newElement.isTransient())));
- }
- if (attribute.getName().equals(VOLATILE)) {
- commands.append(createSetCommand(initialElement, attribute,
- Boolean.valueOf(newElement.isVolatile())));
- }
- if (attribute.getName().equals(CHANGEABLE)) {
- commands.append(createSetCommand(initialElement, attribute,
- Boolean.valueOf(newElement.isChangeable())));
- }
- if (attribute.getName().equals(DERIVED)) {
- commands.append(createSetCommand(initialElement, attribute,
- Boolean.valueOf(newElement.isDerived())));
- }
- }
- }
-
- private void setETypedElementAttributes(final ETypedElement initialElement,
- final ETypedElement newElement, final CompoundCommand commands,
- final List<EAttribute> facetOperations) {
- for (final EAttribute attribute : facetOperations) {
- if (attribute.getName().equals(NAME)) {
- commands.append(createSetCommand(initialElement, attribute,
- newElement.getName()));
- }
- if (attribute.getName().equals(LOWER_BOUND)) {
- commands.append(createSetCommand(initialElement, attribute,
- Integer.valueOf(newElement.getLowerBound())));
- }
- if (attribute.getName().equals(UPPER_BOUND)) {
- commands.append(createSetCommand(initialElement, attribute,
- Integer.valueOf(newElement.getUpperBound())));
- }
- if (attribute.getName().equals(ORDERED)) {
- commands.append(createSetCommand(initialElement, attribute,
- Boolean.valueOf(newElement.isOrdered())));
- }
- if (attribute.getName().equals(UNIQUE)) {
- commands.append(createSetCommand(initialElement, attribute,
- Boolean.valueOf(newElement.isUnique())));
- }
- }
- }
-
-
- public Command createEditFacetOperationCommand(
- final DerivedTypedElement dte, final Facet facetContainer,
- final String name, final int lowerBound, final int upperBound,
- final EClassifier type, final boolean ordered,
- final boolean unique, final Query query) {
-
- return null;
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Alban Ménager (Soft-Maint) - Bug 387470 - [EFacet][Custom] Editors + * Grégoire Dupé (Mia-Software) - Bug 387470 - [EFacet][Custom] Editors + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.CompoundCommand; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.ENamedElement; +import org.eclipse.emf.ecore.EParameter; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.edit.command.AddCommand; +import org.eclipse.emf.edit.command.SetCommand; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetCommandFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.EFacetPackage; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.util.emf.core.command.EmfCommandUtils; + +/** + * Concrete implementation of {@link IFacetCommandFactory}. + */ +public class FacetCommandFactoryImpl implements IFacetCommandFactory { + + private static final String VALUE_NOT_NULL = "The given value cannot be null"; //$NON-NLS-1$ + private static final String PARENT_NOT_NULL = "The given parent cannot be null"; //$NON-NLS-1$ + private static final Object NAME = "name"; //$NON-NLS-1$ + private static final Object LOWER_BOUND = "lowerBound"; //$NON-NLS-1$ + private static final Object UPPER_BOUND = "upperBound"; //$NON-NLS-1$ + private static final Object VOLATILE = "volatile"; //$NON-NLS-1$ + private static final Object CHANGEABLE = "changeable"; //$NON-NLS-1$ + private static final Object DERIVED = "derived"; //$NON-NLS-1$ + private static final Object TRANSIENT = "transient"; //$NON-NLS-1$ + private static final Object ORDERED = "ordered"; //$NON-NLS-1$ + private static final Object UNIQUE = "unique"; //$NON-NLS-1$ + private final EditingDomain editingDomain; + + public FacetCommandFactoryImpl(final EditingDomain editingDomain) { + this.editingDomain = editingDomain; + } + + /** + * Create an {@link AddCommand} to add the element to the owner. + * + * @param owner + * the owner. + * @param element + * the element to add. + * @return the command. + */ + private Command createAddCommand(final Object owner, final Object element) { + + if (owner == null) { + throw new IllegalArgumentException("The given owner cannot be null"); //$NON-NLS-1$ + } + + if (element == null) { + throw new IllegalArgumentException("The given element cannot be null"); //$NON-NLS-1$ + } + + return AddCommand.create(this.editingDomain, owner, + getEStructuralFeature(element), element); + } + + /** + * Create an {@link SetCommand} to add the element to the owner. + * + * @param initialObject + * the owner. + * @param newObject + * the element to add. + * @return the command. + */ + public Command createSetCommand(final Object initialObject, + final Object feature, final Object newValue) { + + if (initialObject == null) { + throw new IllegalArgumentException("The given owner cannot be null"); //$NON-NLS-1$ + } + + if (feature == null) { + throw new IllegalArgumentException("The given feature cannot be null"); //$NON-NLS-1$ + } + + if (newValue == null) { + throw new IllegalArgumentException("The given newValue cannot be null"); //$NON-NLS-1$ + } + + return SetCommand.create(this.editingDomain, initialObject, feature, + newValue); + } + + /** + * Return the {@link EStructuralFeature} for a given element. + * + * @param element + * the element. + * @return the eStructuralFeature for the element. + */ + private static EStructuralFeature getEStructuralFeature(final Object element) { + EStructuralFeature result = null; + if (element instanceof FacetSet) { + result = EcorePackage.eINSTANCE.getEPackage_ESubpackages(); + } else if (element instanceof Facet) { + result = EcorePackage.eINSTANCE.getEPackage_EClassifiers(); + } else if ((element instanceof FacetAttribute) + || (element instanceof FacetReference)) { + result = EFacetPackage.eINSTANCE.getFacet_FacetElements(); + } else if (element instanceof FacetOperation) { + result = EFacetPackage.eINSTANCE.getFacet_FacetOperations(); + } + return result; + + } + + public Command createFacetSetInFacetSetCommand(final FacetSet owner, + final FacetSet facetSet) { + return createAddCommand(owner, facetSet); + } + + public Command createFacetInFacetSetCommand(final FacetSet parent, + final Facet facet) { + return createAddCommand(parent, facet); + } + + public Command createEditFacetStructuralFeatureCommand( + final DerivedTypedElement feature, final Facet container, + final String name, final int lowerBound, final int upperBound, + final EClassifier type, final boolean ordered, + final boolean unique, final Query query, final boolean volatilee, + final boolean change, final boolean derived, + final boolean transientt) { + if (feature == null) { + throw new IllegalArgumentException("The parameter facetOperation must not be null"); //$NON-NLS-1$ + } + final List<Command> commands = new ArrayList<Command>(); + if (feature.eContainer() != container) { + final Command command = new AddCommand(this.editingDomain, + container, + EFacetPackage.eINSTANCE.getFacet_FacetElements(), feature); + commands.add(command); + } + if (feature instanceof EStructuralFeature) { + final EStructuralFeature structuralFeature = (EStructuralFeature) feature; + if (structuralFeature.isVolatile() != volatilee) { + final Command command = new SetCommand(this.editingDomain, + structuralFeature, + EcorePackage.eINSTANCE.getEStructuralFeature_Volatile(), + Boolean.valueOf(volatilee)); + commands.add(command); + } + if (structuralFeature.isChangeable() != change) { + final Command command = new SetCommand(this.editingDomain, + structuralFeature, + EcorePackage.eINSTANCE + .getEStructuralFeature_Changeable(), + Boolean.valueOf(change)); + commands.add(command); + } + if (structuralFeature.isDerived() != derived) { + final Command command = new SetCommand(this.editingDomain, + structuralFeature, + EcorePackage.eINSTANCE.getEStructuralFeature_Derived(), + Boolean.valueOf(ordered)); + commands.add(command); + } + if (structuralFeature.isTransient() != transientt) { + final Command command = new SetCommand(this.editingDomain, + structuralFeature, + EcorePackage.eINSTANCE + .getEStructuralFeature_Transient(), + Boolean.valueOf(unique)); + commands.add(command); + } + } + commands.add(createEditDerivedTypeElementCommand(feature, + name, lowerBound, upperBound, type, ordered, unique, query)); + return EmfCommandUtils.createResult(commands, "edit facet structural feature"); //$NON-NLS-1$ + } + + public Command createAddOperationInFacetCommand(final Facet parent, + final FacetOperation facetOperation) { + return createAddCommand(parent, facetOperation); + } + + public Command createAddReferenceInFacetCommand(final Facet parent, + final FacetReference facetReference) { + return createAddCommand(parent, facetReference); + } + + public Command createAddParameterInOperationCommand( + final FacetOperation parent, final EParameter opParameter) { + return createAddCommand(parent, opParameter); + } + + public Command createChangeOwnerCommand(final Object element, + final Object newOwner) { + if (element == null) { + throw new IllegalArgumentException("The given element cannot be null"); //$NON-NLS-1$ + } + if (newOwner == null) { + throw new IllegalArgumentException("The given element cannot be null"); //$NON-NLS-1$ + } + return createAddCommand(newOwner, element); + } + + public Command createEditFacetSetCommand(final FacetSet editedFacetSet, + final FacetSet container, final String name) { + if (editedFacetSet == null) { + throw new IllegalArgumentException("The parameter 'editedFacetSet' must not be null"); //$NON-NLS-1$ + } + final List<Command> commands = new ArrayList<Command>(); + commands.add(createEditENamedElementcommand(editedFacetSet, name)); + if (editedFacetSet.eContainer() != container) { + final Command command = new AddCommand(this.editingDomain, + container, + EcorePackage.eINSTANCE.getEPackage_ESubpackages(), + editedFacetSet); + commands.add(command); + } + return EmfCommandUtils.createResult(commands, "Edit FacetSet"); //$NON-NLS-1$ + } + + public Command createEditFacetCommand(final Facet facet, + final FacetSet container, final String name, + final ETypedElement conformance, final EClass extendMetaclass, + final FacetSet extendedFacetSet) { + final List<Command> commands = new ArrayList<Command>(); + commands.add(createEditENamedElementcommand(facet, name)); + if (facet.eContainer() != container) { + final Command command = new AddCommand(this.editingDomain, + container, + EcorePackage.eINSTANCE.getEPackage_EClassifiers(), facet); + commands.add(command); + } + if (facet.getConformanceTypedElement() != conformance) { + final Command command = new SetCommand(this.editingDomain, facet, + EFacetPackage.eINSTANCE.getFacet_ConformanceTypedElement(), + conformance); + commands.add(command); + } + if (extendedFacetSet != null + && (facet.getExtendedFacets().isEmpty() || facet + .getExtendedFacets().get(0) != extendedFacetSet)) { + final Command command = new SetCommand(this.editingDomain, + facet, + EFacetPackage.eINSTANCE.getFacet_ExtendedFacets(), + Collections.singletonList(extendedFacetSet)); + commands.add(command); + } + if (facet.getExtendedMetaclass() != extendMetaclass) { + final Command command = new SetCommand(this.editingDomain, facet, + EFacetPackage.eINSTANCE.getFacet_ExtendedMetaclass(), + extendMetaclass); + commands.add(command); + } + return EmfCommandUtils.createResult(commands, "Edit Facet"); //$NON-NLS-1$ + } + + private Command createEditENamedElementcommand( + final ENamedElement namedElement, final String name) { + if (namedElement == null) { + throw new IllegalArgumentException("The parameter 'editedFacetSet' must not be null"); //$NON-NLS-1$ + } + final List<Command> commands = new ArrayList<Command>(); + if (namedElement.getName() != name) { + final Command command = new SetCommand(this.editingDomain, + namedElement, + EcorePackage.eINSTANCE.getENamedElement_Name(), name); + commands.add(command); + } + return EmfCommandUtils.createResult(commands, "Edit NamedElement"); //$NON-NLS-1$ + } + + public Command createSetFacetAttributeCommand(final Facet initialContainer, + final FacetAttribute initialElement, final FacetAttribute newElement) { + if (initialElement == null) { + throw new IllegalArgumentException(PARENT_NOT_NULL); + } + if (newElement == null) { + throw new IllegalArgumentException(VALUE_NOT_NULL); + } + final CompoundCommand commands = new CompoundCommand(); + final List<EAttribute> facetAttributes = EFacetPackage.eINSTANCE + .getFacetAttribute().getEAllAttributes(); + setEStructuralFeatureAttributes(initialElement, newElement, commands, + facetAttributes); + setETypedElementAttributes(initialElement, newElement, commands, + facetAttributes); + final Command changeOwner = createChangeOwnerCommand(newElement, + initialContainer); + commands.append(changeOwner); + return commands; + } + + public Command createSetFacetReferenceCommand(final Facet initialContainer, + final FacetReference initialElement, final FacetReference newElement) { + if (initialElement == null) { + throw new IllegalArgumentException(PARENT_NOT_NULL); + } + if (newElement == null) { + throw new IllegalArgumentException(VALUE_NOT_NULL); + } + final CompoundCommand commands = new CompoundCommand(); + final List<EAttribute> facetReferences = EFacetPackage.eINSTANCE + .getFacetReference().getEAllAttributes(); + setEStructuralFeatureAttributes(initialElement, newElement, commands, + facetReferences); + setETypedElementAttributes(initialElement, newElement, commands, + facetReferences); + final Command changeOwner = createChangeOwnerCommand(newElement, initialContainer); + commands.append(changeOwner); + return commands; + } + + public Command createEditFacetOperationCommand( + final FacetOperation facetOperation, final Facet container, + final String name, final int lowerBound, final int upperBound, + final EClassifier type, final boolean ordered, + final boolean unique, final Query query) { + if (facetOperation == null) { + throw new IllegalArgumentException("The parameter facetOperation must not be null"); //$NON-NLS-1$ + } + final List<Command> commands = new ArrayList<Command>(); + if (facetOperation.eContainer() != container) { + final Command command = new AddCommand(this.editingDomain, + container, + EFacetPackage.eINSTANCE.getFacet_FacetOperations(), + facetOperation); + commands.add(command); + } + commands.add(createEditDerivedTypeElementCommand(facetOperation, name, + lowerBound, upperBound, type, ordered, unique, query)); + return EmfCommandUtils.createResult(commands, "Edit facet operation"); //$NON-NLS-1$ + } + + private Command createEditDerivedTypeElementCommand( + final DerivedTypedElement dte, final String name, + final int lowerBound, final int upperBound, final EClassifier type, + final boolean ordered, final boolean unique, final Query query) { + if (dte == null) { + throw new IllegalArgumentException("The parameter facetOperation must not be null"); //$NON-NLS-1$ + } + final List<Command> commands = new ArrayList<Command>(); + commands.add(createEditETypedElementCommand(dte, name, lowerBound, + upperBound, type, ordered, unique)); + if (dte.getQuery() != query) { + final Command command = new SetCommand(this.editingDomain, dte, + EFacetPackage.eINSTANCE.getDerivedTypedElement_Query(), + query); + commands.add(command); + } + return EmfCommandUtils.createResult(commands, "Edit derived typed element"); //$NON-NLS-1$ + } + + private Command createEditETypedElementCommand( + final ETypedElement typedElement, final String name, + final int lowerBound, final int upperBound, final EClassifier type, + final boolean ordered, final boolean unique) { + final List<Command> commands = new ArrayList<Command>(); + commands.add(createEditENamedElementcommand(typedElement, name)); + if (typedElement.getLowerBound() != lowerBound) { + final Command command = new SetCommand(this.editingDomain, + typedElement, + EcorePackage.eINSTANCE.getETypedElement_LowerBound(), + Integer.valueOf(lowerBound)); + commands.add(command); + } + if (typedElement.getUpperBound() != upperBound) { + final Command command = new SetCommand(this.editingDomain, + typedElement, + EcorePackage.eINSTANCE.getETypedElement_UpperBound(), + Integer.valueOf(upperBound)); + commands.add(command); + } + if (typedElement.isOrdered() != ordered) { + final Command command = new SetCommand(this.editingDomain, + typedElement, + EcorePackage.eINSTANCE.getETypedElement_Ordered(), + Boolean.valueOf(ordered)); + commands.add(command); + } + if (typedElement.isUnique() != unique) { + final Command command = new SetCommand(this.editingDomain, + typedElement, + EcorePackage.eINSTANCE.getETypedElement_Unique(), + Boolean.valueOf(unique)); + commands.add(command); + } + if (typedElement.getEType() != type) { + final Command command = new SetCommand(this.editingDomain, + typedElement, + EcorePackage.eINSTANCE.getETypedElement_EType(), type); + commands.add(command); + } + return EmfCommandUtils.createResult(commands, "Edit ETypedElement"); //$NON-NLS-1$ + } + + public Command createEditOperationParameterCommand( + final EParameter parameter, final FacetOperation facetOperation, + final String name, final int lowerBound, final int upperBound, + final EClassifier type, final boolean ordered, final boolean unique) { + if (parameter == null) { + throw new IllegalArgumentException("The parameter parameter must not be null"); //$NON-NLS-1$ + } + final List<Command> commands = new ArrayList<Command>(); + commands.add(createEditETypedElementCommand(parameter, name, + lowerBound, upperBound, type, ordered, unique)); + return EmfCommandUtils.createResult(commands, "Edit operation parameter"); //$NON-NLS-1$ + } + + private void setEStructuralFeatureAttributes( + final EStructuralFeature initialElement, + final EStructuralFeature newElement, + final CompoundCommand commands, + final List<EAttribute> facetOperations) { + for (final EAttribute attribute : facetOperations) { + if (attribute.getName().equals(TRANSIENT)) { + commands.append(createSetCommand(initialElement, attribute, + Boolean.valueOf(newElement.isTransient()))); + } + if (attribute.getName().equals(VOLATILE)) { + commands.append(createSetCommand(initialElement, attribute, + Boolean.valueOf(newElement.isVolatile()))); + } + if (attribute.getName().equals(CHANGEABLE)) { + commands.append(createSetCommand(initialElement, attribute, + Boolean.valueOf(newElement.isChangeable()))); + } + if (attribute.getName().equals(DERIVED)) { + commands.append(createSetCommand(initialElement, attribute, + Boolean.valueOf(newElement.isDerived()))); + } + } + } + + private void setETypedElementAttributes(final ETypedElement initialElement, + final ETypedElement newElement, final CompoundCommand commands, + final List<EAttribute> facetOperations) { + for (final EAttribute attribute : facetOperations) { + if (attribute.getName().equals(NAME)) { + commands.append(createSetCommand(initialElement, attribute, + newElement.getName())); + } + if (attribute.getName().equals(LOWER_BOUND)) { + commands.append(createSetCommand(initialElement, attribute, + Integer.valueOf(newElement.getLowerBound()))); + } + if (attribute.getName().equals(UPPER_BOUND)) { + commands.append(createSetCommand(initialElement, attribute, + Integer.valueOf(newElement.getUpperBound()))); + } + if (attribute.getName().equals(ORDERED)) { + commands.append(createSetCommand(initialElement, attribute, + Boolean.valueOf(newElement.isOrdered()))); + } + if (attribute.getName().equals(UNIQUE)) { + commands.append(createSetCommand(initialElement, attribute, + Boolean.valueOf(newElement.isUnique()))); + } + } + } + + + public Command createEditFacetOperationCommand( + final DerivedTypedElement dte, final Facet facetContainer, + final String name, final int lowerBound, final int upperBound, + final EClassifier type, final boolean ordered, + final boolean unique, final Query query) { + + return null; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetManager.java index 4a66cea7ffb..da6ee29fce1 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetManager.java @@ -1,670 +1,670 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Mia-Software
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
- * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
- * Grégoire Dupé (Mia-Software) - Bug 361612 - [Restructuring] New core for new version of the Facet metamodel*
- * Olivier Remaud (Soft-Maint) - Bug 361794 - [Restructuring] EMF Facet customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
- * Olivier Remaud (Mia-Software) - Bug 374348 - Infinite loop in Facet override resolution
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Gregoire Dupe (Mia-Software) - Bug 376576 - [EFacet] Change the multiplicity of Facet::extendedFacet
- * Nicolas Bros (Mia-Software) - Bug 378475 - unit test failures after table refactoring
- * Thomas Cicognani (Soft-Maint) - Bug 416221 - New methods to get references in FacetManager API
- * Thomas Cicognani (Soft-Maint) - Bug 420193 - Listener on FacetManager
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EOperation;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.emf.facet.efacet.core.FacetUtils;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManagerListener;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.FacetManagerException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.FacetConformanceEvaluationException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.NonApplicableFacetException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.NonConformingEObjectException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.UnmatchingExpectedTypeException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exported.IResolverManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.serialization.SerializationManager;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementEObjectListResult;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementEObjectResult;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementPrimitiveTypeListResult;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementPrimitiveTypeResult;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.RuntimeFactory;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-
-public class FacetManager implements IFacetManager, Adapter {
-
- private static final EClassifier EBOOLEAN = EcorePackage.eINSTANCE.getEBoolean();
- private static final EClassifier EBOOLEAN_OBJECT = EcorePackage.eINSTANCE.getEBooleanObject();
- private final FacetManagerContext context;
- private final SerializationManager serializationMgr;
- private final ResourceSet resourceSet;
- private final Map<Facet, EClass> extendedMetaclass = new HashMap<>();
- private final Map<Facet, Map<Class<?>, List<? extends ETypedElement>>> typedElements = new HashMap<>();
-
- public FacetManager(final Resource resource) {
- this.serializationMgr = new SerializationManager(resource);
- this.context = new FacetManagerContext(this);
- this.resourceSet = resource.getResourceSet();
- }
-
- public FacetManager(final ResourceSet resourceSet) {
- this.serializationMgr = new SerializationManager(null);
- this.context = new FacetManagerContext(this);
- this.resourceSet = resourceSet;
- }
-
- @Override
- public void saveStructuralFeatureInstanceModel()
- throws FacetManagerException {
- this.serializationMgr.saveStructuralFeatureInstanceModel();
- }
-
- /**
- * Returns whether the given model element conforms to the given Facet
- *
- * @param eObject
- * the model element
- * @param facet
- * the Facet the applicability of which is being tested
- * @return whether the given model element should be seen as an instance of the given Facet
- */
- @Override
- public boolean isConforming(final EObject eObject, final Facet facet)
- throws FacetManagerException {
- return getConformanceState(eObject, facet) == FacetManager.ConformanceState.Conformant;
- }
-
- public enum ConformanceState {
- Conformant, NonConformingMetaclass, NonConformingElement
- }
-
- private void checkConformance(final EObject eObject, final Facet facet)
- throws FacetManagerException {
- final ConformanceState conformanceState = getConformanceState(eObject, facet);
- if (conformanceState == FacetManager.ConformanceState.NonConformingMetaclass) {
- throw new FacetManagerException("NonApplicableFacetException"); //$NON-NLS-1$
- }
- if (conformanceState == FacetManager.ConformanceState.NonConformingElement) {
- throw new FacetManagerException("NonConformingEObjectException"); //$NON-NLS-1$
- }
- }
-
- protected ConformanceState getConformanceState(final EObject eObject,
- final Facet facet) throws FacetManagerException {
- // Begin of precondition section
- if (eObject == null) {
- throw new IllegalArgumentException("eObject cannot be null"); //$NON-NLS-1$
- }
- if (facet == null) {
- throw new IllegalArgumentException("facet cannot be null"); //$NON-NLS-1$
- }
- // End of precondition section
-
- ConformanceState result;
- final EClass extendedMetaclass = getExtendedMetaclass(facet);
- if (extendedMetaclass != null
- && (extendedMetaclass.isSuperTypeOf(eObject.eClass()) || extendedMetaclass == EcorePackage.eINSTANCE.getEObject())) {
- final ETypedElement typeElement = facet.getConformanceTypedElement();
- if (typeElement == null) {
- result = FacetManager.ConformanceState.Conformant;
- } else {
- final Boolean isConforming = getConformanceValue(eObject, typeElement);
- if (isConforming.booleanValue()) {
- result = FacetManager.ConformanceState.Conformant;
- } else {
- result = FacetManager.ConformanceState.NonConformingElement;
- }
- }
- } else {
- result = FacetManager.ConformanceState.NonConformingMetaclass;
- }
- // The conformance constraint is inherited from the super facet.
- if (result == FacetManager.ConformanceState.Conformant) {
- for (Facet extFacet : facet.getExtendedFacets()) {
- result = getConformanceState(eObject, extFacet);
- if (result != FacetManager.ConformanceState.Conformant) {
- break;
- }
- }
- }
- return result;
- }
-
- private final EClass getExtendedMetaclass(Facet facet) {
- if (!extendedMetaclass.containsKey(facet)) {
- extendedMetaclass.put(facet, FacetUtils.getExtendedMetaclass(facet));
- }
- return extendedMetaclass.get(facet);
- }
-
- private Boolean getConformanceValue(final EObject eObject,
- final ETypedElement typeElement) throws FacetManagerException {
- // Begin precondition checking
- if (typeElement.isMany()) {
- throw new FacetManagerException("The Facet's conformance typed element must not be multi-valued"); //$NON-NLS-1$
- }
- if (typeElement.getEType() != FacetManager.EBOOLEAN && typeElement.getEType() != FacetManager.EBOOLEAN_OBJECT) {
- throw new FacetManagerException("The Facet conformance typed element evaluated to a wrong type."); //$NON-NLS-1$
- }
- // End precondition checking
- Boolean result; // conformance typedElement Value
- try {
- if (typeElement instanceof EStructuralFeature) {
- final EStructuralFeature structuralFeature = (EStructuralFeature) typeElement;
- // basicGet = true in order to avoid an infinite recursion
- result = internalGet(eObject, structuralFeature, Boolean.class, true);
- } else if (typeElement instanceof EOperation) {
- final EOperation operation = (EOperation) typeElement;
- if (operation.getEParameters().size() > 0) {
- throw new FacetConformanceEvaluationException("The Facet's conformance operation cannot have parameters"); //$NON-NLS-1$
- }
- // basicInvoke = true in order to avoid an infinite recursion,
- // ie don't check conformance and don't resolve overrides
- result = internalInvoke(eObject, operation, Boolean.class, true);
- } else {
- throw new FacetConformanceEvaluationException("Unsupported conformance typed element type: " + typeElement.getClass().getName()); //$NON-NLS-1$
- }
- } catch (Exception e) {
- throw new FacetManagerException(e);
- }
- if (result == null) {
- throw new FacetManagerException("The Facet conformance typed element evaluated to null"); //$NON-NLS-1$
- }
- return result;
- }
-
- @Override
- public void set(final EObject eObject,
- final EStructuralFeature structuralFeature, final Object newValue,
- final EditingDomain editingDomain) throws FacetManagerException {
- if (structuralFeature.isMany() && !(newValue instanceof Collection<?>)) {
- throw new IllegalArgumentException("newValue should be a Collection because eStructuralFeature is an EReference"); //$NON-NLS-1$
- // TODO: check the type of the elements of the list.
- }
- final EObject eContainer = structuralFeature.eContainer();
- if (eContainer instanceof Facet) {
- final Facet facet = (Facet) eContainer;
- checkConformance(eObject, facet);
- if (structuralFeature instanceof EAttribute) {
- final EAttribute eAttribute = (EAttribute) structuralFeature;
- if (structuralFeature instanceof FacetAttribute) {
- // TODO We still have to implement the setting of a derived facet attribute. Cf.
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=365726
- throw new UnsupportedOperationException("Setting a FacetAttribute is not yet implemented"); //$NON-NLS-1$
- } // else { // instanceof EAttribute
- this.serializationMgr.setAttribute(eObject, eAttribute, newValue);
- // }
- } else if (structuralFeature instanceof EReference) {
- final EReference reference = (EReference) structuralFeature;
- if (reference instanceof FacetReference) {
- // TODO We still have to implement the setting of a derived facet attribute. Cf.
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=365726
- throw new UnsupportedOperationException("Setting a FacetReference is not yet implemented"); //$NON-NLS-1$
- } // else { // instanceof EReference
- this.serializationMgr.setReference(eObject, reference, newValue);
- // }
- } else {
- throw new UnsupportedOperationException(
- "Setting a structural feature of type '" + structuralFeature.getClass().getName() + "' is not implemented"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- } else {
- eObject.eSet(structuralFeature, newValue);
- }
- }
-
- public <T> T get(final EObject eObject,
- final EStructuralFeature structuralFeature,
- final Class<T> expectedType) throws FacetManagerException {
- return internalGet(eObject, structuralFeature, expectedType, false);
- }
-
- private <T> T internalGet(final EObject eObject,
- final EStructuralFeature structuralFeature,
- final Class<T> expectedType, final boolean basicGet)
- throws FacetManagerException {
- try {
- Object value;
- if (structuralFeature.eContainer() instanceof Facet) {
-
- EStructuralFeature baseFeature = structuralFeature;
-
- if (!basicGet) {
- baseFeature = this.context.resolveOverrides(structuralFeature, eObject);
- final Facet facet = (Facet) baseFeature.eContainer();
- checkConformance(eObject, facet);
- }
- if (baseFeature.isDerived()) {
- if (!(baseFeature instanceof DerivedTypedElement)) {
- throw new UnsupportedOperationException("Cannot evaluate a derived structural feature that is not a DerivedTypedElement : not implemented"); //$NON-NLS-1$
- }
- value = IDerivedTypedElementManager.INSTANCE.evaluate((DerivedTypedElement) baseFeature, eObject, null, this);
- } else {
- if (baseFeature instanceof DerivedTypedElement) {
- throw new IllegalArgumentException("A DerivedTypedElement must always be derived"); //$NON-NLS-1$
- }
- value = this.serializationMgr.getNotDerivedValue(eObject, baseFeature);
- }
- } else { // Regular structural feature
- if (structuralFeature instanceof DerivedTypedElement) {
- throw new IllegalStateException("The given DerivedTypedElement is not contained in a Facet"); //$NON-NLS-1$
- }
- value = eObject.eGet(structuralFeature, true);
- }
- return EmfUtils.checkAssignment(structuralFeature, expectedType, value);
- } catch (Exception e) {
- throw new FacetManagerException(e);
- }
- }
-
- public <T> List<T> getMultiValued(final EObject eObject,
- final EStructuralFeature structuralFeature,
- final Class<T> expectedType) throws FacetManagerException {
- final Object result = internalGet(eObject, structuralFeature, null, false);
- // return the original list, which must be modifiable by the caller
- try {
- return CastUtils.castToExpectedListType(result, expectedType, true);
- } catch (UnmatchingExpectedTypeException e) {
- throw new UnmatchingExpectedTypeException("Failed to cast the value of '" + structuralFeature.getName() + "' to a list of " + expectedType.getName(), e); //$NON-NLS-1$//$NON-NLS-2$
- }
- }
-
- @Override
- public <T> T invoke(final EObject eObject, final EOperation operation,
- final Class<T> expectedType, final EditingDomain editingDomain, final Object... arguments)
- throws FacetManagerException {
- try {
- return internalInvoke(eObject, operation, expectedType, false, arguments);
- } catch (Exception e) {
- throw new FacetManagerException("Error invoking Facet operation '" + operation.getName() + "'", e); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public <T> List<T> invokeMultiValued(final EObject eObject, final EOperation operation,
- final Class<T> expectedType, final Object... arguments)
- throws FacetManagerException {
- Object result;
- try {
- result = internalInvoke(eObject, operation, null, false, arguments);
- } catch (Exception e) {
- throw new FacetManagerException("Error invoking Facet operation '" + operation.getName() + "'", e); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return CastUtils.castToExpectedListType(result, expectedType, true);
- }
-
- private <T> T internalInvoke(final EObject eObject, final EOperation operation, final Class<T> expectedType,
- final boolean basicInvoke, final Object... arguments)
- throws DerivedTypedElementException, InvocationTargetException,
- FacetConformanceEvaluationException, NonApplicableFacetException,
- NonConformingEObjectException, FacetManagerException {
- Object result;
- if (operation.eContainer() instanceof Facet) {
- final Facet facet = (Facet) operation.eContainer();
-
- if (!basicInvoke) {
- checkConformance(eObject, facet);
- }
- if (operation instanceof FacetOperation) {
- final FacetOperation facetOperation = (FacetOperation) operation;
- FacetOperation baseOperation = facetOperation;
- if (!basicInvoke) {
- baseOperation = this.context.resolveOverrides(facetOperation, eObject);
- }
- result = DerivedTypedElementUtils.evaluate(eObject, baseOperation, this, arguments);
- } else {
- result = EmfUtils.ecoreInvoke(eObject, operation, null, arguments);
- }
- } else { // Regular eOperation
- if (operation instanceof FacetOperation) {
- throw new IllegalStateException("The given FacetOperation is not contained in a Facet"); //$NON-NLS-1$
- }
- result = EmfUtils.ecoreInvoke(eObject, operation, null, arguments);
- }
- return CastUtils.castToExpectedType(result, expectedType);
- }
-
- public List<ETypedElementResult> get(final Collection<EObject> eObjects, final EStructuralFeature structuralFeature)
- throws DerivedTypedElementException {
-
- throw new UnsupportedOperationException("not implemented yet"); //$NON-NLS-1$
- }
-
- @Override
- public List<ETypedElementResult> batchInvoke(
- final Collection<EObject> eObjects, final EOperation operation,
- final Object... arguments) throws FacetManagerException {
-
- throw new UnsupportedOperationException("not implemented yet"); //$NON-NLS-1$
- }
-
- @Override
- public List<FacetSet> getManagedFacetSets() {
- return this.context;
- }
-
- public void setManagedFacetSets(final List<FacetSet> facetSets) {
- extendedMetaclass.clear();
- typedElements.clear();
- this.context.setManagedFacetSets(facetSets);
- }
-
- public void removeFacetSet(final FacetSet facetSet) {
- extendedMetaclass.clear();
- typedElements.clear();
- this.context.removeFacetSet(facetSet);
- }
-
- @Override
- public ResourceSet getResourceSet() {
- return this.resourceSet;
- }
-
- public List<ETypedElement> getAppliedFeatures() {
-
- throw new UnsupportedOperationException("not implemented yet"); //$NON-NLS-1$
- }
-
- @Override
- public Set<EAttribute> getAttributes(final EObject eObject)
- throws FacetManagerException {
- return new HashSet<>(getETypedElements(eObject, EAttribute.class));
- }
-
- @Override
- public Set<EStructuralFeature> getStructuralFeature(final EObject eObject)
- throws FacetManagerException {
- return new HashSet<>(getETypedElements(eObject, EStructuralFeature.class));
- }
-
- @Override
- public Set<EReference> getReferences(final EObject eObject)
- throws FacetManagerException {
- return new HashSet<>(getETypedElements(eObject, EReference.class));
- }
-
- @Deprecated
- public void addFacets(final EList<Facet> facets) {
- for (Facet facetToLoad : facets) {
- this.context.addFrontManagedFacetSet((FacetSet) facetToLoad
- .getEPackage());
- }
- extendedMetaclass.clear();
- typedElements.clear();
- }
-
- @Deprecated
- public void unLoadAllFacets() {
- removeAllManagedFacetSets();
- }
-
- public void removeAllManagedFacetSets() {
- this.context.clear();
- extendedMetaclass.clear();
- typedElements.clear();
- }
-
- @Override
- public <T> List<T> getOrInvokeMultiValued(final EObject eObject,
- final ETypedElement eTypedElement, final Class<T> classs)
- throws FacetManagerException {
- List<T> result = null;
- if (eTypedElement instanceof EStructuralFeature) {
- final EStructuralFeature structuralFeature = (EStructuralFeature) eTypedElement;
- result = getMultiValued(eObject, structuralFeature, classs);
- } else if (eTypedElement instanceof EOperation) {
- final EOperation eOperation = (EOperation) eTypedElement;
- result = invokeMultiValued(eObject, eOperation, classs);
- }
- return result;
- }
-
- @Override
- public <T> T getOrInvoke(final EObject eObject,
- final ETypedElement eTypedElement, final Class<T> classs)
- throws FacetManagerException {
- T result = null;
- if (eTypedElement instanceof EStructuralFeature) {
- final EStructuralFeature structuralFeature = (EStructuralFeature) eTypedElement;
- result = get(eObject, structuralFeature, classs);
- } else if (eTypedElement instanceof EOperation) {
- final EOperation eOperation = (EOperation) eTypedElement;
- result = invoke(eObject, eOperation, classs, null);
- }
- return result;
- }
-
- public List<Facet> getManagedFacets() {
- throw new IllegalStateException("Not implemented, and never will since it's deprecated"); //$NON-NLS-1$
- }
-
- @Override
- public <T> List<ETypedElementResult> batchGetOrInvoke(final Collection<EObject> sources, final ETypedElement query, final Class<T> classs)
- throws FacetManagerException {
- final List<ETypedElementResult> results = new LinkedList<ETypedElementResult>();
- for (EObject source : sources) {
- ETypedElementResult result = null;
- Exception exception = null;
- if (query.getEType() instanceof EClass) {
- if (query.getUpperBound() == 1) {
- final ETypedElementEObjectResult<EObject> eObjectResult = RuntimeFactory.eINSTANCE.createETypedElementEObjectResult();
- try {
- eObjectResult.setResult(this.getOrInvoke(source, query, EObject.class));
- } catch (Exception e) {
- exception = e;
- }
- result = eObjectResult;
- } else {
- final ETypedElementEObjectListResult<EObject> eObjectResultList = RuntimeFactory.eINSTANCE.createETypedElementEObjectListResult();
- try {
- eObjectResultList.getResultList().addAll(this.getOrInvokeMultiValued(source, query, EObject.class));
- } catch (Exception e) {
- exception = e;
- }
- result = eObjectResultList;
- }
- } else {
- if (query.getUpperBound() == 1) {
- final ETypedElementPrimitiveTypeResult<Object> eObjectResult = RuntimeFactory.eINSTANCE.createETypedElementPrimitiveTypeResult();
- try {
- eObjectResult.setResult(this.getOrInvoke(source, query, Collection.class));
- } catch (Exception e) {
- exception = e;
- }
- result = eObjectResult;
- } else {
- final ETypedElementPrimitiveTypeListResult<Object> eObjectResultList = RuntimeFactory.eINSTANCE.createETypedElementPrimitiveTypeListResult();
- eObjectResultList.getResultList().addAll(this.getOrInvokeMultiValued(source, query, Object.class));
- result = eObjectResultList;
- }
- }
- if (exception != null) {
- result.setException(exception);
- Logger.logWarning(exception, Activator.getDefault());
- }
- result.setDerivedTypedElement(query);
- result.setSource(source);
- results.add(result);
- }
- return results;
- }
-
- public void addBackManagedFacetSet(final FacetSet facetSet) {
- this.context.addBackManagedFacetSet(facetSet);
- extendedMetaclass.clear();
- typedElements.clear();
- }
-
- public void addFrontManagedFacetSet(final FacetSet facetSet) {
- this.context.addFrontManagedFacetSet(facetSet);
- extendedMetaclass.clear();
- typedElements.clear();
- }
-
- @Override
- public void notifyChanged(final Notification notification) {
- // Nothing to do
- }
-
- @Override
- public Notifier getTarget() {
- return null;
- }
-
- @Override
- public void setTarget(final Notifier newTarget) {
- // Nothing to do
- }
-
- @Override
- public boolean isAdapterForType(final Object type) {
- return false;
- }
-
- @Override
- public void addListener(final IFacetManagerListener listener) {
- this.context.addListener(listener);
- }
-
- @Override
- public void removeListener(final IFacetManagerListener listener) {
- this.context.removeListener(listener);
- }
-
-
-
-
-
- /**
- * @see org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager#getETypedElements(org.eclipse.emf.ecore.EObject, java.lang.Class)
- *
- * @param eObject
- * @param classs
- * @return
- * @throws FacetManagerException
- */
- @Override
- public <T extends ETypedElement> List<T> getETypedElements(EObject eObject, Class<T> classs) throws FacetManagerException {
- final List<T> result = new ArrayList<T>();
- for (FacetSet facetSet : getManagedFacetSets()) {
- result.addAll(getETypedElements(eObject, facetSet, classs));
- }
- return result;
- }
-
- private <T extends ETypedElement> List<T> getETypedElements(final EObject eObject, final FacetSet facetSet, final Class<T> classs)
- throws FacetManagerException {
- final List<T> result = new ArrayList<T>();
- for (EClassifier eClassifier : facetSet.getEClassifiers()) {
- if (eClassifier instanceof Facet) {
- final Facet facet = (Facet) eClassifier;
-
- // Before checking conformance, verify that the facet contains at least one element in the returned list.
- // Do no compute conformance if the list will be empty anyway
- if (EStructuralFeature.class.isAssignableFrom(classs)) {
- if (!facet.getAllFacetElements().isEmpty()) {
- if (isConforming(eObject, facet)) {
- result.addAll(getETypedElement(classs, facet));
- }
- }
- } else if (EOperation.class.isAssignableFrom(classs)) {
- if (!facet.getAllFacetOperations().isEmpty()) {
- if (isConforming(eObject, facet)) {
- result.addAll(getETypedElement(classs, facet));
- }
- }
- } else {
- if (isConforming(eObject, facet)) {
- result.addAll(getETypedElement(classs, facet));
- }
- }
-
- }
- }
- // hierarchical FacetSets
- for (EPackage ePackage : facetSet.getESubpackages()) {
- if (ePackage instanceof FacetSet) {
- final FacetSet subFacetSet = (FacetSet) ePackage;
- result.addAll(getETypedElements(eObject, subFacetSet, classs));
- }
- }
- // aggregates
- for (FacetSet subFacetSet : facetSet.getFacetSets()) {
- result.addAll(getETypedElements(eObject, subFacetSet, classs));
- }
- return result;
- }
-
- private <T extends ETypedElement> List<T> getETypedElement(final Class<T> classs, final Facet facet) {
- if (!typedElements.containsKey(facet)) {
- typedElements.put(facet, new HashMap<>());
- }
-
- Map<Class<?>, List<? extends ETypedElement>> cache = typedElements.get(facet);
- if (!cache.containsKey(classs)) {
- final List<ETypedElement> result = new ArrayList<ETypedElement>();
- for (ETypedElement eTypedElement : facet.getAllTypedElements()) {
- if (classs.isInstance(eTypedElement)) {
- @SuppressWarnings("unchecked")
- // @SuppressWarnings("unchecked") This type has been
- // checked using isInstance
- final T typedSF = (T) eTypedElement;
- final T resolvedTE = IResolverManager.DEFAULT
- .resolve(typedSF, classs);
- if (resolvedTE == null) {
- result.add(typedSF);
- } else {
- result.add(resolvedTE);
- }
- }
- }
-
- cache.put(classs, result);
- }
-
- return (List<T>) cache.get(classs);
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2011, 2012 Mia-Software + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values. + * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel + * Grégoire Dupé (Mia-Software) - Bug 361612 - [Restructuring] New core for new version of the Facet metamodel* + * Olivier Remaud (Soft-Maint) - Bug 361794 - [Restructuring] EMF Facet customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet. + * Olivier Remaud (Mia-Software) - Bug 374348 - Infinite loop in Facet override resolution + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Gregoire Dupe (Mia-Software) - Bug 376576 - [EFacet] Change the multiplicity of Facet::extendedFacet + * Nicolas Bros (Mia-Software) - Bug 378475 - unit test failures after table refactoring + * Thomas Cicognani (Soft-Maint) - Bug 416221 - New methods to get references in FacetManager API + * Thomas Cicognani (Soft-Maint) - Bug 420193 - Listener on FacetManager + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.emf.facet.efacet.core.FacetUtils; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManagerListener; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.FacetManagerException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.FacetConformanceEvaluationException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.NonApplicableFacetException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.NonConformingEObjectException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.UnmatchingExpectedTypeException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exported.IResolverManager; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.serialization.SerializationManager; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementEObjectListResult; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementEObjectResult; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementPrimitiveTypeListResult; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementPrimitiveTypeResult; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.RuntimeFactory; +import org.eclipse.papyrus.emf.facet.util.core.Logger; + +public class FacetManager implements IFacetManager, Adapter { + + private static final EClassifier EBOOLEAN = EcorePackage.eINSTANCE.getEBoolean(); + private static final EClassifier EBOOLEAN_OBJECT = EcorePackage.eINSTANCE.getEBooleanObject(); + private final FacetManagerContext context; + private final SerializationManager serializationMgr; + private final ResourceSet resourceSet; + private final Map<Facet, EClass> extendedMetaclass = new HashMap<>(); + private final Map<Facet, Map<Class<?>, List<? extends ETypedElement>>> typedElements = new HashMap<>(); + + public FacetManager(final Resource resource) { + this.serializationMgr = new SerializationManager(resource); + this.context = new FacetManagerContext(this); + this.resourceSet = resource.getResourceSet(); + } + + public FacetManager(final ResourceSet resourceSet) { + this.serializationMgr = new SerializationManager(null); + this.context = new FacetManagerContext(this); + this.resourceSet = resourceSet; + } + + @Override + public void saveStructuralFeatureInstanceModel() + throws FacetManagerException { + this.serializationMgr.saveStructuralFeatureInstanceModel(); + } + + /** + * Returns whether the given model element conforms to the given Facet + * + * @param eObject + * the model element + * @param facet + * the Facet the applicability of which is being tested + * @return whether the given model element should be seen as an instance of the given Facet + */ + @Override + public boolean isConforming(final EObject eObject, final Facet facet) + throws FacetManagerException { + return getConformanceState(eObject, facet) == FacetManager.ConformanceState.Conformant; + } + + public enum ConformanceState { + Conformant, NonConformingMetaclass, NonConformingElement + } + + private void checkConformance(final EObject eObject, final Facet facet) + throws FacetManagerException { + final ConformanceState conformanceState = getConformanceState(eObject, facet); + if (conformanceState == FacetManager.ConformanceState.NonConformingMetaclass) { + throw new FacetManagerException("NonApplicableFacetException"); //$NON-NLS-1$ + } + if (conformanceState == FacetManager.ConformanceState.NonConformingElement) { + throw new FacetManagerException("NonConformingEObjectException"); //$NON-NLS-1$ + } + } + + protected ConformanceState getConformanceState(final EObject eObject, + final Facet facet) throws FacetManagerException { + // Begin of precondition section + if (eObject == null) { + throw new IllegalArgumentException("eObject cannot be null"); //$NON-NLS-1$ + } + if (facet == null) { + throw new IllegalArgumentException("facet cannot be null"); //$NON-NLS-1$ + } + // End of precondition section + + ConformanceState result; + final EClass extendedMetaclass = getExtendedMetaclass(facet); + if (extendedMetaclass != null + && (extendedMetaclass.isSuperTypeOf(eObject.eClass()) || extendedMetaclass == EcorePackage.eINSTANCE.getEObject())) { + final ETypedElement typeElement = facet.getConformanceTypedElement(); + if (typeElement == null) { + result = FacetManager.ConformanceState.Conformant; + } else { + final Boolean isConforming = getConformanceValue(eObject, typeElement); + if (isConforming.booleanValue()) { + result = FacetManager.ConformanceState.Conformant; + } else { + result = FacetManager.ConformanceState.NonConformingElement; + } + } + } else { + result = FacetManager.ConformanceState.NonConformingMetaclass; + } + // The conformance constraint is inherited from the super facet. + if (result == FacetManager.ConformanceState.Conformant) { + for (Facet extFacet : facet.getExtendedFacets()) { + result = getConformanceState(eObject, extFacet); + if (result != FacetManager.ConformanceState.Conformant) { + break; + } + } + } + return result; + } + + private final EClass getExtendedMetaclass(Facet facet) { + if (!extendedMetaclass.containsKey(facet)) { + extendedMetaclass.put(facet, FacetUtils.getExtendedMetaclass(facet)); + } + return extendedMetaclass.get(facet); + } + + private Boolean getConformanceValue(final EObject eObject, + final ETypedElement typeElement) throws FacetManagerException { + // Begin precondition checking + if (typeElement.isMany()) { + throw new FacetManagerException("The Facet's conformance typed element must not be multi-valued"); //$NON-NLS-1$ + } + if (typeElement.getEType() != FacetManager.EBOOLEAN && typeElement.getEType() != FacetManager.EBOOLEAN_OBJECT) { + throw new FacetManagerException("The Facet conformance typed element evaluated to a wrong type."); //$NON-NLS-1$ + } + // End precondition checking + Boolean result; // conformance typedElement Value + try { + if (typeElement instanceof EStructuralFeature) { + final EStructuralFeature structuralFeature = (EStructuralFeature) typeElement; + // basicGet = true in order to avoid an infinite recursion + result = internalGet(eObject, structuralFeature, Boolean.class, true); + } else if (typeElement instanceof EOperation) { + final EOperation operation = (EOperation) typeElement; + if (operation.getEParameters().size() > 0) { + throw new FacetConformanceEvaluationException("The Facet's conformance operation cannot have parameters"); //$NON-NLS-1$ + } + // basicInvoke = true in order to avoid an infinite recursion, + // ie don't check conformance and don't resolve overrides + result = internalInvoke(eObject, operation, Boolean.class, true); + } else { + throw new FacetConformanceEvaluationException("Unsupported conformance typed element type: " + typeElement.getClass().getName()); //$NON-NLS-1$ + } + } catch (Exception e) { + throw new FacetManagerException(e); + } + if (result == null) { + throw new FacetManagerException("The Facet conformance typed element evaluated to null"); //$NON-NLS-1$ + } + return result; + } + + @Override + public void set(final EObject eObject, + final EStructuralFeature structuralFeature, final Object newValue, + final EditingDomain editingDomain) throws FacetManagerException { + if (structuralFeature.isMany() && !(newValue instanceof Collection<?>)) { + throw new IllegalArgumentException("newValue should be a Collection because eStructuralFeature is an EReference"); //$NON-NLS-1$ + // TODO: check the type of the elements of the list. + } + final EObject eContainer = structuralFeature.eContainer(); + if (eContainer instanceof Facet) { + final Facet facet = (Facet) eContainer; + checkConformance(eObject, facet); + if (structuralFeature instanceof EAttribute) { + final EAttribute eAttribute = (EAttribute) structuralFeature; + if (structuralFeature instanceof FacetAttribute) { + // TODO We still have to implement the setting of a derived facet attribute. Cf. + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=365726 + throw new UnsupportedOperationException("Setting a FacetAttribute is not yet implemented"); //$NON-NLS-1$ + } // else { // instanceof EAttribute + this.serializationMgr.setAttribute(eObject, eAttribute, newValue); + // } + } else if (structuralFeature instanceof EReference) { + final EReference reference = (EReference) structuralFeature; + if (reference instanceof FacetReference) { + // TODO We still have to implement the setting of a derived facet attribute. Cf. + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=365726 + throw new UnsupportedOperationException("Setting a FacetReference is not yet implemented"); //$NON-NLS-1$ + } // else { // instanceof EReference + this.serializationMgr.setReference(eObject, reference, newValue); + // } + } else { + throw new UnsupportedOperationException( + "Setting a structural feature of type '" + structuralFeature.getClass().getName() + "' is not implemented"); //$NON-NLS-1$ //$NON-NLS-2$ + } + } else { + eObject.eSet(structuralFeature, newValue); + } + } + + public <T> T get(final EObject eObject, + final EStructuralFeature structuralFeature, + final Class<T> expectedType) throws FacetManagerException { + return internalGet(eObject, structuralFeature, expectedType, false); + } + + private <T> T internalGet(final EObject eObject, + final EStructuralFeature structuralFeature, + final Class<T> expectedType, final boolean basicGet) + throws FacetManagerException { + try { + Object value; + if (structuralFeature.eContainer() instanceof Facet) { + + EStructuralFeature baseFeature = structuralFeature; + + if (!basicGet) { + baseFeature = this.context.resolveOverrides(structuralFeature, eObject); + final Facet facet = (Facet) baseFeature.eContainer(); + checkConformance(eObject, facet); + } + if (baseFeature.isDerived()) { + if (!(baseFeature instanceof DerivedTypedElement)) { + throw new UnsupportedOperationException("Cannot evaluate a derived structural feature that is not a DerivedTypedElement : not implemented"); //$NON-NLS-1$ + } + value = IDerivedTypedElementManager.INSTANCE.evaluate((DerivedTypedElement) baseFeature, eObject, null, this); + } else { + if (baseFeature instanceof DerivedTypedElement) { + throw new IllegalArgumentException("A DerivedTypedElement must always be derived"); //$NON-NLS-1$ + } + value = this.serializationMgr.getNotDerivedValue(eObject, baseFeature); + } + } else { // Regular structural feature + if (structuralFeature instanceof DerivedTypedElement) { + throw new IllegalStateException("The given DerivedTypedElement is not contained in a Facet"); //$NON-NLS-1$ + } + value = eObject.eGet(structuralFeature, true); + } + return EmfUtils.checkAssignment(structuralFeature, expectedType, value); + } catch (Exception e) { + throw new FacetManagerException(e); + } + } + + public <T> List<T> getMultiValued(final EObject eObject, + final EStructuralFeature structuralFeature, + final Class<T> expectedType) throws FacetManagerException { + final Object result = internalGet(eObject, structuralFeature, null, false); + // return the original list, which must be modifiable by the caller + try { + return CastUtils.castToExpectedListType(result, expectedType, true); + } catch (UnmatchingExpectedTypeException e) { + throw new UnmatchingExpectedTypeException("Failed to cast the value of '" + structuralFeature.getName() + "' to a list of " + expectedType.getName(), e); //$NON-NLS-1$//$NON-NLS-2$ + } + } + + @Override + public <T> T invoke(final EObject eObject, final EOperation operation, + final Class<T> expectedType, final EditingDomain editingDomain, final Object... arguments) + throws FacetManagerException { + try { + return internalInvoke(eObject, operation, expectedType, false, arguments); + } catch (Exception e) { + throw new FacetManagerException("Error invoking Facet operation '" + operation.getName() + "'", e); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + + public <T> List<T> invokeMultiValued(final EObject eObject, final EOperation operation, + final Class<T> expectedType, final Object... arguments) + throws FacetManagerException { + Object result; + try { + result = internalInvoke(eObject, operation, null, false, arguments); + } catch (Exception e) { + throw new FacetManagerException("Error invoking Facet operation '" + operation.getName() + "'", e); //$NON-NLS-1$ //$NON-NLS-2$ + } + return CastUtils.castToExpectedListType(result, expectedType, true); + } + + private <T> T internalInvoke(final EObject eObject, final EOperation operation, final Class<T> expectedType, + final boolean basicInvoke, final Object... arguments) + throws DerivedTypedElementException, InvocationTargetException, + FacetConformanceEvaluationException, NonApplicableFacetException, + NonConformingEObjectException, FacetManagerException { + Object result; + if (operation.eContainer() instanceof Facet) { + final Facet facet = (Facet) operation.eContainer(); + + if (!basicInvoke) { + checkConformance(eObject, facet); + } + if (operation instanceof FacetOperation) { + final FacetOperation facetOperation = (FacetOperation) operation; + FacetOperation baseOperation = facetOperation; + if (!basicInvoke) { + baseOperation = this.context.resolveOverrides(facetOperation, eObject); + } + result = DerivedTypedElementUtils.evaluate(eObject, baseOperation, this, arguments); + } else { + result = EmfUtils.ecoreInvoke(eObject, operation, null, arguments); + } + } else { // Regular eOperation + if (operation instanceof FacetOperation) { + throw new IllegalStateException("The given FacetOperation is not contained in a Facet"); //$NON-NLS-1$ + } + result = EmfUtils.ecoreInvoke(eObject, operation, null, arguments); + } + return CastUtils.castToExpectedType(result, expectedType); + } + + public List<ETypedElementResult> get(final Collection<EObject> eObjects, final EStructuralFeature structuralFeature) + throws DerivedTypedElementException { + + throw new UnsupportedOperationException("not implemented yet"); //$NON-NLS-1$ + } + + @Override + public List<ETypedElementResult> batchInvoke( + final Collection<EObject> eObjects, final EOperation operation, + final Object... arguments) throws FacetManagerException { + + throw new UnsupportedOperationException("not implemented yet"); //$NON-NLS-1$ + } + + @Override + public List<FacetSet> getManagedFacetSets() { + return this.context; + } + + public void setManagedFacetSets(final List<FacetSet> facetSets) { + extendedMetaclass.clear(); + typedElements.clear(); + this.context.setManagedFacetSets(facetSets); + } + + public void removeFacetSet(final FacetSet facetSet) { + extendedMetaclass.clear(); + typedElements.clear(); + this.context.removeFacetSet(facetSet); + } + + @Override + public ResourceSet getResourceSet() { + return this.resourceSet; + } + + public List<ETypedElement> getAppliedFeatures() { + + throw new UnsupportedOperationException("not implemented yet"); //$NON-NLS-1$ + } + + @Override + public Set<EAttribute> getAttributes(final EObject eObject) + throws FacetManagerException { + return new HashSet<>(getETypedElements(eObject, EAttribute.class)); + } + + @Override + public Set<EStructuralFeature> getStructuralFeature(final EObject eObject) + throws FacetManagerException { + return new HashSet<>(getETypedElements(eObject, EStructuralFeature.class)); + } + + @Override + public Set<EReference> getReferences(final EObject eObject) + throws FacetManagerException { + return new HashSet<>(getETypedElements(eObject, EReference.class)); + } + + @Deprecated + public void addFacets(final EList<Facet> facets) { + for (Facet facetToLoad : facets) { + this.context.addFrontManagedFacetSet((FacetSet) facetToLoad + .getEPackage()); + } + extendedMetaclass.clear(); + typedElements.clear(); + } + + @Deprecated + public void unLoadAllFacets() { + removeAllManagedFacetSets(); + } + + public void removeAllManagedFacetSets() { + this.context.clear(); + extendedMetaclass.clear(); + typedElements.clear(); + } + + @Override + public <T> List<T> getOrInvokeMultiValued(final EObject eObject, + final ETypedElement eTypedElement, final Class<T> classs) + throws FacetManagerException { + List<T> result = null; + if (eTypedElement instanceof EStructuralFeature) { + final EStructuralFeature structuralFeature = (EStructuralFeature) eTypedElement; + result = getMultiValued(eObject, structuralFeature, classs); + } else if (eTypedElement instanceof EOperation) { + final EOperation eOperation = (EOperation) eTypedElement; + result = invokeMultiValued(eObject, eOperation, classs); + } + return result; + } + + @Override + public <T> T getOrInvoke(final EObject eObject, + final ETypedElement eTypedElement, final Class<T> classs) + throws FacetManagerException { + T result = null; + if (eTypedElement instanceof EStructuralFeature) { + final EStructuralFeature structuralFeature = (EStructuralFeature) eTypedElement; + result = get(eObject, structuralFeature, classs); + } else if (eTypedElement instanceof EOperation) { + final EOperation eOperation = (EOperation) eTypedElement; + result = invoke(eObject, eOperation, classs, null); + } + return result; + } + + public List<Facet> getManagedFacets() { + throw new IllegalStateException("Not implemented, and never will since it's deprecated"); //$NON-NLS-1$ + } + + @Override + public <T> List<ETypedElementResult> batchGetOrInvoke(final Collection<EObject> sources, final ETypedElement query, final Class<T> classs) + throws FacetManagerException { + final List<ETypedElementResult> results = new LinkedList<ETypedElementResult>(); + for (EObject source : sources) { + ETypedElementResult result = null; + Exception exception = null; + if (query.getEType() instanceof EClass) { + if (query.getUpperBound() == 1) { + final ETypedElementEObjectResult<EObject> eObjectResult = RuntimeFactory.eINSTANCE.createETypedElementEObjectResult(); + try { + eObjectResult.setResult(this.getOrInvoke(source, query, EObject.class)); + } catch (Exception e) { + exception = e; + } + result = eObjectResult; + } else { + final ETypedElementEObjectListResult<EObject> eObjectResultList = RuntimeFactory.eINSTANCE.createETypedElementEObjectListResult(); + try { + eObjectResultList.getResultList().addAll(this.getOrInvokeMultiValued(source, query, EObject.class)); + } catch (Exception e) { + exception = e; + } + result = eObjectResultList; + } + } else { + if (query.getUpperBound() == 1) { + final ETypedElementPrimitiveTypeResult<Object> eObjectResult = RuntimeFactory.eINSTANCE.createETypedElementPrimitiveTypeResult(); + try { + eObjectResult.setResult(this.getOrInvoke(source, query, Collection.class)); + } catch (Exception e) { + exception = e; + } + result = eObjectResult; + } else { + final ETypedElementPrimitiveTypeListResult<Object> eObjectResultList = RuntimeFactory.eINSTANCE.createETypedElementPrimitiveTypeListResult(); + eObjectResultList.getResultList().addAll(this.getOrInvokeMultiValued(source, query, Object.class)); + result = eObjectResultList; + } + } + if (exception != null) { + result.setException(exception); + Logger.logWarning(exception, Activator.getDefault()); + } + result.setDerivedTypedElement(query); + result.setSource(source); + results.add(result); + } + return results; + } + + public void addBackManagedFacetSet(final FacetSet facetSet) { + this.context.addBackManagedFacetSet(facetSet); + extendedMetaclass.clear(); + typedElements.clear(); + } + + public void addFrontManagedFacetSet(final FacetSet facetSet) { + this.context.addFrontManagedFacetSet(facetSet); + extendedMetaclass.clear(); + typedElements.clear(); + } + + @Override + public void notifyChanged(final Notification notification) { + // Nothing to do + } + + @Override + public Notifier getTarget() { + return null; + } + + @Override + public void setTarget(final Notifier newTarget) { + // Nothing to do + } + + @Override + public boolean isAdapterForType(final Object type) { + return false; + } + + @Override + public void addListener(final IFacetManagerListener listener) { + this.context.addListener(listener); + } + + @Override + public void removeListener(final IFacetManagerListener listener) { + this.context.removeListener(listener); + } + + + + + + /** + * @see org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager#getETypedElements(org.eclipse.emf.ecore.EObject, java.lang.Class) + * + * @param eObject + * @param classs + * @return + * @throws FacetManagerException + */ + @Override + public <T extends ETypedElement> List<T> getETypedElements(EObject eObject, Class<T> classs) throws FacetManagerException { + final List<T> result = new ArrayList<T>(); + for (FacetSet facetSet : getManagedFacetSets()) { + result.addAll(getETypedElements(eObject, facetSet, classs)); + } + return result; + } + + private <T extends ETypedElement> List<T> getETypedElements(final EObject eObject, final FacetSet facetSet, final Class<T> classs) + throws FacetManagerException { + final List<T> result = new ArrayList<T>(); + for (EClassifier eClassifier : facetSet.getEClassifiers()) { + if (eClassifier instanceof Facet) { + final Facet facet = (Facet) eClassifier; + + // Before checking conformance, verify that the facet contains at least one element in the returned list. + // Do no compute conformance if the list will be empty anyway + if (EStructuralFeature.class.isAssignableFrom(classs)) { + if (!facet.getAllFacetElements().isEmpty()) { + if (isConforming(eObject, facet)) { + result.addAll(getETypedElement(classs, facet)); + } + } + } else if (EOperation.class.isAssignableFrom(classs)) { + if (!facet.getAllFacetOperations().isEmpty()) { + if (isConforming(eObject, facet)) { + result.addAll(getETypedElement(classs, facet)); + } + } + } else { + if (isConforming(eObject, facet)) { + result.addAll(getETypedElement(classs, facet)); + } + } + + } + } + // hierarchical FacetSets + for (EPackage ePackage : facetSet.getESubpackages()) { + if (ePackage instanceof FacetSet) { + final FacetSet subFacetSet = (FacetSet) ePackage; + result.addAll(getETypedElements(eObject, subFacetSet, classs)); + } + } + // aggregates + for (FacetSet subFacetSet : facetSet.getFacetSets()) { + result.addAll(getETypedElements(eObject, subFacetSet, classs)); + } + return result; + } + + private <T extends ETypedElement> List<T> getETypedElement(final Class<T> classs, final Facet facet) { + if (!typedElements.containsKey(facet)) { + typedElements.put(facet, new HashMap<>()); + } + + Map<Class<?>, List<? extends ETypedElement>> cache = typedElements.get(facet); + if (!cache.containsKey(classs)) { + final List<ETypedElement> result = new ArrayList<ETypedElement>(); + for (ETypedElement eTypedElement : facet.getAllTypedElements()) { + if (classs.isInstance(eTypedElement)) { + @SuppressWarnings("unchecked") + // @SuppressWarnings("unchecked") This type has been + // checked using isInstance + final T typedSF = (T) eTypedElement; + final T resolvedTE = IResolverManager.DEFAULT + .resolve(typedSF, classs); + if (resolvedTE == null) { + result.add(typedSF); + } else { + result.add(resolvedTE); + } + } + } + + cache.put(classs, result); + } + + return (List<T>) cache.get(classs); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetManagerFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetManagerFactory.java index 0d44d620e9f..8f3a2c9fe6d 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetManagerFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/FacetManagerFactory.java @@ -1,54 +1,54 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
- * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
- * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Thomas Cicognani (Soft-Maint) - Bug 416223 - IFacetManagerFactory.getOrCreateFacetManager should not create an instance per call
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManagerFactory;
-
-public class FacetManagerFactory implements IFacetManagerFactory {
-
- public IFacetManager getOrCreateFacetManager(final Resource resource) {
- FacetManager result = null;
- for (Adapter adapter : resource.eAdapters()) {
- if (adapter instanceof FacetManager) {
- result = (FacetManager) adapter;
- }
- }
- if (result == null) {
- result = new FacetManager(resource);
- resource.eAdapters().add(result);
- }
- return result;
- }
-
- public IFacetManager getOrCreateFacetManager(final ResourceSet resourceSet) {
- FacetManager result = null;
- for (Adapter adapter : resourceSet.eAdapters()) {
- if (adapter instanceof FacetManager) {
- result = (FacetManager) adapter;
- }
- }
- if (result == null) {
- result = new FacetManager(resourceSet);
- resourceSet.eAdapters().add(result);
- }
- return result;
- }
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values. + * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel + * Gregoire Dupe (Mia-Software) - Bug 361794 - [Restructuring] New customization meta-model + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Thomas Cicognani (Soft-Maint) - Bug 416223 - IFacetManagerFactory.getOrCreateFacetManager should not create an instance per call + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManagerFactory; + +public class FacetManagerFactory implements IFacetManagerFactory { + + public IFacetManager getOrCreateFacetManager(final Resource resource) { + FacetManager result = null; + for (Adapter adapter : resource.eAdapters()) { + if (adapter instanceof FacetManager) { + result = (FacetManager) adapter; + } + } + if (result == null) { + result = new FacetManager(resource); + resource.eAdapters().add(result); + } + return result; + } + + public IFacetManager getOrCreateFacetManager(final ResourceSet resourceSet) { + FacetManager result = null; + for (Adapter adapter : resourceSet.eAdapters()) { + if (adapter instanceof FacetManager) { + result = (FacetManager) adapter; + } + } + if (result == null) { + result = new FacetManager(resourceSet); + resourceSet.eAdapters().add(result); + } + return result; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/Messages.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/Messages.java index cb3066cfa6d..18bc555b28e 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/Messages.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/Messages.java @@ -1,28 +1,28 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal;
-
-import org.eclipse.osgi.util.NLS;
-
-@SuppressWarnings("PMD")
-public final class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.papyrus.emf.facet.efacet.core.internal.messages"; //$NON-NLS-1$
- public static String EFacetCatalogManager_FacetSetCatalogName;
- public static String EFacetCatalogManager_QuerySetCatalogName;
- static {
- // initialize resource bundle
- NLS.initializeMessages(Messages.BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal; + +import org.eclipse.osgi.util.NLS; + +@SuppressWarnings("PMD") +public final class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.papyrus.emf.facet.efacet.core.internal.messages"; //$NON-NLS-1$ + public static String EFacetCatalogManager_FacetSetCatalogName; + public static String EFacetCatalogManager_QuerySetCatalogName; + static { + // initialize resource bundle + NLS.initializeMessages(Messages.BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/ResolverManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/ResolverManager.java index 092e48efa7a..63877739c99 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/ResolverManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/ResolverManager.java @@ -1,113 +1,113 @@ -/**
- * Copyright (c) 2012 CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
- * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exported.IResolver;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exported.IResolverManager;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-
-public class ResolverManager implements IResolverManager {
-
- private static final String ATT_NAME = "class"; //$NON-NLS-1$
- private static final String EXT_POINT_ID = "org.eclipse.papyrus.emf.facet.efacet.core.internal.resolver"; //$NON-NLS-1$
- private final List<IResolver> resolvers = new ArrayList<IResolver>();
-
- public ResolverManager() {
- final IConfigurationElement[] configs = Platform.getExtensionRegistry()
- .getConfigurationElementsFor(ResolverManager.EXT_POINT_ID);
- for (IConfigurationElement config : configs) {
- try {
- final Object object = config
- .createExecutableExtension(ResolverManager.ATT_NAME);
- if (object instanceof IResolver) {
- final IResolver resolver = (IResolver) object;
- this.resolvers.add(resolver);
- }
- } catch (CoreException e) {
- Logger.logError(e, Activator.getDefault());
- }
-
- }
- }
-
- public <T> T resolve(final Object object, final Class<T> aClass) {
- T result = null;
- for (IResolver resolver : this.resolvers) {
- if (resolver.canHandle(object)) {
- try {
- result = resolver.resolve(object, aClass);
- } catch (ClassCastException e) {
- Logger.logWarning(e, Activator.getDefault());
- // Nothing to: we will try with an other resolver or return
- // null
- }
- if (result != null) {
- break;
- }
- }
- }
- return result;
- }
-
- public <T> List<T> selectionPropagation(final Object selectedObject,
- final Class<T> aClass) {
- @SuppressWarnings("unchecked")
- // @SuppressWarnings("unchecked") The untyped list is an definitely
- // empty list.
- List<T> result = Collections.EMPTY_LIST;
- for (IResolver resolver : this.resolvers) {
- if (resolver.canHandle(selectedObject)) {
- try {
- result = resolver.selectionPropagation(selectedObject,
- aClass);
- } catch (ClassCastException e) {
- Logger.logWarning(e, Activator.getDefault());
- // Nothing to: we will try with an other resolver or return
- // null
- }
- if (result != null) {
- break;
- }
- }
- }
- return result;
- }
-
- public <T> T selectionRoot(final Object selectedObject,
- final Class<T> aClass) {
- T result = null;
- for (IResolver resolver : this.resolvers) {
- if (resolver.canHandle(selectedObject)) {
- try {
- result = resolver.selectionRoot(selectedObject,
- aClass);
- } catch (ClassCastException e) {
- Logger.logWarning(e, Activator.getDefault());
- // Nothing to: we will try with an other resolver or return
- // null
- }
- if (result != null) {
- break;
- }
- }
- }
- return result;
- }
-
-}
+/** + * Copyright (c) 2012 CEA LIST. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>) + * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.Platform; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exported.IResolver; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exported.IResolverManager; +import org.eclipse.papyrus.emf.facet.util.core.Logger; + +public class ResolverManager implements IResolverManager { + + private static final String ATT_NAME = "class"; //$NON-NLS-1$ + private static final String EXT_POINT_ID = "org.eclipse.papyrus.emf.facet.efacet.core.internal.resolver"; //$NON-NLS-1$ + private final List<IResolver> resolvers = new ArrayList<IResolver>(); + + public ResolverManager() { + final IConfigurationElement[] configs = Platform.getExtensionRegistry() + .getConfigurationElementsFor(ResolverManager.EXT_POINT_ID); + for (IConfigurationElement config : configs) { + try { + final Object object = config + .createExecutableExtension(ResolverManager.ATT_NAME); + if (object instanceof IResolver) { + final IResolver resolver = (IResolver) object; + this.resolvers.add(resolver); + } + } catch (CoreException e) { + Logger.logError(e, Activator.getDefault()); + } + + } + } + + public <T> T resolve(final Object object, final Class<T> aClass) { + T result = null; + for (IResolver resolver : this.resolvers) { + if (resolver.canHandle(object)) { + try { + result = resolver.resolve(object, aClass); + } catch (ClassCastException e) { + Logger.logWarning(e, Activator.getDefault()); + // Nothing to: we will try with an other resolver or return + // null + } + if (result != null) { + break; + } + } + } + return result; + } + + public <T> List<T> selectionPropagation(final Object selectedObject, + final Class<T> aClass) { + @SuppressWarnings("unchecked") + // @SuppressWarnings("unchecked") The untyped list is an definitely + // empty list. + List<T> result = Collections.EMPTY_LIST; + for (IResolver resolver : this.resolvers) { + if (resolver.canHandle(selectedObject)) { + try { + result = resolver.selectionPropagation(selectedObject, + aClass); + } catch (ClassCastException e) { + Logger.logWarning(e, Activator.getDefault()); + // Nothing to: we will try with an other resolver or return + // null + } + if (result != null) { + break; + } + } + } + return result; + } + + public <T> T selectionRoot(final Object selectedObject, + final Class<T> aClass) { + T result = null; + for (IResolver resolver : this.resolvers) { + if (resolver.canHandle(selectedObject)) { + try { + result = resolver.selectionRoot(selectedObject, + aClass); + } catch (ClassCastException e) { + Logger.logWarning(e, Activator.getDefault()); + // Nothing to: we will try with an other resolver or return + // null + } + if (result != null) { + break; + } + } + } + return result; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/catalog/EFacetCatalogManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/catalog/EFacetCatalogManager.java index 05a8fb6ba3d..ef022fb92fb 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/catalog/EFacetCatalogManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/catalog/EFacetCatalogManager.java @@ -1,58 +1,58 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
- * Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
- * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.catalog;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.QuerySet;
-import org.eclipse.papyrus.emf.facet.efacet.catalog.efacetcatalog.EfacetcatalogFactory;
-import org.eclipse.papyrus.emf.facet.efacet.catalog.efacetcatalog.FacetSetCatalog;
-import org.eclipse.papyrus.emf.facet.efacet.catalog.efacetcatalog.QuerySetCatalog;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.Messages;
-import org.eclipse.papyrus.emf.facet.util.emf.catalog.CatalogSet;
-import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogManager;
-
-/** @deprecated replaced by {@link EFacetCatalogManager2} for the new eFacet2 metamodel */
-@Deprecated
-public class EFacetCatalogManager implements ICatalogManager {
-
- private final FacetSetCatalog facetSetCatalog;
- private final QuerySetCatalog querySetCatalog;
-
- public EFacetCatalogManager() {
- this.facetSetCatalog = EfacetcatalogFactory.eINSTANCE.createFacetSetCatalog();
- this.facetSetCatalog.setName(Messages.EFacetCatalogManager_FacetSetCatalogName);
- this.querySetCatalog = EfacetcatalogFactory.eINSTANCE.createQuerySetCatalog();
- this.querySetCatalog.setName(Messages.EFacetCatalogManager_QuerySetCatalogName);
- }
-
- public boolean canBeManaged(final EObject root) {
- return root instanceof QuerySet || root instanceof FacetSet;
- }
-
- public void manage(final EObject root) {
- if (root instanceof FacetSet) {
- FacetSet facetSet = (FacetSet) root;
- this.facetSetCatalog.getInstalledEntries().add(facetSet);
- } else if (root instanceof QuerySet) {
- QuerySet querySet = (QuerySet) root;
- this.querySetCatalog.getInstalledEntries().add(querySet);
- }
- }
-
- public void setCatalogSet(final CatalogSet catalogSet) {
- catalogSet.getCatalogs().add(this.facetSetCatalog);
- catalogSet.getCatalogs().add(this.querySetCatalog);
- }
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet + * Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet + * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.catalog; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.QuerySet; +import org.eclipse.papyrus.emf.facet.efacet.catalog.efacetcatalog.EfacetcatalogFactory; +import org.eclipse.papyrus.emf.facet.efacet.catalog.efacetcatalog.FacetSetCatalog; +import org.eclipse.papyrus.emf.facet.efacet.catalog.efacetcatalog.QuerySetCatalog; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.Messages; +import org.eclipse.papyrus.emf.facet.util.emf.catalog.CatalogSet; +import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogManager; + +/** @deprecated replaced by {@link EFacetCatalogManager2} for the new eFacet2 metamodel */ +@Deprecated +public class EFacetCatalogManager implements ICatalogManager { + + private final FacetSetCatalog facetSetCatalog; + private final QuerySetCatalog querySetCatalog; + + public EFacetCatalogManager() { + this.facetSetCatalog = EfacetcatalogFactory.eINSTANCE.createFacetSetCatalog(); + this.facetSetCatalog.setName(Messages.EFacetCatalogManager_FacetSetCatalogName); + this.querySetCatalog = EfacetcatalogFactory.eINSTANCE.createQuerySetCatalog(); + this.querySetCatalog.setName(Messages.EFacetCatalogManager_QuerySetCatalogName); + } + + public boolean canBeManaged(final EObject root) { + return root instanceof QuerySet || root instanceof FacetSet; + } + + public void manage(final EObject root) { + if (root instanceof FacetSet) { + FacetSet facetSet = (FacetSet) root; + this.facetSetCatalog.getInstalledEntries().add(facetSet); + } else if (root instanceof QuerySet) { + QuerySet querySet = (QuerySet) root; + this.querySetCatalog.getInstalledEntries().add(querySet); + } + } + + public void setCatalogSet(final CatalogSet catalogSet) { + catalogSet.getCatalogs().add(this.facetSetCatalog); + catalogSet.getCatalogs().add(this.querySetCatalog); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/catalog/EFacetCatalogManager2.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/catalog/EFacetCatalogManager2.java index 398c8ae63e1..38550ba2ba1 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/catalog/EFacetCatalogManager2.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/catalog/EFacetCatalogManager2.java @@ -1,72 +1,72 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia-Software
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
- * Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
- * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
- * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
- * Nicolas Bros (Mia-Software) - Bug 361817 - [Restructuring] Dynamic load to the facet catalog
- * Nicolas Bros (Mia-Software) - Bug 370110 - Rename efacetcatalog2.ecore
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.catalog;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.emf.common.util.BasicEList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetSetCatalogManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacetcatalog.EfacetcatalogFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacetcatalog.FacetSetCatalog;
-import org.eclipse.papyrus.emf.facet.util.emf.catalog.CatalogSet;
-import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogManager;
-
-public class EFacetCatalogManager2 implements IFacetSetCatalogManager, ICatalogManager {
-
- private final FacetSetCatalog facetSetCatalog;
-
- public EFacetCatalogManager2() {
- this.facetSetCatalog = EfacetcatalogFactory.eINSTANCE
- .createFacetSetCatalog();
- this.facetSetCatalog.setName(Messages.EFacetCatalogManager_FacetSetCatalogName);
- }
-
- public boolean canBeManaged(final EObject root) {
- return root instanceof FacetSet;
- }
-
- public void manage(final EObject root) {
- if (root instanceof FacetSet) {
- final FacetSet facetSet = (FacetSet) root;
- this.facetSetCatalog.getInstalledEntries().add(facetSet);
- }
- }
-
- public void setCatalogSet(final CatalogSet catalogSet) {
- catalogSet.getCatalogs().add(this.facetSetCatalog);
- }
-
- public List<FacetSet> getRegisteredFacetSets() {
- final BasicEList<FacetSet> result = new BasicEList<FacetSet>();
- for (EObject eObject : this.facetSetCatalog.getInstalledEntries()) {
- if (eObject instanceof FacetSet) {
- final FacetSet facetSet = (FacetSet) eObject;
- result.add(facetSet);
- }
- }
- return Collections.unmodifiableList(result);
- }
-
- public void registerFacetSet(final FacetSet facetSet) {
- this.facetSetCatalog.getInstalledEntries().add(facetSet);
- }
-}
+/******************************************************************************* + * Copyright (c) 2011 Mia-Software + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet + * Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet + * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values. + * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel + * Nicolas Bros (Mia-Software) - Bug 361817 - [Restructuring] Dynamic load to the facet catalog + * Nicolas Bros (Mia-Software) - Bug 370110 - Rename efacetcatalog2.ecore + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.catalog; + +import java.util.Collections; +import java.util.List; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetSetCatalogManager; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacetcatalog.EfacetcatalogFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacetcatalog.FacetSetCatalog; +import org.eclipse.papyrus.emf.facet.util.emf.catalog.CatalogSet; +import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogManager; + +public class EFacetCatalogManager2 implements IFacetSetCatalogManager, ICatalogManager { + + private final FacetSetCatalog facetSetCatalog; + + public EFacetCatalogManager2() { + this.facetSetCatalog = EfacetcatalogFactory.eINSTANCE + .createFacetSetCatalog(); + this.facetSetCatalog.setName(Messages.EFacetCatalogManager_FacetSetCatalogName); + } + + public boolean canBeManaged(final EObject root) { + return root instanceof FacetSet; + } + + public void manage(final EObject root) { + if (root instanceof FacetSet) { + final FacetSet facetSet = (FacetSet) root; + this.facetSetCatalog.getInstalledEntries().add(facetSet); + } + } + + public void setCatalogSet(final CatalogSet catalogSet) { + catalogSet.getCatalogs().add(this.facetSetCatalog); + } + + public List<FacetSet> getRegisteredFacetSets() { + final BasicEList<FacetSet> result = new BasicEList<FacetSet>(); + for (EObject eObject : this.facetSetCatalog.getInstalledEntries()) { + if (eObject instanceof FacetSet) { + final FacetSet facetSet = (FacetSet) eObject; + result.add(facetSet); + } + } + return Collections.unmodifiableList(result); + } + + public void registerFacetSet(final FacetSet facetSet) { + this.facetSetCatalog.getInstalledEntries().add(facetSet); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/DerivedTypedElementEvaluationException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/DerivedTypedElementEvaluationException.java index 1d2eb901f0d..12fb6cfab51 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/DerivedTypedElementEvaluationException.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/DerivedTypedElementEvaluationException.java @@ -1,44 +1,44 @@ -/**
- * Copyright (c) 2009 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - initial API and implementation
- * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.exception;
-
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.util.core.internal.ErrorHandlingUtils;
-
-/**
- * This exception occurs when something goes wrong during the execution of a query.
- *
- * @since 0.2
- */
-public class DerivedTypedElementEvaluationException extends DerivedTypedElementException {
- // This class is a copy of
- // org.eclipse.papyrus.emf.facet.infra.query.core.ModelQueryExecutionException
-
- private static final long serialVersionUID = -8464252257666617685L;
-
- public DerivedTypedElementEvaluationException(final String message) {
- super(message);
- }
-
- public DerivedTypedElementEvaluationException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- public DerivedTypedElementEvaluationException(final Throwable cause) {
- super(cause);
- }
-
- /** Constructor for evaluation exception due to wrong type */
- public DerivedTypedElementEvaluationException(final String message, final Class<?> expectedType, final Object resultElement) {
- super(ErrorHandlingUtils.buildWrongTypeMessage(message, expectedType, resultElement));
- }
-}
+/** + * Copyright (c) 2009 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - initial API and implementation + * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2 + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.exception; + +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.util.core.internal.ErrorHandlingUtils; + +/** + * This exception occurs when something goes wrong during the execution of a query. + * + * @since 0.2 + */ +public class DerivedTypedElementEvaluationException extends DerivedTypedElementException { + // This class is a copy of + // org.eclipse.papyrus.emf.facet.infra.query.core.ModelQueryExecutionException + + private static final long serialVersionUID = -8464252257666617685L; + + public DerivedTypedElementEvaluationException(final String message) { + super(message); + } + + public DerivedTypedElementEvaluationException(final String message, final Throwable cause) { + super(message, cause); + } + + public DerivedTypedElementEvaluationException(final Throwable cause) { + super(cause); + } + + /** Constructor for evaluation exception due to wrong type */ + public DerivedTypedElementEvaluationException(final String message, final Class<?> expectedType, final Object resultElement) { + super(ErrorHandlingUtils.buildWrongTypeMessage(message, expectedType, resultElement)); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/DerivedTypedElementTypeCheckingException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/DerivedTypedElementTypeCheckingException.java index 610caa6cb28..03d411d56be 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/DerivedTypedElementTypeCheckingException.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/DerivedTypedElementTypeCheckingException.java @@ -1,37 +1,37 @@ -/**
- * Copyright (c) 2009 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - initial API and implementation
- * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.exception;
-
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-
-/**
- * This exception occurs when the type of the result of evaluating a derived typed element is not
- * the one that was expected
- *
- * @since 0.2
- */
-public class DerivedTypedElementTypeCheckingException extends DerivedTypedElementException {
-
- private static final long serialVersionUID = -9064274334817642819L;
-
- public DerivedTypedElementTypeCheckingException(final String message) {
- super(message);
- }
-
- public DerivedTypedElementTypeCheckingException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- public DerivedTypedElementTypeCheckingException(final Throwable cause) {
- super(cause);
- }
-}
+/** + * Copyright (c) 2009 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - initial API and implementation + * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2 + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.exception; + +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; + +/** + * This exception occurs when the type of the result of evaluating a derived typed element is not + * the one that was expected + * + * @since 0.2 + */ +public class DerivedTypedElementTypeCheckingException extends DerivedTypedElementException { + + private static final long serialVersionUID = -9064274334817642819L; + + public DerivedTypedElementTypeCheckingException(final String message) { + super(message); + } + + public DerivedTypedElementTypeCheckingException(final String message, final Throwable cause) { + super(message, cause); + } + + public DerivedTypedElementTypeCheckingException(final Throwable cause) { + super(cause); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/FacetConformanceEvaluationException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/FacetConformanceEvaluationException.java index 0fcbcf17b3f..43a6cbb2e4c 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/FacetConformanceEvaluationException.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/FacetConformanceEvaluationException.java @@ -1,32 +1,32 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia-Software
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.exception;
-
-/**
- * Happens when there is an error evaluating a Facet's conformance typed element.
- *
- * @since 0.2
- */
-public class FacetConformanceEvaluationException extends Exception {
- private static final long serialVersionUID = -5306430483154103388L;
-
- public FacetConformanceEvaluationException(final String message) {
- super(message);
- }
-
- public FacetConformanceEvaluationException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- public FacetConformanceEvaluationException(final Throwable cause) {
- super(cause);
- }
-}
+/******************************************************************************* + * Copyright (c) 2011 Mia-Software + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.exception; + +/** + * Happens when there is an error evaluating a Facet's conformance typed element. + * + * @since 0.2 + */ +public class FacetConformanceEvaluationException extends Exception { + private static final long serialVersionUID = -5306430483154103388L; + + public FacetConformanceEvaluationException(final String message) { + super(message); + } + + public FacetConformanceEvaluationException(final String message, final Throwable cause) { + super(message, cause); + } + + public FacetConformanceEvaluationException(final Throwable cause) { + super(cause); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/NonApplicableFacetException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/NonApplicableFacetException.java index 261426a64eb..e5e5cc78994 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/NonApplicableFacetException.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/NonApplicableFacetException.java @@ -1,22 +1,22 @@ -/*******************************************************************************
- * Copyright (c) 2012 Mia-Software
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.exception;
-
-/**
- * This exception is raised when an object cannot be extended by a facet because the class of the object does not correspond
- * to the extended metaclass of the facet.
- *
- * @since 0.2
- */
-public class NonApplicableFacetException extends Exception {
-
- private static final long serialVersionUID = 2984069177830836577L;
-}
+/******************************************************************************* + * Copyright (c) 2012 Mia-Software + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.exception; + +/** + * This exception is raised when an object cannot be extended by a facet because the class of the object does not correspond + * to the extended metaclass of the facet. + * + * @since 0.2 + */ +public class NonApplicableFacetException extends Exception { + + private static final long serialVersionUID = 2984069177830836577L; +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/NonConformingEObjectException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/NonConformingEObjectException.java index 04fd5f86fb0..ef558adf136 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/NonConformingEObjectException.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/NonConformingEObjectException.java @@ -1,22 +1,22 @@ -/*******************************************************************************
- * Copyright (c) 2012 Mia-Software
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.exception;
-
-/**
- * This exception is raised when an object cannot be extended by a facet because it is filtered by the conformance query
- * of this facet.
- *
- * @since 0.2
- */
-public class NonConformingEObjectException extends Exception {
-
- private static final long serialVersionUID = -7778081627619345385L;
-}
+/******************************************************************************* + * Copyright (c) 2012 Mia-Software + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.exception; + +/** + * This exception is raised when an object cannot be extended by a facet because it is filtered by the conformance query + * of this facet. + * + * @since 0.2 + */ +public class NonConformingEObjectException extends Exception { + + private static final long serialVersionUID = -7778081627619345385L; +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/SaveStructuralFeatureInstanceModelException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/SaveStructuralFeatureInstanceModelException.java index 17d7e643c4d..0470c1a1843 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/SaveStructuralFeatureInstanceModelException.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/SaveStructuralFeatureInstanceModelException.java @@ -1,41 +1,41 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.exception;
-
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.FacetManagerException;
-
-/**
- * This exception is raised when an IOException is caught when trying to save a structural feature instance model
- *
- * @since 0.2
- */
-public class SaveStructuralFeatureInstanceModelException extends
- FacetManagerException {
-
- private static final long serialVersionUID = 7024009106572531846L;
-
- /**
- * Creates a new instance of UnmatchingExpectedTypeException
- * with {@link Throwable} the exception at the origin of this exception
- */
- public SaveStructuralFeatureInstanceModelException(final Throwable cause) {
- super(cause);
- }
-
- /**
- * Creates a new instance of UnmatchingExpectedTypeException
- * with {@link Throwable} the exception at the origin of this exception
- */
- public SaveStructuralFeatureInstanceModelException(final String message) {
- super(message);
- }
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values. + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.exception; + +import org.eclipse.papyrus.emf.facet.efacet.core.exception.FacetManagerException; + +/** + * This exception is raised when an IOException is caught when trying to save a structural feature instance model + * + * @since 0.2 + */ +public class SaveStructuralFeatureInstanceModelException extends + FacetManagerException { + + private static final long serialVersionUID = 7024009106572531846L; + + /** + * Creates a new instance of UnmatchingExpectedTypeException + * with {@link Throwable} the exception at the origin of this exception + */ + public SaveStructuralFeatureInstanceModelException(final Throwable cause) { + super(cause); + } + + /** + * Creates a new instance of UnmatchingExpectedTypeException + * with {@link Throwable} the exception at the origin of this exception + */ + public SaveStructuralFeatureInstanceModelException(final String message) { + super(message); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/UnmatchingExpectedTypeException.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/UnmatchingExpectedTypeException.java index c2a003b99cb..52b66ed777a 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/UnmatchingExpectedTypeException.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exception/UnmatchingExpectedTypeException.java @@ -1,45 +1,45 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia-Software
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
- * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.exception;
-
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.FacetManagerException;
-import org.eclipse.papyrus.emf.facet.util.core.internal.ErrorHandlingUtils;
-
-/**
- * This exception is raised when a value's type does not match with the expected type
- *
- * @since 0.2
- */
-public class UnmatchingExpectedTypeException extends FacetManagerException {
-
- private static final long serialVersionUID = 1456802297756942271L;
-
- public UnmatchingExpectedTypeException() {
- super();
- }
-
- public UnmatchingExpectedTypeException(final String message) {
- super(message);
- }
-
- public UnmatchingExpectedTypeException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
- public UnmatchingExpectedTypeException(final Throwable cause) {
- super(cause);
- }
-
- public UnmatchingExpectedTypeException(final String message, final Class<?> expectedType, final Object resultElement) {
- super(ErrorHandlingUtils.buildWrongTypeMessage(message, expectedType, resultElement));
- }
-}
+/******************************************************************************* + * Copyright (c) 2011 Mia-Software + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values. + * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.exception; + +import org.eclipse.papyrus.emf.facet.efacet.core.exception.FacetManagerException; +import org.eclipse.papyrus.emf.facet.util.core.internal.ErrorHandlingUtils; + +/** + * This exception is raised when a value's type does not match with the expected type + * + * @since 0.2 + */ +public class UnmatchingExpectedTypeException extends FacetManagerException { + + private static final long serialVersionUID = 1456802297756942271L; + + public UnmatchingExpectedTypeException() { + super(); + } + + public UnmatchingExpectedTypeException(final String message) { + super(message); + } + + public UnmatchingExpectedTypeException(final String message, final Throwable cause) { + super(message, cause); + } + + public UnmatchingExpectedTypeException(final Throwable cause) { + super(cause); + } + + public UnmatchingExpectedTypeException(final String message, final Class<?> expectedType, final Object resultElement) { + super(ErrorHandlingUtils.buildWrongTypeMessage(message, expectedType, resultElement)); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exported/IResolver.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exported/IResolver.java index 601a96b7b89..0fae0918b48 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exported/IResolver.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exported/IResolver.java @@ -1,61 +1,61 @@ -/**
- * Copyright (c) 2012 CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
- * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.exported;
-
-import java.util.List;
-
-/**
- * The interface has to be implemented to contribute to the extension point
- * 'org.eclipse.papyrus.emf.facet.efacet.core.internal.resolver'.
- */
-public interface IResolver {
-
- /**
- * Return true is the parameter object can be handle by the implementation
- * of this interface.
- *
- * @param object
- * @return
- */
- boolean canHandle(Object object);
-
- /**
- * If the parameter 'object' is a proxy, this method returns the
- * corresponding a resolved object.
- *
- * @param object
- * a proxy
- * @param aClass
- * the expected resolved object
- */
- <T> T resolve(Object object, Class<T> aClass);
-
- /**
- * This method returns the objects that have to be automatically selected
- * when the parameter 'selectedObject' is selected.
- *
- * @param selectedObject
- * @param aClass
- * the expected list elements type.
- */
- <T> List<T> selectionPropagation(Object selectedObject, Class<T> aClass);
-
- /**
- * This method returns the root of the objects that have to be automatically
- * selected when the parameter 'selectedObject' is selected.
- *
- * @param selectedObject
- * @param aClass
- * the expected list elements type.
- */
- <T> T selectionRoot(Object selectedObject, Class<T> aClass);
-}
+/** + * Copyright (c) 2012 CEA LIST. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>) + * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.exported; + +import java.util.List; + +/** + * The interface has to be implemented to contribute to the extension point + * 'org.eclipse.papyrus.emf.facet.efacet.core.internal.resolver'. + */ +public interface IResolver { + + /** + * Return true is the parameter object can be handle by the implementation + * of this interface. + * + * @param object + * @return + */ + boolean canHandle(Object object); + + /** + * If the parameter 'object' is a proxy, this method returns the + * corresponding a resolved object. + * + * @param object + * a proxy + * @param aClass + * the expected resolved object + */ + <T> T resolve(Object object, Class<T> aClass); + + /** + * This method returns the objects that have to be automatically selected + * when the parameter 'selectedObject' is selected. + * + * @param selectedObject + * @param aClass + * the expected list elements type. + */ + <T> List<T> selectionPropagation(Object selectedObject, Class<T> aClass); + + /** + * This method returns the root of the objects that have to be automatically + * selected when the parameter 'selectedObject' is selected. + * + * @param selectedObject + * @param aClass + * the expected list elements type. + */ + <T> T selectionRoot(Object selectedObject, Class<T> aClass); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exported/IResolverManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exported/IResolverManager.java index 5d67576a5ca..c72b6c50bdb 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exported/IResolverManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/exported/IResolverManager.java @@ -1,28 +1,28 @@ -/**
- * Copyright (c) 2012 CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
- * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.exported;
-
-import java.util.List;
-
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.ResolverManager;
-
-public interface IResolverManager {
-
- IResolverManager DEFAULT = new ResolverManager();
-
- <T> T resolve(Object object, Class<T> aClass);
-
- <T> List<T> selectionPropagation(Object selectedObject, Class<T> aClass);
-
- <T> T selectionRoot(Object selectedObject, Class<T> aClass);
-
-}
+/** + * Copyright (c) 2012 CEA LIST. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>) + * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.exported; + +import java.util.List; + +import org.eclipse.papyrus.emf.facet.efacet.core.internal.ResolverManager; + +public interface IResolverManager { + + IResolverManager DEFAULT = new ResolverManager(); + + <T> T resolve(Object object, Class<T> aClass); + + <T> List<T> selectionPropagation(Object selectedObject, Class<T> aClass); + + <T> T selectionRoot(Object selectedObject, Class<T> aClass); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/incubatingapi/IFacetActions2.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/incubatingapi/IFacetActions2.java index 0799a5fed86..d420d0494ae 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/incubatingapi/IFacetActions2.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/incubatingapi/IFacetActions2.java @@ -1,208 +1,208 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Guyomar (Mia-Software) - Bug 338813 - [EMF Facet Framework] basic Facet actions
- * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.incubatingapi;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.ecore.EOperation;
-import org.eclipse.emf.ecore.EParameter;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.FacetActions2Impl;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.util.emf.core.exception.InvalidFacetSetException;
-
-/**
- * This interface contains methods to create {@link Facet}s.
- *
- * @since 0.2
- */
-public interface IFacetActions2 {
-
- IFacetActions2 INSTANCE = new FacetActions2Impl();
-
- /**
- * Add the given facetSet to the given facetSet model file, which will be created
- *
- * @param facetSet
- * the facetSet to be created. Cannot be <code>null</code>
- * @param project
- * the new file in which the facetSet has to be created. Cannot be <code>null</code>,
- * and cannot already exist
- */
- void saveFacetSet(FacetSet facetSet, IFile file) throws IOException,
- InvalidFacetSetException;
-
- /**
- * Add the given {@link Facet} to the given {@link FacetSet}
- *
- * @param facetSet
- * the parent facetSet, cannot be null
- * @param facet
- * the {@link Facet}, cannot be null, or contained by a resource
- * @param editingDomain
- * the editing domain needed to perform the Add EMF command, cannot be null
- */
- Facet createFacetInFacetSet(FacetSet facetSet, Facet facet,
- EditingDomain editingDomain);
-
- /**
- * Create a command to add the given {@link Facet} to the given {@link FacetSet}
- *
- * @param facetSet
- * the parent facetSet, cannot be null
- * @param facet
- * the {@link Facet}, cannot be null, or contained by a resource
- * @param editingDomain
- * the editing domain needed to perform the Add EMF command, cannot be null
- */
- Command createCreateFacetInFacetSetCommand(FacetSet facetSet, Facet facet,
- EditingDomain editingDomain);
-
- /**
- * Add the given {@link FacetAttribute} to the given {@link Facet}
- *
- * @param facet
- * the parent {@link Facet}, cannot be null
- * @param facetAttribute
- * the {@link FacetAttribute}, cannot be null, or contained by a resource
- * @param editingDomain
- * the editing domain needed to perform the Add Emf command, cannot be null
- */
- void addAttributeInFacet(Facet facet, FacetAttribute facetAttribute,
- EditingDomain editingDomain);
-
- /**
- * Create a command to add the given {@link FacetAttribute} to the given {@link Facet}
- *
- * @param facet
- * the parent {@link Facet}, cannot be null
- * @param facetAttribute
- * the {@link FacetAttribute}, cannot be null, or contained by a resource
- * @param editingDomain
- * the editing domain needed to perform the Add Emf command, cannot be null
- */
- Command createAddAttributeInFacetCommand(Facet facet, FacetAttribute facetAttribute,
- EditingDomain editingDomain);
-
- /**
- * Add the given {@link FacetReference} to the given {@link Facet}
- *
- * @param facet
- * the parent {@link Facet}, cannot be null
- * @param facetReference
- * the {@link FacetReference}, cannot be null, or contained by a resource
- * @param editingDomain
- * the editing domain needed to perform the Add Emf command, cannot be null
- */
- void addReferenceInFacet(Facet facet, FacetReference facetReference,
- EditingDomain editingDomain);
-
- /**
- * Create a command to add the given {@link FacetReference} to the given {@link Facet}
- *
- * @param facet
- * the parent {@link Facet}, cannot be null
- * @param facetReference
- * the {@link FacetReference}, cannot be null, or contained by a resource
- * @param editingDomain
- * the editing domain needed to perform the Add Emf command, cannot be null
- */
- Command createAddReferenceInFacetCommand(Facet facet,
- FacetReference facetReference, EditingDomain editingDomain);
-
- /**
- * Add a new {@link FacetOperation} to the given {@link Facet}
- *
- * @param facet
- * the parent {@link Facet}, cannot be null
- * @param facetOperation
- * the new {@link FacetOperation}, cannot be null, or contained by a resource
- * @param editingDomain
- * the editing domain needed to perform the Add Emf command, cannot be null
- */
- void addOperationInFacet(Facet facet, FacetOperation facetOperation,
- EditingDomain editingDomain);
-
- /**
- * Add a new {@link FacetOperation} to the given {@link Facet}
- *
- * @param facet
- * the parent {@link Facet}, cannot be null
- * @param facetOperation
- * the new {@link FacetOperation}, cannot be null, or contained by a resource
- * @param editingDomain
- * the editing domain needed to perform the Add Emf command, cannot be null
- */
- Command createAddOperationInFacetCommand(Facet facet,
- FacetOperation facetOperation, EditingDomain editingDomain);
-
- /**
- * Add a new {@link EParameter} to the given {@link FacetOperation}
- *
- * @param operation
- * the parent {@link EOperation}
- * @param parameter
- * the new {@link EParameter}
- * @param editingDomain
- * the editing domain needed to perform the Add Emf command, cannot be null
- */
- void addParameterInOperation(FacetOperation operation,
- EParameter parameter, EditingDomain editingDomain);
-
- /**
- * Add a new {@link EParameter} to the given {@link FacetOperation}
- *
- * @param operation
- * the parent {@link EOperation}
- * @param parameter
- * the new {@link EParameter}
- * @param editingDomain
- * the editing domain needed to perform the Add Emf command, cannot be null
- */
- Command createAddParameterInOperationCommand(FacetOperation operation,
- EParameter parameter, EditingDomain editingDomain);
-
- /**
- * Set the given URI to the given {@link FacetSet}
- *
- * @param facetSet
- * the {@link FacetSet} to be modified
- * @param nsUri
- * the Uri
- * @param editingDomain
- * the editing domain needed to perform the Set Emf command, cannot be null
- */
- void setFacetSetNsUri(FacetSet facetSet, String nsUri,
- EditingDomain editingDomain);
-
- /**
- * Set the given URI to the given {@link FacetSet}
- *
- * @param facetSet
- * the {@link FacetSet} to be modified
- * @param nsUri
- * the Uri
- * @param editingDomain
- * the editing domain needed to perform the Set Emf command, cannot be null
- */
- Command createSetFacetSetNsUriCommand(FacetSet facetSet, String nsUri,
- EditingDomain editingDomain);
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Guyomar (Mia-Software) - Bug 338813 - [EMF Facet Framework] basic Facet actions + * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.incubatingapi; + +import java.io.IOException; + +import org.eclipse.core.resources.IFile; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EParameter; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.FacetActions2Impl; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetAttribute; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetReference; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.util.emf.core.exception.InvalidFacetSetException; + +/** + * This interface contains methods to create {@link Facet}s. + * + * @since 0.2 + */ +public interface IFacetActions2 { + + IFacetActions2 INSTANCE = new FacetActions2Impl(); + + /** + * Add the given facetSet to the given facetSet model file, which will be created + * + * @param facetSet + * the facetSet to be created. Cannot be <code>null</code> + * @param project + * the new file in which the facetSet has to be created. Cannot be <code>null</code>, + * and cannot already exist + */ + void saveFacetSet(FacetSet facetSet, IFile file) throws IOException, + InvalidFacetSetException; + + /** + * Add the given {@link Facet} to the given {@link FacetSet} + * + * @param facetSet + * the parent facetSet, cannot be null + * @param facet + * the {@link Facet}, cannot be null, or contained by a resource + * @param editingDomain + * the editing domain needed to perform the Add EMF command, cannot be null + */ + Facet createFacetInFacetSet(FacetSet facetSet, Facet facet, + EditingDomain editingDomain); + + /** + * Create a command to add the given {@link Facet} to the given {@link FacetSet} + * + * @param facetSet + * the parent facetSet, cannot be null + * @param facet + * the {@link Facet}, cannot be null, or contained by a resource + * @param editingDomain + * the editing domain needed to perform the Add EMF command, cannot be null + */ + Command createCreateFacetInFacetSetCommand(FacetSet facetSet, Facet facet, + EditingDomain editingDomain); + + /** + * Add the given {@link FacetAttribute} to the given {@link Facet} + * + * @param facet + * the parent {@link Facet}, cannot be null + * @param facetAttribute + * the {@link FacetAttribute}, cannot be null, or contained by a resource + * @param editingDomain + * the editing domain needed to perform the Add Emf command, cannot be null + */ + void addAttributeInFacet(Facet facet, FacetAttribute facetAttribute, + EditingDomain editingDomain); + + /** + * Create a command to add the given {@link FacetAttribute} to the given {@link Facet} + * + * @param facet + * the parent {@link Facet}, cannot be null + * @param facetAttribute + * the {@link FacetAttribute}, cannot be null, or contained by a resource + * @param editingDomain + * the editing domain needed to perform the Add Emf command, cannot be null + */ + Command createAddAttributeInFacetCommand(Facet facet, FacetAttribute facetAttribute, + EditingDomain editingDomain); + + /** + * Add the given {@link FacetReference} to the given {@link Facet} + * + * @param facet + * the parent {@link Facet}, cannot be null + * @param facetReference + * the {@link FacetReference}, cannot be null, or contained by a resource + * @param editingDomain + * the editing domain needed to perform the Add Emf command, cannot be null + */ + void addReferenceInFacet(Facet facet, FacetReference facetReference, + EditingDomain editingDomain); + + /** + * Create a command to add the given {@link FacetReference} to the given {@link Facet} + * + * @param facet + * the parent {@link Facet}, cannot be null + * @param facetReference + * the {@link FacetReference}, cannot be null, or contained by a resource + * @param editingDomain + * the editing domain needed to perform the Add Emf command, cannot be null + */ + Command createAddReferenceInFacetCommand(Facet facet, + FacetReference facetReference, EditingDomain editingDomain); + + /** + * Add a new {@link FacetOperation} to the given {@link Facet} + * + * @param facet + * the parent {@link Facet}, cannot be null + * @param facetOperation + * the new {@link FacetOperation}, cannot be null, or contained by a resource + * @param editingDomain + * the editing domain needed to perform the Add Emf command, cannot be null + */ + void addOperationInFacet(Facet facet, FacetOperation facetOperation, + EditingDomain editingDomain); + + /** + * Add a new {@link FacetOperation} to the given {@link Facet} + * + * @param facet + * the parent {@link Facet}, cannot be null + * @param facetOperation + * the new {@link FacetOperation}, cannot be null, or contained by a resource + * @param editingDomain + * the editing domain needed to perform the Add Emf command, cannot be null + */ + Command createAddOperationInFacetCommand(Facet facet, + FacetOperation facetOperation, EditingDomain editingDomain); + + /** + * Add a new {@link EParameter} to the given {@link FacetOperation} + * + * @param operation + * the parent {@link EOperation} + * @param parameter + * the new {@link EParameter} + * @param editingDomain + * the editing domain needed to perform the Add Emf command, cannot be null + */ + void addParameterInOperation(FacetOperation operation, + EParameter parameter, EditingDomain editingDomain); + + /** + * Add a new {@link EParameter} to the given {@link FacetOperation} + * + * @param operation + * the parent {@link EOperation} + * @param parameter + * the new {@link EParameter} + * @param editingDomain + * the editing domain needed to perform the Add Emf command, cannot be null + */ + Command createAddParameterInOperationCommand(FacetOperation operation, + EParameter parameter, EditingDomain editingDomain); + + /** + * Set the given URI to the given {@link FacetSet} + * + * @param facetSet + * the {@link FacetSet} to be modified + * @param nsUri + * the Uri + * @param editingDomain + * the editing domain needed to perform the Set Emf command, cannot be null + */ + void setFacetSetNsUri(FacetSet facetSet, String nsUri, + EditingDomain editingDomain); + + /** + * Set the given URI to the given {@link FacetSet} + * + * @param facetSet + * the {@link FacetSet} to be modified + * @param nsUri + * the Uri + * @param editingDomain + * the editing domain needed to perform the Set Emf command, cannot be null + */ + Command createSetFacetSetNsUriCommand(FacetSet facetSet, String nsUri, + EditingDomain editingDomain); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/messages.properties b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/messages.properties index 75dcf1429ef..86c7c25b1ee 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/messages.properties +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/messages.properties @@ -1,13 +1,13 @@ -###########################################################################
-# Copyright (c) 2011 Mia-Software.
-#
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
-###########################################################################
-EFacetCatalogManager_FacetSetCatalogName=FacetSet catalog
-EFacetCatalogManager_QuerySetCatalogName=QuerySet catalog
+########################################################################### +# Copyright (c) 2011 Mia-Software. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet +########################################################################### +EFacetCatalogManager_FacetSetCatalogName=FacetSet catalog +EFacetCatalogManager_QuerySetCatalogName=QuerySet catalog diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/DerivedTypedElementImplementationFactoryRegistry.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/DerivedTypedElementImplementationFactoryRegistry.java index 3253d53ee1c..083bcd4172f 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/DerivedTypedElementImplementationFactoryRegistry.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/DerivedTypedElementImplementationFactoryRegistry.java @@ -1,121 +1,121 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
- * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
- * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
- * Gregoire Dupe (Mia-Software) - Bug 362087 - [Deprecated] org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager
- * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.Activator;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IDerivedTypedElementImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IDerivedTypedElementImplementationFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManagerFactory;
-import org.osgi.framework.Bundle;
-
-/** @deprecated replaced by {@link QueryImplementationFactoryRegistry}. No tracking bug because this API has not been released yet. */
-@Deprecated
-public class DerivedTypedElementImplementationFactoryRegistry {
- private static final String DERIVED_TYPED_ELEMENT_IMPLEMENTATION_REGISTRATION_ID = "org.eclipse.papyrus.emf.facet.efacet.core.derivedTypedElementImplementationRegistration"; //$NON-NLS-1$
- private static final String CLASS = "class"; //$NON-NLS-1$
- public static final DerivedTypedElementImplementationFactoryRegistry INSTANCE = new DerivedTypedElementImplementationFactoryRegistry();
-
- private final List<IDerivedTypedElementImplementationFactory> derivedTypedElementImplementationFactories = new ArrayList<IDerivedTypedElementImplementationFactory>();
-
- public DerivedTypedElementImplementationFactoryRegistry() {
- initRegisteredEntries();
- }
-
- private void initRegisteredEntries() {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extPoint = registry
- .getExtensionPoint(DerivedTypedElementImplementationFactoryRegistry.DERIVED_TYPED_ELEMENT_IMPLEMENTATION_REGISTRATION_ID);
- if (extPoint != null) {
- for (IExtension ext : extPoint.getExtensions()) {
- for (IConfigurationElement configElt : ext.getConfigurationElements()) {
-
- IDerivedTypedElementImplementationFactory derivedTypedElementImplementationFactory;
- try {
- derivedTypedElementImplementationFactory = (IDerivedTypedElementImplementationFactory) configElt
- .createExecutableExtension(DerivedTypedElementImplementationFactoryRegistry.CLASS);
- this.derivedTypedElementImplementationFactories.add(derivedTypedElementImplementationFactory);
- } catch (CoreException e) {
- Logger.logError(e, Activator.getDefault());
- }
- }
- }
- }
- }
-
- /**
- * Returns the derived typed element evaluator that handles the given type of query
- *
- * @param query
- * the type of query for which an {@link IDerivedTypedElementImplementation} is searched
- * @param derivedTEManager
- * @return the {@link IDerivedTypedElementImplementation}
- * @throws DerivedTypedElementException
- * if no factory implementation was registered for the type of the given query
- */
- public IDerivedTypedElementImplementation getEvaluatorFor(final Query query, final IDerivedTypedElementManager derivedTEManager)
- throws DerivedTypedElementException {
- if (query == null) {
- throw new IllegalArgumentException("query cannot be null"); //$NON-NLS-1$
- }
- IDerivedTypedElementImplementation derivedTypedElementImplementation = null;
- boolean factoryFound = false;
- for (IDerivedTypedElementImplementationFactory derivedTypedElementImplementationFactory : this.derivedTypedElementImplementationFactories) {
- factoryFound = derivedTypedElementImplementationFactory.getManagedQueryType() == query.eClass();
- if (factoryFound) {
- Resource queryResource = query.eResource();
- Bundle bundle;
- if (queryResource != null) {
- bundle = ICatalogSetManagerFactory.DEFAULT.createICatalogSetManager(query.eResource().getResourceSet()).getBundleByResource(queryResource);
- } else {
- bundle = null;
- }
- derivedTypedElementImplementation = derivedTypedElementImplementationFactory.create(query, bundle, derivedTEManager);
- break;
- }
- }
- if (!factoryFound) {
- StringBuffer sb = new StringBuffer();
- sb.append("No factory implementation found for "); //$NON-NLS-1$
- sb.append(QueryUtils.getQueryDescription(query));
- sb.append(".\nA factory should be registered through the " + DerivedTypedElementImplementationFactoryRegistry.DERIVED_TYPED_ELEMENT_IMPLEMENTATION_REGISTRATION_ID + " extension point."); //$NON-NLS-1$ //$NON-NLS-2$
- sb.append("\nAvailable Query types are: "); //$NON-NLS-1$
- for (int i = 0; i < this.derivedTypedElementImplementationFactories.size(); i++) {
- if (i > 0) {
- sb.append(", "); //$NON-NLS-1$
- }
- IDerivedTypedElementImplementationFactory queryEvaluatorFactory = this.derivedTypedElementImplementationFactories.get(i);
- sb.append(queryEvaluatorFactory.getManagedQueryType().getName());
- }
- throw new DerivedTypedElementException(sb.toString());
- }
- return derivedTypedElementImplementation;
- }
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet + * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values. + * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel + * Gregoire Dupe (Mia-Software) - Bug 362087 - [Deprecated] org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager + * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2 + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.Activator; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IDerivedTypedElementImplementation; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IDerivedTypedElementImplementationFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManagerFactory; +import org.osgi.framework.Bundle; + +/** @deprecated replaced by {@link QueryImplementationFactoryRegistry}. No tracking bug because this API has not been released yet. */ +@Deprecated +public class DerivedTypedElementImplementationFactoryRegistry { + private static final String DERIVED_TYPED_ELEMENT_IMPLEMENTATION_REGISTRATION_ID = "org.eclipse.papyrus.emf.facet.efacet.core.derivedTypedElementImplementationRegistration"; //$NON-NLS-1$ + private static final String CLASS = "class"; //$NON-NLS-1$ + public static final DerivedTypedElementImplementationFactoryRegistry INSTANCE = new DerivedTypedElementImplementationFactoryRegistry(); + + private final List<IDerivedTypedElementImplementationFactory> derivedTypedElementImplementationFactories = new ArrayList<IDerivedTypedElementImplementationFactory>(); + + public DerivedTypedElementImplementationFactoryRegistry() { + initRegisteredEntries(); + } + + private void initRegisteredEntries() { + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint extPoint = registry + .getExtensionPoint(DerivedTypedElementImplementationFactoryRegistry.DERIVED_TYPED_ELEMENT_IMPLEMENTATION_REGISTRATION_ID); + if (extPoint != null) { + for (IExtension ext : extPoint.getExtensions()) { + for (IConfigurationElement configElt : ext.getConfigurationElements()) { + + IDerivedTypedElementImplementationFactory derivedTypedElementImplementationFactory; + try { + derivedTypedElementImplementationFactory = (IDerivedTypedElementImplementationFactory) configElt + .createExecutableExtension(DerivedTypedElementImplementationFactoryRegistry.CLASS); + this.derivedTypedElementImplementationFactories.add(derivedTypedElementImplementationFactory); + } catch (CoreException e) { + Logger.logError(e, Activator.getDefault()); + } + } + } + } + } + + /** + * Returns the derived typed element evaluator that handles the given type of query + * + * @param query + * the type of query for which an {@link IDerivedTypedElementImplementation} is searched + * @param derivedTEManager + * @return the {@link IDerivedTypedElementImplementation} + * @throws DerivedTypedElementException + * if no factory implementation was registered for the type of the given query + */ + public IDerivedTypedElementImplementation getEvaluatorFor(final Query query, final IDerivedTypedElementManager derivedTEManager) + throws DerivedTypedElementException { + if (query == null) { + throw new IllegalArgumentException("query cannot be null"); //$NON-NLS-1$ + } + IDerivedTypedElementImplementation derivedTypedElementImplementation = null; + boolean factoryFound = false; + for (IDerivedTypedElementImplementationFactory derivedTypedElementImplementationFactory : this.derivedTypedElementImplementationFactories) { + factoryFound = derivedTypedElementImplementationFactory.getManagedQueryType() == query.eClass(); + if (factoryFound) { + Resource queryResource = query.eResource(); + Bundle bundle; + if (queryResource != null) { + bundle = ICatalogSetManagerFactory.DEFAULT.createICatalogSetManager(query.eResource().getResourceSet()).getBundleByResource(queryResource); + } else { + bundle = null; + } + derivedTypedElementImplementation = derivedTypedElementImplementationFactory.create(query, bundle, derivedTEManager); + break; + } + } + if (!factoryFound) { + StringBuffer sb = new StringBuffer(); + sb.append("No factory implementation found for "); //$NON-NLS-1$ + sb.append(QueryUtils.getQueryDescription(query)); + sb.append(".\nA factory should be registered through the " + DerivedTypedElementImplementationFactoryRegistry.DERIVED_TYPED_ELEMENT_IMPLEMENTATION_REGISTRATION_ID + " extension point."); //$NON-NLS-1$ //$NON-NLS-2$ + sb.append("\nAvailable Query types are: "); //$NON-NLS-1$ + for (int i = 0; i < this.derivedTypedElementImplementationFactories.size(); i++) { + if (i > 0) { + sb.append(", "); //$NON-NLS-1$ + } + IDerivedTypedElementImplementationFactory queryEvaluatorFactory = this.derivedTypedElementImplementationFactories.get(i); + sb.append(queryEvaluatorFactory.getManagedQueryType().getName()); + } + throw new DerivedTypedElementException(sb.toString()); + } + return derivedTypedElementImplementation; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/EObjectLiteralQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/EObjectLiteralQueryImplementation.java index 23c12faa73d..e96f07fdd45 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/EObjectLiteralQueryImplementation.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/EObjectLiteralQueryImplementation.java @@ -1,48 +1,48 @@ -/*******************************************************************************
- * Copyright (c) 2012 CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.EObjectLiteralQuery;
-
-public class EObjectLiteralQueryImplementation implements IQueryImplementation {
-
- private boolean checkResultType = false;
-
- public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues,
- final IFacetManager facetManager)
- throws DerivedTypedElementException {
- return ((EObjectLiteralQuery) query).getElement();
- }
-
- public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues,
- final Object newValue)
- throws DerivedTypedElementException {
- throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$
- }
-
- public boolean isCheckResultType() {
- return this.checkResultType;
- }
-
- public void setCheckResultType(final boolean checkResultType) {
- this.checkResultType = checkResultType;
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 CEA LIST. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.EObjectLiteralQuery; + +public class EObjectLiteralQueryImplementation implements IQueryImplementation { + + private boolean checkResultType = false; + + public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, + final IFacetManager facetManager) + throws DerivedTypedElementException { + return ((EObjectLiteralQuery) query).getElement(); + } + + public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, + final Object newValue) + throws DerivedTypedElementException { + throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$ + } + + public boolean isCheckResultType() { + return this.checkResultType; + } + + public void setCheckResultType(final boolean checkResultType) { + this.checkResultType = checkResultType; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/EObjectLiteralQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/EObjectLiteralQueryImplementationFactory.java index 25336424e0c..f847d1e4f1e 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/EObjectLiteralQueryImplementationFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/EObjectLiteralQueryImplementationFactory.java @@ -1,33 +1,33 @@ -/*******************************************************************************
- * Copyright (c) 2012 CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage;
-import org.osgi.framework.Bundle;
-
-public class EObjectLiteralQueryImplementationFactory implements IQueryImplementationFactory {
-
- public EClass getManagedQueryType() {
- return QueryPackage.eINSTANCE.getEObjectLiteralQuery();
- }
-
- public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException {
- final EObjectLiteralQueryImplementation evaluator = new EObjectLiteralQueryImplementation();
- evaluator.setCheckResultType(true);
- return evaluator;
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 CEA LIST. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage; +import org.osgi.framework.Bundle; + +public class EObjectLiteralQueryImplementationFactory implements IQueryImplementationFactory { + + public EClass getManagedQueryType() { + return QueryPackage.eINSTANCE.getEObjectLiteralQuery(); + } + + public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException { + final EObjectLiteralQueryImplementation evaluator = new EObjectLiteralQueryImplementation(); + evaluator.setCheckResultType(true); + return evaluator; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/FalseLiteralQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/FalseLiteralQueryImplementation.java index ed0cc02d92c..4dc8ad25365 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/FalseLiteralQueryImplementation.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/FalseLiteralQueryImplementation.java @@ -1,46 +1,46 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-
-public class FalseLiteralQueryImplementation implements IQueryImplementation {
-
- private boolean checkResultType = false;
-
- public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager)
- throws DerivedTypedElementException {
- return Boolean.FALSE;
- }
-
- public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue)
- throws DerivedTypedElementException {
- throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$
- }
-
- public void setCheckResultType(final boolean checkResultType) {
- this.checkResultType = checkResultType;
- }
-
- public boolean isCheckResultType() {
- return this.checkResultType;
- }
-}
+/** + * Copyright (c) 2012 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; + +public class FalseLiteralQueryImplementation implements IQueryImplementation { + + private boolean checkResultType = false; + + public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager) + throws DerivedTypedElementException { + return Boolean.FALSE; + } + + public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue) + throws DerivedTypedElementException { + throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$ + } + + public void setCheckResultType(final boolean checkResultType) { + this.checkResultType = checkResultType; + } + + public boolean isCheckResultType() { + return this.checkResultType; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/FalseLiteralQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/FalseLiteralQueryImplementationFactory.java index 80734e4196e..076648cb1be 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/FalseLiteralQueryImplementationFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/FalseLiteralQueryImplementationFactory.java @@ -1,35 +1,35 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Grégoire Dupé (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage;
-import org.osgi.framework.Bundle;
-
-public class FalseLiteralQueryImplementationFactory implements IQueryImplementationFactory {
-
- public EClass getManagedQueryType() {
- return QueryPackage.eINSTANCE.getFalseLiteralQuery();
- }
-
- public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException {
- final FalseLiteralQueryImplementation evaluator = new FalseLiteralQueryImplementation();
- evaluator.setCheckResultType(false);
- return evaluator;
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Grégoire Dupé (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage; +import org.osgi.framework.Bundle; + +public class FalseLiteralQueryImplementationFactory implements IQueryImplementationFactory { + + public EClass getManagedQueryType() { + return QueryPackage.eINSTANCE.getFalseLiteralQuery(); + } + + public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException { + final FalseLiteralQueryImplementation evaluator = new FalseLiteralQueryImplementation(); + evaluator.setCheckResultType(false); + return evaluator; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/FloatLiteralQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/FloatLiteralQueryImplementation.java index 02d55135c61..cfecc92d0ae 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/FloatLiteralQueryImplementation.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/FloatLiteralQueryImplementation.java @@ -1,46 +1,46 @@ -/*******************************************************************************
- * Copyright (c) 2012 CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.FloatLiteralQuery;
-
-public class FloatLiteralQueryImplementation implements IQueryImplementation {
-
- private boolean checkResultType = false;
-
- public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager)
- throws DerivedTypedElementException {
- return Float.valueOf(((FloatLiteralQuery) query).getValue());
- }
-
- public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue)
- throws DerivedTypedElementException {
- throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$
- }
-
- public void setCheckResultType(final boolean checkResultType) {
- this.checkResultType = checkResultType;
- }
-
- public boolean isCheckResultType() {
- return this.checkResultType;
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 CEA LIST. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.FloatLiteralQuery; + +public class FloatLiteralQueryImplementation implements IQueryImplementation { + + private boolean checkResultType = false; + + public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager) + throws DerivedTypedElementException { + return Float.valueOf(((FloatLiteralQuery) query).getValue()); + } + + public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue) + throws DerivedTypedElementException { + throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$ + } + + public void setCheckResultType(final boolean checkResultType) { + this.checkResultType = checkResultType; + } + + public boolean isCheckResultType() { + return this.checkResultType; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/FloatLiteralQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/FloatLiteralQueryImplementationFactory.java index 15dbf40a1df..ac71936aff2 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/FloatLiteralQueryImplementationFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/FloatLiteralQueryImplementationFactory.java @@ -1,33 +1,33 @@ -/*******************************************************************************
- * Copyright (c) 2012 CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage;
-import org.osgi.framework.Bundle;
-
-public class FloatLiteralQueryImplementationFactory implements IQueryImplementationFactory {
-
- public EClass getManagedQueryType() {
- return QueryPackage.eINSTANCE.getFloatLiteralQuery();
- }
-
- public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException {
- final FloatLiteralQueryImplementation evaluator = new FloatLiteralQueryImplementation();
- evaluator.setCheckResultType(true);
- return evaluator;
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 CEA LIST. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage; +import org.osgi.framework.Bundle; + +public class FloatLiteralQueryImplementationFactory implements IQueryImplementationFactory { + + public EClass getManagedQueryType() { + return QueryPackage.eINSTANCE.getFloatLiteralQuery(); + } + + public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException { + final FloatLiteralQueryImplementation evaluator = new FloatLiteralQueryImplementation(); + evaluator.setCheckResultType(true); + return evaluator; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/IntegerLiteralQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/IntegerLiteralQueryImplementation.java index a8d247d07fb..938b641dee1 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/IntegerLiteralQueryImplementation.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/IntegerLiteralQueryImplementation.java @@ -1,46 +1,46 @@ -/*******************************************************************************
- * Copyright (c) 2012 CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.IntegerLiteralQuery;
-
-public class IntegerLiteralQueryImplementation implements IQueryImplementation {
-
- private boolean checkResultType = false;
-
- public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager)
- throws DerivedTypedElementException {
- return Integer.valueOf(((IntegerLiteralQuery) query).getValue());
- }
-
- public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue)
- throws DerivedTypedElementException {
- throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$
- }
-
- public void setCheckResultType(final boolean checkResultType) {
- this.checkResultType = checkResultType;
- }
-
- public boolean isCheckResultType() {
- return this.checkResultType;
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 CEA LIST. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.IntegerLiteralQuery; + +public class IntegerLiteralQueryImplementation implements IQueryImplementation { + + private boolean checkResultType = false; + + public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager) + throws DerivedTypedElementException { + return Integer.valueOf(((IntegerLiteralQuery) query).getValue()); + } + + public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue) + throws DerivedTypedElementException { + throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$ + } + + public void setCheckResultType(final boolean checkResultType) { + this.checkResultType = checkResultType; + } + + public boolean isCheckResultType() { + return this.checkResultType; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/IntegerLiteralQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/IntegerLiteralQueryImplementationFactory.java index a23e3fdda64..5b58028d4f1 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/IntegerLiteralQueryImplementationFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/IntegerLiteralQueryImplementationFactory.java @@ -1,33 +1,33 @@ -/*******************************************************************************
- * Copyright (c) 2012 CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage;
-import org.osgi.framework.Bundle;
-
-public class IntegerLiteralQueryImplementationFactory implements IQueryImplementationFactory {
-
- public EClass getManagedQueryType() {
- return QueryPackage.eINSTANCE.getIntegerLiteralQuery();
- }
-
- public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException {
- final IntegerLiteralQueryImplementation evaluator = new IntegerLiteralQueryImplementation();
- evaluator.setCheckResultType(true);
- return evaluator;
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 CEA LIST. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage; +import org.osgi.framework.Bundle; + +public class IntegerLiteralQueryImplementationFactory implements IQueryImplementationFactory { + + public EClass getManagedQueryType() { + return QueryPackage.eINSTANCE.getIntegerLiteralQuery(); + } + + public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException { + final IntegerLiteralQueryImplementation evaluator = new IntegerLiteralQueryImplementation(); + evaluator.setCheckResultType(true); + return evaluator; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/IsOneOfQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/IsOneOfQueryImplementation.java index a5d558a1bdb..2249dd970b2 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/IsOneOfQueryImplementation.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/IsOneOfQueryImplementation.java @@ -1,52 +1,52 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 369673 - [Facet] IsOneOfQuery
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.IsOneOfQuery;
-
-public class IsOneOfQueryImplementation implements IQueryImplementation {
-
- // This class is a modified copy of :
- // org.eclipse.papyrus.emf.facet.infra.query.core.java.internal.JavaModelQueryAdapter
-
- private boolean checkResultType = false;
-
- public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager)
- throws DerivedTypedElementException {
- return Boolean.valueOf(((IsOneOfQuery) query).getExpectedEObjects().contains(source));
- }
-
- public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue)
- throws DerivedTypedElementException {
- throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$
- }
-
- public void setCheckResultType(final boolean checkResultType) {
- this.checkResultType = checkResultType;
- }
-
- public boolean isCheckResultType() {
- return this.checkResultType;
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 369673 - [Facet] IsOneOfQuery + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.IsOneOfQuery; + +public class IsOneOfQueryImplementation implements IQueryImplementation { + + // This class is a modified copy of : + // org.eclipse.papyrus.emf.facet.infra.query.core.java.internal.JavaModelQueryAdapter + + private boolean checkResultType = false; + + public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager) + throws DerivedTypedElementException { + return Boolean.valueOf(((IsOneOfQuery) query).getExpectedEObjects().contains(source)); + } + + public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue) + throws DerivedTypedElementException { + throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$ + } + + public void setCheckResultType(final boolean checkResultType) { + this.checkResultType = checkResultType; + } + + public boolean isCheckResultType() { + return this.checkResultType; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/IsOneOfQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/IsOneOfQueryImplementationFactory.java index a7e28152b89..362a60aa767 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/IsOneOfQueryImplementationFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/IsOneOfQueryImplementationFactory.java @@ -1,36 +1,36 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Grégoire Dupé (Mia-Software) - Bug 369673 - [Facet] IsOneOfQuery
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage;
-import org.osgi.framework.Bundle;
-
-public class IsOneOfQueryImplementationFactory implements IQueryImplementationFactory {
-
- public EClass getManagedQueryType() {
- return QueryPackage.eINSTANCE.getIsOneOfQuery();
- }
-
- public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException {
- final IsOneOfQueryImplementation evaluator = new IsOneOfQueryImplementation();
- evaluator.setCheckResultType(false);
- return evaluator;
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Grégoire Dupé (Mia-Software) - Bug 369673 - [Facet] IsOneOfQuery + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage; +import org.osgi.framework.Bundle; + +public class IsOneOfQueryImplementationFactory implements IQueryImplementationFactory { + + public EClass getManagedQueryType() { + return QueryPackage.eINSTANCE.getIsOneOfQuery(); + } + + public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException { + final IsOneOfQueryImplementation evaluator = new IsOneOfQueryImplementation(); + evaluator.setCheckResultType(false); + return evaluator; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/NavigationQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/NavigationQueryImplementation.java index e3e9c75b2cf..a2f9f42999f 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/NavigationQueryImplementation.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/NavigationQueryImplementation.java @@ -1,80 +1,80 @@ -/**
- * Copyright (c) 2011, 2012 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 366055 - NavigationQuery
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Olivier Remaud (Soft-Maint) - Bug 373087 - [Improvement] Adaptable behavior on error
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EOperation;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.NavigationQuery;
-
-public class NavigationQueryImplementation implements IQueryImplementation {
-
- // This class is a modified copy of :
- // org.eclipse.papyrus.emf.facet.infra.query.core.java.internal.JavaModelQueryAdapter
-
- private boolean checkResultType = false;
-
- public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager)
- throws DerivedTypedElementException {
- final NavigationQuery navigationQuery = (NavigationQuery) query;
- Object current = source;
- for (final ETypedElement typedElement : navigationQuery.getPath()) {
- if (current instanceof EObject) {
- final EObject currentEObject = (EObject) current;
- if (typedElement instanceof EOperation) {
- final EOperation operation = (EOperation) typedElement;
- try {
- current = currentEObject.eInvoke(operation, null);
- } catch (final InvocationTargetException e) {
- throw new DerivedTypedElementEvaluationException("Invocation of " + operation.getName() + " failed.", e); //$NON-NLS-1$//$NON-NLS-2$
- }
- } else if (typedElement instanceof EStructuralFeature) {
- final EStructuralFeature structuralFeature = (EStructuralFeature) typedElement;
- current = currentEObject.eGet(structuralFeature);
- } else {
- throw new DerivedTypedElementEvaluationException("The " + typedElement.eClass().getName() + " is not supported."); //$NON-NLS-1$//$NON-NLS-2$
- }
- } else {
- if (current != null || navigationQuery.isFailOnError()) {
- throw new DerivedTypedElementEvaluationException("Invalid path"); //$NON-NLS-1$
- }
- }
- }
- return current;
- }
-
- public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue)
- throws DerivedTypedElementException {
- throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$
- }
-
- public void setCheckResultType(final boolean checkResultType) {
- this.checkResultType = checkResultType;
- }
-
- public boolean isCheckResultType() {
- return this.checkResultType;
- }
-}
+/** + * Copyright (c) 2011, 2012 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 366055 - NavigationQuery + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Olivier Remaud (Soft-Maint) - Bug 373087 - [Improvement] Adaptable behavior on error + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import java.lang.reflect.InvocationTargetException; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.NavigationQuery; + +public class NavigationQueryImplementation implements IQueryImplementation { + + // This class is a modified copy of : + // org.eclipse.papyrus.emf.facet.infra.query.core.java.internal.JavaModelQueryAdapter + + private boolean checkResultType = false; + + public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager) + throws DerivedTypedElementException { + final NavigationQuery navigationQuery = (NavigationQuery) query; + Object current = source; + for (final ETypedElement typedElement : navigationQuery.getPath()) { + if (current instanceof EObject) { + final EObject currentEObject = (EObject) current; + if (typedElement instanceof EOperation) { + final EOperation operation = (EOperation) typedElement; + try { + current = currentEObject.eInvoke(operation, null); + } catch (final InvocationTargetException e) { + throw new DerivedTypedElementEvaluationException("Invocation of " + operation.getName() + " failed.", e); //$NON-NLS-1$//$NON-NLS-2$ + } + } else if (typedElement instanceof EStructuralFeature) { + final EStructuralFeature structuralFeature = (EStructuralFeature) typedElement; + current = currentEObject.eGet(structuralFeature); + } else { + throw new DerivedTypedElementEvaluationException("The " + typedElement.eClass().getName() + " is not supported."); //$NON-NLS-1$//$NON-NLS-2$ + } + } else { + if (current != null || navigationQuery.isFailOnError()) { + throw new DerivedTypedElementEvaluationException("Invalid path"); //$NON-NLS-1$ + } + } + } + return current; + } + + public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue) + throws DerivedTypedElementException { + throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$ + } + + public void setCheckResultType(final boolean checkResultType) { + this.checkResultType = checkResultType; + } + + public boolean isCheckResultType() { + return this.checkResultType; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/NavigationQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/NavigationQueryImplementationFactory.java index 7a3e4afacec..183da2b0c74 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/NavigationQueryImplementationFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/NavigationQueryImplementationFactory.java @@ -1,35 +1,35 @@ -/**
- * Copyright (c) 2011, 2012 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Grégoire Dupé (Mia-Software) - Bug 366055 - NavigationQuery
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage;
-import org.osgi.framework.Bundle;
-
-public class NavigationQueryImplementationFactory implements IQueryImplementationFactory {
-
- public EClass getManagedQueryType() {
- return QueryPackage.eINSTANCE.getNavigationQuery();
- }
-
- public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException {
- final NavigationQueryImplementation evaluator = new NavigationQueryImplementation();
- evaluator.setCheckResultType(true);
- return evaluator;
- }
-}
+/** + * Copyright (c) 2011, 2012 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Grégoire Dupé (Mia-Software) - Bug 366055 - NavigationQuery + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage; +import org.osgi.framework.Bundle; + +public class NavigationQueryImplementationFactory implements IQueryImplementationFactory { + + public EClass getManagedQueryType() { + return QueryPackage.eINSTANCE.getNavigationQuery(); + } + + public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException { + final NavigationQueryImplementation evaluator = new NavigationQueryImplementation(); + evaluator.setCheckResultType(true); + return evaluator; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/NullLiteralQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/NullLiteralQueryImplementation.java index 5d21fc5a471..a97fb2f2253 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/NullLiteralQueryImplementation.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/NullLiteralQueryImplementation.java @@ -1,46 +1,46 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-
-public class NullLiteralQueryImplementation implements IQueryImplementation {
-
- private boolean checkResultType = false;
-
- public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager)
- throws DerivedTypedElementException {
- return null;
- }
-
- public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue)
- throws DerivedTypedElementException {
- throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$
- }
-
- public void setCheckResultType(final boolean checkResultType) {
- this.checkResultType = checkResultType;
- }
-
- public boolean isCheckResultType() {
- return this.checkResultType;
- }
-}
+/** + * Copyright (c) 2012 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; + +public class NullLiteralQueryImplementation implements IQueryImplementation { + + private boolean checkResultType = false; + + public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager) + throws DerivedTypedElementException { + return null; + } + + public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue) + throws DerivedTypedElementException { + throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$ + } + + public void setCheckResultType(final boolean checkResultType) { + this.checkResultType = checkResultType; + } + + public boolean isCheckResultType() { + return this.checkResultType; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/NullLiteralQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/NullLiteralQueryImplementationFactory.java index 44a78a44390..eb0ec66e652 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/NullLiteralQueryImplementationFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/NullLiteralQueryImplementationFactory.java @@ -1,35 +1,35 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Grégoire Dupé (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage;
-import org.osgi.framework.Bundle;
-
-public class NullLiteralQueryImplementationFactory implements IQueryImplementationFactory {
-
- public EClass getManagedQueryType() {
- return QueryPackage.eINSTANCE.getNullLiteralQuery();
- }
-
- public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException {
- final NullLiteralQueryImplementation evaluator = new NullLiteralQueryImplementation();
- evaluator.setCheckResultType(false);
- return evaluator;
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Grégoire Dupé (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage; +import org.osgi.framework.Bundle; + +public class NullLiteralQueryImplementationFactory implements IQueryImplementationFactory { + + public EClass getManagedQueryType() { + return QueryPackage.eINSTANCE.getNullLiteralQuery(); + } + + public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException { + final NullLiteralQueryImplementation evaluator = new NullLiteralQueryImplementation(); + evaluator.setCheckResultType(false); + return evaluator; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/OperationCallQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/OperationCallQueryImplementation.java index 44a811db10c..6bbbf75af0f 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/OperationCallQueryImplementation.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/OperationCallQueryImplementation.java @@ -1,68 +1,68 @@ -/*******************************************************************************
- * Copyright (c) 2012 CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.FacetManagerException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.OperationCallQuery;
-
-public class OperationCallQueryImplementation implements IQueryImplementation {
-
- private boolean checkResultType = false;
- private final IDerivedTypedElementManager derivedTEManager;
-
- public OperationCallQueryImplementation(final IDerivedTypedElementManager derivedTEManager) {
- this.derivedTEManager = derivedTEManager;
- }
-
- public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager)
- throws DerivedTypedElementException {
- Object result;
- final OperationCallQuery opQuery = (OperationCallQuery) query;
- final List<Object> operationArgs = new ArrayList<Object>();
- for (final Query queryArgument : opQuery.getArguments()) {
- operationArgs.add(this.derivedTEManager.evaluate(queryArgument, source, parameterValues, facetManager));
- }
-
- // FIXME: no EditingDomain is available here
- try {
- result = facetManager.invoke(source, opQuery.getOperation(), null, null, operationArgs.toArray());
- } catch (final FacetManagerException e) {
- throw new DerivedTypedElementEvaluationException("Operation call evaluation failed", e); //$NON-NLS-1$
- }
- return result;
- }
-
- public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue)
- throws DerivedTypedElementException {
- throw new DerivedTypedElementEvaluationException("A set operation cannot be performed through an operation call."); //$NON-NLS-1$
-
- }
-
- public void setCheckResultType(final boolean checkResultType) {
- this.checkResultType = checkResultType;
- }
-
- public boolean isCheckResultType() {
- return this.checkResultType;
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 CEA LIST. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.FacetManagerException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.OperationCallQuery; + +public class OperationCallQueryImplementation implements IQueryImplementation { + + private boolean checkResultType = false; + private final IDerivedTypedElementManager derivedTEManager; + + public OperationCallQueryImplementation(final IDerivedTypedElementManager derivedTEManager) { + this.derivedTEManager = derivedTEManager; + } + + public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager) + throws DerivedTypedElementException { + Object result; + final OperationCallQuery opQuery = (OperationCallQuery) query; + final List<Object> operationArgs = new ArrayList<Object>(); + for (final Query queryArgument : opQuery.getArguments()) { + operationArgs.add(this.derivedTEManager.evaluate(queryArgument, source, parameterValues, facetManager)); + } + + // FIXME: no EditingDomain is available here + try { + result = facetManager.invoke(source, opQuery.getOperation(), null, null, operationArgs.toArray()); + } catch (final FacetManagerException e) { + throw new DerivedTypedElementEvaluationException("Operation call evaluation failed", e); //$NON-NLS-1$ + } + return result; + } + + public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue) + throws DerivedTypedElementException { + throw new DerivedTypedElementEvaluationException("A set operation cannot be performed through an operation call."); //$NON-NLS-1$ + + } + + public void setCheckResultType(final boolean checkResultType) { + this.checkResultType = checkResultType; + } + + public boolean isCheckResultType() { + return this.checkResultType; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/OperationCallQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/OperationCallQueryImplementationFactory.java index e00136ebd7a..10c7ec7cfbd 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/OperationCallQueryImplementationFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/OperationCallQueryImplementationFactory.java @@ -1,32 +1,32 @@ -/*******************************************************************************
- * Copyright (c) 2012 CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage;
-import org.osgi.framework.Bundle;
-
-public class OperationCallQueryImplementationFactory implements IQueryImplementationFactory {
-
- public EClass getManagedQueryType() {
- return QueryPackage.eINSTANCE.getOperationCallQuery();
- }
-
- public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager)
- throws DerivedTypedElementException {
- return new OperationCallQueryImplementation(manager);
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 CEA LIST. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage; +import org.osgi.framework.Bundle; + +public class OperationCallQueryImplementationFactory implements IQueryImplementationFactory { + + public EClass getManagedQueryType() { + return QueryPackage.eINSTANCE.getOperationCallQuery(); + } + + public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) + throws DerivedTypedElementException { + return new OperationCallQueryImplementation(manager); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/QueryEvaluatorFactoryRegistry.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/QueryEvaluatorFactoryRegistry.java index 29ef7f1b926..8ea0811fd02 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/QueryEvaluatorFactoryRegistry.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/QueryEvaluatorFactoryRegistry.java @@ -1,100 +1,100 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
- * Nicolas Guyomar (Mia-Software) - Bug 349566 - Need some new query utils method for query creation
- * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.papyrus.emf.facet.efacet.Query;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.QueryException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.Activator;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryEvaluator;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryEvaluatorFactory;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager;
-
-/** @deprecated replaced by {@link DerivedTypedElementImplementationFactoryRegistry} with the new eFacet2 metamodel */
-@Deprecated
-public class QueryEvaluatorFactoryRegistry {
- private static final String QUERY_EVALUATOR_REGISTRATION_ID = "org.eclipse.papyrus.emf.facet.efacet.core.query.evaluatorregistration"; //$NON-NLS-1$
- private static final String CLASS = "class"; //$NON-NLS-1$
- public static final QueryEvaluatorFactoryRegistry INSTANCE = new QueryEvaluatorFactoryRegistry();
-
- private final List<IQueryEvaluatorFactory> queryEvaluatorFactories = new ArrayList<IQueryEvaluatorFactory>();
-
- public QueryEvaluatorFactoryRegistry() {
- initRegisteredEntries();
- }
-
- private void initRegisteredEntries() {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extPoint = registry
- .getExtensionPoint(QueryEvaluatorFactoryRegistry.QUERY_EVALUATOR_REGISTRATION_ID);
- if (extPoint != null) {
- for (IExtension ext : extPoint.getExtensions()) {
- for (IConfigurationElement configElt : ext.getConfigurationElements()) {
-
- IQueryEvaluatorFactory queryEvaluatorFactory;
- try {
- queryEvaluatorFactory = (IQueryEvaluatorFactory) configElt
- .createExecutableExtension(QueryEvaluatorFactoryRegistry.CLASS);
-
- this.queryEvaluatorFactories.add(queryEvaluatorFactory);
- } catch (CoreException e) {
- Logger.logError(e, Activator.getDefault());
- }
- }
- }
- }
- }
-
- public IQueryEvaluator getEvaluatorFor(final Query query) throws QueryException {
- IQueryEvaluator queryEvaluator = null;
- boolean factoryFound = false;
- for (IQueryEvaluatorFactory queryEvaluatorFactory : this.queryEvaluatorFactories) {
- factoryFound = queryEvaluatorFactory.getManagedQueryType() == query.eClass();
- if (factoryFound) {
- queryEvaluator = queryEvaluatorFactory.create(query,
- ICatalogSetManager.INSTANCE.getBundleByResource(query.eResource()));
- break;
- }
- }
- if (!factoryFound) {
- StringBuffer sb = new StringBuffer();
- sb.append("No factory implementation found for: "); //$NON-NLS-1$
- sb.append(query.eClass().getName());
- sb.append(":"); //$NON-NLS-1$
- sb.append(query.getName());
- sb.append("\n Available Query types are: "); //$NON-NLS-1$
- for (IQueryEvaluatorFactory queryEvaluatorFactory : this.queryEvaluatorFactories) {
- sb.append(queryEvaluatorFactory.getManagedQueryType().getName());
- sb.append(", "); //$NON-NLS-1$
- }
- QueryException e = new QueryException(sb.toString());
- throw e;
- }
- return queryEvaluator;
- }
-
- public List<IQueryEvaluatorFactory> getInstalledQueryFactories() {
- return this.queryEvaluatorFactories;
- }
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Guyomar (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet + * Nicolas Guyomar (Mia-Software) - Bug 349566 - Need some new query utils method for query creation + * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; +import org.eclipse.papyrus.emf.facet.efacet.Query; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.QueryException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.Activator; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryEvaluator; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryEvaluatorFactory; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager; + +/** @deprecated replaced by {@link DerivedTypedElementImplementationFactoryRegistry} with the new eFacet2 metamodel */ +@Deprecated +public class QueryEvaluatorFactoryRegistry { + private static final String QUERY_EVALUATOR_REGISTRATION_ID = "org.eclipse.papyrus.emf.facet.efacet.core.query.evaluatorregistration"; //$NON-NLS-1$ + private static final String CLASS = "class"; //$NON-NLS-1$ + public static final QueryEvaluatorFactoryRegistry INSTANCE = new QueryEvaluatorFactoryRegistry(); + + private final List<IQueryEvaluatorFactory> queryEvaluatorFactories = new ArrayList<IQueryEvaluatorFactory>(); + + public QueryEvaluatorFactoryRegistry() { + initRegisteredEntries(); + } + + private void initRegisteredEntries() { + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint extPoint = registry + .getExtensionPoint(QueryEvaluatorFactoryRegistry.QUERY_EVALUATOR_REGISTRATION_ID); + if (extPoint != null) { + for (IExtension ext : extPoint.getExtensions()) { + for (IConfigurationElement configElt : ext.getConfigurationElements()) { + + IQueryEvaluatorFactory queryEvaluatorFactory; + try { + queryEvaluatorFactory = (IQueryEvaluatorFactory) configElt + .createExecutableExtension(QueryEvaluatorFactoryRegistry.CLASS); + + this.queryEvaluatorFactories.add(queryEvaluatorFactory); + } catch (CoreException e) { + Logger.logError(e, Activator.getDefault()); + } + } + } + } + } + + public IQueryEvaluator getEvaluatorFor(final Query query) throws QueryException { + IQueryEvaluator queryEvaluator = null; + boolean factoryFound = false; + for (IQueryEvaluatorFactory queryEvaluatorFactory : this.queryEvaluatorFactories) { + factoryFound = queryEvaluatorFactory.getManagedQueryType() == query.eClass(); + if (factoryFound) { + queryEvaluator = queryEvaluatorFactory.create(query, + ICatalogSetManager.INSTANCE.getBundleByResource(query.eResource())); + break; + } + } + if (!factoryFound) { + StringBuffer sb = new StringBuffer(); + sb.append("No factory implementation found for: "); //$NON-NLS-1$ + sb.append(query.eClass().getName()); + sb.append(":"); //$NON-NLS-1$ + sb.append(query.getName()); + sb.append("\n Available Query types are: "); //$NON-NLS-1$ + for (IQueryEvaluatorFactory queryEvaluatorFactory : this.queryEvaluatorFactories) { + sb.append(queryEvaluatorFactory.getManagedQueryType().getName()); + sb.append(", "); //$NON-NLS-1$ + } + QueryException e = new QueryException(sb.toString()); + throw e; + } + return queryEvaluator; + } + + public List<IQueryEvaluatorFactory> getInstalledQueryFactories() { + return this.queryEvaluatorFactories; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/QueryImplementationFactoryRegistry.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/QueryImplementationFactoryRegistry.java index 28f96285aa5..ae46d155b71 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/QueryImplementationFactoryRegistry.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/QueryImplementationFactoryRegistry.java @@ -1,127 +1,127 @@ -/*******************************************************************************
- * Copyright (c) 2012 CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.Activator;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManagerFactory;
-import org.osgi.framework.Bundle;
-
-public class QueryImplementationFactoryRegistry {
-
- private static final String EXT_ID = "org.eclipse.papyrus.emf.facet.efacet.core.queryImplementationRegistration"; //$NON-NLS-1$
-
- private static final String CLASS = "class"; //$NON-NLS-1$
-
- public static final QueryImplementationFactoryRegistry INSTANCE = new QueryImplementationFactoryRegistry();
-
- private static final Map<Query, IQueryImplementation> cache = new HashMap<Query, IQueryImplementation>();
-
- private final List<IQueryImplementationFactory> factories = new ArrayList<IQueryImplementationFactory>();
-
- public QueryImplementationFactoryRegistry() {
- initRegisteredEntries();
- }
-
- private void initRegisteredEntries() {
- final IExtensionRegistry registry = Platform.getExtensionRegistry();
- final IExtensionPoint extPoint = registry.getExtensionPoint(QueryImplementationFactoryRegistry.EXT_ID);
- if (extPoint != null) {
- for (final IExtension ext : extPoint.getExtensions()) {
- for (final IConfigurationElement configElt : ext.getConfigurationElements()) {
- try {
- final Object impl = configElt.createExecutableExtension(QueryImplementationFactoryRegistry.CLASS);
- if (impl instanceof IQueryImplementationFactory) {
- final IQueryImplementationFactory factory = (IQueryImplementationFactory) impl;
- this.factories.add(factory);
- } else {
- Logger.logError("Invalid extension in " + ext.getNamespaceIdentifier() + "." + //$NON-NLS-1$ //$NON-NLS-2$
- ". The factory must be an instance of " + IQueryImplementationFactory.class.getName(), Activator.getDefault()); //$NON-NLS-1$
- }
- } catch (final CoreException e) {
- Logger.logError(e, Activator.getDefault());
- }
- }
- }
- }
- }
-
- /**
- * Returns the query evaluator that handles the given type of query
- *
- * @param query
- * the type of query for which an {@link IQueryImplementation} is searched
- * @return the {@link IQueryImplementation}
- * @throws DerivedTypedElementException
- * if no factory implementation was registered for the type of the given query
- */
- public IQueryImplementation getEvaluatorFor(final Query query, final IDerivedTypedElementManager manager) throws DerivedTypedElementException {
- if (query == null) {
- throw new IllegalArgumentException("query cannot be null"); //$NON-NLS-1$
- }
-
- if (!cache.containsKey(query)) {
-
- IQueryImplementation queryImpl = null;
- boolean factoryFound = false;
- for (final IQueryImplementationFactory queryImplFactory : this.factories) {
- factoryFound = queryImplFactory.getManagedQueryType() == query.eClass();
- if (factoryFound) {
- final Resource queryResource = query.eResource();
- Bundle bundle = null;
- if (queryResource != null) {
- bundle = ICatalogSetManagerFactory.DEFAULT.createICatalogSetManager(query.eResource().getResourceSet()).getBundleByResource(queryResource);
- }
- queryImpl = queryImplFactory.create(query, bundle, manager);
- break;
- }
- }
- if (!factoryFound) {
- final StringBuffer buffer = new StringBuffer();
- buffer.append("No factory implementation found for "); //$NON-NLS-1$
- buffer.append(QueryUtils.getQueryDescription(query));
- buffer.append(".\nA factory should be registered through the "); //$NON-NLS-1$
- buffer.append(QueryImplementationFactoryRegistry.EXT_ID);
- buffer.append(" extension point."); //$NON-NLS-1$ // NOPMD: cannot merge with extracted constant string
- buffer.append("\nAvailable Query types are: "); //$NON-NLS-1$
- for (int i = 0; i < this.factories.size(); i++) {
- if (i > 0) {
- buffer.append(", "); //$NON-NLS-1$
- }
- final IQueryImplementationFactory factory = this.factories.get(i);
- buffer.append(factory.getManagedQueryType().getName());
- }
- throw new DerivedTypedElementException(buffer.toString());
- }
-
- cache.put(query, queryImpl);
- }
-
- return cache.get(query);
- }
-}
+/******************************************************************************* + * Copyright (c) 2012 CEA LIST. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtension; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.Activator; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManagerFactory; +import org.osgi.framework.Bundle; + +public class QueryImplementationFactoryRegistry { + + private static final String EXT_ID = "org.eclipse.papyrus.emf.facet.efacet.core.queryImplementationRegistration"; //$NON-NLS-1$ + + private static final String CLASS = "class"; //$NON-NLS-1$ + + public static final QueryImplementationFactoryRegistry INSTANCE = new QueryImplementationFactoryRegistry(); + + private static final Map<Query, IQueryImplementation> cache = new HashMap<Query, IQueryImplementation>(); + + private final List<IQueryImplementationFactory> factories = new ArrayList<IQueryImplementationFactory>(); + + public QueryImplementationFactoryRegistry() { + initRegisteredEntries(); + } + + private void initRegisteredEntries() { + final IExtensionRegistry registry = Platform.getExtensionRegistry(); + final IExtensionPoint extPoint = registry.getExtensionPoint(QueryImplementationFactoryRegistry.EXT_ID); + if (extPoint != null) { + for (final IExtension ext : extPoint.getExtensions()) { + for (final IConfigurationElement configElt : ext.getConfigurationElements()) { + try { + final Object impl = configElt.createExecutableExtension(QueryImplementationFactoryRegistry.CLASS); + if (impl instanceof IQueryImplementationFactory) { + final IQueryImplementationFactory factory = (IQueryImplementationFactory) impl; + this.factories.add(factory); + } else { + Logger.logError("Invalid extension in " + ext.getNamespaceIdentifier() + "." + //$NON-NLS-1$ //$NON-NLS-2$ + ". The factory must be an instance of " + IQueryImplementationFactory.class.getName(), Activator.getDefault()); //$NON-NLS-1$ + } + } catch (final CoreException e) { + Logger.logError(e, Activator.getDefault()); + } + } + } + } + } + + /** + * Returns the query evaluator that handles the given type of query + * + * @param query + * the type of query for which an {@link IQueryImplementation} is searched + * @return the {@link IQueryImplementation} + * @throws DerivedTypedElementException + * if no factory implementation was registered for the type of the given query + */ + public IQueryImplementation getEvaluatorFor(final Query query, final IDerivedTypedElementManager manager) throws DerivedTypedElementException { + if (query == null) { + throw new IllegalArgumentException("query cannot be null"); //$NON-NLS-1$ + } + + if (!cache.containsKey(query)) { + + IQueryImplementation queryImpl = null; + boolean factoryFound = false; + for (final IQueryImplementationFactory queryImplFactory : this.factories) { + factoryFound = queryImplFactory.getManagedQueryType() == query.eClass(); + if (factoryFound) { + final Resource queryResource = query.eResource(); + Bundle bundle = null; + if (queryResource != null) { + bundle = ICatalogSetManagerFactory.DEFAULT.createICatalogSetManager(query.eResource().getResourceSet()).getBundleByResource(queryResource); + } + queryImpl = queryImplFactory.create(query, bundle, manager); + break; + } + } + if (!factoryFound) { + final StringBuffer buffer = new StringBuffer(); + buffer.append("No factory implementation found for "); //$NON-NLS-1$ + buffer.append(QueryUtils.getQueryDescription(query)); + buffer.append(".\nA factory should be registered through the "); //$NON-NLS-1$ + buffer.append(QueryImplementationFactoryRegistry.EXT_ID); + buffer.append(" extension point."); //$NON-NLS-1$ // NOPMD: cannot merge with extracted constant string + buffer.append("\nAvailable Query types are: "); //$NON-NLS-1$ + for (int i = 0; i < this.factories.size(); i++) { + if (i > 0) { + buffer.append(", "); //$NON-NLS-1$ + } + final IQueryImplementationFactory factory = this.factories.get(i); + buffer.append(factory.getManagedQueryType().getName()); + } + throw new DerivedTypedElementException(buffer.toString()); + } + + cache.put(query, queryImpl); + } + + return cache.get(query); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/QueryUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/QueryUtils.java index 4a456e9a887..6f423f9e826 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/QueryUtils.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/QueryUtils.java @@ -1,120 +1,120 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Mia-Software
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
- * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.core.FacetUtils;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-
-public final class QueryUtils {
-
- private QueryUtils() {
- // utility class
- }
-
- /** @return a description to help identify this query in error messages */
- public static String getQueryDescription(final Query query) {
- StringBuffer sb = new StringBuffer();
- sb.append("[Query eClass:"); //$NON-NLS-1$
- sb.append(query.eClass().getName());
- DerivedTypedElement owningDerivedTypedElement = QueryUtils
- .getOwningDerivedTypedElement(query);
- if (owningDerivedTypedElement != null) {
- sb.append(" defined on "); //$NON-NLS-1$
- sb.append(owningDerivedTypedElement.getClass().getSimpleName());
- EClassifier eType = owningDerivedTypedElement.getEType();
- if (eType != null) {
- sb.append(" of type '"); //$NON-NLS-1$
- sb.append(eType.getName());
- sb.append("' named: '"); //$NON-NLS-1$
- } else {
- sb.append(" named: '"); //$NON-NLS-1$
- }
- sb.append(owningDerivedTypedElement.getName());
- sb.append("'"); //$NON-NLS-1$
- } else {
- sb.append(" with a null owning derived typed element"); //$NON-NLS-1$
- }
- sb.append("]"); //$NON-NLS-1$
- return sb.toString();
- }
-
- // Moved from
- // org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.impl.QueryImpl
- public static EClassifier getReturnType(final Query query) {
- EClassifier result = null;
- final DerivedTypedElement owningDTE = QueryUtils
- .getOwningDerivedTypedElement(query);
- if (owningDTE != null) {
- result = owningDTE.getEType();
- }
- return result;
- }
-
- // Moved from
- // org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.impl.QueryImpl
- public static EClassifier getSourceType(final Query query) {
- EClassifier result = null;
- final DerivedTypedElement owningDTE = QueryUtils
- .getOwningDerivedTypedElement(query);
- if (owningDTE != null) {
- final EObject eContainer = QueryUtils.getOwningDerivedTypedElement(
- query).eContainer();
- if (eContainer instanceof Facet) {
- final Facet facet = (Facet) eContainer;
- result = FacetUtils.getExtendedMetaclass(facet);
- } else if (eContainer instanceof ETypedElement) {
- final ETypedElement typedElement = (ETypedElement) eContainer;
- result = typedElement.getEType();
- }
- }
- return result;
- }
-
- // Moved from
- // org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.impl.QueryImpl
- public static DerivedTypedElement getOwningDerivedTypedElement(
- final Query query) {
- DerivedTypedElement result = null;
- EObject container = query.eContainer();
- while (container != null) {
- if (container instanceof DerivedTypedElement) {
- result = (DerivedTypedElement) container;
- break;
- }
- container = container.eContainer();
- }
- if (result == null) {
- throw new IllegalStateException("Query must always be contained by a DerivedTypedElement"); //$NON-NLS-1$
- }
- return (DerivedTypedElement) container;
-
- }
-
- // Moved from
- // org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.impl.QueryImpl
- public static boolean isMany(final Query query) {
- boolean result = false;
- final DerivedTypedElement owningDTE = QueryUtils
- .getOwningDerivedTypedElement(query);
- if (owningDTE != null) {
- result = owningDTE.isMany();
- }
- return result;
- }
-}
+/******************************************************************************* + * Copyright (c) 2011, 2012 Mia-Software + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel + * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2 + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.papyrus.emf.facet.efacet.core.FacetUtils; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; + +public final class QueryUtils { + + private QueryUtils() { + // utility class + } + + /** @return a description to help identify this query in error messages */ + public static String getQueryDescription(final Query query) { + StringBuffer sb = new StringBuffer(); + sb.append("[Query eClass:"); //$NON-NLS-1$ + sb.append(query.eClass().getName()); + DerivedTypedElement owningDerivedTypedElement = QueryUtils + .getOwningDerivedTypedElement(query); + if (owningDerivedTypedElement != null) { + sb.append(" defined on "); //$NON-NLS-1$ + sb.append(owningDerivedTypedElement.getClass().getSimpleName()); + EClassifier eType = owningDerivedTypedElement.getEType(); + if (eType != null) { + sb.append(" of type '"); //$NON-NLS-1$ + sb.append(eType.getName()); + sb.append("' named: '"); //$NON-NLS-1$ + } else { + sb.append(" named: '"); //$NON-NLS-1$ + } + sb.append(owningDerivedTypedElement.getName()); + sb.append("'"); //$NON-NLS-1$ + } else { + sb.append(" with a null owning derived typed element"); //$NON-NLS-1$ + } + sb.append("]"); //$NON-NLS-1$ + return sb.toString(); + } + + // Moved from + // org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.impl.QueryImpl + public static EClassifier getReturnType(final Query query) { + EClassifier result = null; + final DerivedTypedElement owningDTE = QueryUtils + .getOwningDerivedTypedElement(query); + if (owningDTE != null) { + result = owningDTE.getEType(); + } + return result; + } + + // Moved from + // org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.impl.QueryImpl + public static EClassifier getSourceType(final Query query) { + EClassifier result = null; + final DerivedTypedElement owningDTE = QueryUtils + .getOwningDerivedTypedElement(query); + if (owningDTE != null) { + final EObject eContainer = QueryUtils.getOwningDerivedTypedElement( + query).eContainer(); + if (eContainer instanceof Facet) { + final Facet facet = (Facet) eContainer; + result = FacetUtils.getExtendedMetaclass(facet); + } else if (eContainer instanceof ETypedElement) { + final ETypedElement typedElement = (ETypedElement) eContainer; + result = typedElement.getEType(); + } + } + return result; + } + + // Moved from + // org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.impl.QueryImpl + public static DerivedTypedElement getOwningDerivedTypedElement( + final Query query) { + DerivedTypedElement result = null; + EObject container = query.eContainer(); + while (container != null) { + if (container instanceof DerivedTypedElement) { + result = (DerivedTypedElement) container; + break; + } + container = container.eContainer(); + } + if (result == null) { + throw new IllegalStateException("Query must always be contained by a DerivedTypedElement"); //$NON-NLS-1$ + } + return (DerivedTypedElement) container; + + } + + // Moved from + // org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.impl.QueryImpl + public static boolean isMany(final Query query) { + boolean result = false; + final DerivedTypedElement owningDTE = QueryUtils + .getOwningDerivedTypedElement(query); + if (owningDTE != null) { + result = owningDTE.isMany(); + } + return result; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/QueryUtilsImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/QueryUtilsImpl.java index b600cb17e73..1fd305343eb 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/QueryUtilsImpl.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/QueryUtilsImpl.java @@ -1,64 +1,64 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
- * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.papyrus.emf.facet.efacet.Query;
-import org.eclipse.papyrus.emf.facet.efacet.QuerySet;
-import org.eclipse.papyrus.emf.facet.efacet.catalog.efacetcatalog.QuerySetCatalog;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryUtils;
-import org.eclipse.papyrus.emf.facet.util.emf.catalog.Catalog;
-import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager;
-
-/**
- * @deprecated This class manipulated the old facet metamodel. With the new eFacet2 metamodel, there
- * are no QuerySets anymore. Queries are used only in Facets.
- */
-@Deprecated
-public class QueryUtilsImpl implements IQueryUtils {
-
- public Query searchQuery(final String querySetName, final String queryName) {
- List<QuerySetCatalog> querySetCatalogs = new ArrayList<QuerySetCatalog>();
- List<Catalog> catalogs = ICatalogSetManager.INSTANCE.getCatalogSet()
- .getCatalogs();
- for (Catalog catalog : catalogs) {
- if (catalog instanceof QuerySetCatalog) {
- querySetCatalogs.add((QuerySetCatalog) catalog);
- }
- }
-
- QuerySet searchedQuerySet = null;
- for (QuerySetCatalog querySetCatalog : querySetCatalogs) {
- List<QuerySet> querySets = querySetCatalog.getInstalledQuerySets();
- for (QuerySet querySet : querySets) {
- if (querySet.getName() != null
- && querySet.getName().equals(querySetName)) {
- searchedQuerySet = querySet;
- }
- }
- }
- Query searchedQuery = null;
- if (searchedQuerySet != null) {
- for (Query query : searchedQuerySet.getQueries()) {
- if (query.getName() != null
- && query.getName().equals(queryName)) {
- searchedQuery = query;
- }
- }
- }
- return searchedQuery;
- }
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet + * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.papyrus.emf.facet.efacet.Query; +import org.eclipse.papyrus.emf.facet.efacet.QuerySet; +import org.eclipse.papyrus.emf.facet.efacet.catalog.efacetcatalog.QuerySetCatalog; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryUtils; +import org.eclipse.papyrus.emf.facet.util.emf.catalog.Catalog; +import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager; + +/** + * @deprecated This class manipulated the old facet metamodel. With the new eFacet2 metamodel, there + * are no QuerySets anymore. Queries are used only in Facets. + */ +@Deprecated +public class QueryUtilsImpl implements IQueryUtils { + + public Query searchQuery(final String querySetName, final String queryName) { + List<QuerySetCatalog> querySetCatalogs = new ArrayList<QuerySetCatalog>(); + List<Catalog> catalogs = ICatalogSetManager.INSTANCE.getCatalogSet() + .getCatalogs(); + for (Catalog catalog : catalogs) { + if (catalog instanceof QuerySetCatalog) { + querySetCatalogs.add((QuerySetCatalog) catalog); + } + } + + QuerySet searchedQuerySet = null; + for (QuerySetCatalog querySetCatalog : querySetCatalogs) { + List<QuerySet> querySets = querySetCatalog.getInstalledQuerySets(); + for (QuerySet querySet : querySets) { + if (querySet.getName() != null + && querySet.getName().equals(querySetName)) { + searchedQuerySet = querySet; + } + } + } + Query searchedQuery = null; + if (searchedQuerySet != null) { + for (Query query : searchedQuerySet.getQueries()) { + if (query.getName() != null + && query.getName().equals(queryName)) { + searchedQuery = query; + } + } + } + return searchedQuery; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/StringLiteralQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/StringLiteralQueryImplementation.java index 96e3e233b8a..41f86d87e40 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/StringLiteralQueryImplementation.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/StringLiteralQueryImplementation.java @@ -1,49 +1,49 @@ -/**
- * Copyright (c) 2011, 2012 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- Olivier Remaud (Soft-Maint) - Bug 369824 - Add a simple way to return string literal constants from a customization query
- Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- */
-
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.StringLiteralQuery;
-
-public class StringLiteralQueryImplementation implements IQueryImplementation {
-
- private boolean checkResultType = false;
-
- public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager)
- throws DerivedTypedElementException {
- return ((StringLiteralQuery) query).getValue();
- }
-
- public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue)
- throws DerivedTypedElementException {
- throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$
- }
-
- public void setCheckResultType(final boolean checkResultType) {
- this.checkResultType = checkResultType;
- }
-
- public boolean isCheckResultType() {
- return this.checkResultType;
- }
-}
+/** + * Copyright (c) 2011, 2012 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + Olivier Remaud (Soft-Maint) - Bug 369824 - Add a simple way to return string literal constants from a customization query + Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + */ + +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.StringLiteralQuery; + +public class StringLiteralQueryImplementation implements IQueryImplementation { + + private boolean checkResultType = false; + + public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final IFacetManager facetManager) + throws DerivedTypedElementException { + return ((StringLiteralQuery) query).getValue(); + } + + public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, final Object newValue) + throws DerivedTypedElementException { + throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$ + } + + public void setCheckResultType(final boolean checkResultType) { + this.checkResultType = checkResultType; + } + + public boolean isCheckResultType() { + return this.checkResultType; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/StringLiteralQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/StringLiteralQueryImplementationFactory.java index de9570f5144..627501f2f37 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/StringLiteralQueryImplementationFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/StringLiteralQueryImplementationFactory.java @@ -1,36 +1,36 @@ -/**
- * Copyright (c) 2011, 2012 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- Olivier Remaud (Soft-Maint) - Bug 369824 - Add a simple way to return string literal constants from a customization query
- Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage;
-import org.osgi.framework.Bundle;
-
-public class StringLiteralQueryImplementationFactory implements IQueryImplementationFactory {
-
- public EClass getManagedQueryType() {
- return QueryPackage.eINSTANCE.getStringLiteralQuery();
- }
-
- public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException {
- final StringLiteralQueryImplementation evaluator = new StringLiteralQueryImplementation();
- evaluator.setCheckResultType(true);
- return evaluator;
- }
-
-}
+/** + * Copyright (c) 2011, 2012 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + Olivier Remaud (Soft-Maint) - Bug 369824 - Add a simple way to return string literal constants from a customization query + Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage; +import org.osgi.framework.Bundle; + +public class StringLiteralQueryImplementationFactory implements IQueryImplementationFactory { + + public EClass getManagedQueryType() { + return QueryPackage.eINSTANCE.getStringLiteralQuery(); + } + + public IQueryImplementation create(final Query query, final Bundle queryBundle, final IDerivedTypedElementManager manager) throws DerivedTypedElementException { + final StringLiteralQueryImplementation evaluator = new StringLiteralQueryImplementation(); + evaluator.setCheckResultType(true); + return evaluator; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/TrueLiteralQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/TrueLiteralQueryImplementation.java index a736e63d54f..3752d8cba6b 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/TrueLiteralQueryImplementation.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/TrueLiteralQueryImplementation.java @@ -1,48 +1,48 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-
-public class TrueLiteralQueryImplementation implements IQueryImplementation {
-
- private boolean checkResultType = false;
-
- public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues,
- final IFacetManager facetManager)
- throws DerivedTypedElementException {
- return Boolean.TRUE;
- }
-
- public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues,
- final Object newValue)
- throws DerivedTypedElementException {
- throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$
- }
-
- public void setCheckResultType(final boolean checkResultType) {
- this.checkResultType = checkResultType;
- }
-
- public boolean isCheckResultType() {
- return this.checkResultType;
- }
-}
+/** + * Copyright (c) 2012 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; + +public class TrueLiteralQueryImplementation implements IQueryImplementation { + + private boolean checkResultType = false; + + public Object getValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, + final IFacetManager facetManager) + throws DerivedTypedElementException { + return Boolean.TRUE; + } + + public void setValue(final Query query, final DerivedTypedElement feature, final EObject source, final List<ParameterValue> parameterValues, + final Object newValue) + throws DerivedTypedElementException { + throw new DerivedTypedElementEvaluationException("Not implemented"); //$NON-NLS-1$ + } + + public void setCheckResultType(final boolean checkResultType) { + this.checkResultType = checkResultType; + } + + public boolean isCheckResultType() { + return this.checkResultType; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/TrueLiteralQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/TrueLiteralQueryImplementationFactory.java index 182c2bea0a4..17f1b087b97 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/TrueLiteralQueryImplementationFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/query/TrueLiteralQueryImplementationFactory.java @@ -1,36 +1,36 @@ -/**
- * Copyright (c) 2012 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Grégoire Dupé (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.query;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage;
-import org.osgi.framework.Bundle;
-
-public class TrueLiteralQueryImplementationFactory implements IQueryImplementationFactory {
-
- public IQueryImplementation create(final Query query, final Bundle bundle, final IDerivedTypedElementManager derivedTEManager)
- throws DerivedTypedElementException {
- final TrueLiteralQueryImplementation evaluator = new TrueLiteralQueryImplementation();
- evaluator.setCheckResultType(false);
- return evaluator;
- }
-
- public EClass getManagedQueryType() {
- return QueryPackage.eINSTANCE.getTrueLiteralQuery();
- }
-
-}
+/** + * Copyright (c) 2012 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Grégoire Dupé (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.query; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementation; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryImplementationFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.query.QueryPackage; +import org.osgi.framework.Bundle; + +public class TrueLiteralQueryImplementationFactory implements IQueryImplementationFactory { + + public IQueryImplementation create(final Query query, final Bundle bundle, final IDerivedTypedElementManager derivedTEManager) + throws DerivedTypedElementException { + final TrueLiteralQueryImplementation evaluator = new TrueLiteralQueryImplementation(); + evaluator.setCheckResultType(false); + return evaluator; + } + + public EClass getManagedQueryType() { + return QueryPackage.eINSTANCE.getTrueLiteralQuery(); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/serialization/ILinkToExtendedEObjectReference.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/serialization/ILinkToExtendedEObjectReference.java index 8cb9b9164b5..bd4ea52d32d 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/serialization/ILinkToExtendedEObjectReference.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/serialization/ILinkToExtendedEObjectReference.java @@ -1,33 +1,33 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia-Software
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.serialization;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.ExtendedEObjectReference;
-
-/**
- * Interface for the adapter that attaches {@link ExtendedEObjectReference} to {@link EObject}s.
- *
- * @since 0.2
- */
-public interface ILinkToExtendedEObjectReference {
-
- /**
- * @return the current {@link ExtendedEObjectReference}.
- */
- public ExtendedEObjectReference getExtendedEObjectReference();
-
- /**
- * Replace the current ExtendedEObjectReference by {@link ExtendedEObjectReference}.
- */
- public void setExtendedEObjectReference(ExtendedEObjectReference extendedEObjectReference);
-
-}
+/******************************************************************************* + * Copyright (c) 2011 Mia-Software + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values. + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.serialization; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.ExtendedEObjectReference; + +/** + * Interface for the adapter that attaches {@link ExtendedEObjectReference} to {@link EObject}s. + * + * @since 0.2 + */ +public interface ILinkToExtendedEObjectReference { + + /** + * @return the current {@link ExtendedEObjectReference}. + */ + public ExtendedEObjectReference getExtendedEObjectReference(); + + /** + * Replace the current ExtendedEObjectReference by {@link ExtendedEObjectReference}. + */ + public void setExtendedEObjectReference(ExtendedEObjectReference extendedEObjectReference); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/serialization/ILinkToExtendedEObjectReferenceAdapterFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/serialization/ILinkToExtendedEObjectReferenceAdapterFactory.java index fd8979a4563..3ddfdbe5c08 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/serialization/ILinkToExtendedEObjectReferenceAdapterFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/serialization/ILinkToExtendedEObjectReferenceAdapterFactory.java @@ -1,39 +1,39 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.serialization;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.common.notify.Notifier;
-
-/**
- * Factory to create {@link ILinkToExtendedEObjectReference} adapters.
- *
- */
-public interface ILinkToExtendedEObjectReferenceAdapterFactory extends AdapterFactory {
-
- /**
- * Singleton {@link LinkToExtendedEObjectReferenceAdapterFactory}
- */
- public static ILinkToExtendedEObjectReferenceAdapterFactory INSTANCE = new LinkToExtendedEObjectReferenceAdapterFactory();
-
- /**
- * This method returns <code>true</code> if this factory is a factory for the given type {@link Object}, or <code>false</code> otherwise
- */
- public boolean isFactoryForType(final Object type);
-
- /**
- * Creates a new instance of Adapter for the given {@link Notifier}
- */
- public Adapter createAdapter(final Notifier target);
-
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values. + */ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.serialization; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notifier; + +/** + * Factory to create {@link ILinkToExtendedEObjectReference} adapters. + * + */ +public interface ILinkToExtendedEObjectReferenceAdapterFactory extends AdapterFactory { + + /** + * Singleton {@link LinkToExtendedEObjectReferenceAdapterFactory} + */ + public static ILinkToExtendedEObjectReferenceAdapterFactory INSTANCE = new LinkToExtendedEObjectReferenceAdapterFactory(); + + /** + * This method returns <code>true</code> if this factory is a factory for the given type {@link Object}, or <code>false</code> otherwise + */ + public boolean isFactoryForType(final Object type); + + /** + * Creates a new instance of Adapter for the given {@link Notifier} + */ + public Adapter createAdapter(final Notifier target); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/serialization/LinkToExtendedEObjectReferenceAdapter.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/serialization/LinkToExtendedEObjectReferenceAdapter.java index 71c6b709fc0..a37bfd5e1e9 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/serialization/LinkToExtendedEObjectReferenceAdapter.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/serialization/LinkToExtendedEObjectReferenceAdapter.java @@ -1,34 +1,34 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia-Software
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.serialization;
-
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.ExtendedEObjectReference;
-
-public class LinkToExtendedEObjectReferenceAdapter extends AdapterImpl implements
- ILinkToExtendedEObjectReference {
-
- private ExtendedEObjectReference extendedEObjectReference;
-
- public ExtendedEObjectReference getExtendedEObjectReference() {
- return this.extendedEObjectReference;
- }
-
- public void setExtendedEObjectReference(final ExtendedEObjectReference extendedEObjectReference) {
- this.extendedEObjectReference = extendedEObjectReference;
- }
-
- @Override
- public boolean isAdapterForType(final Object type) {
- return type == ILinkToExtendedEObjectReference.class;
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2011 Mia-Software + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values. + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.serialization; + +import org.eclipse.emf.common.notify.impl.AdapterImpl; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.ExtendedEObjectReference; + +public class LinkToExtendedEObjectReferenceAdapter extends AdapterImpl implements + ILinkToExtendedEObjectReference { + + private ExtendedEObjectReference extendedEObjectReference; + + public ExtendedEObjectReference getExtendedEObjectReference() { + return this.extendedEObjectReference; + } + + public void setExtendedEObjectReference(final ExtendedEObjectReference extendedEObjectReference) { + this.extendedEObjectReference = extendedEObjectReference; + } + + @Override + public boolean isAdapterForType(final Object type) { + return type == ILinkToExtendedEObjectReference.class; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/serialization/LinkToExtendedEObjectReferenceAdapterFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/serialization/LinkToExtendedEObjectReferenceAdapterFactory.java index daec83dd61c..d9d23dd8337 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/serialization/LinkToExtendedEObjectReferenceAdapterFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/serialization/LinkToExtendedEObjectReferenceAdapterFactory.java @@ -1,29 +1,29 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia-Software
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.serialization;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
-
-public class LinkToExtendedEObjectReferenceAdapterFactory extends AdapterFactoryImpl implements ILinkToExtendedEObjectReferenceAdapterFactory {
-
- @Override
- public boolean isFactoryForType(final Object type) {
- return type == ILinkToExtendedEObjectReference.class;
- }
-
- @Override
- public Adapter createAdapter(final Notifier target) {
- return new LinkToExtendedEObjectReferenceAdapter();
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2011 Mia-Software + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values. + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.serialization; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; + +public class LinkToExtendedEObjectReferenceAdapterFactory extends AdapterFactoryImpl implements ILinkToExtendedEObjectReferenceAdapterFactory { + + @Override + public boolean isFactoryForType(final Object type) { + return type == ILinkToExtendedEObjectReference.class; + } + + @Override + public Adapter createAdapter(final Notifier target) { + return new LinkToExtendedEObjectReferenceAdapter(); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/serialization/SerializationManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/serialization/SerializationManager.java index 0875b0a50a0..f1c5e504461 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/serialization/SerializationManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/internal/serialization/SerializationManager.java @@ -1,426 +1,426 @@ -/*******************************************************************************
- * Copyright (c) 2011 Mia-Software
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
- * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel
- * Grégoire Dupé (Mia-Software) - Bug 361612 - [Restructuring] New core for new version of the Facet metamodel
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.internal.serialization;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.SaveStructuralFeatureInstanceModelException;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.AbstractAttributeInstance;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.AbstractReferenceInstance;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.ExtendedEObjectReference;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.MultiValuedAttributeInstance;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.MultiValuedContainmentReferenceInstance;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.MultiValuedReferenceInstance;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.SerializationFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.SingleValuedAttributeInstance;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.SingleValuedContainmentReferenceInstance;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.SingleValuedReferenceInstance;
-
-public class SerializationManager {
-
- private final Resource structuralFeatureInstancesResource;
-
- public SerializationManager(final Resource structuralFeatureInstancesResource) {
- this.structuralFeatureInstancesResource = structuralFeatureInstancesResource;
- if (structuralFeatureInstancesResource != null) {
- final EList<EObject> contents = structuralFeatureInstancesResource.getContents();
- for (EObject eObject : contents) {
- if (eObject instanceof ExtendedEObjectReference) {
- final ExtendedEObjectReference extendedEObjectReference = (ExtendedEObjectReference) eObject;
- final LinkToExtendedEObjectReferenceAdapter adapter = (LinkToExtendedEObjectReferenceAdapter) ILinkToExtendedEObjectReferenceAdapterFactory.INSTANCE
- .adapt(extendedEObjectReference.getExtendedEObject(),
- ILinkToExtendedEObjectReference.class);
- adapter.setExtendedEObjectReference(extendedEObjectReference);
- }
- }
- }
- }
-
- /**
- * This method creates a ReferenceInstance in the given {@link ExtendedEObjectReference} with
- * the reference {@link EStructuralFeature} and the value {@link Object}.
- */
- private static MultiValuedContainmentReferenceInstance createMultiValuedContainmentReferenceInstance(final EReference reference,
- final List<EObject> values,
- final ExtendedEObjectReference extendedEObjectReference) {
- final MultiValuedContainmentReferenceInstance containmentReferenceInstance = SerializationFactory.eINSTANCE
- .createMultiValuedContainmentReferenceInstance();
- containmentReferenceInstance.setEReference(reference);
- if (values != null) {
- containmentReferenceInstance.getOwnedElements().addAll(values);
- }
- extendedEObjectReference.getReferenceInstances().add(containmentReferenceInstance);
- return containmentReferenceInstance;
- }
-
- /**
- * This method returns the {@link ExtendedEObjectReference} associated with the given {@link EObject} if it exists or <code>null</code> if it does not exist.
- */
- private static ExtendedEObjectReference getExtendedEObjectReference(final EObject eObject) {
- ExtendedEObjectReference result = null;
- for (final Adapter adapter : eObject.eAdapters()) {
- if (adapter.isAdapterForType(ILinkToExtendedEObjectReference.class)) {
- final LinkToExtendedEObjectReferenceAdapter linkToExtendedEObjectReferenceAdapter = (LinkToExtendedEObjectReferenceAdapter) adapter;
- result = linkToExtendedEObjectReferenceAdapter.getExtendedEObjectReference();
- break;
- }
- }
- return result;
- }
-
- /**
- * This method creates an AttributeInstance in the given {@link ExtendedEObjectReference} with
- * the attribute {@link EStructuralFeature} and the value {@link Object}.
- */
- private static MultiValuedAttributeInstance createMultiValuedAttributeInstance(final EAttribute attribute, final List<Object> values,
- final ExtendedEObjectReference extendedEObjectReference) {
- final MultiValuedAttributeInstance attributeInstance = SerializationFactory.eINSTANCE.createMultiValuedAttributeInstance();
- attributeInstance.setEAttribute(attribute);
- if (values != null) {
- attributeInstance.getValues().addAll(values);
- }
- extendedEObjectReference.getAttributeInstances().add(attributeInstance);
- return attributeInstance;
- }
-
- /**
- * This method creates a ReferenceInstance in the given {@link ExtendedEObjectReference} with
- * the reference {@link EStructuralFeature} and the value {@link Object}.
- */
- private static MultiValuedReferenceInstance createMultiValuedReferenceInstance(final EReference reference, final List<EObject> values,
- final ExtendedEObjectReference extendedEObjectReference) {
- final MultiValuedReferenceInstance referenceInstance = SerializationFactory.eINSTANCE
- .createMultiValuedReferenceInstance();
- referenceInstance.setEReference(reference);
- if (values != null) {
- referenceInstance.getReferencedElements().addAll(values);
- }
- extendedEObjectReference.getReferenceInstances().add(referenceInstance);
- return referenceInstance;
- }
-
- private static SingleValuedAttributeInstance getSingleValuedAttributeInstance(final ExtendedEObjectReference extendedEObjectReference,
- final EAttribute eAttribute) {
- SingleValuedAttributeInstance result = null;
- final EList<AbstractAttributeInstance> attributeInstances = extendedEObjectReference.getAttributeInstances();
- for (final AbstractAttributeInstance attributeInstance : attributeInstances) {
- if (eAttribute.equals(attributeInstance.getEAttribute())) {
- if (attributeInstance instanceof SingleValuedAttributeInstance) {
- result = (SingleValuedAttributeInstance) attributeInstance;
- break;
- }
- throw new IllegalStateException("single valued attribute should be associated to an instance of SingleValuedAttributeInstance"); //$NON-NLS-1$
- }
- }
- return result;
- }
-
- private static MultiValuedAttributeInstance getMultiValuedAttributeInstance(final ExtendedEObjectReference extendedEObjectReference,
- final EAttribute eAttribute) {
- MultiValuedAttributeInstance result = null;
- final EList<AbstractAttributeInstance> attributeInstances = extendedEObjectReference.getAttributeInstances();
- for (final AbstractAttributeInstance attributeInstance : attributeInstances) {
- if (eAttribute.equals(attributeInstance.getEAttribute())) {
- if (attributeInstance instanceof MultiValuedAttributeInstance) {
- result = (MultiValuedAttributeInstance) attributeInstance;
- break;
- }
- throw new IllegalStateException("multi valued attribute should be associated to an instance of MultiValuedAttributeInstance"); //$NON-NLS-1$
-
- }
- }
- return result;
- }
-
- private static SingleValuedReferenceInstance getSingleValuedReferenceInstance(final ExtendedEObjectReference extendedEObjectReference,
- final EReference eReference) {
- SingleValuedReferenceInstance result = null;
- final EList<AbstractReferenceInstance> referenceInstances = extendedEObjectReference.getReferenceInstances();
- for (final AbstractReferenceInstance referenceInstance : referenceInstances) {
- if (eReference.equals(referenceInstance.getEReference())) {
- if (referenceInstance instanceof SingleValuedReferenceInstance) {
- result = (SingleValuedReferenceInstance) referenceInstance;
- break;
- }
- throw new IllegalStateException("a single valued non-containment reference should be associated to an instance of SingleValuedReferenceInstance"); //$NON-NLS-1$
- }
- }
- return result;
- }
-
- private static SingleValuedContainmentReferenceInstance getSingleValuedContainmentReferenceInstance(
- final ExtendedEObjectReference extendedEObjectReference,
- final EReference eReference) {
- SingleValuedContainmentReferenceInstance result = null;
- final EList<AbstractReferenceInstance> referenceInstances = extendedEObjectReference.getReferenceInstances();
- for (final AbstractReferenceInstance referenceInstance : referenceInstances) {
- if (eReference.equals(referenceInstance.getEReference())) {
- if (referenceInstance instanceof SingleValuedContainmentReferenceInstance) {
- result = (SingleValuedContainmentReferenceInstance) referenceInstance;
- break;
- }
- throw new IllegalStateException("a single valued containment reference should be associated to an instance of SingleValuedContainmentReferenceInstance"); //$NON-NLS-1$
- }
- }
- return result;
- }
-
- private static MultiValuedReferenceInstance getMultiValuedReferenceInstance(final ExtendedEObjectReference extendedEObjectReference,
- final EReference eReference) {
- MultiValuedReferenceInstance result = null;
- final EList<AbstractReferenceInstance> referenceInstances = extendedEObjectReference.getReferenceInstances();
- for (final AbstractReferenceInstance referenceInstance : referenceInstances) {
- if (eReference.equals(referenceInstance.getEReference())) {
- if (referenceInstance instanceof MultiValuedReferenceInstance) {
- result = (MultiValuedReferenceInstance) referenceInstance;
- break;
- }
- throw new IllegalStateException("a multi valued non-containment reference should be associated to an instance of MultiValuedReferenceInstance"); //$NON-NLS-1$
- }
- }
- return result;
- }
-
- private static MultiValuedContainmentReferenceInstance getMultiValuedContainmentReferenceInstance(final ExtendedEObjectReference extendedEObjectReference,
- final EReference eReference) {
- MultiValuedContainmentReferenceInstance result = null;
- final EList<AbstractReferenceInstance> referenceInstances = extendedEObjectReference.getReferenceInstances();
- for (final AbstractReferenceInstance referenceInstance : referenceInstances) {
- if (eReference.equals(referenceInstance.getEReference())) {
- if (referenceInstance instanceof MultiValuedContainmentReferenceInstance) {
- result = (MultiValuedContainmentReferenceInstance) referenceInstance;
- break;
- }
- throw new IllegalStateException("a multi valued containment reference should be associated to an instance of MultiValuedContainmentReferenceInstance"); //$NON-NLS-1$
- }
- }
- return result;
- }
-
- public void saveStructuralFeatureInstanceModel()
- throws SaveStructuralFeatureInstanceModelException {
- if (this.structuralFeatureInstancesResource == null) {
- throw new SaveStructuralFeatureInstanceModelException("This facet manager has been initailized with a null structural feature instances resource"); //$NON-NLS-1$
- }
- try {
- this.structuralFeatureInstancesResource.save(Collections.EMPTY_MAP);
- } catch (final IOException e) {
- throw new SaveStructuralFeatureInstanceModelException(e);
- }
- }
-
- /**
- * This method returns the ExtendedEObjectReference associated with the given {@link EObject} if
- * it exists or creates it if it does not exist.
- */
- private ExtendedEObjectReference getOrCreateExtendedEObjectReference(final EObject eObject) {
- ExtendedEObjectReference extendedEObjectReference = SerializationManager.getExtendedEObjectReference(eObject);
- if (extendedEObjectReference == null) {
- extendedEObjectReference = SerializationFactory.eINSTANCE.createExtendedEObjectReference();
- extendedEObjectReference.setExtendedEObject(eObject);
- if (this.structuralFeatureInstancesResource != null) {
- this.structuralFeatureInstancesResource.getContents().add(extendedEObjectReference);
- }
- final LinkToExtendedEObjectReferenceAdapter adapter = (LinkToExtendedEObjectReferenceAdapter) ILinkToExtendedEObjectReferenceAdapterFactory.INSTANCE
- .adapt(eObject, ILinkToExtendedEObjectReference.class);
- adapter.setExtendedEObjectReference(extendedEObjectReference);
- }
- return extendedEObjectReference;
- }
-
- public void setAttribute(final EObject eObject, final EAttribute attribute, final Object newValue) {
- final ExtendedEObjectReference extendedEObjectReference = this.getOrCreateExtendedEObjectReference(eObject);
- if (attribute.isMany()) {
- if (newValue instanceof List) {
- // safe to cast
- @SuppressWarnings("unchecked")
- final List<Object> list = (List<Object>) newValue;
- final MultiValuedAttributeInstance attributeInstance =
- SerializationManager.getMultiValuedAttributeInstance(extendedEObjectReference, attribute);
- if (attributeInstance == null) {
- SerializationManager.createMultiValuedAttributeInstance(attribute, list, extendedEObjectReference);
- } else {
- attributeInstance.getValues().clear();
- attributeInstance.getValues().addAll(list);
- }
- } else {
- throw new IllegalArgumentException("The given FacetAttribute is multiplicity-many, so the value must be a List"); //$NON-NLS-1$
- }
- } else {
- final SingleValuedAttributeInstance attributeInstance =
- SerializationManager.getSingleValuedAttributeInstance(extendedEObjectReference, attribute);
- if (attributeInstance == null) {
- createSingleValuedAttributeInstance(attribute, newValue, extendedEObjectReference);
- } else {
- attributeInstance.setValue(newValue);
- }
- }
-
- }
-
-
- /**
- * This method creates an AttributeInstance in the given {@link ExtendedEObjectReference} with
- * the attribute {@link EStructuralFeature} and the value {@link Object}.
- */
- private static SingleValuedAttributeInstance createSingleValuedAttributeInstance(final EAttribute attribute, final Object value,
- final ExtendedEObjectReference extendedEObjectReference) {
- final SingleValuedAttributeInstance attributeInstance = SerializationFactory.eINSTANCE.createSingleValuedAttributeInstance();
- attributeInstance.setEAttribute(attribute);
- attributeInstance.setValue(value);
- extendedEObjectReference.getAttributeInstances().add(attributeInstance);
- return attributeInstance;
- }
-
- /**
- * This method creates a ReferenceInstance in the given {@link ExtendedEObjectReference} with
- * the reference {@link EStructuralFeature} and the value {@link Object}.
- */
- private static SingleValuedReferenceInstance createSingleValuedReferenceInstance(final EReference reference, final EObject value,
- final ExtendedEObjectReference extendedEObjectReference) {
- final SingleValuedReferenceInstance referenceInstance = SerializationFactory.eINSTANCE
- .createSingleValuedReferenceInstance();
- referenceInstance.setEReference(reference);
- referenceInstance.setReferencedElement(value);
- extendedEObjectReference.getReferenceInstances().add(referenceInstance);
- return referenceInstance;
- }
-
- public void setReference(final EObject eObject, final EReference reference, final Object newValue) {
- final ExtendedEObjectReference extendedEObjectReference = this.getOrCreateExtendedEObjectReference(eObject);
- if (reference.isMany()) {
- throw new UnsupportedOperationException("The given FacetReference is multi-valued : add elements to the list returned by getMultiValuedReference() instead"); //$NON-NLS-1$
- }
- if (!(newValue instanceof EObject)) {
- throw new IllegalArgumentException("newValue should be an EObject because eStructuralFeature is an EReference"); //$NON-NLS-1$
- }
- final EObject newEObjectValue = (EObject) newValue;
- if (reference.isContainment()) {
- final SingleValuedContainmentReferenceInstance referenceInstance =
- SerializationManager.getSingleValuedContainmentReferenceInstance(extendedEObjectReference, reference);
- if (referenceInstance == null) {
- createSingleValuedContainmentReferenceInstance(reference, newEObjectValue, extendedEObjectReference);
- } else {
- referenceInstance.setOwnedElement(newEObjectValue);
- }
- } else {
- final SingleValuedReferenceInstance referenceInstance =
- SerializationManager.getSingleValuedReferenceInstance(extendedEObjectReference, reference);
- if (referenceInstance == null) {
- createSingleValuedReferenceInstance(reference, newEObjectValue, extendedEObjectReference);
- } else {
- referenceInstance.setReferencedElement(newEObjectValue);
- }
- }
-
- }
-
- /**
- * This method creates a ReferenceInstance in the given {@link ExtendedEObjectReference} with
- * the reference {@link EStructuralFeature} and the value {@link Object}.
- */
- private static SingleValuedContainmentReferenceInstance createSingleValuedContainmentReferenceInstance(final EReference reference,
- final EObject value,
- final ExtendedEObjectReference extendedEObjectReference) {
- final SingleValuedContainmentReferenceInstance containmentReferenceInstance = SerializationFactory.eINSTANCE
- .createSingleValuedContainmentReferenceInstance();
- containmentReferenceInstance.setEReference(reference);
- containmentReferenceInstance.setOwnedElement(value);
- extendedEObjectReference.getReferenceInstances().add(containmentReferenceInstance);
- return containmentReferenceInstance;
- }
-
- private Object getMultiValuedStructuralFeature(final EObject eObject, final EStructuralFeature structuralFeature) {
- Object result = null;
- final ExtendedEObjectReference extendedEObjectReference = this.getOrCreateExtendedEObjectReference(eObject);
- if (structuralFeature instanceof EAttribute) {
- final EAttribute eAttribute = (EAttribute) structuralFeature;
- final MultiValuedAttributeInstance attributeInstance =
- SerializationManager.getMultiValuedAttributeInstance(extendedEObjectReference, eAttribute);
- if (attributeInstance != null) {
- result = attributeInstance.getValues();
- }
- } else if (structuralFeature instanceof EReference) {
- final EReference eReference = (EReference) structuralFeature;
- if (eReference.isContainment()) {
- MultiValuedContainmentReferenceInstance referenceInstance =
- SerializationManager.getMultiValuedContainmentReferenceInstance(extendedEObjectReference, eReference);
- if (referenceInstance == null) {
- referenceInstance = SerializationManager.createMultiValuedContainmentReferenceInstance(eReference, null, extendedEObjectReference);
- result = referenceInstance.getOwnedElements();
- } else {
- result = referenceInstance.getOwnedElements();
- }
- } else {
- MultiValuedReferenceInstance referenceInstance =
- SerializationManager.getMultiValuedReferenceInstance(extendedEObjectReference, eReference);
- if (referenceInstance == null) {
- referenceInstance = SerializationManager.createMultiValuedReferenceInstance(eReference, null, extendedEObjectReference);
- result = referenceInstance.getReferencedElements();
- } else {
- result = referenceInstance.getReferencedElements();
- }
- }
- } else {
- throw new UnsupportedOperationException("Getting a structural feature of type '" + structuralFeature.getClass().getName() + "' is not implemented"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return result;
- }
-
- private static Object getSingleValuedStructuralFeature(final EObject eObject, final EStructuralFeature structuralFeature) {
- Object result = null;
- final ExtendedEObjectReference extendedEObjectReference = SerializationManager.getExtendedEObjectReference(eObject);
- if (extendedEObjectReference != null) {
- if (structuralFeature instanceof EAttribute) {
- final EAttribute eAttribute = (EAttribute) structuralFeature;
- final SingleValuedAttributeInstance attributeInstance = SerializationManager.getSingleValuedAttributeInstance(extendedEObjectReference, eAttribute);
- if (attributeInstance != null) {
- result = attributeInstance.getValue();
- }
- } else if (structuralFeature instanceof EReference) {
- final EReference eReference = (EReference) structuralFeature;
- if (eReference.isContainment()) {
- final SingleValuedContainmentReferenceInstance referenceInstance =
- SerializationManager.getSingleValuedContainmentReferenceInstance(extendedEObjectReference, eReference);
- result = referenceInstance.getOwnedElement();
- } else {
- final SingleValuedReferenceInstance referenceInstance =
- SerializationManager.getSingleValuedReferenceInstance(extendedEObjectReference, eReference);
- result = referenceInstance.getReferencedElement();
- }
- } else {
- throw new IllegalArgumentException("Unexpected structuralFeature kind"); //$NON-NLS-1$
- }
- }
- return result;
- }
-
- public Object getNotDerivedValue(final EObject eObject, final EStructuralFeature structuralFeature) {
- Object result;
- if (structuralFeature.isMany()) {
- result = this.getMultiValuedStructuralFeature(eObject, structuralFeature);
- } else {
- result = SerializationManager.getSingleValuedStructuralFeature(eObject, structuralFeature);
- }
- return result;
- }
-}
+/******************************************************************************* + * Copyright (c) 2011 Mia-Software + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values. + * Nicolas Bros (Mia-Software) - Bug 361612 - New core for new version of the Facet metamodel + * Grégoire Dupé (Mia-Software) - Bug 361612 - [Restructuring] New core for new version of the Facet metamodel + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.internal.serialization; + +import java.io.IOException; +import java.util.Collections; +import java.util.List; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.SaveStructuralFeatureInstanceModelException; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.AbstractAttributeInstance; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.AbstractReferenceInstance; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.ExtendedEObjectReference; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.MultiValuedAttributeInstance; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.MultiValuedContainmentReferenceInstance; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.MultiValuedReferenceInstance; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.SerializationFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.SingleValuedAttributeInstance; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.SingleValuedContainmentReferenceInstance; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.serialization.SingleValuedReferenceInstance; + +public class SerializationManager { + + private final Resource structuralFeatureInstancesResource; + + public SerializationManager(final Resource structuralFeatureInstancesResource) { + this.structuralFeatureInstancesResource = structuralFeatureInstancesResource; + if (structuralFeatureInstancesResource != null) { + final EList<EObject> contents = structuralFeatureInstancesResource.getContents(); + for (EObject eObject : contents) { + if (eObject instanceof ExtendedEObjectReference) { + final ExtendedEObjectReference extendedEObjectReference = (ExtendedEObjectReference) eObject; + final LinkToExtendedEObjectReferenceAdapter adapter = (LinkToExtendedEObjectReferenceAdapter) ILinkToExtendedEObjectReferenceAdapterFactory.INSTANCE + .adapt(extendedEObjectReference.getExtendedEObject(), + ILinkToExtendedEObjectReference.class); + adapter.setExtendedEObjectReference(extendedEObjectReference); + } + } + } + } + + /** + * This method creates a ReferenceInstance in the given {@link ExtendedEObjectReference} with + * the reference {@link EStructuralFeature} and the value {@link Object}. + */ + private static MultiValuedContainmentReferenceInstance createMultiValuedContainmentReferenceInstance(final EReference reference, + final List<EObject> values, + final ExtendedEObjectReference extendedEObjectReference) { + final MultiValuedContainmentReferenceInstance containmentReferenceInstance = SerializationFactory.eINSTANCE + .createMultiValuedContainmentReferenceInstance(); + containmentReferenceInstance.setEReference(reference); + if (values != null) { + containmentReferenceInstance.getOwnedElements().addAll(values); + } + extendedEObjectReference.getReferenceInstances().add(containmentReferenceInstance); + return containmentReferenceInstance; + } + + /** + * This method returns the {@link ExtendedEObjectReference} associated with the given {@link EObject} if it exists or <code>null</code> if it does not exist. + */ + private static ExtendedEObjectReference getExtendedEObjectReference(final EObject eObject) { + ExtendedEObjectReference result = null; + for (final Adapter adapter : eObject.eAdapters()) { + if (adapter.isAdapterForType(ILinkToExtendedEObjectReference.class)) { + final LinkToExtendedEObjectReferenceAdapter linkToExtendedEObjectReferenceAdapter = (LinkToExtendedEObjectReferenceAdapter) adapter; + result = linkToExtendedEObjectReferenceAdapter.getExtendedEObjectReference(); + break; + } + } + return result; + } + + /** + * This method creates an AttributeInstance in the given {@link ExtendedEObjectReference} with + * the attribute {@link EStructuralFeature} and the value {@link Object}. + */ + private static MultiValuedAttributeInstance createMultiValuedAttributeInstance(final EAttribute attribute, final List<Object> values, + final ExtendedEObjectReference extendedEObjectReference) { + final MultiValuedAttributeInstance attributeInstance = SerializationFactory.eINSTANCE.createMultiValuedAttributeInstance(); + attributeInstance.setEAttribute(attribute); + if (values != null) { + attributeInstance.getValues().addAll(values); + } + extendedEObjectReference.getAttributeInstances().add(attributeInstance); + return attributeInstance; + } + + /** + * This method creates a ReferenceInstance in the given {@link ExtendedEObjectReference} with + * the reference {@link EStructuralFeature} and the value {@link Object}. + */ + private static MultiValuedReferenceInstance createMultiValuedReferenceInstance(final EReference reference, final List<EObject> values, + final ExtendedEObjectReference extendedEObjectReference) { + final MultiValuedReferenceInstance referenceInstance = SerializationFactory.eINSTANCE + .createMultiValuedReferenceInstance(); + referenceInstance.setEReference(reference); + if (values != null) { + referenceInstance.getReferencedElements().addAll(values); + } + extendedEObjectReference.getReferenceInstances().add(referenceInstance); + return referenceInstance; + } + + private static SingleValuedAttributeInstance getSingleValuedAttributeInstance(final ExtendedEObjectReference extendedEObjectReference, + final EAttribute eAttribute) { + SingleValuedAttributeInstance result = null; + final EList<AbstractAttributeInstance> attributeInstances = extendedEObjectReference.getAttributeInstances(); + for (final AbstractAttributeInstance attributeInstance : attributeInstances) { + if (eAttribute.equals(attributeInstance.getEAttribute())) { + if (attributeInstance instanceof SingleValuedAttributeInstance) { + result = (SingleValuedAttributeInstance) attributeInstance; + break; + } + throw new IllegalStateException("single valued attribute should be associated to an instance of SingleValuedAttributeInstance"); //$NON-NLS-1$ + } + } + return result; + } + + private static MultiValuedAttributeInstance getMultiValuedAttributeInstance(final ExtendedEObjectReference extendedEObjectReference, + final EAttribute eAttribute) { + MultiValuedAttributeInstance result = null; + final EList<AbstractAttributeInstance> attributeInstances = extendedEObjectReference.getAttributeInstances(); + for (final AbstractAttributeInstance attributeInstance : attributeInstances) { + if (eAttribute.equals(attributeInstance.getEAttribute())) { + if (attributeInstance instanceof MultiValuedAttributeInstance) { + result = (MultiValuedAttributeInstance) attributeInstance; + break; + } + throw new IllegalStateException("multi valued attribute should be associated to an instance of MultiValuedAttributeInstance"); //$NON-NLS-1$ + + } + } + return result; + } + + private static SingleValuedReferenceInstance getSingleValuedReferenceInstance(final ExtendedEObjectReference extendedEObjectReference, + final EReference eReference) { + SingleValuedReferenceInstance result = null; + final EList<AbstractReferenceInstance> referenceInstances = extendedEObjectReference.getReferenceInstances(); + for (final AbstractReferenceInstance referenceInstance : referenceInstances) { + if (eReference.equals(referenceInstance.getEReference())) { + if (referenceInstance instanceof SingleValuedReferenceInstance) { + result = (SingleValuedReferenceInstance) referenceInstance; + break; + } + throw new IllegalStateException("a single valued non-containment reference should be associated to an instance of SingleValuedReferenceInstance"); //$NON-NLS-1$ + } + } + return result; + } + + private static SingleValuedContainmentReferenceInstance getSingleValuedContainmentReferenceInstance( + final ExtendedEObjectReference extendedEObjectReference, + final EReference eReference) { + SingleValuedContainmentReferenceInstance result = null; + final EList<AbstractReferenceInstance> referenceInstances = extendedEObjectReference.getReferenceInstances(); + for (final AbstractReferenceInstance referenceInstance : referenceInstances) { + if (eReference.equals(referenceInstance.getEReference())) { + if (referenceInstance instanceof SingleValuedContainmentReferenceInstance) { + result = (SingleValuedContainmentReferenceInstance) referenceInstance; + break; + } + throw new IllegalStateException("a single valued containment reference should be associated to an instance of SingleValuedContainmentReferenceInstance"); //$NON-NLS-1$ + } + } + return result; + } + + private static MultiValuedReferenceInstance getMultiValuedReferenceInstance(final ExtendedEObjectReference extendedEObjectReference, + final EReference eReference) { + MultiValuedReferenceInstance result = null; + final EList<AbstractReferenceInstance> referenceInstances = extendedEObjectReference.getReferenceInstances(); + for (final AbstractReferenceInstance referenceInstance : referenceInstances) { + if (eReference.equals(referenceInstance.getEReference())) { + if (referenceInstance instanceof MultiValuedReferenceInstance) { + result = (MultiValuedReferenceInstance) referenceInstance; + break; + } + throw new IllegalStateException("a multi valued non-containment reference should be associated to an instance of MultiValuedReferenceInstance"); //$NON-NLS-1$ + } + } + return result; + } + + private static MultiValuedContainmentReferenceInstance getMultiValuedContainmentReferenceInstance(final ExtendedEObjectReference extendedEObjectReference, + final EReference eReference) { + MultiValuedContainmentReferenceInstance result = null; + final EList<AbstractReferenceInstance> referenceInstances = extendedEObjectReference.getReferenceInstances(); + for (final AbstractReferenceInstance referenceInstance : referenceInstances) { + if (eReference.equals(referenceInstance.getEReference())) { + if (referenceInstance instanceof MultiValuedContainmentReferenceInstance) { + result = (MultiValuedContainmentReferenceInstance) referenceInstance; + break; + } + throw new IllegalStateException("a multi valued containment reference should be associated to an instance of MultiValuedContainmentReferenceInstance"); //$NON-NLS-1$ + } + } + return result; + } + + public void saveStructuralFeatureInstanceModel() + throws SaveStructuralFeatureInstanceModelException { + if (this.structuralFeatureInstancesResource == null) { + throw new SaveStructuralFeatureInstanceModelException("This facet manager has been initailized with a null structural feature instances resource"); //$NON-NLS-1$ + } + try { + this.structuralFeatureInstancesResource.save(Collections.EMPTY_MAP); + } catch (final IOException e) { + throw new SaveStructuralFeatureInstanceModelException(e); + } + } + + /** + * This method returns the ExtendedEObjectReference associated with the given {@link EObject} if + * it exists or creates it if it does not exist. + */ + private ExtendedEObjectReference getOrCreateExtendedEObjectReference(final EObject eObject) { + ExtendedEObjectReference extendedEObjectReference = SerializationManager.getExtendedEObjectReference(eObject); + if (extendedEObjectReference == null) { + extendedEObjectReference = SerializationFactory.eINSTANCE.createExtendedEObjectReference(); + extendedEObjectReference.setExtendedEObject(eObject); + if (this.structuralFeatureInstancesResource != null) { + this.structuralFeatureInstancesResource.getContents().add(extendedEObjectReference); + } + final LinkToExtendedEObjectReferenceAdapter adapter = (LinkToExtendedEObjectReferenceAdapter) ILinkToExtendedEObjectReferenceAdapterFactory.INSTANCE + .adapt(eObject, ILinkToExtendedEObjectReference.class); + adapter.setExtendedEObjectReference(extendedEObjectReference); + } + return extendedEObjectReference; + } + + public void setAttribute(final EObject eObject, final EAttribute attribute, final Object newValue) { + final ExtendedEObjectReference extendedEObjectReference = this.getOrCreateExtendedEObjectReference(eObject); + if (attribute.isMany()) { + if (newValue instanceof List) { + // safe to cast + @SuppressWarnings("unchecked") + final List<Object> list = (List<Object>) newValue; + final MultiValuedAttributeInstance attributeInstance = + SerializationManager.getMultiValuedAttributeInstance(extendedEObjectReference, attribute); + if (attributeInstance == null) { + SerializationManager.createMultiValuedAttributeInstance(attribute, list, extendedEObjectReference); + } else { + attributeInstance.getValues().clear(); + attributeInstance.getValues().addAll(list); + } + } else { + throw new IllegalArgumentException("The given FacetAttribute is multiplicity-many, so the value must be a List"); //$NON-NLS-1$ + } + } else { + final SingleValuedAttributeInstance attributeInstance = + SerializationManager.getSingleValuedAttributeInstance(extendedEObjectReference, attribute); + if (attributeInstance == null) { + createSingleValuedAttributeInstance(attribute, newValue, extendedEObjectReference); + } else { + attributeInstance.setValue(newValue); + } + } + + } + + + /** + * This method creates an AttributeInstance in the given {@link ExtendedEObjectReference} with + * the attribute {@link EStructuralFeature} and the value {@link Object}. + */ + private static SingleValuedAttributeInstance createSingleValuedAttributeInstance(final EAttribute attribute, final Object value, + final ExtendedEObjectReference extendedEObjectReference) { + final SingleValuedAttributeInstance attributeInstance = SerializationFactory.eINSTANCE.createSingleValuedAttributeInstance(); + attributeInstance.setEAttribute(attribute); + attributeInstance.setValue(value); + extendedEObjectReference.getAttributeInstances().add(attributeInstance); + return attributeInstance; + } + + /** + * This method creates a ReferenceInstance in the given {@link ExtendedEObjectReference} with + * the reference {@link EStructuralFeature} and the value {@link Object}. + */ + private static SingleValuedReferenceInstance createSingleValuedReferenceInstance(final EReference reference, final EObject value, + final ExtendedEObjectReference extendedEObjectReference) { + final SingleValuedReferenceInstance referenceInstance = SerializationFactory.eINSTANCE + .createSingleValuedReferenceInstance(); + referenceInstance.setEReference(reference); + referenceInstance.setReferencedElement(value); + extendedEObjectReference.getReferenceInstances().add(referenceInstance); + return referenceInstance; + } + + public void setReference(final EObject eObject, final EReference reference, final Object newValue) { + final ExtendedEObjectReference extendedEObjectReference = this.getOrCreateExtendedEObjectReference(eObject); + if (reference.isMany()) { + throw new UnsupportedOperationException("The given FacetReference is multi-valued : add elements to the list returned by getMultiValuedReference() instead"); //$NON-NLS-1$ + } + if (!(newValue instanceof EObject)) { + throw new IllegalArgumentException("newValue should be an EObject because eStructuralFeature is an EReference"); //$NON-NLS-1$ + } + final EObject newEObjectValue = (EObject) newValue; + if (reference.isContainment()) { + final SingleValuedContainmentReferenceInstance referenceInstance = + SerializationManager.getSingleValuedContainmentReferenceInstance(extendedEObjectReference, reference); + if (referenceInstance == null) { + createSingleValuedContainmentReferenceInstance(reference, newEObjectValue, extendedEObjectReference); + } else { + referenceInstance.setOwnedElement(newEObjectValue); + } + } else { + final SingleValuedReferenceInstance referenceInstance = + SerializationManager.getSingleValuedReferenceInstance(extendedEObjectReference, reference); + if (referenceInstance == null) { + createSingleValuedReferenceInstance(reference, newEObjectValue, extendedEObjectReference); + } else { + referenceInstance.setReferencedElement(newEObjectValue); + } + } + + } + + /** + * This method creates a ReferenceInstance in the given {@link ExtendedEObjectReference} with + * the reference {@link EStructuralFeature} and the value {@link Object}. + */ + private static SingleValuedContainmentReferenceInstance createSingleValuedContainmentReferenceInstance(final EReference reference, + final EObject value, + final ExtendedEObjectReference extendedEObjectReference) { + final SingleValuedContainmentReferenceInstance containmentReferenceInstance = SerializationFactory.eINSTANCE + .createSingleValuedContainmentReferenceInstance(); + containmentReferenceInstance.setEReference(reference); + containmentReferenceInstance.setOwnedElement(value); + extendedEObjectReference.getReferenceInstances().add(containmentReferenceInstance); + return containmentReferenceInstance; + } + + private Object getMultiValuedStructuralFeature(final EObject eObject, final EStructuralFeature structuralFeature) { + Object result = null; + final ExtendedEObjectReference extendedEObjectReference = this.getOrCreateExtendedEObjectReference(eObject); + if (structuralFeature instanceof EAttribute) { + final EAttribute eAttribute = (EAttribute) structuralFeature; + final MultiValuedAttributeInstance attributeInstance = + SerializationManager.getMultiValuedAttributeInstance(extendedEObjectReference, eAttribute); + if (attributeInstance != null) { + result = attributeInstance.getValues(); + } + } else if (structuralFeature instanceof EReference) { + final EReference eReference = (EReference) structuralFeature; + if (eReference.isContainment()) { + MultiValuedContainmentReferenceInstance referenceInstance = + SerializationManager.getMultiValuedContainmentReferenceInstance(extendedEObjectReference, eReference); + if (referenceInstance == null) { + referenceInstance = SerializationManager.createMultiValuedContainmentReferenceInstance(eReference, null, extendedEObjectReference); + result = referenceInstance.getOwnedElements(); + } else { + result = referenceInstance.getOwnedElements(); + } + } else { + MultiValuedReferenceInstance referenceInstance = + SerializationManager.getMultiValuedReferenceInstance(extendedEObjectReference, eReference); + if (referenceInstance == null) { + referenceInstance = SerializationManager.createMultiValuedReferenceInstance(eReference, null, extendedEObjectReference); + result = referenceInstance.getReferencedElements(); + } else { + result = referenceInstance.getReferencedElements(); + } + } + } else { + throw new UnsupportedOperationException("Getting a structural feature of type '" + structuralFeature.getClass().getName() + "' is not implemented"); //$NON-NLS-1$ //$NON-NLS-2$ + } + return result; + } + + private static Object getSingleValuedStructuralFeature(final EObject eObject, final EStructuralFeature structuralFeature) { + Object result = null; + final ExtendedEObjectReference extendedEObjectReference = SerializationManager.getExtendedEObjectReference(eObject); + if (extendedEObjectReference != null) { + if (structuralFeature instanceof EAttribute) { + final EAttribute eAttribute = (EAttribute) structuralFeature; + final SingleValuedAttributeInstance attributeInstance = SerializationManager.getSingleValuedAttributeInstance(extendedEObjectReference, eAttribute); + if (attributeInstance != null) { + result = attributeInstance.getValue(); + } + } else if (structuralFeature instanceof EReference) { + final EReference eReference = (EReference) structuralFeature; + if (eReference.isContainment()) { + final SingleValuedContainmentReferenceInstance referenceInstance = + SerializationManager.getSingleValuedContainmentReferenceInstance(extendedEObjectReference, eReference); + result = referenceInstance.getOwnedElement(); + } else { + final SingleValuedReferenceInstance referenceInstance = + SerializationManager.getSingleValuedReferenceInstance(extendedEObjectReference, eReference); + result = referenceInstance.getReferencedElement(); + } + } else { + throw new IllegalArgumentException("Unexpected structuralFeature kind"); //$NON-NLS-1$ + } + } + return result; + } + + public Object getNotDerivedValue(final EObject eObject, final EStructuralFeature structuralFeature) { + Object result; + if (structuralFeature.isMany()) { + result = this.getMultiValuedStructuralFeature(eObject, structuralFeature); + } else { + result = SerializationManager.getSingleValuedStructuralFeature(eObject, structuralFeature); + } + return result; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IDerivedTypedElementCollectionImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IDerivedTypedElementCollectionImplementation.java index 36d155537c0..92b6a95eddf 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IDerivedTypedElementCollectionImplementation.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IDerivedTypedElementCollectionImplementation.java @@ -1,84 +1,84 @@ -/**
- * Copyright (c) 2011, 2012 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
- * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.query;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult;
-
-/**
- * This interface can be implemented by EMF Facet derived typed element implementations that want to
- * handle multiple evaluation themselves, presumably to improve the performance of the evaluation.
- * <p>
- * If only {@link IDerivedTypedElementImplementation} is implemented, then the framework will perform multiple-evaluation by calling the single evaluation multiple times, which may be slow in the case of high-latency implementations.
- *
- * @since 0.2
- * @deprecated replaced by {@link IQueryCollectionImplementation}. https://bugs.eclipse.org/bugs/show_bug.cgi?id=377057.
- */
-@Deprecated
-public interface IDerivedTypedElementCollectionImplementation extends IDerivedTypedElementImplementation {
-
- /**
- * This method must be implemented by each sub-class to evaluate the query of a derived typed element on a
- * collection of elements. The query should be evaluated on each of the elements in the given collection.
- * <p>
- * This method should throw a {@link DerivedTypedElementException} only if the {@link DerivedTypedElement} is incorrect. But it must not throw an exception if the evaluation of one element fails. Instead, it must set the exception on the corresponding
- * result ({@link AbstractDerivedTypedElementResult#setException(Throwable)}).
- *
- * @param derivedTypedElement
- * The derived typed element for which to get the values
- * @param sources
- * The model elements on which the derived typed element is evaluated
- * @param arguments
- * The parameter values for the derived typed element (in the case of a {@link FacetOperation}); can be <code>null</code>
- * @return the result :
- * <ul>
- * <li> a list of {@link DerivedTypedElementPrimitiveTypeResult} if the derived typed element is single-valued and returns a primitive type <li> a list of {@link DerivedTypedElementPrimitiveTypeListResult} if the derived typed element is
- * multi-valued and returns a primitive type <li> a list of {@link DerivedTypedElementEObjectResult} if the derived typed element is single-valued and returns a model element <li> a list of {@link DerivedTypedElementEObjectListResult} if the
- * derived typed element is multi-valued and returns model elements
- * </ul>
- * @throws DerivedTypedElementException
- * if the given derivedTypedElement is incorrect
- */
- List<? extends ETypedElementResult> getValues(DerivedTypedElement derivedTypedElement, Collection<? extends EObject> sources, List<ParameterValue> arguments)
- throws DerivedTypedElementException;
-
- /**
- * This method must be implemented by each sub-class to set the values of a collection of elements. The derived
- * typed element's query should be used to set the value of each of the elements in the given collection.
- *
- * @param query
- * The query to evaluate
- * @param source
- * The model elements on which the query is evaluated
- * @param arguments
- * The parameter values for the derived typed element (in the case of a {@link FacetOperation}); can be <code>null</code>
- * @param newValues
- * the new values for the sources; the size of this list must match the size of the list of sources
- * @throws DerivedTypedElementException
- * if the given derivedTypedElement is incorrect
- * @throws DerivedTypedElementEvaluationException
- * if the query of the derived typed element could not be evaluated correctly
- * @throws IllegalArgumentException
- * if the given list of values does not match the list of sources
- */
- void setValues(DerivedTypedElement derivedTypedElement, Collection<? extends EObject> sources, List<ParameterValue> arguments, List<? extends Object> newValues)
- throws DerivedTypedElementException;
-}
+/** + * Copyright (c) 2011, 2012 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2 + * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet. + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + */ +package org.eclipse.papyrus.emf.facet.efacet.core.query; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult; + +/** + * This interface can be implemented by EMF Facet derived typed element implementations that want to + * handle multiple evaluation themselves, presumably to improve the performance of the evaluation. + * <p> + * If only {@link IDerivedTypedElementImplementation} is implemented, then the framework will perform multiple-evaluation by calling the single evaluation multiple times, which may be slow in the case of high-latency implementations. + * + * @since 0.2 + * @deprecated replaced by {@link IQueryCollectionImplementation}. https://bugs.eclipse.org/bugs/show_bug.cgi?id=377057. + */ +@Deprecated +public interface IDerivedTypedElementCollectionImplementation extends IDerivedTypedElementImplementation { + + /** + * This method must be implemented by each sub-class to evaluate the query of a derived typed element on a + * collection of elements. The query should be evaluated on each of the elements in the given collection. + * <p> + * This method should throw a {@link DerivedTypedElementException} only if the {@link DerivedTypedElement} is incorrect. But it must not throw an exception if the evaluation of one element fails. Instead, it must set the exception on the corresponding + * result ({@link AbstractDerivedTypedElementResult#setException(Throwable)}). + * + * @param derivedTypedElement + * The derived typed element for which to get the values + * @param sources + * The model elements on which the derived typed element is evaluated + * @param arguments + * The parameter values for the derived typed element (in the case of a {@link FacetOperation}); can be <code>null</code> + * @return the result : + * <ul> + * <li> a list of {@link DerivedTypedElementPrimitiveTypeResult} if the derived typed element is single-valued and returns a primitive type <li> a list of {@link DerivedTypedElementPrimitiveTypeListResult} if the derived typed element is + * multi-valued and returns a primitive type <li> a list of {@link DerivedTypedElementEObjectResult} if the derived typed element is single-valued and returns a model element <li> a list of {@link DerivedTypedElementEObjectListResult} if the + * derived typed element is multi-valued and returns model elements + * </ul> + * @throws DerivedTypedElementException + * if the given derivedTypedElement is incorrect + */ + List<? extends ETypedElementResult> getValues(DerivedTypedElement derivedTypedElement, Collection<? extends EObject> sources, List<ParameterValue> arguments) + throws DerivedTypedElementException; + + /** + * This method must be implemented by each sub-class to set the values of a collection of elements. The derived + * typed element's query should be used to set the value of each of the elements in the given collection. + * + * @param query + * The query to evaluate + * @param source + * The model elements on which the query is evaluated + * @param arguments + * The parameter values for the derived typed element (in the case of a {@link FacetOperation}); can be <code>null</code> + * @param newValues + * the new values for the sources; the size of this list must match the size of the list of sources + * @throws DerivedTypedElementException + * if the given derivedTypedElement is incorrect + * @throws DerivedTypedElementEvaluationException + * if the query of the derived typed element could not be evaluated correctly + * @throws IllegalArgumentException + * if the given list of values does not match the list of sources + */ + void setValues(DerivedTypedElement derivedTypedElement, Collection<? extends EObject> sources, List<ParameterValue> arguments, List<? extends Object> newValues) + throws DerivedTypedElementException; +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IDerivedTypedElementImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IDerivedTypedElementImplementation.java index da4325697f7..6e5076ead28 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IDerivedTypedElementImplementation.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IDerivedTypedElementImplementation.java @@ -1,90 +1,90 @@ -/**
- * Copyright (c) 2011, 2012 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - initial API and implementation
- * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
- * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.query;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
-
-/**
- * Interface implemented by all EMF Facet derived typed element evaluators.
- * <p>
- * A derived typed element evaluator may choose to implement {@link IDerivedTypedElementCollectionImplementation} instead if it wants to improve the performance of evaluation on collections of elements.
- *
- * @since 0.2
- * @deprecated replaced by {@link IQueryImplementation}. https://bugs.eclipse.org/bugs/show_bug.cgi?id=377058.
- */
-@Deprecated
-public interface IDerivedTypedElementImplementation {
-
- /**
- * This method must be implemented by each sub class to evaluate a derived
- * typed element
- *
- * @param derivedTypedElement
- * The derived typed element to evaluate
- * @param source
- * The model element on which the derived typed element is
- * evaluated
- * @param parameterValues
- * The derived typed element's query parameter values (in the
- * case of a {@link FacetOperation}), can be <code>null</code>
- * @return the result, which can be either a single object or a collection
- * of values depending on the multiplicity of the given derived
- * typed element
- * @throws DerivedTypedElementException
- * if the query of the derived typed element could not be
- * evaluated correctly to get the value
- */
- Object getValue(DerivedTypedElement derivedTypedElement, EObject source,
- List<ParameterValue> parameterValues, IFacetManager facetManager)
- throws DerivedTypedElementException;
-
- /**
- * This method must be implemented by each sub class to set the value of a
- * derived typed element
- *
- * @param derivedTypedElement
- * The derived typed element to set
- * @param source
- * The model element on which the derived typed element is set
- * @param parameterValues
- * The derived typed element's query parameter values (in the
- * case of a {@link FacetOperation}), can be <code>null</code>
- * @param newValue
- * the value to set on the derived typed element
- * @throws DerivedTypedElementException
- * if the query of the derived typed element could not be
- * evaluated correctly to set the value
- */
- void setValue(DerivedTypedElement derivedTypedElement, EObject source,
- List<ParameterValue> parameterValues, Object newValue)
- throws DerivedTypedElementException;
-
- /**
- * Return whether to check the type of the derived typed element result after its evaluation
- * <p>
- * Normally, this is <code>true</code>, but the derived typed element evaluator can choose to skip the check, for example if the return type of the query can't be loaded.
- *
- * @return whether to check the type of the derived typed element result after its evaluation
- */
- boolean getCheckResultType();
-
-}
+/** + * Copyright (c) 2011, 2012 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - initial API and implementation + * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values. + * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2 + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + */ +package org.eclipse.papyrus.emf.facet.efacet.core.query; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; + +/** + * Interface implemented by all EMF Facet derived typed element evaluators. + * <p> + * A derived typed element evaluator may choose to implement {@link IDerivedTypedElementCollectionImplementation} instead if it wants to improve the performance of evaluation on collections of elements. + * + * @since 0.2 + * @deprecated replaced by {@link IQueryImplementation}. https://bugs.eclipse.org/bugs/show_bug.cgi?id=377058. + */ +@Deprecated +public interface IDerivedTypedElementImplementation { + + /** + * This method must be implemented by each sub class to evaluate a derived + * typed element + * + * @param derivedTypedElement + * The derived typed element to evaluate + * @param source + * The model element on which the derived typed element is + * evaluated + * @param parameterValues + * The derived typed element's query parameter values (in the + * case of a {@link FacetOperation}), can be <code>null</code> + * @return the result, which can be either a single object or a collection + * of values depending on the multiplicity of the given derived + * typed element + * @throws DerivedTypedElementException + * if the query of the derived typed element could not be + * evaluated correctly to get the value + */ + Object getValue(DerivedTypedElement derivedTypedElement, EObject source, + List<ParameterValue> parameterValues, IFacetManager facetManager) + throws DerivedTypedElementException; + + /** + * This method must be implemented by each sub class to set the value of a + * derived typed element + * + * @param derivedTypedElement + * The derived typed element to set + * @param source + * The model element on which the derived typed element is set + * @param parameterValues + * The derived typed element's query parameter values (in the + * case of a {@link FacetOperation}), can be <code>null</code> + * @param newValue + * the value to set on the derived typed element + * @throws DerivedTypedElementException + * if the query of the derived typed element could not be + * evaluated correctly to set the value + */ + void setValue(DerivedTypedElement derivedTypedElement, EObject source, + List<ParameterValue> parameterValues, Object newValue) + throws DerivedTypedElementException; + + /** + * Return whether to check the type of the derived typed element result after its evaluation + * <p> + * Normally, this is <code>true</code>, but the derived typed element evaluator can choose to skip the check, for example if the return type of the query can't be loaded. + * + * @return whether to check the type of the derived typed element result after its evaluation + */ + boolean getCheckResultType(); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IDerivedTypedElementImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IDerivedTypedElementImplementationFactory.java index c47667d7a2b..a18a5869a5d 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IDerivedTypedElementImplementationFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IDerivedTypedElementImplementationFactory.java @@ -1,54 +1,54 @@ -/**
- * Copyright (c) 2011, 2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
- * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values.
- * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2
- * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.query;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.osgi.framework.Bundle;
-
-/**
- * This factory allows clients to create a {@link IDerivedTypedElementImplementation} for queries
- * corresponding to this type of factory.
- *
- * @since 0.2
- * @deprecated replaced by {@link IQueryImplementationFactory}. https://bugs.eclipse.org/bugs/show_bug.cgi?id=377059.
- */
-@Deprecated
-public interface IDerivedTypedElementImplementationFactory {
- // Copy of org.eclipse.papyrus.emf.facet.infra.query.core.IModelQueryFactory
-
- /**
- * Create a derived typed element implementation, for getting and setting the value of the
- * derived typed element.
- *
- * @param derivedTypedElement
- * the derived typed element to create an implementation for
- * @param queryBundle
- * the bundle in which the query used to get or set this derived typed element is
- * defined. May be <code>null</code> if the query is not defined in a {@link Bundle}.
- */
- public IDerivedTypedElementImplementation create(Query derivedTypedElement, Bundle queryBundle, IDerivedTypedElementManager derivedTEManager)
- throws DerivedTypedElementException;
-
- /**
- * Return the type of query handled by this implementation.
- *
- * @return the type of query this implementation handles.
- */
- public EClass getManagedQueryType();
-}
+/** + * Copyright (c) 2011, 2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet + * Emmanuelle Rouillé (Mia-Software) - Bug 352618 - To be able to use non derived facet structural features and save them values. + * Nicolas Bros (Mia-Software) - Bug 362191 - [Restructuring] Query mechanism for eFacet2 + * Gregoire Dupe (Mia-Software) - Bug 369987 - [Restructuring][Table] Switch to the new customization and facet framework + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + */ +package org.eclipse.papyrus.emf.facet.efacet.core.query; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.osgi.framework.Bundle; + +/** + * This factory allows clients to create a {@link IDerivedTypedElementImplementation} for queries + * corresponding to this type of factory. + * + * @since 0.2 + * @deprecated replaced by {@link IQueryImplementationFactory}. https://bugs.eclipse.org/bugs/show_bug.cgi?id=377059. + */ +@Deprecated +public interface IDerivedTypedElementImplementationFactory { + // Copy of org.eclipse.papyrus.emf.facet.infra.query.core.IModelQueryFactory + + /** + * Create a derived typed element implementation, for getting and setting the value of the + * derived typed element. + * + * @param derivedTypedElement + * the derived typed element to create an implementation for + * @param queryBundle + * the bundle in which the query used to get or set this derived typed element is + * defined. May be <code>null</code> if the query is not defined in a {@link Bundle}. + */ + public IDerivedTypedElementImplementation create(Query derivedTypedElement, Bundle queryBundle, IDerivedTypedElementManager derivedTEManager) + throws DerivedTypedElementException; + + /** + * Return the type of query handled by this implementation. + * + * @return the type of query this implementation handles. + */ + public EClass getManagedQueryType(); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryCollectionImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryCollectionImplementation.java index b382086e16d..ebb038e6e12 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryCollectionImplementation.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryCollectionImplementation.java @@ -1,91 +1,91 @@ -/*******************************************************************************
- * Copyright (c) 2012 CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.query;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementEObjectListResult;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementEObjectResult;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementPrimitiveTypeListResult;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementPrimitiveTypeResult;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult;
-
-/**
- * This interface can be implemented by EMF Facet query implementations that want to handle multiple evaluation
- * themselves, presumably to improve the performance of the evaluation.
- * <p>
- * If only {@link IQueryImplementation} is implemented, then the framework will perform multiple-evaluation by calling the single evaluation multiple times, which may be slow in the case of high-latency implementations.
- *
- * @since 0.2
- */
-public interface IQueryCollectionImplementation extends IQueryImplementation {
-
- /**
- * This method must be implemented by each sub-class to evaluate a query on a collection of elements. The query
- * should be evaluated on each of the elements in the given collection.
- * <p>
- * This method should throw a {@link DerivedTypedElementException} only if the eTypedElement is an incorrect {@link DerivedTypedElement}. But it must not throw an exception if the evaluation of one element fails. Instead, it must set the exception on the
- * corresponding result ({@link ETypedElementResult#setException(Throwable)}).
- *
- * @param query
- * The query to evaluate
- * @param eTypedElement
- * The feature or operation to get on the sources
- * @param sources
- * The model elements on which the feature or operation is evaluated using the query
- * @param arguments
- * The parameter values for the eTypedElement (in the case of a {@link FacetOperation}); can be <code>null</code>
- * @return the result :
- * <ul>
- * <li> a list of {@link ETypedElementPrimitiveTypeResult} if the eTypedElement is single-valued and returns a primitive type <li> a list of {@link ETypedElementPrimitiveTypeListResult} if the eTypedElement is multi-valued and returns a primitive
- * type <li> a list of {@link ETypedElementEObjectResult} if the eTypedElement is single-valued and returns a model element <li> a list of {@link ETypedElementEObjectListResult} if the eTypedElement is multi-valued and returns model elements
- * </ul>
- * @throws DerivedTypedElementException
- * if the given derivedTypedElement is incorrect
- */
- List<? extends ETypedElementResult> getValues(Query query, ETypedElement eTypedElement, Collection<? extends EObject> sources,
- List<ParameterValue> arguments)
- throws DerivedTypedElementException;
-
- /**
- * This method must be implemented by each sub-class to set the values of a collection of elements. The query should
- * be used to set the value of each of the elements in the given collection.
- *
- * @param query
- * The query to evaluate
- * @param feature
- * The derived typed element to set
- * @param sources
- * The model elements on which the query is evaluated
- * @param arguments
- * The parameter values for the derived typed element (in the case of a {@link FacetOperation}); can be <code>null</code>
- * @param newValues
- * the new values for the sources; the size of this list must match the size of the list of sources
- * @throws DerivedTypedElementException
- * if the given derivedTypedElement is incorrect
- * @throws DerivedTypedElementEvaluationException
- * if the query could not be evaluated correctly
- * @throws IllegalArgumentException
- * if the given list of values does not match the list of sources
- */
- void setValues(Query query, DerivedTypedElement feature, Collection<? extends EObject> sources, List<ParameterValue> arguments,
- List<? extends Object> newValues)
- throws DerivedTypedElementException;
-}
+/******************************************************************************* + * Copyright (c) 2012 CEA LIST. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.query; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exception.DerivedTypedElementEvaluationException; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementEObjectListResult; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementEObjectResult; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementPrimitiveTypeListResult; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementPrimitiveTypeResult; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult; + +/** + * This interface can be implemented by EMF Facet query implementations that want to handle multiple evaluation + * themselves, presumably to improve the performance of the evaluation. + * <p> + * If only {@link IQueryImplementation} is implemented, then the framework will perform multiple-evaluation by calling the single evaluation multiple times, which may be slow in the case of high-latency implementations. + * + * @since 0.2 + */ +public interface IQueryCollectionImplementation extends IQueryImplementation { + + /** + * This method must be implemented by each sub-class to evaluate a query on a collection of elements. The query + * should be evaluated on each of the elements in the given collection. + * <p> + * This method should throw a {@link DerivedTypedElementException} only if the eTypedElement is an incorrect {@link DerivedTypedElement}. But it must not throw an exception if the evaluation of one element fails. Instead, it must set the exception on the + * corresponding result ({@link ETypedElementResult#setException(Throwable)}). + * + * @param query + * The query to evaluate + * @param eTypedElement + * The feature or operation to get on the sources + * @param sources + * The model elements on which the feature or operation is evaluated using the query + * @param arguments + * The parameter values for the eTypedElement (in the case of a {@link FacetOperation}); can be <code>null</code> + * @return the result : + * <ul> + * <li> a list of {@link ETypedElementPrimitiveTypeResult} if the eTypedElement is single-valued and returns a primitive type <li> a list of {@link ETypedElementPrimitiveTypeListResult} if the eTypedElement is multi-valued and returns a primitive + * type <li> a list of {@link ETypedElementEObjectResult} if the eTypedElement is single-valued and returns a model element <li> a list of {@link ETypedElementEObjectListResult} if the eTypedElement is multi-valued and returns model elements + * </ul> + * @throws DerivedTypedElementException + * if the given derivedTypedElement is incorrect + */ + List<? extends ETypedElementResult> getValues(Query query, ETypedElement eTypedElement, Collection<? extends EObject> sources, + List<ParameterValue> arguments) + throws DerivedTypedElementException; + + /** + * This method must be implemented by each sub-class to set the values of a collection of elements. The query should + * be used to set the value of each of the elements in the given collection. + * + * @param query + * The query to evaluate + * @param feature + * The derived typed element to set + * @param sources + * The model elements on which the query is evaluated + * @param arguments + * The parameter values for the derived typed element (in the case of a {@link FacetOperation}); can be <code>null</code> + * @param newValues + * the new values for the sources; the size of this list must match the size of the list of sources + * @throws DerivedTypedElementException + * if the given derivedTypedElement is incorrect + * @throws DerivedTypedElementEvaluationException + * if the query could not be evaluated correctly + * @throws IllegalArgumentException + * if the given list of values does not match the list of sources + */ + void setValues(Query query, DerivedTypedElement feature, Collection<? extends EObject> sources, List<ParameterValue> arguments, + List<? extends Object> newValues) + throws DerivedTypedElementException; +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryEvaluator.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryEvaluator.java index 3824fbb69ff..22c0a594d94 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryEvaluator.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryEvaluator.java @@ -1,110 +1,110 @@ -/**
- * Copyright (c) 2011, 2012 Mia-Software.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - initial API and implementation
- * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.query;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.efacet.ParameterValue;
-import org.eclipse.papyrus.emf.facet.efacet.Query;
-import org.eclipse.papyrus.emf.facet.efacet.QueryResult;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.QueryException;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.QueryExecutionException;
-
-/**
- * This interface is the EMF Facet QueryEvaluator for query evaluation
- *
- * @deprecated use {@link IQueryImplementation} with the new eFacet2 metamodel (https://bugs.eclipse.org/bugs/show_bug.cgi?id=381227)
- */
-@Deprecated
-public interface IQueryEvaluator {
-
- /**
- * This method must be implemented by each sub class to evaluate a query
- *
- * @param query
- * The query to evaluate
- * @param context
- * The model element on which the query is evaluated
- * @param parameterValues
- * The query parameter values, can be <code>null</code>
- * @return A list of {@link QueryResult}s (one per evaluation)
- * @throws QueryExecutionException
- */
- public Object basicEvaluate(final Query query, EObject context,
- final List<ParameterValue> parameterValues) throws QueryException;
-
- /**
- * Return whether to check the query result after its evaluation
- *
- * @return whether to check the query result after its evaluation
- */
- public abstract boolean getCheckResultType();
-
- /**
- * Called when starting the evaluation of a query on one or several context
- * elements (when {@link AbstractQueryEvaluator#evaluate(ModelQueryContext, List)} is
- * called).
- * <p>
- * A subclass will receive in order:<br>
- *
- * <pre>
- * startEvaluate()
- * basicEvaluate(context1, parameters)
- * basicEvaluate(context2, parameters)
- * ...
- * basicEvaluate(contextn, parameters)
- * endEvaluate()
- * </pre>
- *
- * </p>
- *
- * When evaluating a query on several context elements, basicEvaluate is
- * called repeatedly with each context element. For some implementations
- * that make use of a system with which you must establish a connection (e.g.
- * a database) for each call, this is costly.
- *
- * The methods startEvaluate and endEvaluate satisfy this requirement
- *
- * @see {@link AbstractQueryEvaluator#endEvaluate()}
- */
- public void startEvaluate();
-
- /**
- * Called when ending the evaluation of a query on one or several context
- * elements.
- * <p>
- * A subclass will receive in order:<br>
- *
- * <pre>
- * startEvaluate()
- * basicEvaluate(context1, parameters)
- * basicEvaluate(context2, parameters)
- * ...
- * basicEvaluate(contextn, parameters)
- * endEvaluate()
- * </pre>
- *
- * </p>
- * When evaluating a query on several context elements, basicEvaluate is
- * called repeatedly with each context element. For some implementations
- * that make use of a system with which you must establish a connection
- * (e.g. a database) for each call, this is costly.
- *
- * The methods startEvaluate and endEvaluate satisfy this requirement
- *
- * @see {@link AbstractQueryEvaluator#startEvaluate()}
- */
- public void endEvaluate();
-
-}
+/** + * Copyright (c) 2011, 2012 Mia-Software. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - initial API and implementation + * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + */ +package org.eclipse.papyrus.emf.facet.efacet.core.query; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.efacet.Query; +import org.eclipse.papyrus.emf.facet.efacet.QueryResult; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.QueryException; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.QueryExecutionException; + +/** + * This interface is the EMF Facet QueryEvaluator for query evaluation + * + * @deprecated use {@link IQueryImplementation} with the new eFacet2 metamodel (https://bugs.eclipse.org/bugs/show_bug.cgi?id=381227) + */ +@Deprecated +public interface IQueryEvaluator { + + /** + * This method must be implemented by each sub class to evaluate a query + * + * @param query + * The query to evaluate + * @param context + * The model element on which the query is evaluated + * @param parameterValues + * The query parameter values, can be <code>null</code> + * @return A list of {@link QueryResult}s (one per evaluation) + * @throws QueryExecutionException + */ + public Object basicEvaluate(final Query query, EObject context, + final List<ParameterValue> parameterValues) throws QueryException; + + /** + * Return whether to check the query result after its evaluation + * + * @return whether to check the query result after its evaluation + */ + public abstract boolean getCheckResultType(); + + /** + * Called when starting the evaluation of a query on one or several context + * elements (when {@link AbstractQueryEvaluator#evaluate(ModelQueryContext, List)} is + * called). + * <p> + * A subclass will receive in order:<br> + * + * <pre> + * startEvaluate() + * basicEvaluate(context1, parameters) + * basicEvaluate(context2, parameters) + * ... + * basicEvaluate(contextn, parameters) + * endEvaluate() + * </pre> + * + * </p> + * + * When evaluating a query on several context elements, basicEvaluate is + * called repeatedly with each context element. For some implementations + * that make use of a system with which you must establish a connection (e.g. + * a database) for each call, this is costly. + * + * The methods startEvaluate and endEvaluate satisfy this requirement + * + * @see {@link AbstractQueryEvaluator#endEvaluate()} + */ + public void startEvaluate(); + + /** + * Called when ending the evaluation of a query on one or several context + * elements. + * <p> + * A subclass will receive in order:<br> + * + * <pre> + * startEvaluate() + * basicEvaluate(context1, parameters) + * basicEvaluate(context2, parameters) + * ... + * basicEvaluate(contextn, parameters) + * endEvaluate() + * </pre> + * + * </p> + * When evaluating a query on several context elements, basicEvaluate is + * called repeatedly with each context element. For some implementations + * that make use of a system with which you must establish a connection + * (e.g. a database) for each call, this is costly. + * + * The methods startEvaluate and endEvaluate satisfy this requirement + * + * @see {@link AbstractQueryEvaluator#startEvaluate()} + */ + public void endEvaluate(); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryEvaluatorFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryEvaluatorFactory.java index 9ff4d494d2d..354712ab173 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryEvaluatorFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryEvaluatorFactory.java @@ -1,42 +1,42 @@ -/**
- * Copyright (c) 2011, 2012 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
- * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.query;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.emf.facet.efacet.Query;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.QueryException;
-import org.osgi.framework.Bundle;
-
-/**
- * This factory allows the user to create a {@link IQueryEvaluator} conforming to the EMF Facet
- * framework.
- *
- * @deprecated use {@link IQueryImplementationFactory} with the new eFacet2 metamodel (https://bugs.eclipse.org/bugs/show_bug.cgi?id=381229)
- */
-@Deprecated
-public interface IQueryEvaluatorFactory {
- // Copy of org.eclipse.papyrus.emf.facet.infra.query.core.IModelQueryFactory
-
- /**
- * Create a query evaluator.
- */
- public IQueryEvaluator create(Query query, Bundle bundle) throws QueryException;
-
- /**
- * Return the type of query this evaluator can evaluate.
- *
- * @return the type of query this evaluator can evaluate.
- */
- public EClass getManagedQueryType();
-}
+/** + * Copyright (c) 2011, 2012 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet + * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + */ +package org.eclipse.papyrus.emf.facet.efacet.core.query; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.emf.facet.efacet.Query; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.QueryException; +import org.osgi.framework.Bundle; + +/** + * This factory allows the user to create a {@link IQueryEvaluator} conforming to the EMF Facet + * framework. + * + * @deprecated use {@link IQueryImplementationFactory} with the new eFacet2 metamodel (https://bugs.eclipse.org/bugs/show_bug.cgi?id=381229) + */ +@Deprecated +public interface IQueryEvaluatorFactory { + // Copy of org.eclipse.papyrus.emf.facet.infra.query.core.IModelQueryFactory + + /** + * Create a query evaluator. + */ + public IQueryEvaluator create(Query query, Bundle bundle) throws QueryException; + + /** + * Return the type of query this evaluator can evaluate. + * + * @return the type of query this evaluator can evaluate. + */ + public EClass getManagedQueryType(); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryImplementation.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryImplementation.java index e85eb2eabdc..788b22ec4e9 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryImplementation.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryImplementation.java @@ -1,82 +1,82 @@ -/*******************************************************************************
- * Copyright (c) 2012 CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.query;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-
-/**
- * Interface implemented by all EMF Facet query evaluators.
- * <p>
- * A query evaluator may choose to implement {@link IQueryCollectionImplementation} instead if it wants to improve the performance of evaluation on collections of elements.
- *
- * @since 0.2
- */
-public interface IQueryImplementation {
-
- /**
- * This method must be implemented by each sub class to evaluate a query
- *
- * @param query
- * The query to evaluate
- * @param feature
- * The feature or operation to get on the source
- * @param source
- * The model element on which the query is evaluated
- * @param parameterValues
- * The derived typed element's query parameter values (in the case of a {@link FacetOperation}); can be <code>null</code>
- * @return the result, which can be either a single object or a collection of values depending on the multiplicity
- * of the given derived typed element
- * @throws DerivedTypedElementException
- * if the query could not be evaluated correctly to get the value
- */
- Object getValue(Query query, DerivedTypedElement feature, EObject source,
- List<ParameterValue> parameterValues, IFacetManager facetManager)
- throws DerivedTypedElementException;
-
- /**
- * This method must be implemented by each sub class that allows to set the value of a derivedTypedElement using a
- * query
- *
- * @param query
- * The query that sets the value
- * @param feature
- * The derived typed element to set
- * @param source
- * The model element on which the derived typed element must be set
- * @param parameterValues
- * The query parameter values (in the case of a {@link FacetOperation}); can be <code>null</code>
- * @param newValue
- * the value to set on the derived typed element
- * @throws DerivedTypedElementException
- * if the query could not be evaluated correctly to set the value
- */
- void setValue(Query query, DerivedTypedElement feature, EObject source,
- List<ParameterValue> parameterValues, Object newValue)
- throws DerivedTypedElementException;
-
- /**
- * Return whether to check the type of the query result after its evaluation
- * <p>
- * Normally, this is <code>true</code>, but the query evaluator can choose to skip the check, for example if the return type of the query can't be loaded.
- *
- * @return whether to check the type of the query result after its evaluation
- */
- boolean isCheckResultType();
-
-}
+/******************************************************************************* + * Copyright (c) 2012 CEA LIST. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.query; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DerivedTypedElement; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.ParameterValue; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; + +/** + * Interface implemented by all EMF Facet query evaluators. + * <p> + * A query evaluator may choose to implement {@link IQueryCollectionImplementation} instead if it wants to improve the performance of evaluation on collections of elements. + * + * @since 0.2 + */ +public interface IQueryImplementation { + + /** + * This method must be implemented by each sub class to evaluate a query + * + * @param query + * The query to evaluate + * @param feature + * The feature or operation to get on the source + * @param source + * The model element on which the query is evaluated + * @param parameterValues + * The derived typed element's query parameter values (in the case of a {@link FacetOperation}); can be <code>null</code> + * @return the result, which can be either a single object or a collection of values depending on the multiplicity + * of the given derived typed element + * @throws DerivedTypedElementException + * if the query could not be evaluated correctly to get the value + */ + Object getValue(Query query, DerivedTypedElement feature, EObject source, + List<ParameterValue> parameterValues, IFacetManager facetManager) + throws DerivedTypedElementException; + + /** + * This method must be implemented by each sub class that allows to set the value of a derivedTypedElement using a + * query + * + * @param query + * The query that sets the value + * @param feature + * The derived typed element to set + * @param source + * The model element on which the derived typed element must be set + * @param parameterValues + * The query parameter values (in the case of a {@link FacetOperation}); can be <code>null</code> + * @param newValue + * the value to set on the derived typed element + * @throws DerivedTypedElementException + * if the query could not be evaluated correctly to set the value + */ + void setValue(Query query, DerivedTypedElement feature, EObject source, + List<ParameterValue> parameterValues, Object newValue) + throws DerivedTypedElementException; + + /** + * Return whether to check the type of the query result after its evaluation + * <p> + * Normally, this is <code>true</code>, but the query evaluator can choose to skip the check, for example if the return type of the query can't be loaded. + * + * @return whether to check the type of the query result after its evaluation + */ + boolean isCheckResultType(); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryImplementationFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryImplementationFactory.java index c7e655c4854..b8fcab1a1ad 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryImplementationFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryImplementationFactory.java @@ -1,44 +1,44 @@ -/*******************************************************************************
- * Copyright (c) 2012 CEA LIST.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.core.query;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query;
-import org.osgi.framework.Bundle;
-
-/**
- * This factory allows clients to create a {@link IQueryImplementation} for queries corresponding to this type of
- * factory.
- *
- * @since 0.2
- */
-public interface IQueryImplementationFactory {
-
- /**
- * Create a query implementation for the given query.
- *
- * @param query
- * the query to create an implementation for
- * @param queryBundle
- * the bundle in which the query is defined. May be <code>null</code> if the query is not defined in a {@link Bundle}.
- */
- IQueryImplementation create(Query query, Bundle queryBundle, IDerivedTypedElementManager manager)
- throws DerivedTypedElementException;
-
- /**
- * Return the type of query handled by this implementation.
- *
- * @return the type of query this implementation handles.
- */
- EClass getManagedQueryType();
-}
+/******************************************************************************* + * Copyright (c) 2012 CEA LIST. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nicolas Bros (Mia-Software) - Bug 376941 - [EFacet] Facet operation arguments in Facet model + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.core.query; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.emf.facet.efacet.core.IDerivedTypedElementManager; +import org.eclipse.papyrus.emf.facet.efacet.core.exception.DerivedTypedElementException; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.extensible.Query; +import org.osgi.framework.Bundle; + +/** + * This factory allows clients to create a {@link IQueryImplementation} for queries corresponding to this type of + * factory. + * + * @since 0.2 + */ +public interface IQueryImplementationFactory { + + /** + * Create a query implementation for the given query. + * + * @param query + * the query to create an implementation for + * @param queryBundle + * the bundle in which the query is defined. May be <code>null</code> if the query is not defined in a {@link Bundle}. + */ + IQueryImplementation create(Query query, Bundle queryBundle, IDerivedTypedElementManager manager) + throws DerivedTypedElementException; + + /** + * Return the type of query handled by this implementation. + * + * @return the type of query this implementation handles. + */ + EClass getManagedQueryType(); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryUtils.java index 10214173772..45aef838002 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryUtils.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.core/src/org/eclipse/papyrus/emf/facet/efacet/core/query/IQueryUtils.java @@ -1,45 +1,45 @@ -/**
- * Copyright (c) 2011 Mia-Software.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet
- * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
- */
-package org.eclipse.papyrus.emf.facet.efacet.core.query;
-
-import org.eclipse.papyrus.emf.facet.efacet.Query;
-import org.eclipse.papyrus.emf.facet.efacet.catalog.efacetcatalog.QuerySetCatalog;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.query.QueryUtilsImpl;
-
-/**
- * Utility methods for manipulating queries.
- *
- * @deprecated This class manipulated the old facet metamodel. With the new eFacet2 metamodel, there
- * are no QuerySets anymore. Queries are used only in Facets. (https://bugs.eclipse.org/bugs/show_bug.cgi?id=381230)
- */
-@Deprecated
-public interface IQueryUtils {
-
- /** The singleton {@link IQueryUtils} */
- IQueryUtils INSTANCE = new QueryUtilsImpl();
-
- /**
- * This method searches a query in all registered {@link QuerySetCatalog}s.
- *
- * @param querySetName
- * the name of the querySet to search into.
- * @param queryName
- * the name of the query to search for.
- * @return the query if found; <code>null</code> otherwise
- * @deprecated there are no QuerySets anymore. Queries are now a second-level concept only
- * defined in Facets. An equivalent is to search for an attribute or operation on a
- * Facet : see {@link IFacetUtils}
- */
- @Deprecated
- public Query searchQuery(String querySetName, String queryName);
-}
+/** + * Copyright (c) 2011 Mia-Software. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Gregoire Dupe (Mia-Software) - Bug 333553 - The user has not to deal with two files to create a facet + * Nicolas Bros (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels + */ +package org.eclipse.papyrus.emf.facet.efacet.core.query; + +import org.eclipse.papyrus.emf.facet.efacet.Query; +import org.eclipse.papyrus.emf.facet.efacet.catalog.efacetcatalog.QuerySetCatalog; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.query.QueryUtilsImpl; + +/** + * Utility methods for manipulating queries. + * + * @deprecated This class manipulated the old facet metamodel. With the new eFacet2 metamodel, there + * are no QuerySets anymore. Queries are used only in Facets. (https://bugs.eclipse.org/bugs/show_bug.cgi?id=381230) + */ +@Deprecated +public interface IQueryUtils { + + /** The singleton {@link IQueryUtils} */ + IQueryUtils INSTANCE = new QueryUtilsImpl(); + + /** + * This method searches a query in all registered {@link QuerySetCatalog}s. + * + * @param querySetName + * the name of the querySet to search into. + * @param queryName + * the name of the query to search for. + * @return the query if found; <code>null</code> otherwise + * @deprecated there are no QuerySets anymore. Queries are now a second-level concept only + * defined in Facets. An equivalent is to search for an attribute or operation on a + * Facet : see {@link IFacetUtils} + */ + @Deprecated + public Query searchQuery(String querySetName, String queryName); +} |