diff options
author | Quentin Le Menez | 2018-01-09 10:09:46 +0000 |
---|---|---|
committer | Quentin Le Menez | 2018-01-09 13:18:15 +0000 |
commit | d98116b5b376f18b6cf626ba4158a35fe9a4a64e (patch) | |
tree | 4458c9c5ada0a216b385813a56ea9a9b8c7b6509 /plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui | |
parent | 453e99bc2dcbd5fabad100f9d0d5f682013c3b19 (diff) | |
download | org.eclipse.papyrus-d98116b5b376f18b6cf626ba4158a35fe9a4a64e.tar.gz org.eclipse.papyrus-d98116b5b376f18b6cf626ba4158a35fe9a4a64e.tar.xz org.eclipse.papyrus-d98116b5b376f18b6cf626ba4158a35fe9a4a64e.zip |
Bug 515367 - [releng] Uniformization of the end of lines to Unix standard
- Format the EOL of all the files matched by: grep -rIUs . | xargs -Ifile dos2unix -k 'file'
Change-Id: I5c41d540a9a67b50de9b912ab35e16cc9a912961
Signed-off-by: Quentin Le Menez <quentin.lemenez@cea.fr>
Diffstat (limited to 'plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui')
108 files changed, 10916 insertions, 10916 deletions
diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/.classpath b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/.classpath index 45f024e850e..304e86186aa 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/.classpath +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/.classpath @@ -1,7 +1,7 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/.settings/org.eclipse.jdt.core.prefs b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/.settings/org.eclipse.jdt.core.prefs index 4759947300a..c585cc455ae 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/.settings/org.eclipse.jdt.core.prefs +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/.settings/org.eclipse.jdt.core.prefs @@ -1,291 +1,291 @@ -eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
-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.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 +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.ui/META-INF/MANIFEST.MF b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/META-INF/MANIFEST.MF index 0fe941e97e7..eae87c1e3c5 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/META-INF/MANIFEST.MF +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/META-INF/MANIFEST.MF @@ -1,29 +1,29 @@ -Manifest-Version: 1.0
-Export-Package: org.eclipse.papyrus.emf.facet.efacet.ui,
- org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites;x-friends:="org.eclipse.papyrus.emf.facet.query.java.ui",
- org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported;x-friends:="org.eclipse.papyrus.emf.facet.aggregate.tests",
- org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog;x-friends:="org.eclipse.papyrus.emf.facet.widgets.table.ui,
- org.eclipse.papyrus.emf.facet.efacet.tests,
- org.eclipse.papyrus.emf.facet.aggregate.tests",
- org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.view;x-friends:="org.eclipse.papyrus.emf.facet.efacet.tests",
- org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget;x-friends:="org.eclipse.papyrus.emf.facet.efacet.tests",
- org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard;x-friends:="org.eclipse.papyrus.emf.facet.query.java.ui",
- org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards;x-friends:="org.eclipse.papyrus.emf.facet.query.java.ui"
-Require-Bundle: org.eclipse.papyrus.emf.facet.common.ui;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.emf.edit.ui;bundle-version="[2.12.0,3.0.0)",
- org.eclipse.emf.ecore.edit;bundle-version="[2.9.0,3.0.0)",
- org.eclipse.papyrus.emf.facet.widgets.celleditors;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.core.expressions;bundle-version="[3.5.0,4.0.0)",
- org.eclipse.papyrus.emf.facet.efacet.metamodel;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.custom.core;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
- org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="[3.0.0,4.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: 3.0.0.qualifier
-Bundle-Name: %Bundle-Name
-Bundle-Activator: org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator
-Bundle-ManifestVersion: 2
-Bundle-SymbolicName: org.eclipse.papyrus.emf.facet.efacet.ui;singleton:=true
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Manifest-Version: 1.0 +Export-Package: org.eclipse.papyrus.emf.facet.efacet.ui, + org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites;x-friends:="org.eclipse.papyrus.emf.facet.query.java.ui", + org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported;x-friends:="org.eclipse.papyrus.emf.facet.aggregate.tests", + org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog;x-friends:="org.eclipse.papyrus.emf.facet.widgets.table.ui, + org.eclipse.papyrus.emf.facet.efacet.tests, + org.eclipse.papyrus.emf.facet.aggregate.tests", + org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.view;x-friends:="org.eclipse.papyrus.emf.facet.efacet.tests", + org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget;x-friends:="org.eclipse.papyrus.emf.facet.efacet.tests", + org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard;x-friends:="org.eclipse.papyrus.emf.facet.query.java.ui", + org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards;x-friends:="org.eclipse.papyrus.emf.facet.query.java.ui" +Require-Bundle: org.eclipse.papyrus.emf.facet.common.ui;bundle-version="[1.2.0,2.0.0)", + org.eclipse.emf.edit.ui;bundle-version="[2.12.0,3.0.0)", + org.eclipse.emf.ecore.edit;bundle-version="[2.9.0,3.0.0)", + org.eclipse.papyrus.emf.facet.widgets.celleditors;bundle-version="[1.2.0,2.0.0)", + org.eclipse.core.expressions;bundle-version="[3.5.0,4.0.0)", + org.eclipse.papyrus.emf.facet.efacet.metamodel;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.custom.core;bundle-version="[3.0.0,4.0.0)";visibility:=reexport, + org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="[3.0.0,4.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: 3.0.0.qualifier +Bundle-Name: %Bundle-Name +Bundle-Activator: org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator +Bundle-ManifestVersion: 2 +Bundle-SymbolicName: org.eclipse.papyrus.emf.facet.efacet.ui;singleton:=true +Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/OSGI-INF/l10n/bundle.properties b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/OSGI-INF/l10n/bundle.properties index d17155832c8..53a6e3eb857 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/OSGI-INF/l10n/bundle.properties +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/OSGI-INF/l10n/bundle.properties @@ -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 Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
-# Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
-###########################################################################
-#Properties file for org.eclipse.papyrus.emf.facet.efacet.ui
-Bundle-Name = Papyrus EMF Facet EFacet UI
-Bundle-Vendor = Eclipse Modeling Project
-
-category.name = EMF Facet
-wizard.name = Create a FacetSet 0.1 (Deprecated)
-wizard.description = Create a new Facet model
-extension-point.name = Query Factory Wizard Page Registration
-
-menu.label = EMF Facet Commands
-command.name = Create Facet in a FacetSet
-command.name.0 = Add Facet Attribute
-command.name.1 = Add Facet Operation
-command.name.2 = Add Parameter to Facet Operation
-command.name.3 = Add Facet Reference
-view.facetSets = Facet Sets
-navigate_handler = Navigate
-navigation_view = Navigation view
-navigate_command = Navigate
+########################################################################## +# 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 349546 - EMF Facet facetSet editor +# Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet. +########################################################################### +#Properties file for org.eclipse.papyrus.emf.facet.efacet.ui +Bundle-Name = Papyrus EMF Facet EFacet UI +Bundle-Vendor = Eclipse Modeling Project + +category.name = EMF Facet +wizard.name = Create a FacetSet 0.1 (Deprecated) +wizard.description = Create a new Facet model +extension-point.name = Query Factory Wizard Page Registration + +menu.label = EMF Facet Commands +command.name = Create Facet in a FacetSet +command.name.0 = Add Facet Attribute +command.name.1 = Add Facet Operation +command.name.2 = Add Parameter to Facet Operation +command.name.3 = Add Facet Reference +view.facetSets = Facet Sets +navigate_handler = Navigate +navigation_view = Navigation view +navigate_command = Navigate ETypedElementResult_Display = eTypedElementResultDisplay
\ No newline at end of file diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/about.html b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/about.html index 6f266717681..26e8949b523 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/about.html +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/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>June 16, 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>June 16, 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.ui/build.properties b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/build.properties index 52bc5c8fc60..80ec000fd99 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/build.properties +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/build.properties @@ -1,23 +1,23 @@ -##########################################################################
-# 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 349546 - EMF Facet facetSet editor
-###########################################################################
-output.. = bin/
-bin.includes = META-INF/,\
- .,\
- plugin.xml,\
- schema/,\
- OSGI-INF/,\
- build.properties,\
- about.html,\
- icons/,\
- OSGI-INF/l10n/bundle.properties
-source.. = src/
-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 349546 - EMF Facet facetSet editor +########################################################################### +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + schema/,\ + OSGI-INF/,\ + build.properties,\ + about.html,\ + icons/,\ + OSGI-INF/l10n/bundle.properties +source.. = src/ +src.includes = about.html diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/plugin.xml b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/plugin.xml index c885714cf36..7ce20456744 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/plugin.xml +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/plugin.xml @@ -1,26 +1,26 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?eclipse version="3.4"?>
-
<!--
- 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) - initial API and implementation
- 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 377782 - The command 'Navigation' and 'View in table' must not be unable in all menu.
- -->
+<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?eclipse version="3.4"?> +
<!-- + 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) - initial API and implementation + 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 377782 - The command 'Navigation' and 'View in table' must not be unable in all menu. + --> -<plugin>
- <extension-point id="queryFactoryWizardPageRegistration" name="%extension-point.name" schema="schema/queryFactoryWizardPageRegistration.exsd"/>
- <extension-point id="eTypedElementResultDisplay" name="%ETypedElementResult_Display" schema="schema/eTypedElementResultDisplay.exsd"/>
-
- <extension
- point="org.eclipse.core.runtime.preferences">
- <initializer
- class="org.eclipse.papyrus.emf.facet.efacet.ui.internal.preferences.PreferencesInitializer">
- </initializer>
- </extension>
-</plugin>
+<plugin> + <extension-point id="queryFactoryWizardPageRegistration" name="%extension-point.name" schema="schema/queryFactoryWizardPageRegistration.exsd"/> + <extension-point id="eTypedElementResultDisplay" name="%ETypedElementResult_Display" schema="schema/eTypedElementResultDisplay.exsd"/> + + <extension + point="org.eclipse.core.runtime.preferences"> + <initializer + class="org.eclipse.papyrus.emf.facet.efacet.ui.internal.preferences.PreferencesInitializer"> + </initializer> + </extension> +</plugin> diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/pom.xml b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/pom.xml index 1f5cd3cee47..623d5588948 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/pom.xml +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/pom.xml @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> -<project>
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>org.eclipse.papyrus.facet</artifactId>
- <groupId>org.eclipse.papyrus</groupId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
- <artifactId>org.eclipse.papyrus.emf.facet.efacet.ui</artifactId>
- <version>3.0.0-SNAPSHOT</version>
- <packaging>eclipse-plugin</packaging>
+<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>org.eclipse.papyrus.facet</artifactId> + <groupId>org.eclipse.papyrus</groupId> + <version>0.0.1-SNAPSHOT</version> + </parent> + <artifactId>org.eclipse.papyrus.emf.facet.efacet.ui</artifactId> + <version>3.0.0-SNAPSHOT</version> + <packaging>eclipse-plugin</packaging> </project>
\ No newline at end of file diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/schema/eTypedElementResultDisplay.exsd b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/schema/eTypedElementResultDisplay.exsd index 0c4cccb9f5c..a49d1d6a53b 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/schema/eTypedElementResultDisplay.exsd +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/schema/eTypedElementResultDisplay.exsd @@ -1,104 +1,104 @@ -<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.papyrus.emf.facet.infra.query.ui" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.eclipse.papyrus.emf.facet.infra.query.ui" id="queryResultDisplay" name="Display the results of a model query"/>
- </appinfo>
- <documentation>
- Use this extension point to provide a view or editor that can display the results of a model query.
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="displayer" 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="displayer">
- <annotation>
- <documentation>
- Provide a view or editor that will be used to display the results of a model query
- </documentation>
- </annotation>
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- Implemented by a view or editor that wants to be used to display the results of a model query.
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.emf.facet.efacet.ui.IETypedElementResultDisplayer"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- 0.8
- </documentation>
- </annotation>
-
-
-
- <annotation>
- <appinfo>
- <meta.section type="implementation"/>
- </appinfo>
- <documentation>
- See plugin "org.eclipse.papyrus.emf.facet.infra.browser".
- </documentation>
- </annotation>
-
- <annotation>
- <appinfo>
- <meta.section type="copyright"/>
- </appinfo>
- <documentation>
- Copyright (c) 2009, 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
- </documentation>
- </annotation>
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.papyrus.emf.facet.infra.query.ui" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appinfo> + <meta.schema plugin="org.eclipse.papyrus.emf.facet.infra.query.ui" id="queryResultDisplay" name="Display the results of a model query"/> + </appinfo> + <documentation> + Use this extension point to provide a view or editor that can display the results of a model query. + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appinfo> + <meta.element /> + </appinfo> + </annotation> + <complexType> + <sequence> + <element ref="displayer" 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="displayer"> + <annotation> + <documentation> + Provide a view or editor that will be used to display the results of a model query + </documentation> + </annotation> + <complexType> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + Implemented by a view or editor that wants to be used to display the results of a model query. + </documentation> + <appinfo> + <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.emf.facet.efacet.ui.IETypedElementResultDisplayer"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appinfo> + <meta.section type="since"/> + </appinfo> + <documentation> + 0.8 + </documentation> + </annotation> + + + + <annotation> + <appinfo> + <meta.section type="implementation"/> + </appinfo> + <documentation> + See plugin "org.eclipse.papyrus.emf.facet.infra.browser". + </documentation> + </annotation> + + <annotation> + <appinfo> + <meta.section type="copyright"/> + </appinfo> + <documentation> + Copyright (c) 2009, 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 + </documentation> + </annotation> + +</schema> diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/schema/queryFactoryWizardPageRegistration.exsd b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/schema/queryFactoryWizardPageRegistration.exsd index 2687f627d22..de54fb3fae1 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/schema/queryFactoryWizardPageRegistration.exsd +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/schema/queryFactoryWizardPageRegistration.exsd @@ -1,102 +1,102 @@ -<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.papyrus.emf.facet.efacet.ui" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appinfo>
- <meta.schema plugin="org.eclipse.papyrus.emf.facet.efacet.ui" id="queryFactoryWizardPageRegistration" name="Query Factory Wizard Page Registration"/>
- </appinfo>
- <documentation>
- This extension point aims at registering a wizard page for the creation of a query.
-This wizard page has to be associated to the EClass managed by the corresponding query evaluator factory.
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appinfo>
- <meta.element />
- </appinfo>
- </annotation>
- <complexType>
- <sequence>
- <element ref="queryWizardPage" 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="queryWizardPage">
- <complexType>
- <attribute name="managedQueryTypeName" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="wizardPage" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appinfo>
- <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart"/>
- </appinfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appinfo>
- <meta.section type="since"/>
- </appinfo>
- <documentation>
- 0.2.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 349546 - EMF Facet facetSet editor
- </documentation>
- </annotation>
-
-</schema>
+<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.papyrus.emf.facet.efacet.ui" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appinfo> + <meta.schema plugin="org.eclipse.papyrus.emf.facet.efacet.ui" id="queryFactoryWizardPageRegistration" name="Query Factory Wizard Page Registration"/> + </appinfo> + <documentation> + This extension point aims at registering a wizard page for the creation of a query. +This wizard page has to be associated to the EClass managed by the corresponding query evaluator factory. + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appinfo> + <meta.element /> + </appinfo> + </annotation> + <complexType> + <sequence> + <element ref="queryWizardPage" 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="queryWizardPage"> + <complexType> + <attribute name="managedQueryTypeName" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="wizardPage" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appinfo> + <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart"/> + </appinfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appinfo> + <meta.section type="since"/> + </appinfo> + <documentation> + 0.2.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 349546 - EMF Facet facetSet editor + </documentation> + </annotation> + +</schema> diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/IETypedElementResultDisplayer.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/IETypedElementResultDisplayer.java index f2126306c8f..477188a1161 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/IETypedElementResultDisplayer.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/IETypedElementResultDisplayer.java @@ -1,28 +1,28 @@ -/*******************************************************************************
- * Copyright (c) 2010, 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)
- * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui;
-
-import java.util.List;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult;
-
-/**
- * Implemented by a view or editor that wants to be used to display the results
- * of a model query.
- */
-// Copied from org.eclipse.papyrus.emf.facet.infra.query.ui.views.queryExecution.QueryResultDisplayer
-public interface IETypedElementResultDisplayer {
- void displayETypedElementResults(final List<ETypedElementResult> result, EditingDomain editingDomain);
-
- String getName();
-}
+/******************************************************************************* + * Copyright (c) 2010, 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) + * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet. + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui; + +import java.util.List; + +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult; + +/** + * Implemented by a view or editor that wants to be used to display the results + * of a model query. + */ +// Copied from org.eclipse.papyrus.emf.facet.infra.query.ui.views.queryExecution.QueryResultDisplayer +public interface IETypedElementResultDisplayer { + void displayETypedElementResults(final List<ETypedElementResult> result, EditingDomain editingDomain); + + String getName(); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/IETypedElementResultDisplayerOpener.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/IETypedElementResultDisplayerOpener.java index 38e1b23575f..d6da0358b67 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/IETypedElementResultDisplayerOpener.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/IETypedElementResultDisplayerOpener.java @@ -1,30 +1,30 @@ -/**
- * 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 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui;
-
-import java.util.List;
-
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult;
-import org.eclipse.ui.IWorkbenchPart;
-
-
-/**
- * This method must be implemented and referenced by the extension point org.eclipse.papyrus.emf.facet.efacet.ui.displayeropener
- *
- * This is a new version of the org.eclipse.papyrus.emf.facet.infra.query.ui.views.queryExecution.QueryResultDisplayer.
- *
- * @author Gregoire Dupe
- *
- */
-public interface IETypedElementResultDisplayerOpener {
- IWorkbenchPart open(List<ETypedElementResult> results);
-}
+/** + * 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 364325 - [Restructuring] The user must be able to navigate into a model using the Facet. + */ +package org.eclipse.papyrus.emf.facet.efacet.ui; + +import java.util.List; + +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult; +import org.eclipse.ui.IWorkbenchPart; + + +/** + * This method must be implemented and referenced by the extension point org.eclipse.papyrus.emf.facet.efacet.ui.displayeropener + * + * This is a new version of the org.eclipse.papyrus.emf.facet.infra.query.ui.views.queryExecution.QueryResultDisplayer. + * + * @author Gregoire Dupe + * + */ +public interface IETypedElementResultDisplayerOpener { + IWorkbenchPart open(List<ETypedElementResult> results); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/Activator.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/Activator.java index ea0948fd2be..7b9aafdbebe 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/Activator.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/Activator.java @@ -1,59 +1,59 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- * Nicolas Bros (Mia-Software) - Bug 379439 - Missing icons for Navigation view actions
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal;
-
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends AbstractUIPlugin {
-
- public static final String PLUGIN_ID = "org.eclipse.papyrus.emf.facet.efacet.ui"; //$NON-NLS-1$
-
- // The shared instance
- private static Activator plugin;
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext )
- */
- @Override
- public void start(final BundleContext context) throws Exception {
- super.start(context);
- Activator.plugin = this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext )
- */
- @Override
- public void stop(final BundleContext context) throws Exception {
- Activator.plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator 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 349546 - EMF Facet facetSet editor + * Nicolas Bros (Mia-Software) - Bug 379439 - Missing icons for Navigation view actions + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + public static final String PLUGIN_ID = "org.eclipse.papyrus.emf.facet.efacet.ui"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext ) + */ + @Override + public void start(final BundleContext context) throws Exception { + super.start(context); + Activator.plugin = this; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext ) + */ + @Override + public void stop(final BundleContext context) throws Exception { + Activator.plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return Activator.plugin; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/FacetUIFactoryImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/FacetUIFactoryImpl.java index 1f50857d2bc..5b0932e504b 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/FacetUIFactoryImpl.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/FacetUIFactoryImpl.java @@ -1,57 +1,57 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.ICreateFacetInFacetSetWizard;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.ICreateFacetSetWizard;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IFacetChildrenWizard;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.AddFacetAttributeWizardImpl;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.AddFacetOperationParameterWizardImpl;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.AddFacetOperationWizardImpl;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.AddFacetReferenceWizardImpl;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.CreateFacetInFacetSetWizardImpl;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.CreateFacetSetWizardImpl;
-
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public class FacetUIFactoryImpl implements IFacetUIFactory {
-
- public ICreateFacetInFacetSetWizard createCreateFacetInFacetSetWizardDialog(final ISelection selection, final EditingDomain editingDomain) {
- return new CreateFacetInFacetSetWizardImpl(selection, editingDomain);
- }
-
- public ICreateFacetSetWizard createCreateFacetSetWizardDialog(final ISelection selection) {
- return createCreateFacetSetWizardDialog(selection, true);
- }
-
- public ICreateFacetSetWizard createCreateFacetSetWizardDialog(final ISelection selection, final boolean opendCreatedFacetSetInEditor) {
- return new CreateFacetSetWizardImpl(selection, opendCreatedFacetSetInEditor);
- }
-
- public IFacetChildrenWizard createAddFacetAttributeWizardDialog(final ISelection selection, final EditingDomain editingDomain) {
- return new AddFacetAttributeWizardImpl(selection, editingDomain);
- }
-
- public IFacetChildrenWizard createAddFacetOperationWizardDialog(final ISelection selection, final EditingDomain editingDomain) {
- return new AddFacetOperationWizardImpl(selection, editingDomain);
- }
-
- public IFacetChildrenWizard createAddFacetOperationParameterWizardDialog(final ISelection selection, final EditingDomain editingDomain) {
- return new AddFacetOperationParameterWizardImpl(selection, editingDomain);
- }
-
- public IFacetChildrenWizard createAddFacetReferenceWizardDialog(final ISelection selection, final EditingDomain editingDomain) {
- return new AddFacetReferenceWizardImpl(selection, 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal; + +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.ICreateFacetInFacetSetWizard; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.ICreateFacetSetWizard; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IFacetChildrenWizard; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.AddFacetAttributeWizardImpl; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.AddFacetOperationParameterWizardImpl; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.AddFacetOperationWizardImpl; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.AddFacetReferenceWizardImpl; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.CreateFacetInFacetSetWizardImpl; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.CreateFacetSetWizardImpl; + +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public class FacetUIFactoryImpl implements IFacetUIFactory { + + public ICreateFacetInFacetSetWizard createCreateFacetInFacetSetWizardDialog(final ISelection selection, final EditingDomain editingDomain) { + return new CreateFacetInFacetSetWizardImpl(selection, editingDomain); + } + + public ICreateFacetSetWizard createCreateFacetSetWizardDialog(final ISelection selection) { + return createCreateFacetSetWizardDialog(selection, true); + } + + public ICreateFacetSetWizard createCreateFacetSetWizardDialog(final ISelection selection, final boolean opendCreatedFacetSetInEditor) { + return new CreateFacetSetWizardImpl(selection, opendCreatedFacetSetInEditor); + } + + public IFacetChildrenWizard createAddFacetAttributeWizardDialog(final ISelection selection, final EditingDomain editingDomain) { + return new AddFacetAttributeWizardImpl(selection, editingDomain); + } + + public IFacetChildrenWizard createAddFacetOperationWizardDialog(final ISelection selection, final EditingDomain editingDomain) { + return new AddFacetOperationWizardImpl(selection, editingDomain); + } + + public IFacetChildrenWizard createAddFacetOperationParameterWizardDialog(final ISelection selection, final EditingDomain editingDomain) { + return new AddFacetOperationParameterWizardImpl(selection, editingDomain); + } + + public IFacetChildrenWizard createAddFacetReferenceWizardDialog(final ISelection selection, final EditingDomain editingDomain) { + return new AddFacetReferenceWizardImpl(selection, editingDomain); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/IFacetUIFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/IFacetUIFactory.java index 37e0326c0e1..d3bc2ce9056 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/IFacetUIFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/IFacetUIFactory.java @@ -1,109 +1,109 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal;
-
-import org.eclipse.emf.ecore.EParameter;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.ICreateFacetInFacetSetWizard;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.ICreateFacetSetWizard;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IFacetChildrenWizard;
-
-/**
- * This interface provides methods used to create wizards that create {@link Facet}s and Facet elements.
- *
- * @since 0.2
- * @deprecated This interface has been replaced by {@link IFacetUIFactory2}. No tracking bug needed because this API has not been released yet.
- */
-@Deprecated
-public interface IFacetUIFactory {
-
- /**
- * Returns an instance of a {@link FacetUIFactoryImpl}
- */
- IFacetUIFactory INSTANCE = new FacetUIFactoryImpl();
-
- /**
- * Create a wizard dialog dedicated to the addition of a {@link Facet} in a {@link FacetSet}
- *
- * @param selection
- * the current selection, should be a FacetSet
- * @param editingDomain
- * the editing domain used to perform the EMF command
- * @return the newly created wizard
- */
- public ICreateFacetInFacetSetWizard createCreateFacetInFacetSetWizardDialog(ISelection selection, EditingDomain editingDomain);
-
- /**
- * Create a wizard dialog dedicated to the creation of a {@link FacetSet}
- *
- * @param selection
- * the current selection
- * @return the newly created wizard
- */
- public ICreateFacetSetWizard createCreateFacetSetWizardDialog(ISelection selection);
-
- /**
- * Create a wizard dialog dedicated to the creation of a {@link FacetSet}
- *
- * @param selection
- * the current selection
- * @param openCreatedFacetSetInEditor
- * @return the newly created wizard
- */
- public ICreateFacetSetWizard createCreateFacetSetWizardDialog(ISelection selection, boolean openCreatedFacetSetInEditor);
-
- /**
- * Create a wizard dialog dedicated to the addition of a {@link FacetAttribute} in a {@link Facet}
- *
- * @param selection
- * the current selection, should be a Facet
- * @param editingDomain
- * the editing domain used to perform the EMF command
- * @return the newly created wizard
- */
- public IFacetChildrenWizard createAddFacetAttributeWizardDialog(ISelection selection, EditingDomain editingDomain);
-
- /**
- * Create a wizard dialog dedicated to the addition of a {@link FacetOperation} in a {@link Facet}
- *
- * @param selection
- * the current selection, should be a Facet
- * @param editingDomain
- * the editing domain used to perform the EMF command
- * @return the newly created wizard
- */
- public IFacetChildrenWizard createAddFacetOperationWizardDialog(ISelection selection, EditingDomain editingDomain);
-
- /**
- * Create a wizard dialog dedicated to the addition of a {@link EParameter} to a {@link FacetOperation}
- *
- * @param selection
- * the current selection, should be a FacetOperation
- * @param editingDomain
- * the editing domain used to perform the EMF command
- * @return the newly created wizard
- */
- public IFacetChildrenWizard createAddFacetOperationParameterWizardDialog(ISelection selection, EditingDomain editingDomain);
-
- /**
- * Create a wizard dialog dedicated to the addition of a {@link FacetReference} in a {@link Facet}
- *
- * @param selection
- * the current selection, should be a Facet Reference
- * @param editingDomain
- * the editing domain used to perform the EMF command
- * @return the newly created wizard
- */
- public IFacetChildrenWizard createAddFacetReferenceWizardDialog(ISelection selection, 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal; + +import org.eclipse.emf.ecore.EParameter; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.ICreateFacetInFacetSetWizard; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.ICreateFacetSetWizard; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IFacetChildrenWizard; + +/** + * This interface provides methods used to create wizards that create {@link Facet}s and Facet elements. + * + * @since 0.2 + * @deprecated This interface has been replaced by {@link IFacetUIFactory2}. No tracking bug needed because this API has not been released yet. + */ +@Deprecated +public interface IFacetUIFactory { + + /** + * Returns an instance of a {@link FacetUIFactoryImpl} + */ + IFacetUIFactory INSTANCE = new FacetUIFactoryImpl(); + + /** + * Create a wizard dialog dedicated to the addition of a {@link Facet} in a {@link FacetSet} + * + * @param selection + * the current selection, should be a FacetSet + * @param editingDomain + * the editing domain used to perform the EMF command + * @return the newly created wizard + */ + public ICreateFacetInFacetSetWizard createCreateFacetInFacetSetWizardDialog(ISelection selection, EditingDomain editingDomain); + + /** + * Create a wizard dialog dedicated to the creation of a {@link FacetSet} + * + * @param selection + * the current selection + * @return the newly created wizard + */ + public ICreateFacetSetWizard createCreateFacetSetWizardDialog(ISelection selection); + + /** + * Create a wizard dialog dedicated to the creation of a {@link FacetSet} + * + * @param selection + * the current selection + * @param openCreatedFacetSetInEditor + * @return the newly created wizard + */ + public ICreateFacetSetWizard createCreateFacetSetWizardDialog(ISelection selection, boolean openCreatedFacetSetInEditor); + + /** + * Create a wizard dialog dedicated to the addition of a {@link FacetAttribute} in a {@link Facet} + * + * @param selection + * the current selection, should be a Facet + * @param editingDomain + * the editing domain used to perform the EMF command + * @return the newly created wizard + */ + public IFacetChildrenWizard createAddFacetAttributeWizardDialog(ISelection selection, EditingDomain editingDomain); + + /** + * Create a wizard dialog dedicated to the addition of a {@link FacetOperation} in a {@link Facet} + * + * @param selection + * the current selection, should be a Facet + * @param editingDomain + * the editing domain used to perform the EMF command + * @return the newly created wizard + */ + public IFacetChildrenWizard createAddFacetOperationWizardDialog(ISelection selection, EditingDomain editingDomain); + + /** + * Create a wizard dialog dedicated to the addition of a {@link EParameter} to a {@link FacetOperation} + * + * @param selection + * the current selection, should be a FacetOperation + * @param editingDomain + * the editing domain used to perform the EMF command + * @return the newly created wizard + */ + public IFacetChildrenWizard createAddFacetOperationParameterWizardDialog(ISelection selection, EditingDomain editingDomain); + + /** + * Create a wizard dialog dedicated to the addition of a {@link FacetReference} in a {@link Facet} + * + * @param selection + * the current selection, should be a Facet Reference + * @param editingDomain + * the editing domain used to perform the EMF command + * @return the newly created wizard + */ + public IFacetChildrenWizard createAddFacetReferenceWizardDialog(ISelection selection, EditingDomain editingDomain); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/IFacetUIFactory2.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/IFacetUIFactory2.java index d56ac31a732..0be17e2e770 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/IFacetUIFactory2.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/IFacetUIFactory2.java @@ -1,116 +1,116 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- * Gregoire Dupe (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal;
-
-import org.eclipse.emf.ecore.EParameter;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.viewers.ISelection;
-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.ui.internal.exported.wizard.ICreateFacetInFacetSetWizard2;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.ICreateFacetSetWizard;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IFacetChildrenWizard2;
-
-/**
- * This interface provides methods used to create wizards that create {@link Facet}s and Facet elements.
- *
- * TODO: This interface has to be renamed to IFacetUIFactory before the release of 0.2
- *
- * @since 0.2
- */
-// TODO: This interface has to be renamed to IFacetUIFactory before the release of 0.2
-public interface IFacetUIFactory2 {
-
- /**
- * Returns an instance of a {@link FacetUIFactoryImpl}
- */
- IFacetUIFactory2 INSTANCE = null; // TODO cf. https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-
- /**
- * Create a wizard dialog dedicated to the addition of a {@link Facet} in a {@link FacetSet}
- *
- * @param selection
- * the current selection, should be a FacetSet
- * @param editingDomain
- * the editing domain used to perform the EMF command
- * @return the newly created wizard
- */
- public ICreateFacetInFacetSetWizard2 createCreateFacetInFacetSetWizardDialog(ISelection selection, EditingDomain editingDomain);
-
- /**
- * Create a wizard dialog dedicated to the creation of a {@link FacetSet}
- *
- * @param selection
- * the current selection
- * @return the newly created wizard
- */
- public ICreateFacetSetWizard createCreateFacetSetWizardDialog(ISelection selection);
-
- /**
- * Create a wizard dialog dedicated to the creation of a {@link FacetSet}
- *
- * @param selection
- * the current selection
- * @param openCreatedFacetSetInEditor
- * @return the newly created wizard
- */
- public ICreateFacetSetWizard createCreateFacetSetWizardDialog(ISelection selection, boolean openCreatedFacetSetInEditor);
-
- /**
- * Create a wizard dialog dedicated to the addition of a {@link FacetAttribute} in a {@link Facet}
- *
- * @param selection
- * the current selection, should be a Facet
- * @param editingDomain
- * the editing domain used to perform the EMF command
- * @return the newly created wizard
- */
- public IFacetChildrenWizard2 createAddFacetAttributeWizardDialog(ISelection selection, EditingDomain editingDomain);
-
- /**
- * Create a wizard dialog dedicated to the addition of a {@link FacetOperation} in a {@link Facet}
- *
- * @param selection
- * the current selection, should be a Facet
- * @param editingDomain
- * the editing domain used to perform the EMF command
- * @return the newly created wizard
- */
- public IFacetChildrenWizard2 createAddFacetOperationWizardDialog(ISelection selection, EditingDomain editingDomain);
-
- /**
- * Create a wizard dialog dedicated to the addition of a {@link EParameter} to a {@link FacetOperation}
- *
- * @param selection
- * the current selection, should be a FacetOperation
- * @param editingDomain
- * the editing domain used to perform the EMF command
- * @return the newly created wizard
- */
- public IFacetChildrenWizard2 createAddFacetOperationParameterWizardDialog(ISelection selection, EditingDomain editingDomain);
-
- /**
- * Create a wizard dialog dedicated to the addition of a {@link FacetReference} in a {@link Facet}
- *
- * @param selection
- * the current selection, should be a Facet Reference
- * @param editingDomain
- * the editing domain used to perform the EMF command
- * @return the newly created wizard
- */
- public IFacetChildrenWizard2 createAddFacetReferenceWizardDialog(ISelection selection, 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 349546 - EMF Facet facetSet editor + * Gregoire Dupe (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal; + +import org.eclipse.emf.ecore.EParameter; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.jface.viewers.ISelection; +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.ui.internal.exported.wizard.ICreateFacetInFacetSetWizard2; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.ICreateFacetSetWizard; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IFacetChildrenWizard2; + +/** + * This interface provides methods used to create wizards that create {@link Facet}s and Facet elements. + * + * TODO: This interface has to be renamed to IFacetUIFactory before the release of 0.2 + * + * @since 0.2 + */ +// TODO: This interface has to be renamed to IFacetUIFactory before the release of 0.2 +public interface IFacetUIFactory2 { + + /** + * Returns an instance of a {@link FacetUIFactoryImpl} + */ + IFacetUIFactory2 INSTANCE = null; // TODO cf. https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 + + /** + * Create a wizard dialog dedicated to the addition of a {@link Facet} in a {@link FacetSet} + * + * @param selection + * the current selection, should be a FacetSet + * @param editingDomain + * the editing domain used to perform the EMF command + * @return the newly created wizard + */ + public ICreateFacetInFacetSetWizard2 createCreateFacetInFacetSetWizardDialog(ISelection selection, EditingDomain editingDomain); + + /** + * Create a wizard dialog dedicated to the creation of a {@link FacetSet} + * + * @param selection + * the current selection + * @return the newly created wizard + */ + public ICreateFacetSetWizard createCreateFacetSetWizardDialog(ISelection selection); + + /** + * Create a wizard dialog dedicated to the creation of a {@link FacetSet} + * + * @param selection + * the current selection + * @param openCreatedFacetSetInEditor + * @return the newly created wizard + */ + public ICreateFacetSetWizard createCreateFacetSetWizardDialog(ISelection selection, boolean openCreatedFacetSetInEditor); + + /** + * Create a wizard dialog dedicated to the addition of a {@link FacetAttribute} in a {@link Facet} + * + * @param selection + * the current selection, should be a Facet + * @param editingDomain + * the editing domain used to perform the EMF command + * @return the newly created wizard + */ + public IFacetChildrenWizard2 createAddFacetAttributeWizardDialog(ISelection selection, EditingDomain editingDomain); + + /** + * Create a wizard dialog dedicated to the addition of a {@link FacetOperation} in a {@link Facet} + * + * @param selection + * the current selection, should be a Facet + * @param editingDomain + * the editing domain used to perform the EMF command + * @return the newly created wizard + */ + public IFacetChildrenWizard2 createAddFacetOperationWizardDialog(ISelection selection, EditingDomain editingDomain); + + /** + * Create a wizard dialog dedicated to the addition of a {@link EParameter} to a {@link FacetOperation} + * + * @param selection + * the current selection, should be a FacetOperation + * @param editingDomain + * the editing domain used to perform the EMF command + * @return the newly created wizard + */ + public IFacetChildrenWizard2 createAddFacetOperationParameterWizardDialog(ISelection selection, EditingDomain editingDomain); + + /** + * Create a wizard dialog dedicated to the addition of a {@link FacetReference} in a {@link Facet} + * + * @param selection + * the current selection, should be a Facet Reference + * @param editingDomain + * the editing domain used to perform the EMF command + * @return the newly created wizard + */ + public IFacetChildrenWizard2 createAddFacetReferenceWizardDialog(ISelection selection, EditingDomain editingDomain); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/IQueryCreationPagePart2.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/IQueryCreationPagePart2.java index 50e66fca274..a8b6ce2f46f 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/IQueryCreationPagePart2.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/IQueryCreationPagePart2.java @@ -1,168 +1,168 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- * Gregoire Dupe (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-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.swt.events.ModifyListener;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * This interface has to be implemented by {@link Query} factory UI Class. It is used to complete a
- * generic {@link Query} creation wizard with specific widget.
- *
- * TODO: This interface has to be renamed to IQueryCreationPagePart before the release of 0.2
- *
- * @since 0.2
- */
-// TODO: This interface has to be renamed to IQueryCreationPagePart before the release of 0.2
-public interface IQueryCreationPagePart2 {
-
- /**
- * Set the {@link Query}'s {@link FacetSet}.
- *
- * @param facetSet
- * the given {@link FacetSet}
- */
- public void setFacetSet(FacetSet facetSet);
-
- /**
- * Set the {@link Query}'s upperBound.
- *
- * @param upperBound
- * the upperBound.
- */
- public void setUpperBound(int upperBound);
-
- /**
- * Set the {@link Query}'s lowerBound.
- *
- * @param lowerBound
- * the lowerBound.
- */
- public void setLowerBound(int lowerBound);
-
- /**
- * Set the {@link Query}'s {@link Query#isOrdered() <em>attribute</em>} attribute.
- *
- * @param ordered
- * whether
- */
- public void setOrdered(final boolean ordered);
-
- /**
- * Set the {@link Query}'s {@link Query#isUnique() <em>unique</em>} attribute.
- *
- * @param unique
- * Whether the query is unique or not.
- */
- public void setUnique(final boolean unique);
-
- /**
- * Set the {@link Query}'s type.
- *
- * @param queryType
- * the {@link Query}'s type.
- */
- public void setQueryType(EClassifier queryType);
-
- /**
- * Set the {@link Query}'s name.
- *
- * @param name
- * the query's name.
- */
- public void setQueryName(String name);
-
- /**
- * Set the {@link Query}'s {@link Query#isCanBeCached() <em>Can Be Cached</em>}.
- *
- * @param canBeCached
- * whether the query result can be cached.
- */
- public void setCanBeCached(boolean canBeCached);
-
- /**
- * Set the {@link Query}'s {@link Query#isHasSideEffect() <em>Has Side Effect</em>}.
- *
- * @param hasSideEffect
- * whether the query has side effect, such as modifying a model when applied on it.
- */
- public void setHasSideEffect(boolean hasSideEffect);
-
- /**
- * Set the {@link Query}'s '{@link Query#getScope <em>Scope</em>}'.
- *
- * @param type
- * the {@link Query}'s '{@link Query#getScope <em>Scope</em>}'.
- */
- public void setQueryScope(EClass scope);
-
- /**
- * This method is dedicated to create a {@link Query} with every attribute set by the others
- * methods of {@link IQueryCreationPagePart2}.
- *
- * @return the newly created {@link Query}
- */
- public Query performFinish();
-
- /**
- * This method is called by the {@link org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.CreateQueryWizardPage}.
- *
- * @param parent
- * the Wizard's composite to be completed with specific widget for this {@link Query} creation.
- */
- public void completeComposite(Composite parent);
-
- /**
- * Returns <code>true</code> if the composite is complete.
- *
- * @return <code>true</code> if the composite is complete.
- */
- public boolean isCompositeComplete();
-
- /**
- * Returns the error messages generated by the part, or null if none.
- *
- * @return the error messages generated by the part, or null if none.
- */
- public String getErrorMessage();
-
- /**
- * Add a {@link ModifyListener} on the part.
- *
- * @param listener
- * a {@link ModifyListener}
- */
- public void addModifyListener(ModifyListener listener);
-
- /**
- * Remove an existing {@link ModifyListener} from the part's listener.
- *
- * @param listener
- * an existing {@link ModifyListener} listener.
- */
- public void removeModifyListener(ModifyListener listener);
-
- /**
- * Notify the registered listener that something has been modified in the part. It should only
- * be used as a way to update the buttons' state of the containing wizard dialog.
- *
- * @param modifiedComposite
- * the composite on which the modification occured.
- */
- public void notifyCompositeListeners(Composite modifiedComposite);
-
-}
+/** + * 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 349546 - EMF Facet facetSet editor + * Gregoire Dupe (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +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.swt.events.ModifyListener; +import org.eclipse.swt.widgets.Composite; + +/** + * This interface has to be implemented by {@link Query} factory UI Class. It is used to complete a + * generic {@link Query} creation wizard with specific widget. + * + * TODO: This interface has to be renamed to IQueryCreationPagePart before the release of 0.2 + * + * @since 0.2 + */ +// TODO: This interface has to be renamed to IQueryCreationPagePart before the release of 0.2 +public interface IQueryCreationPagePart2 { + + /** + * Set the {@link Query}'s {@link FacetSet}. + * + * @param facetSet + * the given {@link FacetSet} + */ + public void setFacetSet(FacetSet facetSet); + + /** + * Set the {@link Query}'s upperBound. + * + * @param upperBound + * the upperBound. + */ + public void setUpperBound(int upperBound); + + /** + * Set the {@link Query}'s lowerBound. + * + * @param lowerBound + * the lowerBound. + */ + public void setLowerBound(int lowerBound); + + /** + * Set the {@link Query}'s {@link Query#isOrdered() <em>attribute</em>} attribute. + * + * @param ordered + * whether + */ + public void setOrdered(final boolean ordered); + + /** + * Set the {@link Query}'s {@link Query#isUnique() <em>unique</em>} attribute. + * + * @param unique + * Whether the query is unique or not. + */ + public void setUnique(final boolean unique); + + /** + * Set the {@link Query}'s type. + * + * @param queryType + * the {@link Query}'s type. + */ + public void setQueryType(EClassifier queryType); + + /** + * Set the {@link Query}'s name. + * + * @param name + * the query's name. + */ + public void setQueryName(String name); + + /** + * Set the {@link Query}'s {@link Query#isCanBeCached() <em>Can Be Cached</em>}. + * + * @param canBeCached + * whether the query result can be cached. + */ + public void setCanBeCached(boolean canBeCached); + + /** + * Set the {@link Query}'s {@link Query#isHasSideEffect() <em>Has Side Effect</em>}. + * + * @param hasSideEffect + * whether the query has side effect, such as modifying a model when applied on it. + */ + public void setHasSideEffect(boolean hasSideEffect); + + /** + * Set the {@link Query}'s '{@link Query#getScope <em>Scope</em>}'. + * + * @param type + * the {@link Query}'s '{@link Query#getScope <em>Scope</em>}'. + */ + public void setQueryScope(EClass scope); + + /** + * This method is dedicated to create a {@link Query} with every attribute set by the others + * methods of {@link IQueryCreationPagePart2}. + * + * @return the newly created {@link Query} + */ + public Query performFinish(); + + /** + * This method is called by the {@link org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.CreateQueryWizardPage}. + * + * @param parent + * the Wizard's composite to be completed with specific widget for this {@link Query} creation. + */ + public void completeComposite(Composite parent); + + /** + * Returns <code>true</code> if the composite is complete. + * + * @return <code>true</code> if the composite is complete. + */ + public boolean isCompositeComplete(); + + /** + * Returns the error messages generated by the part, or null if none. + * + * @return the error messages generated by the part, or null if none. + */ + public String getErrorMessage(); + + /** + * Add a {@link ModifyListener} on the part. + * + * @param listener + * a {@link ModifyListener} + */ + public void addModifyListener(ModifyListener listener); + + /** + * Remove an existing {@link ModifyListener} from the part's listener. + * + * @param listener + * an existing {@link ModifyListener} listener. + */ + public void removeModifyListener(ModifyListener listener); + + /** + * Notify the registered listener that something has been modified in the part. It should only + * be used as a way to update the buttons' state of the containing wizard dialog. + * + * @param modifiedComposite + * the composite on which the modification occured. + */ + public void notifyCompositeListeners(Composite modifiedComposite); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/IQueryCreationPagePart2Registry.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/IQueryCreationPagePart2Registry.java index b88e2122115..78be98299d6 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/IQueryCreationPagePart2Registry.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/IQueryCreationPagePart2Registry.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:
- * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
- * Gregoire Dupe (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal;
-
-import java.util.Map;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
-
-/**
- * This interface is dedicated to the registry
- *
- * TODO: This interface has to be renamed to IQueryCreationPagePartRegistry before the release of 0.2
- *
- * @since 0.2
- */
-// TODO: This interface has to be renamed to IQueryCreationPagePartRegistry before the release of 0.2
-public interface IQueryCreationPagePart2Registry {
-
- /**
- * Returns an instance of {@link QueryCreationPagePartRegistryImpl}.
- */
- IQueryCreationPagePart2Registry INSTANCE = null; // TODO cf. https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-
- /**
- * Return a registered {@link IQueryCreationPagePart} corresponding to the given type name.
- *
- * @param managedTypeName
- * the type we need a part for.
- * @return a registered {@link IQueryCreationPagePart} corresponding to the given type name.
- */
- public IQueryCreationPagePart2 getWizardPagePartFor(EClass managedQueryType);
-
- /**
- * Returns every registered {@link IQueryCreationPagePart} associated with their managed type.
- *
- * @return
- */
- public Map<String, IQueryCreationPagePart2> getRegisteredWizardPageParts();
-
-}
+/** + * 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 349546 - EMF Facet facetSet editor + * Gregoire Dupe (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal; + +import java.util.Map; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart; + +/** + * This interface is dedicated to the registry + * + * TODO: This interface has to be renamed to IQueryCreationPagePartRegistry before the release of 0.2 + * + * @since 0.2 + */ +// TODO: This interface has to be renamed to IQueryCreationPagePartRegistry before the release of 0.2 +public interface IQueryCreationPagePart2Registry { + + /** + * Returns an instance of {@link QueryCreationPagePartRegistryImpl}. + */ + IQueryCreationPagePart2Registry INSTANCE = null; // TODO cf. https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 + + /** + * Return a registered {@link IQueryCreationPagePart} corresponding to the given type name. + * + * @param managedTypeName + * the type we need a part for. + * @return a registered {@link IQueryCreationPagePart} corresponding to the given type name. + */ + public IQueryCreationPagePart2 getWizardPagePartFor(EClass managedQueryType); + + /** + * Returns every registered {@link IQueryCreationPagePart} associated with their managed type. + * + * @return + */ + public Map<String, IQueryCreationPagePart2> getRegisteredWizardPageParts(); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/IQueryCreationPagePartRegistry.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/IQueryCreationPagePartRegistry.java index 4d8ff56aa95..9e0166409f4 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/IQueryCreationPagePartRegistry.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/IQueryCreationPagePartRegistry.java @@ -1,49 +1,49 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal;
-
-import java.util.Map;
-
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
-
-
-/**
- * This interface is dedicated to the registry
- *
- * @since 0.2
- * @deprecated This interface has been replaced by {@link IQueryCreationPagePart2Registry}. No tracking bug needed because this API has not been released yet.
- */
-@Deprecated
-public interface IQueryCreationPagePartRegistry {
-
- /**
- * Returns an instance of {@link QueryCreationPagePartRegistryImpl}.
- */
- IQueryCreationPagePartRegistry INSTANCE = new QueryCreationPagePartRegistryImpl();
-
- /**
- * Return a registered {@link IQueryCreationPagePart} corresponding to the given type name.
- *
- * @param managedTypeName
- * the type we need a part for.
- * @return a registered {@link IQueryCreationPagePart} corresponding to the given type name.
- */
- public IQueryCreationPagePart getWizardPagePartFor(String managedTypeName);
-
- /**
- * Returns every registered {@link IQueryCreationPagePart} associated with their managed type.
- *
- * @return
- */
- public Map<String, IQueryCreationPagePart> getRegisteredWizardPageParts();
-
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal; + +import java.util.Map; + +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart; + + +/** + * This interface is dedicated to the registry + * + * @since 0.2 + * @deprecated This interface has been replaced by {@link IQueryCreationPagePart2Registry}. No tracking bug needed because this API has not been released yet. + */ +@Deprecated +public interface IQueryCreationPagePartRegistry { + + /** + * Returns an instance of {@link QueryCreationPagePartRegistryImpl}. + */ + IQueryCreationPagePartRegistry INSTANCE = new QueryCreationPagePartRegistryImpl(); + + /** + * Return a registered {@link IQueryCreationPagePart} corresponding to the given type name. + * + * @param managedTypeName + * the type we need a part for. + * @return a registered {@link IQueryCreationPagePart} corresponding to the given type name. + */ + public IQueryCreationPagePart getWizardPagePartFor(String managedTypeName); + + /** + * Returns every registered {@link IQueryCreationPagePart} associated with their managed type. + * + * @return + */ + public Map<String, IQueryCreationPagePart> getRegisteredWizardPageParts(); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/ImageProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/ImageProvider.java index 3453e019023..c2bdca0c136 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/ImageProvider.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/ImageProvider.java @@ -1,108 +1,108 @@ -/*******************************************************************************
- * Copyright (c) 2009, 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)
- * Nicolas Bros (Mia-Software)
- * Nicolas Guyomar (Mia-Software) - Bug 339874 - Infra QuerySelectionDialog should have a "querySet" icon
- * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
- ********************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-
-/**
- * @author Grégoire Dupé (Mia-Software)
- */
-@Deprecated
-// Copied from org.eclipse.papyrus.emf.facet.infra.query.ui.ImageProvider
-public final class ImageProvider {
- // private static final String MODEL_QUERY = "icons/modelQuery.png"; //$NON-NLS-1$
- private static final String REMOVE = "icons/remove.gif"; //$NON-NLS-1$
- private static final String REMOVE_ALL = "icons/removeAll.gif"; //$NON-NLS-1$
- private static final String MODEL_QUERY_SET = "icons/ModelQuerySet.gif"; //$NON-NLS-1$
-
- private static ImageProvider singleton;
-
- private Image modelQuerySet;
-
- // private Image modelQuery;
- // private Image remove;
- // private Image removeAll;
-
- private ImageProvider() {
- // This method must not be instantiated
- }
-
- /**
- * Create an image descriptor from a resource
- *
- * @param resourcePath
- * the path of the resource (in the bundle)
- * @return the image descriptor
- */
- private ImageDescriptor createImageDescriptor(final String resourcePath) {
- ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(
- Activator.PLUGIN_ID, resourcePath);
- if (imageDescriptor == null) {
- Logger.logError(NLS.bind("Resource not found: {0}", resourcePath), Activator //$NON-NLS-1$
- .getDefault());
- return ImageDescriptor.getMissingImageDescriptor();
- }
- return imageDescriptor;
- }
-
- public static ImageProvider getInstance() {
- if (ImageProvider.singleton == null) {
- ImageProvider.singleton = new ImageProvider();
- }
- return ImageProvider.singleton;
- }
-
- public Image getModelQuerySet() {
- if (this.modelQuerySet == null) {
- this.modelQuerySet = createImageDescriptor(ImageProvider.MODEL_QUERY_SET).createImage();
- }
- return this.modelQuerySet;
- }
-
- //
- // public Image getModelQuery() {
- // if (this.modelQuery == null) {
- // this.modelQuery =
- // createImageDescriptor(ImageProvider.MODEL_QUERY).createImage();
- // }
- // return this.modelQuery;
- // }
-
- // public Image getRemove() {
- // if (this.remove == null) {
- // this.remove = createImageDescriptor(ImageProvider.REMOVE).createImage();
- // }
- // return this.remove;
- // }
- //
- // public Image getRemoveAll() {
- // if (this.removeAll == null) {
- // this.removeAll =
- // createImageDescriptor(ImageProvider.REMOVE_ALL).createImage();
- // }
- // return this.removeAll;
- // }
-
- public ImageDescriptor getRemoveImageDescriptor() {
- return createImageDescriptor(ImageProvider.REMOVE);
- }
-
- public ImageDescriptor getRemoveAllImageDescriptor() {
- return createImageDescriptor(ImageProvider.REMOVE_ALL);
- }
-}
+/******************************************************************************* + * Copyright (c) 2009, 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) + * Nicolas Bros (Mia-Software) + * Nicolas Guyomar (Mia-Software) - Bug 339874 - Infra QuerySelectionDialog should have a "querySet" icon + * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet. + ********************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.osgi.util.NLS; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.plugin.AbstractUIPlugin; + +/** + * @author Grégoire Dupé (Mia-Software) + */ +@Deprecated +// Copied from org.eclipse.papyrus.emf.facet.infra.query.ui.ImageProvider +public final class ImageProvider { + // private static final String MODEL_QUERY = "icons/modelQuery.png"; //$NON-NLS-1$ + private static final String REMOVE = "icons/remove.gif"; //$NON-NLS-1$ + private static final String REMOVE_ALL = "icons/removeAll.gif"; //$NON-NLS-1$ + private static final String MODEL_QUERY_SET = "icons/ModelQuerySet.gif"; //$NON-NLS-1$ + + private static ImageProvider singleton; + + private Image modelQuerySet; + + // private Image modelQuery; + // private Image remove; + // private Image removeAll; + + private ImageProvider() { + // This method must not be instantiated + } + + /** + * Create an image descriptor from a resource + * + * @param resourcePath + * the path of the resource (in the bundle) + * @return the image descriptor + */ + private ImageDescriptor createImageDescriptor(final String resourcePath) { + ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin( + Activator.PLUGIN_ID, resourcePath); + if (imageDescriptor == null) { + Logger.logError(NLS.bind("Resource not found: {0}", resourcePath), Activator //$NON-NLS-1$ + .getDefault()); + return ImageDescriptor.getMissingImageDescriptor(); + } + return imageDescriptor; + } + + public static ImageProvider getInstance() { + if (ImageProvider.singleton == null) { + ImageProvider.singleton = new ImageProvider(); + } + return ImageProvider.singleton; + } + + public Image getModelQuerySet() { + if (this.modelQuerySet == null) { + this.modelQuerySet = createImageDescriptor(ImageProvider.MODEL_QUERY_SET).createImage(); + } + return this.modelQuerySet; + } + + // + // public Image getModelQuery() { + // if (this.modelQuery == null) { + // this.modelQuery = + // createImageDescriptor(ImageProvider.MODEL_QUERY).createImage(); + // } + // return this.modelQuery; + // } + + // public Image getRemove() { + // if (this.remove == null) { + // this.remove = createImageDescriptor(ImageProvider.REMOVE).createImage(); + // } + // return this.remove; + // } + // + // public Image getRemoveAll() { + // if (this.removeAll == null) { + // this.removeAll = + // createImageDescriptor(ImageProvider.REMOVE_ALL).createImage(); + // } + // return this.removeAll; + // } + + public ImageDescriptor getRemoveImageDescriptor() { + return createImageDescriptor(ImageProvider.REMOVE); + } + + public ImageDescriptor getRemoveAllImageDescriptor() { + return createImageDescriptor(ImageProvider.REMOVE_ALL); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/Messages.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/Messages.java index 76dcc0d35b6..82c2c2d24ea 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/Messages.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/Messages.java @@ -1,164 +1,164 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- * Nicolas Bros (Mia-Software) - Bug 370442 - rewrite the Facet loading dialog for v0.2
- * Grégoire Dupé (Mia-Software) - copied from org.eclipse.papyrus.emf.facet.infra.query.ui.Messages
- * Nicolas Bros (Mia-Software) - copied from org.eclipse.papyrus.emf.facet.infra.query.ui.Messages
- * 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 372732 - [Facet] Rewrite the catalog views for 0.2
- * Nicolas Bros (Mia-Software) - Bug 372865 - FacetSet selection dialog
- * Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets
- * Nicolas Bros (Mia-Software) - Bug 379518 - NLS missing messages
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal;
-
-import org.eclipse.osgi.util.NLS;
-
-public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.papyrus.emf.facet.efacet.ui.internal.messages"; //$NON-NLS-1$
-
- public static String Enter_a_nsUri;
- public static String Please_enter_nsUri;
-
- public static String Enter_a_prefix;
- public static String ETypedElementSelectionControl_FlatView;
-
- public static String ETypedElementSelectionControl_invalidSelectionAtLeastOneElement;
- public static String ETypedElementSelectionControl_invalidSelection;
- public static String ETypedElementSelectionControl_invalidSelectionAtMostXElements;
- public static String ETypedElementSelectionControl_invalidSelectionETypedElementsOnly;
- public static String ETypedElementSelectionDialog_dialogTitle;
- public static String ETypedElementSelectionDialog_dialogTitleMultiSelection;
- public static String ETypedElementSelectionDialog_radioButtonMultiSelection;
- public static String ETypedElementSelectionDialog_radioButtonNoSelection;
- public static String ETypedElementSelectionDialog_radioButtonSingleSelection;
-
- public static String ETypedElementSelectionSortedControl_groupByMetamodelView;
-
- public static String ETypedElementSelectionSortedControl_toolTip;
-
- public static String Please_enter_prefix;
-
- public static String Please_select_EPackage;
- public static String Select_EPackage;
-
- public static String Operation;
- public static String Parameter_name;
- public static String Operation_name;
- public static String Reference_name;
- public static String Attribute_name;
-
- public static String Add_an_Attribute;
- public static String Add_an_Attribute_desc;
- public static String Add_a_Reference;
- public static String Add_a_Reference_desc;
- public static String Add_an_Operation;
- public static String Add_an_Operation_desc;
- public static String Add_an_Operation_Parameter;
- public static String Add_an_Operation_Parameter_desc;
-
- public static String FacetSet;
- public static String FacetSetsCatalogView_categoriesColumn;
- public static String FacetSetsCatalogView_documentationColumn;
- public static String FacetSetsCatalogView_extendsColumn;
- public static String FacetSetsCatalogView_nameColumn;
- public static String FacetSetsCatalogView_viewTitle;
- public static String FacetSetSelectionControl_mustSelectAtLeastOneElement;
- public static String FacetSetSelectionControl_mustSelectAtMostNElements;
- public static String FacetSetSelectionControl_onlyFacetSetsAllowedInSelection;
- public static String FacetSetSelectionControl_selectionContainsInvalidElements;
- public static String FacetSetSelectionDialog_deselectAll;
- public static String FacetSetSelectionDialog_selectAll;
- public static String FacetSetSelectionDialog_titleSelectFacetSet;
- public static String FacetSetSelectionDialog_titleSelectFacetSets;
- public static String Facet;
-
- public static String Changeable;
- public static String Derived;
- public static String Ordered;
- public static String Transient;
- public static String Unique;
- public static String Volatile;
-
- public static String Lower_bound;
- public static String Upper_bound;
-
- public static String Select_EClass;
- public static String Select_EClassifier;
- public static String Select_EDataType;
-
- public static String No_result_found;
-
- public static String Select;
- public static String Type;
-
- public static String Create_FacetSet_Model;
-
- public static String CreateFacetInFacetSetWizardPage_could_not_find_wizard_page;
- public static String Please_enter_value_for;
- public static String Create_facet_in_facetSet;
-
- public static String CreateFacetInFacetSetWizardPage_Please_fill_extendedMetaClass;
- public static String CreateFacetInFacetSetWizardPage_Sub_Typing_Facet;
- public static String CreateFacetInFacetSetWizardPage_wizard_description;
- public static String CreateFacetSetWizardImpl_Create_new_facet_Set;
- public static String CreateFacetSetWizardImpl_FacetModel;
- public static String CreateFacetSetWizardImpl_File_extension_restriction;
-
- public static String CreateFacetSetWizardPage_Not_a_Plugin_project;
- public static String Create_Query;
- public static String FilteredElementSelectionControl_type_filter_text;
- public static String Load_MetaModel_Resource;
- public static String FacetSetSelectionDialog_selectFacetSetsMessage;
- public static String FacetSetSelectionDialog_selectFacetSetsTitle;
- public static String Package_Selection;
- public static String Select_Registered_URI;
-
- public static String ExtendedMetaClass;
- public static String SelectQueryTypeWizardPage_No_wizard_found;
- public static String SelectQueryTypeWizardPage_Query_Type;
- public static String JavaQueryWizardPage_Can_be_cached;
- public static String JavaQueryWizardPage_has_side_effect;
- public static String JavaQueryWizardPage_Query_name;
-
- // Begin copied from org.eclipse.papyrus.emf.facet.infra.query.ui.Messages
- public static String QueryExecutionView_0;
- public static String QueryExecutionView_1;
- public static String QueryExecutionView_classpathWarning;
- public static String QueryExecutionView_errorInBundleClasspath;
- public static String QueryExecutionView_execEnvNotAvailable;
- public static String QueryExecutionView_execEnvError;
- public static String QueryExecutionView_Context;
- public static String QueryExecutionView_DisplayResultIn;
- public static String QueryExecutionView_dragAndDropHint;
- public static String QueryExecutionView_ErrorExecutingQuery;
-
- public static String QueryExecutionView_ETypedElementsGroup;
- public static String QueryExecutionView_ExecuteButton;
- public static String QueryExecutionView_ExecuteGroup;
- public static String QueryExecutionView_NoQueryDisplayer;
- public static String QueryExecutionView_NoQuerySelected;
- public static String QueryExecutionView_NullQueryResult;
- public static String QueryExecutionView_notImplementedYet;
- public static String QueryExecutionView_Parameters;
- public static String QueryExecutionView_Query;
- public static String QueryExecutionView_QueryException;
- public static String QueryExecutionView_QueryReturnedNull;
- public static String QueryExecutionView_SelectQueryToExecute;
- // End copied from org.eclipse.papyrus.emf.facet.infra.query.ui.Messages
-
- static {
- // initialize resource bundle
- NLS.initializeMessages(Messages.BUNDLE_NAME, Messages.class);
- }
-
- private Messages() {
- }
-}
+/** + * 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 349546 - EMF Facet facetSet editor + * Nicolas Bros (Mia-Software) - Bug 370442 - rewrite the Facet loading dialog for v0.2 + * Grégoire Dupé (Mia-Software) - copied from org.eclipse.papyrus.emf.facet.infra.query.ui.Messages + * Nicolas Bros (Mia-Software) - copied from org.eclipse.papyrus.emf.facet.infra.query.ui.Messages + * 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 372732 - [Facet] Rewrite the catalog views for 0.2 + * Nicolas Bros (Mia-Software) - Bug 372865 - FacetSet selection dialog + * Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets + * Nicolas Bros (Mia-Software) - Bug 379518 - NLS missing messages + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.papyrus.emf.facet.efacet.ui.internal.messages"; //$NON-NLS-1$ + + public static String Enter_a_nsUri; + public static String Please_enter_nsUri; + + public static String Enter_a_prefix; + public static String ETypedElementSelectionControl_FlatView; + + public static String ETypedElementSelectionControl_invalidSelectionAtLeastOneElement; + public static String ETypedElementSelectionControl_invalidSelection; + public static String ETypedElementSelectionControl_invalidSelectionAtMostXElements; + public static String ETypedElementSelectionControl_invalidSelectionETypedElementsOnly; + public static String ETypedElementSelectionDialog_dialogTitle; + public static String ETypedElementSelectionDialog_dialogTitleMultiSelection; + public static String ETypedElementSelectionDialog_radioButtonMultiSelection; + public static String ETypedElementSelectionDialog_radioButtonNoSelection; + public static String ETypedElementSelectionDialog_radioButtonSingleSelection; + + public static String ETypedElementSelectionSortedControl_groupByMetamodelView; + + public static String ETypedElementSelectionSortedControl_toolTip; + + public static String Please_enter_prefix; + + public static String Please_select_EPackage; + public static String Select_EPackage; + + public static String Operation; + public static String Parameter_name; + public static String Operation_name; + public static String Reference_name; + public static String Attribute_name; + + public static String Add_an_Attribute; + public static String Add_an_Attribute_desc; + public static String Add_a_Reference; + public static String Add_a_Reference_desc; + public static String Add_an_Operation; + public static String Add_an_Operation_desc; + public static String Add_an_Operation_Parameter; + public static String Add_an_Operation_Parameter_desc; + + public static String FacetSet; + public static String FacetSetsCatalogView_categoriesColumn; + public static String FacetSetsCatalogView_documentationColumn; + public static String FacetSetsCatalogView_extendsColumn; + public static String FacetSetsCatalogView_nameColumn; + public static String FacetSetsCatalogView_viewTitle; + public static String FacetSetSelectionControl_mustSelectAtLeastOneElement; + public static String FacetSetSelectionControl_mustSelectAtMostNElements; + public static String FacetSetSelectionControl_onlyFacetSetsAllowedInSelection; + public static String FacetSetSelectionControl_selectionContainsInvalidElements; + public static String FacetSetSelectionDialog_deselectAll; + public static String FacetSetSelectionDialog_selectAll; + public static String FacetSetSelectionDialog_titleSelectFacetSet; + public static String FacetSetSelectionDialog_titleSelectFacetSets; + public static String Facet; + + public static String Changeable; + public static String Derived; + public static String Ordered; + public static String Transient; + public static String Unique; + public static String Volatile; + + public static String Lower_bound; + public static String Upper_bound; + + public static String Select_EClass; + public static String Select_EClassifier; + public static String Select_EDataType; + + public static String No_result_found; + + public static String Select; + public static String Type; + + public static String Create_FacetSet_Model; + + public static String CreateFacetInFacetSetWizardPage_could_not_find_wizard_page; + public static String Please_enter_value_for; + public static String Create_facet_in_facetSet; + + public static String CreateFacetInFacetSetWizardPage_Please_fill_extendedMetaClass; + public static String CreateFacetInFacetSetWizardPage_Sub_Typing_Facet; + public static String CreateFacetInFacetSetWizardPage_wizard_description; + public static String CreateFacetSetWizardImpl_Create_new_facet_Set; + public static String CreateFacetSetWizardImpl_FacetModel; + public static String CreateFacetSetWizardImpl_File_extension_restriction; + + public static String CreateFacetSetWizardPage_Not_a_Plugin_project; + public static String Create_Query; + public static String FilteredElementSelectionControl_type_filter_text; + public static String Load_MetaModel_Resource; + public static String FacetSetSelectionDialog_selectFacetSetsMessage; + public static String FacetSetSelectionDialog_selectFacetSetsTitle; + public static String Package_Selection; + public static String Select_Registered_URI; + + public static String ExtendedMetaClass; + public static String SelectQueryTypeWizardPage_No_wizard_found; + public static String SelectQueryTypeWizardPage_Query_Type; + public static String JavaQueryWizardPage_Can_be_cached; + public static String JavaQueryWizardPage_has_side_effect; + public static String JavaQueryWizardPage_Query_name; + + // Begin copied from org.eclipse.papyrus.emf.facet.infra.query.ui.Messages + public static String QueryExecutionView_0; + public static String QueryExecutionView_1; + public static String QueryExecutionView_classpathWarning; + public static String QueryExecutionView_errorInBundleClasspath; + public static String QueryExecutionView_execEnvNotAvailable; + public static String QueryExecutionView_execEnvError; + public static String QueryExecutionView_Context; + public static String QueryExecutionView_DisplayResultIn; + public static String QueryExecutionView_dragAndDropHint; + public static String QueryExecutionView_ErrorExecutingQuery; + + public static String QueryExecutionView_ETypedElementsGroup; + public static String QueryExecutionView_ExecuteButton; + public static String QueryExecutionView_ExecuteGroup; + public static String QueryExecutionView_NoQueryDisplayer; + public static String QueryExecutionView_NoQuerySelected; + public static String QueryExecutionView_NullQueryResult; + public static String QueryExecutionView_notImplementedYet; + public static String QueryExecutionView_Parameters; + public static String QueryExecutionView_Query; + public static String QueryExecutionView_QueryException; + public static String QueryExecutionView_QueryReturnedNull; + public static String QueryExecutionView_SelectQueryToExecute; + // End copied from org.eclipse.papyrus.emf.facet.infra.query.ui.Messages + + static { + // initialize resource bundle + NLS.initializeMessages(Messages.BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/QueryCreationPagePartRegistryImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/QueryCreationPagePartRegistryImpl.java index 311d2f910ed..7447a814bf0 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/QueryCreationPagePartRegistryImpl.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/QueryCreationPagePartRegistryImpl.java @@ -1,77 +1,77 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal;
-
-import java.util.HashMap;
-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.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-
-//TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-@Deprecated
-public class QueryCreationPagePartRegistryImpl implements IQueryCreationPagePartRegistry {
-
- private static final String EXTENSION_POINT_ID = "org.eclipse.papyrus.emf.facet.efacet.ui.queryFactoryWizardPageRegistration"; //$NON-NLS-1$
- private static final String WIZARD_PAGE = "wizardPage"; //$NON-NLS-1$
- private static final String MANAGED_TYPE_NAME = "managedQueryTypeName"; //$NON-NLS-1$
-
- private final Map<String, IQueryCreationPagePart> queryEvaluatorFactories = new HashMap<String, IQueryCreationPagePart>();
-
- public QueryCreationPagePartRegistryImpl() {
- initRegisteredEntries();
- }
-
- private void initRegisteredEntries() {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint extPoint = registry.getExtensionPoint(QueryCreationPagePartRegistryImpl.EXTENSION_POINT_ID);
- if (extPoint != null) {
- for (IExtension ext : extPoint.getExtensions()) {
- for (IConfigurationElement configElt : ext.getConfigurationElements()) {
-
- IQueryCreationPagePart queryCreationWizardPage;
- try {
- configElt.createExecutableExtension(QueryCreationPagePartRegistryImpl.WIZARD_PAGE);
- queryCreationWizardPage = (IQueryCreationPagePart) configElt
- .createExecutableExtension(QueryCreationPagePartRegistryImpl.WIZARD_PAGE);
- String managedQueryTypeName = configElt.getAttribute(QueryCreationPagePartRegistryImpl.MANAGED_TYPE_NAME);
- if (this.queryEvaluatorFactories.containsKey(managedQueryTypeName)) {
- Logger.logError("A conflict occurred for " //$NON-NLS-1$
- + managedQueryTypeName + " query IQueryCreationPage. Only one creationPage is allowed at the same time.", //$NON-NLS-1$
- Activator.getDefault());
- } else {
- this.queryEvaluatorFactories.put(managedQueryTypeName, queryCreationWizardPage);
- }
- } catch (CoreException e) {
- Logger.logError(e, Activator.getDefault());
- }
- }
- }
- } else {
- Logger.logError("Could not find extensionPoint: " + QueryCreationPagePartRegistryImpl.EXTENSION_POINT_ID, Activator.getDefault()); //$NON-NLS-1$
- }
- }
-
- public IQueryCreationPagePart getWizardPagePartFor(final String managedTypeName) {
- return this.queryEvaluatorFactories.get(managedTypeName);
- }
-
- public Map<String, IQueryCreationPagePart> getRegisteredWizardPageParts() {
- 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal; + +import java.util.HashMap; +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.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart; +import org.eclipse.papyrus.emf.facet.util.core.Logger; + +//TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +@Deprecated +public class QueryCreationPagePartRegistryImpl implements IQueryCreationPagePartRegistry { + + private static final String EXTENSION_POINT_ID = "org.eclipse.papyrus.emf.facet.efacet.ui.queryFactoryWizardPageRegistration"; //$NON-NLS-1$ + private static final String WIZARD_PAGE = "wizardPage"; //$NON-NLS-1$ + private static final String MANAGED_TYPE_NAME = "managedQueryTypeName"; //$NON-NLS-1$ + + private final Map<String, IQueryCreationPagePart> queryEvaluatorFactories = new HashMap<String, IQueryCreationPagePart>(); + + public QueryCreationPagePartRegistryImpl() { + initRegisteredEntries(); + } + + private void initRegisteredEntries() { + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IExtensionPoint extPoint = registry.getExtensionPoint(QueryCreationPagePartRegistryImpl.EXTENSION_POINT_ID); + if (extPoint != null) { + for (IExtension ext : extPoint.getExtensions()) { + for (IConfigurationElement configElt : ext.getConfigurationElements()) { + + IQueryCreationPagePart queryCreationWizardPage; + try { + configElt.createExecutableExtension(QueryCreationPagePartRegistryImpl.WIZARD_PAGE); + queryCreationWizardPage = (IQueryCreationPagePart) configElt + .createExecutableExtension(QueryCreationPagePartRegistryImpl.WIZARD_PAGE); + String managedQueryTypeName = configElt.getAttribute(QueryCreationPagePartRegistryImpl.MANAGED_TYPE_NAME); + if (this.queryEvaluatorFactories.containsKey(managedQueryTypeName)) { + Logger.logError("A conflict occurred for " //$NON-NLS-1$ + + managedQueryTypeName + " query IQueryCreationPage. Only one creationPage is allowed at the same time.", //$NON-NLS-1$ + Activator.getDefault()); + } else { + this.queryEvaluatorFactories.put(managedQueryTypeName, queryCreationWizardPage); + } + } catch (CoreException e) { + Logger.logError(e, Activator.getDefault()); + } + } + } + } else { + Logger.logError("Could not find extensionPoint: " + QueryCreationPagePartRegistryImpl.EXTENSION_POINT_ID, Activator.getDefault()); //$NON-NLS-1$ + } + } + + public IQueryCreationPagePart getWizardPagePartFor(final String managedTypeName) { + return this.queryEvaluatorFactories.get(managedTypeName); + } + + public Map<String, IQueryCreationPagePart> getRegisteredWizardPageParts() { + return this.queryEvaluatorFactories; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/actions/LoadMetaModelResourceAction.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/actions/LoadMetaModelResourceAction.java index 7beca855805..8ed38aceee7 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/actions/LoadMetaModelResourceAction.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/actions/LoadMetaModelResourceAction.java @@ -1,100 +1,100 @@ -/*******************************************************************************
- * Copyright (c) 2009,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) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.actions;
-
-import java.util.Arrays;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EPackage.Registry;
-import org.eclipse.emf.ecore.provider.EcoreEditPlugin;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.edit.ui.action.LoadResourceAction;
-import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.papyrus.emf.facet.common.ui.internal.widgets.AnywhereFilterMatcher;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
-
-// This class has been copied from org.eclipse.papyrus.emf.facet.infra.facet.editor.presentation.LoadMetaModelResourceAction
-
-/**
- * @author Gregoire Dupe
- *
- */
-public class LoadMetaModelResourceAction extends LoadResourceAction {
-
- public LoadMetaModelResourceAction() {
- super();
- setText(Messages.Load_MetaModel_Resource);
- }
-
- @Override
- public void run() {
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
-
- RegisteredPackageDialog registeredPackageDialog = new RegisteredPackageDialog(shell);
- registeredPackageDialog.open();
- Object[] results = registeredPackageDialog.getResult();
- // if user cancel the selection of meta models, results = null
- if (results != null) {
- ResourceSet resourceSet = this.domain.getResourceSet();
- for (Object result : results) {
- URI uri = URI.createURI(result.toString());
- Resource r = resourceSet.getResource(uri, true);
- if (!resourceSet.getResources().contains(r)) {
- Registry packageRegistry = resourceSet.getPackageRegistry();
- for (EObject eObject : r.getContents()) {
- if (eObject instanceof EPackage) {
- EPackage ePackage = (EPackage) eObject;
- packageRegistry.put(ePackage.getNsURI(), ePackage);
- }
- }
- resourceSet.getResources().add(r);
- }
- }
- }
- }
-
- public class RegisteredPackageDialog extends ElementListSelectionDialog {
-
- public RegisteredPackageDialog(final Shell parent) {
- super(parent, new LabelProvider() {
- @Override
- public Image getImage(final Object element) {
- return ExtendedImageRegistry.getInstance().getImage(EcoreEditPlugin.INSTANCE.getImage("full/obj16/EPackage")); //$NON-NLS-1$
- }
- });
-
- setMultipleSelection(true);
- setMessage(Messages.Select_Registered_URI);
- setTitle(Messages.Package_Selection);
- Object[] result = EPackage.Registry.INSTANCE.keySet().toArray(new Object[EPackage.Registry.INSTANCE.size()]);
- Arrays.sort(result);
- setElements(result);
- }
-
- @Override
- protected Control createDialogArea(final Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- this.fFilteredList.setFilterMatcher(new AnywhereFilterMatcher());
- return composite;
- }
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2009,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) - initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.actions; + +import java.util.Arrays; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EPackage.Registry; +import org.eclipse.emf.ecore.provider.EcoreEditPlugin; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.edit.ui.action.LoadResourceAction; +import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.papyrus.emf.facet.common.ui.internal.widgets.AnywhereFilterMatcher; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.ElementListSelectionDialog; + +// This class has been copied from org.eclipse.papyrus.emf.facet.infra.facet.editor.presentation.LoadMetaModelResourceAction + +/** + * @author Gregoire Dupe + * + */ +public class LoadMetaModelResourceAction extends LoadResourceAction { + + public LoadMetaModelResourceAction() { + super(); + setText(Messages.Load_MetaModel_Resource); + } + + @Override + public void run() { + Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + + RegisteredPackageDialog registeredPackageDialog = new RegisteredPackageDialog(shell); + registeredPackageDialog.open(); + Object[] results = registeredPackageDialog.getResult(); + // if user cancel the selection of meta models, results = null + if (results != null) { + ResourceSet resourceSet = this.domain.getResourceSet(); + for (Object result : results) { + URI uri = URI.createURI(result.toString()); + Resource r = resourceSet.getResource(uri, true); + if (!resourceSet.getResources().contains(r)) { + Registry packageRegistry = resourceSet.getPackageRegistry(); + for (EObject eObject : r.getContents()) { + if (eObject instanceof EPackage) { + EPackage ePackage = (EPackage) eObject; + packageRegistry.put(ePackage.getNsURI(), ePackage); + } + } + resourceSet.getResources().add(r); + } + } + } + } + + public class RegisteredPackageDialog extends ElementListSelectionDialog { + + public RegisteredPackageDialog(final Shell parent) { + super(parent, new LabelProvider() { + @Override + public Image getImage(final Object element) { + return ExtendedImageRegistry.getInstance().getImage(EcoreEditPlugin.INSTANCE.getImage("full/obj16/EPackage")); //$NON-NLS-1$ + } + }); + + setMultipleSelection(true); + setMessage(Messages.Select_Registered_URI); + setTitle(Messages.Package_Selection); + Object[] result = EPackage.Registry.INSTANCE.keySet().toArray(new Object[EPackage.Registry.INSTANCE.size()]); + Arrays.sort(result); + setElements(result); + } + + @Override + protected Control createDialogArea(final Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + this.fFilteredList.setFilterMatcher(new AnywhereFilterMatcher()); + return composite; + } + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/composites/BrowseComposite.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/composites/BrowseComposite.java index 2aa6441c5dc..e0cbe8bae43 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/composites/BrowseComposite.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/composites/BrowseComposite.java @@ -1,124 +1,124 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- * Gregoire Dupe (Mia-Software) - Bug 373248 - Clean PMD errors
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Text;
-
-@SuppressWarnings("PMD.ConstructorCallsOverridableMethod")
-// @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") Temporary: this class must be deeply refactored.
-// TODO remove the @SuppressWarnings("PMD.ConstructorCallsOverridableMethod")
-// cf. bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=373248
-public class BrowseComposite extends Composite {
-
- private Text textField;
- private Button browseButton;
- private String browseButtonText = "..."; //$NON-NLS-1$
-
- public BrowseComposite(final Composite parent, final int style) {
- this(parent, style, null, true);
- }
-
- public BrowseComposite(final Composite parent, final int style, final String buttonName, final boolean canBeChanged) {
- super(parent, SWT.NONE);
- if (buttonName != null) {
- this.browseButtonText = buttonName;
- }
- setEnabled(canBeChanged);
- GridLayout layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- final int horizontalSpacing = 4;
- layout.horizontalSpacing = horizontalSpacing;
- layout.verticalSpacing = 0;
- layout.makeColumnsEqualWidth = false;
- layout.numColumns = 2;
- setLayout(layout);
- setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
- createWidgets(style);
- init();
- }
-
- public void addModifyListener(final ModifyListener modifyListener) {
- if (this.textField != null) {
- this.textField.addModifyListener(modifyListener);
- }
- }
-
- public void removeModifyListener(final ModifyListener modifyListener) {
- if (this.textField != null) {
- this.textField.removeModifyListener(modifyListener);
- }
- }
-
- protected void createWidgets(final int style) {
- this.textField = new Text(this, SWT.SINGLE | style);
- this.browseButton = new Button(this, SWT.PUSH);
- }
-
- private void init() {
- this.textField.setEditable(false);
- // We want the background white so that the user notices that there is something missing in
- // the textField, but he has to use the "..." button
- this.textField.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
- this.textField.setBounds(getBounds());
- this.textField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- this.textField.addKeyListener(new KeyListener() {
- public void keyReleased(final KeyEvent e) {
- // Nothing on release
- }
-
- public void keyPressed(final KeyEvent event) {
- // Enter key pressed
- if ((event.keyCode == SWT.CR && event.stateMask == 0) || (event.keyCode == SWT.KEYPAD_CR && event.stateMask == 0)) {
- handleBrowse();
- }
- }
- });
-
- this.browseButton.setText(this.browseButtonText);
- this.browseButton.setEnabled(isEnabled());
- GridData data = new GridData(SWT.FILL, SWT.FILL, false, true);
- this.browseButton.setLayoutData(data);
- this.browseButton.addSelectionListener(new SelectionListener() {
- public void widgetSelected(final SelectionEvent e) {
- handleBrowse();
- }
-
- public void widgetDefaultSelected(final SelectionEvent e) {
- // Nothing
- }
- });
- }
-
- protected void handleBrowse() {
- // Meant to be overridden
- }
-
- public void updateTextFieldContent(final String content) {
- if (this.textField != null) {
- this.textField.setText(content);
- this.textField.setFocus();
- }
- }
-}
+/** + * 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 349546 - EMF Facet facetSet editor + * Gregoire Dupe (Mia-Software) - Bug 373248 - Clean PMD errors + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Text; + +@SuppressWarnings("PMD.ConstructorCallsOverridableMethod") +// @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") Temporary: this class must be deeply refactored. +// TODO remove the @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") +// cf. bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=373248 +public class BrowseComposite extends Composite { + + private Text textField; + private Button browseButton; + private String browseButtonText = "..."; //$NON-NLS-1$ + + public BrowseComposite(final Composite parent, final int style) { + this(parent, style, null, true); + } + + public BrowseComposite(final Composite parent, final int style, final String buttonName, final boolean canBeChanged) { + super(parent, SWT.NONE); + if (buttonName != null) { + this.browseButtonText = buttonName; + } + setEnabled(canBeChanged); + GridLayout layout = new GridLayout(); + layout.marginHeight = 0; + layout.marginWidth = 0; + final int horizontalSpacing = 4; + layout.horizontalSpacing = horizontalSpacing; + layout.verticalSpacing = 0; + layout.makeColumnsEqualWidth = false; + layout.numColumns = 2; + setLayout(layout); + setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); + createWidgets(style); + init(); + } + + public void addModifyListener(final ModifyListener modifyListener) { + if (this.textField != null) { + this.textField.addModifyListener(modifyListener); + } + } + + public void removeModifyListener(final ModifyListener modifyListener) { + if (this.textField != null) { + this.textField.removeModifyListener(modifyListener); + } + } + + protected void createWidgets(final int style) { + this.textField = new Text(this, SWT.SINGLE | style); + this.browseButton = new Button(this, SWT.PUSH); + } + + private void init() { + this.textField.setEditable(false); + // We want the background white so that the user notices that there is something missing in + // the textField, but he has to use the "..." button + this.textField.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE)); + this.textField.setBounds(getBounds()); + this.textField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + this.textField.addKeyListener(new KeyListener() { + public void keyReleased(final KeyEvent e) { + // Nothing on release + } + + public void keyPressed(final KeyEvent event) { + // Enter key pressed + if ((event.keyCode == SWT.CR && event.stateMask == 0) || (event.keyCode == SWT.KEYPAD_CR && event.stateMask == 0)) { + handleBrowse(); + } + } + }); + + this.browseButton.setText(this.browseButtonText); + this.browseButton.setEnabled(isEnabled()); + GridData data = new GridData(SWT.FILL, SWT.FILL, false, true); + this.browseButton.setLayoutData(data); + this.browseButton.addSelectionListener(new SelectionListener() { + public void widgetSelected(final SelectionEvent e) { + handleBrowse(); + } + + public void widgetDefaultSelected(final SelectionEvent e) { + // Nothing + } + }); + } + + protected void handleBrowse() { + // Meant to be overridden + } + + public void updateTextFieldContent(final String content) { + if (this.textField != null) { + this.textField.setText(content); + this.textField.setFocus(); + } + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/composites/FilteredElementSelectionComposite.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/composites/FilteredElementSelectionComposite.java index 2e7abb314fa..7d626872a2e 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/composites/FilteredElementSelectionComposite.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/composites/FilteredElementSelectionComposite.java @@ -1,134 +1,134 @@ -/*******************************************************************************
- * Copyright (c) 2010, 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) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites;
-
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.FilteredList;
-
-/**
- * A control for selecting an element from a list of elements, that can be filtered using the
- * associated text field.
- */
-public class FilteredElementSelectionComposite extends Composite {
-
- private final Text filterText;
- private final FilteredList fFilteredList;
-
- public FilteredElementSelectionComposite(final Composite parent, final boolean matchAnywhere, final boolean multiSelection) {
- super(parent, SWT.BORDER);
- setLayout(new GridLayout());
-
- this.filterText = createFilterText(this);
- this.fFilteredList = createFilteredList(this, multiSelection);
-
- final String matchPrefix;
- if (matchAnywhere) {
- matchPrefix = "*"; //$NON-NLS-1$
- } else {
- matchPrefix = ""; //$NON-NLS-1$
- }
-
- this.filterText.addModifyListener(new ModifyListener() {
- public void modifyText(final ModifyEvent e) {
- getfFilteredList().setFilter(matchPrefix + getFilterText().getText());
- }
- });
-
- this.filterText.addKeyListener(new KeyListener() {
- public void keyPressed(final KeyEvent e) {
- if (e.keyCode == SWT.ARROW_DOWN) {
- getfFilteredList().setFocus();
- }
- }
-
- public void keyReleased(final KeyEvent e) {
- // nothing
- }
- });
- }
-
- public void setElements(final Object[] elements) {
- this.fFilteredList.setElements(elements);
- }
-
- protected static FilteredList createFilteredList(final Composite parent, final boolean multiSelection) {
- int multi;
- if (multiSelection) {
- multi = SWT.MULTI;
- } else {
- multi = SWT.SINGLE;
- }
- final FilteredList filteredList = new FilteredList(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | multi, new LabelProvider(), true,
- false, true);
-
- final GridData data = new GridData();
- data.grabExcessVerticalSpace = true;
- data.grabExcessHorizontalSpace = true;
- data.horizontalAlignment = GridData.FILL;
- data.verticalAlignment = GridData.FILL;
- filteredList.setLayoutData(data);
- filteredList.setFilter(""); //$NON-NLS-1$
-
- return filteredList;
- }
-
- protected static Text createFilterText(final Composite parent) {
- final Text text = new Text(parent, SWT.BORDER);
- text.setMessage(Messages.FilteredElementSelectionControl_type_filter_text);
-
- final GridData data = new GridData();
- data.grabExcessVerticalSpace = false;
- data.grabExcessHorizontalSpace = true;
- data.horizontalAlignment = GridData.FILL;
- data.verticalAlignment = GridData.BEGINNING;
- text.setLayoutData(data);
-
- return text;
- }
-
- public Object getFirstSelectedElement() {
- final Object[] selection = this.fFilteredList.getSelection();
- if (selection.length > 0) {
- return selection[0];
- }
- return null;
- }
-
- public Object[] getSelectedElements() {
- Object[] selection = this.fFilteredList.getSelection();
- if (selection.length == 0) {
- return null;
- }
- return selection;
- }
-
- public FilteredList getFilteredList() {
- return this.fFilteredList;
- }
-
- public Text getFilterText() {
- return this.filterText;
- }
-
- protected FilteredList getfFilteredList() {
- return this.fFilteredList;
- }
-}
+/******************************************************************************* + * Copyright (c) 2010, 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) - initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites; + +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.dialogs.FilteredList; + +/** + * A control for selecting an element from a list of elements, that can be filtered using the + * associated text field. + */ +public class FilteredElementSelectionComposite extends Composite { + + private final Text filterText; + private final FilteredList fFilteredList; + + public FilteredElementSelectionComposite(final Composite parent, final boolean matchAnywhere, final boolean multiSelection) { + super(parent, SWT.BORDER); + setLayout(new GridLayout()); + + this.filterText = createFilterText(this); + this.fFilteredList = createFilteredList(this, multiSelection); + + final String matchPrefix; + if (matchAnywhere) { + matchPrefix = "*"; //$NON-NLS-1$ + } else { + matchPrefix = ""; //$NON-NLS-1$ + } + + this.filterText.addModifyListener(new ModifyListener() { + public void modifyText(final ModifyEvent e) { + getfFilteredList().setFilter(matchPrefix + getFilterText().getText()); + } + }); + + this.filterText.addKeyListener(new KeyListener() { + public void keyPressed(final KeyEvent e) { + if (e.keyCode == SWT.ARROW_DOWN) { + getfFilteredList().setFocus(); + } + } + + public void keyReleased(final KeyEvent e) { + // nothing + } + }); + } + + public void setElements(final Object[] elements) { + this.fFilteredList.setElements(elements); + } + + protected static FilteredList createFilteredList(final Composite parent, final boolean multiSelection) { + int multi; + if (multiSelection) { + multi = SWT.MULTI; + } else { + multi = SWT.SINGLE; + } + final FilteredList filteredList = new FilteredList(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | multi, new LabelProvider(), true, + false, true); + + final GridData data = new GridData(); + data.grabExcessVerticalSpace = true; + data.grabExcessHorizontalSpace = true; + data.horizontalAlignment = GridData.FILL; + data.verticalAlignment = GridData.FILL; + filteredList.setLayoutData(data); + filteredList.setFilter(""); //$NON-NLS-1$ + + return filteredList; + } + + protected static Text createFilterText(final Composite parent) { + final Text text = new Text(parent, SWT.BORDER); + text.setMessage(Messages.FilteredElementSelectionControl_type_filter_text); + + final GridData data = new GridData(); + data.grabExcessVerticalSpace = false; + data.grabExcessHorizontalSpace = true; + data.horizontalAlignment = GridData.FILL; + data.verticalAlignment = GridData.BEGINNING; + text.setLayoutData(data); + + return text; + } + + public Object getFirstSelectedElement() { + final Object[] selection = this.fFilteredList.getSelection(); + if (selection.length > 0) { + return selection[0]; + } + return null; + } + + public Object[] getSelectedElements() { + Object[] selection = this.fFilteredList.getSelection(); + if (selection.length == 0) { + return null; + } + return selection; + } + + public FilteredList getFilteredList() { + return this.fFilteredList; + } + + public Text getFilterText() { + return this.filterText; + } + + protected FilteredList getfFilteredList() { + return this.fFilteredList; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/composites/SelectETypeComposite.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/composites/SelectETypeComposite.java index 1bbca042fd3..48ae6c4da07 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/composites/SelectETypeComposite.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/composites/SelectETypeComposite.java @@ -1,172 +1,172 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- * Gregoire Dupe (Mia-Software) - Bug 373248 - Clean PMD errors
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.SelectETypeWizardImpl;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-@SuppressWarnings("PMD.ConstructorCallsOverridableMethod")
-// @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") Temporary: this class must be deeply refactored.
-// TODO remove the @SuppressWarnings("PMD.ConstructorCallsOverridableMethod")
-// cf. bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=373248
-public class SelectETypeComposite extends Composite {
-
- private static final int NUMBER_COLUMN = 3;
-
- /** to be returned by the composite */
- private EClassifier selectedEType = null;
-
- private EditingDomain editingDomain;
-
- private Label eTypeLabel;
- private Button selectButton;
- private Text eTypedTextField;
-
- private ETypeSelectionOptions eTypeSelectionOption;
-
- private boolean canChangeEPackage = true;
-
- private final EPackage ePackage;
-
- public enum ETypeSelectionOptions {
- ECLASSIFIER, EDATATYPE, ECLASS
- }
-
- public SelectETypeComposite(final Composite parent, final int style, final ETypeSelectionOptions option, final boolean canChangeEPackage,
- final EPackage ePackage) {
- super(parent, style);
- this.eTypeSelectionOption = option;
- this.ePackage = ePackage;
- this.canChangeEPackage = canChangeEPackage;
- init();
- }
-
- protected void createCompositeWidget() {
- this.eTypeLabel = new Label(this, SWT.NULL);
- this.eTypedTextField = new Text(this, SWT.BORDER | SWT.SINGLE);
- this.selectButton = new Button(this, SWT.PUSH);
- }
-
- private void init() {
- GridLayout gridLayout = new GridLayout(SelectETypeComposite.NUMBER_COLUMN, false);
- setLayout(gridLayout);
- createCompositeWidget();
- initializeWidgets();
- initializeLabelText();
- }
-
- private void initializeLabelText() {
- this.eTypeLabel.setText(Messages.Type);
- this.selectButton.setText(Messages.Select);
- }
-
- protected void initializeWidgets() {
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- this.eTypedTextField.setLayoutData(gd);
-
- this.selectButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(final SelectionEvent e) {
- SelectETypeComposite.this.handleBrowse();
- }
- });
- }
-
- /**
- * This method call the SelectETypeWizardImpl
- */
- protected void handleBrowse() {
- if (this.eTypeSelectionOption == null) {
- this.eTypeSelectionOption = SelectETypeComposite.ETypeSelectionOptions.ECLASSIFIER;
- }
- SelectETypeWizardImpl dialog = new SelectETypeWizardImpl(this.editingDomain, this.eTypeSelectionOption, this.canChangeEPackage, this.ePackage);
- if (dialog.open() != Window.CANCEL) {
- setEClass(dialog.getSelectedEType());
- eTypeSelected();
- }
- }
-
- protected void eTypeSelected() {
- // Meant to be implemented
- }
-
- public void setEClass(final EClassifier eClass) {
- this.selectedEType = eClass;
- if (eClass != null) {
- this.eTypedTextField.setText(eClass.getName());
- this.eTypedTextField.redraw();
- this.eTypedTextField.setFocus();
- }
- }
-
- public void canChangeEType(final boolean canChange) {
- // this.eTypedTextField.setEditable(true);
- // this.eTypedTextField.setEnabled(false);
- this.selectButton.setEnabled(canChange);
- }
-
- public EClassifier getEType() {
- return this.selectedEType;
- }
-
- protected void setQueryLabel(final Label queryLabel) {
- this.eTypeLabel = queryLabel;
- }
-
- protected void setBrowseButton(final Button browseButton) {
- this.selectButton = browseButton;
- }
-
- protected void setQueryNameTextField(final Text queryNameTextField) {
- this.eTypedTextField = queryNameTextField;
- }
-
- public void setETypeLabel(final Label eTypeLabel) {
- this.eTypeLabel = eTypeLabel;
- }
-
- public void setSelectButton(final Button selectButton) {
- this.selectButton = selectButton;
- }
-
- public void setETypedTextField(final Text eTypedTextField) {
- this.eTypedTextField = eTypedTextField;
- }
-
- public void setEditingDomain(final EditingDomain editingDomain2) {
- this.editingDomain = editingDomain2;
- }
-
- public void setEType(final EClass type) {
- this.selectedEType = type;
- if (this.eTypedTextField != null) {
- this.eTypedTextField.setText(this.selectedEType.getName());
- this.eTypedTextField.redraw();
- }
- }
-
-}
+/** + * 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 349546 - EMF Facet facetSet editor + * Gregoire Dupe (Mia-Software) - Bug 373248 - Clean PMD errors + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.jface.window.Window; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.SelectETypeWizardImpl; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +@SuppressWarnings("PMD.ConstructorCallsOverridableMethod") +// @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") Temporary: this class must be deeply refactored. +// TODO remove the @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") +// cf. bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=373248 +public class SelectETypeComposite extends Composite { + + private static final int NUMBER_COLUMN = 3; + + /** to be returned by the composite */ + private EClassifier selectedEType = null; + + private EditingDomain editingDomain; + + private Label eTypeLabel; + private Button selectButton; + private Text eTypedTextField; + + private ETypeSelectionOptions eTypeSelectionOption; + + private boolean canChangeEPackage = true; + + private final EPackage ePackage; + + public enum ETypeSelectionOptions { + ECLASSIFIER, EDATATYPE, ECLASS + } + + public SelectETypeComposite(final Composite parent, final int style, final ETypeSelectionOptions option, final boolean canChangeEPackage, + final EPackage ePackage) { + super(parent, style); + this.eTypeSelectionOption = option; + this.ePackage = ePackage; + this.canChangeEPackage = canChangeEPackage; + init(); + } + + protected void createCompositeWidget() { + this.eTypeLabel = new Label(this, SWT.NULL); + this.eTypedTextField = new Text(this, SWT.BORDER | SWT.SINGLE); + this.selectButton = new Button(this, SWT.PUSH); + } + + private void init() { + GridLayout gridLayout = new GridLayout(SelectETypeComposite.NUMBER_COLUMN, false); + setLayout(gridLayout); + createCompositeWidget(); + initializeWidgets(); + initializeLabelText(); + } + + private void initializeLabelText() { + this.eTypeLabel.setText(Messages.Type); + this.selectButton.setText(Messages.Select); + } + + protected void initializeWidgets() { + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + this.eTypedTextField.setLayoutData(gd); + + this.selectButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(final SelectionEvent e) { + SelectETypeComposite.this.handleBrowse(); + } + }); + } + + /** + * This method call the SelectETypeWizardImpl + */ + protected void handleBrowse() { + if (this.eTypeSelectionOption == null) { + this.eTypeSelectionOption = SelectETypeComposite.ETypeSelectionOptions.ECLASSIFIER; + } + SelectETypeWizardImpl dialog = new SelectETypeWizardImpl(this.editingDomain, this.eTypeSelectionOption, this.canChangeEPackage, this.ePackage); + if (dialog.open() != Window.CANCEL) { + setEClass(dialog.getSelectedEType()); + eTypeSelected(); + } + } + + protected void eTypeSelected() { + // Meant to be implemented + } + + public void setEClass(final EClassifier eClass) { + this.selectedEType = eClass; + if (eClass != null) { + this.eTypedTextField.setText(eClass.getName()); + this.eTypedTextField.redraw(); + this.eTypedTextField.setFocus(); + } + } + + public void canChangeEType(final boolean canChange) { + // this.eTypedTextField.setEditable(true); + // this.eTypedTextField.setEnabled(false); + this.selectButton.setEnabled(canChange); + } + + public EClassifier getEType() { + return this.selectedEType; + } + + protected void setQueryLabel(final Label queryLabel) { + this.eTypeLabel = queryLabel; + } + + protected void setBrowseButton(final Button browseButton) { + this.selectButton = browseButton; + } + + protected void setQueryNameTextField(final Text queryNameTextField) { + this.eTypedTextField = queryNameTextField; + } + + public void setETypeLabel(final Label eTypeLabel) { + this.eTypeLabel = eTypeLabel; + } + + public void setSelectButton(final Button selectButton) { + this.selectButton = selectButton; + } + + public void setETypedTextField(final Text eTypedTextField) { + this.eTypedTextField = eTypedTextField; + } + + public void setEditingDomain(final EditingDomain editingDomain2) { + this.editingDomain = editingDomain2; + } + + public void setEType(final EClass type) { + this.selectedEType = type; + if (this.eTypedTextField != null) { + this.eTypedTextField.setText(this.selectedEType.getName()); + this.eTypedTextField.redraw(); + } + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/composites/SelectQueryTypeComposite.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/composites/SelectQueryTypeComposite.java index 97e4a2cf612..1337f081796 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/composites/SelectQueryTypeComposite.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/composites/SelectQueryTypeComposite.java @@ -1,101 +1,101 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- * Gregoire Dupe (Mia-Software) - Bug 373248 - Clean PMD errors
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites;
-
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.query.QueryEvaluatorFactoryRegistry;
-import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryEvaluatorFactory;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-
-@SuppressWarnings("PMD.ConstructorCallsOverridableMethod")
-// @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") This class is
-// deprecated, we won't then spend to many time to conforms to PMD rules.
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public class SelectQueryTypeComposite extends Composite {
-
- private Combo queryTypeComboBox;
- private Label queryTypeLabel;
- private static final int NUMBER_COLUMN = 3;
-
- public SelectQueryTypeComposite(final Composite parent, final int style) {
- super(parent, style);
- init();
- }
-
- @Override
- public void setEnabled(final boolean visible) {
- this.queryTypeComboBox.setEnabled(visible);
- this.queryTypeLabel.setEnabled(visible);
- }
-
- private void init() {
- GridLayout gridLayout = new GridLayout(SelectQueryTypeComposite.NUMBER_COLUMN, false);
- setLayout(gridLayout);
- createCompositeWidget();
- initializeWidgets();
- }
-
- protected void createCompositeWidget() {
- this.queryTypeLabel = new Label(this, SWT.NONE);
- this.queryTypeComboBox = new Combo(this, SWT.DROP_DOWN | SWT.READ_ONLY);
- }
-
- private void initializeWidgets() {
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
-
- this.queryTypeLabel.setText(Messages.SelectQueryTypeWizardPage_Query_Type);
- this.queryTypeComboBox.setLayoutData(gd);
-
- for (IQueryEvaluatorFactory factory : QueryEvaluatorFactoryRegistry.INSTANCE.getInstalledQueryFactories()) {
- this.queryTypeComboBox.add(factory.getManagedQueryType().getName());
- }
- this.queryTypeComboBox.select(0);
- this.queryTypeComboBox.addSelectionListener(new SelectionListener() {
- public void widgetSelected(final SelectionEvent e) {
- queryTypeSelected();
- }
-
- public void widgetDefaultSelected(final SelectionEvent e) {
- // Nothing
- }
- });
- }
-
- protected void queryTypeSelected() {
- // Intended to be overridden
- }
-
- protected void setQueryTypeLabel(final Label queryTypeLabel) {
- this.queryTypeLabel = queryTypeLabel;
- }
-
- protected void setQueryTypeComboBox(final Combo queryTypeComboBox) {
- this.queryTypeComboBox = queryTypeComboBox;
- }
-
- public String getSelectedQueryType() {
- if (this.queryTypeComboBox.getSelectionIndex() != -1) {
- return this.queryTypeComboBox.getItem(this.queryTypeComboBox.getSelectionIndex());
- }
- return null;
- }
-
-}
+/** + * 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 349546 - EMF Facet facetSet editor + * Gregoire Dupe (Mia-Software) - Bug 373248 - Clean PMD errors + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites; + +import org.eclipse.papyrus.emf.facet.efacet.core.internal.query.QueryEvaluatorFactoryRegistry; +import org.eclipse.papyrus.emf.facet.efacet.core.query.IQueryEvaluatorFactory; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; + +@SuppressWarnings("PMD.ConstructorCallsOverridableMethod") +// @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") This class is +// deprecated, we won't then spend to many time to conforms to PMD rules. +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public class SelectQueryTypeComposite extends Composite { + + private Combo queryTypeComboBox; + private Label queryTypeLabel; + private static final int NUMBER_COLUMN = 3; + + public SelectQueryTypeComposite(final Composite parent, final int style) { + super(parent, style); + init(); + } + + @Override + public void setEnabled(final boolean visible) { + this.queryTypeComboBox.setEnabled(visible); + this.queryTypeLabel.setEnabled(visible); + } + + private void init() { + GridLayout gridLayout = new GridLayout(SelectQueryTypeComposite.NUMBER_COLUMN, false); + setLayout(gridLayout); + createCompositeWidget(); + initializeWidgets(); + } + + protected void createCompositeWidget() { + this.queryTypeLabel = new Label(this, SWT.NONE); + this.queryTypeComboBox = new Combo(this, SWT.DROP_DOWN | SWT.READ_ONLY); + } + + private void initializeWidgets() { + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + + this.queryTypeLabel.setText(Messages.SelectQueryTypeWizardPage_Query_Type); + this.queryTypeComboBox.setLayoutData(gd); + + for (IQueryEvaluatorFactory factory : QueryEvaluatorFactoryRegistry.INSTANCE.getInstalledQueryFactories()) { + this.queryTypeComboBox.add(factory.getManagedQueryType().getName()); + } + this.queryTypeComboBox.select(0); + this.queryTypeComboBox.addSelectionListener(new SelectionListener() { + public void widgetSelected(final SelectionEvent e) { + queryTypeSelected(); + } + + public void widgetDefaultSelected(final SelectionEvent e) { + // Nothing + } + }); + } + + protected void queryTypeSelected() { + // Intended to be overridden + } + + protected void setQueryTypeLabel(final Label queryTypeLabel) { + this.queryTypeLabel = queryTypeLabel; + } + + protected void setQueryTypeComboBox(final Combo queryTypeComboBox) { + this.queryTypeComboBox = queryTypeComboBox; + } + + public String getSelectedQueryType() { + if (this.queryTypeComboBox.getSelectionIndex() != -1) { + return this.queryTypeComboBox.getItem(this.queryTypeComboBox.getSelectionIndex()); + } + return null; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/DefaultFacetLabelProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/DefaultFacetLabelProvider.java index 28c21590c17..fe9d3521827 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/DefaultFacetLabelProvider.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/DefaultFacetLabelProvider.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:
- * Nicolas Bros (Mia-Software) - Bug 370442 - rewrite the Facet loading dialog for v0.2
- * Nicolas Bros(Mia-Software) - Bug 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs;
-
-import org.eclipse.emf.ecore.ENamedElement;
-import org.eclipse.jface.viewers.LabelProvider;
-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.FacetSet;
-import org.eclipse.papyrus.emf.facet.util.emf.ui.internal.utils.ImageUtils;
-import org.eclipse.swt.graphics.Image;
-
-public class DefaultFacetLabelProvider extends LabelProvider {
- @Override
- public String getText(final Object element) {
- String label;
- if (element instanceof FacetSet) {
- final FacetSet facetSet = (FacetSet) element;
- label = facetSet.getName();
- } else if (element instanceof Facet) {
- final Facet facet = (Facet) element;
- label = facet.getName();
- } else if (element instanceof ENamedElement) {
- final ENamedElement namedElement = (ENamedElement) element;
- label = namedElement.getName();
- } else if (element == null) {
- label = "null"; //$NON-NLS-1$
- } else {
- label = element.getClass().getName();
- }
- return label;
- }
-
- @Override
- public Image getImage(final Object element) {
- return ImageUtils.getImage(element);
- }
-}
+/******************************************************************************* + * 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 370442 - rewrite the Facet loading dialog for v0.2 + * Nicolas Bros(Mia-Software) - Bug 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2 + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs; + +import org.eclipse.emf.ecore.ENamedElement; +import org.eclipse.jface.viewers.LabelProvider; +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.FacetSet; +import org.eclipse.papyrus.emf.facet.util.emf.ui.internal.utils.ImageUtils; +import org.eclipse.swt.graphics.Image; + +public class DefaultFacetLabelProvider extends LabelProvider { + @Override + public String getText(final Object element) { + String label; + if (element instanceof FacetSet) { + final FacetSet facetSet = (FacetSet) element; + label = facetSet.getName(); + } else if (element instanceof Facet) { + final Facet facet = (Facet) element; + label = facet.getName(); + } else if (element instanceof ENamedElement) { + final ENamedElement namedElement = (ENamedElement) element; + label = namedElement.getName(); + } else if (element == null) { + label = "null"; //$NON-NLS-1$ + } else { + label = element.getClass().getName(); + } + return label; + } + + @Override + public Image getImage(final Object element) { + return ImageUtils.getImage(element); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/ETypedElementSelectionDialog.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/ETypedElementSelectionDialog.java index 54182e75acf..85a37eedce8 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/ETypedElementSelectionDialog.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/ETypedElementSelectionDialog.java @@ -1,243 +1,243 @@ -/*******************************************************************************
- * Copyright (c) 2009-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)
- * Nicolas Guyomar (Mia-Software) - Bug 339874 - Infra QuerySelectionDialog should have a "querySet" icon
- * Nicolas Bros (Mia-Software) - Bug 366367 - To be able to change the "CanBePresentedInTheTable" query
- * Nicolas Bros (Mia-Software) - Bug 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2
- * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- * Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets
- * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
- * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
- * Nicolas Bros (Mia-Software) - Bug 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog.IETypedElementSelectionDialogInternal;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget.ETypedElementSelectionControlManager;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget.IETypedElementSelectionControlManager;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallbackWithPreCommit;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.dialogs.SelectionStatusDialog;
-
-/**
- * A dialog to select an {@link ETypedElement} among a tree of {@link EObject}s that are children of a given set of root {@link EObject}s
- */
-public class ETypedElementSelectionDialog<T2, D> extends SelectionStatusDialog
- implements IETypedElementSelectionDialogInternal<D> { // NOPMD
-
- // note: the dialog should be large enough to see the validator message
- private static final int DEFAULT_WIDTH = 550;
- private static final int DEFAULT_HEIGHT = 550;
-
- private final boolean allowEmpty;
- private final IDialogCallbackWithPreCommit<List<ETypedElement>, T2, D> callback;
- private final Collection<? extends ETypedElement> availableElements;
- private final int selectionMaxSize;
- private final ICustomizationManager customManager;
- private IETypedElementSelectionControlManager manager;
- private final Collection<? extends EPackage> knownEPackage;
-
- /**
- * @param eTypedElements
- * the list of ETypedElements that can be selected
- * @param selectionMaxSize
- * the maximum number of typed elements that the user can select
- * @param allowEmpty
- * whether to allow the user to select no ETypedElement (i.e : select <code>null</code>)
- * @param callback
- * called when the dialog closes
- * @param parentShell
- * the parent shell
- * @param customManager
- * the customization manager used by the ICustomizableLabelProvider
- */
- public ETypedElementSelectionDialog(final Collection<? extends ETypedElement> eTypedElements,
- final int selectionMaxSize, final boolean allowEmpty,
- final IDialogCallbackWithPreCommit<List<ETypedElement>, T2, D> callback,
- final Shell parentShell, final ICustomizationManager customManager,
- final Collection<? extends EPackage> knownEPackage) {
- super(parentShell);
- this.availableElements = eTypedElements;
- this.selectionMaxSize = selectionMaxSize;
- this.allowEmpty = allowEmpty;
- this.callback = callback;
- this.customManager = customManager;
- this.knownEPackage = knownEPackage;
- setHelpAvailable(false);
-
- }
-
- @Override
- protected Control createDialogArea(final Composite parent) {
- final Composite composite = (Composite) super.createDialogArea(parent);
- this.manager = new ETypedElementSelectionControlManager(composite,
- this.selectionMaxSize, this.allowEmpty, this.customManager,
- this.knownEPackage);
- this.manager.createContents();
- this.manager.setAvailableETypedElements(this.availableElements);
-
- // double-click or enter to choose the selected typed element
- this.manager.addOpenListener(new IOpenListener() {
- public void open(final OpenEvent event) {
- ETypedElementSelectionDialog.this.okPressed();
- }
- });
-
- this.manager.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(final SelectionChangedEvent event) {
- updateValidationStatus();
- }
- });
- return composite;
- }
-
- protected void updateValidationStatus() {
- updateStatus(this.manager.getValidationStatus());
- }
-
- @Override
- protected void configureShell(final Shell shell) {
- super.configureShell(shell);
- if (this.selectionMaxSize > 1) {
- shell.setText(Messages.ETypedElementSelectionDialog_dialogTitleMultiSelection);
- } else {
- shell.setText(Messages.ETypedElementSelectionDialog_dialogTitle);
- }
- // TODO: image for ETypedElement
- // shell.setImage(...);
- }
-
- @Override
- protected boolean isResizable() {
- return true;
- }
-
- @Override
- protected IDialogSettings getDialogBoundsSettings() {
- final String sectionName = this.getClass().getName() + ".settings"; //$NON-NLS-1$
- final IDialogSettings settings = Activator.getDefault().getDialogSettings();
- IDialogSettings section = settings.getSection(sectionName);
- if (section == null) {
- section = settings.addNewSection(sectionName);
- // cf Dialog#DIALOG_WIDTH
- section.put("DIALOG_WIDTH", ETypedElementSelectionDialog.DEFAULT_WIDTH); //$NON-NLS-1$
- section.put("DIALOG_HEIGHT", ETypedElementSelectionDialog.DEFAULT_HEIGHT); //$NON-NLS-1$
- }
- return section;
- }
-
- public boolean isErrorStatus() {
- final IStatus validationStatus = this.manager.getValidationStatus();
- return validationStatus == null || validationStatus.getSeverity() >= IStatus.ERROR;
- }
-
- @Override
- protected void okPressed() {
- if (isErrorStatus()) {
- throw new IllegalStateException("The current selection is not valid"); //$NON-NLS-1$
- }
- super.okPressed();
- }
-
- public D pressOk() {
- okPressed();
- return null;
- }
-
- public void pressCancel() {
- setReturnCode(Window.CANCEL);
- close();
- }
-
- @Override
- public boolean close() {
- final boolean result = super.close();
- invokeCallback();
- return result;
- }
-
- private void invokeCallback() {
- if (this.callback == null) {
- return;
- }
- if (getReturnCode() == Window.OK) {
- this.callback.committed(getSelectedETypedElements(), null);
- }
- }
-
- public List<ETypedElement> getSelectedETypedElements() {
- List<ETypedElement> currentlySelected = new ArrayList<ETypedElement>();
- if (this.manager.isDisposed()) {
- final Object[] result = getResult();
- if (result == null) {
- throw new UnsupportedOperationException("No selection available because the dialog was canceled"); //$NON-NLS-1$
- }
- for (Object current : result) {
- currentlySelected.add((ETypedElement) current);
- }
- } else {
- currentlySelected = this.manager.computeResult();
- }
- return Collections.unmodifiableList(currentlySelected);
- }
-
- public ETypedElement getFirstSelectedETypedElement() {
- ETypedElement result = null;
- final List<ETypedElement> typedElements = getSelectedETypedElements();
- if (typedElements != null && !typedElements.isEmpty()) {
- result = typedElements.get(0);
- }
- return result;
- }
-
- public void setSelectedETypedElements(final List<? extends ETypedElement> newSelection) {
- if (newSelection == null) {
- throw new IllegalArgumentException();
- }
- this.manager.setSelectedETypedElements(newSelection);
- updateValidationStatus();
- }
-
- public void setSelection(final IStructuredSelection selection) {
- this.manager.setSelection(selection);
- updateValidationStatus();
- }
-
- @Override
- protected void computeResult() {
- // we build the result
- final List<ETypedElement> currentSelection = this.manager.computeResult();
- setResult(currentSelection);
- }
-
- public boolean isOkButtonEnabled() {
- return getOkButton().isEnabled();
- }
-}
+/******************************************************************************* + * Copyright (c) 2009-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) + * Nicolas Guyomar (Mia-Software) - Bug 339874 - Infra QuerySelectionDialog should have a "querySet" icon + * Nicolas Bros (Mia-Software) - Bug 366367 - To be able to change the "CanBePresentedInTheTable" query + * Nicolas Bros (Mia-Software) - Bug 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2 + * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + * Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets + * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>) + * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates + * Nicolas Bros (Mia-Software) - Bug 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2 + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.viewers.IOpenListener; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.OpenEvent; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.window.Window; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog.IETypedElementSelectionDialogInternal; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget.ETypedElementSelectionControlManager; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget.IETypedElementSelectionControlManager; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallbackWithPreCommit; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.dialogs.SelectionStatusDialog; + +/** + * A dialog to select an {@link ETypedElement} among a tree of {@link EObject}s that are children of a given set of root {@link EObject}s + */ +public class ETypedElementSelectionDialog<T2, D> extends SelectionStatusDialog + implements IETypedElementSelectionDialogInternal<D> { // NOPMD + + // note: the dialog should be large enough to see the validator message + private static final int DEFAULT_WIDTH = 550; + private static final int DEFAULT_HEIGHT = 550; + + private final boolean allowEmpty; + private final IDialogCallbackWithPreCommit<List<ETypedElement>, T2, D> callback; + private final Collection<? extends ETypedElement> availableElements; + private final int selectionMaxSize; + private final ICustomizationManager customManager; + private IETypedElementSelectionControlManager manager; + private final Collection<? extends EPackage> knownEPackage; + + /** + * @param eTypedElements + * the list of ETypedElements that can be selected + * @param selectionMaxSize + * the maximum number of typed elements that the user can select + * @param allowEmpty + * whether to allow the user to select no ETypedElement (i.e : select <code>null</code>) + * @param callback + * called when the dialog closes + * @param parentShell + * the parent shell + * @param customManager + * the customization manager used by the ICustomizableLabelProvider + */ + public ETypedElementSelectionDialog(final Collection<? extends ETypedElement> eTypedElements, + final int selectionMaxSize, final boolean allowEmpty, + final IDialogCallbackWithPreCommit<List<ETypedElement>, T2, D> callback, + final Shell parentShell, final ICustomizationManager customManager, + final Collection<? extends EPackage> knownEPackage) { + super(parentShell); + this.availableElements = eTypedElements; + this.selectionMaxSize = selectionMaxSize; + this.allowEmpty = allowEmpty; + this.callback = callback; + this.customManager = customManager; + this.knownEPackage = knownEPackage; + setHelpAvailable(false); + + } + + @Override + protected Control createDialogArea(final Composite parent) { + final Composite composite = (Composite) super.createDialogArea(parent); + this.manager = new ETypedElementSelectionControlManager(composite, + this.selectionMaxSize, this.allowEmpty, this.customManager, + this.knownEPackage); + this.manager.createContents(); + this.manager.setAvailableETypedElements(this.availableElements); + + // double-click or enter to choose the selected typed element + this.manager.addOpenListener(new IOpenListener() { + public void open(final OpenEvent event) { + ETypedElementSelectionDialog.this.okPressed(); + } + }); + + this.manager.addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(final SelectionChangedEvent event) { + updateValidationStatus(); + } + }); + return composite; + } + + protected void updateValidationStatus() { + updateStatus(this.manager.getValidationStatus()); + } + + @Override + protected void configureShell(final Shell shell) { + super.configureShell(shell); + if (this.selectionMaxSize > 1) { + shell.setText(Messages.ETypedElementSelectionDialog_dialogTitleMultiSelection); + } else { + shell.setText(Messages.ETypedElementSelectionDialog_dialogTitle); + } + // TODO: image for ETypedElement + // shell.setImage(...); + } + + @Override + protected boolean isResizable() { + return true; + } + + @Override + protected IDialogSettings getDialogBoundsSettings() { + final String sectionName = this.getClass().getName() + ".settings"; //$NON-NLS-1$ + final IDialogSettings settings = Activator.getDefault().getDialogSettings(); + IDialogSettings section = settings.getSection(sectionName); + if (section == null) { + section = settings.addNewSection(sectionName); + // cf Dialog#DIALOG_WIDTH + section.put("DIALOG_WIDTH", ETypedElementSelectionDialog.DEFAULT_WIDTH); //$NON-NLS-1$ + section.put("DIALOG_HEIGHT", ETypedElementSelectionDialog.DEFAULT_HEIGHT); //$NON-NLS-1$ + } + return section; + } + + public boolean isErrorStatus() { + final IStatus validationStatus = this.manager.getValidationStatus(); + return validationStatus == null || validationStatus.getSeverity() >= IStatus.ERROR; + } + + @Override + protected void okPressed() { + if (isErrorStatus()) { + throw new IllegalStateException("The current selection is not valid"); //$NON-NLS-1$ + } + super.okPressed(); + } + + public D pressOk() { + okPressed(); + return null; + } + + public void pressCancel() { + setReturnCode(Window.CANCEL); + close(); + } + + @Override + public boolean close() { + final boolean result = super.close(); + invokeCallback(); + return result; + } + + private void invokeCallback() { + if (this.callback == null) { + return; + } + if (getReturnCode() == Window.OK) { + this.callback.committed(getSelectedETypedElements(), null); + } + } + + public List<ETypedElement> getSelectedETypedElements() { + List<ETypedElement> currentlySelected = new ArrayList<ETypedElement>(); + if (this.manager.isDisposed()) { + final Object[] result = getResult(); + if (result == null) { + throw new UnsupportedOperationException("No selection available because the dialog was canceled"); //$NON-NLS-1$ + } + for (Object current : result) { + currentlySelected.add((ETypedElement) current); + } + } else { + currentlySelected = this.manager.computeResult(); + } + return Collections.unmodifiableList(currentlySelected); + } + + public ETypedElement getFirstSelectedETypedElement() { + ETypedElement result = null; + final List<ETypedElement> typedElements = getSelectedETypedElements(); + if (typedElements != null && !typedElements.isEmpty()) { + result = typedElements.get(0); + } + return result; + } + + public void setSelectedETypedElements(final List<? extends ETypedElement> newSelection) { + if (newSelection == null) { + throw new IllegalArgumentException(); + } + this.manager.setSelectedETypedElements(newSelection); + updateValidationStatus(); + } + + public void setSelection(final IStructuredSelection selection) { + this.manager.setSelection(selection); + updateValidationStatus(); + } + + @Override + protected void computeResult() { + // we build the result + final List<ETypedElement> currentSelection = this.manager.computeResult(); + setResult(currentSelection); + } + + public boolean isOkButtonEnabled() { + return getOkButton().isEnabled(); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/ETypedElementSelectionDialogFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/ETypedElementSelectionDialogFactory.java index b7709ad5158..5291cf9c6be 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/ETypedElementSelectionDialogFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/ETypedElementSelectionDialogFactory.java @@ -1,50 +1,50 @@ -/*******************************************************************************
- * 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 370442 - rewrite the Facet loading dialog for v0.2
- * Nicolas Bros (Mia-Software) - Bug 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2
- * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- * 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.ui.internal.dialogs;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog.IETypedElementSelectionDialog;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog.IETypedElementSelectionDialogFactory;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallbackWithPreCommit;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-public class ETypedElementSelectionDialogFactory implements IETypedElementSelectionDialogFactory {
-
- public <T2, D> IETypedElementSelectionDialog<D> openETypedElementSelectionDialog(
- final Collection<? extends ETypedElement> eTypedElements,
- final int selectionMaxSize,
- final boolean allowEmpty,
- final IDialogCallbackWithPreCommit<List<ETypedElement>, T2, D> callback,
- final Shell parentShell, final ICustomizationManager customManager,
- final Collection<? extends EPackage> knownFacetSets) {
- final ETypedElementSelectionDialog<T2, D> dialog = new ETypedElementSelectionDialog<T2, D>(
- eTypedElements, selectionMaxSize, allowEmpty, callback,
- parentShell, customManager, knownFacetSets);
- // must be synchronous, otherwise the shell is not created before SynchronizedETypedElementSelectionDialog, and SynchronizedComposite throws a NPE
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- dialog.setBlockOnOpen(false);
- dialog.open();
- }
- });
- return new SynchronizedETypedElementSelectionDialog<T2, D>(dialog);
- }
-}
+/******************************************************************************* + * 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 370442 - rewrite the Facet loading dialog for v0.2 + * Nicolas Bros (Mia-Software) - Bug 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2 + * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + * 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.ui.internal.dialogs; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog.IETypedElementSelectionDialog; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog.IETypedElementSelectionDialogFactory; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallbackWithPreCommit; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +public class ETypedElementSelectionDialogFactory implements IETypedElementSelectionDialogFactory { + + public <T2, D> IETypedElementSelectionDialog<D> openETypedElementSelectionDialog( + final Collection<? extends ETypedElement> eTypedElements, + final int selectionMaxSize, + final boolean allowEmpty, + final IDialogCallbackWithPreCommit<List<ETypedElement>, T2, D> callback, + final Shell parentShell, final ICustomizationManager customManager, + final Collection<? extends EPackage> knownFacetSets) { + final ETypedElementSelectionDialog<T2, D> dialog = new ETypedElementSelectionDialog<T2, D>( + eTypedElements, selectionMaxSize, allowEmpty, callback, + parentShell, customManager, knownFacetSets); + // must be synchronous, otherwise the shell is not created before SynchronizedETypedElementSelectionDialog, and SynchronizedComposite throws a NPE + Display.getDefault().syncExec(new Runnable() { + public void run() { + dialog.setBlockOnOpen(false); + dialog.open(); + } + }); + return new SynchronizedETypedElementSelectionDialog<T2, D>(dialog); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/FacetSetSelectionDialog.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/FacetSetSelectionDialog.java index 4e88deffeda..ec1985fdf30 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/FacetSetSelectionDialog.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/FacetSetSelectionDialog.java @@ -1,229 +1,229 @@ -/*******************************************************************************
- * 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 372865 - FacetSet selection dialog
- * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog.IFacetSetSelectionDialogInternal;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget.FacetSetSelectionControl;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallback;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallbackWithPreCommit;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.dialogs.SelectionStatusDialog;
-
-/**
- * A dialog to select {@link FacetSet}s
- *
- * @param <T>
- * the type of a pre-commit dialog
- */
-public class FacetSetSelectionDialog<T> extends SelectionStatusDialog implements IFacetSetSelectionDialogInternal<T> {
-
- // note: the dialog should be large enough to see the validator message
- private static final int DEFAULT_WIDTH = 800;
- private static final int DEFAULT_HEIGHT = 600;
-
- private final Collection<FacetSet> available;
- private final int selectionMaxSize;
- private final boolean allowEmpty;
- private final IDialogCallbackWithPreCommit<List<FacetSet>, Boolean, T> callback;
- private FacetSetSelectionControl selectionControl;
-
- public FacetSetSelectionDialog(final Collection<FacetSet> available,
- final int selectionMaxSize, final boolean allowEmpty,
- final IDialogCallbackWithPreCommit<List<FacetSet>, Boolean, T> callback, final Shell parentShell) {
- super(parentShell);
- Assert.isLegal(callback != null, "available cannot be null"); //$NON-NLS-1$
- Assert.isLegal(callback != null, "callback cannot be null"); //$NON-NLS-1$
- Assert.isLegal(selectionMaxSize > 0, "selectionMaxSize must be > 0"); //$NON-NLS-1$
- this.available = available;
- this.selectionMaxSize = selectionMaxSize;
- this.allowEmpty = allowEmpty;
- this.callback = callback;
- setHelpAvailable(false);
- }
-
- @Override
- protected Control createDialogArea(final Composite parent) {
- final Composite composite = (Composite) super.createDialogArea(parent);
- final Runnable onChange = new Runnable() {
- public void run() {
- updateValidationStatus();
- }
- };
- this.selectionControl = createFacetSetSelectionControl(composite, onChange);
- this.selectionControl.createContents();
- this.selectionControl.setAvailableFacetSets(this.available);
- updateValidationStatus();
- return composite;
- }
-
- protected FacetSetSelectionControl createFacetSetSelectionControl(final Composite parentComposite, final Runnable onChange) {
- return new FacetSetSelectionControl(parentComposite, this.selectionMaxSize, this.allowEmpty, onChange);
- }
-
- @Override
- protected void createButtonsForButtonBar(final Composite parent) {
- createButton(parent, IDialogConstants.SELECT_ALL_ID, Messages.FacetSetSelectionDialog_selectAll, false);
- createButton(parent, IDialogConstants.DESELECT_ALL_ID, Messages.FacetSetSelectionDialog_deselectAll, false);
- super.createButtonsForButtonBar(parent);
- }
-
- @Override
- protected void buttonPressed(final int buttonId) {
- super.buttonPressed(buttonId);
- if (IDialogConstants.SELECT_ALL_ID == buttonId) {
- selectAll();
- } else if (IDialogConstants.DESELECT_ALL_ID == buttonId) {
- deselectAll();
- }
- }
-
- protected void updateValidationStatus() {
- updateStatus(this.selectionControl.getValidationStatus());
- }
-
- @Override
- protected void configureShell(final Shell shell) {
- super.configureShell(shell);
- if (this.selectionMaxSize > 1) {
- shell.setText(Messages.FacetSetSelectionDialog_titleSelectFacetSets);
- } else {
- shell.setText(Messages.FacetSetSelectionDialog_titleSelectFacetSet);
- }
- }
-
- @Override
- protected boolean isResizable() {
- return true;
- }
-
- @Override
- protected IDialogSettings getDialogBoundsSettings() {
- final String sectionName = this.getClass().getName() + ".settings"; //$NON-NLS-1$
- final IDialogSettings settings = Activator.getDefault().getDialogSettings();
- IDialogSettings section = settings.getSection(sectionName);
- if (section == null) {
- section = settings.addNewSection(sectionName);
- // cf Dialog#DIALOG_WIDTH
- section.put("DIALOG_WIDTH", FacetSetSelectionDialog.DEFAULT_WIDTH); //$NON-NLS-1$
- section.put("DIALOG_HEIGHT", FacetSetSelectionDialog.DEFAULT_HEIGHT); //$NON-NLS-1$
- }
- return section;
- }
-
- public boolean isErrorStatus() {
- final IStatus validationStatus = this.selectionControl.getValidationStatus();
- return validationStatus == null || validationStatus.getSeverity() >= IStatus.ERROR;
- }
-
- public T pressOk() {
- final IDialogCallback<Boolean> precommitCallBack = new IDialogCallback<Boolean>() {
- public void committed(final Boolean precommitResult) {
- commit(precommitResult);
- }
- };
- final T dialog = this.callback.openPrecommitDialog(
- getSelectedFacetSets(),
- precommitCallBack);
- if (dialog == null) {
- commit(Boolean.TRUE);
- }
- return dialog;
- }
-
- public void pressCancel() {
- setReturnCode(Window.CANCEL);
- close();
- }
-
- @Override
- protected void okPressed() {
- pressOk();
- }
-
- @Override
- protected void cancelPressed() {
- pressCancel();
- }
-
- protected void commit(final Boolean precommitResult) {
- // since the callback is called from client code, we need to ensure we are running on the UI thread
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- commitOnUIThread(precommitResult);
- }
- });
- }
-
- protected void commitOnUIThread(final Boolean precommitResult) {
- final List<FacetSet> selectedFacetSets = getSelectedFacetSets();
- setReturnCode(Window.OK);
- close();
- this.callback.committed(selectedFacetSets, precommitResult);
- }
-
- @Override
- public int open() {
- // so that this dialog can be manipulated programmatically
- setBlockOnOpen(false);
- return super.open();
- }
-
- public List<FacetSet> getSelectedFacetSets() {
- if (this.selectionControl.isDisposed()) {
- throw new UnsupportedOperationException("No selection available because the dialog is closed"); //$NON-NLS-1$
- }
- return this.selectionControl.getSelectedFacetSets();
- }
-
- public void setSelectedFacetSets(final List<? extends FacetSet> newSelection) {
- this.selectionControl.setSelectedFacetSets(newSelection);
- updateValidationStatus();
- }
-
- public void selectAll() {
- this.selectionControl.selectAll();
- updateValidationStatus();
- }
-
- public void deselectAll() {
- this.selectionControl.deselectAll();
- updateValidationStatus();
- }
-
- public boolean isOkButtonEnabled() {
- return getOkButton().isEnabled();
- }
-
- @Override
- protected void computeResult() {
- // nothing : the dialog is not used in a standard way : use the callback
- }
-
- public TreeViewer getTreeViewer() {
- return this.selectionControl.getTreeViewer();
- }
+/******************************************************************************* + * 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 372865 - FacetSet selection dialog + * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.window.Window; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog.IFacetSetSelectionDialogInternal; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget.FacetSetSelectionControl; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallback; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallbackWithPreCommit; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.dialogs.SelectionStatusDialog; + +/** + * A dialog to select {@link FacetSet}s + * + * @param <T> + * the type of a pre-commit dialog + */ +public class FacetSetSelectionDialog<T> extends SelectionStatusDialog implements IFacetSetSelectionDialogInternal<T> { + + // note: the dialog should be large enough to see the validator message + private static final int DEFAULT_WIDTH = 800; + private static final int DEFAULT_HEIGHT = 600; + + private final Collection<FacetSet> available; + private final int selectionMaxSize; + private final boolean allowEmpty; + private final IDialogCallbackWithPreCommit<List<FacetSet>, Boolean, T> callback; + private FacetSetSelectionControl selectionControl; + + public FacetSetSelectionDialog(final Collection<FacetSet> available, + final int selectionMaxSize, final boolean allowEmpty, + final IDialogCallbackWithPreCommit<List<FacetSet>, Boolean, T> callback, final Shell parentShell) { + super(parentShell); + Assert.isLegal(callback != null, "available cannot be null"); //$NON-NLS-1$ + Assert.isLegal(callback != null, "callback cannot be null"); //$NON-NLS-1$ + Assert.isLegal(selectionMaxSize > 0, "selectionMaxSize must be > 0"); //$NON-NLS-1$ + this.available = available; + this.selectionMaxSize = selectionMaxSize; + this.allowEmpty = allowEmpty; + this.callback = callback; + setHelpAvailable(false); + } + + @Override + protected Control createDialogArea(final Composite parent) { + final Composite composite = (Composite) super.createDialogArea(parent); + final Runnable onChange = new Runnable() { + public void run() { + updateValidationStatus(); + } + }; + this.selectionControl = createFacetSetSelectionControl(composite, onChange); + this.selectionControl.createContents(); + this.selectionControl.setAvailableFacetSets(this.available); + updateValidationStatus(); + return composite; + } + + protected FacetSetSelectionControl createFacetSetSelectionControl(final Composite parentComposite, final Runnable onChange) { + return new FacetSetSelectionControl(parentComposite, this.selectionMaxSize, this.allowEmpty, onChange); + } + + @Override + protected void createButtonsForButtonBar(final Composite parent) { + createButton(parent, IDialogConstants.SELECT_ALL_ID, Messages.FacetSetSelectionDialog_selectAll, false); + createButton(parent, IDialogConstants.DESELECT_ALL_ID, Messages.FacetSetSelectionDialog_deselectAll, false); + super.createButtonsForButtonBar(parent); + } + + @Override + protected void buttonPressed(final int buttonId) { + super.buttonPressed(buttonId); + if (IDialogConstants.SELECT_ALL_ID == buttonId) { + selectAll(); + } else if (IDialogConstants.DESELECT_ALL_ID == buttonId) { + deselectAll(); + } + } + + protected void updateValidationStatus() { + updateStatus(this.selectionControl.getValidationStatus()); + } + + @Override + protected void configureShell(final Shell shell) { + super.configureShell(shell); + if (this.selectionMaxSize > 1) { + shell.setText(Messages.FacetSetSelectionDialog_titleSelectFacetSets); + } else { + shell.setText(Messages.FacetSetSelectionDialog_titleSelectFacetSet); + } + } + + @Override + protected boolean isResizable() { + return true; + } + + @Override + protected IDialogSettings getDialogBoundsSettings() { + final String sectionName = this.getClass().getName() + ".settings"; //$NON-NLS-1$ + final IDialogSettings settings = Activator.getDefault().getDialogSettings(); + IDialogSettings section = settings.getSection(sectionName); + if (section == null) { + section = settings.addNewSection(sectionName); + // cf Dialog#DIALOG_WIDTH + section.put("DIALOG_WIDTH", FacetSetSelectionDialog.DEFAULT_WIDTH); //$NON-NLS-1$ + section.put("DIALOG_HEIGHT", FacetSetSelectionDialog.DEFAULT_HEIGHT); //$NON-NLS-1$ + } + return section; + } + + public boolean isErrorStatus() { + final IStatus validationStatus = this.selectionControl.getValidationStatus(); + return validationStatus == null || validationStatus.getSeverity() >= IStatus.ERROR; + } + + public T pressOk() { + final IDialogCallback<Boolean> precommitCallBack = new IDialogCallback<Boolean>() { + public void committed(final Boolean precommitResult) { + commit(precommitResult); + } + }; + final T dialog = this.callback.openPrecommitDialog( + getSelectedFacetSets(), + precommitCallBack); + if (dialog == null) { + commit(Boolean.TRUE); + } + return dialog; + } + + public void pressCancel() { + setReturnCode(Window.CANCEL); + close(); + } + + @Override + protected void okPressed() { + pressOk(); + } + + @Override + protected void cancelPressed() { + pressCancel(); + } + + protected void commit(final Boolean precommitResult) { + // since the callback is called from client code, we need to ensure we are running on the UI thread + Display.getDefault().syncExec(new Runnable() { + public void run() { + commitOnUIThread(precommitResult); + } + }); + } + + protected void commitOnUIThread(final Boolean precommitResult) { + final List<FacetSet> selectedFacetSets = getSelectedFacetSets(); + setReturnCode(Window.OK); + close(); + this.callback.committed(selectedFacetSets, precommitResult); + } + + @Override + public int open() { + // so that this dialog can be manipulated programmatically + setBlockOnOpen(false); + return super.open(); + } + + public List<FacetSet> getSelectedFacetSets() { + if (this.selectionControl.isDisposed()) { + throw new UnsupportedOperationException("No selection available because the dialog is closed"); //$NON-NLS-1$ + } + return this.selectionControl.getSelectedFacetSets(); + } + + public void setSelectedFacetSets(final List<? extends FacetSet> newSelection) { + this.selectionControl.setSelectedFacetSets(newSelection); + updateValidationStatus(); + } + + public void selectAll() { + this.selectionControl.selectAll(); + updateValidationStatus(); + } + + public void deselectAll() { + this.selectionControl.deselectAll(); + updateValidationStatus(); + } + + public boolean isOkButtonEnabled() { + return getOkButton().isEnabled(); + } + + @Override + protected void computeResult() { + // nothing : the dialog is not used in a standard way : use the callback + } + + public TreeViewer getTreeViewer() { + return this.selectionControl.getTreeViewer(); + } }
\ No newline at end of file diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/FacetSetSelectionDialogFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/FacetSetSelectionDialogFactory.java index 3a8a262f335..b2335e9a5ed 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/FacetSetSelectionDialogFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/FacetSetSelectionDialogFactory.java @@ -1,72 +1,72 @@ -/*******************************************************************************
- * 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 372865 - FacetSet selection dialog
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog.IFacetSetSelectionDialog;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog.IFacetSetSelectionDialogFactory;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallback;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallbackWithPreCommit;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-public class FacetSetSelectionDialogFactory implements IFacetSetSelectionDialogFactory {
-
- private class DummyPrecommitDialog { // NOPMD
- // placeholder type
- }
-
- public IFacetSetSelectionDialog<?> openFacetSetSelectionDialog(
- final Collection<FacetSet> available, final int selectionMaxSize, final boolean allowEmpty,
- final IDialogCallback<List<FacetSet>> callback, final Shell parentShell) {
-
- final IDialogCallbackWithPreCommit<List<FacetSet>, Boolean, FacetSetSelectionDialogFactory.DummyPrecommitDialog> wrappedCallback =
- new IDialogCallbackWithPreCommit<List<FacetSet>, Boolean, FacetSetSelectionDialogFactory.DummyPrecommitDialog>() {
- public void committed(final List<FacetSet> result, final Boolean precommitResult) {
- callback.committed(result);
- }
-
- public DummyPrecommitDialog openPrecommitDialog(final List<FacetSet> result, final IDialogCallback<Boolean> precommitCallback) {
- return null;
- }
- };
-
- final FacetSetSelectionDialog<FacetSetSelectionDialogFactory.DummyPrecommitDialog> dialog =
- new FacetSetSelectionDialog<FacetSetSelectionDialogFactory.DummyPrecommitDialog>(
- available, selectionMaxSize, allowEmpty, wrappedCallback, parentShell);
- // must be synchronous, otherwise the shell is not created before SynchronizedFacetSetsSelectionDialog, and
- // SynchronizedComposite throws a NPE
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- dialog.open();
- }
- });
- return new SynchronizedFacetSetSelectionDialog<FacetSetSelectionDialogFactory.DummyPrecommitDialog>(dialog);
- }
-
- public <T> IFacetSetSelectionDialog<T> openFacetSetSelectionDialog(
- final Collection<FacetSet> available, final int selectionMaxSize, final boolean allowEmpty,
- final IDialogCallbackWithPreCommit<List<FacetSet>, Boolean, T> callback, final Shell parentShell) {
- final FacetSetSelectionDialog<T> dialog = new FacetSetSelectionDialog<T>(available,
- selectionMaxSize, allowEmpty, callback, parentShell);
- // must be synchronous, otherwise the shell is not created before SynchronizedFacetSetsSelectionDialog, and
- // SynchronizedComposite throws a NPE
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- dialog.open();
- }
- });
- return new SynchronizedFacetSetSelectionDialog<T>(dialog);
- }
-}
+/******************************************************************************* + * 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 372865 - FacetSet selection dialog + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog.IFacetSetSelectionDialog; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog.IFacetSetSelectionDialogFactory; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallback; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallbackWithPreCommit; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; + +public class FacetSetSelectionDialogFactory implements IFacetSetSelectionDialogFactory { + + private class DummyPrecommitDialog { // NOPMD + // placeholder type + } + + public IFacetSetSelectionDialog<?> openFacetSetSelectionDialog( + final Collection<FacetSet> available, final int selectionMaxSize, final boolean allowEmpty, + final IDialogCallback<List<FacetSet>> callback, final Shell parentShell) { + + final IDialogCallbackWithPreCommit<List<FacetSet>, Boolean, FacetSetSelectionDialogFactory.DummyPrecommitDialog> wrappedCallback = + new IDialogCallbackWithPreCommit<List<FacetSet>, Boolean, FacetSetSelectionDialogFactory.DummyPrecommitDialog>() { + public void committed(final List<FacetSet> result, final Boolean precommitResult) { + callback.committed(result); + } + + public DummyPrecommitDialog openPrecommitDialog(final List<FacetSet> result, final IDialogCallback<Boolean> precommitCallback) { + return null; + } + }; + + final FacetSetSelectionDialog<FacetSetSelectionDialogFactory.DummyPrecommitDialog> dialog = + new FacetSetSelectionDialog<FacetSetSelectionDialogFactory.DummyPrecommitDialog>( + available, selectionMaxSize, allowEmpty, wrappedCallback, parentShell); + // must be synchronous, otherwise the shell is not created before SynchronizedFacetSetsSelectionDialog, and + // SynchronizedComposite throws a NPE + Display.getDefault().syncExec(new Runnable() { + public void run() { + dialog.open(); + } + }); + return new SynchronizedFacetSetSelectionDialog<FacetSetSelectionDialogFactory.DummyPrecommitDialog>(dialog); + } + + public <T> IFacetSetSelectionDialog<T> openFacetSetSelectionDialog( + final Collection<FacetSet> available, final int selectionMaxSize, final boolean allowEmpty, + final IDialogCallbackWithPreCommit<List<FacetSet>, Boolean, T> callback, final Shell parentShell) { + final FacetSetSelectionDialog<T> dialog = new FacetSetSelectionDialog<T>(available, + selectionMaxSize, allowEmpty, callback, parentShell); + // must be synchronous, otherwise the shell is not created before SynchronizedFacetSetsSelectionDialog, and + // SynchronizedComposite throws a NPE + Display.getDefault().syncExec(new Runnable() { + public void run() { + dialog.open(); + } + }); + return new SynchronizedFacetSetSelectionDialog<T>(dialog); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/FacetSetTreeContentProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/FacetSetTreeContentProvider.java index 977292eb4d7..9cd0de8f596 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/FacetSetTreeContentProvider.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/FacetSetTreeContentProvider.java @@ -1,94 +1,94 @@ -/*******************************************************************************
- * 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 370442 - rewrite the Facet loading dialog for v0.2
- * Nicolas Bros (Mia-Software) - Bug 371367 - Hierarchical FacetSets
- * Nicolas Bros (Mia-Software) - Bug 372626 - Aggregates
- * Nicolas Bros (Mia-Software) - Bug 372865 - FacetSet selection dialog
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.papyrus.emf.facet.efacet.core.FacetUtils;
-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.FacetSet;
-
-public class FacetSetTreeContentProvider implements ITreeContentProvider {
-
- private final boolean bFacets;
- private final boolean bContainedFS;
- private final boolean bSubpackages;
-
- public FacetSetTreeContentProvider(final boolean facets, final boolean containedFSs, final boolean subpackages) {
- this.bFacets = facets;
- this.bContainedFS = containedFSs;
- this.bSubpackages = subpackages;
- }
-
- public FacetSetTreeContentProvider() {
- this(true, true, true);
- }
-
- public Object[] getElements(final Object inputElement) {
- if (inputElement == null) {
- throw new IllegalArgumentException("inputElement must not be null"); //$NON-NLS-1$
- }
- if (!(inputElement instanceof Object[])) {
- throw new IllegalArgumentException("inputElement must be an array"); //$NON-NLS-1$
- }
- return (Object[]) inputElement;
- }
-
- public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) {
- // Nothing to do
- }
-
- public Object[] getChildren(final Object parentElement) {
- final List<Object> children = new ArrayList<Object>();
- if (parentElement instanceof FacetSet) {
- final FacetSet facetSet = (FacetSet) parentElement;
- if (this.bContainedFS) {
- children.addAll(facetSet.getFacetSets());
- }
- if (this.bFacets) {
- children.addAll(FacetUtils.getFacets(facetSet));
- }
- if (this.bSubpackages) {
- children.addAll(facetSet.getESubpackages());
- }
- }
- return children.toArray();
- }
-
- public Object getParent(final Object element) {
- Object parent = null;
- if (element instanceof Facet) {
- final Facet facet = (Facet) element;
- parent = FacetUtils.getFacetSet(facet);
- } else if (element instanceof EPackage) {
- final EPackage ePackage = (EPackage) element;
- parent = ePackage.getESuperPackage();
- }
- return parent;
- }
-
- public boolean hasChildren(final Object element) {
- return getChildren(element).length > 0;
- }
-
- public void dispose() {
- // Nothing to do
- }
-
-}
+/******************************************************************************* + * 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 370442 - rewrite the Facet loading dialog for v0.2 + * Nicolas Bros (Mia-Software) - Bug 371367 - Hierarchical FacetSets + * Nicolas Bros (Mia-Software) - Bug 372626 - Aggregates + * Nicolas Bros (Mia-Software) - Bug 372865 - FacetSet selection dialog + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.papyrus.emf.facet.efacet.core.FacetUtils; +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.FacetSet; + +public class FacetSetTreeContentProvider implements ITreeContentProvider { + + private final boolean bFacets; + private final boolean bContainedFS; + private final boolean bSubpackages; + + public FacetSetTreeContentProvider(final boolean facets, final boolean containedFSs, final boolean subpackages) { + this.bFacets = facets; + this.bContainedFS = containedFSs; + this.bSubpackages = subpackages; + } + + public FacetSetTreeContentProvider() { + this(true, true, true); + } + + public Object[] getElements(final Object inputElement) { + if (inputElement == null) { + throw new IllegalArgumentException("inputElement must not be null"); //$NON-NLS-1$ + } + if (!(inputElement instanceof Object[])) { + throw new IllegalArgumentException("inputElement must be an array"); //$NON-NLS-1$ + } + return (Object[]) inputElement; + } + + public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) { + // Nothing to do + } + + public Object[] getChildren(final Object parentElement) { + final List<Object> children = new ArrayList<Object>(); + if (parentElement instanceof FacetSet) { + final FacetSet facetSet = (FacetSet) parentElement; + if (this.bContainedFS) { + children.addAll(facetSet.getFacetSets()); + } + if (this.bFacets) { + children.addAll(FacetUtils.getFacets(facetSet)); + } + if (this.bSubpackages) { + children.addAll(facetSet.getESubpackages()); + } + } + return children.toArray(); + } + + public Object getParent(final Object element) { + Object parent = null; + if (element instanceof Facet) { + final Facet facet = (Facet) element; + parent = FacetUtils.getFacetSet(facet); + } else if (element instanceof EPackage) { + final EPackage ePackage = (EPackage) element; + parent = ePackage.getESuperPackage(); + } + return parent; + } + + public boolean hasChildren(final Object element) { + return getChildren(element).length > 0; + } + + public void dispose() { + // Nothing to do + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/SelectQueryDialog.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/SelectQueryDialog.java index 5cc797e3604..e350ca3820a 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/SelectQueryDialog.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/SelectQueryDialog.java @@ -1,135 +1,135 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.jface.resource.ImageDescriptor;
-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.ui.internal.Activator;
-import org.eclipse.papyrus.emf.facet.util.emf.catalog.Catalog;
-import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.dialogs.SelectionDialog;
-
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public class SelectQueryDialog extends SelectionDialog {
-
- private static final int SHELL_SIZE = 300;
- private Tree tree = null;
- private Query selectedQuery = null;
-
- public SelectQueryDialog(final Shell parent) {
- super(parent);
- }
-
- @Override
- public Object[] getResult() {
- return new Object[] { this.selectedQuery };
- }
-
- @Override
- protected void configureShell(final Shell shell) {
- shell.setSize(SelectQueryDialog.SHELL_SIZE, SelectQueryDialog.SHELL_SIZE);
- super.configureShell(shell);
- }
-
- @Override
- protected Control createDialogArea(final Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- Font font = parent.getFont();
- composite.setFont(font);
- GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false);
- this.tree = new Tree(composite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- this.tree.setLayoutData(gd);
- EList<Catalog> catalogs = ICatalogSetManager.INSTANCE.getCatalogSet().getCatalogs();
-
- QuerySetCatalog querySetCatalog = null;
- for (Catalog catalog : catalogs) {
- if (catalog instanceof QuerySetCatalog) {
- querySetCatalog = (QuerySetCatalog) catalog;
- break;
- }
- }
- Image rootIcon = ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/querySet.gif")).createImage(); //$NON-NLS-1$
-
- if (querySetCatalog != null) {
-
- for (QuerySet querySet : querySetCatalog.getInstalledQuerySets()) {
- TreeItem root = new TreeItem(this.tree, 0);
- root.setText(querySet.getName());
- root.setData(querySet);
- root.setImage(rootIcon);
- // see
- // http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet8.java?view=co
- // for this dummyTreeItem, it will be populated later in the listener
- @SuppressWarnings("unused")
- TreeItem dummyTreeItem = new TreeItem(root, 0);
- }
- this.tree.addListener(SWT.Expand, new Listener() {
- public void handleEvent(final Event event) {
- final TreeItem root = (TreeItem) event.item;
- TreeItem[] items = root.getItems();
- for (TreeItem item : items) {
- if (item.getData() != null) {
- return;
- }
- item.dispose();
- }
- QuerySet querySet = (QuerySet) root.getData();
- EList<Query> queries = querySet.getQueries();
- if (queries == null) {
- return;
- }
-
- for (Query query : queries) {
- TreeItem item = new TreeItem(root, 0);
- item.setText(query.getName());
- item.setData(query);
- }
- }
- });
-
- this.tree.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(final SelectionEvent e) {
- if (e.item instanceof TreeItem) {
- TreeItem treeItem = (TreeItem) e.item;
- if (treeItem.getData() instanceof Query) {
- setSelectedQuery((Query) treeItem.getData());
- }
- }
- }
- });
- }
-
- return composite;
- }
-
- protected void setSelectedQuery(final Query selectedQuery) {
- this.selectedQuery = selectedQuery;
- }
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.jface.resource.ImageDescriptor; +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.ui.internal.Activator; +import org.eclipse.papyrus.emf.facet.util.emf.catalog.Catalog; +import org.eclipse.papyrus.emf.facet.util.emf.core.ICatalogSetManager; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.TreeItem; +import org.eclipse.ui.dialogs.SelectionDialog; + +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public class SelectQueryDialog extends SelectionDialog { + + private static final int SHELL_SIZE = 300; + private Tree tree = null; + private Query selectedQuery = null; + + public SelectQueryDialog(final Shell parent) { + super(parent); + } + + @Override + public Object[] getResult() { + return new Object[] { this.selectedQuery }; + } + + @Override + protected void configureShell(final Shell shell) { + shell.setSize(SelectQueryDialog.SHELL_SIZE, SelectQueryDialog.SHELL_SIZE); + super.configureShell(shell); + } + + @Override + protected Control createDialogArea(final Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + Font font = parent.getFont(); + composite.setFont(font); + GridData gd = new GridData(SWT.FILL, SWT.FILL, false, false); + this.tree = new Tree(composite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); + this.tree.setLayoutData(gd); + EList<Catalog> catalogs = ICatalogSetManager.INSTANCE.getCatalogSet().getCatalogs(); + + QuerySetCatalog querySetCatalog = null; + for (Catalog catalog : catalogs) { + if (catalog instanceof QuerySetCatalog) { + querySetCatalog = (QuerySetCatalog) catalog; + break; + } + } + Image rootIcon = ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/querySet.gif")).createImage(); //$NON-NLS-1$ + + if (querySetCatalog != null) { + + for (QuerySet querySet : querySetCatalog.getInstalledQuerySets()) { + TreeItem root = new TreeItem(this.tree, 0); + root.setText(querySet.getName()); + root.setData(querySet); + root.setImage(rootIcon); + // see + // http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet8.java?view=co + // for this dummyTreeItem, it will be populated later in the listener + @SuppressWarnings("unused") + TreeItem dummyTreeItem = new TreeItem(root, 0); + } + this.tree.addListener(SWT.Expand, new Listener() { + public void handleEvent(final Event event) { + final TreeItem root = (TreeItem) event.item; + TreeItem[] items = root.getItems(); + for (TreeItem item : items) { + if (item.getData() != null) { + return; + } + item.dispose(); + } + QuerySet querySet = (QuerySet) root.getData(); + EList<Query> queries = querySet.getQueries(); + if (queries == null) { + return; + } + + for (Query query : queries) { + TreeItem item = new TreeItem(root, 0); + item.setText(query.getName()); + item.setData(query); + } + } + }); + + this.tree.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(final SelectionEvent e) { + if (e.item instanceof TreeItem) { + TreeItem treeItem = (TreeItem) e.item; + if (treeItem.getData() instanceof Query) { + setSelectedQuery((Query) treeItem.getData()); + } + } + } + }); + } + + return composite; + } + + protected void setSelectedQuery(final Query selectedQuery) { + this.selectedQuery = selectedQuery; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/SynchronizedETypedElementSelectionDialog.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/SynchronizedETypedElementSelectionDialog.java index 87cd87a5bac..f081fbf0e93 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/SynchronizedETypedElementSelectionDialog.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/SynchronizedETypedElementSelectionDialog.java @@ -1,101 +1,101 @@ -/*******************************************************************************
- * 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 370442 - rewrite the Facet loading dialog for v0.2
- * Nicolas Bros (Mia-Software) - Bug 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2
- * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog.IETypedElementSelectionDialog;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog.IETypedElementSelectionDialogInternal;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.SynchronizedComposite;
-import org.eclipse.swt.widgets.Shell;
-
-/** A synchronization facade for {@link IETypedElementSelectionDialog}. */
-public class SynchronizedETypedElementSelectionDialog<T2, D> extends
- SynchronizedComposite<Shell> implements
- IETypedElementSelectionDialogInternal<D> {
-
- private final IETypedElementSelectionDialogInternal<D> dialog;
-
- public IETypedElementSelectionDialogInternal<D> getDialog() {
- return this.dialog;
- }
-
- public SynchronizedETypedElementSelectionDialog(
- final ETypedElementSelectionDialog<T2, D> delegate) {
- super(delegate.getShell());
- this.dialog = delegate;
- }
-
- public D pressOk() {
- return safeSyncExec(new AbstractExceptionFreeRunnable<D>() {
- @Override
- public D safeRun() {
- return getDialog().pressOk();
- }
- });
- }
-
- public void pressCancel() {
- voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
- @Override
- public void voidSafeRun() {
- getDialog().pressCancel();
- }
- });
-
- }
-
- public List<ETypedElement> getSelectedETypedElements() {
- return safeSyncExec(new AbstractExceptionFreeRunnable<List<ETypedElement>>() {
- @Override
- public List<ETypedElement> safeRun() {
- return getDialog().getSelectedETypedElements();
- }
- });
- }
-
- public ETypedElement getFirstSelectedETypedElement() {
- return safeSyncExec(new AbstractExceptionFreeRunnable<ETypedElement>() {
- @Override
- public ETypedElement safeRun() {
- return getDialog().getFirstSelectedETypedElement();
- }
- });
- }
-
- public void setSelectedETypedElements(final List<? extends ETypedElement> newSelection) {
- voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
- @Override
- public void voidSafeRun() {
- getDialog().setSelectedETypedElements(newSelection);
-
- }
- });
- }
-
- public int getReturnCode() {
- return getDialog().getReturnCode();
- }
-
- public boolean isOkButtonEnabled() {
- return safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() {
- @Override
- public Boolean safeRun() {
- return Boolean.valueOf(getDialog().isOkButtonEnabled());
- }
- }).booleanValue();
- }
-}
+/******************************************************************************* + * 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 370442 - rewrite the Facet loading dialog for v0.2 + * Nicolas Bros (Mia-Software) - Bug 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2 + * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>) + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs; + +import java.util.List; + +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog.IETypedElementSelectionDialog; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog.IETypedElementSelectionDialogInternal; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.SynchronizedComposite; +import org.eclipse.swt.widgets.Shell; + +/** A synchronization facade for {@link IETypedElementSelectionDialog}. */ +public class SynchronizedETypedElementSelectionDialog<T2, D> extends + SynchronizedComposite<Shell> implements + IETypedElementSelectionDialogInternal<D> { + + private final IETypedElementSelectionDialogInternal<D> dialog; + + public IETypedElementSelectionDialogInternal<D> getDialog() { + return this.dialog; + } + + public SynchronizedETypedElementSelectionDialog( + final ETypedElementSelectionDialog<T2, D> delegate) { + super(delegate.getShell()); + this.dialog = delegate; + } + + public D pressOk() { + return safeSyncExec(new AbstractExceptionFreeRunnable<D>() { + @Override + public D safeRun() { + return getDialog().pressOk(); + } + }); + } + + public void pressCancel() { + voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() { + @Override + public void voidSafeRun() { + getDialog().pressCancel(); + } + }); + + } + + public List<ETypedElement> getSelectedETypedElements() { + return safeSyncExec(new AbstractExceptionFreeRunnable<List<ETypedElement>>() { + @Override + public List<ETypedElement> safeRun() { + return getDialog().getSelectedETypedElements(); + } + }); + } + + public ETypedElement getFirstSelectedETypedElement() { + return safeSyncExec(new AbstractExceptionFreeRunnable<ETypedElement>() { + @Override + public ETypedElement safeRun() { + return getDialog().getFirstSelectedETypedElement(); + } + }); + } + + public void setSelectedETypedElements(final List<? extends ETypedElement> newSelection) { + voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() { + @Override + public void voidSafeRun() { + getDialog().setSelectedETypedElements(newSelection); + + } + }); + } + + public int getReturnCode() { + return getDialog().getReturnCode(); + } + + public boolean isOkButtonEnabled() { + return safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() { + @Override + public Boolean safeRun() { + return Boolean.valueOf(getDialog().isOkButtonEnabled()); + } + }).booleanValue(); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/SynchronizedFacetSetSelectionDialog.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/SynchronizedFacetSetSelectionDialog.java index 111f1448460..19b6892b9ea 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/SynchronizedFacetSetSelectionDialog.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/dialogs/SynchronizedFacetSetSelectionDialog.java @@ -1,102 +1,102 @@ -/*******************************************************************************
- * 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 372865 - FacetSet selection dialog
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs;
-
-import java.util.List;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog.IFacetSetSelectionDialog;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog.IFacetSetSelectionDialogInternal;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.SynchronizedComposite;
-import org.eclipse.swt.widgets.Shell;
-
-/** A synchronization facade for {@link IFacetSetSelectionDialog}. */
-public class SynchronizedFacetSetSelectionDialog<T> extends SynchronizedComposite<Shell> implements IFacetSetSelectionDialogInternal<T> {
-
- private final IFacetSetSelectionDialogInternal<T> dialog;
-
- public IFacetSetSelectionDialogInternal<T> getDialog() {
- return this.dialog;
- }
-
- public SynchronizedFacetSetSelectionDialog(final FacetSetSelectionDialog<T> delegate) {
- super(delegate.getShell());
- this.dialog = delegate;
- }
-
- public void setSelectedFacetSets(final List<? extends FacetSet> newSelection) {
- voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
- @Override
- public void voidSafeRun() {
- getDialog().setSelectedFacetSets(newSelection);
-
- }
- });
- }
-
- public T pressOk() {
- return safeSyncExec(new AbstractExceptionFreeRunnable<T>() {
- @Override
- public T safeRun() {
- return getDialog().pressOk();
- }
- });
- }
-
- public void pressCancel() {
- voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
- @Override
- public void voidSafeRun() {
- getDialog().pressCancel();
- }
- });
- }
-
- public void selectAll() {
- voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
- @Override
- public void voidSafeRun() {
- getDialog().selectAll();
- }
- });
- }
-
- public void deselectAll() {
- voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
- @Override
- public void voidSafeRun() {
- getDialog().deselectAll();
- }
- });
- }
-
- public boolean isOkButtonEnabled() {
- return safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() {
- @Override
- public Boolean safeRun() {
- return Boolean.valueOf(getDialog().isOkButtonEnabled());
- }
- }).booleanValue();
- }
-
- public TreeViewer getTreeViewer() {
- return safeSyncExec(new AbstractExceptionFreeRunnable<TreeViewer>() {
- @Override
- public TreeViewer safeRun() {
- return getDialog().getTreeViewer();
- }
- });
- }
-
-}
+/******************************************************************************* + * 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 372865 - FacetSet selection dialog + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs; + +import java.util.List; + +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog.IFacetSetSelectionDialog; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog.IFacetSetSelectionDialogInternal; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.SynchronizedComposite; +import org.eclipse.swt.widgets.Shell; + +/** A synchronization facade for {@link IFacetSetSelectionDialog}. */ +public class SynchronizedFacetSetSelectionDialog<T> extends SynchronizedComposite<Shell> implements IFacetSetSelectionDialogInternal<T> { + + private final IFacetSetSelectionDialogInternal<T> dialog; + + public IFacetSetSelectionDialogInternal<T> getDialog() { + return this.dialog; + } + + public SynchronizedFacetSetSelectionDialog(final FacetSetSelectionDialog<T> delegate) { + super(delegate.getShell()); + this.dialog = delegate; + } + + public void setSelectedFacetSets(final List<? extends FacetSet> newSelection) { + voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() { + @Override + public void voidSafeRun() { + getDialog().setSelectedFacetSets(newSelection); + + } + }); + } + + public T pressOk() { + return safeSyncExec(new AbstractExceptionFreeRunnable<T>() { + @Override + public T safeRun() { + return getDialog().pressOk(); + } + }); + } + + public void pressCancel() { + voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() { + @Override + public void voidSafeRun() { + getDialog().pressCancel(); + } + }); + } + + public void selectAll() { + voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() { + @Override + public void voidSafeRun() { + getDialog().selectAll(); + } + }); + } + + public void deselectAll() { + voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() { + @Override + public void voidSafeRun() { + getDialog().deselectAll(); + } + }); + } + + public boolean isOkButtonEnabled() { + return safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() { + @Override + public Boolean safeRun() { + return Boolean.valueOf(getDialog().isOkButtonEnabled()); + } + }).booleanValue(); + } + + public TreeViewer getTreeViewer() { + return safeSyncExec(new AbstractExceptionFreeRunnable<TreeViewer>() { + @Override + public TreeViewer safeRun() { + return getDialog().getTreeViewer(); + } + }); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/EFacetUIConstants.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/EFacetUIConstants.java index 8e244938e8f..3a3728117f3 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/EFacetUIConstants.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/EFacetUIConstants.java @@ -1,24 +1,24 @@ -/*******************************************************************************
- * 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 372626 - Aggregates
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported;
-
-public final class EFacetUIConstants {
-
- private static final String CATALOG_VIEW_ID = "org.eclipse.papyrus.emf.facet.efacet.ui.view.catalog"; //$NON-NLS-1$
-
- private EFacetUIConstants() {
- // utility class
- }
-
- public static String getFacetSetsCatalogViewId() {
- return EFacetUIConstants.CATALOG_VIEW_ID;
- }
-}
+/******************************************************************************* + * 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 372626 - Aggregates + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported; + +public final class EFacetUIConstants { + + private static final String CATALOG_VIEW_ID = "org.eclipse.papyrus.emf.facet.efacet.ui.view.catalog"; //$NON-NLS-1$ + + private EFacetUIConstants() { + // utility class + } + + public static String getFacetSetsCatalogViewId() { + return EFacetUIConstants.CATALOG_VIEW_ID; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IETypedElementSelectionDialog.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IETypedElementSelectionDialog.java index a9569ae7482..634fa8ea6ec 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IETypedElementSelectionDialog.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IETypedElementSelectionDialog.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:
- * Nicolas Bros (Mia-Software) - Bug 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2
- * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.ETypedElement;
-
-/**
- * A dialog to let the user select ETypedElements.
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- * @since 0.2.0
- */
-public interface IETypedElementSelectionDialog<D> {
-
- /** Set the selection to the given list of ETypedElements */
- void setSelectedETypedElements(List<? extends ETypedElement> newSelection);
-
- /** Emulate a press on the OK button */
- D pressOk();
-
- /** Emulate a press on the Cancel button */
- void pressCancel();
-}
+/******************************************************************************* + * 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 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2 + * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>) + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog; + +import java.util.List; + +import org.eclipse.emf.ecore.ETypedElement; + +/** + * A dialog to let the user select ETypedElements. + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @since 0.2.0 + */ +public interface IETypedElementSelectionDialog<D> { + + /** Set the selection to the given list of ETypedElements */ + void setSelectedETypedElements(List<? extends ETypedElement> newSelection); + + /** Emulate a press on the OK button */ + D pressOk(); + + /** Emulate a press on the Cancel button */ + void pressCancel(); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IETypedElementSelectionDialogCallback.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IETypedElementSelectionDialogCallback.java index 88cf8f47c90..bc6d215b2b0 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IETypedElementSelectionDialogCallback.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IETypedElementSelectionDialogCallback.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:
- * Nicolas Bros (Mia-Software) - Bug 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.ETypedElement;
-
-/**
- * Called when a {@link IETypedElementSelectionDialog} is closed, either by OK or Cancel.
- * <p>
- * This interface is intended to be implemented by clients.
- *
- * @since 0.2.0
- */
-public interface IETypedElementSelectionDialogCallback {
- /** The user canceled the dialog */
- void canceled();
-
- /** The user committed their selection in the dialog */
- void committed(List<ETypedElement> selection);
-}
+/******************************************************************************* + * 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 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2 + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog; + +import java.util.List; + +import org.eclipse.emf.ecore.ETypedElement; + +/** + * Called when a {@link IETypedElementSelectionDialog} is closed, either by OK or Cancel. + * <p> + * This interface is intended to be implemented by clients. + * + * @since 0.2.0 + */ +public interface IETypedElementSelectionDialogCallback { + /** The user canceled the dialog */ + void canceled(); + + /** The user committed their selection in the dialog */ + void committed(List<ETypedElement> selection); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IETypedElementSelectionDialogFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IETypedElementSelectionDialogFactory.java index e0a080542c2..ee391616a42 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IETypedElementSelectionDialogFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IETypedElementSelectionDialogFactory.java @@ -1,62 +1,62 @@ -/*******************************************************************************
- * 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 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2
- * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- * 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.ui.internal.exported.dialog;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs.ETypedElementSelectionDialogFactory;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallbackWithPreCommit;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * A factory to create {@link IETypedElementSelectionDialog}s
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- * @since 0.2.0
- */
-public interface IETypedElementSelectionDialogFactory {
-
- /** This is the default instance of this interface. */
- IETypedElementSelectionDialogFactory DEFAULT = new ETypedElementSelectionDialogFactory();
-
- /**
- * Open a dialog to let the user select ETypedElements to load.
- *
- * @param eTypedElements
- * the list of ETypedElements that can be selected using this dialog
- * @param selectionMaxSize
- * the maximum number of typed elements that the user can select
- * @param allowEmpty
- * whether to allow the user to select no ETypedElement (i.e : select <code>null</code>)
- * @param callback
- * called when the dialog closes
- * @param parentShell
- * the parent shell
- * @param customManager
- * the customization manager used by the
- * ICustomizableLabelProvider. Can be null.
- */
- <T2, D> IETypedElementSelectionDialog<D> openETypedElementSelectionDialog(
- Collection<? extends ETypedElement> eTypedElements,
- int selectionMaxSize, boolean allowEmpty,
- IDialogCallbackWithPreCommit<List<ETypedElement>, T2, D> callback,
- Shell parentShell,
- ICustomizationManager customManager,
- Collection<? extends EPackage> knownFacetSets);
-}
+/******************************************************************************* + * 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 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2 + * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + * 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.ui.internal.exported.dialog; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs.ETypedElementSelectionDialogFactory; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallbackWithPreCommit; +import org.eclipse.swt.widgets.Shell; + +/** + * A factory to create {@link IETypedElementSelectionDialog}s + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @since 0.2.0 + */ +public interface IETypedElementSelectionDialogFactory { + + /** This is the default instance of this interface. */ + IETypedElementSelectionDialogFactory DEFAULT = new ETypedElementSelectionDialogFactory(); + + /** + * Open a dialog to let the user select ETypedElements to load. + * + * @param eTypedElements + * the list of ETypedElements that can be selected using this dialog + * @param selectionMaxSize + * the maximum number of typed elements that the user can select + * @param allowEmpty + * whether to allow the user to select no ETypedElement (i.e : select <code>null</code>) + * @param callback + * called when the dialog closes + * @param parentShell + * the parent shell + * @param customManager + * the customization manager used by the + * ICustomizableLabelProvider. Can be null. + */ + <T2, D> IETypedElementSelectionDialog<D> openETypedElementSelectionDialog( + Collection<? extends ETypedElement> eTypedElements, + int selectionMaxSize, boolean allowEmpty, + IDialogCallbackWithPreCommit<List<ETypedElement>, T2, D> callback, + Shell parentShell, + ICustomizationManager customManager, + Collection<? extends EPackage> knownFacetSets); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IETypedElementSelectionDialogInternal.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IETypedElementSelectionDialogInternal.java index 0231978559b..8f21f2c35bc 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IETypedElementSelectionDialogInternal.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IETypedElementSelectionDialogInternal.java @@ -1,53 +1,53 @@ -/*******************************************************************************
- * 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 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2
- * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.jface.window.Window;
-
-/**
- * Internal interface for a dialog to let the user select ETypedElements.
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- * @since 0.2.0
- */
-public interface IETypedElementSelectionDialogInternal<D> extends
- IETypedElementSelectionDialog<D> {
-
- /**
- * @return whether the "OK" button is currently enabled. It can be disabled if a validator is set, and the current
- * selection is not valid.
- */
- boolean isOkButtonEnabled();
-
- /**
- * @return the selected ETypedElements.
- * @throws UnsupportedOperationException
- * if the dialog was cancelled (check {@link IETypedElementSelectionDialogInternal#getReturnCode()
- * getReturnCode} before calling this method
- */
- List<ETypedElement> getSelectedETypedElements();
-
- /**
- * @return the first selected ETypedElements or <code>null</code> if none.
- * @throws UnsupportedOperationException
- * if the dialog was cancelled (check {@link IETypedElementSelectionDialogInternal#getReturnCode()
- * getReturnCode} before calling this method
- */
- ETypedElement getFirstSelectedETypedElement();
-
- /** @return {@link Window#OK} or {@link Window#CANCEL}. */
- int getReturnCode();
-}
+/******************************************************************************* + * 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 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2 + * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>) + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog; + +import java.util.List; + +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.jface.window.Window; + +/** + * Internal interface for a dialog to let the user select ETypedElements. + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @since 0.2.0 + */ +public interface IETypedElementSelectionDialogInternal<D> extends + IETypedElementSelectionDialog<D> { + + /** + * @return whether the "OK" button is currently enabled. It can be disabled if a validator is set, and the current + * selection is not valid. + */ + boolean isOkButtonEnabled(); + + /** + * @return the selected ETypedElements. + * @throws UnsupportedOperationException + * if the dialog was cancelled (check {@link IETypedElementSelectionDialogInternal#getReturnCode() + * getReturnCode} before calling this method + */ + List<ETypedElement> getSelectedETypedElements(); + + /** + * @return the first selected ETypedElements or <code>null</code> if none. + * @throws UnsupportedOperationException + * if the dialog was cancelled (check {@link IETypedElementSelectionDialogInternal#getReturnCode() + * getReturnCode} before calling this method + */ + ETypedElement getFirstSelectedETypedElement(); + + /** @return {@link Window#OK} or {@link Window#CANCEL}. */ + int getReturnCode(); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IFacetSetSelectionDialog.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IFacetSetSelectionDialog.java index 7ead21c30b1..130d2ec6879 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IFacetSetSelectionDialog.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IFacetSetSelectionDialog.java @@ -1,47 +1,47 @@ -/*******************************************************************************
- * 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 372865 - FacetSet selection dialog
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog;
-
-import java.util.List;
-
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-
-/**
- * A dialog to let the user select facet sets to load.
- *
- * @param <T>
- * the type of a pre-commit dialog
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- * @since 0.2.0
- */
-public interface IFacetSetSelectionDialog<T> {
-
- /** Set the selection to the given list of {@link FacetSet}s */
- void setSelectedFacetSets(List<? extends FacetSet> newSelection);
-
- /**
- * Emulate a press on the OK button
- *
- * @return a pre-commit dialog, or <code>null</code> if no pre-commit dialog was opened
- */
- T pressOk();
-
- /** Emulate a press on the Cancel button */
- void pressCancel();
-
- /** Check all {@link FacetSet}s */
- void selectAll();
-
- /** Uncheck all {@link FacetSet}s */
- void deselectAll();
-}
+/******************************************************************************* + * 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 372865 - FacetSet selection dialog + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog; + +import java.util.List; + +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; + +/** + * A dialog to let the user select facet sets to load. + * + * @param <T> + * the type of a pre-commit dialog + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @since 0.2.0 + */ +public interface IFacetSetSelectionDialog<T> { + + /** Set the selection to the given list of {@link FacetSet}s */ + void setSelectedFacetSets(List<? extends FacetSet> newSelection); + + /** + * Emulate a press on the OK button + * + * @return a pre-commit dialog, or <code>null</code> if no pre-commit dialog was opened + */ + T pressOk(); + + /** Emulate a press on the Cancel button */ + void pressCancel(); + + /** Check all {@link FacetSet}s */ + void selectAll(); + + /** Uncheck all {@link FacetSet}s */ + void deselectAll(); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IFacetSetSelectionDialogFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IFacetSetSelectionDialogFactory.java index 1eec2e88538..044abce2376 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IFacetSetSelectionDialogFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IFacetSetSelectionDialogFactory.java @@ -1,72 +1,72 @@ -/*******************************************************************************
- * 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 372865 - FacetSet selection dialog
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs.FacetSetSelectionDialogFactory;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallback;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallbackWithPreCommit;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * A factory to create {@link IFacetSetSelectionDialog}s
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- * @since 0.2.0
- */
-public interface IFacetSetSelectionDialogFactory {
-
- /** This is the default instance of this interface. */
- IFacetSetSelectionDialogFactory DEFAULT = new FacetSetSelectionDialogFactory();
-
- /**
- * Open a dialog to let the user select facet sets.
- *
- * @param available
- * the {@link FacetSet}s the user will be able to select in the dialog
- * @param selectionMaxSize
- * the maximum number of {@link FacetSet}s that the user can select
- * @param allowEmpty
- * whether to allow the user to select no FacetSet (i.e : select <code>null</code>)
- * @param callback
- * called when the dialog closes
- * @param parentShell
- * the parent shell
- * @return an instance of the dialog being opened
- */
- IFacetSetSelectionDialog<?> openFacetSetSelectionDialog(Collection<FacetSet> available,
- int selectionMaxSize, boolean allowEmpty, IDialogCallback<List<FacetSet>> callback,
- Shell parentShell);
-
- /**
- * Open a dialog to let the user select facet sets. The callback will be called before the dialog closes, to let you
- * open a "pre-commit" dialog, to ask the user for confirmation for example.
- *
- * @param available
- * the {@link FacetSet}s the user will be able to select in the dialog
- * @param selectionMaxSize
- * the maximum number of {@link FacetSet}s that the user can select
- * @param allowEmpty
- * whether to allow the user to select no FacetSet (i.e : select <code>null</code>)
- * @param callback
- * called before the dialog is committed, and again when the dialog is committed
- * @param parentShell
- * the parent shell
- * @return an instance of the dialog being opened
- */
- <T> IFacetSetSelectionDialog<T> openFacetSetSelectionDialog(Collection<FacetSet> available,
- int selectionMaxSize, boolean allowEmpty, IDialogCallbackWithPreCommit<List<FacetSet>, Boolean, T> callback,
- Shell parentShell);
-}
+/******************************************************************************* + * 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 372865 - FacetSet selection dialog + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs.FacetSetSelectionDialogFactory; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallback; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.dialog.IDialogCallbackWithPreCommit; +import org.eclipse.swt.widgets.Shell; + +/** + * A factory to create {@link IFacetSetSelectionDialog}s + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @since 0.2.0 + */ +public interface IFacetSetSelectionDialogFactory { + + /** This is the default instance of this interface. */ + IFacetSetSelectionDialogFactory DEFAULT = new FacetSetSelectionDialogFactory(); + + /** + * Open a dialog to let the user select facet sets. + * + * @param available + * the {@link FacetSet}s the user will be able to select in the dialog + * @param selectionMaxSize + * the maximum number of {@link FacetSet}s that the user can select + * @param allowEmpty + * whether to allow the user to select no FacetSet (i.e : select <code>null</code>) + * @param callback + * called when the dialog closes + * @param parentShell + * the parent shell + * @return an instance of the dialog being opened + */ + IFacetSetSelectionDialog<?> openFacetSetSelectionDialog(Collection<FacetSet> available, + int selectionMaxSize, boolean allowEmpty, IDialogCallback<List<FacetSet>> callback, + Shell parentShell); + + /** + * Open a dialog to let the user select facet sets. The callback will be called before the dialog closes, to let you + * open a "pre-commit" dialog, to ask the user for confirmation for example. + * + * @param available + * the {@link FacetSet}s the user will be able to select in the dialog + * @param selectionMaxSize + * the maximum number of {@link FacetSet}s that the user can select + * @param allowEmpty + * whether to allow the user to select no FacetSet (i.e : select <code>null</code>) + * @param callback + * called before the dialog is committed, and again when the dialog is committed + * @param parentShell + * the parent shell + * @return an instance of the dialog being opened + */ + <T> IFacetSetSelectionDialog<T> openFacetSetSelectionDialog(Collection<FacetSet> available, + int selectionMaxSize, boolean allowEmpty, IDialogCallbackWithPreCommit<List<FacetSet>, Boolean, T> callback, + Shell parentShell); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IFacetSetSelectionDialogInternal.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IFacetSetSelectionDialogInternal.java index 5f569d0cc0b..779091c4a07 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IFacetSetSelectionDialogInternal.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/dialog/IFacetSetSelectionDialogInternal.java @@ -1,35 +1,35 @@ -/*******************************************************************************
- * 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 372865 - FacetSet selection dialog
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-
-/**
- * Internal interface for a dialog to let the user select {@link FacetSet}s.
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- *
- * @param <T>
- * the type of a pre-commit dialog (can be <code>null</code> if there is no pre-commit dialog)
- */
-public interface IFacetSetSelectionDialogInternal<T> extends IFacetSetSelectionDialog<T> {
-
- /**
- * @return whether the "OK" button is currently enabled. It can be disabled if a validator is set, and the current
- * selection is not valid.
- */
- boolean isOkButtonEnabled();
-
- /** @return the tree viewer */
- TreeViewer getTreeViewer();
-}
+/******************************************************************************* + * 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 372865 - FacetSet selection dialog + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.dialog; + +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; + +/** + * Internal interface for a dialog to let the user select {@link FacetSet}s. + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * + * @param <T> + * the type of a pre-commit dialog (can be <code>null</code> if there is no pre-commit dialog) + */ +public interface IFacetSetSelectionDialogInternal<T> extends IFacetSetSelectionDialog<T> { + + /** + * @return whether the "OK" button is currently enabled. It can be disabled if a validator is set, and the current + * selection is not valid. + */ + boolean isOkButtonEnabled(); + + /** @return the tree viewer */ + TreeViewer getTreeViewer(); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/view/INavigationView.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/view/INavigationView.java index b3a6da3a073..35e2fe96ca0 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/view/INavigationView.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/view/INavigationView.java @@ -1,124 +1,124 @@ -/**
- * 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 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
- * Nicolas Bros (Mia-Software) - Bug 379395 - Navigate should replace elements
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.view;
-
-import java.io.NotActiveException;
-import java.util.Collection;
-import java.util.List;
-
-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.ui.IETypedElementResultDisplayerOpener;
-import org.eclipse.ui.part.WorkbenchPart;
-
-/**
- * This interface presents the services provided by a navigation view.
- *
- * @author Gregoire Dupe
- *
- */
-public interface INavigationView {
-
- /**
- * Add {@link EObject}s to the list of sources.
- * <p>
- * This method is called by the drop listener to fill the the navigation source {@link EObject} list
- *
- * @param eObjects
- * the model elements to add to the list of sources
- */
- void addEObjects(Collection<? extends EObject> eObjects);
-
- /**
- * This method removes one eObject from the navigation source {@link EObject} list
- *
- * This method must be called by the "Delete" command handler.
- *
- * @param eObject
- * eObject to remove from the navigation source {@link EObject} list
- */
- void removeEObject(EObject eObject);
-
- /**
- * This method remove a list of eObject from the navigation source {@link EObject} list
- * This method must be called by the "Delete" command handler
- *
- * @param eObjects
- * eObjects to remove from the navigation source {@link EObject} list
- */
- void removeEObjects(List<? extends EObject> eObjects);
-
- /**
- * This method clear the navigation source {@link EObject} list
- */
- void removeAllEObjects();
-
- /**
- * The methods must return the classifier for which each selected EObject conforms to.
- *
- * @return classifiers usable to the navigation
- */
- List<EClassifier> getUsableEClassifiers();
-
- /**
- * This method selects the eTypedElement that we want to navigate through. We can navigate
- * through an eStructuralFeature (or an eOperation) owned by a Facet or owned by an EClass.
- *
- * @param eTypedElement
- * must a contained by one of the classifier returned by getUsableEClassifiers().
- * @throws IllegalArgumentException
- * if eTypedElement is {@link NotActiveException} contained by one of the classifier
- * returned by getUsableEClassifiers().
- */
- void selectETypedElement(ETypedElement eTypedElement);
-
- /**
- * This method returns the eTypedElement that we want to navigate through.
- *
- * @return the eTypedElement that we want to navigate through.
- */
- ETypedElement getSelectedETypedElement();
-
- /**
- * This method returns the list of {@link IETypedElementResultDisplayerOpener} which have
- * been resisted using the org.eclipse.papyrus.emf.facet.efacet.ui.displayeropener extension point.
- *
- * @return a list of {@link IETypedElementResultDisplayerOpener}
- */
- List<IETypedElementResultDisplayerOpener> getAvailableSelectedDisplayers();
-
- /**
- * This method has to be used to select a {@link IETypedElementResultDisplayerOpener}
- *
- * @param resultDisplayer
- * must be contained in the list returned by getAvailableSelectedDisplayers().
- */
- void setSelectDisplayer(
- IETypedElementResultDisplayerOpener resultDisplayer);
-
- /**
- * This method the selected {@link IETypedElementResultDisplayerOpener}
- *
- * @return an {@link IETypedElementResultDisplayerOpener} which is contained by the list
- * returned by getAvailableSelectedDisplayers().
- */
- IETypedElementResultDisplayerOpener getSelectedDisplayer();
-
- /**
- * This method performs the navigation and return the {@link WorkbenchPart} in which the result is presented.
- *
- * @return
- */
- WorkbenchPart preform();
-}
+/** + * 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 364325 - [Restructuring] The user must be able to navigate into a model using the Facet. + * Nicolas Bros (Mia-Software) - Bug 379395 - Navigate should replace elements + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.view; + +import java.io.NotActiveException; +import java.util.Collection; +import java.util.List; + +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.ui.IETypedElementResultDisplayerOpener; +import org.eclipse.ui.part.WorkbenchPart; + +/** + * This interface presents the services provided by a navigation view. + * + * @author Gregoire Dupe + * + */ +public interface INavigationView { + + /** + * Add {@link EObject}s to the list of sources. + * <p> + * This method is called by the drop listener to fill the the navigation source {@link EObject} list + * + * @param eObjects + * the model elements to add to the list of sources + */ + void addEObjects(Collection<? extends EObject> eObjects); + + /** + * This method removes one eObject from the navigation source {@link EObject} list + * + * This method must be called by the "Delete" command handler. + * + * @param eObject + * eObject to remove from the navigation source {@link EObject} list + */ + void removeEObject(EObject eObject); + + /** + * This method remove a list of eObject from the navigation source {@link EObject} list + * This method must be called by the "Delete" command handler + * + * @param eObjects + * eObjects to remove from the navigation source {@link EObject} list + */ + void removeEObjects(List<? extends EObject> eObjects); + + /** + * This method clear the navigation source {@link EObject} list + */ + void removeAllEObjects(); + + /** + * The methods must return the classifier for which each selected EObject conforms to. + * + * @return classifiers usable to the navigation + */ + List<EClassifier> getUsableEClassifiers(); + + /** + * This method selects the eTypedElement that we want to navigate through. We can navigate + * through an eStructuralFeature (or an eOperation) owned by a Facet or owned by an EClass. + * + * @param eTypedElement + * must a contained by one of the classifier returned by getUsableEClassifiers(). + * @throws IllegalArgumentException + * if eTypedElement is {@link NotActiveException} contained by one of the classifier + * returned by getUsableEClassifiers(). + */ + void selectETypedElement(ETypedElement eTypedElement); + + /** + * This method returns the eTypedElement that we want to navigate through. + * + * @return the eTypedElement that we want to navigate through. + */ + ETypedElement getSelectedETypedElement(); + + /** + * This method returns the list of {@link IETypedElementResultDisplayerOpener} which have + * been resisted using the org.eclipse.papyrus.emf.facet.efacet.ui.displayeropener extension point. + * + * @return a list of {@link IETypedElementResultDisplayerOpener} + */ + List<IETypedElementResultDisplayerOpener> getAvailableSelectedDisplayers(); + + /** + * This method has to be used to select a {@link IETypedElementResultDisplayerOpener} + * + * @param resultDisplayer + * must be contained in the list returned by getAvailableSelectedDisplayers(). + */ + void setSelectDisplayer( + IETypedElementResultDisplayerOpener resultDisplayer); + + /** + * This method the selected {@link IETypedElementResultDisplayerOpener} + * + * @return an {@link IETypedElementResultDisplayerOpener} which is contained by the list + * returned by getAvailableSelectedDisplayers(). + */ + IETypedElementResultDisplayerOpener getSelectedDisplayer(); + + /** + * This method performs the navigation and return the {@link WorkbenchPart} in which the result is presented. + * + * @return + */ + WorkbenchPart preform(); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/view/INavigationViewFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/view/INavigationViewFactory.java index 98c05cfc4a8..ea427b7781e 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/view/INavigationViewFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/view/INavigationViewFactory.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:
- * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.view;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.view.NavigationViewFactory;
-
-/**
- * This interface allows to get an instance of the {@link INavigationView} interface
- *
- * @author Gregoire Dupe
- *
- */
-public interface INavigationViewFactory {
-
- /**
- * This is the default instance of this interface.
- */
- INavigationViewFactory DEFAULT = new NavigationViewFactory();
-
- /**
- * This method is the only way to open and access the navigation view.
- *
- * @param editingDomain
- *
- * @return an instance of {@link INavigationView}
- */
- INavigationView openNavigationView(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: + * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet. + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.view; + +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.view.NavigationViewFactory; + +/** + * This interface allows to get an instance of the {@link INavigationView} interface + * + * @author Gregoire Dupe + * + */ +public interface INavigationViewFactory { + + /** + * This is the default instance of this interface. + */ + INavigationViewFactory DEFAULT = new NavigationViewFactory(); + + /** + * This method is the only way to open and access the navigation view. + * + * @param editingDomain + * + * @return an instance of {@link INavigationView} + */ + INavigationView openNavigationView(EditingDomain editingDomain); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/widget/IETypedElementSelectionWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/widget/IETypedElementSelectionWidget.java index e75618ad6e2..66875bdf96c 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/widget/IETypedElementSelectionWidget.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/widget/IETypedElementSelectionWidget.java @@ -1,42 +1,42 @@ -/*******************************************************************************
- * 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 370442 - rewrite the Facet loading dialog for v0.2
- * Nicolas Bros (Mia-Software) - Bug 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.emf.ecore.ETypedElement;
-
-/**
- * A widget to select one or more {@link ETypedElement}s from a list
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- * @since 0.2.0
- */
-public interface IETypedElementSelectionWidget {
-
- /**
- * This method can be called at any time to change the {@link ETypedElement}s which can be selected by the user.
- *
- * @param available
- * the {@link ETypedElement}s that can be selected in this widget
- */
- void setAvailableETypedElements(Collection<? extends ETypedElement> available);
-
- /** @return the list of selected {@link ETypedElement}s */
- List<ETypedElement> getSelectedETypedElements();
-
- /** Select the given {@link ETypedElement}s in this widget. */
- void setSelectedETypedElements(Collection<? extends ETypedElement> elementsToSelect);
-
-}
+/******************************************************************************* + * 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 370442 - rewrite the Facet loading dialog for v0.2 + * Nicolas Bros (Mia-Software) - Bug 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2 + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.ecore.ETypedElement; + +/** + * A widget to select one or more {@link ETypedElement}s from a list + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @since 0.2.0 + */ +public interface IETypedElementSelectionWidget { + + /** + * This method can be called at any time to change the {@link ETypedElement}s which can be selected by the user. + * + * @param available + * the {@link ETypedElement}s that can be selected in this widget + */ + void setAvailableETypedElements(Collection<? extends ETypedElement> available); + + /** @return the list of selected {@link ETypedElement}s */ + List<ETypedElement> getSelectedETypedElements(); + + /** Select the given {@link ETypedElement}s in this widget. */ + void setSelectedETypedElements(Collection<? extends ETypedElement> elementsToSelect); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/widget/IETypedElementSelectionWidgetFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/widget/IETypedElementSelectionWidgetFactory.java index 5e19a8a0c26..1de1ddaec13 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/widget/IETypedElementSelectionWidgetFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/widget/IETypedElementSelectionWidgetFactory.java @@ -1,55 +1,55 @@ -/*******************************************************************************
- * 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 370442 - rewrite the Facet loading dialog for v0.2
- * Nicolas Bros (Mia-Software) - Bug 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2
- * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget;
-
-import java.util.Collection;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget.ETypedElementSelectionWidgetFactory;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * Factory for {@link IETypedElementSelectionWidget}
- *
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- * @since 0.2.0
- */
-public interface IETypedElementSelectionWidgetFactory {
- /** This is the default instance of this interface. */
- IETypedElementSelectionWidgetFactory DEFAULT = new ETypedElementSelectionWidgetFactory();
-
- /**
- * Open a dialog to let the user select ETypedElements
- *
- * @param selectionMaxSize
- * the maximum number of typed elements that the user can select.
- * @param allowEmpty
- * whether to allow the user to select no ETypedElement (i.e :
- * select <code>null</code>)
- * @param parentComposite
- * the parent composite
- * @param customManager
- * the customization manager used by the
- * ICustomizableLabelProvider
- * @since 0.2
- */
- IETypedElementSelectionWidget createETypedElementSelectionWidget(
- int selectionMaxSize,
- boolean allowEmpty,
- Composite parentComposite,
- ICustomizationManager customManager,
- Collection<? extends EObject> knownEPackage);
-}
+/******************************************************************************* + * 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 370442 - rewrite the Facet loading dialog for v0.2 + * Nicolas Bros (Mia-Software) - Bug 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2 + * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget; + +import java.util.Collection; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget.ETypedElementSelectionWidgetFactory; +import org.eclipse.swt.widgets.Composite; + +/** + * Factory for {@link IETypedElementSelectionWidget} + * + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + * @since 0.2.0 + */ +public interface IETypedElementSelectionWidgetFactory { + /** This is the default instance of this interface. */ + IETypedElementSelectionWidgetFactory DEFAULT = new ETypedElementSelectionWidgetFactory(); + + /** + * Open a dialog to let the user select ETypedElements + * + * @param selectionMaxSize + * the maximum number of typed elements that the user can select. + * @param allowEmpty + * whether to allow the user to select no ETypedElement (i.e : + * select <code>null</code>) + * @param parentComposite + * the parent composite + * @param customManager + * the customization manager used by the + * ICustomizableLabelProvider + * @since 0.2 + */ + IETypedElementSelectionWidget createETypedElementSelectionWidget( + int selectionMaxSize, + boolean allowEmpty, + Composite parentComposite, + ICustomizationManager customManager, + Collection<? extends EObject> knownEPackage); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/widget/IFacetSetSelectionWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/widget/IFacetSetSelectionWidget.java index f755dc50579..593fb7c40e6 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/widget/IFacetSetSelectionWidget.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/widget/IFacetSetSelectionWidget.java @@ -1,50 +1,50 @@ -/*******************************************************************************
- * 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 372865 - FacetSet selection dialog
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.swt.widgets.Control;
-
-/**
- * A widget to select one or more {@link FacetSet}s from a tree
- *
- * @since 0.2.0
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface IFacetSetSelectionWidget {
-
- /**
- * This method can be called at any time to change the {@link FacetSet}s which can be selected by the user.
- *
- * @param available
- * the {@link FacetSet}s that can be selected in this widget
- */
- void setAvailableFacetSets(Collection<? extends FacetSet> available);
-
- /** @return the list of selected {@link FacetSet}s */
- List<FacetSet> getSelectedFacetSets();
-
- /** Select the given {@link FacetSet}s in this widget. */
- void setSelectedFacetSets(Collection<? extends FacetSet> newSelection);
-
- /**
- * @return the validation status : the selection is not valid if {@link IStatus#getSeverity()} >= {@link IStatus#ERROR}
- */
- IStatus getValidationStatus();
-
- /** @return the SWT control */
- Control getControl();
-}
+/******************************************************************************* + * 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 372865 - FacetSet selection dialog + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; +import org.eclipse.swt.widgets.Control; + +/** + * A widget to select one or more {@link FacetSet}s from a tree + * + * @since 0.2.0 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface IFacetSetSelectionWidget { + + /** + * This method can be called at any time to change the {@link FacetSet}s which can be selected by the user. + * + * @param available + * the {@link FacetSet}s that can be selected in this widget + */ + void setAvailableFacetSets(Collection<? extends FacetSet> available); + + /** @return the list of selected {@link FacetSet}s */ + List<FacetSet> getSelectedFacetSets(); + + /** Select the given {@link FacetSet}s in this widget. */ + void setSelectedFacetSets(Collection<? extends FacetSet> newSelection); + + /** + * @return the validation status : the selection is not valid if {@link IStatus#getSeverity()} >= {@link IStatus#ERROR} + */ + IStatus getValidationStatus(); + + /** @return the SWT control */ + Control getControl(); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/widget/IFacetSetSelectionWidgetFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/widget/IFacetSetSelectionWidgetFactory.java index 2c535ab9b14..c40fd9066e6 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/widget/IFacetSetSelectionWidgetFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/widget/IFacetSetSelectionWidgetFactory.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 372865 - FacetSet selection dialog
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget;
-
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget.FacetSetSelectionWidgetFactory;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * Factory for {@link IFacetSetSelectionWidget}
- *
- * @since 0.2.0
- * @noextend This interface is not intended to be extended by clients.
- * @noimplement This interface is not intended to be implemented by clients.
- */
-public interface IFacetSetSelectionWidgetFactory {
- /** This is the default instance of this interface. */
- IFacetSetSelectionWidgetFactory DEFAULT = new FacetSetSelectionWidgetFactory();
-
- /**
- * Open a dialog to let the user select ETypedElements
- *
- * @param selectionMaxSize
- * the maximum number of typed elements that the user can select.
- * @param allowEmpty
- * whether to allow the user to select no ETypedElement (i.e : select <code>null</code>)
- * @param parentComposite
- * the parent composite
- * @param onChange
- * called when the selection changes
- */
- IFacetSetSelectionWidget createFacetSetSelectionWidget(
- int selectionMaxSize,
- boolean allowEmpty,
- Composite parentComposite,
- Runnable onChange);
-}
+/******************************************************************************* + * 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 372865 - FacetSet selection dialog + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget; + +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget.FacetSetSelectionWidgetFactory; +import org.eclipse.swt.widgets.Composite; + +/** + * Factory for {@link IFacetSetSelectionWidget} + * + * @since 0.2.0 + * @noextend This interface is not intended to be extended by clients. + * @noimplement This interface is not intended to be implemented by clients. + */ +public interface IFacetSetSelectionWidgetFactory { + /** This is the default instance of this interface. */ + IFacetSetSelectionWidgetFactory DEFAULT = new FacetSetSelectionWidgetFactory(); + + /** + * Open a dialog to let the user select ETypedElements + * + * @param selectionMaxSize + * the maximum number of typed elements that the user can select. + * @param allowEmpty + * whether to allow the user to select no ETypedElement (i.e : select <code>null</code>) + * @param parentComposite + * the parent composite + * @param onChange + * called when the selection changes + */ + IFacetSetSelectionWidget createFacetSetSelectionWidget( + int selectionMaxSize, + boolean allowEmpty, + Composite parentComposite, + Runnable onChange); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/ICreateFacetInFacetSetWizard.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/ICreateFacetInFacetSetWizard.java index 571a35b879c..0e230437593 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/ICreateFacetInFacetSetWizard.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/ICreateFacetInFacetSetWizard.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:
- * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.emf.facet.efacet.FacetSet;
-
-/**
- *
- * @deprecated This interface has been replaced by ICreateFacetInFacetSetWizard2. No tracking bug needed because this API has not been released yet.
- * @since 0.2
- */
-@Deprecated
-public interface ICreateFacetInFacetSetWizard {
-
- public void setFacetSet(FacetSet facetSet);
-
- public void canChangeFacetSet(boolean canChange);
-
- public void setExtendedMetaClass(EClass extendedMetaClass);
-
- public void canChangeExtendedMetaClass(boolean canChange);
-
- public int open();
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.emf.facet.efacet.FacetSet; + +/** + * + * @deprecated This interface has been replaced by ICreateFacetInFacetSetWizard2. No tracking bug needed because this API has not been released yet. + * @since 0.2 + */ +@Deprecated +public interface ICreateFacetInFacetSetWizard { + + public void setFacetSet(FacetSet facetSet); + + public void canChangeFacetSet(boolean canChange); + + public void setExtendedMetaClass(EClass extendedMetaClass); + + public void canChangeExtendedMetaClass(boolean canChange); + + public int open(); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/ICreateFacetInFacetSetWizard2.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/ICreateFacetInFacetSetWizard2.java index ceb1b96ca88..a6223291b6d 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/ICreateFacetInFacetSetWizard2.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/ICreateFacetInFacetSetWizard2.java @@ -1,35 +1,35 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- * Gregoire Dupe (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-
-/**
- * TODO This interface has to be renamed to ICreateFacetInFacetSetWizard before the release of 0.2
- *
- * @since 0.2
- */
-// TODO This interface has to be renamed to ICreateFacetInFacetSetWizard before the release of 0.2
-public interface ICreateFacetInFacetSetWizard2 {
-
- public void setFacetSet(FacetSet facetSet);
-
- public void canChangeFacetSet(boolean canChange);
-
- public void setExtendedMetaClass(EClass extendedMetaClass);
-
- public void canChangeExtendedMetaClass(boolean canChange);
-
- public int open();
-}
+/** + * 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 349546 - EMF Facet facetSet editor + * Gregoire Dupe (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; + +/** + * TODO This interface has to be renamed to ICreateFacetInFacetSetWizard before the release of 0.2 + * + * @since 0.2 + */ +// TODO This interface has to be renamed to ICreateFacetInFacetSetWizard before the release of 0.2 +public interface ICreateFacetInFacetSetWizard2 { + + public void setFacetSet(FacetSet facetSet); + + public void canChangeFacetSet(boolean canChange); + + public void setExtendedMetaClass(EClass extendedMetaClass); + + public void canChangeExtendedMetaClass(boolean canChange); + + public int open(); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/ICreateFacetSetWizard.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/ICreateFacetSetWizard.java index 2a28d2fb837..9ea9a105819 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/ICreateFacetSetWizard.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/ICreateFacetSetWizard.java @@ -1,18 +1,18 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard;
-
-public interface ICreateFacetSetWizard {
-
- public int open();
-
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard; + +public interface ICreateFacetSetWizard { + + public int open(); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/IFacetChildrenWizard.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/IFacetChildrenWizard.java index f7dc59bde1b..2e3691c55a7 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/IFacetChildrenWizard.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/IFacetChildrenWizard.java @@ -1,47 +1,47 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.emf.facet.efacet.Facet;
-
-/**
- *
- * @deprecated This interface has been replaced by ICreateFacetInFacetSetWizard2. No tracking bug needed because this API has not been released yet.
- * @since 0.2
- */
-@Deprecated
-public interface IFacetChildrenWizard {
-
- public int open();
-
- public void setFacet(Facet facet);
-
- public void setChildrenName(String name);
-
- public void setUpperBound(int upperBound);
-
- public void setLowerBound(int lowerBound);
-
- public void setType(EClass type);
-
- public void canChangeFacet(boolean canChange);
-
- public void canChangeChildrenName(boolean canChange);
-
- public void canChangeUpperBound(boolean canChange);
-
- public void canChangeLowerBound(boolean canChange);
-
- public void canChangeType(boolean canChange);
-
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.emf.facet.efacet.Facet; + +/** + * + * @deprecated This interface has been replaced by ICreateFacetInFacetSetWizard2. No tracking bug needed because this API has not been released yet. + * @since 0.2 + */ +@Deprecated +public interface IFacetChildrenWizard { + + public int open(); + + public void setFacet(Facet facet); + + public void setChildrenName(String name); + + public void setUpperBound(int upperBound); + + public void setLowerBound(int lowerBound); + + public void setType(EClass type); + + public void canChangeFacet(boolean canChange); + + public void canChangeChildrenName(boolean canChange); + + public void canChangeUpperBound(boolean canChange); + + public void canChangeLowerBound(boolean canChange); + + public void canChangeType(boolean canChange); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/IFacetChildrenWizard2.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/IFacetChildrenWizard2.java index 94b2a655913..bbab839c958 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/IFacetChildrenWizard2.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/IFacetChildrenWizard2.java @@ -1,47 +1,47 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- * Gregoire Dupe (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet;
-
-/**
- *
- * @since 0.2
- */
-// TODO This interface has to be renamed to ICreateFacetInFacetSetWizard before the release of 0.2
-public interface IFacetChildrenWizard2 {
-
- public int open();
-
- public void setFacet(Facet facet);
-
- public void setChildrenName(String name);
-
- public void setUpperBound(int upperBound);
-
- public void setLowerBound(int lowerBound);
-
- public void setType(EClass type);
-
- public void canChangeFacet(boolean canChange);
-
- public void canChangeChildrenName(boolean canChange);
-
- public void canChangeUpperBound(boolean canChange);
-
- public void canChangeLowerBound(boolean canChange);
-
- public void canChangeType(boolean canChange);
-
-}
+/** + * 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 349546 - EMF Facet facetSet editor + * Gregoire Dupe (Mia-Software) - Bug 361617 - Deprecation of APIs for the old Facet metamodels + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Facet; + +/** + * + * @since 0.2 + */ +// TODO This interface has to be renamed to ICreateFacetInFacetSetWizard before the release of 0.2 +public interface IFacetChildrenWizard2 { + + public int open(); + + public void setFacet(Facet facet); + + public void setChildrenName(String name); + + public void setUpperBound(int upperBound); + + public void setLowerBound(int lowerBound); + + public void setType(EClass type); + + public void canChangeFacet(boolean canChange); + + public void canChangeChildrenName(boolean canChange); + + public void canChangeUpperBound(boolean canChange); + + public void canChangeLowerBound(boolean canChange); + + public void canChangeType(boolean canChange); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/IQueryCreationPagePart.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/IQueryCreationPagePart.java index 2024978c4cc..331359307a0 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/IQueryCreationPagePart.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/IQueryCreationPagePart.java @@ -1,168 +1,168 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.papyrus.emf.facet.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.Query;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.IQueryCreationPagePart2;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.CreateQueryWizardPage;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * This interface has to be implemented by {@link Query} factory UI Class. It is used to complete a
- * generic {@link Query} creation wizard with specific widget.
- *
- * @deprecated This interface has been replaced by {@link IQueryCreationPagePart2}. No tracking bug needed because this API has not been released yet.
- * @since 0.2
- */
-@Deprecated
-public interface IQueryCreationPagePart {
-
- /**
- * Set the {@link Query}'s {@link FacetSet}.
- *
- * @param facetSet
- * the given {@link FacetSet}
- */
- public void setFacetSet(FacetSet facetSet);
-
- /**
- * Set the {@link Query}'s upperBound.
- *
- * @param upperBound
- * the upperBound.
- */
- public void setUpperBound(int upperBound);
-
- /**
- * Set the {@link Query}'s lowerBound.
- *
- * @param lowerBound
- * the lowerBound.
- */
- public void setLowerBound(int lowerBound);
-
- /**
- * Set the {@link Query}'s {@link Query#isOrdered() <em>attribute</em>} attribute.
- *
- * @param ordered
- * whether
- */
- public void setOrdered(final boolean ordered);
-
- /**
- * Set the {@link Query}'s {@link Query#isUnique() <em>unique</em>} attribute.
- *
- * @param unique
- * Whether the query is unique or not.
- */
- public void setUnique(final boolean unique);
-
- /**
- * Set the {@link Query}'s type.
- *
- * @param queryType
- * the {@link Query}'s type.
- */
- public void setQueryType(EClassifier queryType);
-
- /**
- * Set the {@link Query}'s name.
- *
- * @param name
- * the query's name.
- */
- public void setQueryName(String name);
-
- /**
- * Set the {@link Query}'s {@link Query#isCanBeCached() <em>Can Be Cached</em>}.
- *
- * @param canBeCached
- * whether the query result can be cached.
- */
- public void setCanBeCached(boolean canBeCached);
-
- /**
- * Set the {@link Query}'s {@link Query#isHasSideEffect() <em>Has Side Effect</em>}.
- *
- * @param hasSideEffect
- * whether the query has side effect, such as modifying a model when applied on it.
- */
- public void setHasSideEffect(boolean hasSideEffect);
-
- /**
- * Set the {@link Query}'s '{@link Query#getScope <em>Scope</em>}'.
- *
- * @param type
- * the {@link Query}'s '{@link Query#getScope <em>Scope</em>}'.
- */
- public void setQueryScope(EClass scope);
-
- /**
- * This method is dedicated to create a {@link Query} with every attribute set by the others
- * methods of {@link IQueryCreationPagePart}.
- *
- * @return the newly created {@link Query}
- */
- public Query performFinish();
-
- /**
- * This method is called by the {@link CreateQueryWizardPage}.
- *
- * @param parent
- * the Wizard's composite to be completed with specific widget for this {@link Query} creation.
- */
- public void completeComposite(Composite parent);
-
- /**
- * Returns <code>true</code> if the composite is complete.
- *
- * @return <code>true</code> if the composite is complete.
- */
- public boolean isCompositeComplete();
-
- /**
- * Returns the error messages generated by the part, or null if none.
- *
- * @return the error messages generated by the part, or null if none.
- */
- public String getErrorMessage();
-
- /**
- * Add a {@link ModifyListener} on the part.
- *
- * @param listener
- * a {@link ModifyListener}
- */
- public void addModifyListener(ModifyListener listener);
-
- /**
- * Remove an existing {@link ModifyListener} from the part's listener.
- *
- * @param listener
- * an existing {@link ModifyListener} listener.
- */
- public void removeModifyListener(ModifyListener listener);
-
- /**
- * Notify the registered listener that something has been modified in the part. It should only
- * be used as a way to update the buttons' state of the containing wizard dialog.
- *
- * @param modifiedComposite
- * the composite on which the modification occured.
- */
- public void notifyCompositeListeners(Composite modifiedComposite);
-
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.papyrus.emf.facet.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.Query; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.IQueryCreationPagePart2; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.CreateQueryWizardPage; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.widgets.Composite; + +/** + * This interface has to be implemented by {@link Query} factory UI Class. It is used to complete a + * generic {@link Query} creation wizard with specific widget. + * + * @deprecated This interface has been replaced by {@link IQueryCreationPagePart2}. No tracking bug needed because this API has not been released yet. + * @since 0.2 + */ +@Deprecated +public interface IQueryCreationPagePart { + + /** + * Set the {@link Query}'s {@link FacetSet}. + * + * @param facetSet + * the given {@link FacetSet} + */ + public void setFacetSet(FacetSet facetSet); + + /** + * Set the {@link Query}'s upperBound. + * + * @param upperBound + * the upperBound. + */ + public void setUpperBound(int upperBound); + + /** + * Set the {@link Query}'s lowerBound. + * + * @param lowerBound + * the lowerBound. + */ + public void setLowerBound(int lowerBound); + + /** + * Set the {@link Query}'s {@link Query#isOrdered() <em>attribute</em>} attribute. + * + * @param ordered + * whether + */ + public void setOrdered(final boolean ordered); + + /** + * Set the {@link Query}'s {@link Query#isUnique() <em>unique</em>} attribute. + * + * @param unique + * Whether the query is unique or not. + */ + public void setUnique(final boolean unique); + + /** + * Set the {@link Query}'s type. + * + * @param queryType + * the {@link Query}'s type. + */ + public void setQueryType(EClassifier queryType); + + /** + * Set the {@link Query}'s name. + * + * @param name + * the query's name. + */ + public void setQueryName(String name); + + /** + * Set the {@link Query}'s {@link Query#isCanBeCached() <em>Can Be Cached</em>}. + * + * @param canBeCached + * whether the query result can be cached. + */ + public void setCanBeCached(boolean canBeCached); + + /** + * Set the {@link Query}'s {@link Query#isHasSideEffect() <em>Has Side Effect</em>}. + * + * @param hasSideEffect + * whether the query has side effect, such as modifying a model when applied on it. + */ + public void setHasSideEffect(boolean hasSideEffect); + + /** + * Set the {@link Query}'s '{@link Query#getScope <em>Scope</em>}'. + * + * @param type + * the {@link Query}'s '{@link Query#getScope <em>Scope</em>}'. + */ + public void setQueryScope(EClass scope); + + /** + * This method is dedicated to create a {@link Query} with every attribute set by the others + * methods of {@link IQueryCreationPagePart}. + * + * @return the newly created {@link Query} + */ + public Query performFinish(); + + /** + * This method is called by the {@link CreateQueryWizardPage}. + * + * @param parent + * the Wizard's composite to be completed with specific widget for this {@link Query} creation. + */ + public void completeComposite(Composite parent); + + /** + * Returns <code>true</code> if the composite is complete. + * + * @return <code>true</code> if the composite is complete. + */ + public boolean isCompositeComplete(); + + /** + * Returns the error messages generated by the part, or null if none. + * + * @return the error messages generated by the part, or null if none. + */ + public String getErrorMessage(); + + /** + * Add a {@link ModifyListener} on the part. + * + * @param listener + * a {@link ModifyListener} + */ + public void addModifyListener(ModifyListener listener); + + /** + * Remove an existing {@link ModifyListener} from the part's listener. + * + * @param listener + * an existing {@link ModifyListener} listener. + */ + public void removeModifyListener(ModifyListener listener); + + /** + * Notify the registered listener that something has been modified in the part. It should only + * be used as a way to update the buttons' state of the containing wizard dialog. + * + * @param modifiedComposite + * the composite on which the modification occured. + */ + public void notifyCompositeListeners(Composite modifiedComposite); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/ISelectETypeWizard.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/ISelectETypeWizard.java index 2fb96d54fb2..4729267851f 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/ISelectETypeWizard.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/exported/wizard/ISelectETypeWizard.java @@ -1,20 +1,20 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard;
-
-import org.eclipse.emf.ecore.EClassifier;
-
-public interface ISelectETypeWizard {
- public int open();
-
- public EClassifier getSelectedEType();
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard; + +import org.eclipse.emf.ecore.EClassifier; + +public interface ISelectETypeWizard { + public int open(); + + public EClassifier getSelectedEType(); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/AddFacetAttributeHandler.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/AddFacetAttributeHandler.java index 6ad9d902c0a..74e581149a5 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/AddFacetAttributeHandler.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/AddFacetAttributeHandler.java @@ -1,48 +1,48 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.IFacetUIFactory;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IFacetChildrenWizard;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * This class handle the action "Add facet attribute"
- */
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public class AddFacetAttributeHandler extends AbstractHandler {
-
- public Object execute(final ExecutionEvent event) throws ExecutionException {
- ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
-
- // Retrieve the editor
- IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- // Retrieve the editing domain
- EditingDomain editingDomain = ((IEditingDomainProvider) editor).getEditingDomain();
-
- IFacetChildrenWizard dialog = IFacetUIFactory.INSTANCE.createAddFacetAttributeWizardDialog(selection, editingDomain);
- dialog.canChangeFacet(false);
- dialog.setLowerBound(0);
- dialog.setUpperBound(0);
- dialog.open();
- return null;
- }
-
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.edit.domain.IEditingDomainProvider; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.IFacetUIFactory; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IFacetChildrenWizard; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PlatformUI; + +/** + * This class handle the action "Add facet attribute" + */ +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public class AddFacetAttributeHandler extends AbstractHandler { + + public Object execute(final ExecutionEvent event) throws ExecutionException { + ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection(); + + // Retrieve the editor + IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); + // Retrieve the editing domain + EditingDomain editingDomain = ((IEditingDomainProvider) editor).getEditingDomain(); + + IFacetChildrenWizard dialog = IFacetUIFactory.INSTANCE.createAddFacetAttributeWizardDialog(selection, editingDomain); + dialog.canChangeFacet(false); + dialog.setLowerBound(0); + dialog.setUpperBound(0); + dialog.open(); + return null; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/AddFacetOperationHandler.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/AddFacetOperationHandler.java index 1b780637067..e28f5a8e9b7 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/AddFacetOperationHandler.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/AddFacetOperationHandler.java @@ -1,48 +1,48 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.IFacetUIFactory;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IFacetChildrenWizard;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * This class handle the action "Add facet operation"
- */
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public class AddFacetOperationHandler extends AbstractHandler {
-
- public Object execute(final ExecutionEvent event) throws ExecutionException {
- ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
-
- // Retrieve the editor
- IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- // Retrieve the editing domain
- EditingDomain editingDomain = ((IEditingDomainProvider) editor).getEditingDomain();
-
- IFacetChildrenWizard dialog = IFacetUIFactory.INSTANCE.createAddFacetOperationWizardDialog(selection, editingDomain);
- dialog.canChangeFacet(false);
- dialog.setLowerBound(0);
- dialog.setUpperBound(0);
- dialog.open();
- return null;
- }
-
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.edit.domain.IEditingDomainProvider; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.IFacetUIFactory; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IFacetChildrenWizard; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PlatformUI; + +/** + * This class handle the action "Add facet operation" + */ +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public class AddFacetOperationHandler extends AbstractHandler { + + public Object execute(final ExecutionEvent event) throws ExecutionException { + ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection(); + + // Retrieve the editor + IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); + // Retrieve the editing domain + EditingDomain editingDomain = ((IEditingDomainProvider) editor).getEditingDomain(); + + IFacetChildrenWizard dialog = IFacetUIFactory.INSTANCE.createAddFacetOperationWizardDialog(selection, editingDomain); + dialog.canChangeFacet(false); + dialog.setLowerBound(0); + dialog.setUpperBound(0); + dialog.open(); + return null; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/AddFacetParameterOperationHandler.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/AddFacetParameterOperationHandler.java index 294a7526e8a..ecf1148c8f2 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/AddFacetParameterOperationHandler.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/AddFacetParameterOperationHandler.java @@ -1,48 +1,48 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.IFacetUIFactory;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IFacetChildrenWizard;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * This class handle the action "Add facet operation parameter"
- */
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public class AddFacetParameterOperationHandler extends AbstractHandler {
-
- public Object execute(final ExecutionEvent event) throws ExecutionException {
- ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
-
- // Retrieve the editor
- IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- // Retrieve the editing domain
- EditingDomain editingDomain = ((IEditingDomainProvider) editor).getEditingDomain();
-
- IFacetChildrenWizard dialog = IFacetUIFactory.INSTANCE.createAddFacetOperationParameterWizardDialog(selection, editingDomain);
- dialog.canChangeFacet(false);
- dialog.setLowerBound(0);
- dialog.setUpperBound(0);
- dialog.open();
- return null;
- }
-
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.edit.domain.IEditingDomainProvider; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.IFacetUIFactory; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IFacetChildrenWizard; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PlatformUI; + +/** + * This class handle the action "Add facet operation parameter" + */ +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public class AddFacetParameterOperationHandler extends AbstractHandler { + + public Object execute(final ExecutionEvent event) throws ExecutionException { + ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection(); + + // Retrieve the editor + IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); + // Retrieve the editing domain + EditingDomain editingDomain = ((IEditingDomainProvider) editor).getEditingDomain(); + + IFacetChildrenWizard dialog = IFacetUIFactory.INSTANCE.createAddFacetOperationParameterWizardDialog(selection, editingDomain); + dialog.canChangeFacet(false); + dialog.setLowerBound(0); + dialog.setUpperBound(0); + dialog.open(); + return null; + } + }
\ No newline at end of file diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/AddFacetReferenceHandler.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/AddFacetReferenceHandler.java index dcd987d0c25..755079a8d47 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/AddFacetReferenceHandler.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/AddFacetReferenceHandler.java @@ -1,48 +1,48 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.IFacetUIFactory;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IFacetChildrenWizard;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * This class handle the action "Add facet reference"
- */
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public class AddFacetReferenceHandler extends AbstractHandler {
-
- public Object execute(final ExecutionEvent event) throws ExecutionException {
- ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
-
- // Retrieve the editor
- IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- // Retrieve the editing domain
- EditingDomain editingDomain = ((IEditingDomainProvider) editor).getEditingDomain();
-
- IFacetChildrenWizard dialog = IFacetUIFactory.INSTANCE.createAddFacetReferenceWizardDialog(selection, editingDomain);
- dialog.canChangeFacet(false);
- dialog.setLowerBound(0);
- dialog.setUpperBound(0);
- dialog.open();
- return null;
- }
-
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.edit.domain.IEditingDomainProvider; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.IFacetUIFactory; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IFacetChildrenWizard; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PlatformUI; + +/** + * This class handle the action "Add facet reference" + */ +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public class AddFacetReferenceHandler extends AbstractHandler { + + public Object execute(final ExecutionEvent event) throws ExecutionException { + ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection(); + + // Retrieve the editor + IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); + // Retrieve the editing domain + EditingDomain editingDomain = ((IEditingDomainProvider) editor).getEditingDomain(); + + IFacetChildrenWizard dialog = IFacetUIFactory.INSTANCE.createAddFacetReferenceWizardDialog(selection, editingDomain); + dialog.canChangeFacet(false); + dialog.setLowerBound(0); + dialog.setUpperBound(0); + dialog.open(); + return null; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/CreateFacetInFacetSetHandler.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/CreateFacetInFacetSetHandler.java index 1a0abdf2bd0..3fcfdb0a349 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/CreateFacetInFacetSetHandler.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/CreateFacetInFacetSetHandler.java @@ -1,44 +1,44 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.IFacetUIFactory;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.ICreateFacetInFacetSetWizard;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * This class handle the action "Create a facet in a facetSet"
- */
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public class CreateFacetInFacetSetHandler extends AbstractHandler {
-
- public Object execute(final ExecutionEvent event) throws ExecutionException {
- ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
-
- // Retrieve the editor
- IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- // Retrieve the editing domain
- EditingDomain editingDomain = ((IEditingDomainProvider) editor).getEditingDomain();
-
- ICreateFacetInFacetSetWizard dialog = IFacetUIFactory.INSTANCE.createCreateFacetInFacetSetWizardDialog(selection, editingDomain);
- dialog.open();
- return null;
- }
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.handlers; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.edit.domain.IEditingDomainProvider; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.IFacetUIFactory; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.ICreateFacetInFacetSetWizard; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PlatformUI; + +/** + * This class handle the action "Create a facet in a facetSet" + */ +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public class CreateFacetInFacetSetHandler extends AbstractHandler { + + public Object execute(final ExecutionEvent event) throws ExecutionException { + ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection(); + + // Retrieve the editor + IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); + // Retrieve the editing domain + EditingDomain editingDomain = ((IEditingDomainProvider) editor).getEditingDomain(); + + ICreateFacetInFacetSetWizard dialog = IFacetUIFactory.INSTANCE.createCreateFacetInFacetSetWizardDialog(selection, editingDomain); + dialog.open(); + return null; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/FacetPropertyTester.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/FacetPropertyTester.java index 41106b8eb63..97ccabc1b14 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/FacetPropertyTester.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/FacetPropertyTester.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:
- * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.handlers;
-
-import org.eclipse.core.expressions.PropertyTester;
-import org.eclipse.jface.viewers.StructuredSelection;
-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;
-
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public class FacetPropertyTester extends PropertyTester {
-
- private static final String IS_FACET = "isFacet"; //$NON-NLS-1$
- private static final String IS_FACET_SET = "isFacetSet"; //$NON-NLS-1$
- private static final String IS_FACET_OP = "isFacetOperation"; //$NON-NLS-1$
- private static final String IS_FACET_ATT = "isFacetAttribute"; //$NON-NLS-1$
- private static final String IS_FACET_REF = "isFacetReference"; //$NON-NLS-1$
-
- public boolean test(final Object receiver, final String property, final Object[] args, final Object expectedValue) {
- boolean result = false;
- if (expectedValue instanceof Boolean && receiver instanceof StructuredSelection) {
- final StructuredSelection selection = (StructuredSelection) receiver;
- Boolean test = null;
- if (property.equalsIgnoreCase(FacetPropertyTester.IS_FACET)) {
- test = Boolean.valueOf(selection.getFirstElement() instanceof Facet);
- } else if (property.equalsIgnoreCase(FacetPropertyTester.IS_FACET_ATT)) {
- test = Boolean.valueOf(selection.getFirstElement() instanceof FacetAttribute);
- } else if (property.equalsIgnoreCase(FacetPropertyTester.IS_FACET_OP)) {
- test = Boolean.valueOf(selection.getFirstElement() instanceof FacetOperation);
- } else if (property.equalsIgnoreCase(FacetPropertyTester.IS_FACET_REF)) {
- test = Boolean.valueOf(selection.getFirstElement() instanceof FacetReference);
- } else if (property.equalsIgnoreCase(FacetPropertyTester.IS_FACET_SET)) {
- test = Boolean.valueOf(selection.getFirstElement() instanceof FacetSet);
- }
- if (test != null) {
- result = expectedValue.equals(test);
- }
- }
- 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: + * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.handlers; + +import org.eclipse.core.expressions.PropertyTester; +import org.eclipse.jface.viewers.StructuredSelection; +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; + +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public class FacetPropertyTester extends PropertyTester { + + private static final String IS_FACET = "isFacet"; //$NON-NLS-1$ + private static final String IS_FACET_SET = "isFacetSet"; //$NON-NLS-1$ + private static final String IS_FACET_OP = "isFacetOperation"; //$NON-NLS-1$ + private static final String IS_FACET_ATT = "isFacetAttribute"; //$NON-NLS-1$ + private static final String IS_FACET_REF = "isFacetReference"; //$NON-NLS-1$ + + public boolean test(final Object receiver, final String property, final Object[] args, final Object expectedValue) { + boolean result = false; + if (expectedValue instanceof Boolean && receiver instanceof StructuredSelection) { + final StructuredSelection selection = (StructuredSelection) receiver; + Boolean test = null; + if (property.equalsIgnoreCase(FacetPropertyTester.IS_FACET)) { + test = Boolean.valueOf(selection.getFirstElement() instanceof Facet); + } else if (property.equalsIgnoreCase(FacetPropertyTester.IS_FACET_ATT)) { + test = Boolean.valueOf(selection.getFirstElement() instanceof FacetAttribute); + } else if (property.equalsIgnoreCase(FacetPropertyTester.IS_FACET_OP)) { + test = Boolean.valueOf(selection.getFirstElement() instanceof FacetOperation); + } else if (property.equalsIgnoreCase(FacetPropertyTester.IS_FACET_REF)) { + test = Boolean.valueOf(selection.getFirstElement() instanceof FacetReference); + } else if (property.equalsIgnoreCase(FacetPropertyTester.IS_FACET_SET)) { + test = Boolean.valueOf(selection.getFirstElement() instanceof FacetSet); + } + if (test != null) { + result = expectedValue.equals(test); + } + } + return result; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/NavigationHandler.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/NavigationHandler.java index f9f1a2abc23..b22fd35df4d 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/NavigationHandler.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/handlers/NavigationHandler.java @@ -1,69 +1,69 @@ -/**
- * 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 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
- * Nicolas Bros (Mia-Software) - Bug 379395 - Navigate should replace elements
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.handlers;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.view.INavigationView;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.view.INavigationViewFactory;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * This class handle the action "Add facet attribute"
- */
-public class NavigationHandler extends AbstractHandler {
-
- public Object execute(final ExecutionEvent event) throws ExecutionException {
- final ISelection selection = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getSelectionService()
- .getSelection();
-
- // Retrieve the editor
- final IEditorPart editor = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- // Retrieve the editing domain
-
- EditingDomain editingDomain = null;
- if (editor instanceof IEditingDomainProvider) {
- final IEditingDomainProvider edProvider = (IEditingDomainProvider) editor;
- editingDomain = edProvider.getEditingDomain();
- }
-
- final List<EObject> eObjects = new LinkedList<EObject>();
- final INavigationView view = INavigationViewFactory.DEFAULT
- .openNavigationView(editingDomain);
- if (selection instanceof IStructuredSelection) {
- final IStructuredSelection sSelection = (IStructuredSelection) selection;
- for (Object object : sSelection.toList()) {
- if (object instanceof EObject) {
- final EObject eObject = (EObject) object;
- eObjects.add(eObject);
- }
- }
- }
- view.removeAllEObjects();
- view.addEObjects(eObjects);
- return null;
- }
-
-}
+/** + * 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 364325 - [Restructuring] The user must be able to navigate into a model using the Facet. + * Nicolas Bros (Mia-Software) - Bug 379395 - Navigate should replace elements + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.handlers; + +import java.util.LinkedList; +import java.util.List; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.edit.domain.IEditingDomainProvider; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.view.INavigationView; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.view.INavigationViewFactory; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PlatformUI; + +/** + * This class handle the action "Add facet attribute" + */ +public class NavigationHandler extends AbstractHandler { + + public Object execute(final ExecutionEvent event) throws ExecutionException { + final ISelection selection = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getSelectionService() + .getSelection(); + + // Retrieve the editor + final IEditorPart editor = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage().getActiveEditor(); + // Retrieve the editing domain + + EditingDomain editingDomain = null; + if (editor instanceof IEditingDomainProvider) { + final IEditingDomainProvider edProvider = (IEditingDomainProvider) editor; + editingDomain = edProvider.getEditingDomain(); + } + + final List<EObject> eObjects = new LinkedList<EObject>(); + final INavigationView view = INavigationViewFactory.DEFAULT + .openNavigationView(editingDomain); + if (selection instanceof IStructuredSelection) { + final IStructuredSelection sSelection = (IStructuredSelection) selection; + for (Object object : sSelection.toList()) { + if (object instanceof EObject) { + final EObject eObject = (EObject) object; + eObjects.add(eObject); + } + } + } + view.removeAllEObjects(); + view.addEObjects(eObjects); + return null; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/messages.properties b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/messages.properties index f30cb8fba77..e80ed70ccf7 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/messages.properties +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/messages.properties @@ -1,127 +1,127 @@ -##########################################################################
-# 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 349546 - EMF Facet facetSet editor
-# Nicolas Bros (Mia-Software) - Bug 370442 - rewrite the Facet loading dialog for v0.2
-# Grégoire Dupé (Mia-Software) - copied from /org.eclipse.papyrus.emf.facet.infra.query.ui/src/org/eclipse/emf/facet/infra/query/ui/messages.properties
-# Nicolas Bros (Mia-Software) - copied from /org.eclipse.papyrus.emf.facet.infra.query.ui/src/org/eclipse/emf/facet/infra/query/ui/messages.properties
-# 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 372732 - [Facet] Rewrite the catalog views for 0.2
-# Nicolas Bros (Mia-Software) - Bug 372865 - FacetSet selection dialog
-# Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets
-###########################################################################
-Changeable=Changeable
-Derived=Derived
-Ordered=Ordered
-Transient=Transient
-Unique=Unique
-Volatile=Volatile
-Enter_a_nsUri=Enter a nsUri :
-Please_enter_nsUri=Please enter a nsUri
-Enter_a_prefix=Enter a prefix :
-ETypedElementSelectionControl_FlatView=Flat
-ETypedElementSelectionControl_invalidSelection=The selection contains invalid elements
-ETypedElementSelectionControl_invalidSelectionAtLeastOneElement=You must select at least 1 element
-ETypedElementSelectionControl_invalidSelectionAtMostXElements=You must select at most {0} elements
-ETypedElementSelectionControl_invalidSelectionETypedElementsOnly=Only ETypedElements can be selected
-ETypedElementSelectionDialog_dialogTitle=Select ETypedElement
-ETypedElementSelectionDialog_dialogTitleMultiSelection=Select ETypedElements
-ETypedElementSelectionDialog_radioButtonMultiSelection=ETypedElements selected below:
-ETypedElementSelectionDialog_radioButtonNoSelection=No selection
-ETypedElementSelectionDialog_radioButtonSingleSelection=ETypedElement selected below:
-ETypedElementSelectionSortedControl_groupByMetamodelView=Grouped By Metamodel
-ETypedElementSelectionSortedControl_toolTip=Display available ETypedElement sorted by extended metamodels
-Please_enter_prefix=Please enter a prefix
-Please_select_EPackage=Please, select an EPackage
-Add_an_Attribute=Add an attribute
-Add_an_Attribute_desc=Add a new attribute to the selected facet
-Attribute_name=Attribute name:
-Operation=Operation :
-Facet=Facet :
-FacetSet=FacetSet :
-FacetSetsCatalogView_categoriesColumn=Categories
-FacetSetsCatalogView_documentationColumn=Documentation
-FacetSetsCatalogView_extendsColumn=Extends
-FacetSetsCatalogView_nameColumn=Name
-FacetSetsCatalogView_viewTitle=Facet Sets
-FacetSetSelectionControl_mustSelectAtLeastOneElement=You must select at least 1 element
-FacetSetSelectionControl_mustSelectAtMostNElements=You must select at most {0} elements
-FacetSetSelectionControl_onlyFacetSetsAllowedInSelection=Only FacetSets can be selected
-FacetSetSelectionControl_selectionContainsInvalidElements=The selection contains invalid elements
-FacetSetSelectionDialog_deselectAll=Deselect All
-FacetSetSelectionDialog_selectAll=Select All
-FacetSetSelectionDialog_titleSelectFacetSet=Select FacetSet
-FacetSetSelectionDialog_titleSelectFacetSets=Select FacetSets
-Lower_bound=Lower Bound :
-Upper_bound=Upper Bound :
-Add_a_Reference=Add a reference
-Add_an_Operation=Add an Operation
-Add_an_Operation_desc=Add a new operation to the selected facet
-Add_an_Operation_Parameter=Add an Operation Parameter
-Add_an_Operation_Parameter_desc=Add a new operation's parameter to the selected operation
-Operation_name=Operation Name:
-Parameter_name=Parameter Name:
-Add_a_Reference_desc=Add a reference to the selected facet
-Create_FacetSet_Model=Create FacetSet Model
-CreateFacetInFacetSetWizardPage_could_not_find_wizard_page=Could not find the wizard for this query type
-Create_facet_in_facetSet=Create a Facet in a FacetSet
-Please_enter_value_for=Please enter a value for {0}
-CreateFacetInFacetSetWizardPage_Please_fill_extendedMetaClass=Please fill the extendedMetaClass field
-CreateFacetInFacetSetWizardPage_Sub_Typing_Facet=SubTyping Facet
-CreateFacetInFacetSetWizardPage_wizard_description=This wizard creates a new facet in a facetSet.
-CreateFacetSetWizardImpl_Create_new_facet_Set=Create a new Facet Set
-CreateFacetSetWizardImpl_FacetModel=Facet Set
-CreateFacetSetWizardImpl_File_extension_restriction=File extension has to be ".efacet"
-CreateFacetSetWizardPage_Not_a_Plugin_project=Warning : you are creating this FacetSet in a non-Plugin project. It will not be available until moved to a Plugin project.
-Create_Query=Create Query:
-FilteredElementSelectionControl_type_filter_text=type filter text
-Load_MetaModel_Resource=Load Meta-model Resource
-FacetSetSelectionDialog_selectFacetSetsMessage=Choose FacetSets:
-FacetSetSelectionDialog_selectFacetSetsTitle=Select FacetSets
-Package_Selection=Package Selection
-Select_Registered_URI=&Select a registered package URI:
-Select_EClass=Select an EClass
-Select_EClassifier=Select an EClassifier
-Select_EDataType=Select an EDataType
-Select_EPackage=Select an EPackage
-Select=Select
-Type=Type :
-ExtendedMetaClass=&Extended Meta-Class:
-SelectQueryTypeWizardPage_No_wizard_found=No wizard page extension was found for the selected query type. Wizard pages have to be registered using queryFactoryWizardPageRegistration extension point
-SelectQueryTypeWizardPage_Query_Type=Query Type :
-JavaQueryWizardPage_Can_be_cached=Can be cached :
-JavaQueryWizardPage_has_side_effect=Has side effect :
-JavaQueryWizardPage_Query_name=Query name :
-No_result_found=No result found
-Reference_name=Reference name:
-
-#### Begin: copied from /org.eclipse.papyrus.emf.facet.infra.query.ui/src/org/eclipse/emf/facet/infra/query/ui/messages.properties
-QueryExecutionView_0=Missing bundle...
-QueryExecutionView_1=To execute the query, the depending bundle {0} must be installed. It will not be hot loaded.
-QueryExecutionView_classpathWarning=The output location of the Java project "{0}" was not found in its Bundle-ClassPath. This prevents the Java queries implementations it contains from being loaded.
-QueryExecutionView_errorInBundleClasspath=Error in Bundle-ClassPath
-QueryExecutionView_execEnvNotAvailable=Execution environment not available
-QueryExecutionView_execEnvError=To execute the query the execution environment {0} is required but not available. The available execution environments are: {1}
-QueryExecutionView_Context=Context
-QueryExecutionView_DisplayResultIn=Display result in:
-QueryExecutionView_dragAndDropHint=drag&drop model elements here
-QueryExecutionView_ErrorExecutingQuery=Error executing query
-QueryExecutionView_ETypedElementsGroup=ETypedElements
-QueryExecutionView_ExecuteButton=E&xecute
-QueryExecutionView_ExecuteGroup=Execute
-QueryExecutionView_NoQueryDisplayer=No Query Displayer
-QueryExecutionView_NoQuerySelected=No query
-QueryExecutionView_notImplementedYet=<Not implemented yet>
-QueryExecutionView_NullQueryResult=Null query result
-QueryExecutionView_Parameters=Parameters
-QueryExecutionView_Query=Query
-QueryExecutionView_QueryException=Query exception
-QueryExecutionView_QueryReturnedNull=Query returned a null result (see error log)
-QueryExecutionView_SelectQueryToExecute=You must select a query to execute
+########################################################################## +# 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 349546 - EMF Facet facetSet editor +# Nicolas Bros (Mia-Software) - Bug 370442 - rewrite the Facet loading dialog for v0.2 +# Grégoire Dupé (Mia-Software) - copied from /org.eclipse.papyrus.emf.facet.infra.query.ui/src/org/eclipse/emf/facet/infra/query/ui/messages.properties +# Nicolas Bros (Mia-Software) - copied from /org.eclipse.papyrus.emf.facet.infra.query.ui/src/org/eclipse/emf/facet/infra/query/ui/messages.properties +# 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 372732 - [Facet] Rewrite the catalog views for 0.2 +# Nicolas Bros (Mia-Software) - Bug 372865 - FacetSet selection dialog +# Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets +########################################################################### +Changeable=Changeable +Derived=Derived +Ordered=Ordered +Transient=Transient +Unique=Unique +Volatile=Volatile +Enter_a_nsUri=Enter a nsUri : +Please_enter_nsUri=Please enter a nsUri +Enter_a_prefix=Enter a prefix : +ETypedElementSelectionControl_FlatView=Flat +ETypedElementSelectionControl_invalidSelection=The selection contains invalid elements +ETypedElementSelectionControl_invalidSelectionAtLeastOneElement=You must select at least 1 element +ETypedElementSelectionControl_invalidSelectionAtMostXElements=You must select at most {0} elements +ETypedElementSelectionControl_invalidSelectionETypedElementsOnly=Only ETypedElements can be selected +ETypedElementSelectionDialog_dialogTitle=Select ETypedElement +ETypedElementSelectionDialog_dialogTitleMultiSelection=Select ETypedElements +ETypedElementSelectionDialog_radioButtonMultiSelection=ETypedElements selected below: +ETypedElementSelectionDialog_radioButtonNoSelection=No selection +ETypedElementSelectionDialog_radioButtonSingleSelection=ETypedElement selected below: +ETypedElementSelectionSortedControl_groupByMetamodelView=Grouped By Metamodel +ETypedElementSelectionSortedControl_toolTip=Display available ETypedElement sorted by extended metamodels +Please_enter_prefix=Please enter a prefix +Please_select_EPackage=Please, select an EPackage +Add_an_Attribute=Add an attribute +Add_an_Attribute_desc=Add a new attribute to the selected facet +Attribute_name=Attribute name: +Operation=Operation : +Facet=Facet : +FacetSet=FacetSet : +FacetSetsCatalogView_categoriesColumn=Categories +FacetSetsCatalogView_documentationColumn=Documentation +FacetSetsCatalogView_extendsColumn=Extends +FacetSetsCatalogView_nameColumn=Name +FacetSetsCatalogView_viewTitle=Facet Sets +FacetSetSelectionControl_mustSelectAtLeastOneElement=You must select at least 1 element +FacetSetSelectionControl_mustSelectAtMostNElements=You must select at most {0} elements +FacetSetSelectionControl_onlyFacetSetsAllowedInSelection=Only FacetSets can be selected +FacetSetSelectionControl_selectionContainsInvalidElements=The selection contains invalid elements +FacetSetSelectionDialog_deselectAll=Deselect All +FacetSetSelectionDialog_selectAll=Select All +FacetSetSelectionDialog_titleSelectFacetSet=Select FacetSet +FacetSetSelectionDialog_titleSelectFacetSets=Select FacetSets +Lower_bound=Lower Bound : +Upper_bound=Upper Bound : +Add_a_Reference=Add a reference +Add_an_Operation=Add an Operation +Add_an_Operation_desc=Add a new operation to the selected facet +Add_an_Operation_Parameter=Add an Operation Parameter +Add_an_Operation_Parameter_desc=Add a new operation's parameter to the selected operation +Operation_name=Operation Name: +Parameter_name=Parameter Name: +Add_a_Reference_desc=Add a reference to the selected facet +Create_FacetSet_Model=Create FacetSet Model +CreateFacetInFacetSetWizardPage_could_not_find_wizard_page=Could not find the wizard for this query type +Create_facet_in_facetSet=Create a Facet in a FacetSet +Please_enter_value_for=Please enter a value for {0} +CreateFacetInFacetSetWizardPage_Please_fill_extendedMetaClass=Please fill the extendedMetaClass field +CreateFacetInFacetSetWizardPage_Sub_Typing_Facet=SubTyping Facet +CreateFacetInFacetSetWizardPage_wizard_description=This wizard creates a new facet in a facetSet. +CreateFacetSetWizardImpl_Create_new_facet_Set=Create a new Facet Set +CreateFacetSetWizardImpl_FacetModel=Facet Set +CreateFacetSetWizardImpl_File_extension_restriction=File extension has to be ".efacet" +CreateFacetSetWizardPage_Not_a_Plugin_project=Warning : you are creating this FacetSet in a non-Plugin project. It will not be available until moved to a Plugin project. +Create_Query=Create Query: +FilteredElementSelectionControl_type_filter_text=type filter text +Load_MetaModel_Resource=Load Meta-model Resource +FacetSetSelectionDialog_selectFacetSetsMessage=Choose FacetSets: +FacetSetSelectionDialog_selectFacetSetsTitle=Select FacetSets +Package_Selection=Package Selection +Select_Registered_URI=&Select a registered package URI: +Select_EClass=Select an EClass +Select_EClassifier=Select an EClassifier +Select_EDataType=Select an EDataType +Select_EPackage=Select an EPackage +Select=Select +Type=Type : +ExtendedMetaClass=&Extended Meta-Class: +SelectQueryTypeWizardPage_No_wizard_found=No wizard page extension was found for the selected query type. Wizard pages have to be registered using queryFactoryWizardPageRegistration extension point +SelectQueryTypeWizardPage_Query_Type=Query Type : +JavaQueryWizardPage_Can_be_cached=Can be cached : +JavaQueryWizardPage_has_side_effect=Has side effect : +JavaQueryWizardPage_Query_name=Query name : +No_result_found=No result found +Reference_name=Reference name: + +#### Begin: copied from /org.eclipse.papyrus.emf.facet.infra.query.ui/src/org/eclipse/emf/facet/infra/query/ui/messages.properties +QueryExecutionView_0=Missing bundle... +QueryExecutionView_1=To execute the query, the depending bundle {0} must be installed. It will not be hot loaded. +QueryExecutionView_classpathWarning=The output location of the Java project "{0}" was not found in its Bundle-ClassPath. This prevents the Java queries implementations it contains from being loaded. +QueryExecutionView_errorInBundleClasspath=Error in Bundle-ClassPath +QueryExecutionView_execEnvNotAvailable=Execution environment not available +QueryExecutionView_execEnvError=To execute the query the execution environment {0} is required but not available. The available execution environments are: {1} +QueryExecutionView_Context=Context +QueryExecutionView_DisplayResultIn=Display result in: +QueryExecutionView_dragAndDropHint=drag&drop model elements here +QueryExecutionView_ErrorExecutingQuery=Error executing query +QueryExecutionView_ETypedElementsGroup=ETypedElements +QueryExecutionView_ExecuteButton=E&xecute +QueryExecutionView_ExecuteGroup=Execute +QueryExecutionView_NoQueryDisplayer=No Query Displayer +QueryExecutionView_NoQuerySelected=No query +QueryExecutionView_notImplementedYet=<Not implemented yet> +QueryExecutionView_NullQueryResult=Null query result +QueryExecutionView_Parameters=Parameters +QueryExecutionView_Query=Query +QueryExecutionView_QueryException=Query exception +QueryExecutionView_QueryReturnedNull=Query returned a null result (see error log) +QueryExecutionView_SelectQueryToExecute=You must select a query to execute #### End: copied from /org.eclipse.papyrus.emf.facet.infra.query.ui/src/org/eclipse/emf/facet/infra/query/ui/messages.properties
\ No newline at end of file diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/preferences/PreferenceConstants.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/preferences/PreferenceConstants.java index 0e822f562e5..71abb5698ae 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/preferences/PreferenceConstants.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/preferences/PreferenceConstants.java @@ -1,22 +1,22 @@ -/**
- * 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:
- * Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets
- * Gregoire Dupe (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.preferences;
-
-public final class PreferenceConstants {
-
- public static final String TE_SELECTION_TAB = "ETypedElementSelectionDialogPreferedTab"; //$NON-NLS-1$
-
- private PreferenceConstants() {
- // nothing to do
- }
-}
+/** + * 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: + * Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets + * Gregoire Dupe (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.preferences; + +public final class PreferenceConstants { + + public static final String TE_SELECTION_TAB = "ETypedElementSelectionDialogPreferedTab"; //$NON-NLS-1$ + + private PreferenceConstants() { + // nothing to do + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/preferences/PreferencesInitializer.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/preferences/PreferencesInitializer.java index adeaf4fe014..cb7fb0d49ab 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/preferences/PreferencesInitializer.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/preferences/PreferencesInitializer.java @@ -1,27 +1,27 @@ -/**
- * 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:
- * Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.preferences;
-
-import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget.ETypedElementSelectionControl;
-
-public class PreferencesInitializer extends AbstractPreferenceInitializer {
-
- @Override
- public void initializeDefaultPreferences() {
- IPreferenceStore store = Activator.getDefault().getPreferenceStore();
- store.setDefault(PreferenceConstants.TE_SELECTION_TAB, ETypedElementSelectionControl.TAB_ID);
- }
-
-}
+/** + * 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: + * Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.preferences; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget.ETypedElementSelectionControl; + +public class PreferencesInitializer extends AbstractPreferenceInitializer { + + @Override + public void initializeDefaultPreferences() { + IPreferenceStore store = Activator.getDefault().getPreferenceStore(); + store.setDefault(PreferenceConstants.TE_SELECTION_TAB, ETypedElementSelectionControl.TAB_ID); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/utils/ImageProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/utils/ImageProvider.java index d0238ee2636..905dcde8452 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/utils/ImageProvider.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/utils/ImageProvider.java @@ -1,96 +1,96 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- * Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.utils;
-
-import java.net.URL;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.swt.graphics.Image;
-
-public class ImageProvider {
-
- private static ImageProvider instance;
-
- public static ImageProvider getInstance() {
- if (ImageProvider.instance == null) {
- ImageProvider.instance = new ImageProvider();
- }
- return ImageProvider.instance;
- }
-
- private static final String QUERY_SET_ICON_PATH = "/icons/querySet.gif"; //$NON-NLS-1$
- private static final String FACET_ICON_PATH = "/icons/facet.gif"; //$NON-NLS-1$
- private static final String FLAT_VIEW_ICON_PATH = "/icons/flatView.gif"; //$NON-NLS-1$
- private static final String TREE_VIEW_ICON_PATH = "/icons/treeView.gif"; //$NON-NLS-1$
-
- private Image facetIcon;
- private Image queryIcon;
- private Image flatViewIcon;
- private Image treeViewIcon;
-
- /**
- * Create an image descriptor from a resource
- *
- * @param resourcePath
- * the path of the resource (in the bundle)
- * @return the image descriptor
- */
- private static ImageDescriptor createImageDescriptor(final String resourcePath) {
- final URL url = Activator.getDefault().getBundle().getResource(resourcePath);
- if (url == null) {
- Logger.logError(NLS.bind("Resource not found: {0}", //$NON-NLS-1$
- resourcePath), Activator.getDefault());
- return ImageDescriptor.getMissingImageDescriptor();
- }
- return ImageDescriptor.createFromURL(url);
- }
-
- /** Return the icon representing a query */
- public Image getFacetIcon() {
- if (this.facetIcon == null) {
- this.facetIcon = createImageDescriptor(ImageProvider.FACET_ICON_PATH).createImage();
- }
- return this.facetIcon;
- }
-
- /** Return the descriptor representing a query */
- public static ImageDescriptor getFacetIconDescriptor() {
- return createImageDescriptor(ImageProvider.FACET_ICON_PATH);
- }
-
- /** Return the icon representing a querySet */
- public Image getQuerySetIcon() {
- if (this.queryIcon == null) {
- this.queryIcon = createImageDescriptor(ImageProvider.QUERY_SET_ICON_PATH).createImage();
- }
- return this.queryIcon;
- }
-
- public Image getFlatViewIcon() {
- if (this.flatViewIcon == null) {
- this.flatViewIcon = createImageDescriptor(ImageProvider.FLAT_VIEW_ICON_PATH).createImage();
- }
- return this.flatViewIcon;
- }
-
- public Image getTreeViewIcon() {
- if (this.treeViewIcon == null) {
- this.treeViewIcon = createImageDescriptor(ImageProvider.TREE_VIEW_ICON_PATH).createImage();
- }
- return this.treeViewIcon;
- }
-
-}
+/** + * 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 349546 - EMF Facet facetSet editor + * Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.utils; + +import java.net.URL; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.osgi.util.NLS; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.swt.graphics.Image; + +public class ImageProvider { + + private static ImageProvider instance; + + public static ImageProvider getInstance() { + if (ImageProvider.instance == null) { + ImageProvider.instance = new ImageProvider(); + } + return ImageProvider.instance; + } + + private static final String QUERY_SET_ICON_PATH = "/icons/querySet.gif"; //$NON-NLS-1$ + private static final String FACET_ICON_PATH = "/icons/facet.gif"; //$NON-NLS-1$ + private static final String FLAT_VIEW_ICON_PATH = "/icons/flatView.gif"; //$NON-NLS-1$ + private static final String TREE_VIEW_ICON_PATH = "/icons/treeView.gif"; //$NON-NLS-1$ + + private Image facetIcon; + private Image queryIcon; + private Image flatViewIcon; + private Image treeViewIcon; + + /** + * Create an image descriptor from a resource + * + * @param resourcePath + * the path of the resource (in the bundle) + * @return the image descriptor + */ + private static ImageDescriptor createImageDescriptor(final String resourcePath) { + final URL url = Activator.getDefault().getBundle().getResource(resourcePath); + if (url == null) { + Logger.logError(NLS.bind("Resource not found: {0}", //$NON-NLS-1$ + resourcePath), Activator.getDefault()); + return ImageDescriptor.getMissingImageDescriptor(); + } + return ImageDescriptor.createFromURL(url); + } + + /** Return the icon representing a query */ + public Image getFacetIcon() { + if (this.facetIcon == null) { + this.facetIcon = createImageDescriptor(ImageProvider.FACET_ICON_PATH).createImage(); + } + return this.facetIcon; + } + + /** Return the descriptor representing a query */ + public static ImageDescriptor getFacetIconDescriptor() { + return createImageDescriptor(ImageProvider.FACET_ICON_PATH); + } + + /** Return the icon representing a querySet */ + public Image getQuerySetIcon() { + if (this.queryIcon == null) { + this.queryIcon = createImageDescriptor(ImageProvider.QUERY_SET_ICON_PATH).createImage(); + } + return this.queryIcon; + } + + public Image getFlatViewIcon() { + if (this.flatViewIcon == null) { + this.flatViewIcon = createImageDescriptor(ImageProvider.FLAT_VIEW_ICON_PATH).createImage(); + } + return this.flatViewIcon; + } + + public Image getTreeViewIcon() { + if (this.treeViewIcon == null) { + this.treeViewIcon = createImageDescriptor(ImageProvider.TREE_VIEW_ICON_PATH).createImage(); + } + return this.treeViewIcon; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/ContextPaneMenuManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/ContextPaneMenuManager.java index 8e78f6b543e..268a6b95f28 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/ContextPaneMenuManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/ContextPaneMenuManager.java @@ -1,94 +1,94 @@ -/*******************************************************************************
- * Copyright (c) 2010, 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)
- * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.view;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.ImageProvider;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.view.NavigationView.ContextInfo;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-
-@SuppressWarnings("synthetic-access")
-// Copied from org.eclipse.papyrus.emf.facet.infra.query.ui.views.queryExecution.internal.ContextPaneMenuManager
-public class ContextPaneMenuManager extends MenuManager implements IMenuListener {
-
- private final EditableContext context;
- private final NavigationView queryExecutionView;
-
- public ContextPaneMenuManager(final NavigationView queryExecutionView,
- final EditableContext context, final TreeViewer treeViewer) {
- this.queryExecutionView = queryExecutionView;
- this.context = context;
- addMenuActions();
- addMenuListener(this);
- addKeyShortcuts(treeViewer);
- }
-
- private void addKeyShortcuts(final TreeViewer treeViewer) {
- treeViewer.getTree().addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(final KeyEvent e) {
- if (e.keyCode == SWT.DEL) {
- ContextPaneMenuManager.this.removeSelectedElementsAction.run();
- }
- }
- });
- }
-
- private void addMenuActions() {
- this.add(this.removeSelectedElementsAction);
- this.add(this.removeAllAction);
- }
-
- /** This action removes all model elements from the context */
- private final IAction removeAllAction = new Action("Remove all") {
- {
- setImageDescriptor(ImageProvider.getInstance().getRemoveAllImageDescriptor());
- }
-
- @Override
- public void run() {
- ContextPaneMenuManager.this.context.clear();
- ContextPaneMenuManager.this.context.done();
- }
- };
-
- /** This action removes selected model elements from the context */
- private final IAction removeSelectedElementsAction = new Action("Remove") {
- {
- setImageDescriptor(ImageProvider.getInstance().getRemoveImageDescriptor());
- }
-
- @Override
- public void run() {
- ContextInfo contextInfo = ContextPaneMenuManager.this.queryExecutionView
- .getContextInfo();
- for (EObject eObject : contextInfo.getSelectedEObjects()) {
- ContextPaneMenuManager.this.context.remove(eObject);
- }
- ContextPaneMenuManager.this.context.done();
- }
- };
-
- public void menuAboutToShow(final IMenuManager manager) {
- ContextInfo contextInfo = ContextPaneMenuManager.this.queryExecutionView.getContextInfo();
- this.removeAllAction.setEnabled(contextInfo.getEObjects().size() > 0);
- this.removeSelectedElementsAction.setEnabled(contextInfo.getSelectedEObjects().size() > 0);
- }
+/******************************************************************************* + * Copyright (c) 2010, 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) + * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet. + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.view; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IMenuListener; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.ImageProvider; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.view.NavigationView.ContextInfo; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; + +@SuppressWarnings("synthetic-access") +// Copied from org.eclipse.papyrus.emf.facet.infra.query.ui.views.queryExecution.internal.ContextPaneMenuManager +public class ContextPaneMenuManager extends MenuManager implements IMenuListener { + + private final EditableContext context; + private final NavigationView queryExecutionView; + + public ContextPaneMenuManager(final NavigationView queryExecutionView, + final EditableContext context, final TreeViewer treeViewer) { + this.queryExecutionView = queryExecutionView; + this.context = context; + addMenuActions(); + addMenuListener(this); + addKeyShortcuts(treeViewer); + } + + private void addKeyShortcuts(final TreeViewer treeViewer) { + treeViewer.getTree().addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(final KeyEvent e) { + if (e.keyCode == SWT.DEL) { + ContextPaneMenuManager.this.removeSelectedElementsAction.run(); + } + } + }); + } + + private void addMenuActions() { + this.add(this.removeSelectedElementsAction); + this.add(this.removeAllAction); + } + + /** This action removes all model elements from the context */ + private final IAction removeAllAction = new Action("Remove all") { + { + setImageDescriptor(ImageProvider.getInstance().getRemoveAllImageDescriptor()); + } + + @Override + public void run() { + ContextPaneMenuManager.this.context.clear(); + ContextPaneMenuManager.this.context.done(); + } + }; + + /** This action removes selected model elements from the context */ + private final IAction removeSelectedElementsAction = new Action("Remove") { + { + setImageDescriptor(ImageProvider.getInstance().getRemoveImageDescriptor()); + } + + @Override + public void run() { + ContextInfo contextInfo = ContextPaneMenuManager.this.queryExecutionView + .getContextInfo(); + for (EObject eObject : contextInfo.getSelectedEObjects()) { + ContextPaneMenuManager.this.context.remove(eObject); + } + ContextPaneMenuManager.this.context.done(); + } + }; + + public void menuAboutToShow(final IMenuManager manager) { + ContextInfo contextInfo = ContextPaneMenuManager.this.queryExecutionView.getContextInfo(); + this.removeAllAction.setEnabled(contextInfo.getEObjects().size() > 0); + this.removeSelectedElementsAction.setEnabled(contextInfo.getSelectedEObjects().size() > 0); + } }
\ No newline at end of file diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/DropAdapter.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/DropAdapter.java index 9c60e5e846b..2ba2259b3cd 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/DropAdapter.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/DropAdapter.java @@ -1,92 +1,92 @@ -/*******************************************************************************
- * Copyright (c) 2010, 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)
- * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.view;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.edit.ui.dnd.LocalTransfer;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.DropTargetListener;
-
-/**
- * Implements a {@link DropTargetListener} that accepts {@link EObject}s
- * transferred locally (i.e. through {@link LocalTransfer}), and calls the given {@link DropAction} with the dropped {@link EObject}s.
- */
-// Copied from org.eclipse.papyrus.emf.facet.infra.query.ui.views.queryExecution.internal.DropAdapter
-public class DropAdapter implements DropTargetListener {
-
- private final DropAction dropAction;
-
- public abstract static class DropAction {
- /** The given EObjects are being dropped */
- public abstract void dropped(Set<EObject> eObjects);
- }
-
- /**
- * @param dropAction
- * the action that will be called when model elements are dropped
- */
- public DropAdapter(final DropAction dropAction) {
- this.dropAction = dropAction;
- }
-
- public void drop(final DropTargetEvent event) {
- this.dropAction.dropped(getTransferredEObjects(event));
- }
-
- private Set<EObject> getTransferredEObjects(final DropTargetEvent event) {
- Set<EObject> eObjects = new HashSet<EObject>();
- if (LocalTransfer.getInstance().isSupportedType(event.currentDataType)) {
- if (event.data instanceof StructuredSelection) {
- StructuredSelection structuredSelection = (StructuredSelection) event.data;
- Iterator<?> iterator = structuredSelection.iterator();
- while (iterator.hasNext()) {
- Object element = iterator.next();
- if (element instanceof EObject) {
- EObject eObject = (EObject) element;
- eObjects.add(eObject);
- }
- }
- }
- }
- return eObjects;
- }
-
- public void dropAccept(final DropTargetEvent event) {
- // nothing
- }
-
- public void dragOver(final DropTargetEvent event) {
- // if (getTransferredEObjects(event).size() == 0) {
- // // don't allow the drop
- // event.detail = DND.DROP_NONE;
- // }
- // event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL;
- }
-
- public void dragOperationChanged(final DropTargetEvent event) {
- // nothing
- }
-
- public void dragLeave(final DropTargetEvent event) {
- // nothing
- }
-
- public void dragEnter(final DropTargetEvent event) {
- event.detail = DND.DROP_LINK;
- }
+/******************************************************************************* + * Copyright (c) 2010, 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) + * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet. + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.view; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.edit.ui.dnd.LocalTransfer; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.dnd.DND; +import org.eclipse.swt.dnd.DropTargetEvent; +import org.eclipse.swt.dnd.DropTargetListener; + +/** + * Implements a {@link DropTargetListener} that accepts {@link EObject}s + * transferred locally (i.e. through {@link LocalTransfer}), and calls the given {@link DropAction} with the dropped {@link EObject}s. + */ +// Copied from org.eclipse.papyrus.emf.facet.infra.query.ui.views.queryExecution.internal.DropAdapter +public class DropAdapter implements DropTargetListener { + + private final DropAction dropAction; + + public abstract static class DropAction { + /** The given EObjects are being dropped */ + public abstract void dropped(Set<EObject> eObjects); + } + + /** + * @param dropAction + * the action that will be called when model elements are dropped + */ + public DropAdapter(final DropAction dropAction) { + this.dropAction = dropAction; + } + + public void drop(final DropTargetEvent event) { + this.dropAction.dropped(getTransferredEObjects(event)); + } + + private Set<EObject> getTransferredEObjects(final DropTargetEvent event) { + Set<EObject> eObjects = new HashSet<EObject>(); + if (LocalTransfer.getInstance().isSupportedType(event.currentDataType)) { + if (event.data instanceof StructuredSelection) { + StructuredSelection structuredSelection = (StructuredSelection) event.data; + Iterator<?> iterator = structuredSelection.iterator(); + while (iterator.hasNext()) { + Object element = iterator.next(); + if (element instanceof EObject) { + EObject eObject = (EObject) element; + eObjects.add(eObject); + } + } + } + } + return eObjects; + } + + public void dropAccept(final DropTargetEvent event) { + // nothing + } + + public void dragOver(final DropTargetEvent event) { + // if (getTransferredEObjects(event).size() == 0) { + // // don't allow the drop + // event.detail = DND.DROP_NONE; + // } + // event.feedback = DND.FEEDBACK_SELECT | DND.FEEDBACK_SCROLL; + } + + public void dragOperationChanged(final DropTargetEvent event) { + // nothing + } + + public void dragLeave(final DropTargetEvent event) { + // nothing + } + + public void dragEnter(final DropTargetEvent event) { + event.detail = DND.DROP_LINK; + } }
\ No newline at end of file diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/EditableContext.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/EditableContext.java index 322b3769458..fbefa4e8134 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/EditableContext.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/EditableContext.java @@ -1,27 +1,27 @@ -/*******************************************************************************
- * Copyright (c) 2010, 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)
- * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.view;
-
-import org.eclipse.emf.ecore.EObject;
-
-/** An interface that supports editing the query context */
-// Copied from org.eclipse.papyrus.emf.facet.infra.query.ui.views.queryExecution.internal.EditableContext
-public interface EditableContext {
- void add(EObject eObject);
-
- void remove(EObject eObject);
-
- void clear();
-
- /** must be called after editing to refresh the viewers */
- void done();
-}
+/******************************************************************************* + * Copyright (c) 2010, 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) + * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet. + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.view; + +import org.eclipse.emf.ecore.EObject; + +/** An interface that supports editing the query context */ +// Copied from org.eclipse.papyrus.emf.facet.infra.query.ui.views.queryExecution.internal.EditableContext +public interface EditableContext { + void add(EObject eObject); + + void remove(EObject eObject); + + void clear(); + + /** must be called after editing to refresh the viewers */ + void done(); +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/FacetSetsCatalogView.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/FacetSetsCatalogView.java index 7b1afef33ca..a349af6a971 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/FacetSetsCatalogView.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/FacetSetsCatalogView.java @@ -1,211 +1,211 @@ -/*******************************************************************************
- * Copyright (c) 2009-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) - initial API and implementation
- * Grégoire Dupé (Mia-Software) - initial API and implementation
- * Nicolas Bros (Mia-Software) - Bug 372732 - [Facet] Rewrite the catalog views for 0.2
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- *******************************************************************************/
-
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.view;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IExecutableExtensionFactory;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.papyrus.emf.facet.common.ui.internal.exported.views.IColumnDescription;
-import org.eclipse.papyrus.emf.facet.common.ui.internal.exported.views.IElementsViewFactory;
-import org.eclipse.papyrus.emf.facet.efacet.core.FacetUtils;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetSetCatalogManagerFactory;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Category;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DocumentedElement;
-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.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs.FacetSetTreeContentProvider;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.utils.ImageProvider;
-import org.eclipse.papyrus.emf.facet.util.emf.ui.internal.utils.ImageUtils;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * An Eclipse view that displays a list of available facet sets. Clicking on a facet set opens it in the facet set
- * editor.
- */
-public class FacetSetsCatalogView implements IExecutableExtensionFactory, IOpenListener {
-
- public Object create() throws CoreException {
- final Collection<IColumnDescription> columnDescriptions = new ArrayList<IColumnDescription>();
- columnDescriptions.add(createNameColumnDescription());
- columnDescriptions.add(createExtendsColumnDescription());
- columnDescriptions.add(createCategoriesColumnDescription());
- columnDescriptions.add(createDocumentationColumnDescription());
- return IElementsViewFactory.DEFAULT.createElementsView(columnDescriptions, getContentProvider(), getInput(),
- Messages.FacetSetsCatalogView_viewTitle, ImageProvider.getInstance().getFacetIcon(), this);
- }
-
- private static final String NAME_COLUMN = "FacetView_NameColumn"; //$NON-NLS-1$
- private static final String DOCUMENTATION_COLUMN = "FacetView_LocationColumn"; //$NON-NLS-1$
- private static final String CATEGORIES_COLUMN = "FacetView_DefaultColumn"; //$NON-NLS-1$
- private static final String EXTENDS_COLUMN = "FacetView_ExtendsColumn"; //$NON-NLS-1$
-
- private static final int NAME_COLUMN_WIDTH = 300;
- private static final int EXTENDS_COLUMN_WIDTH = 200;
- private static final int CATEGORIES_COLUMN_WIDTH = 200;
- private static final int DOCUMENTATION_COLUMN_WIDTH = 400;
-
- private static IColumnDescription createNameColumnDescription() {
- final ColumnLabelProvider columnLabelProvider = new ColumnLabelProvider() {
- @Override
- public String getText(final Object element) {
- if (element instanceof FacetSet) {
- final FacetSet facetSet = (FacetSet) element;
- return facetSet.getName();
- } else if (element instanceof Facet) {
- final Facet facet = (Facet) element;
- return facet.getName();
- } else if (element instanceof EStructuralFeature) {
- final EStructuralFeature feature = (EStructuralFeature) element;
- return feature.getName();
- } else {
- return ""; //$NON-NLS-1$
- }
-
- }
-
- @Override
- public Image getImage(final Object element) {
- return ImageUtils.getImage(element);
- }
- };
- return IElementsViewFactory.DEFAULT.createColumnDescription(Messages.FacetSetsCatalogView_nameColumn, FacetSetsCatalogView.NAME_COLUMN, FacetSetsCatalogView.NAME_COLUMN_WIDTH,
- columnLabelProvider);
- }
-
- private static IColumnDescription createExtendsColumnDescription() {
- final ColumnLabelProvider columnLabelProvider = new ColumnLabelProvider() {
- @Override
- public String getText(final Object element) {
- String result = null;
- if (element instanceof FacetSet) {
- final FacetSet facetSet = (FacetSet) element;
- final EPackage extendedEPackage = FacetUtils
- .getExtendedEPackage(facetSet);
- if (extendedEPackage != null) {
- result = extendedEPackage.getName() + " " + extendedEPackage.getNsURI(); //$NON-NLS-1$
- }
- }
- return result;
- }
-
- };
- return IElementsViewFactory.DEFAULT.createColumnDescription(Messages.FacetSetsCatalogView_extendsColumn, FacetSetsCatalogView.EXTENDS_COLUMN, FacetSetsCatalogView.EXTENDS_COLUMN_WIDTH,
- columnLabelProvider);
-
- }
-
- private static IColumnDescription createCategoriesColumnDescription() {
- final ColumnLabelProvider columnLabelProvider = new ColumnLabelProvider() {
- @Override
- public String getText(final Object element) {
- String result = null;
- if (element instanceof FacetSet) {
- final FacetSet facetSet = (FacetSet) element;
- final StringBuilder strCategories = new StringBuilder();
- final EList<Category> categories = facetSet.getCategories();
- for (final Category category : categories) {
- if (strCategories.length() > 0) {
- strCategories.append("; "); //$NON-NLS-1$
- }
- strCategories.append(category.getName());
- }
- result = strCategories.toString();
- }
- return result;
- }
- };
- return IElementsViewFactory.DEFAULT.createColumnDescription(Messages.FacetSetsCatalogView_categoriesColumn, FacetSetsCatalogView.CATEGORIES_COLUMN, FacetSetsCatalogView.CATEGORIES_COLUMN_WIDTH,
- columnLabelProvider);
- }
-
- private static IColumnDescription createDocumentationColumnDescription() {
- final ColumnLabelProvider columnLabelProvider = new ColumnLabelProvider() {
- @Override
- public String getText(final Object element) {
- String result = null;
- if (element instanceof DocumentedElement) {
- final DocumentedElement documentedElement = (DocumentedElement) element;
- result = documentedElement.getDocumentation();
- }
- return result;
- }
- };
- return IElementsViewFactory.DEFAULT.createColumnDescription(Messages.FacetSetsCatalogView_documentationColumn, FacetSetsCatalogView.DOCUMENTATION_COLUMN,
- FacetSetsCatalogView.DOCUMENTATION_COLUMN_WIDTH, columnLabelProvider);
-
- }
-
- protected static ITreeContentProvider getContentProvider() {
- return new FacetSetTreeContentProvider();
- }
-
- public void open(final OpenEvent event) {
- // TODO: re-enable when there is a FacetSet editor
-
- // final EObject modelElement = (EObject) element;
- // EPackage facetSet = null;
- // if (modelElement instanceof FacetSet) {
- // facetSet = (FacetSet) modelElement;
- // } else if (modelElement instanceof Facet) {
- // Facet facet = (Facet) modelElement;
- // facetSet = facet.getEPackage();
- // }
- // if (facetSet != null) {
- // // open facet set in editor
- // URI uri = null;
- // try {
- // String uriString = FacetSetCatalog.getSingleton().getURI(facetSet.getName())
- // .toString();
- // uri = URI.create(uriString);
- // IEditorPart editor = null;
- // if ("file".equals(uri.getScheme())) { //$NON-NLS-1$
- // editor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- // .getActivePage(), new URI(facetSet.eResource().getURI().toString()),
- // Activator.FACET_EDITOR_ID, true);
- // } else {
- // URIEditorInput uriEditorInput = new URIEditorInput(
- // org.eclipse.emf.common.util.URI.createURI(uri.toString()));
- // editor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- // .getActivePage(), uriEditorInput, Activator.FACET_EDITOR_ID, true);
- // }
- // if (editor instanceof FacetEditor) {
- // FacetEditor facetEditor = (FacetEditor) editor;
- // facetEditor.setSelectionToViewer(modelElement);
- // }
- //
- // } catch (Exception e) {
- // Logger.logError(e, "Failed to open: " + uri, Activator.getDefault()); //$NON-NLS-1$
- // }
- // }
- }
-
- protected static Object getInput() {
- return IFacetSetCatalogManagerFactory.DEFAULT
- .getOrCreateFacetSetCatalogManager(new ResourceSetImpl())
- .getRegisteredFacetSets().toArray();
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2009-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) - initial API and implementation + * Grégoire Dupé (Mia-Software) - initial API and implementation + * Nicolas Bros (Mia-Software) - Bug 372732 - [Facet] Rewrite the catalog views for 0.2 + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + *******************************************************************************/ + +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.view; + +import java.util.ArrayList; +import java.util.Collection; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IExecutableExtensionFactory; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.jface.viewers.ColumnLabelProvider; +import org.eclipse.jface.viewers.IOpenListener; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.OpenEvent; +import org.eclipse.papyrus.emf.facet.common.ui.internal.exported.views.IColumnDescription; +import org.eclipse.papyrus.emf.facet.common.ui.internal.exported.views.IElementsViewFactory; +import org.eclipse.papyrus.emf.facet.efacet.core.FacetUtils; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetSetCatalogManagerFactory; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.Category; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.DocumentedElement; +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.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs.FacetSetTreeContentProvider; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.utils.ImageProvider; +import org.eclipse.papyrus.emf.facet.util.emf.ui.internal.utils.ImageUtils; +import org.eclipse.swt.graphics.Image; + +/** + * An Eclipse view that displays a list of available facet sets. Clicking on a facet set opens it in the facet set + * editor. + */ +public class FacetSetsCatalogView implements IExecutableExtensionFactory, IOpenListener { + + public Object create() throws CoreException { + final Collection<IColumnDescription> columnDescriptions = new ArrayList<IColumnDescription>(); + columnDescriptions.add(createNameColumnDescription()); + columnDescriptions.add(createExtendsColumnDescription()); + columnDescriptions.add(createCategoriesColumnDescription()); + columnDescriptions.add(createDocumentationColumnDescription()); + return IElementsViewFactory.DEFAULT.createElementsView(columnDescriptions, getContentProvider(), getInput(), + Messages.FacetSetsCatalogView_viewTitle, ImageProvider.getInstance().getFacetIcon(), this); + } + + private static final String NAME_COLUMN = "FacetView_NameColumn"; //$NON-NLS-1$ + private static final String DOCUMENTATION_COLUMN = "FacetView_LocationColumn"; //$NON-NLS-1$ + private static final String CATEGORIES_COLUMN = "FacetView_DefaultColumn"; //$NON-NLS-1$ + private static final String EXTENDS_COLUMN = "FacetView_ExtendsColumn"; //$NON-NLS-1$ + + private static final int NAME_COLUMN_WIDTH = 300; + private static final int EXTENDS_COLUMN_WIDTH = 200; + private static final int CATEGORIES_COLUMN_WIDTH = 200; + private static final int DOCUMENTATION_COLUMN_WIDTH = 400; + + private static IColumnDescription createNameColumnDescription() { + final ColumnLabelProvider columnLabelProvider = new ColumnLabelProvider() { + @Override + public String getText(final Object element) { + if (element instanceof FacetSet) { + final FacetSet facetSet = (FacetSet) element; + return facetSet.getName(); + } else if (element instanceof Facet) { + final Facet facet = (Facet) element; + return facet.getName(); + } else if (element instanceof EStructuralFeature) { + final EStructuralFeature feature = (EStructuralFeature) element; + return feature.getName(); + } else { + return ""; //$NON-NLS-1$ + } + + } + + @Override + public Image getImage(final Object element) { + return ImageUtils.getImage(element); + } + }; + return IElementsViewFactory.DEFAULT.createColumnDescription(Messages.FacetSetsCatalogView_nameColumn, FacetSetsCatalogView.NAME_COLUMN, FacetSetsCatalogView.NAME_COLUMN_WIDTH, + columnLabelProvider); + } + + private static IColumnDescription createExtendsColumnDescription() { + final ColumnLabelProvider columnLabelProvider = new ColumnLabelProvider() { + @Override + public String getText(final Object element) { + String result = null; + if (element instanceof FacetSet) { + final FacetSet facetSet = (FacetSet) element; + final EPackage extendedEPackage = FacetUtils + .getExtendedEPackage(facetSet); + if (extendedEPackage != null) { + result = extendedEPackage.getName() + " " + extendedEPackage.getNsURI(); //$NON-NLS-1$ + } + } + return result; + } + + }; + return IElementsViewFactory.DEFAULT.createColumnDescription(Messages.FacetSetsCatalogView_extendsColumn, FacetSetsCatalogView.EXTENDS_COLUMN, FacetSetsCatalogView.EXTENDS_COLUMN_WIDTH, + columnLabelProvider); + + } + + private static IColumnDescription createCategoriesColumnDescription() { + final ColumnLabelProvider columnLabelProvider = new ColumnLabelProvider() { + @Override + public String getText(final Object element) { + String result = null; + if (element instanceof FacetSet) { + final FacetSet facetSet = (FacetSet) element; + final StringBuilder strCategories = new StringBuilder(); + final EList<Category> categories = facetSet.getCategories(); + for (final Category category : categories) { + if (strCategories.length() > 0) { + strCategories.append("; "); //$NON-NLS-1$ + } + strCategories.append(category.getName()); + } + result = strCategories.toString(); + } + return result; + } + }; + return IElementsViewFactory.DEFAULT.createColumnDescription(Messages.FacetSetsCatalogView_categoriesColumn, FacetSetsCatalogView.CATEGORIES_COLUMN, FacetSetsCatalogView.CATEGORIES_COLUMN_WIDTH, + columnLabelProvider); + } + + private static IColumnDescription createDocumentationColumnDescription() { + final ColumnLabelProvider columnLabelProvider = new ColumnLabelProvider() { + @Override + public String getText(final Object element) { + String result = null; + if (element instanceof DocumentedElement) { + final DocumentedElement documentedElement = (DocumentedElement) element; + result = documentedElement.getDocumentation(); + } + return result; + } + }; + return IElementsViewFactory.DEFAULT.createColumnDescription(Messages.FacetSetsCatalogView_documentationColumn, FacetSetsCatalogView.DOCUMENTATION_COLUMN, + FacetSetsCatalogView.DOCUMENTATION_COLUMN_WIDTH, columnLabelProvider); + + } + + protected static ITreeContentProvider getContentProvider() { + return new FacetSetTreeContentProvider(); + } + + public void open(final OpenEvent event) { + // TODO: re-enable when there is a FacetSet editor + + // final EObject modelElement = (EObject) element; + // EPackage facetSet = null; + // if (modelElement instanceof FacetSet) { + // facetSet = (FacetSet) modelElement; + // } else if (modelElement instanceof Facet) { + // Facet facet = (Facet) modelElement; + // facetSet = facet.getEPackage(); + // } + // if (facetSet != null) { + // // open facet set in editor + // URI uri = null; + // try { + // String uriString = FacetSetCatalog.getSingleton().getURI(facetSet.getName()) + // .toString(); + // uri = URI.create(uriString); + // IEditorPart editor = null; + // if ("file".equals(uri.getScheme())) { //$NON-NLS-1$ + // editor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow() + // .getActivePage(), new URI(facetSet.eResource().getURI().toString()), + // Activator.FACET_EDITOR_ID, true); + // } else { + // URIEditorInput uriEditorInput = new URIEditorInput( + // org.eclipse.emf.common.util.URI.createURI(uri.toString())); + // editor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow() + // .getActivePage(), uriEditorInput, Activator.FACET_EDITOR_ID, true); + // } + // if (editor instanceof FacetEditor) { + // FacetEditor facetEditor = (FacetEditor) editor; + // facetEditor.setSelectionToViewer(modelElement); + // } + // + // } catch (Exception e) { + // Logger.logError(e, "Failed to open: " + uri, Activator.getDefault()); //$NON-NLS-1$ + // } + // } + } + + protected static Object getInput() { + return IFacetSetCatalogManagerFactory.DEFAULT + .getOrCreateFacetSetCatalogManager(new ResourceSetImpl()) + .getRegisteredFacetSets().toArray(); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/FacetUIUtils.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/FacetUIUtils.java index 467b04019a3..0d35e09a0e9 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/FacetUIUtils.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/FacetUIUtils.java @@ -1,109 +1,109 @@ -/*****************************************************************************
- * Copyright (c) 2016 CEA LIST and others.
- *
- * 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:
- * CEA LIST - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.view;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetSetCatalogManagerFactory;
-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.FacetSet;
-
-/**
- * @author Camille Letavernier
- *
- */
-//Moved from FacetUtils to clarify
-public class FacetUIUtils {
-
- /**
- * This methods returns all the known (registered) eTypedElements.
- *
- * @param resourceSet
- * the eTypedElement search will be done in/using this resourceSet
- * @return all the known (registered) eTypedElements
- */
- public static Set<? extends ETypedElement> getETypedElements(
- final ResourceSet resourceSet) {
- final Set<ETypedElement> result = new HashSet<ETypedElement>();
- final Collection<Object> ePackages = EPackage.Registry.INSTANCE
- .values();
- for (Object object : ePackages) {
- EPackage ePackage = null;
- if (object instanceof EPackage) {
- ePackage = (EPackage) object;
- } else if (object instanceof EPackage.Descriptor) {
- final EPackage.Descriptor descriptor = (EPackage.Descriptor) object;
- ePackage = descriptor.getEPackage();
- }
- if (ePackage != null) {
- result.addAll(getETypedElements(ePackage));
- }
- }
- result.addAll(getFacetETypedElements(resourceSet));
- return result;
- }
-
- /**
- * @since 0.3
- */
- public static Set<? extends ETypedElement> getFacetETypedElements(
- final ResourceSet resourceSet) {
- final Set<ETypedElement> result = new HashSet<ETypedElement>();
- final Collection<FacetSet> facetSets = IFacetSetCatalogManagerFactory.DEFAULT
- .getOrCreateFacetSetCatalogManager(resourceSet)
- .getRegisteredFacetSets();
- for (FacetSet facetSet : facetSets) {
- result.addAll(getETypedElements(facetSet));
- }
- return result;
- }
-
- public static List<ETypedElement> getETypedElements(final EPackage ePackage) {
- final List<ETypedElement> result = new ArrayList<ETypedElement>();
- for (EClassifier eClassifier : ePackage.getEClassifiers()) {
- result.addAll(getETypedElements(eClassifier));
- }
- for (EPackage subPackage : ePackage.getESubpackages()) {
- result.addAll(getETypedElements(subPackage));
- }
- return result;
- }
-
- /**
- * @since 0.3
- */
- public static List<ETypedElement> getETypedElements(
- final EClassifier eClassifier) {
- final List<ETypedElement> result = new ArrayList<ETypedElement>();
- if (eClassifier instanceof Facet) {
- final Facet facet = (Facet) eClassifier;
- result.addAll(facet.getFacetElements());
- result.addAll(facet.getFacetOperations());
- } else if (eClassifier instanceof EClass) {
- final EClass eClass = (EClass) eClassifier;
- result.addAll(eClass.getEAllStructuralFeatures());
- result.addAll(eClass.getEAllOperations());
- }
- return result;
- }
-
-}
+/***************************************************************************** + * Copyright (c) 2016 CEA LIST and others. + * + * 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: + * CEA LIST - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.view; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetSetCatalogManagerFactory; +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.FacetSet; + +/** + * @author Camille Letavernier + * + */ +//Moved from FacetUtils to clarify +public class FacetUIUtils { + + /** + * This methods returns all the known (registered) eTypedElements. + * + * @param resourceSet + * the eTypedElement search will be done in/using this resourceSet + * @return all the known (registered) eTypedElements + */ + public static Set<? extends ETypedElement> getETypedElements( + final ResourceSet resourceSet) { + final Set<ETypedElement> result = new HashSet<ETypedElement>(); + final Collection<Object> ePackages = EPackage.Registry.INSTANCE + .values(); + for (Object object : ePackages) { + EPackage ePackage = null; + if (object instanceof EPackage) { + ePackage = (EPackage) object; + } else if (object instanceof EPackage.Descriptor) { + final EPackage.Descriptor descriptor = (EPackage.Descriptor) object; + ePackage = descriptor.getEPackage(); + } + if (ePackage != null) { + result.addAll(getETypedElements(ePackage)); + } + } + result.addAll(getFacetETypedElements(resourceSet)); + return result; + } + + /** + * @since 0.3 + */ + public static Set<? extends ETypedElement> getFacetETypedElements( + final ResourceSet resourceSet) { + final Set<ETypedElement> result = new HashSet<ETypedElement>(); + final Collection<FacetSet> facetSets = IFacetSetCatalogManagerFactory.DEFAULT + .getOrCreateFacetSetCatalogManager(resourceSet) + .getRegisteredFacetSets(); + for (FacetSet facetSet : facetSets) { + result.addAll(getETypedElements(facetSet)); + } + return result; + } + + public static List<ETypedElement> getETypedElements(final EPackage ePackage) { + final List<ETypedElement> result = new ArrayList<ETypedElement>(); + for (EClassifier eClassifier : ePackage.getEClassifiers()) { + result.addAll(getETypedElements(eClassifier)); + } + for (EPackage subPackage : ePackage.getESubpackages()) { + result.addAll(getETypedElements(subPackage)); + } + return result; + } + + /** + * @since 0.3 + */ + public static List<ETypedElement> getETypedElements( + final EClassifier eClassifier) { + final List<ETypedElement> result = new ArrayList<ETypedElement>(); + if (eClassifier instanceof Facet) { + final Facet facet = (Facet) eClassifier; + result.addAll(facet.getFacetElements()); + result.addAll(facet.getFacetOperations()); + } else if (eClassifier instanceof EClass) { + final EClass eClass = (EClass) eClassifier; + result.addAll(eClass.getEAllStructuralFeatures()); + result.addAll(eClass.getEAllOperations()); + } + return result; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/NavigationView.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/NavigationView.java index c583bcd51a8..5d14e808888 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/NavigationView.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/NavigationView.java @@ -1,687 +1,687 @@ -/*******************************************************************************
- * Copyright (c) 2010, 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)
- * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
- * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- * 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 373510 - EditingDomain, ResourceSet, Catalogs, etc. have to be properly managed between editors and views
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
- * Olivier Remaud (Soft-Maint) - Bug 377615 - Query View filtering
- * Gregoire Dupe (Mia-Software) - Bug 378498 - Navigation view sometimes lacks an EditingDomain
- * Nicolas Bros (Mia-Software) - Bug 379395 - Navigate should replace elements
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.view;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.emf.common.command.BasicCommandStack;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-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.AdapterFactoryEditingDomain;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.domain.IEditingDomainProvider;
-import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
-import org.eclipse.emf.edit.ui.dnd.LocalTransfer;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManagerFactory;
-import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProviderFactory;
-import org.eclipse.papyrus.emf.facet.efacet.core.FacetUtils;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManagerFactory;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetSetCatalogManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetSetCatalogManagerFactory;
-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.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult;
-import org.eclipse.papyrus.emf.facet.efacet.ui.IETypedElementResultDisplayer;
-import org.eclipse.papyrus.emf.facet.efacet.ui.IETypedElementResultDisplayerOpener;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.view.INavigationView;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget.IETypedElementSelectionWidget;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget.IETypedElementSelectionWidgetFactory;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.view.DropAdapter.DropAction;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTargetListener;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.part.ViewPart;
-import org.eclipse.ui.part.WorkbenchPart;
-
-//Copied from org.eclipse.papyrus.emf.facet.infra.query.ui.views.queryExecution.internal.QueryExecutionView
-public class NavigationView extends ViewPart implements INavigationView {
-
- /**
- * Execution button minimal width.
- */
- private static final int EXEC_BT_MIN_WIDTH = 100;
-
- private TreeViewer contextViewer;
- private Composite mainComposite;
- private Composite parentComposite;
-
- private final Set<EObject> fContext = new HashSet<EObject>();
- private LayoutStyle layoutStyle = NavigationView.LayoutStyle.Horizontal;
- private IETypedElementSelectionWidget navSelection;
- private Combo comboDisplayer;
- private EditingDomain editingDomain = null;
- private ILabelProvider labelProvider;
- private final IContentProvider contextCP = new ITreeContentProvider() {
-
- public void inputChanged(final Viewer viewer, final Object oldInput,
- final Object newInput) {
- // nothing
- }
-
- public void dispose() {
- // nothing
- }
-
- public Object[] getElements(final Object inputElement) {
- Object[] result = new Object[0];
- if (inputElement instanceof Set<?>) {
- final Set<?> set = ((Set<?>) inputElement);
- if (set.isEmpty()) {
- result = new Object[] { Messages.QueryExecutionView_dragAndDropHint };
- } else {
- result = set.toArray();
- }
- }
- return result;
- }
-
- public boolean hasChildren(final Object element) {
- return false;
- }
-
- public Object getParent(final Object element) {
- return null;
- }
-
- public Object[] getChildren(final Object parentElement) {
- return new Object[] {};
- }
- };
-
- private enum LayoutStyle {
- Horizontal, Vertical
- }
-
- public NavigationView() {
- super();
- updateEditingDomain();
- }
-
- @Override
- public void createPartControl(final Composite parent) {
- this.parentComposite = parent;
- parent.setLayout(gridLayoutWithNoMargins());
- this.layoutStyle = NavigationView.LayoutStyle.Horizontal;
- createMainComposite();
- parent.addControlListener(new ControlAdapter() {
- @Override
- public void controlResized(final ControlEvent event) {
- NavigationView.this.controlResized(parent);
- }
- });
- createContextMenu();
- }
-
- public void controlResized(final Composite parent) {
- final LayoutStyle oldLayoutStyle = NavigationView.this.layoutStyle;
- final Point size = parent.getSize();
- if (size.x > size.y) {
- this.layoutStyle = NavigationView.LayoutStyle.Horizontal;
- } else {
- this.layoutStyle = NavigationView.LayoutStyle.Vertical;
- }
- if (this.layoutStyle != oldLayoutStyle) {
- createMainComposite();
- }
- }
-
- protected static void createContextMenu() {
- final MenuManager contextMenu = new MenuManager("#PopUp"); //$NON-NLS-1$
- contextMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
- }
-
- private void createMainComposite() {
- if (this.mainComposite != null) {
- this.mainComposite.dispose();
- }
- this.mainComposite = new Composite(this.parentComposite, SWT.NONE);
- this.mainComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- this.mainComposite.setLayout(gridLayoutWithNoMargins());
-
- int direction;
- if (this.layoutStyle == NavigationView.LayoutStyle.Horizontal) {
- direction = SWT.HORIZONTAL;
- } else {
- direction = SWT.VERTICAL;
- }
-
- final SashForm sashForm = new SashForm(this.mainComposite, SWT.SMOOTH
- | direction);
- sashForm.setLayout(new FillLayout());
- sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- createContextGroup(sashForm);
- // createQueryGroup(sashForm);
- final Composite lastGroup = new Composite(sashForm, SWT.NONE);
- createQueryGroup(lastGroup);
- lastGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- GridLayout gridLayout;
- if (this.layoutStyle == NavigationView.LayoutStyle.Horizontal) {
- gridLayout = new GridLayout(2, false);
- } else {
- gridLayout = new GridLayout();
- }
- gridLayout.marginHeight = 0;
- gridLayout.marginWidth = 0;
- lastGroup.setLayout(gridLayout);
- // TODO: implement parameters (hidden in the meantime)
- // /!\ when it is added back, put the QueryGroup back in the sashForm
- // instead of lastGroup
- // createParametersGroup(lastGroup);
- createExecuteGroup(lastGroup);
- }
-
- private static GridLayout gridLayoutWithNoMargins() {
- final GridLayout gridLayout = new GridLayout();
- gridLayout.marginWidth = 0;
- gridLayout.marginHeight = 0;
- return gridLayout;
- }
-
- private void createQueryGroup(final Composite parent) {
- final Group queryGroup = new Group(parent, SWT.NONE);
- queryGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- queryGroup.setText(Messages.QueryExecutionView_ETypedElementsGroup);
- final GridLayout groupLayout = new GridLayout();
- queryGroup.setLayout(groupLayout);
- final Collection<ETypedElement> eTypedElements = new ArrayList<ETypedElement>(
- FacetUIUtils.getETypedElements(getResourceSet()));
- final Collection<? extends EObject> knownEPackages = IFacetSetCatalogManagerFactory.DEFAULT
- .getOrCreateFacetSetCatalogManager(this.getResourceSet())
- .getRegisteredFacetSets();
- this.navSelection = IETypedElementSelectionWidgetFactory.DEFAULT
- .createETypedElementSelectionWidget(
- 1,
- false,
- queryGroup,
- getCustomizationManager(),
- knownEPackages);
- this.navSelection.setAvailableETypedElements(eTypedElements);
- }
-
- private void createContextGroup(final Composite parent) {
- final Group contextGroup = new Group(parent, SWT.NONE);
- contextGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- contextGroup.setText(Messages.QueryExecutionView_Context);
- final GridLayout groupLayout = new GridLayout();
- contextGroup.setLayout(groupLayout);
- createContextViewer(contextGroup);
- }
-
- private void createContextViewer(final Group contextGroup) {
- this.contextViewer = new TreeViewer(contextGroup, SWT.MULTI | SWT.BORDER);
- final GridData listData = new GridData(SWT.FILL, SWT.FILL, true, true);
- this.contextViewer.getTree().setLayoutData(listData);
- addDropSupport(this.contextViewer);
- createContextMenu(this.contextViewer);
- this.contextViewer.setContentProvider(this.contextCP);
- changeEditingDomain(this.editingDomain);
- this.contextViewer.setLabelProvider(this.labelProvider);
- this.contextViewer.setInput(this.fContext);
- this.contextViewer.setComparator(new ViewerComparator() {
- @Override
- public int compare(final Viewer viewer, final Object object1,
- final Object object2) {
- return NavigationView.this.compare(object1, object2);
- }
- });
- }
-
- protected int compare(final Object object1, final Object object2) {
- final String label1 = this.labelProvider.getText(object1);
- final String label2 = this.labelProvider.getText(object2);
- return label1.compareToIgnoreCase(label2);
- }
-
- private EditableContext createEditableContext() {
- return new EditableContext() {
- public void add(final EObject eObject) {
- NavigationView.this.dropEObject(eObject);
- }
-
- public void remove(final EObject eObject) {
- NavigationView.this.removeEObject(eObject);
- }
-
- public void clear() {
- NavigationView.this.removeAllEObjects();
- }
-
- public void done() {
- NavigationView.this.refreshContextViewer();
- }
- };
- }
-
- protected void dropEObject(final EObject eObject) {
- this.fContext.add(eObject);
- }
-
- /** Create a context menu on the context pane */
- private void createContextMenu(final TreeViewer treeViewer) {
- final ContextPaneMenuManager menuManager = new ContextPaneMenuManager(this,
- createEditableContext(), treeViewer);
- final Menu menu = menuManager.createContextMenu(treeViewer.getTree());
- treeViewer.getTree().setMenu(menu);
- }
-
- private void addDropSupport(final TreeViewer viewer) {
- final DropTargetListener dropListener = new DropAdapter(
- new DropAction() {
- @Override
- public void dropped(final Set<EObject> eObjects) {
- addEObjects(eObjects);
- }
- });
- final int dndOperations = DND.DROP_LINK | DND.DROP_COPY | DND.DROP_MOVE;
- final Transfer[] transfers = new Transfer[] { LocalTransfer
- .getInstance() };
- viewer.addDropSupport(dndOperations, transfers, dropListener);
- }
-
- protected final void refreshContextViewer() {
- if (this.contextViewer != null) {
- this.contextViewer.refresh();
- final Set<EObject> toBeRemoved = new HashSet<EObject>();
- for (EObject eObject : this.fContext) {
- if (eObject.eResource().getResourceSet() != getResourceSet()) {
- toBeRemoved.add(eObject);
- }
- }
- this.fContext.remove(toBeRemoved);
- this.contextViewer.setInput(this.fContext);
- this.contextViewer.setLabelProvider(this.labelProvider);
- updateQueriesInput();
- }
- }
-
- private void updateQueriesInput() {
- final Collection<ETypedElement> result = new ArrayList<ETypedElement>();
- final ResourceSet resourceSet = this.editingDomain.getResourceSet();
- final IFacetSetCatalogManager catalog = IFacetSetCatalogManagerFactory.DEFAULT
- .getOrCreateFacetSetCatalogManager(resourceSet);
- final Collection<FacetSet> registeredFS = catalog
- .getRegisteredFacetSets();
- for (FacetSet facetSet : registeredFS) {
- result.addAll(getETypedElements(facetSet));
- }
- this.navSelection.setAvailableETypedElements(result);
- }
-
- private Collection<? extends ETypedElement> getETypedElements(
- final FacetSet facetSet) {
- final Collection<ETypedElement> result = new ArrayList<ETypedElement>();
- for (EClassifier eClassifier : facetSet.getEClassifiers()) {
- if (eClassifier instanceof Facet) {
- final Facet facet = (Facet) eClassifier;
- if (isApplicableFacet(facet)) {
- result.addAll(facet.getFacetElements());
- result.addAll(facet.getFacetOperations());
- }
- }
- }
- for (FacetSet subFacetSet : facetSet.getFacetSets()) {
- result.addAll(getETypedElements(subFacetSet));
- }
- for (EPackage subPackage : facetSet.getESubpackages()) {
- if (subPackage instanceof FacetSet) {
- final FacetSet subFacetSet = (FacetSet) subPackage;
- result.addAll(getETypedElements(subFacetSet));
- }
- }
- return result;
- }
-
- private void createExecuteGroup(final Composite parent) {
- final Group executeGroup = new Group(parent, SWT.NONE);
- executeGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
- executeGroup.setText(Messages.QueryExecutionView_ExecuteGroup);
- executeGroup.setLayout(new GridLayout());
- createDisplayStyleComposite(executeGroup);
- final Button buttonExecute = new Button(executeGroup, SWT.PUSH);
- buttonExecute.setText(Messages.QueryExecutionView_ExecuteButton);
- final GridData buttonData = new GridData(SWT.CENTER, SWT.NONE, true,
- false);
- buttonData.minimumWidth = NavigationView.EXEC_BT_MIN_WIDTH;
- buttonExecute.setLayoutData(buttonData);
- buttonExecute.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(final SelectionEvent event) {
- executeClicked();
- }
- });
- }
-
- protected void executeClicked() {
- final ETypedElement selectedQuery = getSelectedQuery();
- if (selectedQuery == null) {
- MessageDialog.openInformation(getSite().getShell(),
- Messages.QueryExecutionView_NoQuerySelected,
- Messages.QueryExecutionView_SelectQueryToExecute);
- } else {
- try {
- final IFacetManager facetMgr = IFacetManagerFactory.DEFAULT
- .getOrCreateFacetManager(getResourceSet());
- final List<ETypedElementResult> results = facetMgr
- .batchGetOrInvoke(this.fContext, selectedQuery,
- Object.class);
- if (checkResult(results)) {
- displayResult(results);
- }
- } catch (final Exception e) {
- final StackTraceElement[] stackTrace = e.getStackTrace();
- String stack = ""; //$NON-NLS-1$
- if (stackTrace.length > 0) {
- stack = "\nat:" + stackTrace[0].toString(); //$NON-NLS-1$
- }
- String message;
- if (e.getMessage() == null) {
- message = ""; //$NON-NLS-1$
- } else {
- message = " : " + e.getMessage(); //$NON-NLS-1$
- }
- MessageDialog.openError(getSite().getShell(),
- Messages.QueryExecutionView_ErrorExecutingQuery, e.getClass()
- .getSimpleName() + message + stack);
- Logger.logError(e, Activator.getDefault());
- }
- }
- }
-
- private boolean checkResult(final List<ETypedElementResult> results) {
- boolean result = true;
- for (ETypedElementResult modelQueryResult : results) {
- final Throwable exc = modelQueryResult.getException();
- if (exc != null) {
- Logger.logError(exc, "Query exception", Activator.getDefault()); //$NON-NLS-1$
- MessageDialog.openError(this.mainComposite.getShell(),
- Messages.QueryExecutionView_QueryException, exc.getClass().getSimpleName()
- + " : " + exc.getMessage()); //$NON-NLS-1$
- result = false;
- break;
- }
- }
- return result;
- }
-
- private void displayResult(final List<ETypedElementResult> result) {
- final String displayerName = this.comboDisplayer.getText();
- final IETypedElementResultDisplayer displayer = QueryResultDisplayersRegistry
- .getInstance().getQueryResultDisplayer(displayerName);
- if (displayer == null) {
- final String message = NLS
- .bind("Query Displayer with name \"{0}\" not found", displayerName); //$NON-NLS-1$
- Logger.logError(message, Activator.getDefault());
- MessageDialog.openWarning(getSite().getShell(),
- Messages.QueryExecutionView_NoQueryDisplayer, message);
- } else {
- displayer.displayETypedElementResults(result, this.editingDomain);
- }
- }
-
- private ETypedElement getSelectedQuery() {
- final ETypedElement selectedQuery = this.navSelection
- .getSelectedETypedElements().get(0);
- return selectedQuery;
- }
-
- private void createDisplayStyleComposite(final Group executeGroup) {
- final Composite displayStyle = new Composite(executeGroup,
- SWT.NONE);
- displayStyle.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
- displayStyle.setLayout(new GridLayout(2, false));
- final Label label = new Label(displayStyle, SWT.NONE);
- label.setText(Messages.QueryExecutionView_DisplayResultIn);
- this.comboDisplayer = new Combo(displayStyle, SWT.DROP_DOWN | SWT.READ_ONLY);
-
- final List<IETypedElementResultDisplayer> resultDisplayers = QueryResultDisplayersRegistry
- .getInstance().getQueryResultDisplayers();
- for (IETypedElementResultDisplayer namedQueryResultDisplayer : resultDisplayers) {
- this.comboDisplayer.add(namedQueryResultDisplayer.getName());
- }
-
- this.comboDisplayer.select(0);
- this.comboDisplayer.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
- }
-
- @Override
- public void setFocus() {
- updateEditingDomain();
- this.refreshContextViewer();
- }
-
- private void updateEditingDomain() {
- final IWorkbenchPage activePage = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage();
- if (activePage != null) {
- final IWorkbenchPart part = activePage.getActivePart();
- if (part instanceof IEditingDomainProvider) {
- final IEditingDomainProvider edProvider = (IEditingDomainProvider) part;
- final EditingDomain newEditingDomain = edProvider
- .getEditingDomain();
- if ((this.editingDomain != newEditingDomain)
- || (this.editingDomain == null)) {
- changeEditingDomain(newEditingDomain);
- }
- }
- }
- }
-
- private void changeEditingDomain(final EditingDomain newEditingDomain) {
- this.editingDomain = newEditingDomain;
- if (this.editingDomain == null) {
- final ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(
- ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
- final BasicCommandStack commandStack = new BasicCommandStack();
- this.editingDomain = new AdapterFactoryEditingDomain(
- adapterFactory, commandStack,
- new HashMap<Resource, Boolean>());
- }
- final ICustomizationManager customMgr = ICustomizationManagerFactory.DEFAULT
- .getOrCreateICustomizationManager(this.editingDomain
- .getResourceSet());
- this.labelProvider = ICustomizedLabelProviderFactory.DEFAULT
- .createCustomizedLabelProvider(customMgr);
- }
-
- public void setContext(final List<EObject> selectedEObjects) {
- this.fContext.clear();
- this.fContext.addAll(selectedEObjects);
- refreshContextViewer();
- }
-
- public void setSelectedQueries(final List<ETypedElement> queries) {
- this.navSelection.setSelectedETypedElements(queries);
- }
-
- public ContextInfo getContextInfo() {
- final ContextInfo contextInfo = new ContextInfo(
- new ArrayList<EObject>(this.fContext));
- final ISelection selection = this.contextViewer.getSelection();
- if (selection instanceof IStructuredSelection) {
- final IStructuredSelection structSelection = (IStructuredSelection) selection;
- final Iterator<?> iterator = structSelection.iterator();
- while (iterator.hasNext()) {
- final Object selectedElement = iterator.next();
- if (selectedElement instanceof EObject) {
- final EObject eObject = (EObject) selectedElement;
- contextInfo.addSelectedEObject(eObject);
- }
- }
- }
- return contextInfo;
- }
-
- public final class ContextInfo {
- private final List<EObject> eObjects;
- private final List<EObject> selectedEObjects = new ArrayList<EObject>();
-
- public ContextInfo(final List<EObject> eObjects) {
- this.eObjects = eObjects;
- }
-
- public List<EObject> getEObjects() {
- return this.eObjects;
- }
-
- public void addSelectedEObject(final EObject eObject) {
- this.selectedEObjects.add(eObject);
- }
-
- public List<EObject> getSelectedEObjects() {
- return this.selectedEObjects;
- }
-
- }
-
- public void addEObjects(final Collection<? extends EObject> eObjects) {
- updateEditingDomain();
- for (EObject eObject : eObjects) {
- final ResourceSet eObjectRS = eObject.eResource().getResourceSet();
- final ResourceSet currentRS = getResourceSet();
- if (!eObjectRS.equals(currentRS)) {
- throw new IllegalStateException("Invalid resourceSet"); //$NON-NLS-1$
- }
- }
- this.fContext.addAll(eObjects);
- refreshContextViewer();
- }
-
- public void removeEObject(final EObject eObject) {
- this.fContext.remove(eObject);
- }
-
- public void removeEObjects(final List<? extends EObject> eObjects) {
- this.fContext.removeAll(eObjects);
- }
-
- public void removeAllEObjects() {
- this.fContext.clear();
- }
-
- public List<EClassifier> getUsableEClassifiers() {
-
- return null;
- }
-
- public void selectETypedElement(final ETypedElement eTypedElement) {
-
-
- }
-
- public ETypedElement getSelectedETypedElement() {
-
- return null;
- }
-
- public List<IETypedElementResultDisplayerOpener> getAvailableSelectedDisplayers() {
-
- return null;
- }
-
- public void setSelectDisplayer(final IETypedElementResultDisplayerOpener resultDisplayer) {
-
-
- }
-
- public IETypedElementResultDisplayerOpener getSelectedDisplayer() {
-
- return null;
- }
-
- public WorkbenchPart preform() {
-
- return null;
- }
-
- private ResourceSet getResourceSet() {
- return this.editingDomain.getResourceSet();
- }
-
- private ICustomizationManager getCustomizationManager() {
- return ICustomizationManagerFactory.DEFAULT
- .getOrCreateICustomizationManager(getResourceSet());
- }
-
- private boolean isApplicableFacet(final Facet facet) {
- final EClass eobjectClass = EcorePackage.eINSTANCE.getEObject();
- boolean result = false;
- for (final EObject object : this.fContext) {
- if (facet.getExtendedMetaclass() == null
- || facet.getExtendedMetaclass() == eobjectClass
- || facet.getExtendedMetaclass().isSuperTypeOf(object.eClass())) {
- result = true;
- break;
- }
- }
- return result;
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2010, 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) + * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet. + * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + * 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 373510 - EditingDomain, ResourceSet, Catalogs, etc. have to be properly managed between editors and views + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates + * Olivier Remaud (Soft-Maint) - Bug 377615 - Query View filtering + * Gregoire Dupe (Mia-Software) - Bug 378498 - Navigation view sometimes lacks an EditingDomain + * Nicolas Bros (Mia-Software) - Bug 379395 - Navigate should replace elements + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.view; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import org.eclipse.emf.common.command.BasicCommandStack; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +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.AdapterFactoryEditingDomain; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.edit.domain.IEditingDomainProvider; +import org.eclipse.emf.edit.provider.ComposedAdapterFactory; +import org.eclipse.emf.edit.ui.dnd.LocalTransfer; +import org.eclipse.jface.action.GroupMarker; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.IContentProvider; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerComparator; +import org.eclipse.osgi.util.NLS; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManagerFactory; +import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProviderFactory; +import org.eclipse.papyrus.emf.facet.efacet.core.FacetUtils; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManager; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetManagerFactory; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetSetCatalogManager; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetSetCatalogManagerFactory; +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.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.runtime.ETypedElementResult; +import org.eclipse.papyrus.emf.facet.efacet.ui.IETypedElementResultDisplayer; +import org.eclipse.papyrus.emf.facet.efacet.ui.IETypedElementResultDisplayerOpener; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.view.INavigationView; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget.IETypedElementSelectionWidget; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget.IETypedElementSelectionWidgetFactory; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.view.DropAdapter.DropAction; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.SashForm; +import org.eclipse.swt.dnd.DND; +import org.eclipse.swt.dnd.DropTargetListener; +import org.eclipse.swt.dnd.Transfer; +import org.eclipse.swt.events.ControlAdapter; +import org.eclipse.swt.events.ControlEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.ui.IWorkbenchActionConstants; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.ViewPart; +import org.eclipse.ui.part.WorkbenchPart; + +//Copied from org.eclipse.papyrus.emf.facet.infra.query.ui.views.queryExecution.internal.QueryExecutionView +public class NavigationView extends ViewPart implements INavigationView { + + /** + * Execution button minimal width. + */ + private static final int EXEC_BT_MIN_WIDTH = 100; + + private TreeViewer contextViewer; + private Composite mainComposite; + private Composite parentComposite; + + private final Set<EObject> fContext = new HashSet<EObject>(); + private LayoutStyle layoutStyle = NavigationView.LayoutStyle.Horizontal; + private IETypedElementSelectionWidget navSelection; + private Combo comboDisplayer; + private EditingDomain editingDomain = null; + private ILabelProvider labelProvider; + private final IContentProvider contextCP = new ITreeContentProvider() { + + public void inputChanged(final Viewer viewer, final Object oldInput, + final Object newInput) { + // nothing + } + + public void dispose() { + // nothing + } + + public Object[] getElements(final Object inputElement) { + Object[] result = new Object[0]; + if (inputElement instanceof Set<?>) { + final Set<?> set = ((Set<?>) inputElement); + if (set.isEmpty()) { + result = new Object[] { Messages.QueryExecutionView_dragAndDropHint }; + } else { + result = set.toArray(); + } + } + return result; + } + + public boolean hasChildren(final Object element) { + return false; + } + + public Object getParent(final Object element) { + return null; + } + + public Object[] getChildren(final Object parentElement) { + return new Object[] {}; + } + }; + + private enum LayoutStyle { + Horizontal, Vertical + } + + public NavigationView() { + super(); + updateEditingDomain(); + } + + @Override + public void createPartControl(final Composite parent) { + this.parentComposite = parent; + parent.setLayout(gridLayoutWithNoMargins()); + this.layoutStyle = NavigationView.LayoutStyle.Horizontal; + createMainComposite(); + parent.addControlListener(new ControlAdapter() { + @Override + public void controlResized(final ControlEvent event) { + NavigationView.this.controlResized(parent); + } + }); + createContextMenu(); + } + + public void controlResized(final Composite parent) { + final LayoutStyle oldLayoutStyle = NavigationView.this.layoutStyle; + final Point size = parent.getSize(); + if (size.x > size.y) { + this.layoutStyle = NavigationView.LayoutStyle.Horizontal; + } else { + this.layoutStyle = NavigationView.LayoutStyle.Vertical; + } + if (this.layoutStyle != oldLayoutStyle) { + createMainComposite(); + } + } + + protected static void createContextMenu() { + final MenuManager contextMenu = new MenuManager("#PopUp"); //$NON-NLS-1$ + contextMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + } + + private void createMainComposite() { + if (this.mainComposite != null) { + this.mainComposite.dispose(); + } + this.mainComposite = new Composite(this.parentComposite, SWT.NONE); + this.mainComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + this.mainComposite.setLayout(gridLayoutWithNoMargins()); + + int direction; + if (this.layoutStyle == NavigationView.LayoutStyle.Horizontal) { + direction = SWT.HORIZONTAL; + } else { + direction = SWT.VERTICAL; + } + + final SashForm sashForm = new SashForm(this.mainComposite, SWT.SMOOTH + | direction); + sashForm.setLayout(new FillLayout()); + sashForm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + createContextGroup(sashForm); + // createQueryGroup(sashForm); + final Composite lastGroup = new Composite(sashForm, SWT.NONE); + createQueryGroup(lastGroup); + lastGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + GridLayout gridLayout; + if (this.layoutStyle == NavigationView.LayoutStyle.Horizontal) { + gridLayout = new GridLayout(2, false); + } else { + gridLayout = new GridLayout(); + } + gridLayout.marginHeight = 0; + gridLayout.marginWidth = 0; + lastGroup.setLayout(gridLayout); + // TODO: implement parameters (hidden in the meantime) + // /!\ when it is added back, put the QueryGroup back in the sashForm + // instead of lastGroup + // createParametersGroup(lastGroup); + createExecuteGroup(lastGroup); + } + + private static GridLayout gridLayoutWithNoMargins() { + final GridLayout gridLayout = new GridLayout(); + gridLayout.marginWidth = 0; + gridLayout.marginHeight = 0; + return gridLayout; + } + + private void createQueryGroup(final Composite parent) { + final Group queryGroup = new Group(parent, SWT.NONE); + queryGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + queryGroup.setText(Messages.QueryExecutionView_ETypedElementsGroup); + final GridLayout groupLayout = new GridLayout(); + queryGroup.setLayout(groupLayout); + final Collection<ETypedElement> eTypedElements = new ArrayList<ETypedElement>( + FacetUIUtils.getETypedElements(getResourceSet())); + final Collection<? extends EObject> knownEPackages = IFacetSetCatalogManagerFactory.DEFAULT + .getOrCreateFacetSetCatalogManager(this.getResourceSet()) + .getRegisteredFacetSets(); + this.navSelection = IETypedElementSelectionWidgetFactory.DEFAULT + .createETypedElementSelectionWidget( + 1, + false, + queryGroup, + getCustomizationManager(), + knownEPackages); + this.navSelection.setAvailableETypedElements(eTypedElements); + } + + private void createContextGroup(final Composite parent) { + final Group contextGroup = new Group(parent, SWT.NONE); + contextGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + contextGroup.setText(Messages.QueryExecutionView_Context); + final GridLayout groupLayout = new GridLayout(); + contextGroup.setLayout(groupLayout); + createContextViewer(contextGroup); + } + + private void createContextViewer(final Group contextGroup) { + this.contextViewer = new TreeViewer(contextGroup, SWT.MULTI | SWT.BORDER); + final GridData listData = new GridData(SWT.FILL, SWT.FILL, true, true); + this.contextViewer.getTree().setLayoutData(listData); + addDropSupport(this.contextViewer); + createContextMenu(this.contextViewer); + this.contextViewer.setContentProvider(this.contextCP); + changeEditingDomain(this.editingDomain); + this.contextViewer.setLabelProvider(this.labelProvider); + this.contextViewer.setInput(this.fContext); + this.contextViewer.setComparator(new ViewerComparator() { + @Override + public int compare(final Viewer viewer, final Object object1, + final Object object2) { + return NavigationView.this.compare(object1, object2); + } + }); + } + + protected int compare(final Object object1, final Object object2) { + final String label1 = this.labelProvider.getText(object1); + final String label2 = this.labelProvider.getText(object2); + return label1.compareToIgnoreCase(label2); + } + + private EditableContext createEditableContext() { + return new EditableContext() { + public void add(final EObject eObject) { + NavigationView.this.dropEObject(eObject); + } + + public void remove(final EObject eObject) { + NavigationView.this.removeEObject(eObject); + } + + public void clear() { + NavigationView.this.removeAllEObjects(); + } + + public void done() { + NavigationView.this.refreshContextViewer(); + } + }; + } + + protected void dropEObject(final EObject eObject) { + this.fContext.add(eObject); + } + + /** Create a context menu on the context pane */ + private void createContextMenu(final TreeViewer treeViewer) { + final ContextPaneMenuManager menuManager = new ContextPaneMenuManager(this, + createEditableContext(), treeViewer); + final Menu menu = menuManager.createContextMenu(treeViewer.getTree()); + treeViewer.getTree().setMenu(menu); + } + + private void addDropSupport(final TreeViewer viewer) { + final DropTargetListener dropListener = new DropAdapter( + new DropAction() { + @Override + public void dropped(final Set<EObject> eObjects) { + addEObjects(eObjects); + } + }); + final int dndOperations = DND.DROP_LINK | DND.DROP_COPY | DND.DROP_MOVE; + final Transfer[] transfers = new Transfer[] { LocalTransfer + .getInstance() }; + viewer.addDropSupport(dndOperations, transfers, dropListener); + } + + protected final void refreshContextViewer() { + if (this.contextViewer != null) { + this.contextViewer.refresh(); + final Set<EObject> toBeRemoved = new HashSet<EObject>(); + for (EObject eObject : this.fContext) { + if (eObject.eResource().getResourceSet() != getResourceSet()) { + toBeRemoved.add(eObject); + } + } + this.fContext.remove(toBeRemoved); + this.contextViewer.setInput(this.fContext); + this.contextViewer.setLabelProvider(this.labelProvider); + updateQueriesInput(); + } + } + + private void updateQueriesInput() { + final Collection<ETypedElement> result = new ArrayList<ETypedElement>(); + final ResourceSet resourceSet = this.editingDomain.getResourceSet(); + final IFacetSetCatalogManager catalog = IFacetSetCatalogManagerFactory.DEFAULT + .getOrCreateFacetSetCatalogManager(resourceSet); + final Collection<FacetSet> registeredFS = catalog + .getRegisteredFacetSets(); + for (FacetSet facetSet : registeredFS) { + result.addAll(getETypedElements(facetSet)); + } + this.navSelection.setAvailableETypedElements(result); + } + + private Collection<? extends ETypedElement> getETypedElements( + final FacetSet facetSet) { + final Collection<ETypedElement> result = new ArrayList<ETypedElement>(); + for (EClassifier eClassifier : facetSet.getEClassifiers()) { + if (eClassifier instanceof Facet) { + final Facet facet = (Facet) eClassifier; + if (isApplicableFacet(facet)) { + result.addAll(facet.getFacetElements()); + result.addAll(facet.getFacetOperations()); + } + } + } + for (FacetSet subFacetSet : facetSet.getFacetSets()) { + result.addAll(getETypedElements(subFacetSet)); + } + for (EPackage subPackage : facetSet.getESubpackages()) { + if (subPackage instanceof FacetSet) { + final FacetSet subFacetSet = (FacetSet) subPackage; + result.addAll(getETypedElements(subFacetSet)); + } + } + return result; + } + + private void createExecuteGroup(final Composite parent) { + final Group executeGroup = new Group(parent, SWT.NONE); + executeGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); + executeGroup.setText(Messages.QueryExecutionView_ExecuteGroup); + executeGroup.setLayout(new GridLayout()); + createDisplayStyleComposite(executeGroup); + final Button buttonExecute = new Button(executeGroup, SWT.PUSH); + buttonExecute.setText(Messages.QueryExecutionView_ExecuteButton); + final GridData buttonData = new GridData(SWT.CENTER, SWT.NONE, true, + false); + buttonData.minimumWidth = NavigationView.EXEC_BT_MIN_WIDTH; + buttonExecute.setLayoutData(buttonData); + buttonExecute.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(final SelectionEvent event) { + executeClicked(); + } + }); + } + + protected void executeClicked() { + final ETypedElement selectedQuery = getSelectedQuery(); + if (selectedQuery == null) { + MessageDialog.openInformation(getSite().getShell(), + Messages.QueryExecutionView_NoQuerySelected, + Messages.QueryExecutionView_SelectQueryToExecute); + } else { + try { + final IFacetManager facetMgr = IFacetManagerFactory.DEFAULT + .getOrCreateFacetManager(getResourceSet()); + final List<ETypedElementResult> results = facetMgr + .batchGetOrInvoke(this.fContext, selectedQuery, + Object.class); + if (checkResult(results)) { + displayResult(results); + } + } catch (final Exception e) { + final StackTraceElement[] stackTrace = e.getStackTrace(); + String stack = ""; //$NON-NLS-1$ + if (stackTrace.length > 0) { + stack = "\nat:" + stackTrace[0].toString(); //$NON-NLS-1$ + } + String message; + if (e.getMessage() == null) { + message = ""; //$NON-NLS-1$ + } else { + message = " : " + e.getMessage(); //$NON-NLS-1$ + } + MessageDialog.openError(getSite().getShell(), + Messages.QueryExecutionView_ErrorExecutingQuery, e.getClass() + .getSimpleName() + message + stack); + Logger.logError(e, Activator.getDefault()); + } + } + } + + private boolean checkResult(final List<ETypedElementResult> results) { + boolean result = true; + for (ETypedElementResult modelQueryResult : results) { + final Throwable exc = modelQueryResult.getException(); + if (exc != null) { + Logger.logError(exc, "Query exception", Activator.getDefault()); //$NON-NLS-1$ + MessageDialog.openError(this.mainComposite.getShell(), + Messages.QueryExecutionView_QueryException, exc.getClass().getSimpleName() + + " : " + exc.getMessage()); //$NON-NLS-1$ + result = false; + break; + } + } + return result; + } + + private void displayResult(final List<ETypedElementResult> result) { + final String displayerName = this.comboDisplayer.getText(); + final IETypedElementResultDisplayer displayer = QueryResultDisplayersRegistry + .getInstance().getQueryResultDisplayer(displayerName); + if (displayer == null) { + final String message = NLS + .bind("Query Displayer with name \"{0}\" not found", displayerName); //$NON-NLS-1$ + Logger.logError(message, Activator.getDefault()); + MessageDialog.openWarning(getSite().getShell(), + Messages.QueryExecutionView_NoQueryDisplayer, message); + } else { + displayer.displayETypedElementResults(result, this.editingDomain); + } + } + + private ETypedElement getSelectedQuery() { + final ETypedElement selectedQuery = this.navSelection + .getSelectedETypedElements().get(0); + return selectedQuery; + } + + private void createDisplayStyleComposite(final Group executeGroup) { + final Composite displayStyle = new Composite(executeGroup, + SWT.NONE); + displayStyle.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); + displayStyle.setLayout(new GridLayout(2, false)); + final Label label = new Label(displayStyle, SWT.NONE); + label.setText(Messages.QueryExecutionView_DisplayResultIn); + this.comboDisplayer = new Combo(displayStyle, SWT.DROP_DOWN | SWT.READ_ONLY); + + final List<IETypedElementResultDisplayer> resultDisplayers = QueryResultDisplayersRegistry + .getInstance().getQueryResultDisplayers(); + for (IETypedElementResultDisplayer namedQueryResultDisplayer : resultDisplayers) { + this.comboDisplayer.add(namedQueryResultDisplayer.getName()); + } + + this.comboDisplayer.select(0); + this.comboDisplayer.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); + } + + @Override + public void setFocus() { + updateEditingDomain(); + this.refreshContextViewer(); + } + + private void updateEditingDomain() { + final IWorkbenchPage activePage = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage(); + if (activePage != null) { + final IWorkbenchPart part = activePage.getActivePart(); + if (part instanceof IEditingDomainProvider) { + final IEditingDomainProvider edProvider = (IEditingDomainProvider) part; + final EditingDomain newEditingDomain = edProvider + .getEditingDomain(); + if ((this.editingDomain != newEditingDomain) + || (this.editingDomain == null)) { + changeEditingDomain(newEditingDomain); + } + } + } + } + + private void changeEditingDomain(final EditingDomain newEditingDomain) { + this.editingDomain = newEditingDomain; + if (this.editingDomain == null) { + final ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory( + ComposedAdapterFactory.Descriptor.Registry.INSTANCE); + final BasicCommandStack commandStack = new BasicCommandStack(); + this.editingDomain = new AdapterFactoryEditingDomain( + adapterFactory, commandStack, + new HashMap<Resource, Boolean>()); + } + final ICustomizationManager customMgr = ICustomizationManagerFactory.DEFAULT + .getOrCreateICustomizationManager(this.editingDomain + .getResourceSet()); + this.labelProvider = ICustomizedLabelProviderFactory.DEFAULT + .createCustomizedLabelProvider(customMgr); + } + + public void setContext(final List<EObject> selectedEObjects) { + this.fContext.clear(); + this.fContext.addAll(selectedEObjects); + refreshContextViewer(); + } + + public void setSelectedQueries(final List<ETypedElement> queries) { + this.navSelection.setSelectedETypedElements(queries); + } + + public ContextInfo getContextInfo() { + final ContextInfo contextInfo = new ContextInfo( + new ArrayList<EObject>(this.fContext)); + final ISelection selection = this.contextViewer.getSelection(); + if (selection instanceof IStructuredSelection) { + final IStructuredSelection structSelection = (IStructuredSelection) selection; + final Iterator<?> iterator = structSelection.iterator(); + while (iterator.hasNext()) { + final Object selectedElement = iterator.next(); + if (selectedElement instanceof EObject) { + final EObject eObject = (EObject) selectedElement; + contextInfo.addSelectedEObject(eObject); + } + } + } + return contextInfo; + } + + public final class ContextInfo { + private final List<EObject> eObjects; + private final List<EObject> selectedEObjects = new ArrayList<EObject>(); + + public ContextInfo(final List<EObject> eObjects) { + this.eObjects = eObjects; + } + + public List<EObject> getEObjects() { + return this.eObjects; + } + + public void addSelectedEObject(final EObject eObject) { + this.selectedEObjects.add(eObject); + } + + public List<EObject> getSelectedEObjects() { + return this.selectedEObjects; + } + + } + + public void addEObjects(final Collection<? extends EObject> eObjects) { + updateEditingDomain(); + for (EObject eObject : eObjects) { + final ResourceSet eObjectRS = eObject.eResource().getResourceSet(); + final ResourceSet currentRS = getResourceSet(); + if (!eObjectRS.equals(currentRS)) { + throw new IllegalStateException("Invalid resourceSet"); //$NON-NLS-1$ + } + } + this.fContext.addAll(eObjects); + refreshContextViewer(); + } + + public void removeEObject(final EObject eObject) { + this.fContext.remove(eObject); + } + + public void removeEObjects(final List<? extends EObject> eObjects) { + this.fContext.removeAll(eObjects); + } + + public void removeAllEObjects() { + this.fContext.clear(); + } + + public List<EClassifier> getUsableEClassifiers() { + + return null; + } + + public void selectETypedElement(final ETypedElement eTypedElement) { + + + } + + public ETypedElement getSelectedETypedElement() { + + return null; + } + + public List<IETypedElementResultDisplayerOpener> getAvailableSelectedDisplayers() { + + return null; + } + + public void setSelectDisplayer(final IETypedElementResultDisplayerOpener resultDisplayer) { + + + } + + public IETypedElementResultDisplayerOpener getSelectedDisplayer() { + + return null; + } + + public WorkbenchPart preform() { + + return null; + } + + private ResourceSet getResourceSet() { + return this.editingDomain.getResourceSet(); + } + + private ICustomizationManager getCustomizationManager() { + return ICustomizationManagerFactory.DEFAULT + .getOrCreateICustomizationManager(getResourceSet()); + } + + private boolean isApplicableFacet(final Facet facet) { + final EClass eobjectClass = EcorePackage.eINSTANCE.getEObject(); + boolean result = false; + for (final EObject object : this.fContext) { + if (facet.getExtendedMetaclass() == null + || facet.getExtendedMetaclass() == eobjectClass + || facet.getExtendedMetaclass().isSuperTypeOf(object.eClass())) { + result = true; + break; + } + } + return result; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/NavigationViewFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/NavigationViewFactory.java index 89520afbe26..6db1537b587 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/NavigationViewFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/NavigationViewFactory.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:
- * Nicolas Bros (Mia-Software)
- * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.view;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.view.INavigationView;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.view.INavigationViewFactory;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-
-public class NavigationViewFactory implements INavigationViewFactory {
-
- public static final String VIEW_ID = "org.eclipse.papyrus.emf.facet.efacet.ui.view.navigation"; //$NON-NLS-1$
-
- public INavigationView openNavigationView(final EditingDomain editingDomain) {
- INavigationView result = null;
- try {
- final IWorkbenchWindow window = PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow();
- if (window != null) {
- final IWorkbenchPage activePage = window.getActivePage();
- if (activePage != null) {
- result = (INavigationView) activePage
- .showView(NavigationViewFactory.VIEW_ID);
- }
- }
- } catch (final PartInitException e) {
- Logger.logError(e, Activator.getDefault());
- }
- return result;
- }
-
-}
+/******************************************************************************* + * 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) + * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet. + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.view; + +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.view.INavigationView; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.view.INavigationViewFactory; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; + +public class NavigationViewFactory implements INavigationViewFactory { + + public static final String VIEW_ID = "org.eclipse.papyrus.emf.facet.efacet.ui.view.navigation"; //$NON-NLS-1$ + + public INavigationView openNavigationView(final EditingDomain editingDomain) { + INavigationView result = null; + try { + final IWorkbenchWindow window = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow(); + if (window != null) { + final IWorkbenchPage activePage = window.getActivePage(); + if (activePage != null) { + result = (INavigationView) activePage + .showView(NavigationViewFactory.VIEW_ID); + } + } + } catch (final PartInitException e) { + Logger.logError(e, Activator.getDefault()); + } + return result; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/QueryResultDisplayersRegistry.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/QueryResultDisplayersRegistry.java index d617604a6bd..886f4c6490c 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/QueryResultDisplayersRegistry.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/view/QueryResultDisplayersRegistry.java @@ -1,108 +1,108 @@ -/*******************************************************************************
- * Copyright (c) 2008, 2010, 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) - initial API and implementation
- * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet.
- *******************************************************************************/
-
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.view;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.emf.facet.efacet.ui.IETypedElementResultDisplayer;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.papyrus.emf.facet.util.core.internal.exported.AbstractRegistry;
-
-/**
- * The singleton registry of {@link IETypedElementResultDisplayer}s, which initializes
- * the registry by reading extensions when first accessed.
- */
-// Copied from org.eclipse.papyrus.emf.facet.infra.query.ui.views.queryExecution.internal.QueryResultDisplayersRegistry
-public class QueryResultDisplayersRegistry extends AbstractRegistry {
-
- private static final String EXTENSION_POINT_NAME = "eTypedElementResultDisplay"; //$NON-NLS-1$
- private static final String ELEMENT_QUERY_RESULT_DISPLAYER = "displayer"; //$NON-NLS-1$
- private static final String ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$
-
- private static QueryResultDisplayersRegistry instance = null;
-
- private final List<IETypedElementResultDisplayer> queryResultDisplayers;
-
- public QueryResultDisplayersRegistry() {
- this.queryResultDisplayers = new ArrayList<IETypedElementResultDisplayer>();
- initialize();
- }
-
- public static QueryResultDisplayersRegistry getInstance() {
- if (QueryResultDisplayersRegistry.instance == null) {
- QueryResultDisplayersRegistry.instance = new QueryResultDisplayersRegistry();
- }
- return QueryResultDisplayersRegistry.instance;
- }
-
- public List<IETypedElementResultDisplayer> getQueryResultDisplayers() {
- return this.queryResultDisplayers;
- }
-
- public IETypedElementResultDisplayer getQueryResultDisplayer(final String name) {
- for (IETypedElementResultDisplayer namedQueryResultDisplayer : this.queryResultDisplayers) {
- if (name.equals(namedQueryResultDisplayer.getName())) {
- return namedQueryResultDisplayer;
- }
- }
- return null;
- }
-
- @Override
- protected String getExtensionPointName() {
- return QueryResultDisplayersRegistry.EXTENSION_POINT_NAME;
- }
-
- @Override
- protected String getExtensionPointNamespace() {
- return Activator.getDefault().getBundle().getSymbolicName();
- }
-
- @Override
- protected void handleRootElement(final IConfigurationElement configurationElement) {
- final String name = configurationElement.getName();
- if (name.equalsIgnoreCase(QueryResultDisplayersRegistry.ELEMENT_QUERY_RESULT_DISPLAYER)) {
- readQueryResultDisplayer(configurationElement);
- } else {
- logUnknownElement(configurationElement);
- }
- }
-
- private void readQueryResultDisplayer(final IConfigurationElement configurationElement) {
- Object queryResultDisplayerObject = null;
- try {
- queryResultDisplayerObject = configurationElement
- .createExecutableExtension(QueryResultDisplayersRegistry.ATTRIBUTE_CLASS);
- } catch (final CoreException e) {
- Logger.logError(e, Activator.getDefault());
- }
- if (queryResultDisplayerObject == null) {
- logMissingAttribute(configurationElement, QueryResultDisplayersRegistry.ATTRIBUTE_CLASS);
- return;
- }
-
- if (queryResultDisplayerObject instanceof IETypedElementResultDisplayer) {
- IETypedElementResultDisplayer queryResultDisplayer = (IETypedElementResultDisplayer) queryResultDisplayerObject;
- this.queryResultDisplayers.add(queryResultDisplayer);
- } else {
- logError(configurationElement, NLS.bind("The given class is not a {0}.", //$NON-NLS-1$
- IETypedElementResultDisplayer.class.getSimpleName()));
- }
-
- }
-}
+/******************************************************************************* + * Copyright (c) 2008, 2010, 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) - initial API and implementation + * Gregoire Dupe (Mia-Software) - Bug 364325 - [Restructuring] The user must be able to navigate into a model using the Facet. + *******************************************************************************/ + +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.view; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.osgi.util.NLS; +import org.eclipse.papyrus.emf.facet.efacet.ui.IETypedElementResultDisplayer; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.papyrus.emf.facet.util.core.internal.exported.AbstractRegistry; + +/** + * The singleton registry of {@link IETypedElementResultDisplayer}s, which initializes + * the registry by reading extensions when first accessed. + */ +// Copied from org.eclipse.papyrus.emf.facet.infra.query.ui.views.queryExecution.internal.QueryResultDisplayersRegistry +public class QueryResultDisplayersRegistry extends AbstractRegistry { + + private static final String EXTENSION_POINT_NAME = "eTypedElementResultDisplay"; //$NON-NLS-1$ + private static final String ELEMENT_QUERY_RESULT_DISPLAYER = "displayer"; //$NON-NLS-1$ + private static final String ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$ + + private static QueryResultDisplayersRegistry instance = null; + + private final List<IETypedElementResultDisplayer> queryResultDisplayers; + + public QueryResultDisplayersRegistry() { + this.queryResultDisplayers = new ArrayList<IETypedElementResultDisplayer>(); + initialize(); + } + + public static QueryResultDisplayersRegistry getInstance() { + if (QueryResultDisplayersRegistry.instance == null) { + QueryResultDisplayersRegistry.instance = new QueryResultDisplayersRegistry(); + } + return QueryResultDisplayersRegistry.instance; + } + + public List<IETypedElementResultDisplayer> getQueryResultDisplayers() { + return this.queryResultDisplayers; + } + + public IETypedElementResultDisplayer getQueryResultDisplayer(final String name) { + for (IETypedElementResultDisplayer namedQueryResultDisplayer : this.queryResultDisplayers) { + if (name.equals(namedQueryResultDisplayer.getName())) { + return namedQueryResultDisplayer; + } + } + return null; + } + + @Override + protected String getExtensionPointName() { + return QueryResultDisplayersRegistry.EXTENSION_POINT_NAME; + } + + @Override + protected String getExtensionPointNamespace() { + return Activator.getDefault().getBundle().getSymbolicName(); + } + + @Override + protected void handleRootElement(final IConfigurationElement configurationElement) { + final String name = configurationElement.getName(); + if (name.equalsIgnoreCase(QueryResultDisplayersRegistry.ELEMENT_QUERY_RESULT_DISPLAYER)) { + readQueryResultDisplayer(configurationElement); + } else { + logUnknownElement(configurationElement); + } + } + + private void readQueryResultDisplayer(final IConfigurationElement configurationElement) { + Object queryResultDisplayerObject = null; + try { + queryResultDisplayerObject = configurationElement + .createExecutableExtension(QueryResultDisplayersRegistry.ATTRIBUTE_CLASS); + } catch (final CoreException e) { + Logger.logError(e, Activator.getDefault()); + } + if (queryResultDisplayerObject == null) { + logMissingAttribute(configurationElement, QueryResultDisplayersRegistry.ATTRIBUTE_CLASS); + return; + } + + if (queryResultDisplayerObject instanceof IETypedElementResultDisplayer) { + IETypedElementResultDisplayer queryResultDisplayer = (IETypedElementResultDisplayer) queryResultDisplayerObject; + this.queryResultDisplayers.add(queryResultDisplayer); + } else { + logError(configurationElement, NLS.bind("The given class is not a {0}.", //$NON-NLS-1$ + IETypedElementResultDisplayer.class.getSimpleName())); + } + + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/EClassifierSelectionControl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/EClassifierSelectionControl.java index 3fee0d0bb99..d2b715fd1b3 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/EClassifierSelectionControl.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/EClassifierSelectionControl.java @@ -1,90 +1,90 @@ -/*******************************************************************************
- * Copyright (c) 2009, 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) - initial API and implementation
- * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.FilteredElementSelectionComposite;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.SelectETypeComposite.ETypeSelectionOptions;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * A control to select an {@link EClass}, that can be filtered using the associated text field.
- */
-public class EClassifierSelectionControl extends FilteredElementSelectionComposite {
-
- private final Map<String, EClassifier> stringToEClassifierMap = new HashMap<String, EClassifier>();
- private final ETypeSelectionOptions eTypeSelectionOption;
- private String metamodelNsUri;
-
- public EClassifierSelectionControl(final Composite parent, final String metamodelNsUri, final ETypeSelectionOptions eTypeSelectionOption) {
- super(parent, true, false);
- this.eTypeSelectionOption = eTypeSelectionOption;
- this.metamodelNsUri = metamodelNsUri;
- }
-
- public void updateList(final String metamodelNsUri2) {
- this.metamodelNsUri = metamodelNsUri2;
- EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(this.metamodelNsUri);
- if (ePackage != null) {
- List<String> eClasses = new ArrayList<String>();
- EList<EClassifier> eClassifiers = ePackage.getEClassifiers();
- if (this.eTypeSelectionOption == ETypeSelectionOptions.ECLASS) {
- for (EClassifier eClassifier : eClassifiers) {
- if (eClassifier instanceof EClass) {
- eClasses.add(eClassifier.getName());
- this.stringToEClassifierMap.put(eClassifier.getName(), eClassifier);
- }
- }
- } else if (this.eTypeSelectionOption == ETypeSelectionOptions.EDATATYPE) {
- for (EClassifier eClassifier : eClassifiers) {
- if (eClassifier instanceof EDataType) {
- eClasses.add(eClassifier.getName());
- this.stringToEClassifierMap.put(eClassifier.getName(), eClassifier);
- }
- }
-
- } else {
- for (EClassifier eClassifier : eClassifiers) {
- eClasses.add(eClassifier.getName());
- this.stringToEClassifierMap.put(eClassifier.getName(), eClassifier);
- }
- }
- if (eClasses.isEmpty()) {
- eClasses.add(Messages.No_result_found);
- setEnabled(false);
- } else {
- setEnabled(true);
- }
- setElements(eClasses.toArray());
- }
- }
-
- public EClassifier getSelectedEClassifier() {
- Object[] selectElements = getSelectedElements();
- if (selectElements != null && selectElements.length > 0) {
- if (this.stringToEClassifierMap.containsKey(selectElements[0])) {
- return this.stringToEClassifierMap.get(selectElements[0]);
- }
- }
- return null;
- }
-}
+/******************************************************************************* + * Copyright (c) 2009, 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) - initial API and implementation + * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.FilteredElementSelectionComposite; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.SelectETypeComposite.ETypeSelectionOptions; +import org.eclipse.swt.widgets.Composite; + +/** + * A control to select an {@link EClass}, that can be filtered using the associated text field. + */ +public class EClassifierSelectionControl extends FilteredElementSelectionComposite { + + private final Map<String, EClassifier> stringToEClassifierMap = new HashMap<String, EClassifier>(); + private final ETypeSelectionOptions eTypeSelectionOption; + private String metamodelNsUri; + + public EClassifierSelectionControl(final Composite parent, final String metamodelNsUri, final ETypeSelectionOptions eTypeSelectionOption) { + super(parent, true, false); + this.eTypeSelectionOption = eTypeSelectionOption; + this.metamodelNsUri = metamodelNsUri; + } + + public void updateList(final String metamodelNsUri2) { + this.metamodelNsUri = metamodelNsUri2; + EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(this.metamodelNsUri); + if (ePackage != null) { + List<String> eClasses = new ArrayList<String>(); + EList<EClassifier> eClassifiers = ePackage.getEClassifiers(); + if (this.eTypeSelectionOption == ETypeSelectionOptions.ECLASS) { + for (EClassifier eClassifier : eClassifiers) { + if (eClassifier instanceof EClass) { + eClasses.add(eClassifier.getName()); + this.stringToEClassifierMap.put(eClassifier.getName(), eClassifier); + } + } + } else if (this.eTypeSelectionOption == ETypeSelectionOptions.EDATATYPE) { + for (EClassifier eClassifier : eClassifiers) { + if (eClassifier instanceof EDataType) { + eClasses.add(eClassifier.getName()); + this.stringToEClassifierMap.put(eClassifier.getName(), eClassifier); + } + } + + } else { + for (EClassifier eClassifier : eClassifiers) { + eClasses.add(eClassifier.getName()); + this.stringToEClassifierMap.put(eClassifier.getName(), eClassifier); + } + } + if (eClasses.isEmpty()) { + eClasses.add(Messages.No_result_found); + setEnabled(false); + } else { + setEnabled(true); + } + setElements(eClasses.toArray()); + } + } + + public EClassifier getSelectedEClassifier() { + Object[] selectElements = getSelectedElements(); + if (selectElements != null && selectElements.length > 0) { + if (this.stringToEClassifierMap.containsKey(selectElements[0])) { + return this.stringToEClassifierMap.get(selectElements[0]); + } + } + return null; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/ETypedElementSelectionControl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/ETypedElementSelectionControl.java index a12ce14b409..89c491793ad 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/ETypedElementSelectionControl.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/ETypedElementSelectionControl.java @@ -1,431 +1,431 @@ -/*******************************************************************************
- * Copyright (c) 2010, 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 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2
- * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- * Gregoire Dupe (Mia-Software) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets
- * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
- * Olivier Remaud (Soft-Maint) - Bug 377615 - Query View filtering
- * Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets
- * Vincent Lorenzo (CEA-LIST) - Bug 377909 - The elements displayed in the ETypedElement dialog are not sorted by alphabetic order
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
-import org.eclipse.jface.viewers.IBaseLabelProvider;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.OpenEvent;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManagerFactory;
-import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProviderFactory;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.utils.ImageProvider;
-import org.eclipse.papyrus.emf.facet.util.core.internal.exported.IFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.dialogs.FilteredTree;
-import org.eclipse.ui.dialogs.PatternFilter;
-
-/**
- * A control that displays a tree of ETypedElements under a list of containers (EPackages for example), with a filter
- * text field.
- */
-public class ETypedElementSelectionControl implements IETypedElementTabSelectionWidgetInternal {
-
- public static final String TAB_ID = "flat.view.id"; //$NON-NLS-1$
-
- public static final String TITLE = Messages.ETypedElementSelectionControl_FlatView;
-
- /** An OK status, but without the "OK" message, because we don't want "OK" to appear in the status bar */
- private static final IStatus OK_STATUS = new Status(IStatus.OK, Activator.PLUGIN_ID, ""); //$NON-NLS-1$
-
- private FilteredTree filteredTree;
- protected Collection<? extends ETypedElement> available;
- private final int selectionMaxSize;
- private final boolean allowEmpty;
- private Button rbNoSelection;
- private Button rbSelection;
- private IStatus validationStatus;
- private final IBaseLabelProvider labelProvider;
- private final Composite cParent;
- private final Collection<? extends EObject> knownEPackage;
-
- /** Create a tree with a filter text field to select ETypedElements. */
- public ETypedElementSelectionControl(final Composite parentComposite,
- final int selectionMaxSize, final boolean allowEmpty,
- final ICustomizationManager customManager,
- final Collection<? extends EObject> knownEPackage) {
- this.cParent = parentComposite;
- this.knownEPackage = knownEPackage;
- this.selectionMaxSize = selectionMaxSize;
- this.allowEmpty = allowEmpty;
- ICustomizationManager tempCustomManager;
- if (customManager == null) {
- tempCustomManager = ICustomizationManagerFactory.DEFAULT.getOrCreateICustomizationManager(new ResourceSetImpl());
- } else {
- tempCustomManager = customManager;
- }
- this.labelProvider = ICustomizedLabelProviderFactory.DEFAULT
- .createCustomizedLabelProvider(tempCustomManager);
- }
-
- public void createContents() {
- final Composite composite = new Composite(this.cParent, SWT.NONE);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- if (this.allowEmpty) {
- this.rbNoSelection = new Button(composite, SWT.RADIO);
- this.rbNoSelection.setText(Messages.ETypedElementSelectionDialog_radioButtonNoSelection);
- this.rbNoSelection.setSelection(true);
- this.rbNoSelection.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(final SelectionEvent event) {
- final boolean selected = getRadioButtonNoSelection().getSelection();
- setETypedElementSelectionEnabled(!selected);
- if (selected) {
- setSelection(StructuredSelection.EMPTY);
- }
- }
- });
- this.rbSelection = new Button(composite, SWT.RADIO);
- if (this.selectionMaxSize > 1) {
- this.rbSelection.setText(Messages.ETypedElementSelectionDialog_radioButtonMultiSelection);
- } else {
- this.rbSelection.setText(Messages.ETypedElementSelectionDialog_radioButtonSingleSelection);
- }
- this.rbSelection.setSelection(false);
- this.rbSelection.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(final SelectionEvent event) {
- final boolean selected = getRadioButtonSelection().getSelection();
- setETypedElementSelectionEnabled(selected);
- if (!selected) {
- setSelection(StructuredSelection.EMPTY);
- }
- }
- });
- }
-
- createFilteredTree(composite);
-
- this.filteredTree.getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(final SelectionChangedEvent event) {
- updateValidationStatus();
- }
- });
-
- if (this.allowEmpty) {
- setETypedElementSelectionEnabled(false);
- }
-
- updateValidationStatus();
- }
-
- public void addOpenListener(final IOpenListener openListener) {
- // double-click or enter to choose the selected typed element
- this.filteredTree.getViewer().addOpenListener(new IOpenListener() {
- public void open(final OpenEvent event) {
- // only if the selection is valid
- if (!isErrorStatus()) {
- openListener.open(event);
- }
- }
- });
- }
-
- public void addSelectionChangedListener(final ISelectionChangedListener listener) {
- this.filteredTree.getViewer().addSelectionChangedListener(listener);
- }
-
- private void createFilteredTree(final Composite parentComposite) {
- this.filteredTree = new FilteredTree(parentComposite, selectionStyle(this.selectionMaxSize) | SWT.H_SCROLL | SWT.V_SCROLL
- | SWT.BORDER, createPatternFilter(), true);
- // allow tooltip for this viewer
- ColumnViewerToolTipSupport.enableFor(this.filteredTree.getViewer());
- this.filteredTree.getViewer().setContentProvider(createContentProvider());
- this.filteredTree.getViewer().setLabelProvider(this.labelProvider);
- this.filteredTree.getViewer().setFilters(new ViewerFilter[] { this.filteredTree.getPatternFilter() });
- this.filteredTree.getViewer().setComparator(new ViewerComparator());
- }
-
- protected void updateValidationStatus() {
- if (this.filteredTree == null) {
- return;
- }
-
- final Status errorElements = new Status(IStatus.ERROR, Activator.PLUGIN_ID,
- Messages.ETypedElementSelectionControl_invalidSelectionETypedElementsOnly);
- final Status errorSelection = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ETypedElementSelectionControl_invalidSelection);
-
- final IStructuredSelection selection = (IStructuredSelection) this.filteredTree.getViewer().getSelection();
- IStatus newStatus = ETypedElementSelectionControl.OK_STATUS;
- if (!this.allowEmpty && selection.isEmpty()) {
- newStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(Messages.ETypedElementSelectionControl_invalidSelectionAtLeastOneElement,
- Integer.valueOf(this.selectionMaxSize)));
- } else if (selection.size() > this.selectionMaxSize) {
- newStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(Messages.ETypedElementSelectionControl_invalidSelectionAtMostXElements,
- Integer.valueOf(this.selectionMaxSize)));
- } else {
- final Iterator<?> iterator = selection.iterator();
- while (iterator.hasNext()) {
- final Object selectedElement = iterator.next();
- if (!(selectedElement instanceof ETypedElement)) {
- newStatus = errorElements;
- break;
- }
- }
- }
- setValidationStatus(newStatus);
- }
-
- protected void setValidationStatus(final IStatus status) {
- this.validationStatus = status;
- }
-
- public IStatus getValidationStatus() {
- return this.validationStatus;
- }
-
- public boolean isErrorStatus() {
- return this.validationStatus == null || this.validationStatus.getSeverity() >= IStatus.ERROR;
- }
-
- public void setAvailableETypedElements(final Collection<? extends ETypedElement> newAvailable) {
- this.available = newAvailable;
- final Set<EObject> containers = new HashSet<EObject>();
- for (final ETypedElement eTypedElement : newAvailable) {
- final EObject container = getTopmostContainer(eTypedElement);
- if (container != null && containsETypedElement(container)) {
- containers.add(container);
- }
- }
- for (EObject eObject : this.knownEPackage) {
- if (containsETypedElement(eObject)) {
- containers.add(eObject);
- }
- }
- setInput(containers);
- }
-
- protected static EObject getTopmostContainer(final EObject eObject) {
- EObject container = eObject.eContainer();
- EObject result = container;
- while (container != null) {
- result = container;
- container = container.eContainer();
- }
- return result;
- }
-
- public List<ETypedElement> getSelectedETypedElements() {
- final List<ETypedElement> currentlySelected = new ArrayList<ETypedElement>();
- if (this.filteredTree.isDisposed()) {
- throw new IllegalStateException("Cannot get the selection since the viewer is disposed."); //$NON-NLS-1$
- }
- final IStructuredSelection selection = (IStructuredSelection) this.filteredTree.getViewer()
- .getSelection();
- final Iterator<?> iterator = selection.iterator();
- while (iterator.hasNext()) {
- final Object element = iterator.next();
- if (element instanceof ETypedElement) {
- final ETypedElement eTypedElement = (ETypedElement) element;
- currentlySelected.add(eTypedElement);
- }
- }
- return currentlySelected;
- }
-
- public void setSelectedETypedElements(final Collection<? extends ETypedElement> newSelection) {
- if (newSelection == null) {
- throw new IllegalArgumentException();
- }
- final List<ETypedElement> filteredSelection = new ArrayList<ETypedElement>();
- filteredSelection.addAll(newSelection);
- // only keep available elements
- filteredSelection.retainAll(this.available);
- setSelection(new StructuredSelection(filteredSelection));
- }
-
- public void setSelection(final IStructuredSelection selection) {
- setETypedElementSelectionEnabled(!selection.isEmpty());
- this.filteredTree.getViewer().setSelection(selection);
- updateValidationStatus();
- }
-
- protected void setETypedElementSelectionEnabled(final boolean enabled) {
- getRadioButtonNoSelection().setSelection(!enabled);
- getRadioButtonSelection().setSelection(enabled);
- this.filteredTree.getViewer().getTree().setEnabled(enabled);
- this.filteredTree.getFilterControl().setEnabled(enabled);
- }
-
- public void setInput(final Collection<? extends EObject> containers) {
- this.filteredTree.getViewer().setInput(containers);
- }
-
- // @SuppressWarnings("unchecked") : this is the input type
- @SuppressWarnings("unchecked")
- public Collection<? extends EObject> getInput() {
- return (Collection<? extends EObject>) this.filteredTree.getViewer().getInput();
- }
-
- protected IContentProvider createContentProvider() {
- return new ETypedElementSelectionControlContentProvider(new IFilter<EObject>() {
- public boolean filter(final EObject eObject) {
- return filterChild(eObject);
- }
- });
- }
-
- protected boolean filterChild(final EObject eObject) {
- boolean selected;
- if (containsETypedElement(eObject)) {
- selected = true;
- } else if (eObject instanceof ETypedElement) {
- selected = isAvailable(eObject);
- } else {
- selected = false;
- }
- return selected;
- }
-
- protected boolean isAvailable(final EObject eObject) {
- return this.available.contains(eObject);
- }
-
- protected boolean containsETypedElement(final EObject eObject) {
- boolean result = false;
- final TreeIterator<EObject> eAllContents = eObject.eAllContents();
- while (eAllContents.hasNext()) {
- final EObject element = eAllContents.next();
- if (element instanceof ETypedElement) {
- final ETypedElement typedElement = (ETypedElement) element;
- if (isAvailable(typedElement)) {
- result = true;
- break;
- }
- } else {
- result = containsETypedElement(element);
- if (result) {
- break;
- }
- }
- }
- return result;
- }
-
- private static int selectionStyle(final int selectionMaxSize) {
- int selectionStyle;
- if (selectionMaxSize > 1) {
- selectionStyle = SWT.MULTI;
- } else {
- selectionStyle = SWT.SINGLE;
- }
- return selectionStyle;
- }
-
- private static PatternFilter createPatternFilter() {
- return new PatternFilter() {
- @Override
- protected boolean isLeafMatch(final Viewer viewer, final Object element) {
- final String labelText = ((ILabelProvider) ((StructuredViewer) viewer).getLabelProvider())
- .getText(element);
-
- if (labelText == null) {
- return false;
- }
- return wordMatches(labelText) || parentMatches(viewer, element);
- }
-
- private boolean parentMatches(final Viewer viewer, final Object element) {
- final ITreeContentProvider contentProvider = (ITreeContentProvider) ((StructuredViewer) viewer)
- .getContentProvider();
- final Object parent = contentProvider.getParent(element);
- if (parent == null) {
- return false;
- }
- return isLeafMatch(viewer, parent);
- }
- };
- }
-
- public IStructuredSelection getSelection() {
- return (IStructuredSelection) this.filteredTree.getViewer().getSelection();
- }
-
- protected Button getRadioButtonNoSelection() {
- return this.rbNoSelection;
- }
-
- protected Button getRadioButtonSelection() {
- return this.rbSelection;
- }
-
- public FilteredTree getFilteredTree() {
- return this.filteredTree;
- }
-
- public boolean isDisposed() {
- return this.filteredTree.isDisposed();
- }
-
- public String getTitle() {
- return ETypedElementSelectionControl.TITLE;
- }
-
- public String getToolTipText() {
- return getTitle();
- }
-
- public Image getImage() {
- return ImageProvider.getInstance().getFlatViewIcon();
- }
-
- public String getTabId() {
- return ETypedElementSelectionControl.TAB_ID;
- }
-
- public Collection<? extends EObject> getKnownEPackage() {
- return this.knownEPackage;
- }
-}
+/******************************************************************************* + * Copyright (c) 2010, 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 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2 + * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + * Gregoire Dupe (Mia-Software) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets + * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates + * Olivier Remaud (Soft-Maint) - Bug 377615 - Query View filtering + * Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets + * Vincent Lorenzo (CEA-LIST) - Bug 377909 - The elements displayed in the ETypedElement dialog are not sorted by alphabetic order + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.jface.viewers.ColumnViewerToolTipSupport; +import org.eclipse.jface.viewers.IBaseLabelProvider; +import org.eclipse.jface.viewers.IContentProvider; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.IOpenListener; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.OpenEvent; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.StructuredViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerComparator; +import org.eclipse.jface.viewers.ViewerFilter; +import org.eclipse.osgi.util.NLS; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManagerFactory; +import org.eclipse.papyrus.emf.facet.custom.ui.ICustomizedLabelProviderFactory; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.utils.ImageProvider; +import org.eclipse.papyrus.emf.facet.util.core.internal.exported.IFilter; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.dialogs.FilteredTree; +import org.eclipse.ui.dialogs.PatternFilter; + +/** + * A control that displays a tree of ETypedElements under a list of containers (EPackages for example), with a filter + * text field. + */ +public class ETypedElementSelectionControl implements IETypedElementTabSelectionWidgetInternal { + + public static final String TAB_ID = "flat.view.id"; //$NON-NLS-1$ + + public static final String TITLE = Messages.ETypedElementSelectionControl_FlatView; + + /** An OK status, but without the "OK" message, because we don't want "OK" to appear in the status bar */ + private static final IStatus OK_STATUS = new Status(IStatus.OK, Activator.PLUGIN_ID, ""); //$NON-NLS-1$ + + private FilteredTree filteredTree; + protected Collection<? extends ETypedElement> available; + private final int selectionMaxSize; + private final boolean allowEmpty; + private Button rbNoSelection; + private Button rbSelection; + private IStatus validationStatus; + private final IBaseLabelProvider labelProvider; + private final Composite cParent; + private final Collection<? extends EObject> knownEPackage; + + /** Create a tree with a filter text field to select ETypedElements. */ + public ETypedElementSelectionControl(final Composite parentComposite, + final int selectionMaxSize, final boolean allowEmpty, + final ICustomizationManager customManager, + final Collection<? extends EObject> knownEPackage) { + this.cParent = parentComposite; + this.knownEPackage = knownEPackage; + this.selectionMaxSize = selectionMaxSize; + this.allowEmpty = allowEmpty; + ICustomizationManager tempCustomManager; + if (customManager == null) { + tempCustomManager = ICustomizationManagerFactory.DEFAULT.getOrCreateICustomizationManager(new ResourceSetImpl()); + } else { + tempCustomManager = customManager; + } + this.labelProvider = ICustomizedLabelProviderFactory.DEFAULT + .createCustomizedLabelProvider(tempCustomManager); + } + + public void createContents() { + final Composite composite = new Composite(this.cParent, SWT.NONE); + composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + if (this.allowEmpty) { + this.rbNoSelection = new Button(composite, SWT.RADIO); + this.rbNoSelection.setText(Messages.ETypedElementSelectionDialog_radioButtonNoSelection); + this.rbNoSelection.setSelection(true); + this.rbNoSelection.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(final SelectionEvent event) { + final boolean selected = getRadioButtonNoSelection().getSelection(); + setETypedElementSelectionEnabled(!selected); + if (selected) { + setSelection(StructuredSelection.EMPTY); + } + } + }); + this.rbSelection = new Button(composite, SWT.RADIO); + if (this.selectionMaxSize > 1) { + this.rbSelection.setText(Messages.ETypedElementSelectionDialog_radioButtonMultiSelection); + } else { + this.rbSelection.setText(Messages.ETypedElementSelectionDialog_radioButtonSingleSelection); + } + this.rbSelection.setSelection(false); + this.rbSelection.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(final SelectionEvent event) { + final boolean selected = getRadioButtonSelection().getSelection(); + setETypedElementSelectionEnabled(selected); + if (!selected) { + setSelection(StructuredSelection.EMPTY); + } + } + }); + } + + createFilteredTree(composite); + + this.filteredTree.getViewer().addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(final SelectionChangedEvent event) { + updateValidationStatus(); + } + }); + + if (this.allowEmpty) { + setETypedElementSelectionEnabled(false); + } + + updateValidationStatus(); + } + + public void addOpenListener(final IOpenListener openListener) { + // double-click or enter to choose the selected typed element + this.filteredTree.getViewer().addOpenListener(new IOpenListener() { + public void open(final OpenEvent event) { + // only if the selection is valid + if (!isErrorStatus()) { + openListener.open(event); + } + } + }); + } + + public void addSelectionChangedListener(final ISelectionChangedListener listener) { + this.filteredTree.getViewer().addSelectionChangedListener(listener); + } + + private void createFilteredTree(final Composite parentComposite) { + this.filteredTree = new FilteredTree(parentComposite, selectionStyle(this.selectionMaxSize) | SWT.H_SCROLL | SWT.V_SCROLL + | SWT.BORDER, createPatternFilter(), true); + // allow tooltip for this viewer + ColumnViewerToolTipSupport.enableFor(this.filteredTree.getViewer()); + this.filteredTree.getViewer().setContentProvider(createContentProvider()); + this.filteredTree.getViewer().setLabelProvider(this.labelProvider); + this.filteredTree.getViewer().setFilters(new ViewerFilter[] { this.filteredTree.getPatternFilter() }); + this.filteredTree.getViewer().setComparator(new ViewerComparator()); + } + + protected void updateValidationStatus() { + if (this.filteredTree == null) { + return; + } + + final Status errorElements = new Status(IStatus.ERROR, Activator.PLUGIN_ID, + Messages.ETypedElementSelectionControl_invalidSelectionETypedElementsOnly); + final Status errorSelection = new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.ETypedElementSelectionControl_invalidSelection); + + final IStructuredSelection selection = (IStructuredSelection) this.filteredTree.getViewer().getSelection(); + IStatus newStatus = ETypedElementSelectionControl.OK_STATUS; + if (!this.allowEmpty && selection.isEmpty()) { + newStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(Messages.ETypedElementSelectionControl_invalidSelectionAtLeastOneElement, + Integer.valueOf(this.selectionMaxSize))); + } else if (selection.size() > this.selectionMaxSize) { + newStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(Messages.ETypedElementSelectionControl_invalidSelectionAtMostXElements, + Integer.valueOf(this.selectionMaxSize))); + } else { + final Iterator<?> iterator = selection.iterator(); + while (iterator.hasNext()) { + final Object selectedElement = iterator.next(); + if (!(selectedElement instanceof ETypedElement)) { + newStatus = errorElements; + break; + } + } + } + setValidationStatus(newStatus); + } + + protected void setValidationStatus(final IStatus status) { + this.validationStatus = status; + } + + public IStatus getValidationStatus() { + return this.validationStatus; + } + + public boolean isErrorStatus() { + return this.validationStatus == null || this.validationStatus.getSeverity() >= IStatus.ERROR; + } + + public void setAvailableETypedElements(final Collection<? extends ETypedElement> newAvailable) { + this.available = newAvailable; + final Set<EObject> containers = new HashSet<EObject>(); + for (final ETypedElement eTypedElement : newAvailable) { + final EObject container = getTopmostContainer(eTypedElement); + if (container != null && containsETypedElement(container)) { + containers.add(container); + } + } + for (EObject eObject : this.knownEPackage) { + if (containsETypedElement(eObject)) { + containers.add(eObject); + } + } + setInput(containers); + } + + protected static EObject getTopmostContainer(final EObject eObject) { + EObject container = eObject.eContainer(); + EObject result = container; + while (container != null) { + result = container; + container = container.eContainer(); + } + return result; + } + + public List<ETypedElement> getSelectedETypedElements() { + final List<ETypedElement> currentlySelected = new ArrayList<ETypedElement>(); + if (this.filteredTree.isDisposed()) { + throw new IllegalStateException("Cannot get the selection since the viewer is disposed."); //$NON-NLS-1$ + } + final IStructuredSelection selection = (IStructuredSelection) this.filteredTree.getViewer() + .getSelection(); + final Iterator<?> iterator = selection.iterator(); + while (iterator.hasNext()) { + final Object element = iterator.next(); + if (element instanceof ETypedElement) { + final ETypedElement eTypedElement = (ETypedElement) element; + currentlySelected.add(eTypedElement); + } + } + return currentlySelected; + } + + public void setSelectedETypedElements(final Collection<? extends ETypedElement> newSelection) { + if (newSelection == null) { + throw new IllegalArgumentException(); + } + final List<ETypedElement> filteredSelection = new ArrayList<ETypedElement>(); + filteredSelection.addAll(newSelection); + // only keep available elements + filteredSelection.retainAll(this.available); + setSelection(new StructuredSelection(filteredSelection)); + } + + public void setSelection(final IStructuredSelection selection) { + setETypedElementSelectionEnabled(!selection.isEmpty()); + this.filteredTree.getViewer().setSelection(selection); + updateValidationStatus(); + } + + protected void setETypedElementSelectionEnabled(final boolean enabled) { + getRadioButtonNoSelection().setSelection(!enabled); + getRadioButtonSelection().setSelection(enabled); + this.filteredTree.getViewer().getTree().setEnabled(enabled); + this.filteredTree.getFilterControl().setEnabled(enabled); + } + + public void setInput(final Collection<? extends EObject> containers) { + this.filteredTree.getViewer().setInput(containers); + } + + // @SuppressWarnings("unchecked") : this is the input type + @SuppressWarnings("unchecked") + public Collection<? extends EObject> getInput() { + return (Collection<? extends EObject>) this.filteredTree.getViewer().getInput(); + } + + protected IContentProvider createContentProvider() { + return new ETypedElementSelectionControlContentProvider(new IFilter<EObject>() { + public boolean filter(final EObject eObject) { + return filterChild(eObject); + } + }); + } + + protected boolean filterChild(final EObject eObject) { + boolean selected; + if (containsETypedElement(eObject)) { + selected = true; + } else if (eObject instanceof ETypedElement) { + selected = isAvailable(eObject); + } else { + selected = false; + } + return selected; + } + + protected boolean isAvailable(final EObject eObject) { + return this.available.contains(eObject); + } + + protected boolean containsETypedElement(final EObject eObject) { + boolean result = false; + final TreeIterator<EObject> eAllContents = eObject.eAllContents(); + while (eAllContents.hasNext()) { + final EObject element = eAllContents.next(); + if (element instanceof ETypedElement) { + final ETypedElement typedElement = (ETypedElement) element; + if (isAvailable(typedElement)) { + result = true; + break; + } + } else { + result = containsETypedElement(element); + if (result) { + break; + } + } + } + return result; + } + + private static int selectionStyle(final int selectionMaxSize) { + int selectionStyle; + if (selectionMaxSize > 1) { + selectionStyle = SWT.MULTI; + } else { + selectionStyle = SWT.SINGLE; + } + return selectionStyle; + } + + private static PatternFilter createPatternFilter() { + return new PatternFilter() { + @Override + protected boolean isLeafMatch(final Viewer viewer, final Object element) { + final String labelText = ((ILabelProvider) ((StructuredViewer) viewer).getLabelProvider()) + .getText(element); + + if (labelText == null) { + return false; + } + return wordMatches(labelText) || parentMatches(viewer, element); + } + + private boolean parentMatches(final Viewer viewer, final Object element) { + final ITreeContentProvider contentProvider = (ITreeContentProvider) ((StructuredViewer) viewer) + .getContentProvider(); + final Object parent = contentProvider.getParent(element); + if (parent == null) { + return false; + } + return isLeafMatch(viewer, parent); + } + }; + } + + public IStructuredSelection getSelection() { + return (IStructuredSelection) this.filteredTree.getViewer().getSelection(); + } + + protected Button getRadioButtonNoSelection() { + return this.rbNoSelection; + } + + protected Button getRadioButtonSelection() { + return this.rbSelection; + } + + public FilteredTree getFilteredTree() { + return this.filteredTree; + } + + public boolean isDisposed() { + return this.filteredTree.isDisposed(); + } + + public String getTitle() { + return ETypedElementSelectionControl.TITLE; + } + + public String getToolTipText() { + return getTitle(); + } + + public Image getImage() { + return ImageProvider.getInstance().getFlatViewIcon(); + } + + public String getTabId() { + return ETypedElementSelectionControl.TAB_ID; + } + + public Collection<? extends EObject> getKnownEPackage() { + return this.knownEPackage; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/ETypedElementSelectionControlContentProvider.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/ETypedElementSelectionControlContentProvider.java index d195dc26d76..3a2ce35d5ed 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/ETypedElementSelectionControlContentProvider.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/ETypedElementSelectionControlContentProvider.java @@ -1,99 +1,99 @@ -/*******************************************************************************
- * 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 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2
- * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.papyrus.emf.facet.util.core.internal.exported.IFilter;
-
-public class ETypedElementSelectionControlContentProvider implements ITreeContentProvider {
-
- private final IFilter<EObject> childrenFilter;
-
- public ETypedElementSelectionControlContentProvider(final IFilter<EObject> childrenFilter) {
- this.childrenFilter = childrenFilter;
- }
-
- private Object input;
-
- public Object[] getElements(final Object inputElement) {
- // @SuppressWarnings("unchecked") : this is the type setInput accepts
- @SuppressWarnings("unchecked")
- final Collection<? extends EObject> containers = (Collection<? extends EObject>) inputElement;
- return containers.toArray();
- }
-
- public Object[] getChildren(final Object parentElement) {
- Object[] children;
- if (parentElement instanceof EObject) {
- final EObject container = (EObject) parentElement;
- final List<EObject> filteredChildren = computeFilteredChildren(container);
- children = filteredChildren.toArray();
- } else {
- children = new Object[0];
- }
- return children;
- }
-
- public Object getParent(final Object element) {
- Object parent = null;
- if (element instanceof EObject) {
- parent = ((EObject) element).eContainer();
- }
- return parent;
- }
-
- // @SuppressWarnings("unchecked") : the input type is checked by setInput
- @SuppressWarnings("unchecked")
- public boolean hasChildren(final Object element) {
- boolean result;
- final Collection<? extends EObject> rootElements = (Collection<? extends EObject>) this.input;
- if (rootElements.contains(element)) {
- // avoid computing all the children of all the top-level elements
- // since this could be very expensive
- result = true;
- } else if (element instanceof EObject) {
- result = getChildren(element).length > 0;
- } else {
- result = false;
- }
- return result;
- }
-
- public void inputChanged(final Viewer viewer, final Object oldInput,
- final Object newInput) {
- this.input = newInput;
- }
-
- public void dispose() {
- // nothing
- }
-
- protected List<EObject> computeFilteredChildren(final EObject parentEObject) {
- final List<EObject> children = new ArrayList<EObject>();
- final EList<EObject> eContents = parentEObject.eContents();
- children.addAll(eContents);
- final List<EObject> filteredChildren = new ArrayList<EObject>();
- for (final EObject eObject : children) {
- if (this.childrenFilter.filter(eObject)) {
- filteredChildren.add(eObject);
- }
- }
- return filteredChildren;
- }
+/******************************************************************************* + * 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 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2 + * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.papyrus.emf.facet.util.core.internal.exported.IFilter; + +public class ETypedElementSelectionControlContentProvider implements ITreeContentProvider { + + private final IFilter<EObject> childrenFilter; + + public ETypedElementSelectionControlContentProvider(final IFilter<EObject> childrenFilter) { + this.childrenFilter = childrenFilter; + } + + private Object input; + + public Object[] getElements(final Object inputElement) { + // @SuppressWarnings("unchecked") : this is the type setInput accepts + @SuppressWarnings("unchecked") + final Collection<? extends EObject> containers = (Collection<? extends EObject>) inputElement; + return containers.toArray(); + } + + public Object[] getChildren(final Object parentElement) { + Object[] children; + if (parentElement instanceof EObject) { + final EObject container = (EObject) parentElement; + final List<EObject> filteredChildren = computeFilteredChildren(container); + children = filteredChildren.toArray(); + } else { + children = new Object[0]; + } + return children; + } + + public Object getParent(final Object element) { + Object parent = null; + if (element instanceof EObject) { + parent = ((EObject) element).eContainer(); + } + return parent; + } + + // @SuppressWarnings("unchecked") : the input type is checked by setInput + @SuppressWarnings("unchecked") + public boolean hasChildren(final Object element) { + boolean result; + final Collection<? extends EObject> rootElements = (Collection<? extends EObject>) this.input; + if (rootElements.contains(element)) { + // avoid computing all the children of all the top-level elements + // since this could be very expensive + result = true; + } else if (element instanceof EObject) { + result = getChildren(element).length > 0; + } else { + result = false; + } + return result; + } + + public void inputChanged(final Viewer viewer, final Object oldInput, + final Object newInput) { + this.input = newInput; + } + + public void dispose() { + // nothing + } + + protected List<EObject> computeFilteredChildren(final EObject parentEObject) { + final List<EObject> children = new ArrayList<EObject>(); + final EList<EObject> eContents = parentEObject.eContents(); + children.addAll(eContents); + final List<EObject> filteredChildren = new ArrayList<EObject>(); + for (final EObject eObject : children) { + if (this.childrenFilter.filter(eObject)) { + filteredChildren.add(eObject); + } + } + return filteredChildren; + } }
\ No newline at end of file diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/ETypedElementSelectionControlManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/ETypedElementSelectionControlManager.java index 22c60b3f9a3..85e28e5b0d2 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/ETypedElementSelectionControlManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/ETypedElementSelectionControlManager.java @@ -1,219 +1,219 @@ -/**
- * 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:
- * Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets
- * Gregoire Dupe (Mia-Software) - Bug 357621 - Improve the label displayed for Customization and Facets
- * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
- * Nicolas Bros (Mia-Software) - Bug 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.preferences.PreferenceConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.ui.dialogs.FilteredTree;
-
-public class ETypedElementSelectionControlManager implements
- IETypedElementSelectionControlManager {
-
- // this map does the link between the tabItem and the filtered trees
- private final Map<TabItem, IETypedElementTabSelectionWidgetInternal> trees;
- private TabFolder tabFolder;
- private final Composite parentComposite;
- private final int selectionMaxSize;
-
- /**
- * true if empty selection is allowed
- */
- private final boolean emptySelection;
- private final ICustomizationManager customManager;
- private Collection<? extends ETypedElement> availableElements;
- private final Collection<? extends EObject> knownEPackage;
-
- public ETypedElementSelectionControlManager(
- final Composite parentComposite, final int selectionMaxSize,
- final boolean emptySelection,
- final ICustomizationManager customManager,
- final Collection<? extends EObject> knownEPackage) {
-
- this.trees = new HashMap<TabItem, IETypedElementTabSelectionWidgetInternal>();
- this.parentComposite = parentComposite;
- this.selectionMaxSize = selectionMaxSize;
- this.emptySelection = emptySelection;
- this.customManager = customManager;
- this.knownEPackage = knownEPackage;
- }
-
- private static Composite createComposite(final Composite parent) {
- final Composite composite = new Composite(parent, SWT.NONE);
- final GridLayout layout = new GridLayout();
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- return composite;
- }
-
- private void init() {
- this.tabFolder = new TabFolder(this.parentComposite, SWT.TOP);
- this.tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
- true));
-
- // we create the flat tree
- final TabItem flatItem = new TabItem(this.tabFolder, SWT.NONE);
-
- final Composite flatComposite = createComposite(this.tabFolder);
- IETypedElementTabSelectionWidgetInternal filteredTree = new ETypedElementSelectionControl(
- flatComposite, this.selectionMaxSize, this.emptySelection,
- this.customManager, this.knownEPackage);
- flatItem.setText(filteredTree.getTitle());
- flatItem.setToolTipText(filteredTree.getToolTipText());
- flatItem.setImage(filteredTree.getImage());
- this.trees.put(flatItem, filteredTree);
- flatItem.setControl(flatComposite);
- // we create the sortedTabItem
- final TabItem sortedItem = new TabItem(this.tabFolder, SWT.NONE);
- final Composite sortedComposite = createComposite(this.tabFolder);
- filteredTree = new ETypedElementSelectionSortedControl(sortedComposite,
- this.selectionMaxSize, this.emptySelection, this.customManager,
- this.knownEPackage);
- sortedItem.setText(filteredTree.getTitle());
- sortedItem.setToolTipText(filteredTree.getToolTipText());
- sortedItem.setImage(filteredTree.getImage());
- sortedItem.setControl(sortedComposite);
- this.trees.put(sortedItem, filteredTree);
- initSelectedTabItem();
- }
-
- private IETypedElementTabSelectionWidgetInternal getActiveTree() {
- // selectionIndex: Index of the selected tab
- final int selectionIndex = this.tabFolder.getSelectionIndex();
- final TabItem currentTabItem = this.tabFolder
- .getItem(selectionIndex);
- return this.trees.get(currentTabItem);
- }
-
- public void addOpenListener(final IOpenListener openListener) {
- for (IETypedElementSelectionWidgetInternal tree : this.trees.values()) {
- tree.addOpenListener(openListener);
- }
- }
-
- public void addSelectionChangedListener(
- final ISelectionChangedListener listener) {
- for (IETypedElementSelectionWidgetInternal tree : this.trees.values()) {
- tree.addSelectionChangedListener(listener);
- }
- }
-
- /**
- * Set the focus on the last selected TabItem
- */
- private void initSelectedTabItem() {
- final IPreferenceStore store = Activator.getDefault()
- .getPreferenceStore();
- final String value = store
- .getString(PreferenceConstants.TE_SELECTION_TAB);
- for (TabItem item : this.tabFolder.getItems()) {
- if (item.getText().equals(value)) {
- this.tabFolder.setSelection(item);
- return;
- }
- }
- }
-
- public IStatus getValidationStatus() {
- return getActiveTree().getValidationStatus();
- }
-
- public void setAvailableETypedElements(
- final Collection<? extends ETypedElement> availableTE) {
- this.availableElements = availableTE;
- for (IETypedElementSelectionWidgetInternal current : this.trees
- .values()) {
- current.setAvailableETypedElements(availableTE);
- }
- }
-
- public List<ETypedElement> getSelectedETypedElements() {
- return getActiveTree().getSelectedETypedElements();
- }
-
- private void updatePreferenceValue() {
- final IPreferenceStore store = Activator.getDefault()
- .getPreferenceStore();
- final String value = getActiveTree().getTitle();
- store.setValue(
- PreferenceConstants.TE_SELECTION_TAB,
- value);
- }
-
- public void setSelectedETypedElements(
- final Collection<? extends ETypedElement> newSelection) {
- if (newSelection == null) {
- throw new IllegalArgumentException();
- }
- // only select elements that match the filter
- final List<ETypedElement> filteredSelection = new ArrayList<ETypedElement>();
- for (ETypedElement typedElement : newSelection) {
- if (this.availableElements.contains(typedElement)) {
- filteredSelection.add(typedElement);
- }
- }
- setSelection(new StructuredSelection(filteredSelection));
- }
-
- public void setSelection(final IStructuredSelection selection) {
- for (IETypedElementSelectionWidgetInternal filteredTree : this.trees
- .values()) {
- filteredTree.setSelection(selection);
- }
- }
-
- public List<ETypedElement> computeResult() {
- // we save the last visible item :
- updatePreferenceValue();
- return getActiveTree().getSelectedETypedElements();
- }
-
- public boolean isDisposed() {
- return this.tabFolder == null || this.tabFolder.isDisposed() || getActiveTree().isDisposed();
- }
-
- public FilteredTree getFilteredTree() {
- return getActiveTree().getFilteredTree();
- }
-
- public void createContents() {
- init();
- for (IETypedElementSelectionWidgetInternal current : this.trees
- .values()) {
- current.createContents();
- }
- }
-
+/** + * 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: + * Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets + * Gregoire Dupe (Mia-Software) - Bug 357621 - Improve the label displayed for Customization and Facets + * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates + * Nicolas Bros (Mia-Software) - Bug 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2 + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.viewers.IOpenListener; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.preferences.PreferenceConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.TabItem; +import org.eclipse.ui.dialogs.FilteredTree; + +public class ETypedElementSelectionControlManager implements + IETypedElementSelectionControlManager { + + // this map does the link between the tabItem and the filtered trees + private final Map<TabItem, IETypedElementTabSelectionWidgetInternal> trees; + private TabFolder tabFolder; + private final Composite parentComposite; + private final int selectionMaxSize; + + /** + * true if empty selection is allowed + */ + private final boolean emptySelection; + private final ICustomizationManager customManager; + private Collection<? extends ETypedElement> availableElements; + private final Collection<? extends EObject> knownEPackage; + + public ETypedElementSelectionControlManager( + final Composite parentComposite, final int selectionMaxSize, + final boolean emptySelection, + final ICustomizationManager customManager, + final Collection<? extends EObject> knownEPackage) { + + this.trees = new HashMap<TabItem, IETypedElementTabSelectionWidgetInternal>(); + this.parentComposite = parentComposite; + this.selectionMaxSize = selectionMaxSize; + this.emptySelection = emptySelection; + this.customManager = customManager; + this.knownEPackage = knownEPackage; + } + + private static Composite createComposite(final Composite parent) { + final Composite composite = new Composite(parent, SWT.NONE); + final GridLayout layout = new GridLayout(); + composite.setLayout(layout); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + return composite; + } + + private void init() { + this.tabFolder = new TabFolder(this.parentComposite, SWT.TOP); + this.tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, + true)); + + // we create the flat tree + final TabItem flatItem = new TabItem(this.tabFolder, SWT.NONE); + + final Composite flatComposite = createComposite(this.tabFolder); + IETypedElementTabSelectionWidgetInternal filteredTree = new ETypedElementSelectionControl( + flatComposite, this.selectionMaxSize, this.emptySelection, + this.customManager, this.knownEPackage); + flatItem.setText(filteredTree.getTitle()); + flatItem.setToolTipText(filteredTree.getToolTipText()); + flatItem.setImage(filteredTree.getImage()); + this.trees.put(flatItem, filteredTree); + flatItem.setControl(flatComposite); + // we create the sortedTabItem + final TabItem sortedItem = new TabItem(this.tabFolder, SWT.NONE); + final Composite sortedComposite = createComposite(this.tabFolder); + filteredTree = new ETypedElementSelectionSortedControl(sortedComposite, + this.selectionMaxSize, this.emptySelection, this.customManager, + this.knownEPackage); + sortedItem.setText(filteredTree.getTitle()); + sortedItem.setToolTipText(filteredTree.getToolTipText()); + sortedItem.setImage(filteredTree.getImage()); + sortedItem.setControl(sortedComposite); + this.trees.put(sortedItem, filteredTree); + initSelectedTabItem(); + } + + private IETypedElementTabSelectionWidgetInternal getActiveTree() { + // selectionIndex: Index of the selected tab + final int selectionIndex = this.tabFolder.getSelectionIndex(); + final TabItem currentTabItem = this.tabFolder + .getItem(selectionIndex); + return this.trees.get(currentTabItem); + } + + public void addOpenListener(final IOpenListener openListener) { + for (IETypedElementSelectionWidgetInternal tree : this.trees.values()) { + tree.addOpenListener(openListener); + } + } + + public void addSelectionChangedListener( + final ISelectionChangedListener listener) { + for (IETypedElementSelectionWidgetInternal tree : this.trees.values()) { + tree.addSelectionChangedListener(listener); + } + } + + /** + * Set the focus on the last selected TabItem + */ + private void initSelectedTabItem() { + final IPreferenceStore store = Activator.getDefault() + .getPreferenceStore(); + final String value = store + .getString(PreferenceConstants.TE_SELECTION_TAB); + for (TabItem item : this.tabFolder.getItems()) { + if (item.getText().equals(value)) { + this.tabFolder.setSelection(item); + return; + } + } + } + + public IStatus getValidationStatus() { + return getActiveTree().getValidationStatus(); + } + + public void setAvailableETypedElements( + final Collection<? extends ETypedElement> availableTE) { + this.availableElements = availableTE; + for (IETypedElementSelectionWidgetInternal current : this.trees + .values()) { + current.setAvailableETypedElements(availableTE); + } + } + + public List<ETypedElement> getSelectedETypedElements() { + return getActiveTree().getSelectedETypedElements(); + } + + private void updatePreferenceValue() { + final IPreferenceStore store = Activator.getDefault() + .getPreferenceStore(); + final String value = getActiveTree().getTitle(); + store.setValue( + PreferenceConstants.TE_SELECTION_TAB, + value); + } + + public void setSelectedETypedElements( + final Collection<? extends ETypedElement> newSelection) { + if (newSelection == null) { + throw new IllegalArgumentException(); + } + // only select elements that match the filter + final List<ETypedElement> filteredSelection = new ArrayList<ETypedElement>(); + for (ETypedElement typedElement : newSelection) { + if (this.availableElements.contains(typedElement)) { + filteredSelection.add(typedElement); + } + } + setSelection(new StructuredSelection(filteredSelection)); + } + + public void setSelection(final IStructuredSelection selection) { + for (IETypedElementSelectionWidgetInternal filteredTree : this.trees + .values()) { + filteredTree.setSelection(selection); + } + } + + public List<ETypedElement> computeResult() { + // we save the last visible item : + updatePreferenceValue(); + return getActiveTree().getSelectedETypedElements(); + } + + public boolean isDisposed() { + return this.tabFolder == null || this.tabFolder.isDisposed() || getActiveTree().isDisposed(); + } + + public FilteredTree getFilteredTree() { + return getActiveTree().getFilteredTree(); + } + + public void createContents() { + init(); + for (IETypedElementSelectionWidgetInternal current : this.trees + .values()) { + current.createContents(); + } + } + }
\ No newline at end of file diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/ETypedElementSelectionSortedControl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/ETypedElementSelectionSortedControl.java index ee6b5b1d056..75676aab08f 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/ETypedElementSelectionSortedControl.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/ETypedElementSelectionSortedControl.java @@ -1,206 +1,206 @@ -/*******************************************************************************
- * 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:
- * Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets
- * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning
- * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>)
- * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
- * Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.efacet.core.FacetUtils;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.utils.ImageProvider;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.papyrus.emf.facet.util.core.internal.exported.IFilter;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * A control that displays a tree of ETypedElements under a list of containers
- * (EPackages for example), with a filter text field.
- *
- * the result should be : Ecore - FacetSet/Custom/... UML - FacetSet/Custom/...
- * Aggregate - FacetSet/Custom/...
- */
-public class ETypedElementSelectionSortedControl extends
- ETypedElementSelectionControl {
-
- /** this groupByMap is used to define the input of the treeviewer */
- private final Map<EPackage, Set<EObject>> groupByMap;
-
- /** the name of the tabs */
- private static final String NAME = Messages.ETypedElementSelectionSortedControl_groupByMetamodelView;
-
- public static final String GROUPED_TAB_ID = "group.by.metamodel.view.id"; //$NON-NLS-1$
-
- public static final String TOOLTIP = Messages.ETypedElementSelectionSortedControl_toolTip;
-
- /**
- *
- * @param parentComposite
- * @param selectionMaxSize
- * @param allowEmptySelection
- * @param customizationMgr
- */
- public ETypedElementSelectionSortedControl(final Composite parentComposite,
- final int selectionMaxSize, final boolean allowEmpty,
- final ICustomizationManager customizationMgr,
- final Collection<? extends EObject> knownEPackage) {
- super(parentComposite, selectionMaxSize, allowEmpty,
- customizationMgr, knownEPackage);
- this.groupByMap = new HashMap<EPackage, Set<EObject>>();
- }
-
- @Override
- public void setAvailableETypedElements(
- final Collection<? extends ETypedElement> newAvailable) {
- this.available = newAvailable;
- prepareInput();
- setInput(this.groupByMap.keySet());
- }
-
- /**
- * this method is used to organize the input
- */
- private void prepareInput() {
- if (this.available != null) {
- for (ETypedElement eTypedElement : this.available) {
- final EObject container = getTopmostContainer(eTypedElement);
- if (container != null && containsETypedElement(container)) {
- addContainer(container);
- }
- }
- }
- for (EObject current : getKnownEPackage()) {
- if (containsETypedElement(current)) {
- addContainer(current);
- }
- }
- }
-
-
- /**
- * Add a container to the groupByMap
- *
- * @param container
- * a container to add
- */
- private void addContainer(final EObject container) {
- if (container instanceof FacetSet) { // we show only FacetSet in this view
- final FacetSet facetSet = (FacetSet) container;
- final Set<EPackage> packs = FacetUtils
- .getAllExtendedEPackage(facetSet);
- if (packs.isEmpty()) {
- Logger.logError(NLS.bind("Package not found: {0}", //$NON-NLS-1$
- container), Activator.getDefault());
- }
- for (EPackage current : packs) {
- getValues(current).add(container);
- }
- }
- }
-
- /**
- *
- * @param pack
- * an EPackage
- * @return the values associated to the EPackage
- */
- private Collection<EObject> getValues(final EPackage pack) {
- if (!this.groupByMap.containsKey(pack)) {
- final Set<EObject> values = new HashSet<EObject>();
- this.groupByMap.put(pack, values);
- }
- return this.groupByMap.get(pack);
- }
-
- @Override
- protected IContentProvider createContentProvider() {
- return new SortedContentProvider(new IFilter<EObject>() {
- public boolean filter(final EObject eObject) {
- return filterChild(eObject);
- }
- });
- }
-
- @Override
- public String getTitle() {
- return ETypedElementSelectionSortedControl.NAME;
- }
-
- @Override
- public Image getImage() {
- return ImageProvider.getInstance().getTreeViewIcon();
- }
-
- @Override
- public String getToolTipText() {
- return ETypedElementSelectionSortedControl.TOOLTIP;
- }
-
- @Override
- public String getTabId() {
- return ETypedElementSelectionSortedControl.GROUPED_TAB_ID;
- }
-
- public Set<EObject> getChlidren(final Object parentElement) {
- return this.groupByMap
- .get(parentElement);
- }
-
- private class SortedContentProvider extends
- ETypedElementSelectionControlContentProvider {
-
- public SortedContentProvider(final IFilter<EObject> childrenFilter) {
- super(childrenFilter);
- }
-
- @Override
- public Object[] getChildren(final Object parentElement) {
- Object[] children;
- final Set<EObject> list = ETypedElementSelectionSortedControl.this
- .getChlidren(parentElement);
- if (list == null) {
- children = super.getChildren(parentElement);
- } else {
- children = list.toArray();
- }
- return children;
- }
-
- @Override
- public Object getParent(final Object element) {
- Object parent = super.getParent(element);
- if (parent == null && element instanceof FacetSet) {
- final Set<EPackage> packs = FacetUtils
- .getAllExtendedEPackage((FacetSet) element);
- if (!packs.isEmpty()) {
- parent = packs.iterator().next();
- }
- }
- return parent;
- }
-
- }
-}
+/******************************************************************************* + * 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: + * Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets + * Gregoire Dupe (Mia-Software) - Bug 373078 - API Cleaning + * Gregoire Dupe (Mia-Software) - Bug 375087 - [Table] ITableWidget.addColumn(List<ETypedElement>, List<FacetSet>) + * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates + * Vincent Lorenzo (CEA-LIST) - Bug 357621 - Improve the label displayed for Customization and Facets + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget; + +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.jface.viewers.IContentProvider; +import org.eclipse.osgi.util.NLS; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.efacet.core.FacetUtils; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.utils.ImageProvider; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.papyrus.emf.facet.util.core.internal.exported.IFilter; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Composite; + +/** + * A control that displays a tree of ETypedElements under a list of containers + * (EPackages for example), with a filter text field. + * + * the result should be : Ecore - FacetSet/Custom/... UML - FacetSet/Custom/... + * Aggregate - FacetSet/Custom/... + */ +public class ETypedElementSelectionSortedControl extends + ETypedElementSelectionControl { + + /** this groupByMap is used to define the input of the treeviewer */ + private final Map<EPackage, Set<EObject>> groupByMap; + + /** the name of the tabs */ + private static final String NAME = Messages.ETypedElementSelectionSortedControl_groupByMetamodelView; + + public static final String GROUPED_TAB_ID = "group.by.metamodel.view.id"; //$NON-NLS-1$ + + public static final String TOOLTIP = Messages.ETypedElementSelectionSortedControl_toolTip; + + /** + * + * @param parentComposite + * @param selectionMaxSize + * @param allowEmptySelection + * @param customizationMgr + */ + public ETypedElementSelectionSortedControl(final Composite parentComposite, + final int selectionMaxSize, final boolean allowEmpty, + final ICustomizationManager customizationMgr, + final Collection<? extends EObject> knownEPackage) { + super(parentComposite, selectionMaxSize, allowEmpty, + customizationMgr, knownEPackage); + this.groupByMap = new HashMap<EPackage, Set<EObject>>(); + } + + @Override + public void setAvailableETypedElements( + final Collection<? extends ETypedElement> newAvailable) { + this.available = newAvailable; + prepareInput(); + setInput(this.groupByMap.keySet()); + } + + /** + * this method is used to organize the input + */ + private void prepareInput() { + if (this.available != null) { + for (ETypedElement eTypedElement : this.available) { + final EObject container = getTopmostContainer(eTypedElement); + if (container != null && containsETypedElement(container)) { + addContainer(container); + } + } + } + for (EObject current : getKnownEPackage()) { + if (containsETypedElement(current)) { + addContainer(current); + } + } + } + + + /** + * Add a container to the groupByMap + * + * @param container + * a container to add + */ + private void addContainer(final EObject container) { + if (container instanceof FacetSet) { // we show only FacetSet in this view + final FacetSet facetSet = (FacetSet) container; + final Set<EPackage> packs = FacetUtils + .getAllExtendedEPackage(facetSet); + if (packs.isEmpty()) { + Logger.logError(NLS.bind("Package not found: {0}", //$NON-NLS-1$ + container), Activator.getDefault()); + } + for (EPackage current : packs) { + getValues(current).add(container); + } + } + } + + /** + * + * @param pack + * an EPackage + * @return the values associated to the EPackage + */ + private Collection<EObject> getValues(final EPackage pack) { + if (!this.groupByMap.containsKey(pack)) { + final Set<EObject> values = new HashSet<EObject>(); + this.groupByMap.put(pack, values); + } + return this.groupByMap.get(pack); + } + + @Override + protected IContentProvider createContentProvider() { + return new SortedContentProvider(new IFilter<EObject>() { + public boolean filter(final EObject eObject) { + return filterChild(eObject); + } + }); + } + + @Override + public String getTitle() { + return ETypedElementSelectionSortedControl.NAME; + } + + @Override + public Image getImage() { + return ImageProvider.getInstance().getTreeViewIcon(); + } + + @Override + public String getToolTipText() { + return ETypedElementSelectionSortedControl.TOOLTIP; + } + + @Override + public String getTabId() { + return ETypedElementSelectionSortedControl.GROUPED_TAB_ID; + } + + public Set<EObject> getChlidren(final Object parentElement) { + return this.groupByMap + .get(parentElement); + } + + private class SortedContentProvider extends + ETypedElementSelectionControlContentProvider { + + public SortedContentProvider(final IFilter<EObject> childrenFilter) { + super(childrenFilter); + } + + @Override + public Object[] getChildren(final Object parentElement) { + Object[] children; + final Set<EObject> list = ETypedElementSelectionSortedControl.this + .getChlidren(parentElement); + if (list == null) { + children = super.getChildren(parentElement); + } else { + children = list.toArray(); + } + return children; + } + + @Override + public Object getParent(final Object element) { + Object parent = super.getParent(element); + if (parent == null && element instanceof FacetSet) { + final Set<EPackage> packs = FacetUtils + .getAllExtendedEPackage((FacetSet) element); + if (!packs.isEmpty()) { + parent = packs.iterator().next(); + } + } + return parent; + } + + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/ETypedElementSelectionWidgetFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/ETypedElementSelectionWidgetFactory.java index 79ee6f69549..ea64dff6d2a 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/ETypedElementSelectionWidgetFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/ETypedElementSelectionWidgetFactory.java @@ -1,43 +1,43 @@ -/*******************************************************************************
- * 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 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2
- * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget;
-
-import java.util.Collection;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget.IETypedElementSelectionWidget;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget.IETypedElementSelectionWidgetFactory;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-
-public class ETypedElementSelectionWidgetFactory implements IETypedElementSelectionWidgetFactory {
-
- public IETypedElementSelectionWidget createETypedElementSelectionWidget(
- final int selectionMaxSize, final boolean allowEmpty,
- final Composite parentComposite,
- final ICustomizationManager customManager,
- final Collection<? extends EObject> knownEPackage) {
- final ETypedElementSelectionControlManager[] control = new ETypedElementSelectionControlManager[1];
- // must be synchronous, otherwise the shell is not created before SynchronizedETypedElementSelectionWidget, and SynchronizedComposite throws a NPE
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- control[0] = new ETypedElementSelectionControlManager(parentComposite,
- selectionMaxSize, allowEmpty,
- customManager, knownEPackage);
- control[0].createContents();
- }
- });
- return new SynchronizedETypedElementSelectionWidget(control[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: + * Nicolas Bros (Mia-Software) - Bug 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2 + * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget; + +import java.util.Collection; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.emf.facet.custom.core.ICustomizationManager; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget.IETypedElementSelectionWidget; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget.IETypedElementSelectionWidgetFactory; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; + +public class ETypedElementSelectionWidgetFactory implements IETypedElementSelectionWidgetFactory { + + public IETypedElementSelectionWidget createETypedElementSelectionWidget( + final int selectionMaxSize, final boolean allowEmpty, + final Composite parentComposite, + final ICustomizationManager customManager, + final Collection<? extends EObject> knownEPackage) { + final ETypedElementSelectionControlManager[] control = new ETypedElementSelectionControlManager[1]; + // must be synchronous, otherwise the shell is not created before SynchronizedETypedElementSelectionWidget, and SynchronizedComposite throws a NPE + Display.getDefault().syncExec(new Runnable() { + public void run() { + control[0] = new ETypedElementSelectionControlManager(parentComposite, + selectionMaxSize, allowEmpty, + customManager, knownEPackage); + control[0].createContents(); + } + }); + return new SynchronizedETypedElementSelectionWidget(control[0]); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/FacetSetSelectionControl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/FacetSetSelectionControl.java index c1991cdfa17..3477bfbd112 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/FacetSetSelectionControl.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/FacetSetSelectionControl.java @@ -1,333 +1,333 @@ -/*******************************************************************************
- * 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 372865 - FacetSet selection dialog
- * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates
- * Nicolas Bros (Mia-Software) - Bug 372626 - Aggregates
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.ecore.ENamedElement;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTreeViewer;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ICheckStateProvider;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.emf.facet.efacet.core.internal.exported.IResolverManager;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs.FacetSetTreeContentProvider;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget.IFacetSetSelectionWidget;
-import org.eclipse.papyrus.emf.facet.util.emf.ui.internal.utils.ImageUtils;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-/** A control that displays a tree of FacetSets with checkboxes to select them. */
-public class FacetSetSelectionControl implements IFacetSetSelectionWidget {
-
- /** An OK status, but without the "OK" message, because we don't want "OK" to appear in the status bar */
- protected static final IStatus OK_STATUS = new Status(IStatus.OK, Activator.PLUGIN_ID, ""); //$NON-NLS-1$
- protected static final String INVALID_ELEMENTS = Messages.FacetSetSelectionControl_selectionContainsInvalidElements;
- protected static final String ONLY_FACET_SETS = Messages.FacetSetSelectionControl_onlyFacetSetsAllowedInSelection;
-
- private final Composite cParent;
- private CheckboxTreeViewer treeViewer;
- private Collection<? extends FacetSet> available;
-
- private final int selectionMaxSize;
- private final boolean allowEmpty;
- private IStatus validationStatus;
- private final Runnable onChange;
- private final Set<FacetSet> selected = new HashSet<FacetSet>();
-
- /** Create a checkbox tree to select FacetSets. */
- public FacetSetSelectionControl(final Composite parentComposite, final int selectionMaxSize, final boolean allowEmpty, final Runnable onChange) {
- this.cParent = parentComposite;
- this.selectionMaxSize = selectionMaxSize;
- this.allowEmpty = allowEmpty;
- this.onChange = onChange;
- }
-
- public void createContents() {
- final Composite composite = new Composite(this.cParent, SWT.NONE);
- composite.setLayout(new GridLayout());
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- createCheckboxTreeViewer(composite);
- updateValidationStatus();
- }
-
- protected void notifyChanged() {
- if (this.onChange != null) {
- this.onChange.run();
- }
- }
-
- public void setAvailableFacetSets(final Collection<? extends FacetSet> newAvailable) {
- this.available = newAvailable;
- this.treeViewer.setInput(newAvailable.toArray());
- updateValidationStatus();
- notifyChanged();
- }
-
- public Collection<? extends FacetSet> getAvailableFacetSets() {
- return Collections.unmodifiableCollection(this.available);
- }
-
- public List<FacetSet> getSelectedFacetSets() {
- return Collections.unmodifiableList(new ArrayList<FacetSet>(this.selected));
- }
-
- public void setSelectedFacetSets(final Collection<? extends FacetSet> facetSetsToSelect) {
- if (facetSetsToSelect == null) {
- throw new IllegalArgumentException();
- }
- this.selected.clear();
- this.selected.addAll(facetSetsToSelect);
- updateValidationStatus();
- notifyChanged();
- this.treeViewer.refresh();
- }
-
- public final void addCheckStateListener(final ICheckStateListener listener) {
- this.treeViewer.addCheckStateListener(listener);
- }
-
- protected void createCheckboxTreeViewer(final Composite parentComposite) {
- this.treeViewer = new CheckboxTreeViewer(parentComposite, SWT.BORDER);
- this.treeViewer.setContentProvider(createContentProvider());
- this.treeViewer.setLabelProvider(createLabelProvider());
- this.treeViewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
- getTreeViewer().setCheckStateProvider(createCheckStateProvider());
- addCheckStateListener(new ICheckStateListener() {
- public void checkStateChanged(final CheckStateChangedEvent event) {
- FacetSetSelectionControl.this.checkStateChanged(event);
- }
- });
- getTreeViewer().refresh();
- }
-
- protected void checkStateChanged(final CheckStateChangedEvent event) {
- handleCheckStateChange(event);
- getTreeViewer().refresh();
- updateValidationStatus();
- notifyChanged();
- }
-
- protected void handleCheckStateChange(final CheckStateChangedEvent event) {
- final Object element = event.getElement();
- if (event.getElement() instanceof FacetSet) {
- final FacetSet facetSet = (FacetSet) event.getElement();
- FacetSet propagation = IResolverManager.DEFAULT
- .selectionRoot(element, FacetSet.class);
- if (propagation == null) {
- propagation = facetSet;
- }
- if (event.getChecked()) {
- this.selected.add(propagation);
- } else {
- this.selected.remove(propagation);
- }
- }
- this.treeViewer.refresh();
- }
-
- protected boolean isUnderCheckedSuperPackage(final Object element) {
- boolean result = false;
- if (element instanceof FacetSet) {
- final FacetSet facetSet = (FacetSet) element;
- EObject eSuperPackage = facetSet.eContainer();
- while (eSuperPackage != null) {
- if (this.selected.contains(eSuperPackage)) {
- result = true;
- break;
- }
- eSuperPackage = eSuperPackage.eContainer();
- }
- }
- return result;
- }
-
- protected ICheckStateProvider createCheckStateProvider() {
- return new ICheckStateProvider() {
- public boolean isGrayed(final Object element) {
- return FacetSetSelectionControl.this.isGrayed(element);
- }
-
- public boolean isChecked(final Object element) {
- return FacetSetSelectionControl.this.isChecked(element);
- }
- };
- }
-
- protected boolean isGrayed(final Object element) {
- final List<FacetSet> propagation = IResolverManager.DEFAULT
- .selectionPropagation(element, FacetSet.class);
- boolean contains = false;
- if (element instanceof EObject) {
- final EObject eObject = (EObject) element;
- contains = containsSelectedElement(eObject);
- }
- return (contains || isUnderCheckedSuperPackage(element) || propagation
- .contains(element)) && !this.selected.contains(element);
- }
-
- protected boolean containsSelectedElement(final EObject eObject) {
- boolean contains = false;
- final Iterator<EObject> iterator = eObject.eAllContents();
- while (iterator.hasNext()) {
- final EObject subObject = iterator.next();
- contains = this.selected.contains(subObject);
- if (contains) {
- break;
- }
- }
- return contains;
- }
-
- protected boolean isChecked(final Object element) {
- // This "|| isGrayed(element)" has been added avoid problems with
- // Windows 7.
- return this.selected.contains(element) || isGrayed(element);
- }
-
- protected void updateValidationStatus() {
- if (this.treeViewer == null) {
- return;
- }
- final Object[] checkedElements = this.treeViewer.getCheckedElements();
- IStatus newStatus = FacetSetSelectionControl.OK_STATUS;
- if (!this.allowEmpty && checkedElements.length == 0) {
- newStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(Messages.FacetSetSelectionControl_mustSelectAtLeastOneElement,
- Integer.valueOf(this.selectionMaxSize)));
- } else if (checkedElements.length > this.selectionMaxSize) {
- newStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(Messages.FacetSetSelectionControl_mustSelectAtMostNElements,
- Integer.valueOf(this.selectionMaxSize)));
- } else {
- for (final Object checkedElement : checkedElements) {
- final IStatus elementStatus = validateElement(checkedElement);
- if (elementStatus.getSeverity() >= IStatus.ERROR) {
- newStatus = elementStatus;
- break;
- }
- }
- }
- setValidationStatus(newStatus);
- }
-
- protected static IStatus validateElement(final Object checkedElement) {
- IStatus status = FacetSetSelectionControl.OK_STATUS;
- if (!(checkedElement instanceof FacetSet)) {
- status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, FacetSetSelectionControl.ONLY_FACET_SETS);
- }
- return status;
- }
-
- protected boolean isAvailable(final FacetSet facetSet) {
- boolean bAvailable = false;
- if (this.available.contains(facetSet)) {
- bAvailable = true;
- } else {
- EPackage parent = facetSet.getESuperPackage();
- while (parent != null) {
- if (this.available.contains(parent)) {
- bAvailable = true;
- break;
- }
- parent = parent.getESuperPackage();
- }
- }
- return bAvailable;
- }
-
- protected void setValidationStatus(final IStatus status) {
- this.validationStatus = status;
- }
-
- public IStatus getValidationStatus() {
- return this.validationStatus;
- }
-
- public boolean isErrorStatus() {
- return this.validationStatus == null || this.validationStatus.getSeverity() >= IStatus.ERROR;
- }
-
- protected ILabelProvider createLabelProvider() {
- return new LabelProvider() {
- @Override
- public String getText(final Object element) {
- String text;
- if (element instanceof ENamedElement) {
- final ENamedElement namedElement = (ENamedElement) element;
- text = namedElement.getName();
- } else {
- text = super.getText(element);
- }
- return text;
- }
-
- @Override
- public Image getImage(final Object element) {
- return ImageUtils.getImage(element);
- }
- };
- }
-
- // @SuppressWarnings("static-method") : meant to be overridden
- @SuppressWarnings("static-method")
- protected IContentProvider createContentProvider() {
- return new FacetSetTreeContentProvider(false, true, true);
- }
-
- public CheckboxTreeViewer getTreeViewer() {
- return this.treeViewer;
- }
-
- public boolean isDisposed() {
- return this.treeViewer.getTree().isDisposed();
- }
-
- public void selectAll() {
- this.selected.clear();
- this.selected.addAll(this.available);
- this.treeViewer.refresh();
- }
-
- public void deselectAll() {
- this.selected.clear();
- this.treeViewer.refresh();
- }
-
- public Control getControl() {
- Control control = null;
- if (this.treeViewer != null) {
- control = this.treeViewer.getTree();
- }
- return control;
- }
-}
+/******************************************************************************* + * 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 372865 - FacetSet selection dialog + * Gregoire Dupe (Mia-Software) - Bug 372626 - Aggregates + * Nicolas Bros (Mia-Software) - Bug 372626 - Aggregates + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.emf.ecore.ENamedElement; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.jface.viewers.CheckStateChangedEvent; +import org.eclipse.jface.viewers.CheckboxTreeViewer; +import org.eclipse.jface.viewers.ICheckStateListener; +import org.eclipse.jface.viewers.ICheckStateProvider; +import org.eclipse.jface.viewers.IContentProvider; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.osgi.util.NLS; +import org.eclipse.papyrus.emf.facet.efacet.core.internal.exported.IResolverManager; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.dialogs.FacetSetTreeContentProvider; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget.IFacetSetSelectionWidget; +import org.eclipse.papyrus.emf.facet.util.emf.ui.internal.utils.ImageUtils; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; + +/** A control that displays a tree of FacetSets with checkboxes to select them. */ +public class FacetSetSelectionControl implements IFacetSetSelectionWidget { + + /** An OK status, but without the "OK" message, because we don't want "OK" to appear in the status bar */ + protected static final IStatus OK_STATUS = new Status(IStatus.OK, Activator.PLUGIN_ID, ""); //$NON-NLS-1$ + protected static final String INVALID_ELEMENTS = Messages.FacetSetSelectionControl_selectionContainsInvalidElements; + protected static final String ONLY_FACET_SETS = Messages.FacetSetSelectionControl_onlyFacetSetsAllowedInSelection; + + private final Composite cParent; + private CheckboxTreeViewer treeViewer; + private Collection<? extends FacetSet> available; + + private final int selectionMaxSize; + private final boolean allowEmpty; + private IStatus validationStatus; + private final Runnable onChange; + private final Set<FacetSet> selected = new HashSet<FacetSet>(); + + /** Create a checkbox tree to select FacetSets. */ + public FacetSetSelectionControl(final Composite parentComposite, final int selectionMaxSize, final boolean allowEmpty, final Runnable onChange) { + this.cParent = parentComposite; + this.selectionMaxSize = selectionMaxSize; + this.allowEmpty = allowEmpty; + this.onChange = onChange; + } + + public void createContents() { + final Composite composite = new Composite(this.cParent, SWT.NONE); + composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + createCheckboxTreeViewer(composite); + updateValidationStatus(); + } + + protected void notifyChanged() { + if (this.onChange != null) { + this.onChange.run(); + } + } + + public void setAvailableFacetSets(final Collection<? extends FacetSet> newAvailable) { + this.available = newAvailable; + this.treeViewer.setInput(newAvailable.toArray()); + updateValidationStatus(); + notifyChanged(); + } + + public Collection<? extends FacetSet> getAvailableFacetSets() { + return Collections.unmodifiableCollection(this.available); + } + + public List<FacetSet> getSelectedFacetSets() { + return Collections.unmodifiableList(new ArrayList<FacetSet>(this.selected)); + } + + public void setSelectedFacetSets(final Collection<? extends FacetSet> facetSetsToSelect) { + if (facetSetsToSelect == null) { + throw new IllegalArgumentException(); + } + this.selected.clear(); + this.selected.addAll(facetSetsToSelect); + updateValidationStatus(); + notifyChanged(); + this.treeViewer.refresh(); + } + + public final void addCheckStateListener(final ICheckStateListener listener) { + this.treeViewer.addCheckStateListener(listener); + } + + protected void createCheckboxTreeViewer(final Composite parentComposite) { + this.treeViewer = new CheckboxTreeViewer(parentComposite, SWT.BORDER); + this.treeViewer.setContentProvider(createContentProvider()); + this.treeViewer.setLabelProvider(createLabelProvider()); + this.treeViewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + + getTreeViewer().setCheckStateProvider(createCheckStateProvider()); + addCheckStateListener(new ICheckStateListener() { + public void checkStateChanged(final CheckStateChangedEvent event) { + FacetSetSelectionControl.this.checkStateChanged(event); + } + }); + getTreeViewer().refresh(); + } + + protected void checkStateChanged(final CheckStateChangedEvent event) { + handleCheckStateChange(event); + getTreeViewer().refresh(); + updateValidationStatus(); + notifyChanged(); + } + + protected void handleCheckStateChange(final CheckStateChangedEvent event) { + final Object element = event.getElement(); + if (event.getElement() instanceof FacetSet) { + final FacetSet facetSet = (FacetSet) event.getElement(); + FacetSet propagation = IResolverManager.DEFAULT + .selectionRoot(element, FacetSet.class); + if (propagation == null) { + propagation = facetSet; + } + if (event.getChecked()) { + this.selected.add(propagation); + } else { + this.selected.remove(propagation); + } + } + this.treeViewer.refresh(); + } + + protected boolean isUnderCheckedSuperPackage(final Object element) { + boolean result = false; + if (element instanceof FacetSet) { + final FacetSet facetSet = (FacetSet) element; + EObject eSuperPackage = facetSet.eContainer(); + while (eSuperPackage != null) { + if (this.selected.contains(eSuperPackage)) { + result = true; + break; + } + eSuperPackage = eSuperPackage.eContainer(); + } + } + return result; + } + + protected ICheckStateProvider createCheckStateProvider() { + return new ICheckStateProvider() { + public boolean isGrayed(final Object element) { + return FacetSetSelectionControl.this.isGrayed(element); + } + + public boolean isChecked(final Object element) { + return FacetSetSelectionControl.this.isChecked(element); + } + }; + } + + protected boolean isGrayed(final Object element) { + final List<FacetSet> propagation = IResolverManager.DEFAULT + .selectionPropagation(element, FacetSet.class); + boolean contains = false; + if (element instanceof EObject) { + final EObject eObject = (EObject) element; + contains = containsSelectedElement(eObject); + } + return (contains || isUnderCheckedSuperPackage(element) || propagation + .contains(element)) && !this.selected.contains(element); + } + + protected boolean containsSelectedElement(final EObject eObject) { + boolean contains = false; + final Iterator<EObject> iterator = eObject.eAllContents(); + while (iterator.hasNext()) { + final EObject subObject = iterator.next(); + contains = this.selected.contains(subObject); + if (contains) { + break; + } + } + return contains; + } + + protected boolean isChecked(final Object element) { + // This "|| isGrayed(element)" has been added avoid problems with + // Windows 7. + return this.selected.contains(element) || isGrayed(element); + } + + protected void updateValidationStatus() { + if (this.treeViewer == null) { + return; + } + final Object[] checkedElements = this.treeViewer.getCheckedElements(); + IStatus newStatus = FacetSetSelectionControl.OK_STATUS; + if (!this.allowEmpty && checkedElements.length == 0) { + newStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(Messages.FacetSetSelectionControl_mustSelectAtLeastOneElement, + Integer.valueOf(this.selectionMaxSize))); + } else if (checkedElements.length > this.selectionMaxSize) { + newStatus = new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(Messages.FacetSetSelectionControl_mustSelectAtMostNElements, + Integer.valueOf(this.selectionMaxSize))); + } else { + for (final Object checkedElement : checkedElements) { + final IStatus elementStatus = validateElement(checkedElement); + if (elementStatus.getSeverity() >= IStatus.ERROR) { + newStatus = elementStatus; + break; + } + } + } + setValidationStatus(newStatus); + } + + protected static IStatus validateElement(final Object checkedElement) { + IStatus status = FacetSetSelectionControl.OK_STATUS; + if (!(checkedElement instanceof FacetSet)) { + status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, FacetSetSelectionControl.ONLY_FACET_SETS); + } + return status; + } + + protected boolean isAvailable(final FacetSet facetSet) { + boolean bAvailable = false; + if (this.available.contains(facetSet)) { + bAvailable = true; + } else { + EPackage parent = facetSet.getESuperPackage(); + while (parent != null) { + if (this.available.contains(parent)) { + bAvailable = true; + break; + } + parent = parent.getESuperPackage(); + } + } + return bAvailable; + } + + protected void setValidationStatus(final IStatus status) { + this.validationStatus = status; + } + + public IStatus getValidationStatus() { + return this.validationStatus; + } + + public boolean isErrorStatus() { + return this.validationStatus == null || this.validationStatus.getSeverity() >= IStatus.ERROR; + } + + protected ILabelProvider createLabelProvider() { + return new LabelProvider() { + @Override + public String getText(final Object element) { + String text; + if (element instanceof ENamedElement) { + final ENamedElement namedElement = (ENamedElement) element; + text = namedElement.getName(); + } else { + text = super.getText(element); + } + return text; + } + + @Override + public Image getImage(final Object element) { + return ImageUtils.getImage(element); + } + }; + } + + // @SuppressWarnings("static-method") : meant to be overridden + @SuppressWarnings("static-method") + protected IContentProvider createContentProvider() { + return new FacetSetTreeContentProvider(false, true, true); + } + + public CheckboxTreeViewer getTreeViewer() { + return this.treeViewer; + } + + public boolean isDisposed() { + return this.treeViewer.getTree().isDisposed(); + } + + public void selectAll() { + this.selected.clear(); + this.selected.addAll(this.available); + this.treeViewer.refresh(); + } + + public void deselectAll() { + this.selected.clear(); + this.treeViewer.refresh(); + } + + public Control getControl() { + Control control = null; + if (this.treeViewer != null) { + control = this.treeViewer.getTree(); + } + return control; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/FacetSetSelectionWidgetFactory.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/FacetSetSelectionWidgetFactory.java index 447f1f4c552..055fadecb0f 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/FacetSetSelectionWidgetFactory.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/FacetSetSelectionWidgetFactory.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 372865 - FacetSet selection dialog
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget;
-
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget.IFacetSetSelectionWidget;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget.IFacetSetSelectionWidgetFactory;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-
-public class FacetSetSelectionWidgetFactory implements IFacetSetSelectionWidgetFactory {
-
- public IFacetSetSelectionWidget createFacetSetSelectionWidget(final int selectionMaxSize, final boolean allowEmpty,
- final Composite parentComposite, final Runnable onChange) {
- final FacetSetSelectionControl[] control = new FacetSetSelectionControl[1];
- // must be synchronous, otherwise the shell is not created before SynchronizedFacetSetSelectionWidget, and
- // SynchronizedComposite throws a NPE
- Display.getDefault().syncExec(new Runnable() {
- public void run() {
- control[0] = new FacetSetSelectionControl(parentComposite, selectionMaxSize, allowEmpty, onChange);
- control[0].createContents();
- }
- });
- return new SynchronizedFacetSetSelectionWidget(control[0]);
- }
-}
+/******************************************************************************* + * 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 372865 - FacetSet selection dialog + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget; + +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget.IFacetSetSelectionWidget; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget.IFacetSetSelectionWidgetFactory; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; + +public class FacetSetSelectionWidgetFactory implements IFacetSetSelectionWidgetFactory { + + public IFacetSetSelectionWidget createFacetSetSelectionWidget(final int selectionMaxSize, final boolean allowEmpty, + final Composite parentComposite, final Runnable onChange) { + final FacetSetSelectionControl[] control = new FacetSetSelectionControl[1]; + // must be synchronous, otherwise the shell is not created before SynchronizedFacetSetSelectionWidget, and + // SynchronizedComposite throws a NPE + Display.getDefault().syncExec(new Runnable() { + public void run() { + control[0] = new FacetSetSelectionControl(parentComposite, selectionMaxSize, allowEmpty, onChange); + control[0].createContents(); + } + }); + return new SynchronizedFacetSetSelectionWidget(control[0]); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/IETypedElementSelectionControlManager.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/IETypedElementSelectionControlManager.java index 3dcb72a271a..5211e194143 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/IETypedElementSelectionControlManager.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/IETypedElementSelectionControlManager.java @@ -1,51 +1,51 @@ -/*******************************************************************************
- * 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:
- * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- * Gregoire Dupe (Mia-Software) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.jface.viewers.IStructuredSelection;
-
-public interface IETypedElementSelectionControlManager extends
- IETypedElementSelectionWidgetInternal {
-
- /**
- * @return the validation status
- */
- IStatus getValidationStatus();
-
- /**
- * Set the available elements
- *
- * @param eTypedElements
- * available eTypedElements
- */
- void setAvailableETypedElements(
- Collection<? extends ETypedElement> eTypedElements);
-
- /**
- *
- * @param selection
- * the selection
- */
- void setSelection(final IStructuredSelection selection);
-
- /**
- *
- * @return the selection
- */
- List<ETypedElement> computeResult();
-
-}
+/******************************************************************************* + * 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: + * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + * Gregoire Dupe (Mia-Software) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.jface.viewers.IStructuredSelection; + +public interface IETypedElementSelectionControlManager extends + IETypedElementSelectionWidgetInternal { + + /** + * @return the validation status + */ + IStatus getValidationStatus(); + + /** + * Set the available elements + * + * @param eTypedElements + * available eTypedElements + */ + void setAvailableETypedElements( + Collection<? extends ETypedElement> eTypedElements); + + /** + * + * @param selection + * the selection + */ + void setSelection(final IStructuredSelection selection); + + /** + * + * @return the selection + */ + List<ETypedElement> computeResult(); + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/IETypedElementSelectionWidgetInternal.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/IETypedElementSelectionWidgetInternal.java index 4f12040142b..f58fce86834 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/IETypedElementSelectionWidgetInternal.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/IETypedElementSelectionWidgetInternal.java @@ -1,41 +1,41 @@ -/*******************************************************************************
- * 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 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2
- * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget.IETypedElementSelectionWidget;
-import org.eclipse.ui.dialogs.FilteredTree;
-
-public interface IETypedElementSelectionWidgetInternal extends IETypedElementSelectionWidget {
-
- /** Adds a listener that is notified when an element is double-clicked or the Enter key is pressed */
- void addOpenListener(IOpenListener openListener);
-
- /** Adds a listener that is notified when the selection changes */
- void addSelectionChangedListener(ISelectionChangedListener listener);
-
- /** @return the validation status : the selection is not valid if {@link IStatus#getSeverity()} >= {@link IStatus#ERROR} */
- IStatus getValidationStatus();
-
- /** @return whether the widget is disposed */
- boolean isDisposed();
-
- FilteredTree getFilteredTree();
-
- void createContents();
-
- void setSelection(IStructuredSelection selection);
-
+/******************************************************************************* + * 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 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2 + * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.jface.viewers.IOpenListener; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget.IETypedElementSelectionWidget; +import org.eclipse.ui.dialogs.FilteredTree; + +public interface IETypedElementSelectionWidgetInternal extends IETypedElementSelectionWidget { + + /** Adds a listener that is notified when an element is double-clicked or the Enter key is pressed */ + void addOpenListener(IOpenListener openListener); + + /** Adds a listener that is notified when the selection changes */ + void addSelectionChangedListener(ISelectionChangedListener listener); + + /** @return the validation status : the selection is not valid if {@link IStatus#getSeverity()} >= {@link IStatus#ERROR} */ + IStatus getValidationStatus(); + + /** @return whether the widget is disposed */ + boolean isDisposed(); + + FilteredTree getFilteredTree(); + + void createContents(); + + void setSelection(IStructuredSelection selection); + }
\ No newline at end of file diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/IETypedElementTabSelectionWidgetInternal.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/IETypedElementTabSelectionWidgetInternal.java index c5f848c1673..10f208ff00b 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/IETypedElementTabSelectionWidgetInternal.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/IETypedElementTabSelectionWidgetInternal.java @@ -1,47 +1,47 @@ -/*******************************************************************************
- * 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:
- * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget;
-
-import org.eclipse.swt.graphics.Image;
-
-/**
- *
- * Each tab in ETypedElementSectionDialog should implements this interface
- *
- */
-public interface IETypedElementTabSelectionWidgetInternal extends
- IETypedElementSelectionWidgetInternal {
-
- /**
- *
- * @return the title for the tab
- */
- String getTitle();
-
- /**
- *
- * @return the tooltip for the tab
- */
- String getToolTipText();
-
- /**
- *
- * @return the image for the tab
- */
- Image getImage();
-
- /**
- *
- * @return the id for the tab
- */
- String getTabId();
-
+/******************************************************************************* + * 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: + * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget; + +import org.eclipse.swt.graphics.Image; + +/** + * + * Each tab in ETypedElementSectionDialog should implements this interface + * + */ +public interface IETypedElementTabSelectionWidgetInternal extends + IETypedElementSelectionWidgetInternal { + + /** + * + * @return the title for the tab + */ + String getTitle(); + + /** + * + * @return the tooltip for the tab + */ + String getToolTipText(); + + /** + * + * @return the image for the tab + */ + Image getImage(); + + /** + * + * @return the id for the tab + */ + String getTabId(); + }
\ No newline at end of file diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/MetamodelSelectionControl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/MetamodelSelectionControl.java index 0bdd559cf26..3f6d7af05f7 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/MetamodelSelectionControl.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/MetamodelSelectionControl.java @@ -1,37 +1,37 @@ -/*******************************************************************************
- * Copyright (c) 2009, 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) - initial API and implementation
- * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.FilteredElementSelectionComposite;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * A control to select a metamodel from a list of metamodels, that can be filtered using the
- * associated text field.
- */
-public class MetamodelSelectionControl extends FilteredElementSelectionComposite {
-
- public MetamodelSelectionControl(final Composite parent) {
- super(parent, true, false);
-
- final Set<String> uris = new TreeSet<String>();
- for (final Object name : ((Map<?, ?>) EPackage.Registry.INSTANCE).keySet()) {
- uris.add((name).toString());
- }
- setElements(uris.toArray());
- }
-}
+/******************************************************************************* + * Copyright (c) 2009, 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) - initial API and implementation + * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget; + +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.FilteredElementSelectionComposite; +import org.eclipse.swt.widgets.Composite; + +/** + * A control to select a metamodel from a list of metamodels, that can be filtered using the + * associated text field. + */ +public class MetamodelSelectionControl extends FilteredElementSelectionComposite { + + public MetamodelSelectionControl(final Composite parent) { + super(parent, true, false); + + final Set<String> uris = new TreeSet<String>(); + for (final Object name : ((Map<?, ?>) EPackage.Registry.INSTANCE).keySet()) { + uris.add((name).toString()); + } + setElements(uris.toArray()); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/SynchronizedETypedElementSelectionWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/SynchronizedETypedElementSelectionWidget.java index 9d3903b394f..ed5d575ba7e 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/SynchronizedETypedElementSelectionWidget.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/SynchronizedETypedElementSelectionWidget.java @@ -1,123 +1,123 @@ -/*******************************************************************************
- * 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 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2
- * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.jface.viewers.IOpenListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.SynchronizedObject;
-import org.eclipse.ui.dialogs.FilteredTree;
-
-public class SynchronizedETypedElementSelectionWidget extends SynchronizedObject<ETypedElementSelectionControlManager> implements
- IETypedElementSelectionWidgetInternal {
-
- private final ETypedElementSelectionControlManager control;
-
- protected IETypedElementSelectionWidgetInternal getControl() {
- return this.control;
- }
-
- public SynchronizedETypedElementSelectionWidget(final ETypedElementSelectionControlManager control) {
- super(control, control.getFilteredTree().getDisplay());
- this.control = control;
- }
-
- public void setAvailableETypedElements(final Collection<? extends ETypedElement> available) {
- voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
- @Override
- public void voidSafeRun() {
- getControl().setAvailableETypedElements(available);
- }
- });
- }
-
- public List<ETypedElement> getSelectedETypedElements() {
- return safeSyncExec(new AbstractExceptionFreeRunnable<List<ETypedElement>>() {
- @Override
- public List<ETypedElement> safeRun() {
- return getControl().getSelectedETypedElements();
- }
- });
- }
-
- public void setSelectedETypedElements(final Collection<? extends ETypedElement> elementsToSelect) {
- voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
- @Override
- public void voidSafeRun() {
- getControl().setSelectedETypedElements(elementsToSelect);
- }
- });
- }
-
- public void addOpenListener(final IOpenListener openListener) {
- voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
- @Override
- public void voidSafeRun() {
- getControl().addOpenListener(openListener);
- }
- });
- }
-
- public void addSelectionChangedListener(final ISelectionChangedListener listener) {
- voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
- @Override
- public void voidSafeRun() {
- getControl().addSelectionChangedListener(listener);
- }
- });
- }
-
- public IStatus getValidationStatus() {
- return safeSyncExec(new AbstractExceptionFreeRunnable<IStatus>() {
- @Override
- public IStatus safeRun() {
- return getControl().getValidationStatus();
- }
- });
- }
-
- public boolean isDisposed() {
- return safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() {
- @Override
- public Boolean safeRun() {
- return Boolean.valueOf(getControl().isDisposed());
- }
- }).booleanValue();
- }
-
- public FilteredTree getFilteredTree() {
- // should not be used!
- throw new UnsupportedOperationException();
- }
-
- public void createContents() {
- // //nothing to do
- throw new UnsupportedOperationException();
- }
-
- public void setSelection(final IStructuredSelection selection) {
- voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
- @Override
- public void voidSafeRun() {
- getControl().setSelection(selection);
- }
- });
- }
-
-}
+/******************************************************************************* + * 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 370806 - [table] rewrite the "allowed contents" query selection dialog for v0.2 + * Vincent Lorenzo (CEA-LIST) - Bug 372644 - Create Customizable tooltips for the TreeViewer using a CustomizableLabelProvider + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.jface.viewers.IOpenListener; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.SynchronizedObject; +import org.eclipse.ui.dialogs.FilteredTree; + +public class SynchronizedETypedElementSelectionWidget extends SynchronizedObject<ETypedElementSelectionControlManager> implements + IETypedElementSelectionWidgetInternal { + + private final ETypedElementSelectionControlManager control; + + protected IETypedElementSelectionWidgetInternal getControl() { + return this.control; + } + + public SynchronizedETypedElementSelectionWidget(final ETypedElementSelectionControlManager control) { + super(control, control.getFilteredTree().getDisplay()); + this.control = control; + } + + public void setAvailableETypedElements(final Collection<? extends ETypedElement> available) { + voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() { + @Override + public void voidSafeRun() { + getControl().setAvailableETypedElements(available); + } + }); + } + + public List<ETypedElement> getSelectedETypedElements() { + return safeSyncExec(new AbstractExceptionFreeRunnable<List<ETypedElement>>() { + @Override + public List<ETypedElement> safeRun() { + return getControl().getSelectedETypedElements(); + } + }); + } + + public void setSelectedETypedElements(final Collection<? extends ETypedElement> elementsToSelect) { + voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() { + @Override + public void voidSafeRun() { + getControl().setSelectedETypedElements(elementsToSelect); + } + }); + } + + public void addOpenListener(final IOpenListener openListener) { + voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() { + @Override + public void voidSafeRun() { + getControl().addOpenListener(openListener); + } + }); + } + + public void addSelectionChangedListener(final ISelectionChangedListener listener) { + voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() { + @Override + public void voidSafeRun() { + getControl().addSelectionChangedListener(listener); + } + }); + } + + public IStatus getValidationStatus() { + return safeSyncExec(new AbstractExceptionFreeRunnable<IStatus>() { + @Override + public IStatus safeRun() { + return getControl().getValidationStatus(); + } + }); + } + + public boolean isDisposed() { + return safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() { + @Override + public Boolean safeRun() { + return Boolean.valueOf(getControl().isDisposed()); + } + }).booleanValue(); + } + + public FilteredTree getFilteredTree() { + // should not be used! + throw new UnsupportedOperationException(); + } + + public void createContents() { + // //nothing to do + throw new UnsupportedOperationException(); + } + + public void setSelection(final IStructuredSelection selection) { + voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() { + @Override + public void voidSafeRun() { + getControl().setSelection(selection); + } + }); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/SynchronizedFacetSetSelectionWidget.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/SynchronizedFacetSetSelectionWidget.java index c917df782af..461d90babdf 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/SynchronizedFacetSetSelectionWidget.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/widget/SynchronizedFacetSetSelectionWidget.java @@ -1,90 +1,90 @@ -/*******************************************************************************
- * 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 372865 - FacetSet selection dialog
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget.IFacetSetSelectionWidget;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable;
-import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.SynchronizedObject;
-import org.eclipse.swt.widgets.Control;
-
-public class SynchronizedFacetSetSelectionWidget extends SynchronizedObject<FacetSetSelectionControl> implements IFacetSetSelectionWidget {
-
- private final FacetSetSelectionControl control;
-
- protected FacetSetSelectionControl getDelegate() {
- return this.control;
- }
-
- public SynchronizedFacetSetSelectionWidget(final FacetSetSelectionControl control) {
- super(control, control.getTreeViewer().getTree().getDisplay());
- this.control = control;
- }
-
- public void setAvailableFacetSets(final Collection<? extends FacetSet> available) {
- voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
- @Override
- public void voidSafeRun() {
- getDelegate().setAvailableFacetSets(available);
- }
- });
- }
-
- public List<FacetSet> getSelectedFacetSets() {
- return safeSyncExec(new AbstractExceptionFreeRunnable<List<FacetSet>>() {
- @Override
- public List<FacetSet> safeRun() {
- return getDelegate().getSelectedFacetSets();
- }
- });
- }
-
- public void setSelectedFacetSets(final Collection<? extends FacetSet> facetSetsToSelect) {
- voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() {
- @Override
- public void voidSafeRun() {
- getDelegate().setSelectedFacetSets(facetSetsToSelect);
- }
- });
- }
-
- public IStatus getValidationStatus() {
- return safeSyncExec(new AbstractExceptionFreeRunnable<IStatus>() {
- @Override
- public IStatus safeRun() {
- return getDelegate().getValidationStatus();
- }
- });
- }
-
- public boolean isDisposed() {
- return safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() {
- @Override
- public Boolean safeRun() {
- return Boolean.valueOf(getDelegate().isDisposed());
- }
- }).booleanValue();
- }
-
- public Control getControl() {
- return safeSyncExec(new AbstractExceptionFreeRunnable<Control>() {
- @Override
- public Control safeRun() {
- return getDelegate().getControl();
- }
- });
- }
-}
+/******************************************************************************* + * 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 372865 - FacetSet selection dialog + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.papyrus.emf.facet.efacet.metamodel.v0_2_0.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.widget.IFacetSetSelectionWidget; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractExceptionFreeRunnable; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.AbstractVoidExceptionFreeRunnable; +import org.eclipse.papyrus.emf.facet.util.ui.internal.exported.displaysync.SynchronizedObject; +import org.eclipse.swt.widgets.Control; + +public class SynchronizedFacetSetSelectionWidget extends SynchronizedObject<FacetSetSelectionControl> implements IFacetSetSelectionWidget { + + private final FacetSetSelectionControl control; + + protected FacetSetSelectionControl getDelegate() { + return this.control; + } + + public SynchronizedFacetSetSelectionWidget(final FacetSetSelectionControl control) { + super(control, control.getTreeViewer().getTree().getDisplay()); + this.control = control; + } + + public void setAvailableFacetSets(final Collection<? extends FacetSet> available) { + voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() { + @Override + public void voidSafeRun() { + getDelegate().setAvailableFacetSets(available); + } + }); + } + + public List<FacetSet> getSelectedFacetSets() { + return safeSyncExec(new AbstractExceptionFreeRunnable<List<FacetSet>>() { + @Override + public List<FacetSet> safeRun() { + return getDelegate().getSelectedFacetSets(); + } + }); + } + + public void setSelectedFacetSets(final Collection<? extends FacetSet> facetSetsToSelect) { + voidExceptionFreeRunnable(new AbstractVoidExceptionFreeRunnable() { + @Override + public void voidSafeRun() { + getDelegate().setSelectedFacetSets(facetSetsToSelect); + } + }); + } + + public IStatus getValidationStatus() { + return safeSyncExec(new AbstractExceptionFreeRunnable<IStatus>() { + @Override + public IStatus safeRun() { + return getDelegate().getValidationStatus(); + } + }); + } + + public boolean isDisposed() { + return safeSyncExec(new AbstractExceptionFreeRunnable<Boolean>() { + @Override + public Boolean safeRun() { + return Boolean.valueOf(getDelegate().isDisposed()); + } + }).booleanValue(); + } + + public Control getControl() { + return safeSyncExec(new AbstractExceptionFreeRunnable<Control>() { + @Override + public Control safeRun() { + return getDelegate().getControl(); + } + }); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AbstractAddFacetChildrenWizard.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AbstractAddFacetChildrenWizard.java index 7fca36a2e3e..9cb33494282 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AbstractAddFacetChildrenWizard.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AbstractAddFacetChildrenWizard.java @@ -1,175 +1,175 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- * Grégoire Dupe (Mia-Software) - Bug 373248 - Clean PMD errors
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards;
-
-import java.util.Map;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.papyrus.emf.facet.efacet.Facet;
-import org.eclipse.papyrus.emf.facet.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.IQueryCreationPagePartRegistry;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IFacetChildrenWizard;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.AbstractFacetWizardPage;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.CreateQueryWizardPage;
-
-@SuppressWarnings("PMD.ConstructorCallsOverridableMethod")
-// @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") This class is
-// deprecated, we won't then spend to many time to conforms to PMD rules.
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public abstract class AbstractAddFacetChildrenWizard extends Wizard implements IFacetChildrenWizard {
-
- private final ISelection selection;
- private final EditingDomain editingDomain;
- private final WizardDialog dialog;
- private FacetSet facetSet;
- private Facet facet;
- private final Map<String, IQueryCreationPagePart> queryTypeNameToQueryCreationPage;
-
- private AbstractFacetWizardPage facetCreationPage;
- private CreateQueryWizardPage queryCreationPage;
-
- public AbstractAddFacetChildrenWizard(final ISelection selection, final EditingDomain editingDomain) {
- this.selection = selection;
- this.editingDomain = editingDomain;
- initializeSelection();
- this.queryTypeNameToQueryCreationPage = IQueryCreationPagePartRegistry.INSTANCE.getRegisteredWizardPageParts();
- this.dialog = new WizardDialog(getShell(), this);
- addQueryCreationPage();
- }
-
- protected void addQueryCreationPage() {
- this.queryCreationPage = new CreateQueryWizardPage(this.queryTypeNameToQueryCreationPage, getFacetSet(), this.facet);
- }
-
- private void initializeSelection() {
- if (this.selection != null && !this.selection.isEmpty() && this.selection instanceof IStructuredSelection) {
- IStructuredSelection ssel = (IStructuredSelection) this.selection;
- if (ssel.size() > 1) {
- return;
- }
- Object obj = ssel.getFirstElement();
- if (obj instanceof FacetSet) {
- this.facetSet = (FacetSet) obj;
- } else {
- if (obj instanceof Facet) {
- this.facetSet = ((Facet) obj).getFacetSet();
- this.facet = (Facet) obj;
- }
- }
- }
- }
-
- @Override
- public void addPages() {
- if (this.facetCreationPage != null) {
- addPage(this.facetCreationPage);
- }
- if (this.queryCreationPage != null) {
- this.queryCreationPage.canChangeCanBeCached(false);
- this.queryCreationPage.canChangeHasSideEffect(false);
- this.queryCreationPage.canChangeLowerBound(false);
- this.queryCreationPage.canChangeUpperBound(false);
- this.queryCreationPage.canChangeQueryName(false);
- this.queryCreationPage.setFacetSet(getFacetSet());
- addPage(this.queryCreationPage);
- }
- }
-
- @Override
- public boolean canFinish() {
- return getContainer().getCurrentPage() == this.queryCreationPage && this.queryCreationPage.isPageComplete();
- }
-
- public int open() {
- if (this.dialog != null) {
- return this.dialog.open();
- }
- return Window.CANCEL;
- }
-
- public void setFacet(final Facet facet) {
- this.facetCreationPage.setFacet(facet);
- }
-
- public void setChildrenName(final String referenceName) {
- this.facetCreationPage.setChildrenName(referenceName);
- }
-
- public void setUpperBound(final int upperBound) {
- this.facetCreationPage.setUpperBound(upperBound);
- }
-
- public void setLowerBound(final int lowerBound) {
- this.facetCreationPage.setLowerBound(lowerBound);
- }
-
- public void setType(final EClass type) {
- this.facetCreationPage.setType(type);
- }
-
- public void canChangeFacet(final boolean canChange) {
- this.facetCreationPage.canChangeParentName(canChange);
- }
-
- public void canChangeChildrenName(final boolean canChange) {
- this.facetCreationPage.canChangeChildrenName(canChange);
- }
-
- public void canChangeUpperBound(final boolean canChange) {
- this.facetCreationPage.canChangeUpperBound(canChange);
- }
-
- public void canChangeLowerBound(final boolean canChange) {
- this.facetCreationPage.canChangeLowerBound(canChange);
- }
-
- public void canChangeType(final boolean canChange) {
- this.facetCreationPage.canChangeType(canChange);
- }
-
- public EditingDomain getEditingDomain() {
- return this.editingDomain;
- }
-
- protected final FacetSet getFacetSet() {
- return this.facetSet;
- }
-
- protected final CreateQueryWizardPage getQueryCreationPage() {
- return this.queryCreationPage;
- }
-
- protected void setFacetCreationPage(final AbstractFacetWizardPage facetCreationPage) {
- this.facetCreationPage = facetCreationPage;
- }
-
- protected ISelection getSelection() {
- return this.selection;
- }
-
- protected Map<String, IQueryCreationPagePart> getQueryTypeNameToQueryCreationPage() {
- return this.queryTypeNameToQueryCreationPage;
- }
-
- protected AbstractFacetWizardPage getFacetCreationPage() {
- return this.facetCreationPage;
- }
-}
+/** + * 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 349546 - EMF Facet facetSet editor + * Grégoire Dupe (Mia-Software) - Bug 373248 - Clean PMD errors + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards; + +import java.util.Map; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.window.Window; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.papyrus.emf.facet.efacet.Facet; +import org.eclipse.papyrus.emf.facet.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.IQueryCreationPagePartRegistry; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IFacetChildrenWizard; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.AbstractFacetWizardPage; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.CreateQueryWizardPage; + +@SuppressWarnings("PMD.ConstructorCallsOverridableMethod") +// @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") This class is +// deprecated, we won't then spend to many time to conforms to PMD rules. +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public abstract class AbstractAddFacetChildrenWizard extends Wizard implements IFacetChildrenWizard { + + private final ISelection selection; + private final EditingDomain editingDomain; + private final WizardDialog dialog; + private FacetSet facetSet; + private Facet facet; + private final Map<String, IQueryCreationPagePart> queryTypeNameToQueryCreationPage; + + private AbstractFacetWizardPage facetCreationPage; + private CreateQueryWizardPage queryCreationPage; + + public AbstractAddFacetChildrenWizard(final ISelection selection, final EditingDomain editingDomain) { + this.selection = selection; + this.editingDomain = editingDomain; + initializeSelection(); + this.queryTypeNameToQueryCreationPage = IQueryCreationPagePartRegistry.INSTANCE.getRegisteredWizardPageParts(); + this.dialog = new WizardDialog(getShell(), this); + addQueryCreationPage(); + } + + protected void addQueryCreationPage() { + this.queryCreationPage = new CreateQueryWizardPage(this.queryTypeNameToQueryCreationPage, getFacetSet(), this.facet); + } + + private void initializeSelection() { + if (this.selection != null && !this.selection.isEmpty() && this.selection instanceof IStructuredSelection) { + IStructuredSelection ssel = (IStructuredSelection) this.selection; + if (ssel.size() > 1) { + return; + } + Object obj = ssel.getFirstElement(); + if (obj instanceof FacetSet) { + this.facetSet = (FacetSet) obj; + } else { + if (obj instanceof Facet) { + this.facetSet = ((Facet) obj).getFacetSet(); + this.facet = (Facet) obj; + } + } + } + } + + @Override + public void addPages() { + if (this.facetCreationPage != null) { + addPage(this.facetCreationPage); + } + if (this.queryCreationPage != null) { + this.queryCreationPage.canChangeCanBeCached(false); + this.queryCreationPage.canChangeHasSideEffect(false); + this.queryCreationPage.canChangeLowerBound(false); + this.queryCreationPage.canChangeUpperBound(false); + this.queryCreationPage.canChangeQueryName(false); + this.queryCreationPage.setFacetSet(getFacetSet()); + addPage(this.queryCreationPage); + } + } + + @Override + public boolean canFinish() { + return getContainer().getCurrentPage() == this.queryCreationPage && this.queryCreationPage.isPageComplete(); + } + + public int open() { + if (this.dialog != null) { + return this.dialog.open(); + } + return Window.CANCEL; + } + + public void setFacet(final Facet facet) { + this.facetCreationPage.setFacet(facet); + } + + public void setChildrenName(final String referenceName) { + this.facetCreationPage.setChildrenName(referenceName); + } + + public void setUpperBound(final int upperBound) { + this.facetCreationPage.setUpperBound(upperBound); + } + + public void setLowerBound(final int lowerBound) { + this.facetCreationPage.setLowerBound(lowerBound); + } + + public void setType(final EClass type) { + this.facetCreationPage.setType(type); + } + + public void canChangeFacet(final boolean canChange) { + this.facetCreationPage.canChangeParentName(canChange); + } + + public void canChangeChildrenName(final boolean canChange) { + this.facetCreationPage.canChangeChildrenName(canChange); + } + + public void canChangeUpperBound(final boolean canChange) { + this.facetCreationPage.canChangeUpperBound(canChange); + } + + public void canChangeLowerBound(final boolean canChange) { + this.facetCreationPage.canChangeLowerBound(canChange); + } + + public void canChangeType(final boolean canChange) { + this.facetCreationPage.canChangeType(canChange); + } + + public EditingDomain getEditingDomain() { + return this.editingDomain; + } + + protected final FacetSet getFacetSet() { + return this.facetSet; + } + + protected final CreateQueryWizardPage getQueryCreationPage() { + return this.queryCreationPage; + } + + protected void setFacetCreationPage(final AbstractFacetWizardPage facetCreationPage) { + this.facetCreationPage = facetCreationPage; + } + + protected ISelection getSelection() { + return this.selection; + } + + protected Map<String, IQueryCreationPagePart> getQueryTypeNameToQueryCreationPage() { + return this.queryTypeNameToQueryCreationPage; + } + + protected AbstractFacetWizardPage getFacetCreationPage() { + return this.facetCreationPage; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetAttributeWizardImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetAttributeWizardImpl.java index 8dd3dd8d098..1b8eb2fd802 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetAttributeWizardImpl.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetAttributeWizardImpl.java @@ -1,76 +1,76 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.papyrus.emf.facet.efacet.EFacetFactory;
-import org.eclipse.papyrus.emf.facet.efacet.FacetAttribute;
-import org.eclipse.papyrus.emf.facet.efacet.Query;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetAction;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.AbstractFacetWizardPage;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.AddAttributeInFacetWizardPage;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.CreateQueryWizardPage;
-
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public class AddFacetAttributeWizardImpl extends AbstractAddFacetChildrenWizard {
-
- public AddFacetAttributeWizardImpl(final ISelection selection, final EditingDomain editingDomain) {
- super(selection, editingDomain);
- setWindowTitle(Messages.Add_an_Attribute);
- setFacetCreationPage(new AddAttributeInFacetWizardPage(getSelection(), getEditingDomain(), getQueryTypeNameToQueryCreationPage()));
- }
-
- @Override
- public boolean performFinish() {
- Query query = null;
- AbstractFacetWizardPage facetPage = getFacetCreationPage();
-
- if (facetPage.isSubTypingFacet()) {
- CreateQueryWizardPage queryPage = getQueryCreationPage();
-
- IQueryCreationPagePart iQueryPage = queryPage.getQueryCreationPage();
- iQueryPage.setCanBeCached(queryPage.getCanBeCached());
- iQueryPage.setHasSideEffect(queryPage.getHasSideEffect());
- iQueryPage.setQueryName(queryPage.getQueryName());
- iQueryPage.setLowerBound(queryPage.getLowerBound());
- iQueryPage.setUpperBound(queryPage.getUpperBound());
- iQueryPage.setQueryScope(facetPage.getFacet().getExtendedMetaclass());
- iQueryPage.setQueryType(facetPage.getType());
-
- iQueryPage.setUnique(facetPage.isUnique());
- iQueryPage.setOrdered(facetPage.isOrdered());
-
- query = iQueryPage.performFinish();
- }
-
- FacetAttribute facetAttribute = EFacetFactory.eINSTANCE.createFacetAttribute();
- facetAttribute.setName(facetPage.getChildrenName());
- facetAttribute.setEType(facetPage.getType());
- facetAttribute.setQuery(query);
- facetAttribute.setLowerBound(facetPage.getLowerBound());
- facetAttribute.setUpperBound(facetPage.getUpperBound());
-
- facetAttribute.setUnique(facetPage.isUnique());
- facetAttribute.setOrdered(facetPage.isOrdered());
- facetAttribute.setTransient(facetPage.isTransient());
- facetAttribute.setChangeable(facetPage.isChangeable());
- facetAttribute.setDerived(facetPage.isDerived());
- facetAttribute.setVolatile(facetPage.isVolatile());
-
- IFacetAction.INSTANCE.addAttributeInFacet(facetPage.getFacet(), facetAttribute, getEditingDomain());
- return true;
- }
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards; + +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.emf.facet.efacet.EFacetFactory; +import org.eclipse.papyrus.emf.facet.efacet.FacetAttribute; +import org.eclipse.papyrus.emf.facet.efacet.Query; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetAction; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.AbstractFacetWizardPage; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.AddAttributeInFacetWizardPage; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.CreateQueryWizardPage; + +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public class AddFacetAttributeWizardImpl extends AbstractAddFacetChildrenWizard { + + public AddFacetAttributeWizardImpl(final ISelection selection, final EditingDomain editingDomain) { + super(selection, editingDomain); + setWindowTitle(Messages.Add_an_Attribute); + setFacetCreationPage(new AddAttributeInFacetWizardPage(getSelection(), getEditingDomain(), getQueryTypeNameToQueryCreationPage())); + } + + @Override + public boolean performFinish() { + Query query = null; + AbstractFacetWizardPage facetPage = getFacetCreationPage(); + + if (facetPage.isSubTypingFacet()) { + CreateQueryWizardPage queryPage = getQueryCreationPage(); + + IQueryCreationPagePart iQueryPage = queryPage.getQueryCreationPage(); + iQueryPage.setCanBeCached(queryPage.getCanBeCached()); + iQueryPage.setHasSideEffect(queryPage.getHasSideEffect()); + iQueryPage.setQueryName(queryPage.getQueryName()); + iQueryPage.setLowerBound(queryPage.getLowerBound()); + iQueryPage.setUpperBound(queryPage.getUpperBound()); + iQueryPage.setQueryScope(facetPage.getFacet().getExtendedMetaclass()); + iQueryPage.setQueryType(facetPage.getType()); + + iQueryPage.setUnique(facetPage.isUnique()); + iQueryPage.setOrdered(facetPage.isOrdered()); + + query = iQueryPage.performFinish(); + } + + FacetAttribute facetAttribute = EFacetFactory.eINSTANCE.createFacetAttribute(); + facetAttribute.setName(facetPage.getChildrenName()); + facetAttribute.setEType(facetPage.getType()); + facetAttribute.setQuery(query); + facetAttribute.setLowerBound(facetPage.getLowerBound()); + facetAttribute.setUpperBound(facetPage.getUpperBound()); + + facetAttribute.setUnique(facetPage.isUnique()); + facetAttribute.setOrdered(facetPage.isOrdered()); + facetAttribute.setTransient(facetPage.isTransient()); + facetAttribute.setChangeable(facetPage.isChangeable()); + facetAttribute.setDerived(facetPage.isDerived()); + facetAttribute.setVolatile(facetPage.isVolatile()); + + IFacetAction.INSTANCE.addAttributeInFacet(facetPage.getFacet(), facetAttribute, getEditingDomain()); + return true; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetOperationParameterWizardImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetOperationParameterWizardImpl.java index 8e414427abc..cda592d1f1b 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetOperationParameterWizardImpl.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetOperationParameterWizardImpl.java @@ -1,60 +1,60 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards;
-
-import org.eclipse.emf.ecore.EParameter;
-import org.eclipse.emf.ecore.EcoreFactory;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.papyrus.emf.facet.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetAction;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.AbstractFacetWizardPage;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.AddOperationParameterInFacetWizardPage;
-
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public class AddFacetOperationParameterWizardImpl extends AbstractAddFacetChildrenWizard {
-
- public AddFacetOperationParameterWizardImpl(final ISelection selection, final EditingDomain editingDomain) {
- super(selection, editingDomain);
- setFacetCreationPage(new AddOperationParameterInFacetWizardPage(getSelection(), getEditingDomain()));
- setWindowTitle(Messages.Add_an_Operation_Parameter);
- }
-
- @Override
- protected void addQueryCreationPage() {
- // We do not want to create a query for the operation's parameter
- }
-
- @Override
- public boolean canFinish() {
- return getFacetCreationPage().isPageComplete();
- }
-
- @Override
- public boolean performFinish() {
- AbstractFacetWizardPage page = getFacetCreationPage();
- FacetOperation facetOperation = (FacetOperation) page.getQueryFacetElement();
-
- EParameter parameter = EcoreFactory.eINSTANCE.createEParameter();
- parameter.setName(page.getChildrenName());
- parameter.setEType(page.getType());
- parameter.setLowerBound(page.getLowerBound());
- parameter.setUpperBound(page.getUpperBound());
- parameter.setUnique(page.isUnique());
- parameter.setOrdered(page.isOrdered());
-
- IFacetAction.INSTANCE.addParameterInOperation(facetOperation, parameter, getEditingDomain());
- return true;
- }
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards; + +import org.eclipse.emf.ecore.EParameter; +import org.eclipse.emf.ecore.EcoreFactory; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.emf.facet.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetAction; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.AbstractFacetWizardPage; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.AddOperationParameterInFacetWizardPage; + +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public class AddFacetOperationParameterWizardImpl extends AbstractAddFacetChildrenWizard { + + public AddFacetOperationParameterWizardImpl(final ISelection selection, final EditingDomain editingDomain) { + super(selection, editingDomain); + setFacetCreationPage(new AddOperationParameterInFacetWizardPage(getSelection(), getEditingDomain())); + setWindowTitle(Messages.Add_an_Operation_Parameter); + } + + @Override + protected void addQueryCreationPage() { + // We do not want to create a query for the operation's parameter + } + + @Override + public boolean canFinish() { + return getFacetCreationPage().isPageComplete(); + } + + @Override + public boolean performFinish() { + AbstractFacetWizardPage page = getFacetCreationPage(); + FacetOperation facetOperation = (FacetOperation) page.getQueryFacetElement(); + + EParameter parameter = EcoreFactory.eINSTANCE.createEParameter(); + parameter.setName(page.getChildrenName()); + parameter.setEType(page.getType()); + parameter.setLowerBound(page.getLowerBound()); + parameter.setUpperBound(page.getUpperBound()); + parameter.setUnique(page.isUnique()); + parameter.setOrdered(page.isOrdered()); + + IFacetAction.INSTANCE.addParameterInOperation(facetOperation, parameter, getEditingDomain()); + return true; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetOperationWizardImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetOperationWizardImpl.java index 2105d744c31..d9807e678d2 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetOperationWizardImpl.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetOperationWizardImpl.java @@ -1,71 +1,71 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.papyrus.emf.facet.efacet.EFacetFactory;
-import org.eclipse.papyrus.emf.facet.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.Query;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetAction;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.AbstractFacetWizardPage;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.AddOperationInFacetWizardPage;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.CreateQueryWizardPage;
-
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public class AddFacetOperationWizardImpl extends AbstractAddFacetChildrenWizard {
-
- public AddFacetOperationWizardImpl(final ISelection selection, final EditingDomain editingDomain) {
- super(selection, editingDomain);
- setWindowTitle(Messages.Add_an_Operation);
- setFacetCreationPage(new AddOperationInFacetWizardPage(getSelection(), getEditingDomain(), getQueryTypeNameToQueryCreationPage()));
- }
-
- @Override
- public boolean performFinish() {
- Query conformanceQuery = null;
- AbstractFacetWizardPage facetPage = getFacetCreationPage();
-
- if (facetPage.isSubTypingFacet()) {
- CreateQueryWizardPage queryPage = getQueryCreationPage();
-
- IQueryCreationPagePart iQueryPage = queryPage.getQueryCreationPage();
- iQueryPage.setCanBeCached(queryPage.getCanBeCached());
- iQueryPage.setHasSideEffect(queryPage.getHasSideEffect());
- iQueryPage.setQueryName(queryPage.getQueryName());
- iQueryPage.setLowerBound(queryPage.getLowerBound());
- iQueryPage.setUpperBound(queryPage.getUpperBound());
- iQueryPage.setQueryScope(facetPage.getFacet().getExtendedMetaclass());
- iQueryPage.setQueryType(facetPage.getType());
-
- iQueryPage.setUnique(facetPage.isUnique());
- iQueryPage.setOrdered(facetPage.isOrdered());
-
- conformanceQuery = iQueryPage.performFinish();
- }
-
- FacetOperation facetOperation = EFacetFactory.eINSTANCE.createFacetOperation();
- facetOperation.setName(facetPage.getChildrenName());
- facetOperation.setEType(facetPage.getType());
- facetOperation.setQuery(conformanceQuery);
- facetOperation.setLowerBound(facetPage.getLowerBound());
- facetOperation.setUpperBound(facetPage.getUpperBound());
- facetOperation.setUnique(facetPage.isUnique());
- facetOperation.setOrdered(facetPage.isOrdered());
-
- IFacetAction.INSTANCE.addOperationInFacet(facetPage.getFacet(), facetOperation, getEditingDomain());
- return true;
- }
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards; + +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.emf.facet.efacet.EFacetFactory; +import org.eclipse.papyrus.emf.facet.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.Query; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetAction; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.AbstractFacetWizardPage; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.AddOperationInFacetWizardPage; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.CreateQueryWizardPage; + +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public class AddFacetOperationWizardImpl extends AbstractAddFacetChildrenWizard { + + public AddFacetOperationWizardImpl(final ISelection selection, final EditingDomain editingDomain) { + super(selection, editingDomain); + setWindowTitle(Messages.Add_an_Operation); + setFacetCreationPage(new AddOperationInFacetWizardPage(getSelection(), getEditingDomain(), getQueryTypeNameToQueryCreationPage())); + } + + @Override + public boolean performFinish() { + Query conformanceQuery = null; + AbstractFacetWizardPage facetPage = getFacetCreationPage(); + + if (facetPage.isSubTypingFacet()) { + CreateQueryWizardPage queryPage = getQueryCreationPage(); + + IQueryCreationPagePart iQueryPage = queryPage.getQueryCreationPage(); + iQueryPage.setCanBeCached(queryPage.getCanBeCached()); + iQueryPage.setHasSideEffect(queryPage.getHasSideEffect()); + iQueryPage.setQueryName(queryPage.getQueryName()); + iQueryPage.setLowerBound(queryPage.getLowerBound()); + iQueryPage.setUpperBound(queryPage.getUpperBound()); + iQueryPage.setQueryScope(facetPage.getFacet().getExtendedMetaclass()); + iQueryPage.setQueryType(facetPage.getType()); + + iQueryPage.setUnique(facetPage.isUnique()); + iQueryPage.setOrdered(facetPage.isOrdered()); + + conformanceQuery = iQueryPage.performFinish(); + } + + FacetOperation facetOperation = EFacetFactory.eINSTANCE.createFacetOperation(); + facetOperation.setName(facetPage.getChildrenName()); + facetOperation.setEType(facetPage.getType()); + facetOperation.setQuery(conformanceQuery); + facetOperation.setLowerBound(facetPage.getLowerBound()); + facetOperation.setUpperBound(facetPage.getUpperBound()); + facetOperation.setUnique(facetPage.isUnique()); + facetOperation.setOrdered(facetPage.isOrdered()); + + IFacetAction.INSTANCE.addOperationInFacet(facetPage.getFacet(), facetOperation, getEditingDomain()); + return true; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetReferenceWizardImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetReferenceWizardImpl.java index e468b8d404d..73b6419c084 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetReferenceWizardImpl.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/AddFacetReferenceWizardImpl.java @@ -1,78 +1,78 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.papyrus.emf.facet.efacet.EFacetFactory;
-import org.eclipse.papyrus.emf.facet.efacet.FacetReference;
-import org.eclipse.papyrus.emf.facet.efacet.Query;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetAction;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.AbstractFacetWizardPage;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.AddReferenceInFacetWizardPage;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.CreateQueryWizardPage;
-
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public class AddFacetReferenceWizardImpl extends AbstractAddFacetChildrenWizard {
-
- public AddFacetReferenceWizardImpl(final ISelection selection, final EditingDomain editingDomain) {
- super(selection, editingDomain);
- setWindowTitle(Messages.Add_a_Reference);
-
- setFacetCreationPage(new AddReferenceInFacetWizardPage(getSelection(), getEditingDomain(), getQueryTypeNameToQueryCreationPage()));
- }
-
- @Override
- public boolean performFinish() {
- Query conformanceQuery = null;
- AbstractFacetWizardPage facetPage = getFacetCreationPage();
-
- if (facetPage.isSubTypingFacet()) {
- CreateQueryWizardPage queryPage = getQueryCreationPage();
-
- IQueryCreationPagePart iQueryPage = queryPage.getQueryCreationPage();
- iQueryPage.setCanBeCached(queryPage.getCanBeCached());
- iQueryPage.setHasSideEffect(queryPage.getHasSideEffect());
- iQueryPage.setQueryName(queryPage.getQueryName());
- iQueryPage.setLowerBound(queryPage.getLowerBound());
- iQueryPage.setUpperBound(queryPage.getUpperBound());
- iQueryPage.setQueryScope(facetPage.getFacet().getExtendedMetaclass());
- iQueryPage.setQueryType(facetPage.getType());
-
- iQueryPage.setUnique(facetPage.isUnique());
- iQueryPage.setOrdered(facetPage.isOrdered());
-
- conformanceQuery = iQueryPage.performFinish();
- }
-
- FacetReference facetReference = EFacetFactory.eINSTANCE.createFacetReference();
- facetReference.setName(facetPage.getChildrenName());
- facetReference.setEType(facetPage.getType());
- facetReference.setQuery(conformanceQuery);
- facetReference.setLowerBound(facetPage.getLowerBound());
- facetReference.setUpperBound(facetPage.getUpperBound());
-
- facetReference.setUnique(facetPage.isUnique());
- facetReference.setOrdered(facetPage.isOrdered());
- facetReference.setTransient(facetPage.isTransient());
- facetReference.setChangeable(facetPage.isChangeable());
- facetReference.setDerived(facetPage.isDerived());
- facetReference.setVolatile(facetPage.isVolatile());
-
- IFacetAction.INSTANCE.addReferenceInFacet(facetPage.getFacet(), facetReference, getEditingDomain());
- return true;
- }
-
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards; + +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.emf.facet.efacet.EFacetFactory; +import org.eclipse.papyrus.emf.facet.efacet.FacetReference; +import org.eclipse.papyrus.emf.facet.efacet.Query; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetAction; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.AbstractFacetWizardPage; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.AddReferenceInFacetWizardPage; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.CreateQueryWizardPage; + +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public class AddFacetReferenceWizardImpl extends AbstractAddFacetChildrenWizard { + + public AddFacetReferenceWizardImpl(final ISelection selection, final EditingDomain editingDomain) { + super(selection, editingDomain); + setWindowTitle(Messages.Add_a_Reference); + + setFacetCreationPage(new AddReferenceInFacetWizardPage(getSelection(), getEditingDomain(), getQueryTypeNameToQueryCreationPage())); + } + + @Override + public boolean performFinish() { + Query conformanceQuery = null; + AbstractFacetWizardPage facetPage = getFacetCreationPage(); + + if (facetPage.isSubTypingFacet()) { + CreateQueryWizardPage queryPage = getQueryCreationPage(); + + IQueryCreationPagePart iQueryPage = queryPage.getQueryCreationPage(); + iQueryPage.setCanBeCached(queryPage.getCanBeCached()); + iQueryPage.setHasSideEffect(queryPage.getHasSideEffect()); + iQueryPage.setQueryName(queryPage.getQueryName()); + iQueryPage.setLowerBound(queryPage.getLowerBound()); + iQueryPage.setUpperBound(queryPage.getUpperBound()); + iQueryPage.setQueryScope(facetPage.getFacet().getExtendedMetaclass()); + iQueryPage.setQueryType(facetPage.getType()); + + iQueryPage.setUnique(facetPage.isUnique()); + iQueryPage.setOrdered(facetPage.isOrdered()); + + conformanceQuery = iQueryPage.performFinish(); + } + + FacetReference facetReference = EFacetFactory.eINSTANCE.createFacetReference(); + facetReference.setName(facetPage.getChildrenName()); + facetReference.setEType(facetPage.getType()); + facetReference.setQuery(conformanceQuery); + facetReference.setLowerBound(facetPage.getLowerBound()); + facetReference.setUpperBound(facetPage.getUpperBound()); + + facetReference.setUnique(facetPage.isUnique()); + facetReference.setOrdered(facetPage.isOrdered()); + facetReference.setTransient(facetPage.isTransient()); + facetReference.setChangeable(facetPage.isChangeable()); + facetReference.setDerived(facetPage.isDerived()); + facetReference.setVolatile(facetPage.isVolatile()); + + IFacetAction.INSTANCE.addReferenceInFacet(facetPage.getFacet(), facetReference, getEditingDomain()); + return true; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/CreateFacetInFacetSetWizardImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/CreateFacetInFacetSetWizardImpl.java index b782503ff20..f3f67028143 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/CreateFacetInFacetSetWizardImpl.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/CreateFacetInFacetSetWizardImpl.java @@ -1,163 +1,163 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards;
-
-import java.util.Map;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.papyrus.emf.facet.efacet.EFacetFactory;
-import org.eclipse.papyrus.emf.facet.efacet.Facet;
-import org.eclipse.papyrus.emf.facet.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.Query;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetAction;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.IQueryCreationPagePartRegistry;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.ICreateFacetInFacetSetWizard;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.CreateFacetInFacetSetWizardPage;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.CreateQueryWizardPage;
-
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public class CreateFacetInFacetSetWizardImpl extends Wizard implements ICreateFacetInFacetSetWizard {
-
- private WizardDialog dialog = null;
- private final CreateFacetInFacetSetWizardPage facetCreationPage;
- private final CreateQueryWizardPage queryCreationPage;
-
- private final ISelection selection;
- private final EditingDomain editingDomain;
-
- private FacetSet facetSet;
- private boolean canChangeFacetSet;
-
- private final Facet facet;
-
- private boolean canChangeExtendedMetaClass = true;
-
- private final Map<String, IQueryCreationPagePart> queryTypeNameToQueryCreationPage;
-
- public CreateFacetInFacetSetWizardImpl(final ISelection selection2, final EditingDomain editingDomain2) {
- super();
- this.facet = EFacetFactory.eINSTANCE.createFacet();
- setWindowTitle(Messages.Create_facet_in_facetSet);
- this.selection = selection2;
- initializeSelection();
- this.editingDomain = editingDomain2;
-
- this.queryTypeNameToQueryCreationPage = IQueryCreationPagePartRegistry.INSTANCE.getRegisteredWizardPageParts();
-
- this.dialog = new WizardDialog(getShell(), this);
-
- this.facetCreationPage = new CreateFacetInFacetSetWizardPage(this.facet, this.selection, this.editingDomain,
- this.queryTypeNameToQueryCreationPage);
-
- this.queryCreationPage = new CreateQueryWizardPage(this.queryTypeNameToQueryCreationPage, this.facetSet, this.facet);
-
- }
-
- private void initializeSelection() {
- if (this.selection != null && !this.selection.isEmpty() && this.selection instanceof IStructuredSelection) {
- IStructuredSelection ssel = (IStructuredSelection) this.selection;
- if (ssel.size() > 1) {
- return;
- }
- Object obj = ssel.getFirstElement();
- if (obj instanceof FacetSet) {
- this.facetSet = (FacetSet) obj;
- }
- }
- }
-
- @Override
- public void addPages() {
- this.facetCreationPage.setFacetSet(this.facetSet);
- this.facetCreationPage.canChangeParentName(this.canChangeFacetSet);
- this.facetCreationPage.setExtendedMetaClass(this.facet.getExtendedMetaclass());
- this.facetCreationPage.canChangeExtendedMetaClass(this.canChangeExtendedMetaClass);
- addPage(this.facetCreationPage);
-
- this.queryCreationPage.canChangeCanBeCached(false);
- this.queryCreationPage.canChangeHasSideEffect(false);
- this.queryCreationPage.canChangeLowerBound(false);
- this.queryCreationPage.canChangeUpperBound(false);
- this.queryCreationPage.canChangeQueryName(false);
- this.queryCreationPage.setFacetSet(this.facetSet);
- addPage(this.queryCreationPage);
- }
-
- @Override
- public boolean canFinish() {
- if (getContainer().getCurrentPage() == this.facetCreationPage && !this.facetCreationPage.isSubTypingFacet()
- && this.facetCreationPage.isPageComplete()) {
- return true;
- }
- return getContainer().getCurrentPage() == this.queryCreationPage && getContainer().getCurrentPage().isPageComplete();
- }
-
- public int open() {
- if (this.dialog != null) {
- return this.dialog.open();
- }
- return Window.CANCEL;
- }
-
- @Override
- public boolean performFinish() {
- final String facetName = this.facetCreationPage.getChildrenName();
- Query conformanceQuery = null;
- if (this.facetCreationPage.isSubTypingFacet()) {
- IQueryCreationPagePart iQueryPage = this.queryCreationPage.getQueryCreationPage();
- iQueryPage.setCanBeCached(this.queryCreationPage.getCanBeCached());
- iQueryPage.setHasSideEffect(this.queryCreationPage.getHasSideEffect());
- iQueryPage.setQueryName(this.queryCreationPage.getQueryName());
- iQueryPage.setLowerBound(this.queryCreationPage.getLowerBound());
- iQueryPage.setUpperBound(this.queryCreationPage.getUpperBound());
- iQueryPage.setQueryScope(this.facetCreationPage.getExtendedMetaclass());
- iQueryPage.setQueryType(EcorePackage.eINSTANCE.getEBoolean());
- conformanceQuery = iQueryPage.performFinish();
- }
-
- this.facet.setName(facetName);
- this.facet.setExtendedMetaclass(this.facetCreationPage.getExtendedMetaclass());
- this.facet.setConformanceQuery(conformanceQuery);
-
- IFacetAction.INSTANCE.createFacetInFacetSet(this.facetCreationPage.getFacetSet(), this.facet, this.editingDomain);
- return true;
- }
-
- public void setFacetSet(final FacetSet facetSet2) {
- this.facetSet = facetSet2;
- this.queryCreationPage.setFacetSet(facetSet2);
- }
-
- public void canChangeFacetSet(final boolean canChange) {
- this.canChangeFacetSet = canChange;
-
- }
-
- public void setExtendedMetaClass(final EClass extendedMetaClass) {
- this.facet.setExtendedMetaclass(extendedMetaClass);
-
- }
-
- public void canChangeExtendedMetaClass(final boolean canChange) {
- this.canChangeExtendedMetaClass = canChange;
- }
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards; + +import java.util.Map; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.window.Window; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.papyrus.emf.facet.efacet.EFacetFactory; +import org.eclipse.papyrus.emf.facet.efacet.Facet; +import org.eclipse.papyrus.emf.facet.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.Query; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetAction; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.IQueryCreationPagePartRegistry; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.ICreateFacetInFacetSetWizard; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.CreateFacetInFacetSetWizardPage; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.CreateQueryWizardPage; + +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public class CreateFacetInFacetSetWizardImpl extends Wizard implements ICreateFacetInFacetSetWizard { + + private WizardDialog dialog = null; + private final CreateFacetInFacetSetWizardPage facetCreationPage; + private final CreateQueryWizardPage queryCreationPage; + + private final ISelection selection; + private final EditingDomain editingDomain; + + private FacetSet facetSet; + private boolean canChangeFacetSet; + + private final Facet facet; + + private boolean canChangeExtendedMetaClass = true; + + private final Map<String, IQueryCreationPagePart> queryTypeNameToQueryCreationPage; + + public CreateFacetInFacetSetWizardImpl(final ISelection selection2, final EditingDomain editingDomain2) { + super(); + this.facet = EFacetFactory.eINSTANCE.createFacet(); + setWindowTitle(Messages.Create_facet_in_facetSet); + this.selection = selection2; + initializeSelection(); + this.editingDomain = editingDomain2; + + this.queryTypeNameToQueryCreationPage = IQueryCreationPagePartRegistry.INSTANCE.getRegisteredWizardPageParts(); + + this.dialog = new WizardDialog(getShell(), this); + + this.facetCreationPage = new CreateFacetInFacetSetWizardPage(this.facet, this.selection, this.editingDomain, + this.queryTypeNameToQueryCreationPage); + + this.queryCreationPage = new CreateQueryWizardPage(this.queryTypeNameToQueryCreationPage, this.facetSet, this.facet); + + } + + private void initializeSelection() { + if (this.selection != null && !this.selection.isEmpty() && this.selection instanceof IStructuredSelection) { + IStructuredSelection ssel = (IStructuredSelection) this.selection; + if (ssel.size() > 1) { + return; + } + Object obj = ssel.getFirstElement(); + if (obj instanceof FacetSet) { + this.facetSet = (FacetSet) obj; + } + } + } + + @Override + public void addPages() { + this.facetCreationPage.setFacetSet(this.facetSet); + this.facetCreationPage.canChangeParentName(this.canChangeFacetSet); + this.facetCreationPage.setExtendedMetaClass(this.facet.getExtendedMetaclass()); + this.facetCreationPage.canChangeExtendedMetaClass(this.canChangeExtendedMetaClass); + addPage(this.facetCreationPage); + + this.queryCreationPage.canChangeCanBeCached(false); + this.queryCreationPage.canChangeHasSideEffect(false); + this.queryCreationPage.canChangeLowerBound(false); + this.queryCreationPage.canChangeUpperBound(false); + this.queryCreationPage.canChangeQueryName(false); + this.queryCreationPage.setFacetSet(this.facetSet); + addPage(this.queryCreationPage); + } + + @Override + public boolean canFinish() { + if (getContainer().getCurrentPage() == this.facetCreationPage && !this.facetCreationPage.isSubTypingFacet() + && this.facetCreationPage.isPageComplete()) { + return true; + } + return getContainer().getCurrentPage() == this.queryCreationPage && getContainer().getCurrentPage().isPageComplete(); + } + + public int open() { + if (this.dialog != null) { + return this.dialog.open(); + } + return Window.CANCEL; + } + + @Override + public boolean performFinish() { + final String facetName = this.facetCreationPage.getChildrenName(); + Query conformanceQuery = null; + if (this.facetCreationPage.isSubTypingFacet()) { + IQueryCreationPagePart iQueryPage = this.queryCreationPage.getQueryCreationPage(); + iQueryPage.setCanBeCached(this.queryCreationPage.getCanBeCached()); + iQueryPage.setHasSideEffect(this.queryCreationPage.getHasSideEffect()); + iQueryPage.setQueryName(this.queryCreationPage.getQueryName()); + iQueryPage.setLowerBound(this.queryCreationPage.getLowerBound()); + iQueryPage.setUpperBound(this.queryCreationPage.getUpperBound()); + iQueryPage.setQueryScope(this.facetCreationPage.getExtendedMetaclass()); + iQueryPage.setQueryType(EcorePackage.eINSTANCE.getEBoolean()); + conformanceQuery = iQueryPage.performFinish(); + } + + this.facet.setName(facetName); + this.facet.setExtendedMetaclass(this.facetCreationPage.getExtendedMetaclass()); + this.facet.setConformanceQuery(conformanceQuery); + + IFacetAction.INSTANCE.createFacetInFacetSet(this.facetCreationPage.getFacetSet(), this.facet, this.editingDomain); + return true; + } + + public void setFacetSet(final FacetSet facetSet2) { + this.facetSet = facetSet2; + this.queryCreationPage.setFacetSet(facetSet2); + } + + public void canChangeFacetSet(final boolean canChange) { + this.canChangeFacetSet = canChange; + + } + + public void setExtendedMetaClass(final EClass extendedMetaClass) { + this.facet.setExtendedMetaclass(extendedMetaClass); + + } + + public void canChangeExtendedMetaClass(final boolean canChange) { + this.canChangeExtendedMetaClass = canChange; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/CreateFacetSetWizardImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/CreateFacetSetWizardImpl.java index 67b969a37fd..3494b66299a 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/CreateFacetSetWizardImpl.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/CreateFacetSetWizardImpl.java @@ -1,189 +1,189 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.papyrus.emf.facet.efacet.EFacetPackage;
-import org.eclipse.papyrus.emf.facet.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.core.IFacetAction;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.ICreateFacetSetWizard;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.utils.ImageProvider;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.CreateFacetSetWizardPage;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.FacetSetPropertyWizardPage;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.part.ISetSelectionTarget;
-
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public class CreateFacetSetWizardImpl extends Wizard implements INewWizard, ICreateFacetSetWizard {
-
- public static final String FILE_EXTENSION = "efacet"; //$NON-NLS-1$
-
- private final CreateFacetSetWizardPage newFileCreationPage;
- private final FacetSetPropertyWizardPage facetSetPropertyWizardPage;
-
- private IStructuredSelection selection;
-
- private IWorkbench workbench;
-
- private final WizardDialog dialog;
-
- private boolean openCreatedFacet = true;
-
- public CreateFacetSetWizardImpl() {
- this(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection());
- }
-
- public CreateFacetSetWizardImpl(final ISelection selection2, final boolean openCreatedFacetSet) {
- this(selection2);
- this.openCreatedFacet = openCreatedFacetSet;
- }
-
- public CreateFacetSetWizardImpl(final ISelection selection2) {
- super();
- this.dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), this);
- if (selection2 != null && selection2 instanceof IStructuredSelection) {
- this.selection = (IStructuredSelection) selection2;
- }
- setWindowTitle(Messages.Create_FacetSet_Model);
- ImageProvider.getInstance();
- setDefaultPageImageDescriptor(ImageProvider.getFacetIconDescriptor());
-
- this.newFileCreationPage = new CreateFacetSetWizardPage("Whatever", this.selection); //$NON-NLS-1$
-
- this.facetSetPropertyWizardPage = new FacetSetPropertyWizardPage(null);
- }
-
- public void init(final IWorkbench workbench2, final IStructuredSelection selection2) {
- this.workbench = workbench2;
- this.selection = selection2;
- }
-
- protected FacetSet createInitialFacet() {
- FacetSet facetSet = EFacetPackage.eINSTANCE.getEFacetFactory().createFacetSet();
- String modelFacetSetName = getModelFile().getName().replaceAll(".facetSet$", ""); //$NON-NLS-1$ //$NON-NLS-2$
- facetSet.setName(modelFacetSetName);
- facetSet.setNsURI(this.facetSetPropertyWizardPage.getNsUri());
- facetSet.setNsPrefix(this.facetSetPropertyWizardPage.getPrefix());
- facetSet.setExtendedEPackage(this.facetSetPropertyWizardPage.getFirstSelectedEPackage());
- return facetSet;
- }
-
- @Override
- public boolean performFinish() {
- if (this.facetSetPropertyWizardPage.isPageComplete()) {
- try {
- // Remember the file.
- //
- final IFile modelFile = getModelFile();
-
- // Do the work within an operation.
- //
- WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
- @Override
- protected void execute(final IProgressMonitor progressMonitor) {
- try {
- FacetSet facetSet = createInitialFacet();
- IFacetAction.INSTANCE.createFacetSet(facetSet, modelFile);
- } catch (Exception exception) {
- Logger.logError(exception, Activator.getDefault());
- } finally {
- progressMonitor.done();
- }
- }
- };
-
- getContainer().run(false, false, operation);
-
- if (this.openCreatedFacet) {
- // Select the new file resource in the current view.
- if (this.workbench == null) {
- this.workbench = PlatformUI.getWorkbench();
- }
- IWorkbenchWindow workbenchWindow = this.workbench.getActiveWorkbenchWindow();
- IWorkbenchPage page = workbenchWindow.getActivePage();
- final IWorkbenchPart activePart = page.getActivePart();
- if (activePart instanceof ISetSelectionTarget) {
- final ISelection targetSelection = new StructuredSelection(modelFile);
- getShell().getDisplay().asyncExec(new Runnable() {
- public void run() {
- ((ISetSelectionTarget) activePart).selectReveal(targetSelection);
- }
- });
- }
-
- // Open an editor on the new file.
- //
- try {
- page.openEditor(new FileEditorInput(modelFile),
- this.workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId());
- } catch (PartInitException exception) {
- MessageDialog.openError(workbenchWindow.getShell(), "Open Editor", exception.getMessage()); //$NON-NLS-1$
- return false;
- }
- }
-
- return true;
- } catch (Exception exception) {
- Logger.logError(exception, Activator.getDefault());
- return false;
- }
- }
- return false;
- }
-
- @Override
- public boolean canFinish() {
- return getContainer().getCurrentPage() == this.facetSetPropertyWizardPage && this.facetSetPropertyWizardPage.isPageComplete();
- }
-
- @Override
- public boolean isHelpAvailable() {
- return false;
- }
-
- @Override
- public void addPages() {
- addPage(this.newFileCreationPage);
- addPage(this.facetSetPropertyWizardPage);
- }
-
- public IFile getModelFile() {
- return this.newFileCreationPage.getModelFile();
- }
-
- public int open() {
- if (this.dialog != null) {
- return this.dialog.open();
- }
- return Window.CANCEL;
- }
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.window.Window; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.papyrus.emf.facet.efacet.EFacetPackage; +import org.eclipse.papyrus.emf.facet.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.core.IFacetAction; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.ICreateFacetSetWizard; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.utils.ImageProvider; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.CreateFacetSetWizardPage; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.FacetSetPropertyWizardPage; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.actions.WorkspaceModifyOperation; +import org.eclipse.ui.part.FileEditorInput; +import org.eclipse.ui.part.ISetSelectionTarget; + +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public class CreateFacetSetWizardImpl extends Wizard implements INewWizard, ICreateFacetSetWizard { + + public static final String FILE_EXTENSION = "efacet"; //$NON-NLS-1$ + + private final CreateFacetSetWizardPage newFileCreationPage; + private final FacetSetPropertyWizardPage facetSetPropertyWizardPage; + + private IStructuredSelection selection; + + private IWorkbench workbench; + + private final WizardDialog dialog; + + private boolean openCreatedFacet = true; + + public CreateFacetSetWizardImpl() { + this(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection()); + } + + public CreateFacetSetWizardImpl(final ISelection selection2, final boolean openCreatedFacetSet) { + this(selection2); + this.openCreatedFacet = openCreatedFacetSet; + } + + public CreateFacetSetWizardImpl(final ISelection selection2) { + super(); + this.dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), this); + if (selection2 != null && selection2 instanceof IStructuredSelection) { + this.selection = (IStructuredSelection) selection2; + } + setWindowTitle(Messages.Create_FacetSet_Model); + ImageProvider.getInstance(); + setDefaultPageImageDescriptor(ImageProvider.getFacetIconDescriptor()); + + this.newFileCreationPage = new CreateFacetSetWizardPage("Whatever", this.selection); //$NON-NLS-1$ + + this.facetSetPropertyWizardPage = new FacetSetPropertyWizardPage(null); + } + + public void init(final IWorkbench workbench2, final IStructuredSelection selection2) { + this.workbench = workbench2; + this.selection = selection2; + } + + protected FacetSet createInitialFacet() { + FacetSet facetSet = EFacetPackage.eINSTANCE.getEFacetFactory().createFacetSet(); + String modelFacetSetName = getModelFile().getName().replaceAll(".facetSet$", ""); //$NON-NLS-1$ //$NON-NLS-2$ + facetSet.setName(modelFacetSetName); + facetSet.setNsURI(this.facetSetPropertyWizardPage.getNsUri()); + facetSet.setNsPrefix(this.facetSetPropertyWizardPage.getPrefix()); + facetSet.setExtendedEPackage(this.facetSetPropertyWizardPage.getFirstSelectedEPackage()); + return facetSet; + } + + @Override + public boolean performFinish() { + if (this.facetSetPropertyWizardPage.isPageComplete()) { + try { + // Remember the file. + // + final IFile modelFile = getModelFile(); + + // Do the work within an operation. + // + WorkspaceModifyOperation operation = new WorkspaceModifyOperation() { + @Override + protected void execute(final IProgressMonitor progressMonitor) { + try { + FacetSet facetSet = createInitialFacet(); + IFacetAction.INSTANCE.createFacetSet(facetSet, modelFile); + } catch (Exception exception) { + Logger.logError(exception, Activator.getDefault()); + } finally { + progressMonitor.done(); + } + } + }; + + getContainer().run(false, false, operation); + + if (this.openCreatedFacet) { + // Select the new file resource in the current view. + if (this.workbench == null) { + this.workbench = PlatformUI.getWorkbench(); + } + IWorkbenchWindow workbenchWindow = this.workbench.getActiveWorkbenchWindow(); + IWorkbenchPage page = workbenchWindow.getActivePage(); + final IWorkbenchPart activePart = page.getActivePart(); + if (activePart instanceof ISetSelectionTarget) { + final ISelection targetSelection = new StructuredSelection(modelFile); + getShell().getDisplay().asyncExec(new Runnable() { + public void run() { + ((ISetSelectionTarget) activePart).selectReveal(targetSelection); + } + }); + } + + // Open an editor on the new file. + // + try { + page.openEditor(new FileEditorInput(modelFile), + this.workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId()); + } catch (PartInitException exception) { + MessageDialog.openError(workbenchWindow.getShell(), "Open Editor", exception.getMessage()); //$NON-NLS-1$ + return false; + } + } + + return true; + } catch (Exception exception) { + Logger.logError(exception, Activator.getDefault()); + return false; + } + } + return false; + } + + @Override + public boolean canFinish() { + return getContainer().getCurrentPage() == this.facetSetPropertyWizardPage && this.facetSetPropertyWizardPage.isPageComplete(); + } + + @Override + public boolean isHelpAvailable() { + return false; + } + + @Override + public void addPages() { + addPage(this.newFileCreationPage); + addPage(this.facetSetPropertyWizardPage); + } + + public IFile getModelFile() { + return this.newFileCreationPage.getModelFile(); + } + + public int open() { + if (this.dialog != null) { + return this.dialog.open(); + } + return Window.CANCEL; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/SelectETypeWizardImpl.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/SelectETypeWizardImpl.java index 475e0a7fee0..899086ba26a 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/SelectETypeWizardImpl.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/SelectETypeWizardImpl.java @@ -1,82 +1,82 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards;
-
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.SelectETypeComposite.ETypeSelectionOptions;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.ISelectETypeWizard;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.SelectEClassifierWizardPage;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.SelectEPackageWizardPage;
-import org.eclipse.ui.PlatformUI;
-
-public class SelectETypeWizardImpl extends Wizard implements ISelectETypeWizard {
-
- private final WizardDialog dialog;
-
- private final SelectEPackageWizardPage selectEPackagePage;
- private final SelectEClassifierWizardPage selectETypePage;
-
- private final EditingDomain editingDomain;
-
- private EClassifier selectedEType;
-
- private boolean canChangeEPackage = true;
-
- public SelectETypeWizardImpl(final EditingDomain editingDomain, final ETypeSelectionOptions eTypeSelectionOption,
- final boolean canChangeEPackage, final EPackage ePackage) {
- super();
- this.editingDomain = editingDomain;
- this.canChangeEPackage = canChangeEPackage;
- this.dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), this);
- this.selectEPackagePage = new SelectEPackageWizardPage(this.editingDomain);
- this.selectETypePage = new SelectEClassifierWizardPage(eTypeSelectionOption, ePackage);
- if (eTypeSelectionOption == ETypeSelectionOptions.ECLASS) {
- setWindowTitle(Messages.Select_EClass);
- } else if (eTypeSelectionOption == ETypeSelectionOptions.EDATATYPE) {
- setWindowTitle(Messages.Select_EDataType);
- } else {
- setWindowTitle(Messages.Select_EClassifier);
- }
- }
-
- @Override
- public void addPages() {
- if (this.canChangeEPackage) {
- addPage(this.selectEPackagePage);
- }
- addPage(this.selectETypePage);
- }
-
- public int open() {
- if (this.dialog != null) {
- return this.dialog.open();
- }
- return Window.CANCEL;
- }
-
- @Override
- public boolean performFinish() {
- this.selectedEType = this.selectETypePage.getSelectedEclassifier();
- return true;
- }
-
- public EClassifier getSelectedEType() {
- return this.selectedEType;
- }
-
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards; + +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.jface.window.Window; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.SelectETypeComposite.ETypeSelectionOptions; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.ISelectETypeWizard; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.SelectEClassifierWizardPage; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages.SelectEPackageWizardPage; +import org.eclipse.ui.PlatformUI; + +public class SelectETypeWizardImpl extends Wizard implements ISelectETypeWizard { + + private final WizardDialog dialog; + + private final SelectEPackageWizardPage selectEPackagePage; + private final SelectEClassifierWizardPage selectETypePage; + + private final EditingDomain editingDomain; + + private EClassifier selectedEType; + + private boolean canChangeEPackage = true; + + public SelectETypeWizardImpl(final EditingDomain editingDomain, final ETypeSelectionOptions eTypeSelectionOption, + final boolean canChangeEPackage, final EPackage ePackage) { + super(); + this.editingDomain = editingDomain; + this.canChangeEPackage = canChangeEPackage; + this.dialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), this); + this.selectEPackagePage = new SelectEPackageWizardPage(this.editingDomain); + this.selectETypePage = new SelectEClassifierWizardPage(eTypeSelectionOption, ePackage); + if (eTypeSelectionOption == ETypeSelectionOptions.ECLASS) { + setWindowTitle(Messages.Select_EClass); + } else if (eTypeSelectionOption == ETypeSelectionOptions.EDATATYPE) { + setWindowTitle(Messages.Select_EDataType); + } else { + setWindowTitle(Messages.Select_EClassifier); + } + } + + @Override + public void addPages() { + if (this.canChangeEPackage) { + addPage(this.selectEPackagePage); + } + addPage(this.selectETypePage); + } + + public int open() { + if (this.dialog != null) { + return this.dialog.open(); + } + return Window.CANCEL; + } + + @Override + public boolean performFinish() { + this.selectedEType = this.selectETypePage.getSelectedEclassifier(); + return true; + } + + public EClassifier getSelectedEType() { + return this.selectedEType; + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AbstractFacetWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AbstractFacetWizardPage.java index 516e06fee59..54d189cc06d 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AbstractFacetWizardPage.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AbstractFacetWizardPage.java @@ -1,786 +1,786 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- * Gregoire Dupe (Mia-Software) - Bug 373248 - Clean PMD errors
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages;
-
-import java.util.Map;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.papyrus.emf.facet.efacet.Facet;
-import org.eclipse.papyrus.emf.facet.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.QueryFacetElement;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.SelectETypeComposite;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.SelectETypeComposite.ETypeSelectionOptions;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.SelectQueryTypeComposite;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.papyrus.emf.facet.widgets.celleditors.AbstractCellEditorComposite;
-import org.eclipse.papyrus.emf.facet.widgets.celleditors.ICompositeEditorFactory;
-import org.eclipse.papyrus.emf.facet.widgets.celleditors.core.composite.registries.ICompositeEditorFactoriesRegistry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-@SuppressWarnings("PMD.ConstructorCallsOverridableMethod")
-// @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") This class is
-// deprecated, we won't then spend to many time to conforms to PMD rules.
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public abstract class AbstractFacetWizardPage extends WizardPage {
-
- private static final int QUERY_SELECTION_GROUP_COLUMN_NUMBER = 4;
- private static final int NUMBER_COLUMN_PROPERTY = 3;
- protected static final int NUMBER_COLUMN = 3;
- protected static final int VERTICAL_SPACING = 9;
-
- private ISelection selection;
- private EditingDomain editingDomain;
-
- // USER PERMISSION
- private boolean canChangeParentName = true;
- private boolean canChangeChildrenName = true;
- private boolean canChangeUpperBound = true;
- private boolean canChangeLowerBound = true;
- private boolean canChangeType = true;
- private final boolean canChangeVolatile = false;
- private final boolean canChangeChangeable = false;
- private final boolean canChangeDerived = false;
- private final boolean canChangeTransient = false;
- private final boolean canChangeOrdered = true;
- private final boolean canChangeUnique = true;
- private boolean canChangeEPackage = true;
-
- private boolean showUpperBound = true;
- private boolean showLowerBound = true;
- private boolean showParentName = true;
- private boolean showChildrenName = true;
- private boolean showQueryTypeSelection = true;
- private boolean showEType = true;
- private boolean showVolatile = true;
- private boolean showChangeable = true;
- private boolean showDerived = true;
- private boolean showTransient = true;
- private boolean showOrdered = true;
- private boolean showUnique = true;
-
- // DATA
- private FacetSet facetSet;
- private Facet facet;
- private String facetName;
- private QueryFacetElement queryFacetElement;
- private EClass type;
- private String parentName = ""; //$NON-NLS-1$
- private String childrenName = ""; //$NON-NLS-1$
- private int lowerBound;
- private int upperBound;
- private boolean fVolatile = true;
- private boolean fChangeable = false;
- private boolean fDerived = true;
- private boolean fTransient = true;
- private boolean fOrdered = false;
- private boolean fUnique = false;
-
- // COMPOSITE
- private Label parentNameLabel;
- private Label childrenNameLabel;
- private Label lowerBoundLabel;
- private Label upperBoundLabel;
- private SelectETypeComposite selectETypeComposite;
- private Text parentNameTextField;
- private Text childrenNameTextField;
- private AbstractCellEditorComposite<Integer> lowerBoundTextField;
- private AbstractCellEditorComposite<Integer> upperBoundTextField;
- private SelectQueryTypeComposite selectQueryTypeComposite;
- private Button subClassingQueryButton;
-
- private Map<String, IQueryCreationPagePart> queryTypeNameToWizardPage;
- private boolean wizardNeedsQuery = true;
- private ETypeSelectionOptions eTypeSelectionOption;
-
- public AbstractFacetWizardPage(final ISelection selection, final EditingDomain editingDomain,
- final Map<String, IQueryCreationPagePart> queryTypeNameToWizardPage,
- final ETypeSelectionOptions eTypeSelectionOption) {
- this(selection, editingDomain);
- this.queryTypeNameToWizardPage = queryTypeNameToWizardPage;
- this.eTypeSelectionOption = eTypeSelectionOption;
- }
-
- public AbstractFacetWizardPage(final ISelection selection, final EditingDomain editingDomain) {
- super("whatever"); //$NON-NLS-1$
- this.selection = selection;
- this.editingDomain = editingDomain;
- initializeWithSelection();
- }
-
- @Override
- public void setVisible(final boolean visible) {
- updatePageButtons();
- super.setVisible(visible);
- }
-
- protected Composite createControlParts(final Composite parent) {
-
- final Composite threeColumnContainer = new Composite(parent, SWT.NONE);
- GridLayout layout3Column = new GridLayout(AbstractFacetWizardPage.NUMBER_COLUMN, false);
- threeColumnContainer.setLayout(layout3Column);
- GridData fillGridData = new GridData(GridData.FILL_HORIZONTAL);
-
- threeColumnContainer.setLayoutData(fillGridData);
-
- if (this.showParentName) {
- this.parentNameLabel = new Label(threeColumnContainer, SWT.NONE);
- this.parentNameTextField = new Text(threeColumnContainer, SWT.BORDER | SWT.SINGLE);
- this.parentNameTextField.setText(this.parentName);
- this.parentNameTextField.setEnabled(this.canChangeParentName);
- this.parentNameTextField.setLayoutData(fillGridData);
- this.parentNameTextField.addModifyListener(new ModifyListener() {
- public void modifyText(final ModifyEvent e) {
- setParentName(((Text) e.getSource()).getText(), false);
- updatePageButtons();
- }
- });
- Label dummyLabel = new Label(threeColumnContainer, SWT.NONE);
- dummyLabel.setText(""); //$NON-NLS-1$
- }
-
- if (this.showChildrenName) {
- this.childrenNameLabel = new Label(threeColumnContainer, SWT.NONE);
- this.childrenNameTextField = new Text(threeColumnContainer, SWT.BORDER | SWT.SINGLE);
- this.childrenNameTextField.setText(this.childrenName);
- this.childrenNameTextField.setEnabled(canChangeChildrenName());
- this.childrenNameTextField.setLayoutData(fillGridData);
- this.childrenNameTextField.addModifyListener(new ModifyListener() {
- public void modifyText(final ModifyEvent e) {
- setChildrenName(((Text) e.getSource()).getText());
- updatePageButtons();
- }
- });
- Label dummyLabel2 = new Label(threeColumnContainer, SWT.NONE);
- dummyLabel2.setText(""); //$NON-NLS-1$
- }
- ICompositeEditorFactory<Integer> compositeFactory = ICompositeEditorFactoriesRegistry.INSTANCE
- .getCompositeEditorFactory(Integer.class);
- if (this.showLowerBound) {
- this.lowerBoundLabel = new Label(threeColumnContainer, SWT.NONE);
- this.lowerBoundTextField = compositeFactory.createCompositeEditor(threeColumnContainer, SWT.BORDER
- | SWT.SINGLE);
- this.lowerBoundTextField.setLayoutData(fillGridData);
- this.lowerBoundTextField.setEnabled(canChangeLowerBound());
- setLowerBound(this.lowerBound);
- Label dummyLabel5 = new Label(threeColumnContainer, SWT.NONE);
- dummyLabel5.setText(""); //$NON-NLS-1$
- }
- if (this.showUpperBound) {
- this.upperBoundLabel = new Label(threeColumnContainer, SWT.NONE);
- this.upperBoundTextField = compositeFactory.createCompositeEditor(threeColumnContainer, SWT.BORDER
- | SWT.SINGLE);
- this.upperBoundTextField.setLayoutData(fillGridData);
- this.upperBoundTextField.setEnabled(this.canChangeUpperBound);
- setUpperBound(this.upperBound);
- Label dummyLabel6 = new Label(threeColumnContainer, SWT.NONE);
- dummyLabel6.setText(""); //$NON-NLS-1$
- }
- if (this.showEType) {
- this.selectETypeComposite = new SelectETypeComposite(parent, SWT.NONE, this.eTypeSelectionOption,
- this.canChangeEPackage, this.facetSet) {
- @Override
- protected void createCompositeWidget() {
- setETypeLabel(new Label(threeColumnContainer, SWT.NULL));
- setETypedTextField(new Text(threeColumnContainer, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY));
- setSelectButton(new Button(threeColumnContainer, SWT.PUSH));
- }
-
- @Override
- protected void eTypeSelected() {
- updatePageButtons();
- }
- };
- if (this.type != null) {
- this.selectETypeComposite.setEType(this.type);
- }
- this.selectETypeComposite.setEditingDomain(getEditingDomain());
- this.selectETypeComposite.canChangeEType(this.canChangeType);
- }
-
- createPropertyControls(threeColumnContainer);
-
- if (this.wizardNeedsQuery) {
- createQueryComposite(parent, threeColumnContainer);
- }
- return threeColumnContainer;
- }
-
- /**
- * @param parent
- * @param threeColumnContainer
- */
- protected void createQueryComposite(final Composite parent, final Composite threeColumnContainer) {
- if (this.showQueryTypeSelection) {
- final Group group = new Group(threeColumnContainer, SWT.SHADOW_ETCHED_OUT);
- group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, AbstractFacetWizardPage.NUMBER_COLUMN, 1));
- group.setLayout(new GridLayout(AbstractFacetWizardPage.QUERY_SELECTION_GROUP_COLUMN_NUMBER, false));
- Label subClassingQueryButtonText = new Label(group, SWT.NONE);
- subClassingQueryButtonText.setText(Messages.CreateFacetInFacetSetWizardPage_Sub_Typing_Facet);
-
- this.subClassingQueryButton = new Button(group, SWT.CHECK);
- this.subClassingQueryButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- this.subClassingQueryButton.addSelectionListener(new SelectionListener() {
- public void widgetSelected(final SelectionEvent e) {
- setQueryTypeSelectionVisible(getSubClassingQueryButton().getSelection());
- updatePageButtons();
- }
-
- public void widgetDefaultSelected(final SelectionEvent e) {
- // nothing
- }
- });
-
- // Query Type Composite
- this.selectQueryTypeComposite = new SelectQueryTypeComposite(parent, SWT.NONE) {
- @Override
- protected void createCompositeWidget() {
- setQueryTypeLabel(new Label(group, SWT.NONE));
- setQueryTypeComboBox(new Combo(group, SWT.DROP_DOWN));
- }
-
- @Override
- protected void queryTypeSelected() {
- updatePageButtons();
- }
- };
-
- setQueryTypeSelectionVisible(false);
- } else {
- // Query Type Composite
- this.selectQueryTypeComposite = new SelectQueryTypeComposite(parent, SWT.NONE) {
- @Override
- protected void createCompositeWidget() {
- setQueryTypeLabel(new Label(threeColumnContainer, SWT.NONE));
- setQueryTypeComboBox(new Combo(threeColumnContainer, SWT.DROP_DOWN | SWT.READ_ONLY));
- }
-
- @Override
- protected void queryTypeSelected() {
- updatePageButtons();
- }
- };
- }
- }
-
- /**
- * @param threeColumnContainer
- */
- protected void createPropertyControls(final Composite threeColumnContainer) {
- Label dummyLabel = new Label(threeColumnContainer, SWT.NONE);
- dummyLabel.setText(""); //$NON-NLS-1$
- Composite composite = new Composite(threeColumnContainer, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = AbstractFacetWizardPage.NUMBER_COLUMN_PROPERTY;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
- if (this.showVolatile) {
- final Button button = new Button(composite, SWT.CHECK);
- button.setText(Messages.Volatile);
- button.setEnabled(this.canChangeVolatile);
- button.setSelection(this.fVolatile);
- button.addSelectionListener(new SelectionListener() {
- public void widgetSelected(final SelectionEvent e) {
- setVolatile(button.getSelection());
- }
-
- public void widgetDefaultSelected(final SelectionEvent e) {
- // Nothing
- }
- });
- }
- if (this.showChangeable) {
- final Button button = new Button(composite, SWT.CHECK);
- button.setText(Messages.Changeable);
- button.setSelection(this.fChangeable);
- button.setEnabled(this.canChangeChangeable);
- button.addSelectionListener(new SelectionListener() {
- public void widgetSelected(final SelectionEvent e) {
- setChangeable(button.getSelection());
- }
-
- public void widgetDefaultSelected(final SelectionEvent e) {
- // Nothing
- }
- });
- }
- if (this.showDerived) {
- final Button button = new Button(composite, SWT.CHECK);
- button.setText(Messages.Derived);
- button.setEnabled(this.canChangeDerived);
- button.setSelection(this.fDerived);
- button.addSelectionListener(new SelectionListener() {
- public void widgetSelected(final SelectionEvent e) {
- setDerived(button.getSelection());
- }
-
- public void widgetDefaultSelected(final SelectionEvent e) {
- // Nothing
- }
- });
- }
- if (this.showTransient) {
- final Button button = new Button(composite, SWT.CHECK);
- button.setText(Messages.Transient);
- button.setEnabled(this.canChangeTransient);
- button.setSelection(this.fTransient);
- button.addSelectionListener(new SelectionListener() {
- public void widgetSelected(final SelectionEvent e) {
- setTransient(button.getSelection());
- }
-
- public void widgetDefaultSelected(final SelectionEvent e) {
- // Nothing
- }
- });
- }
- if (this.showOrdered) {
- final Button button = new Button(composite, SWT.CHECK);
- button.setText(Messages.Ordered);
- button.setSelection(this.fOrdered);
- button.setEnabled(this.canChangeOrdered);
- button.addSelectionListener(new SelectionListener() {
- public void widgetSelected(final SelectionEvent e) {
- setOrdered(button.getSelection());
- }
-
- public void widgetDefaultSelected(final SelectionEvent e) {
- // Nothing
- }
- });
- }
- if (this.showUnique) {
- final Button button = new Button(composite, SWT.CHECK);
- button.setText(Messages.Unique);
- button.setSelection(this.fUnique);
- button.setEnabled(this.canChangeUnique);
- button.addSelectionListener(new SelectionListener() {
- public void widgetSelected(final SelectionEvent e) {
- setUnique(button.getSelection());
- }
-
- public void widgetDefaultSelected(final SelectionEvent e) {
- // Nothing
- }
- });
- }
- }
-
- public boolean isSubTypingFacet() {
- if (getSubClassingQueryButton() == null) {
- return true;
- }
- return getSubClassingQueryButton().getSelection();
- }
-
- protected void initializeWithSelection() {
- if (getSelection() != null && !getSelection().isEmpty() && getSelection() instanceof IStructuredSelection) {
- IStructuredSelection ssel = (IStructuredSelection) getSelection();
- if (ssel.size() > 1) {
- return;
- }
- Object obj = ssel.getFirstElement();
- if (obj instanceof Facet) {
- setFacet((Facet) obj);
- setFacetSet(((Facet) obj).getFacetSet());
- if (((Facet) obj).getName() != null) {
- setParentName(((Facet) obj).getName(), true);
- }
- }
- }
- }
-
- @Override
- public IWizardPage getNextPage() {
- if (this.showQueryTypeSelection) {
- if (this.queryTypeNameToWizardPage != null && this.subClassingQueryButton != null) {
- if (this.subClassingQueryButton.getSelection()) {
- IQueryCreationPagePart wizard = this.queryTypeNameToWizardPage.get(getSelectedQueryType());
- if (wizard != null) {
- return super.getNextPage();
- }
- setErrorMessage(Messages.SelectQueryTypeWizardPage_No_wizard_found);
- }
- }
- } else {
- if (this.queryTypeNameToWizardPage != null) {
- IQueryCreationPagePart wizard = this.queryTypeNameToWizardPage.get(getSelectedQueryType());
- if (wizard != null) {
- return super.getNextPage();
- }
- setErrorMessage(Messages.SelectQueryTypeWizardPage_No_wizard_found);
- }
- }
- return null;
- }
-
- @Override
- protected void setControl(final Control newControl) {
- updatePageButtons();
- super.setControl(newControl);
- }
-
- protected void setQueryTypeSelectionVisible(final boolean visible) {
- this.selectQueryTypeComposite.setEnabled(visible);
- }
-
- public String getSelectedQueryType() {
- return this.selectQueryTypeComposite.getSelectedQueryType();
- }
-
- protected void updatePageButtons() {
- if (getContainer() != null && getContainer().getCurrentPage() != null) {
- getContainer().updateButtons();
- }
- }
-
- public void initializeTextContent(final String parentName2, final String childrenName2) {
- if (parentName2 != null) {
- this.parentNameLabel.setText(parentName2);
- }
- this.childrenNameLabel.setText(childrenName2);
- if (this.showLowerBound) {
- this.lowerBoundLabel.setText(Messages.Lower_bound);
- }
- if (this.showUpperBound) {
- this.upperBoundLabel.setText(Messages.Upper_bound);
- }
- }
-
- @Override
- public boolean isPageComplete() {
- if (getChildrenName() == null) {
- return false;
- }
- if (this.showChildrenName && getChildrenName().length() == 0) {
- setErrorMessage(NLS.bind(Messages.Please_enter_value_for, this.childrenNameLabel.getText()));
- return false;
- }
- if (this.showLowerBound && this.lowerBoundTextField.getValue() == null) {
- setErrorMessage(NLS.bind(Messages.Please_enter_value_for, this.lowerBoundLabel.getText()));
- return false;
- }
- if (this.showUpperBound && this.upperBoundTextField.getValue() == null) {
- setErrorMessage(NLS.bind(Messages.Please_enter_value_for, this.upperBoundLabel.getText()));
- return false;
- }
- if (this.showEType && getType() == null) {
- setErrorMessage(NLS.bind(Messages.Please_enter_value_for, "Type")); //$NON-NLS-1$
- return false;
- }
- if (this.wizardNeedsQuery) {
- if (this.subClassingQueryButton != null && !this.subClassingQueryButton.getSelection()) {
- setErrorMessage(null);
- return true;
- }
- if (getNextPage() == null) {
- setErrorMessage(Messages.CreateFacetInFacetSetWizardPage_could_not_find_wizard_page);
- return false;
- }
- }
- setErrorMessage(null);
- return true;
- }
-
- // CanChange section
- public void canChangeParentName(final boolean canChange) {
- this.canChangeParentName = canChange;
- }
-
- public boolean canChangeParentName() {
- return this.canChangeParentName;
- }
-
- public void canChangeChildrenName(final boolean canChange) {
- this.canChangeChildrenName = canChange;
- }
-
- public boolean canChangeChildrenName() {
- return this.canChangeChildrenName;
- }
-
- public void canChangeUpperBound(final boolean canChange) {
- this.canChangeUpperBound = canChange;
- }
-
- public boolean canChangeUpperBound() {
- return this.canChangeUpperBound;
- }
-
- public void canChangeLowerBound(final boolean canChange) {
- this.canChangeLowerBound = canChange;
- }
-
- public boolean canChangeLowerBound() {
- return this.canChangeLowerBound;
- }
-
- public void canChangeType(final boolean canChange) {
- this.canChangeType = canChange;
- }
-
- public boolean canChangeType() {
- return this.canChangeType;
- }
-
- public void canChangeEPackage(final boolean canChangeEPackage2) {
- this.canChangeEPackage = canChangeEPackage2;
- }
-
- public EditingDomain getEditingDomain() {
- return this.editingDomain;
- }
-
- public void setEditingDomain(final EditingDomain editingDomain) {
- this.editingDomain = editingDomain;
- }
-
- public final ISelection getSelection() {
- return this.selection;
- }
-
- public void setSelection(final ISelection selection) {
- this.selection = selection;
- }
-
- public final FacetSet getFacetSet() {
- return this.facetSet;
- }
-
- public final void setFacetSet(final FacetSet facetSet) {
- this.facetSet = facetSet;
- }
-
- public Facet getFacet() {
- return this.facet;
- }
-
- public final void setFacet(final Facet facet) {
- this.facet = facet;
- }
-
- public String getFacetName() {
- return this.facetName;
- }
-
- public void setFacetName(final String facetName) {
- this.facetName = facetName;
- }
-
- public int getLowerBound() {
- try {
- return (this.lowerBoundTextField.getValue()).intValue();
- } catch (Exception e) {
- Logger.logError(e, Activator.getDefault());
- }
- return 0;
- }
-
- public void setLowerBound(final int lowerBound) {
- this.lowerBound = lowerBound;
- if (this.lowerBoundTextField != null) {
- (this.lowerBoundTextField).setValue(Integer.valueOf(lowerBound));
- }
- }
-
- public int getUpperBound() {
- try {
- return (this.upperBoundTextField.getValue()).intValue();
- } catch (Exception e) {
- Logger.logError(e, Activator.getDefault());
- }
- return 0;
- }
-
- public void setUpperBound(final int upperBound) {
- this.upperBound = upperBound;
- if (this.upperBoundTextField != null) {
- this.upperBoundTextField.setValue(Integer.valueOf(upperBound));
- }
- }
-
- public EClassifier getType() {
- return this.selectETypeComposite.getEType();
- }
-
- public void setType(final EClass eType) {
- this.type = eType;
- if (this.selectETypeComposite != null) {
- this.selectETypeComposite.setEType(eType);
- }
- }
-
- public String getParentName() {
- return this.parentName;
- }
-
- /**
- * Set the parent(container) name
- *
- * @param parentName
- * the new parent's name
- * @param updateTextField
- * whether to update the corresponding textField
- */
- public final void setParentName(final String parentName2, final boolean updateTextField) {
- this.parentName = parentName2;
- if (this.parentNameTextField != null) {
- if (updateTextField) {
- this.parentNameTextField.setText(parentName2);
- }
- }
- }
-
- public String getChildrenName() {
- return this.childrenName;
- }
-
- public void setChildrenName(final String childrenName) {
- this.childrenName = childrenName;
- }
-
- public Button getSubClassingQueryButton() {
- return this.subClassingQueryButton;
- }
-
- public void showUpperBound(final boolean showUpperBound2) {
- this.showUpperBound = showUpperBound2;
- }
-
- public void showLowerBound(final boolean showLOwerBound2) {
- this.showLowerBound = showLOwerBound2;
- }
-
- public void showParentName(final boolean showParentName2) {
- this.showParentName = showParentName2;
- }
-
- public void showChildrenName(final boolean showChildrenName2) {
- this.showChildrenName = showChildrenName2;
- }
-
- public void showQueryTypeSelection(final boolean showQueryTypeSelection2) {
- this.showQueryTypeSelection = showQueryTypeSelection2;
- }
-
- public void showEType(final boolean showEType2) {
- this.showEType = showEType2;
- }
-
- public boolean isVolatile() {
- return this.fVolatile;
- }
-
- public void showVolatile(final boolean fVolatile1) {
- this.showVolatile = fVolatile1;
- }
-
- public boolean isChangeable() {
- return this.fChangeable;
- }
-
- public void showChangeable(final boolean fChangeable1) {
- this.showChangeable = fChangeable1;
- }
-
- public boolean isDerived() {
- return this.fDerived;
- }
-
- public void showDerived(final boolean fDerived1) {
- this.showDerived = fDerived1;
- }
-
- public boolean isTransient() {
- return this.fTransient;
- }
-
- public void showTransient(final boolean fTransient1) {
- this.showTransient = fTransient1;
- }
-
- public boolean isOrdered() {
- return this.fOrdered;
- }
-
- public void showOrdered(final boolean fOrdered1) {
- this.showOrdered = fOrdered1;
- }
-
- public boolean isUnique() {
- return this.fUnique;
- }
-
- public void showUnique(final boolean fUnique1) {
- this.showUnique = fUnique1;
- }
-
- public void setVolatile(final boolean fVolatile2) {
- this.fVolatile = fVolatile2;
- }
-
- public void setChangeable(final boolean fChangeable2) {
- this.fChangeable = fChangeable2;
- }
-
- public void setDerived(final boolean fDerived2) {
- this.fDerived = fDerived2;
- }
-
- public void setTransient(final boolean fTransient2) {
- this.fTransient = fTransient2;
- }
-
- public void setOrdered(final boolean ordered) {
- this.fOrdered = ordered;
- }
-
- public void setUnique(final boolean fUnique2) {
- this.fUnique = fUnique2;
- }
-
- public void setWizardNeedsQuery(final boolean wizardNeedsQuery) {
- this.wizardNeedsQuery = wizardNeedsQuery;
- }
-
- public QueryFacetElement getQueryFacetElement() {
- return this.queryFacetElement;
- }
-
- public void setQueryFacetElement(final QueryFacetElement queryFacetElement) {
- this.queryFacetElement = queryFacetElement;
- }
-}
+/** + * 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 349546 - EMF Facet facetSet editor + * Gregoire Dupe (Mia-Software) - Bug 373248 - Clean PMD errors + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages; + +import java.util.Map; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.osgi.util.NLS; +import org.eclipse.papyrus.emf.facet.efacet.Facet; +import org.eclipse.papyrus.emf.facet.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.QueryFacetElement; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.SelectETypeComposite; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.SelectETypeComposite.ETypeSelectionOptions; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.SelectQueryTypeComposite; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.papyrus.emf.facet.widgets.celleditors.AbstractCellEditorComposite; +import org.eclipse.papyrus.emf.facet.widgets.celleditors.ICompositeEditorFactory; +import org.eclipse.papyrus.emf.facet.widgets.celleditors.core.composite.registries.ICompositeEditorFactoriesRegistry; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +@SuppressWarnings("PMD.ConstructorCallsOverridableMethod") +// @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") This class is +// deprecated, we won't then spend to many time to conforms to PMD rules. +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public abstract class AbstractFacetWizardPage extends WizardPage { + + private static final int QUERY_SELECTION_GROUP_COLUMN_NUMBER = 4; + private static final int NUMBER_COLUMN_PROPERTY = 3; + protected static final int NUMBER_COLUMN = 3; + protected static final int VERTICAL_SPACING = 9; + + private ISelection selection; + private EditingDomain editingDomain; + + // USER PERMISSION + private boolean canChangeParentName = true; + private boolean canChangeChildrenName = true; + private boolean canChangeUpperBound = true; + private boolean canChangeLowerBound = true; + private boolean canChangeType = true; + private final boolean canChangeVolatile = false; + private final boolean canChangeChangeable = false; + private final boolean canChangeDerived = false; + private final boolean canChangeTransient = false; + private final boolean canChangeOrdered = true; + private final boolean canChangeUnique = true; + private boolean canChangeEPackage = true; + + private boolean showUpperBound = true; + private boolean showLowerBound = true; + private boolean showParentName = true; + private boolean showChildrenName = true; + private boolean showQueryTypeSelection = true; + private boolean showEType = true; + private boolean showVolatile = true; + private boolean showChangeable = true; + private boolean showDerived = true; + private boolean showTransient = true; + private boolean showOrdered = true; + private boolean showUnique = true; + + // DATA + private FacetSet facetSet; + private Facet facet; + private String facetName; + private QueryFacetElement queryFacetElement; + private EClass type; + private String parentName = ""; //$NON-NLS-1$ + private String childrenName = ""; //$NON-NLS-1$ + private int lowerBound; + private int upperBound; + private boolean fVolatile = true; + private boolean fChangeable = false; + private boolean fDerived = true; + private boolean fTransient = true; + private boolean fOrdered = false; + private boolean fUnique = false; + + // COMPOSITE + private Label parentNameLabel; + private Label childrenNameLabel; + private Label lowerBoundLabel; + private Label upperBoundLabel; + private SelectETypeComposite selectETypeComposite; + private Text parentNameTextField; + private Text childrenNameTextField; + private AbstractCellEditorComposite<Integer> lowerBoundTextField; + private AbstractCellEditorComposite<Integer> upperBoundTextField; + private SelectQueryTypeComposite selectQueryTypeComposite; + private Button subClassingQueryButton; + + private Map<String, IQueryCreationPagePart> queryTypeNameToWizardPage; + private boolean wizardNeedsQuery = true; + private ETypeSelectionOptions eTypeSelectionOption; + + public AbstractFacetWizardPage(final ISelection selection, final EditingDomain editingDomain, + final Map<String, IQueryCreationPagePart> queryTypeNameToWizardPage, + final ETypeSelectionOptions eTypeSelectionOption) { + this(selection, editingDomain); + this.queryTypeNameToWizardPage = queryTypeNameToWizardPage; + this.eTypeSelectionOption = eTypeSelectionOption; + } + + public AbstractFacetWizardPage(final ISelection selection, final EditingDomain editingDomain) { + super("whatever"); //$NON-NLS-1$ + this.selection = selection; + this.editingDomain = editingDomain; + initializeWithSelection(); + } + + @Override + public void setVisible(final boolean visible) { + updatePageButtons(); + super.setVisible(visible); + } + + protected Composite createControlParts(final Composite parent) { + + final Composite threeColumnContainer = new Composite(parent, SWT.NONE); + GridLayout layout3Column = new GridLayout(AbstractFacetWizardPage.NUMBER_COLUMN, false); + threeColumnContainer.setLayout(layout3Column); + GridData fillGridData = new GridData(GridData.FILL_HORIZONTAL); + + threeColumnContainer.setLayoutData(fillGridData); + + if (this.showParentName) { + this.parentNameLabel = new Label(threeColumnContainer, SWT.NONE); + this.parentNameTextField = new Text(threeColumnContainer, SWT.BORDER | SWT.SINGLE); + this.parentNameTextField.setText(this.parentName); + this.parentNameTextField.setEnabled(this.canChangeParentName); + this.parentNameTextField.setLayoutData(fillGridData); + this.parentNameTextField.addModifyListener(new ModifyListener() { + public void modifyText(final ModifyEvent e) { + setParentName(((Text) e.getSource()).getText(), false); + updatePageButtons(); + } + }); + Label dummyLabel = new Label(threeColumnContainer, SWT.NONE); + dummyLabel.setText(""); //$NON-NLS-1$ + } + + if (this.showChildrenName) { + this.childrenNameLabel = new Label(threeColumnContainer, SWT.NONE); + this.childrenNameTextField = new Text(threeColumnContainer, SWT.BORDER | SWT.SINGLE); + this.childrenNameTextField.setText(this.childrenName); + this.childrenNameTextField.setEnabled(canChangeChildrenName()); + this.childrenNameTextField.setLayoutData(fillGridData); + this.childrenNameTextField.addModifyListener(new ModifyListener() { + public void modifyText(final ModifyEvent e) { + setChildrenName(((Text) e.getSource()).getText()); + updatePageButtons(); + } + }); + Label dummyLabel2 = new Label(threeColumnContainer, SWT.NONE); + dummyLabel2.setText(""); //$NON-NLS-1$ + } + ICompositeEditorFactory<Integer> compositeFactory = ICompositeEditorFactoriesRegistry.INSTANCE + .getCompositeEditorFactory(Integer.class); + if (this.showLowerBound) { + this.lowerBoundLabel = new Label(threeColumnContainer, SWT.NONE); + this.lowerBoundTextField = compositeFactory.createCompositeEditor(threeColumnContainer, SWT.BORDER + | SWT.SINGLE); + this.lowerBoundTextField.setLayoutData(fillGridData); + this.lowerBoundTextField.setEnabled(canChangeLowerBound()); + setLowerBound(this.lowerBound); + Label dummyLabel5 = new Label(threeColumnContainer, SWT.NONE); + dummyLabel5.setText(""); //$NON-NLS-1$ + } + if (this.showUpperBound) { + this.upperBoundLabel = new Label(threeColumnContainer, SWT.NONE); + this.upperBoundTextField = compositeFactory.createCompositeEditor(threeColumnContainer, SWT.BORDER + | SWT.SINGLE); + this.upperBoundTextField.setLayoutData(fillGridData); + this.upperBoundTextField.setEnabled(this.canChangeUpperBound); + setUpperBound(this.upperBound); + Label dummyLabel6 = new Label(threeColumnContainer, SWT.NONE); + dummyLabel6.setText(""); //$NON-NLS-1$ + } + if (this.showEType) { + this.selectETypeComposite = new SelectETypeComposite(parent, SWT.NONE, this.eTypeSelectionOption, + this.canChangeEPackage, this.facetSet) { + @Override + protected void createCompositeWidget() { + setETypeLabel(new Label(threeColumnContainer, SWT.NULL)); + setETypedTextField(new Text(threeColumnContainer, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY)); + setSelectButton(new Button(threeColumnContainer, SWT.PUSH)); + } + + @Override + protected void eTypeSelected() { + updatePageButtons(); + } + }; + if (this.type != null) { + this.selectETypeComposite.setEType(this.type); + } + this.selectETypeComposite.setEditingDomain(getEditingDomain()); + this.selectETypeComposite.canChangeEType(this.canChangeType); + } + + createPropertyControls(threeColumnContainer); + + if (this.wizardNeedsQuery) { + createQueryComposite(parent, threeColumnContainer); + } + return threeColumnContainer; + } + + /** + * @param parent + * @param threeColumnContainer + */ + protected void createQueryComposite(final Composite parent, final Composite threeColumnContainer) { + if (this.showQueryTypeSelection) { + final Group group = new Group(threeColumnContainer, SWT.SHADOW_ETCHED_OUT); + group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, AbstractFacetWizardPage.NUMBER_COLUMN, 1)); + group.setLayout(new GridLayout(AbstractFacetWizardPage.QUERY_SELECTION_GROUP_COLUMN_NUMBER, false)); + Label subClassingQueryButtonText = new Label(group, SWT.NONE); + subClassingQueryButtonText.setText(Messages.CreateFacetInFacetSetWizardPage_Sub_Typing_Facet); + + this.subClassingQueryButton = new Button(group, SWT.CHECK); + this.subClassingQueryButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + this.subClassingQueryButton.addSelectionListener(new SelectionListener() { + public void widgetSelected(final SelectionEvent e) { + setQueryTypeSelectionVisible(getSubClassingQueryButton().getSelection()); + updatePageButtons(); + } + + public void widgetDefaultSelected(final SelectionEvent e) { + // nothing + } + }); + + // Query Type Composite + this.selectQueryTypeComposite = new SelectQueryTypeComposite(parent, SWT.NONE) { + @Override + protected void createCompositeWidget() { + setQueryTypeLabel(new Label(group, SWT.NONE)); + setQueryTypeComboBox(new Combo(group, SWT.DROP_DOWN)); + } + + @Override + protected void queryTypeSelected() { + updatePageButtons(); + } + }; + + setQueryTypeSelectionVisible(false); + } else { + // Query Type Composite + this.selectQueryTypeComposite = new SelectQueryTypeComposite(parent, SWT.NONE) { + @Override + protected void createCompositeWidget() { + setQueryTypeLabel(new Label(threeColumnContainer, SWT.NONE)); + setQueryTypeComboBox(new Combo(threeColumnContainer, SWT.DROP_DOWN | SWT.READ_ONLY)); + } + + @Override + protected void queryTypeSelected() { + updatePageButtons(); + } + }; + } + } + + /** + * @param threeColumnContainer + */ + protected void createPropertyControls(final Composite threeColumnContainer) { + Label dummyLabel = new Label(threeColumnContainer, SWT.NONE); + dummyLabel.setText(""); //$NON-NLS-1$ + Composite composite = new Composite(threeColumnContainer, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = AbstractFacetWizardPage.NUMBER_COLUMN_PROPERTY; + composite.setLayout(layout); + composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); + if (this.showVolatile) { + final Button button = new Button(composite, SWT.CHECK); + button.setText(Messages.Volatile); + button.setEnabled(this.canChangeVolatile); + button.setSelection(this.fVolatile); + button.addSelectionListener(new SelectionListener() { + public void widgetSelected(final SelectionEvent e) { + setVolatile(button.getSelection()); + } + + public void widgetDefaultSelected(final SelectionEvent e) { + // Nothing + } + }); + } + if (this.showChangeable) { + final Button button = new Button(composite, SWT.CHECK); + button.setText(Messages.Changeable); + button.setSelection(this.fChangeable); + button.setEnabled(this.canChangeChangeable); + button.addSelectionListener(new SelectionListener() { + public void widgetSelected(final SelectionEvent e) { + setChangeable(button.getSelection()); + } + + public void widgetDefaultSelected(final SelectionEvent e) { + // Nothing + } + }); + } + if (this.showDerived) { + final Button button = new Button(composite, SWT.CHECK); + button.setText(Messages.Derived); + button.setEnabled(this.canChangeDerived); + button.setSelection(this.fDerived); + button.addSelectionListener(new SelectionListener() { + public void widgetSelected(final SelectionEvent e) { + setDerived(button.getSelection()); + } + + public void widgetDefaultSelected(final SelectionEvent e) { + // Nothing + } + }); + } + if (this.showTransient) { + final Button button = new Button(composite, SWT.CHECK); + button.setText(Messages.Transient); + button.setEnabled(this.canChangeTransient); + button.setSelection(this.fTransient); + button.addSelectionListener(new SelectionListener() { + public void widgetSelected(final SelectionEvent e) { + setTransient(button.getSelection()); + } + + public void widgetDefaultSelected(final SelectionEvent e) { + // Nothing + } + }); + } + if (this.showOrdered) { + final Button button = new Button(composite, SWT.CHECK); + button.setText(Messages.Ordered); + button.setSelection(this.fOrdered); + button.setEnabled(this.canChangeOrdered); + button.addSelectionListener(new SelectionListener() { + public void widgetSelected(final SelectionEvent e) { + setOrdered(button.getSelection()); + } + + public void widgetDefaultSelected(final SelectionEvent e) { + // Nothing + } + }); + } + if (this.showUnique) { + final Button button = new Button(composite, SWT.CHECK); + button.setText(Messages.Unique); + button.setSelection(this.fUnique); + button.setEnabled(this.canChangeUnique); + button.addSelectionListener(new SelectionListener() { + public void widgetSelected(final SelectionEvent e) { + setUnique(button.getSelection()); + } + + public void widgetDefaultSelected(final SelectionEvent e) { + // Nothing + } + }); + } + } + + public boolean isSubTypingFacet() { + if (getSubClassingQueryButton() == null) { + return true; + } + return getSubClassingQueryButton().getSelection(); + } + + protected void initializeWithSelection() { + if (getSelection() != null && !getSelection().isEmpty() && getSelection() instanceof IStructuredSelection) { + IStructuredSelection ssel = (IStructuredSelection) getSelection(); + if (ssel.size() > 1) { + return; + } + Object obj = ssel.getFirstElement(); + if (obj instanceof Facet) { + setFacet((Facet) obj); + setFacetSet(((Facet) obj).getFacetSet()); + if (((Facet) obj).getName() != null) { + setParentName(((Facet) obj).getName(), true); + } + } + } + } + + @Override + public IWizardPage getNextPage() { + if (this.showQueryTypeSelection) { + if (this.queryTypeNameToWizardPage != null && this.subClassingQueryButton != null) { + if (this.subClassingQueryButton.getSelection()) { + IQueryCreationPagePart wizard = this.queryTypeNameToWizardPage.get(getSelectedQueryType()); + if (wizard != null) { + return super.getNextPage(); + } + setErrorMessage(Messages.SelectQueryTypeWizardPage_No_wizard_found); + } + } + } else { + if (this.queryTypeNameToWizardPage != null) { + IQueryCreationPagePart wizard = this.queryTypeNameToWizardPage.get(getSelectedQueryType()); + if (wizard != null) { + return super.getNextPage(); + } + setErrorMessage(Messages.SelectQueryTypeWizardPage_No_wizard_found); + } + } + return null; + } + + @Override + protected void setControl(final Control newControl) { + updatePageButtons(); + super.setControl(newControl); + } + + protected void setQueryTypeSelectionVisible(final boolean visible) { + this.selectQueryTypeComposite.setEnabled(visible); + } + + public String getSelectedQueryType() { + return this.selectQueryTypeComposite.getSelectedQueryType(); + } + + protected void updatePageButtons() { + if (getContainer() != null && getContainer().getCurrentPage() != null) { + getContainer().updateButtons(); + } + } + + public void initializeTextContent(final String parentName2, final String childrenName2) { + if (parentName2 != null) { + this.parentNameLabel.setText(parentName2); + } + this.childrenNameLabel.setText(childrenName2); + if (this.showLowerBound) { + this.lowerBoundLabel.setText(Messages.Lower_bound); + } + if (this.showUpperBound) { + this.upperBoundLabel.setText(Messages.Upper_bound); + } + } + + @Override + public boolean isPageComplete() { + if (getChildrenName() == null) { + return false; + } + if (this.showChildrenName && getChildrenName().length() == 0) { + setErrorMessage(NLS.bind(Messages.Please_enter_value_for, this.childrenNameLabel.getText())); + return false; + } + if (this.showLowerBound && this.lowerBoundTextField.getValue() == null) { + setErrorMessage(NLS.bind(Messages.Please_enter_value_for, this.lowerBoundLabel.getText())); + return false; + } + if (this.showUpperBound && this.upperBoundTextField.getValue() == null) { + setErrorMessage(NLS.bind(Messages.Please_enter_value_for, this.upperBoundLabel.getText())); + return false; + } + if (this.showEType && getType() == null) { + setErrorMessage(NLS.bind(Messages.Please_enter_value_for, "Type")); //$NON-NLS-1$ + return false; + } + if (this.wizardNeedsQuery) { + if (this.subClassingQueryButton != null && !this.subClassingQueryButton.getSelection()) { + setErrorMessage(null); + return true; + } + if (getNextPage() == null) { + setErrorMessage(Messages.CreateFacetInFacetSetWizardPage_could_not_find_wizard_page); + return false; + } + } + setErrorMessage(null); + return true; + } + + // CanChange section + public void canChangeParentName(final boolean canChange) { + this.canChangeParentName = canChange; + } + + public boolean canChangeParentName() { + return this.canChangeParentName; + } + + public void canChangeChildrenName(final boolean canChange) { + this.canChangeChildrenName = canChange; + } + + public boolean canChangeChildrenName() { + return this.canChangeChildrenName; + } + + public void canChangeUpperBound(final boolean canChange) { + this.canChangeUpperBound = canChange; + } + + public boolean canChangeUpperBound() { + return this.canChangeUpperBound; + } + + public void canChangeLowerBound(final boolean canChange) { + this.canChangeLowerBound = canChange; + } + + public boolean canChangeLowerBound() { + return this.canChangeLowerBound; + } + + public void canChangeType(final boolean canChange) { + this.canChangeType = canChange; + } + + public boolean canChangeType() { + return this.canChangeType; + } + + public void canChangeEPackage(final boolean canChangeEPackage2) { + this.canChangeEPackage = canChangeEPackage2; + } + + public EditingDomain getEditingDomain() { + return this.editingDomain; + } + + public void setEditingDomain(final EditingDomain editingDomain) { + this.editingDomain = editingDomain; + } + + public final ISelection getSelection() { + return this.selection; + } + + public void setSelection(final ISelection selection) { + this.selection = selection; + } + + public final FacetSet getFacetSet() { + return this.facetSet; + } + + public final void setFacetSet(final FacetSet facetSet) { + this.facetSet = facetSet; + } + + public Facet getFacet() { + return this.facet; + } + + public final void setFacet(final Facet facet) { + this.facet = facet; + } + + public String getFacetName() { + return this.facetName; + } + + public void setFacetName(final String facetName) { + this.facetName = facetName; + } + + public int getLowerBound() { + try { + return (this.lowerBoundTextField.getValue()).intValue(); + } catch (Exception e) { + Logger.logError(e, Activator.getDefault()); + } + return 0; + } + + public void setLowerBound(final int lowerBound) { + this.lowerBound = lowerBound; + if (this.lowerBoundTextField != null) { + (this.lowerBoundTextField).setValue(Integer.valueOf(lowerBound)); + } + } + + public int getUpperBound() { + try { + return (this.upperBoundTextField.getValue()).intValue(); + } catch (Exception e) { + Logger.logError(e, Activator.getDefault()); + } + return 0; + } + + public void setUpperBound(final int upperBound) { + this.upperBound = upperBound; + if (this.upperBoundTextField != null) { + this.upperBoundTextField.setValue(Integer.valueOf(upperBound)); + } + } + + public EClassifier getType() { + return this.selectETypeComposite.getEType(); + } + + public void setType(final EClass eType) { + this.type = eType; + if (this.selectETypeComposite != null) { + this.selectETypeComposite.setEType(eType); + } + } + + public String getParentName() { + return this.parentName; + } + + /** + * Set the parent(container) name + * + * @param parentName + * the new parent's name + * @param updateTextField + * whether to update the corresponding textField + */ + public final void setParentName(final String parentName2, final boolean updateTextField) { + this.parentName = parentName2; + if (this.parentNameTextField != null) { + if (updateTextField) { + this.parentNameTextField.setText(parentName2); + } + } + } + + public String getChildrenName() { + return this.childrenName; + } + + public void setChildrenName(final String childrenName) { + this.childrenName = childrenName; + } + + public Button getSubClassingQueryButton() { + return this.subClassingQueryButton; + } + + public void showUpperBound(final boolean showUpperBound2) { + this.showUpperBound = showUpperBound2; + } + + public void showLowerBound(final boolean showLOwerBound2) { + this.showLowerBound = showLOwerBound2; + } + + public void showParentName(final boolean showParentName2) { + this.showParentName = showParentName2; + } + + public void showChildrenName(final boolean showChildrenName2) { + this.showChildrenName = showChildrenName2; + } + + public void showQueryTypeSelection(final boolean showQueryTypeSelection2) { + this.showQueryTypeSelection = showQueryTypeSelection2; + } + + public void showEType(final boolean showEType2) { + this.showEType = showEType2; + } + + public boolean isVolatile() { + return this.fVolatile; + } + + public void showVolatile(final boolean fVolatile1) { + this.showVolatile = fVolatile1; + } + + public boolean isChangeable() { + return this.fChangeable; + } + + public void showChangeable(final boolean fChangeable1) { + this.showChangeable = fChangeable1; + } + + public boolean isDerived() { + return this.fDerived; + } + + public void showDerived(final boolean fDerived1) { + this.showDerived = fDerived1; + } + + public boolean isTransient() { + return this.fTransient; + } + + public void showTransient(final boolean fTransient1) { + this.showTransient = fTransient1; + } + + public boolean isOrdered() { + return this.fOrdered; + } + + public void showOrdered(final boolean fOrdered1) { + this.showOrdered = fOrdered1; + } + + public boolean isUnique() { + return this.fUnique; + } + + public void showUnique(final boolean fUnique1) { + this.showUnique = fUnique1; + } + + public void setVolatile(final boolean fVolatile2) { + this.fVolatile = fVolatile2; + } + + public void setChangeable(final boolean fChangeable2) { + this.fChangeable = fChangeable2; + } + + public void setDerived(final boolean fDerived2) { + this.fDerived = fDerived2; + } + + public void setTransient(final boolean fTransient2) { + this.fTransient = fTransient2; + } + + public void setOrdered(final boolean ordered) { + this.fOrdered = ordered; + } + + public void setUnique(final boolean fUnique2) { + this.fUnique = fUnique2; + } + + public void setWizardNeedsQuery(final boolean wizardNeedsQuery) { + this.wizardNeedsQuery = wizardNeedsQuery; + } + + public QueryFacetElement getQueryFacetElement() { + return this.queryFacetElement; + } + + public void setQueryFacetElement(final QueryFacetElement queryFacetElement) { + this.queryFacetElement = queryFacetElement; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddAttributeInFacetWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddAttributeInFacetWizardPage.java index 28c1206f169..1edb13a4257 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddAttributeInFacetWizardPage.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddAttributeInFacetWizardPage.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:
- * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages;
-
-import java.util.Map;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.SelectETypeComposite.ETypeSelectionOptions;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public class AddAttributeInFacetWizardPage extends AbstractFacetWizardPage {
-
- public AddAttributeInFacetWizardPage(final ISelection selection, final EditingDomain editingDomain,
- final Map<String, IQueryCreationPagePart> queryTypeNameToWizardPage) {
- super(selection, editingDomain, queryTypeNameToWizardPage, ETypeSelectionOptions.EDATATYPE);
- setTitle(Messages.Add_an_Attribute);
- setDescription(Messages.Add_an_Attribute_desc);
- }
-
- public void createControl(final Composite parent) {
- final Composite container = new Composite(parent, SWT.NULL);
-
- GridLayout layout = new GridLayout();
- container.setLayout(layout);
- layout.numColumns = 1;
- layout.verticalSpacing = AbstractFacetWizardPage.VERTICAL_SPACING;
-
- showQueryTypeSelection(false);
-
- createControlParts(container);
- initializeTextContent(Messages.Facet, Messages.Attribute_name);
-
- setControl(container);
- }
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages; + +import java.util.Map; + +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.SelectETypeComposite.ETypeSelectionOptions; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; + +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public class AddAttributeInFacetWizardPage extends AbstractFacetWizardPage { + + public AddAttributeInFacetWizardPage(final ISelection selection, final EditingDomain editingDomain, + final Map<String, IQueryCreationPagePart> queryTypeNameToWizardPage) { + super(selection, editingDomain, queryTypeNameToWizardPage, ETypeSelectionOptions.EDATATYPE); + setTitle(Messages.Add_an_Attribute); + setDescription(Messages.Add_an_Attribute_desc); + } + + public void createControl(final Composite parent) { + final Composite container = new Composite(parent, SWT.NULL); + + GridLayout layout = new GridLayout(); + container.setLayout(layout); + layout.numColumns = 1; + layout.verticalSpacing = AbstractFacetWizardPage.VERTICAL_SPACING; + + showQueryTypeSelection(false); + + createControlParts(container); + initializeTextContent(Messages.Facet, Messages.Attribute_name); + + setControl(container); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddOperationInFacetWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddOperationInFacetWizardPage.java index ce6d75232c3..121abacb98e 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddOperationInFacetWizardPage.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddOperationInFacetWizardPage.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:
- * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages;
-
-import java.util.Map;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.SelectETypeComposite.ETypeSelectionOptions;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public class AddOperationInFacetWizardPage extends AbstractFacetWizardPage {
-
- public AddOperationInFacetWizardPage(final ISelection selection, final EditingDomain editingDomain,
- final Map<String, IQueryCreationPagePart> queryTypeNameToWizardPage) {
- super(selection, editingDomain, queryTypeNameToWizardPage, ETypeSelectionOptions.ECLASSIFIER);
- setTitle(Messages.Add_an_Operation);
- setDescription(Messages.Add_an_Operation_desc);
- }
-
- public void createControl(final Composite parent) {
- final Composite container = new Composite(parent, SWT.NULL);
-
- GridLayout layout = new GridLayout();
- container.setLayout(layout);
- layout.numColumns = 1;
- layout.verticalSpacing = AbstractFacetWizardPage.VERTICAL_SPACING;
-
- showQueryTypeSelection(false);
-
- createControlParts(container);
- initializeTextContent(Messages.Facet, Messages.Operation_name);
-
- setControl(container);
- }
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages; + +import java.util.Map; + +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.SelectETypeComposite.ETypeSelectionOptions; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; + +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public class AddOperationInFacetWizardPage extends AbstractFacetWizardPage { + + public AddOperationInFacetWizardPage(final ISelection selection, final EditingDomain editingDomain, + final Map<String, IQueryCreationPagePart> queryTypeNameToWizardPage) { + super(selection, editingDomain, queryTypeNameToWizardPage, ETypeSelectionOptions.ECLASSIFIER); + setTitle(Messages.Add_an_Operation); + setDescription(Messages.Add_an_Operation_desc); + } + + public void createControl(final Composite parent) { + final Composite container = new Composite(parent, SWT.NULL); + + GridLayout layout = new GridLayout(); + container.setLayout(layout); + layout.numColumns = 1; + layout.verticalSpacing = AbstractFacetWizardPage.VERTICAL_SPACING; + + showQueryTypeSelection(false); + + createControlParts(container); + initializeTextContent(Messages.Facet, Messages.Operation_name); + + setControl(container); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddOperationParameterInFacetWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddOperationParameterInFacetWizardPage.java index dbae59f0f39..3588851bcb1 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddOperationParameterInFacetWizardPage.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddOperationParameterInFacetWizardPage.java @@ -1,69 +1,69 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.emf.facet.efacet.FacetOperation;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public class AddOperationParameterInFacetWizardPage extends AbstractFacetWizardPage {
-
- public AddOperationParameterInFacetWizardPage(final ISelection selection, final EditingDomain editingDomain) {
- super(selection, editingDomain);
- setTitle(Messages.Add_an_Operation_Parameter);
- setDescription(Messages.Add_an_Operation_Parameter_desc);
- }
-
- @Override
- protected void initializeWithSelection() {
- if (getSelection() != null && !getSelection().isEmpty() && getSelection() instanceof IStructuredSelection) {
- IStructuredSelection ssel = (IStructuredSelection) getSelection();
- if (ssel.size() > 1) {
- return;
- }
- Object obj = ssel.getFirstElement();
- if (obj instanceof FacetOperation) {
- FacetOperation facetOperation = (FacetOperation) obj;
- setQueryFacetElement(facetOperation);
- setFacet(facetOperation.getFacet());
- setFacetSet(facetOperation.getFacet().getFacetSet());
- if (facetOperation.getName() != null) {
- setParentName(facetOperation.getName(), true);
- }
- }
- }
- }
-
- public void createControl(final Composite parent) {
- final Composite container = new Composite(parent, SWT.NULL);
-
- GridLayout layout = new GridLayout();
- container.setLayout(layout);
- layout.numColumns = 1;
- layout.verticalSpacing = AbstractFacetWizardPage.VERTICAL_SPACING;
-
- setWizardNeedsQuery(false);
-
- createControlParts(container);
- initializeTextContent(Messages.Operation, Messages.Parameter_name);
-
- setControl(container);
- }
-
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages; + +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.papyrus.emf.facet.efacet.FacetOperation; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; + +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public class AddOperationParameterInFacetWizardPage extends AbstractFacetWizardPage { + + public AddOperationParameterInFacetWizardPage(final ISelection selection, final EditingDomain editingDomain) { + super(selection, editingDomain); + setTitle(Messages.Add_an_Operation_Parameter); + setDescription(Messages.Add_an_Operation_Parameter_desc); + } + + @Override + protected void initializeWithSelection() { + if (getSelection() != null && !getSelection().isEmpty() && getSelection() instanceof IStructuredSelection) { + IStructuredSelection ssel = (IStructuredSelection) getSelection(); + if (ssel.size() > 1) { + return; + } + Object obj = ssel.getFirstElement(); + if (obj instanceof FacetOperation) { + FacetOperation facetOperation = (FacetOperation) obj; + setQueryFacetElement(facetOperation); + setFacet(facetOperation.getFacet()); + setFacetSet(facetOperation.getFacet().getFacetSet()); + if (facetOperation.getName() != null) { + setParentName(facetOperation.getName(), true); + } + } + } + } + + public void createControl(final Composite parent) { + final Composite container = new Composite(parent, SWT.NULL); + + GridLayout layout = new GridLayout(); + container.setLayout(layout); + layout.numColumns = 1; + layout.verticalSpacing = AbstractFacetWizardPage.VERTICAL_SPACING; + + setWizardNeedsQuery(false); + + createControlParts(container); + initializeTextContent(Messages.Operation, Messages.Parameter_name); + + setControl(container); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddReferenceInFacetWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddReferenceInFacetWizardPage.java index 14b25b7c925..eee015bf610 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddReferenceInFacetWizardPage.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/AddReferenceInFacetWizardPage.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:
- * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages;
-
-import java.util.Map;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.SelectETypeComposite.ETypeSelectionOptions;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public class AddReferenceInFacetWizardPage extends AbstractFacetWizardPage {
-
- public AddReferenceInFacetWizardPage(final ISelection selection, final EditingDomain editingDomain,
- final Map<String, IQueryCreationPagePart> queryTypeNameToWizardPage) {
- super(selection, editingDomain, queryTypeNameToWizardPage, ETypeSelectionOptions.ECLASS);
- setTitle(Messages.Add_a_Reference);
- setDescription(Messages.Add_a_Reference_desc);
- }
-
- public void createControl(final Composite parent) {
- final Composite container = new Composite(parent, SWT.NULL);
-
- GridLayout layout = new GridLayout();
- container.setLayout(layout);
- layout.numColumns = 1;
- layout.verticalSpacing = AbstractFacetWizardPage.VERTICAL_SPACING;
-
- showQueryTypeSelection(false);
-
- createControlParts(container);
- initializeTextContent(Messages.Facet, Messages.Reference_name);
-
- setControl(container);
- }
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages; + +import java.util.Map; + +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.SelectETypeComposite.ETypeSelectionOptions; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; + +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public class AddReferenceInFacetWizardPage extends AbstractFacetWizardPage { + + public AddReferenceInFacetWizardPage(final ISelection selection, final EditingDomain editingDomain, + final Map<String, IQueryCreationPagePart> queryTypeNameToWizardPage) { + super(selection, editingDomain, queryTypeNameToWizardPage, ETypeSelectionOptions.ECLASS); + setTitle(Messages.Add_a_Reference); + setDescription(Messages.Add_a_Reference_desc); + } + + public void createControl(final Composite parent) { + final Composite container = new Composite(parent, SWT.NULL); + + GridLayout layout = new GridLayout(); + container.setLayout(layout); + layout.numColumns = 1; + layout.verticalSpacing = AbstractFacetWizardPage.VERTICAL_SPACING; + + showQueryTypeSelection(false); + + createControlParts(container); + initializeTextContent(Messages.Facet, Messages.Reference_name); + + setControl(container); + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/CreateFacetSetWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/CreateFacetSetWizardPage.java index 2840a0b702d..fca1dcff4a5 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/CreateFacetSetWizardPage.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/CreateFacetSetWizardPage.java @@ -1,107 +1,107 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.CreateFacetSetWizardImpl;
-import org.eclipse.papyrus.emf.facet.util.core.Logger;
-import org.eclipse.papyrus.emf.facet.util.pde.core.internal.exported.PluginUtils;
-import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
-
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public class CreateFacetSetWizardPage extends WizardNewFileCreationPage {
-
- public CreateFacetSetWizardPage(final String pageId, final IStructuredSelection selection) {
- super(pageId, selection);
-
- setTitle(Messages.CreateFacetSetWizardImpl_FacetModel);
- setDescription(Messages.CreateFacetSetWizardImpl_Create_new_facet_Set);
- setFileName("My" //$NON-NLS-1$
- + "." + CreateFacetSetWizardImpl.FILE_EXTENSION); //$NON-NLS-1$
-
- // Try and get the resource selection to determine a current directory
- // for the file dialog.
- if (selection != null && !selection.isEmpty()) {
- // Get the resource...
- //
- Object selectedElement = selection.iterator().next();
- if (selectedElement instanceof IResource) {
- // Get the resource parent, if its a file.
- IResource selectedResource = (IResource) selectedElement;
- if (selectedResource.getType() == IResource.FILE) {
- selectedResource = selectedResource.getParent();
- }
-
- // This gives us a directory...
- if (selectedResource instanceof IFolder || selectedResource instanceof IProject) {
- // Set this for the container.
- setContainerFullPath(selectedResource.getFullPath());
-
- // Make up a unique new name here.
- //
- String defaultModelBaseFilename = "My"; //$NON-NLS-1$
- String defaultModelFilenameExtension = CreateFacetSetWizardImpl.FILE_EXTENSION;
- String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension; //$NON-NLS-1$
- for (int i = 1; ((IContainer) selectedResource).findMember(modelFilename) != null; ++i) {
- modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension; //$NON-NLS-1$
- }
- setFileName(modelFilename);
- }
- }
- }
- }
-
- @Override
- protected boolean validatePage() {
- boolean valid = super.validatePage();
-
- if (valid) {
- String extension = new Path(getFileName()).getFileExtension();
- if (extension == null || !CreateFacetSetWizardImpl.FILE_EXTENSION.equalsIgnoreCase((extension))) {
- setErrorMessage(Messages.CreateFacetSetWizardImpl_File_extension_restriction);
- valid = false;
- }
- }
-
- if (valid) {
-
- IPath containerFullPath = getContainerFullPath();
- try {
- if (!PluginUtils.isInPluginProject(containerFullPath)) {
- setMessage(Messages.CreateFacetSetWizardPage_Not_a_Plugin_project, IMessageProvider.WARNING);
- }
- } catch (CoreException e) {
- Logger.logError(e, Activator.getDefault());
- }
- }
-
- return valid;
- }
-
- public IFile getModelFile() {
- return ResourcesPlugin.getWorkspace().getRoot().getFile(getContainerFullPath().append(getFileName()));
- }
-
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Activator; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.CreateFacetSetWizardImpl; +import org.eclipse.papyrus.emf.facet.util.core.Logger; +import org.eclipse.papyrus.emf.facet.util.pde.core.internal.exported.PluginUtils; +import org.eclipse.ui.dialogs.WizardNewFileCreationPage; + +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public class CreateFacetSetWizardPage extends WizardNewFileCreationPage { + + public CreateFacetSetWizardPage(final String pageId, final IStructuredSelection selection) { + super(pageId, selection); + + setTitle(Messages.CreateFacetSetWizardImpl_FacetModel); + setDescription(Messages.CreateFacetSetWizardImpl_Create_new_facet_Set); + setFileName("My" //$NON-NLS-1$ + + "." + CreateFacetSetWizardImpl.FILE_EXTENSION); //$NON-NLS-1$ + + // Try and get the resource selection to determine a current directory + // for the file dialog. + if (selection != null && !selection.isEmpty()) { + // Get the resource... + // + Object selectedElement = selection.iterator().next(); + if (selectedElement instanceof IResource) { + // Get the resource parent, if its a file. + IResource selectedResource = (IResource) selectedElement; + if (selectedResource.getType() == IResource.FILE) { + selectedResource = selectedResource.getParent(); + } + + // This gives us a directory... + if (selectedResource instanceof IFolder || selectedResource instanceof IProject) { + // Set this for the container. + setContainerFullPath(selectedResource.getFullPath()); + + // Make up a unique new name here. + // + String defaultModelBaseFilename = "My"; //$NON-NLS-1$ + String defaultModelFilenameExtension = CreateFacetSetWizardImpl.FILE_EXTENSION; + String modelFilename = defaultModelBaseFilename + "." + defaultModelFilenameExtension; //$NON-NLS-1$ + for (int i = 1; ((IContainer) selectedResource).findMember(modelFilename) != null; ++i) { + modelFilename = defaultModelBaseFilename + i + "." + defaultModelFilenameExtension; //$NON-NLS-1$ + } + setFileName(modelFilename); + } + } + } + } + + @Override + protected boolean validatePage() { + boolean valid = super.validatePage(); + + if (valid) { + String extension = new Path(getFileName()).getFileExtension(); + if (extension == null || !CreateFacetSetWizardImpl.FILE_EXTENSION.equalsIgnoreCase((extension))) { + setErrorMessage(Messages.CreateFacetSetWizardImpl_File_extension_restriction); + valid = false; + } + } + + if (valid) { + + IPath containerFullPath = getContainerFullPath(); + try { + if (!PluginUtils.isInPluginProject(containerFullPath)) { + setMessage(Messages.CreateFacetSetWizardPage_Not_a_Plugin_project, IMessageProvider.WARNING); + } + } catch (CoreException e) { + Logger.logError(e, Activator.getDefault()); + } + } + + return valid; + } + + public IFile getModelFile() { + return ResourcesPlugin.getWorkspace().getRoot().getFile(getContainerFullPath().append(getFileName())); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/CreateQueryWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/CreateQueryWizardPage.java index b5b5257f54a..953759a25e4 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/CreateQueryWizardPage.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/CreateQueryWizardPage.java @@ -1,286 +1,286 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- * Gregoire Dupe (Mia-Software) - Bug 373248 - Clean PMD errors
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages;
-
-import java.util.Map;
-
-import org.eclipse.jface.wizard.IWizardPage;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.papyrus.emf.facet.efacet.Facet;
-import org.eclipse.papyrus.emf.facet.efacet.FacetSet;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart;
-import org.eclipse.papyrus.emf.facet.widgets.celleditors.AbstractCellEditorComposite;
-import org.eclipse.papyrus.emf.facet.widgets.celleditors.ICompositeEditorFactory;
-import org.eclipse.papyrus.emf.facet.widgets.celleditors.core.composite.registries.ICompositeEditorFactoriesRegistry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-@Deprecated
-// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601
-public class CreateQueryWizardPage extends WizardPage {
-
- private static final int NUMBER_COLUMN = 3;
-
- private Map<String, IQueryCreationPagePart> queryTypeNameToQueryCreationPage;
-
- private Text queryNameText;
- private boolean canChangeQueryName = true;
-
- private Button canBeCachedButton;
- private boolean canChangeCanBeCached = true;
-
- private Button hasSideEffectButton;
- private boolean canChangeHasSideEffect = true;
-
- private AbstractCellEditorComposite<Integer> lowerBoundText;
- private boolean canChangeLowerBound = true;
-
- private AbstractCellEditorComposite<Integer> upperBoundText;
- private boolean canChangeUpperBound = true;
-
- private String queryName;
- private FacetSet facetSet;
- private Facet facet;
- private String queryType;
-
- private Composite parentComposite;
- private IQueryCreationPagePart queryCreationPage;
-
- public CreateQueryWizardPage(final Map<String, IQueryCreationPagePart> queryTypeNameToQueryCreationPage,
- final FacetSet facetSet, final Facet facet) {
- this("Whatever", facetSet); //$NON-NLS-1$
- this.facet = facet;
- this.queryTypeNameToQueryCreationPage = queryTypeNameToQueryCreationPage;
- }
-
- @Override
- public void setVisible(final boolean visible) {
- if (visible) {
- setFocus();
- IWizardPage previousPage = getPreviousPage();
- if (previousPage instanceof AbstractFacetWizardPage) {
- AbstractFacetWizardPage createFacetInFacetSetWizardPage = (AbstractFacetWizardPage) getPreviousPage();
- this.queryType = createFacetInFacetSetWizardPage.getSelectedQueryType();
- String childrenName = createFacetInFacetSetWizardPage.getChildrenName();
- String childrenNameFirstLetterToUpperCase = childrenName.substring(0, 1).toUpperCase()
- + childrenName.substring(1);
- if (previousPage instanceof CreateFacetInFacetSetWizardPage) {
- setQueryName("is" + childrenNameFirstLetterToUpperCase); //$NON-NLS-1$
- } else if (previousPage instanceof AddReferenceInFacetWizardPage
- || previousPage instanceof AddAttributeInFacetWizardPage) {
- setQueryName("get" + childrenNameFirstLetterToUpperCase); //$NON-NLS-1$
- } else {
- setQueryName(childrenNameFirstLetterToUpperCase);
- }
- deleteAllControls(this.parentComposite);
- createControl2(this.parentComposite);
- this.parentComposite.layout();
- }
- }
- super.setVisible(visible);
- }
-
- private void setFocus() {
- this.queryNameText.setFocus();
- }
-
- public CreateQueryWizardPage(final String pageName, final FacetSet facetSet) {
- super(pageName);
- setTitle(Messages.Create_Query);
- this.facetSet = facetSet;
- }
-
- private static void deleteAllControls(final Composite comp) {
- for (Control c : comp.getChildren()) {
- c.dispose();
- }
- }
-
- @Override
- public boolean isPageComplete() {
- if (this.queryCreationPage != null) {
- if (!this.queryCreationPage.isCompositeComplete()) {
- setErrorMessage(this.queryCreationPage.getErrorMessage());
- return false;
- }
- setErrorMessage(null);
- }
- return super.isPageComplete();
- }
-
- private void createControl2(final Composite parent) {
- Composite threeColumnContainer = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout(CreateQueryWizardPage.NUMBER_COLUMN, false);
- threeColumnContainer.setLayout(layout);
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- threeColumnContainer.setLayoutData(gridData);
- Label label = new Label(threeColumnContainer, SWT.NONE);
- label.setText(Messages.JavaQueryWizardPage_Query_name);
- this.queryNameText = new Text(threeColumnContainer, SWT.BORDER);
- this.queryNameText.setEditable(this.canChangeQueryName);
- this.queryNameText.setLayoutData(gridData);
- if (this.queryName != null) {
- this.queryNameText.setText(this.queryName);
- }
- this.queryNameText.addModifyListener(new ModifyListener() {
- public void modifyText(final ModifyEvent e) {
- updateQueryName();
- }
- });
- Label dummyLabel = new Label(threeColumnContainer, SWT.NONE);
- dummyLabel.setText(""); //$NON-NLS-1$
- Label canBeCachedLabel = new Label(threeColumnContainer, SWT.NONE);
- canBeCachedLabel.setText(Messages.JavaQueryWizardPage_Can_be_cached);
- this.canBeCachedButton = new Button(threeColumnContainer, SWT.CHECK);
- this.canBeCachedButton.setEnabled(this.canChangeCanBeCached);
-
- Label dummyLabel1 = new Label(threeColumnContainer, SWT.NONE);
- dummyLabel1.setText(""); //$NON-NLS-1$
-
- Label hasSideEffectLabel = new Label(threeColumnContainer, SWT.NONE);
- hasSideEffectLabel.setText(Messages.JavaQueryWizardPage_has_side_effect);
- this.hasSideEffectButton = new Button(threeColumnContainer, SWT.CHECK);
- this.hasSideEffectButton.setEnabled(this.canChangeHasSideEffect);
-
- Label dummyLabel2 = new Label(threeColumnContainer, SWT.NONE);
- dummyLabel2.setText(""); //$NON-NLS-1$
- ICompositeEditorFactory<Integer> compositeFactory = ICompositeEditorFactoriesRegistry.INSTANCE
- .getCompositeEditorFactory(Integer.class);
-
- Label lowerBoundLabel = new Label(threeColumnContainer, SWT.NONE);
- lowerBoundLabel.setText(Messages.Lower_bound);
- this.lowerBoundText = compositeFactory.createCompositeEditor(threeColumnContainer, SWT.BORDER | SWT.SINGLE);
- this.lowerBoundText.setLayoutData(gridData);
- this.lowerBoundText.setEnabled(this.canChangeLowerBound);
- this.lowerBoundText.setValue(Integer.valueOf(1));
- Label dummyLabel3 = new Label(threeColumnContainer, SWT.NONE);
- dummyLabel3.setText(""); //$NON-NLS-1$
-
- Label upperBoundLabel = new Label(threeColumnContainer, SWT.NONE);
- upperBoundLabel.setText(Messages.Upper_bound);
- this.upperBoundText = compositeFactory.createCompositeEditor(threeColumnContainer, SWT.BORDER | SWT.SINGLE);
- this.upperBoundText.setLayoutData(gridData);
- this.upperBoundText.setEnabled(this.canChangeUpperBound);
- this.upperBoundText.setValue(Integer.valueOf(1));
- Label dummyLabel4 = new Label(threeColumnContainer, SWT.NONE);
- dummyLabel4.setText(""); //$NON-NLS-1$
-
- // Add the composite provided by extension point for the chosen Query type
- if (this.queryTypeNameToQueryCreationPage != null) {
- this.queryCreationPage = this.queryTypeNameToQueryCreationPage.get(this.queryType);
- if (this.queryCreationPage != null) {
- this.queryCreationPage.completeComposite(threeColumnContainer);
- this.queryCreationPage.setFacetSet(getFacetSet());
- this.queryCreationPage.setQueryType(this.facet.getExtendedMetaclass());
- this.queryCreationPage.setQueryName(this.queryName);
- this.queryCreationPage.addModifyListener(new ModifyListener() {
-
- public void modifyText(final ModifyEvent e) {
- updateButtons();
- }
- });
- }
- }
-
- setControl(threeColumnContainer);
- }
-
- private FacetSet getFacetSet() {
- return this.facetSet;
- }
-
- public void createControl(final Composite parent) {
- this.parentComposite = new Composite(parent, SWT.NONE);
- this.parentComposite.setLayout(new GridLayout(1, false));
- createControl2(this.parentComposite);
- }
-
- protected void updateButtons() {
- if (getContainer() != null && getContainer().getCurrentPage() != null) {
- getContainer().updateButtons();
- this.queryNameText.setFocus();
- }
- }
-
- protected void updateQueryName() {
- if (this.queryNameText != null) {
- this.queryName = this.queryNameText.getText();
- this.queryNameText.setFocus();
- }
- }
-
- public void setQueryName(final String queryName) {
- this.queryName = queryName;
- if (this.queryNameText != null) {
- this.queryNameText.setText(queryName);
- this.queryNameText.redraw();
- }
- }
-
- public String getQueryName() {
- return this.queryName;
- }
-
- public void canChangeUpperBound(final boolean canChange) {
- this.canChangeUpperBound = canChange;
- }
-
- public void canChangeQueryName(final boolean canChange) {
- this.canChangeQueryName = canChange;
- }
-
- public void canChangeLowerBound(final boolean canChange) {
- this.canChangeLowerBound = canChange;
- }
-
- public void canChangeHasSideEffect(final boolean canChange) {
- this.canChangeHasSideEffect = canChange;
- }
-
- public void canChangeCanBeCached(final boolean canChange) {
- this.canChangeCanBeCached = canChange;
- }
-
- public boolean getCanBeCached() {
- return this.canBeCachedButton.getSelection();
- }
-
- public boolean getHasSideEffect() {
- return this.hasSideEffectButton.getSelection();
- }
-
- public int getLowerBound() {
- return this.lowerBoundText.getValue().intValue();
- }
-
- public int getUpperBound() {
- return this.upperBoundText.getValue().intValue();
- }
-
- public IQueryCreationPagePart getQueryCreationPage() {
- return this.queryCreationPage;
- }
-
- public void setFacetSet(final FacetSet facetSet) {
- this.facetSet = 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: + * Nicolas Guyomar (Mia-Software) - Bug 349546 - EMF Facet facetSet editor + * Gregoire Dupe (Mia-Software) - Bug 373248 - Clean PMD errors + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages; + +import java.util.Map; + +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.papyrus.emf.facet.efacet.Facet; +import org.eclipse.papyrus.emf.facet.efacet.FacetSet; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.exported.wizard.IQueryCreationPagePart; +import org.eclipse.papyrus.emf.facet.widgets.celleditors.AbstractCellEditorComposite; +import org.eclipse.papyrus.emf.facet.widgets.celleditors.ICompositeEditorFactory; +import org.eclipse.papyrus.emf.facet.widgets.celleditors.core.composite.registries.ICompositeEditorFactoriesRegistry; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +@Deprecated +// TODO @Deprecated must be removed after a refactoring planed by https://bugs.eclipse.org/bugs/show_bug.cgi?id=364601 +public class CreateQueryWizardPage extends WizardPage { + + private static final int NUMBER_COLUMN = 3; + + private Map<String, IQueryCreationPagePart> queryTypeNameToQueryCreationPage; + + private Text queryNameText; + private boolean canChangeQueryName = true; + + private Button canBeCachedButton; + private boolean canChangeCanBeCached = true; + + private Button hasSideEffectButton; + private boolean canChangeHasSideEffect = true; + + private AbstractCellEditorComposite<Integer> lowerBoundText; + private boolean canChangeLowerBound = true; + + private AbstractCellEditorComposite<Integer> upperBoundText; + private boolean canChangeUpperBound = true; + + private String queryName; + private FacetSet facetSet; + private Facet facet; + private String queryType; + + private Composite parentComposite; + private IQueryCreationPagePart queryCreationPage; + + public CreateQueryWizardPage(final Map<String, IQueryCreationPagePart> queryTypeNameToQueryCreationPage, + final FacetSet facetSet, final Facet facet) { + this("Whatever", facetSet); //$NON-NLS-1$ + this.facet = facet; + this.queryTypeNameToQueryCreationPage = queryTypeNameToQueryCreationPage; + } + + @Override + public void setVisible(final boolean visible) { + if (visible) { + setFocus(); + IWizardPage previousPage = getPreviousPage(); + if (previousPage instanceof AbstractFacetWizardPage) { + AbstractFacetWizardPage createFacetInFacetSetWizardPage = (AbstractFacetWizardPage) getPreviousPage(); + this.queryType = createFacetInFacetSetWizardPage.getSelectedQueryType(); + String childrenName = createFacetInFacetSetWizardPage.getChildrenName(); + String childrenNameFirstLetterToUpperCase = childrenName.substring(0, 1).toUpperCase() + + childrenName.substring(1); + if (previousPage instanceof CreateFacetInFacetSetWizardPage) { + setQueryName("is" + childrenNameFirstLetterToUpperCase); //$NON-NLS-1$ + } else if (previousPage instanceof AddReferenceInFacetWizardPage + || previousPage instanceof AddAttributeInFacetWizardPage) { + setQueryName("get" + childrenNameFirstLetterToUpperCase); //$NON-NLS-1$ + } else { + setQueryName(childrenNameFirstLetterToUpperCase); + } + deleteAllControls(this.parentComposite); + createControl2(this.parentComposite); + this.parentComposite.layout(); + } + } + super.setVisible(visible); + } + + private void setFocus() { + this.queryNameText.setFocus(); + } + + public CreateQueryWizardPage(final String pageName, final FacetSet facetSet) { + super(pageName); + setTitle(Messages.Create_Query); + this.facetSet = facetSet; + } + + private static void deleteAllControls(final Composite comp) { + for (Control c : comp.getChildren()) { + c.dispose(); + } + } + + @Override + public boolean isPageComplete() { + if (this.queryCreationPage != null) { + if (!this.queryCreationPage.isCompositeComplete()) { + setErrorMessage(this.queryCreationPage.getErrorMessage()); + return false; + } + setErrorMessage(null); + } + return super.isPageComplete(); + } + + private void createControl2(final Composite parent) { + Composite threeColumnContainer = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(CreateQueryWizardPage.NUMBER_COLUMN, false); + threeColumnContainer.setLayout(layout); + GridData gridData = new GridData(GridData.FILL_HORIZONTAL); + threeColumnContainer.setLayoutData(gridData); + Label label = new Label(threeColumnContainer, SWT.NONE); + label.setText(Messages.JavaQueryWizardPage_Query_name); + this.queryNameText = new Text(threeColumnContainer, SWT.BORDER); + this.queryNameText.setEditable(this.canChangeQueryName); + this.queryNameText.setLayoutData(gridData); + if (this.queryName != null) { + this.queryNameText.setText(this.queryName); + } + this.queryNameText.addModifyListener(new ModifyListener() { + public void modifyText(final ModifyEvent e) { + updateQueryName(); + } + }); + Label dummyLabel = new Label(threeColumnContainer, SWT.NONE); + dummyLabel.setText(""); //$NON-NLS-1$ + Label canBeCachedLabel = new Label(threeColumnContainer, SWT.NONE); + canBeCachedLabel.setText(Messages.JavaQueryWizardPage_Can_be_cached); + this.canBeCachedButton = new Button(threeColumnContainer, SWT.CHECK); + this.canBeCachedButton.setEnabled(this.canChangeCanBeCached); + + Label dummyLabel1 = new Label(threeColumnContainer, SWT.NONE); + dummyLabel1.setText(""); //$NON-NLS-1$ + + Label hasSideEffectLabel = new Label(threeColumnContainer, SWT.NONE); + hasSideEffectLabel.setText(Messages.JavaQueryWizardPage_has_side_effect); + this.hasSideEffectButton = new Button(threeColumnContainer, SWT.CHECK); + this.hasSideEffectButton.setEnabled(this.canChangeHasSideEffect); + + Label dummyLabel2 = new Label(threeColumnContainer, SWT.NONE); + dummyLabel2.setText(""); //$NON-NLS-1$ + ICompositeEditorFactory<Integer> compositeFactory = ICompositeEditorFactoriesRegistry.INSTANCE + .getCompositeEditorFactory(Integer.class); + + Label lowerBoundLabel = new Label(threeColumnContainer, SWT.NONE); + lowerBoundLabel.setText(Messages.Lower_bound); + this.lowerBoundText = compositeFactory.createCompositeEditor(threeColumnContainer, SWT.BORDER | SWT.SINGLE); + this.lowerBoundText.setLayoutData(gridData); + this.lowerBoundText.setEnabled(this.canChangeLowerBound); + this.lowerBoundText.setValue(Integer.valueOf(1)); + Label dummyLabel3 = new Label(threeColumnContainer, SWT.NONE); + dummyLabel3.setText(""); //$NON-NLS-1$ + + Label upperBoundLabel = new Label(threeColumnContainer, SWT.NONE); + upperBoundLabel.setText(Messages.Upper_bound); + this.upperBoundText = compositeFactory.createCompositeEditor(threeColumnContainer, SWT.BORDER | SWT.SINGLE); + this.upperBoundText.setLayoutData(gridData); + this.upperBoundText.setEnabled(this.canChangeUpperBound); + this.upperBoundText.setValue(Integer.valueOf(1)); + Label dummyLabel4 = new Label(threeColumnContainer, SWT.NONE); + dummyLabel4.setText(""); //$NON-NLS-1$ + + // Add the composite provided by extension point for the chosen Query type + if (this.queryTypeNameToQueryCreationPage != null) { + this.queryCreationPage = this.queryTypeNameToQueryCreationPage.get(this.queryType); + if (this.queryCreationPage != null) { + this.queryCreationPage.completeComposite(threeColumnContainer); + this.queryCreationPage.setFacetSet(getFacetSet()); + this.queryCreationPage.setQueryType(this.facet.getExtendedMetaclass()); + this.queryCreationPage.setQueryName(this.queryName); + this.queryCreationPage.addModifyListener(new ModifyListener() { + + public void modifyText(final ModifyEvent e) { + updateButtons(); + } + }); + } + } + + setControl(threeColumnContainer); + } + + private FacetSet getFacetSet() { + return this.facetSet; + } + + public void createControl(final Composite parent) { + this.parentComposite = new Composite(parent, SWT.NONE); + this.parentComposite.setLayout(new GridLayout(1, false)); + createControl2(this.parentComposite); + } + + protected void updateButtons() { + if (getContainer() != null && getContainer().getCurrentPage() != null) { + getContainer().updateButtons(); + this.queryNameText.setFocus(); + } + } + + protected void updateQueryName() { + if (this.queryNameText != null) { + this.queryName = this.queryNameText.getText(); + this.queryNameText.setFocus(); + } + } + + public void setQueryName(final String queryName) { + this.queryName = queryName; + if (this.queryNameText != null) { + this.queryNameText.setText(queryName); + this.queryNameText.redraw(); + } + } + + public String getQueryName() { + return this.queryName; + } + + public void canChangeUpperBound(final boolean canChange) { + this.canChangeUpperBound = canChange; + } + + public void canChangeQueryName(final boolean canChange) { + this.canChangeQueryName = canChange; + } + + public void canChangeLowerBound(final boolean canChange) { + this.canChangeLowerBound = canChange; + } + + public void canChangeHasSideEffect(final boolean canChange) { + this.canChangeHasSideEffect = canChange; + } + + public void canChangeCanBeCached(final boolean canChange) { + this.canChangeCanBeCached = canChange; + } + + public boolean getCanBeCached() { + return this.canBeCachedButton.getSelection(); + } + + public boolean getHasSideEffect() { + return this.hasSideEffectButton.getSelection(); + } + + public int getLowerBound() { + return this.lowerBoundText.getValue().intValue(); + } + + public int getUpperBound() { + return this.upperBoundText.getValue().intValue(); + } + + public IQueryCreationPagePart getQueryCreationPage() { + return this.queryCreationPage; + } + + public void setFacetSet(final FacetSet facetSet) { + this.facetSet = facetSet; + } +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/FacetSetPropertyWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/FacetSetPropertyWizardPage.java index 209ae86f838..91356e293fe 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/FacetSetPropertyWizardPage.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/FacetSetPropertyWizardPage.java @@ -1,106 +1,106 @@ -/**
- * 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 349546 - EMF Facet facetSet editor
- */
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages;
-
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Wizard page to enter a NsURI, a prefix and an extended EPackage to a facetSet
- */
-public class FacetSetPropertyWizardPage extends SelectEPackageWizardPage {
-
- private Text nsUriTextField;
- private Text prefixTextField;
-
- public FacetSetPropertyWizardPage(final EditingDomain editingDomain) {
- super(editingDomain);
- }
-
- @Override
- public void createControl(final Composite parent) {
-
- // Extends the SelectEPackageWizardPage to add a NsURI and a Prefix textField
- Composite container = new Composite(parent, SWT.NONE);
- container.setLayout(new GridLayout(1, false));
- container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL, GridData.FILL_VERTICAL, true, true));
-
- Composite nsURiContainer = new Composite(container, SWT.NONE);
- nsURiContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- nsURiContainer.setLayout(new GridLayout(2, false));
-
- // NsURI
- Label nsUriLabel = new Label(nsURiContainer, SWT.NONE);
- nsUriLabel.setText(Messages.Enter_a_nsUri);
- this.nsUriTextField = new Text(nsURiContainer, SWT.BORDER | SWT.SINGLE);
- this.nsUriTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- this.nsUriTextField.addListener(SWT.Modify, new Listener() {
- public void handleEvent(final Event event) {
- updateButtons();
- }
- });
-
- // PREFIX
- Label prefixLabel = new Label(nsURiContainer, SWT.NONE);
- prefixLabel.setText(Messages.Enter_a_prefix);
- this.prefixTextField = new Text(nsURiContainer, SWT.BORDER | SWT.SINGLE);
- this.prefixTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- this.prefixTextField.addListener(SWT.Modify, new Listener() {
- public void handleEvent(final Event event) {
- updateButtons();
- }
- });
-
- super.createControl(container);
- }
-
- @Override
- public boolean isPageComplete() {
- if (this.nsUriTextField.getText().length() == 0) {
- setErrorMessage(Messages.Please_enter_nsUri);
- return false;
- }
-
- if (this.prefixTextField.getText().length() == 0) {
- setErrorMessage(Messages.Please_enter_prefix);
- return false;
- }
- if (super.isPageComplete()) {
- setErrorMessage(null);
- return true;
- }
- setErrorMessage(Messages.Please_select_EPackage);
-
- return false;
- }
-
- public String getNsUri() {
- return this.nsUriTextField.getText();
- }
-
- public String getPrefix() {
- return this.prefixTextField.getText();
- }
-
- protected void updateButtons() {
- getContainer().updateButtons();
- }
-
-}
+/** + * 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 349546 - EMF Facet facetSet editor + */ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages; + +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Text; + +/** + * Wizard page to enter a NsURI, a prefix and an extended EPackage to a facetSet + */ +public class FacetSetPropertyWizardPage extends SelectEPackageWizardPage { + + private Text nsUriTextField; + private Text prefixTextField; + + public FacetSetPropertyWizardPage(final EditingDomain editingDomain) { + super(editingDomain); + } + + @Override + public void createControl(final Composite parent) { + + // Extends the SelectEPackageWizardPage to add a NsURI and a Prefix textField + Composite container = new Composite(parent, SWT.NONE); + container.setLayout(new GridLayout(1, false)); + container.setLayoutData(new GridData(GridData.FILL_HORIZONTAL, GridData.FILL_VERTICAL, true, true)); + + Composite nsURiContainer = new Composite(container, SWT.NONE); + nsURiContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + nsURiContainer.setLayout(new GridLayout(2, false)); + + // NsURI + Label nsUriLabel = new Label(nsURiContainer, SWT.NONE); + nsUriLabel.setText(Messages.Enter_a_nsUri); + this.nsUriTextField = new Text(nsURiContainer, SWT.BORDER | SWT.SINGLE); + this.nsUriTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + this.nsUriTextField.addListener(SWT.Modify, new Listener() { + public void handleEvent(final Event event) { + updateButtons(); + } + }); + + // PREFIX + Label prefixLabel = new Label(nsURiContainer, SWT.NONE); + prefixLabel.setText(Messages.Enter_a_prefix); + this.prefixTextField = new Text(nsURiContainer, SWT.BORDER | SWT.SINGLE); + this.prefixTextField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + this.prefixTextField.addListener(SWT.Modify, new Listener() { + public void handleEvent(final Event event) { + updateButtons(); + } + }); + + super.createControl(container); + } + + @Override + public boolean isPageComplete() { + if (this.nsUriTextField.getText().length() == 0) { + setErrorMessage(Messages.Please_enter_nsUri); + return false; + } + + if (this.prefixTextField.getText().length() == 0) { + setErrorMessage(Messages.Please_enter_prefix); + return false; + } + if (super.isPageComplete()) { + setErrorMessage(null); + return true; + } + setErrorMessage(Messages.Please_select_EPackage); + + return false; + } + + public String getNsUri() { + return this.nsUriTextField.getText(); + } + + public String getPrefix() { + return this.prefixTextField.getText(); + } + + protected void updateButtons() { + getContainer().updateButtons(); + } + +} diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/SelectEClassifierWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/SelectEClassifierWizardPage.java index 024e2368dcc..c2ef1483fc4 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/SelectEClassifierWizardPage.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/SelectEClassifierWizardPage.java @@ -1,114 +1,114 @@ -/*******************************************************************************
- * Copyright (c) 2009, 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) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages;
-
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.SelectETypeComposite.ETypeSelectionOptions;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget.EClassifierSelectionControl;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.dialogs.FilteredList;
-
-public class SelectEClassifierWizardPage extends WizardPage {
-
- private EClassifierSelectionControl eClassSelectionControl;
- private final ETypeSelectionOptions eTypeSelectionOption;
- private String metamodelNsUri;
-
- public SelectEClassifierWizardPage(final ETypeSelectionOptions eTypeSelectionOption, final EPackage ePackage) {
- super("Whatever"); //$NON-NLS-1$
- if (eTypeSelectionOption == ETypeSelectionOptions.ECLASS) {
- setTitle(Messages.Select_EClass);
- } else if (eTypeSelectionOption == ETypeSelectionOptions.EDATATYPE) {
- setTitle(Messages.Select_EDataType);
- } else {
- setTitle(Messages.Select_EClassifier);
- }
- if (ePackage != null) {
- this.metamodelNsUri = ePackage.getNsURI();
- }
- this.eTypeSelectionOption = eTypeSelectionOption;
- }
-
- @Override
- public boolean isPageComplete() {
- return this.eClassSelectionControl.getSelectedEClassifier() != null;
- }
-
- @Override
- public void setVisible(final boolean visible) {
- super.setVisible(visible);
- if (getPreviousPage() instanceof SelectEPackageWizardPage) {
- SelectEPackageWizardPage selectEPackageWizardPage = (SelectEPackageWizardPage) getPreviousPage();
- this.metamodelNsUri = selectEPackageWizardPage.getFirstSelectedEPackage().getNsURI();
- if (this.metamodelNsUri != null) {
- setDescription(selectEPackageWizardPage.getFirstSelectedEPackage().getNsURI());
- }
- }
- this.eClassSelectionControl.updateList(this.metamodelNsUri);
- }
-
- public void createControl(final Composite parent) {
- this.eClassSelectionControl = new EClassifierSelectionControl(parent, this.metamodelNsUri, this.eTypeSelectionOption);
- final FilteredList filteredList = this.eClassSelectionControl.getFilteredList();
-
- filteredList.addSelectionListener(new SelectionListener() {
- public void widgetSelected(final SelectionEvent e) {
- if (e.item != null) {
- updateButton();
- // setPageComplete(filteredList.getSelection().length == 1);
- }
- }
-
- public void widgetDefaultSelected(final SelectionEvent e) {
- if (getWizard().canFinish()) {
- getWizard().performFinish();
- }
- if (getNextPage() != null) {
- goToNextPage();
- }
- }
- });
-
- this.eClassSelectionControl.getFilterText().addModifyListener(new ModifyListener() {
-
- public void modifyText(final ModifyEvent e) {
- updateButton();
- }
- });
-
- // avoid the page being "complete" when still on a previous page
- filteredList.setSelection(new int[0]);
- setPageComplete(false);
-
- setControl(this.eClassSelectionControl);
- }
-
- protected void goToNextPage() {
- getContainer().showPage(getNextPage());
- }
-
- protected void updateButton() {
- if (getContainer() != null && getContainer().getCurrentPage() != null) {
- getContainer().updateButtons();
- }
- }
-
- public EClassifier getSelectedEclassifier() {
- return this.eClassSelectionControl.getSelectedEClassifier();
- }
+/******************************************************************************* + * Copyright (c) 2009, 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) - initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages; + +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.composites.SelectETypeComposite.ETypeSelectionOptions; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget.EClassifierSelectionControl; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.dialogs.FilteredList; + +public class SelectEClassifierWizardPage extends WizardPage { + + private EClassifierSelectionControl eClassSelectionControl; + private final ETypeSelectionOptions eTypeSelectionOption; + private String metamodelNsUri; + + public SelectEClassifierWizardPage(final ETypeSelectionOptions eTypeSelectionOption, final EPackage ePackage) { + super("Whatever"); //$NON-NLS-1$ + if (eTypeSelectionOption == ETypeSelectionOptions.ECLASS) { + setTitle(Messages.Select_EClass); + } else if (eTypeSelectionOption == ETypeSelectionOptions.EDATATYPE) { + setTitle(Messages.Select_EDataType); + } else { + setTitle(Messages.Select_EClassifier); + } + if (ePackage != null) { + this.metamodelNsUri = ePackage.getNsURI(); + } + this.eTypeSelectionOption = eTypeSelectionOption; + } + + @Override + public boolean isPageComplete() { + return this.eClassSelectionControl.getSelectedEClassifier() != null; + } + + @Override + public void setVisible(final boolean visible) { + super.setVisible(visible); + if (getPreviousPage() instanceof SelectEPackageWizardPage) { + SelectEPackageWizardPage selectEPackageWizardPage = (SelectEPackageWizardPage) getPreviousPage(); + this.metamodelNsUri = selectEPackageWizardPage.getFirstSelectedEPackage().getNsURI(); + if (this.metamodelNsUri != null) { + setDescription(selectEPackageWizardPage.getFirstSelectedEPackage().getNsURI()); + } + } + this.eClassSelectionControl.updateList(this.metamodelNsUri); + } + + public void createControl(final Composite parent) { + this.eClassSelectionControl = new EClassifierSelectionControl(parent, this.metamodelNsUri, this.eTypeSelectionOption); + final FilteredList filteredList = this.eClassSelectionControl.getFilteredList(); + + filteredList.addSelectionListener(new SelectionListener() { + public void widgetSelected(final SelectionEvent e) { + if (e.item != null) { + updateButton(); + // setPageComplete(filteredList.getSelection().length == 1); + } + } + + public void widgetDefaultSelected(final SelectionEvent e) { + if (getWizard().canFinish()) { + getWizard().performFinish(); + } + if (getNextPage() != null) { + goToNextPage(); + } + } + }); + + this.eClassSelectionControl.getFilterText().addModifyListener(new ModifyListener() { + + public void modifyText(final ModifyEvent e) { + updateButton(); + } + }); + + // avoid the page being "complete" when still on a previous page + filteredList.setSelection(new int[0]); + setPageComplete(false); + + setControl(this.eClassSelectionControl); + } + + protected void goToNextPage() { + getContainer().showPage(getNextPage()); + } + + protected void updateButton() { + if (getContainer() != null && getContainer().getCurrentPage() != null) { + getContainer().updateButtons(); + } + } + + public EClassifier getSelectedEclassifier() { + return this.eClassSelectionControl.getSelectedEClassifier(); + } }
\ No newline at end of file diff --git a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/SelectEPackageWizardPage.java b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/SelectEPackageWizardPage.java index 92df0478391..1d662da5a5c 100644 --- a/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/SelectEPackageWizardPage.java +++ b/plugins/facet/org.eclipse.papyrus.emf.facet.efacet.ui/src/org/eclipse/papyrus/emf/facet/efacet/ui/internal/wizards/pages/SelectEPackageWizardPage.java @@ -1,114 +1,114 @@ -/*******************************************************************************
- * Copyright (c) 2009, 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) - initial API and implementation
- *******************************************************************************/
-package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EPackage.Registry;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages;
-import org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget.MetamodelSelectionControl;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.dialogs.FilteredList;
-
-public class SelectEPackageWizardPage extends WizardPage {
-
- private MetamodelSelectionControl metamodelSelectionControl;
- private final EditingDomain editingDomain;
-
- public SelectEPackageWizardPage(final EditingDomain editingDomain) {
- super("Whatever"); //$NON-NLS-1$
- setTitle(Messages.Select_EPackage);
- this.editingDomain = editingDomain;
- }
-
- @Override
- public void setVisible(final boolean visible) {
- super.setVisible(visible);
- if (visible) {
- this.metamodelSelectionControl.getFilterText().setFocus();
- setPageComplete(true);
- }
- }
-
- public void createControl(final Composite parent) {
- this.metamodelSelectionControl = new MetamodelSelectionControl(parent);
- this.metamodelSelectionControl.setLayoutData(new GridData(GridData.FILL_BOTH));
- final FilteredList filteredList = this.metamodelSelectionControl.getFilteredList();
-
- filteredList.addSelectionListener(new SelectionListener() {
- public void widgetSelected(final SelectionEvent e) {
- if (e.item != null) {
- setPageComplete(filteredList.getSelection().length == 1);
- }
- }
-
- public void widgetDefaultSelected(final SelectionEvent e) {
- if (getWizard().canFinish()) {
- getWizard().performFinish();
- }
- if (getNextPage() != null) {
- goToNextPage();
- }
- }
- });
-
- // prevent the page from being "complete" when still on a previous page
- filteredList.setSelection(new int[0]);
- setPageComplete(false);
-
- setControl(this.metamodelSelectionControl);
- }
-
- protected void goToNextPage() {
- getContainer().showPage(getNextPage());
- }
-
- public EPackage getFirstSelectedEPackage() {
- // Only one result
- if (this.metamodelSelectionControl.getSelectedElements() != null) {
- Object result = this.metamodelSelectionControl.getSelectedElements()[0];
- if (EPackage.Registry.INSTANCE.containsKey(result.toString())) {
- return EPackage.Registry.INSTANCE.getEPackage(result.toString());
- }
- }
- return null;
- }
-
- public void loadSelectedMetamodel() {
- Object[] results = this.metamodelSelectionControl.getSelectedElements();
- // if user cancel the selection of meta models, results = null
- if (results != null) {
- ResourceSet resourceSet = this.editingDomain.getResourceSet();
- for (Object result : results) {
- URI uri = URI.createURI(result.toString());
- Resource r = resourceSet.getResource(uri, true);
- if (!resourceSet.getResources().contains(r)) {
- Registry packageRegistry = resourceSet.getPackageRegistry();
- for (EObject eObject : r.getContents()) {
- if (eObject instanceof EPackage) {
- EPackage ePackage = (EPackage) eObject;
- packageRegistry.put(ePackage.getNsURI(), ePackage);
- }
- }
- resourceSet.getResources().add(r);
- }
- }
- }
- }
-}
+/******************************************************************************* + * Copyright (c) 2009, 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) - initial API and implementation + *******************************************************************************/ +package org.eclipse.papyrus.emf.facet.efacet.ui.internal.wizards.pages; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EPackage.Registry; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.Messages; +import org.eclipse.papyrus.emf.facet.efacet.ui.internal.widget.MetamodelSelectionControl; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.dialogs.FilteredList; + +public class SelectEPackageWizardPage extends WizardPage { + + private MetamodelSelectionControl metamodelSelectionControl; + private final EditingDomain editingDomain; + + public SelectEPackageWizardPage(final EditingDomain editingDomain) { + super("Whatever"); //$NON-NLS-1$ + setTitle(Messages.Select_EPackage); + this.editingDomain = editingDomain; + } + + @Override + public void setVisible(final boolean visible) { + super.setVisible(visible); + if (visible) { + this.metamodelSelectionControl.getFilterText().setFocus(); + setPageComplete(true); + } + } + + public void createControl(final Composite parent) { + this.metamodelSelectionControl = new MetamodelSelectionControl(parent); + this.metamodelSelectionControl.setLayoutData(new GridData(GridData.FILL_BOTH)); + final FilteredList filteredList = this.metamodelSelectionControl.getFilteredList(); + + filteredList.addSelectionListener(new SelectionListener() { + public void widgetSelected(final SelectionEvent e) { + if (e.item != null) { + setPageComplete(filteredList.getSelection().length == 1); + } + } + + public void widgetDefaultSelected(final SelectionEvent e) { + if (getWizard().canFinish()) { + getWizard().performFinish(); + } + if (getNextPage() != null) { + goToNextPage(); + } + } + }); + + // prevent the page from being "complete" when still on a previous page + filteredList.setSelection(new int[0]); + setPageComplete(false); + + setControl(this.metamodelSelectionControl); + } + + protected void goToNextPage() { + getContainer().showPage(getNextPage()); + } + + public EPackage getFirstSelectedEPackage() { + // Only one result + if (this.metamodelSelectionControl.getSelectedElements() != null) { + Object result = this.metamodelSelectionControl.getSelectedElements()[0]; + if (EPackage.Registry.INSTANCE.containsKey(result.toString())) { + return EPackage.Registry.INSTANCE.getEPackage(result.toString()); + } + } + return null; + } + + public void loadSelectedMetamodel() { + Object[] results = this.metamodelSelectionControl.getSelectedElements(); + // if user cancel the selection of meta models, results = null + if (results != null) { + ResourceSet resourceSet = this.editingDomain.getResourceSet(); + for (Object result : results) { + URI uri = URI.createURI(result.toString()); + Resource r = resourceSet.getResource(uri, true); + if (!resourceSet.getResources().contains(r)) { + Registry packageRegistry = resourceSet.getPackageRegistry(); + for (EObject eObject : r.getContents()) { + if (eObject instanceof EPackage) { + EPackage ePackage = (EPackage) eObject; + packageRegistry.put(ePackage.getNsURI(), ePackage); + } + } + resourceSet.getResources().add(r); + } + } + } + } +} |