diff options
author | Francois Le Fevre | 2017-05-03 08:20:53 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2017-05-05 08:04:01 +0000 |
commit | 9b82580acc51513b875cc90d65349b8e4523ab7c (patch) | |
tree | 0ca7d9e550e044d7e76f74ff1d97fdd724197493 /plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette | |
parent | 44212c988540c3295a3c06c141f7f47cc83b6163 (diff) | |
download | org.eclipse.papyrus-9b82580acc51513b875cc90d65349b8e4523ab7c.tar.gz org.eclipse.papyrus-9b82580acc51513b875cc90d65349b8e4523ab7c.tar.xz org.eclipse.papyrus-9b82580acc51513b875cc90d65349b8e4523ab7c.zip |
Bug 516087 - [Toolsmiths][palette] rename the plugin to respect
convention
Actions
-rename the plugin (package,.project etc..)
-update feature.xml
Test
-look for plugins that are using customization.palette: not found
Change-Id: If4585e2e200ea5aaa4fd40ff3c6891679fefd42f
Signed-off-by: Francois Le Fevre <francois.le-fevre@cea.fr>
Diffstat (limited to 'plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette')
33 files changed, 6157 insertions, 0 deletions
diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/.classpath b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/.classpath new file mode 100644 index 00000000000..eca7bdba8f0 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/.project b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/.project new file mode 100644 index 00000000000..b92e0983fdc --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/.project @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.papyrus.toolsmiths.palette</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.oomph.version.VersionBuilder</name> + <arguments> + <dictionary> + <key>check.maven.pom</key> + <value>true</value> + </dictionary> + <dictionary> + <key>ignore.lower.bound.dependency.ranges</key> + <value>true</value> + </dictionary> + <dictionary> + <key>release.path</key> + <value>/org.eclipse.papyrus.releng.main.release/release.xml</value> + </dictionary> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + <nature>org.eclipse.oomph.version.VersionNature</nature> + <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature> + </natures> +</projectDescription> diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/.settings/org.eclipse.jdt.core.prefs b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..b3aa6d60f94 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,291 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=260 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=false +org.eclipse.jdt.core.formatter.join_wrapped_lines=false +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=260 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=5 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/.settings/org.eclipse.jdt.ui.prefs b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 00000000000..954281dbc31 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,68 @@ +cleanup.add_default_serial_version_id=true +cleanup.add_generated_serial_version_id=false +cleanup.add_missing_annotations=true +cleanup.add_missing_deprecated_annotations=true +cleanup.add_missing_methods=false +cleanup.add_missing_nls_tags=false +cleanup.add_missing_override_annotations=true +cleanup.add_missing_override_annotations_interface_methods=true +cleanup.add_serial_version_id=false +cleanup.always_use_blocks=true +cleanup.always_use_parentheses_in_expressions=false +cleanup.always_use_this_for_non_static_field_access=false +cleanup.always_use_this_for_non_static_method_access=false +cleanup.convert_functional_interfaces=false +cleanup.convert_to_enhanced_for_loop=false +cleanup.correct_indentation=false +cleanup.format_source_code=false +cleanup.format_source_code_changes_only=false +cleanup.insert_inferred_type_arguments=false +cleanup.make_local_variable_final=true +cleanup.make_parameters_final=false +cleanup.make_private_fields_final=true +cleanup.make_type_abstract_if_missing_method=false +cleanup.make_variable_declarations_final=false +cleanup.never_use_blocks=false +cleanup.never_use_parentheses_in_expressions=true +cleanup.organize_imports=false +cleanup.qualify_static_field_accesses_with_declaring_class=false +cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +cleanup.qualify_static_member_accesses_with_declaring_class=true +cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.remove_private_constructors=true +cleanup.remove_redundant_type_arguments=true +cleanup.remove_trailing_whitespaces=true +cleanup.remove_trailing_whitespaces_all=true +cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_casts=true +cleanup.remove_unnecessary_nls_tags=true +cleanup.remove_unused_imports=true +cleanup.remove_unused_local_variables=false +cleanup.remove_unused_private_fields=true +cleanup.remove_unused_private_members=false +cleanup.remove_unused_private_methods=true +cleanup.remove_unused_private_types=true +cleanup.sort_members=false +cleanup.sort_members_all=false +cleanup.use_anonymous_class_creation=false +cleanup.use_blocks=true +cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_lambda=true +cleanup.use_parentheses_in_expressions=false +cleanup.use_this_for_non_static_field_access=false +cleanup.use_this_for_non_static_field_access_only_if_necessary=true +cleanup.use_this_for_non_static_method_access=false +cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup.use_type_arguments=false +cleanup_profile=_Papyrus +cleanup_settings_version=2 +eclipse.preferences.version=1 +formatter_profile=_Papyrus +formatter_settings_version=12 +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=java;javax;org;com; +org.eclipse.jdt.ui.javadoc=true +org.eclipse.jdt.ui.ondemandthreshold=99 +org.eclipse.jdt.ui.staticondemandthreshold=99 +org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="false" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * Constructor.\n *\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*****************************************************************************\n * Copyright (c) ${year} CEA LIST and others.\n * \n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http\://www.eclipse.org/legal/epl-v10.html\n *\n * Contributors\:\n * CEA LIST - Initial API and implementation\n * \n *****************************************************************************/\n</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author ${user}\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/**\n * ${see_to_overridden}\n *\n * ${tags}\n */</template><template autoinsert\="false" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${see_to_target}\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates> diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/.settings/org.eclipse.pde.api.tools.prefs b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/.settings/org.eclipse.pde.api.tools.prefs new file mode 100644 index 00000000000..23fb95e120f --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/.settings/org.eclipse.pde.api.tools.prefs @@ -0,0 +1,98 @@ +ANNOTATION_ELEMENT_TYPE_ADDED_METHOD_WITHOUT_DEFAULT_VALUE=Error +ANNOTATION_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_FIELD=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD=Error +ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_API_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_API_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_TYPE=Error +API_COMPONENT_ELEMENT_TYPE_REMOVED_TYPE=Error +API_USE_SCAN_FIELD_SEVERITY=Error +API_USE_SCAN_METHOD_SEVERITY=Error +API_USE_SCAN_TYPE_SEVERITY=Error +CLASS_ELEMENT_TYPE_ADDED_METHOD=Error +CLASS_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +CLASS_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +CLASS_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +CLASS_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +CLASS_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error +CLASS_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +CLASS_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +CLASS_ELEMENT_TYPE_REMOVED_CONSTRUCTOR=Error +CLASS_ELEMENT_TYPE_REMOVED_FIELD=Error +CLASS_ELEMENT_TYPE_REMOVED_METHOD=Error +CLASS_ELEMENT_TYPE_REMOVED_SUPERCLASS=Error +CLASS_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +CONSTRUCTOR_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +CONSTRUCTOR_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error +CONSTRUCTOR_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +ENUM_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +ENUM_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +ENUM_ELEMENT_TYPE_REMOVED_ENUM_CONSTANT=Error +ENUM_ELEMENT_TYPE_REMOVED_FIELD=Error +ENUM_ELEMENT_TYPE_REMOVED_METHOD=Error +ENUM_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +FIELD_ELEMENT_TYPE_ADDED_VALUE=Error +FIELD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +FIELD_ELEMENT_TYPE_CHANGED_FINAL_TO_NON_FINAL_STATIC_CONSTANT=Error +FIELD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +FIELD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error +FIELD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error +FIELD_ELEMENT_TYPE_CHANGED_TYPE=Error +FIELD_ELEMENT_TYPE_CHANGED_VALUE=Error +FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENT=Error +FIELD_ELEMENT_TYPE_REMOVED_VALUE=Error +ILLEGAL_EXTEND=Warning +ILLEGAL_IMPLEMENT=Warning +ILLEGAL_INSTANTIATE=Warning +ILLEGAL_OVERRIDE=Warning +ILLEGAL_REFERENCE=Warning +INTERFACE_ELEMENT_TYPE_ADDED_FIELD=Ignore +INTERFACE_ELEMENT_TYPE_ADDED_METHOD=Error +INTERFACE_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +INTERFACE_ELEMENT_TYPE_ADDED_SUPER_INTERFACE_WITH_METHODS=Error +INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +INTERFACE_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error +INTERFACE_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error +INTERFACE_ELEMENT_TYPE_REMOVED_FIELD=Error +INTERFACE_ELEMENT_TYPE_REMOVED_METHOD=Error +INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error +INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +INVALID_ANNOTATION=Ignore +INVALID_JAVADOC_TAG=Ignore +INVALID_REFERENCE_IN_SYSTEM_LIBRARIES=Ignore +LEAK_EXTEND=Warning +LEAK_FIELD_DECL=Warning +LEAK_IMPLEMENT=Warning +LEAK_METHOD_PARAM=Warning +LEAK_METHOD_RETURN_TYPE=Warning +METHOD_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error +METHOD_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error +METHOD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error +METHOD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error +METHOD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error +METHOD_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error +METHOD_ELEMENT_TYPE_REMOVED_ANNOTATION_DEFAULT_VALUE=Error +METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error +MISSING_EE_DESCRIPTIONS=Error +TYPE_PARAMETER_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error +TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error +UNUSED_PROBLEM_FILTERS=Warning +automatically_removed_unused_problem_filters=Enabled +eclipse.preferences.version=1 +incompatible_api_component_version=Error +incompatible_api_component_version_include_major_without_breaking_change=Disabled +incompatible_api_component_version_include_minor_without_api_change=Disabled +invalid_since_tag_version=Error +malformed_since_tag=Error +missing_since_tag=Warning +report_api_breakage_when_major_version_incremented=Disabled +report_resolution_errors_api_component=Warning diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/META-INF/MANIFEST.MF b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..e190c8cdbfa --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/META-INF/MANIFEST.MF @@ -0,0 +1,33 @@ +Manifest-Version: 1.0 +Export-Package: org.eclipse.papyrus.toolsmiths.palette, + org.eclipse.papyrus.toolsmiths.palette.dialog +Require-Bundle: org.eclipse.uml2.uml;bundle-version="[5.2.0,6.0.0)", + org.eclipse.pde;bundle-version="[3.12.0,4.0.0)", + org.eclipse.pde.ui;bundle-version="[3.9.0,4.0.0)", + org.eclipse.core.runtime;bundle-version="[3.12.0,4.0.0)", + org.eclipse.ui.views.properties.tabbed;bundle-version="[3.7.0,4.0.0)", + org.eclipse.gmf.runtime.diagram.ui;bundle-version="[1.8.0,2.0.0)", + org.eclipse.papyrus.infra.core.log;bundle-version="[1.2.0,2.0.0)", + org.eclipse.papyrus.infra.core.sasheditor;bundle-version="[2.0.0,3.0.0)", + org.eclipse.papyrus.infra.core;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.infra.emf;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.emf.facet.custom.ui;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.emf.facet.custom.core;bundle-version="[2.1.0,3.0.0)", + org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.edit;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.editor;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.views.properties;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.infra.widgets;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.infra.gmfdiag.dnd;bundle-version="[1.2.0,2.0.0)", + org.eclipse.papyrus.infra.types;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.infra.types.editor;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="[3.0.0,4.0.0)", + org.eclipse.papyrus.uml.types.core;bundle-version="[3.0.0,4.0.0)" +Bundle-Vendor: %providerName +Bundle-ClassPath: . +Bundle-Version: 3.0.0.qualifier +Bundle-Localization: plugin +Bundle-Name: %pluginName +Bundle-ManifestVersion: 2 +Bundle-SymbolicName: org.eclipse.papyrus.toolsmiths.palette;singleton:=true +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/about.html b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/about.html new file mode 100644 index 00000000000..209103075a7 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/about.html @@ -0,0 +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>November 14, 2008</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/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/build.properties b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/build.properties new file mode 100644 index 00000000000..447b2cd9ef8 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/build.properties @@ -0,0 +1,11 @@ +#
+#Mon Sep 12 09:29:44 CEST 2011
+bin.includes = META-INF/,\
+ .,\
+ about.html,\
+ plugin.xml,\
+ plugin.properties,\
+ icons/
+src.includes=about.html
+source..=src/
+bin..=bin/
diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/icons/Stereotype.gif b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/icons/Stereotype.gif Binary files differnew file mode 100644 index 00000000000..145e5d589d8 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/icons/Stereotype.gif diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/icons/configuration.gif b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/icons/configuration.gif Binary files differnew file mode 100644 index 00000000000..0b1be97b8cf --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/icons/configuration.gif diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/icons/error.gif b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/icons/error.gif Binary files differnew file mode 100644 index 00000000000..9b048d60532 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/icons/error.gif diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/plugin.properties b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/plugin.properties new file mode 100644 index 00000000000..24304a9bdfb --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/plugin.properties @@ -0,0 +1,13 @@ +#################################################################################
+# Copyright (c) 2010 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:
+# Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - initial API and implementation
+##################################################################################
+pluginName=Papyrus Toolsmiths Palette Customization
+providerName=Eclipse Modeling Project
+
diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/plugin.xml b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/plugin.xml new file mode 100644 index 00000000000..fbb0f54f475 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/plugin.xml @@ -0,0 +1,78 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ allPopups="false"
+ locationURI="popup:org.eclipse.ui.popup.any?after=additions">
+ <command
+ commandId="org.eclipse.papyrus.customization.palette.extended.undeploy"
+ icon="icons/configuration.gif"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <adapt
+ type="org.eclipse.core.resources.IFile">
+ <or>
+ <test
+ property="org.eclipse.core.resources.extension"
+ value="paletteconfiguration">
+ </test>
+ </or>
+ </adapt>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ <command
+ commandId="org.eclipse.papyrus.customization.palette.extended.deploy"
+ icon="icons/configuration.gif"
+ style="push">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="selection">
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <adapt
+ type="org.eclipse.core.resources.IFile">
+ <or>
+ <test
+ property="org.eclipse.core.resources.extension"
+ value="paletteconfiguration">
+ </test>
+ </or>
+ </adapt>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+</menuContribution>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ defaultHandler="org.eclipse.papyrus.toolsmiths.palette.handler.DeployExtendedPaletteConfigurationHandler"
+ id="org.eclipse.papyrus.customization.palette.extended.deploy"
+ name="Deploy Extended Palette configuration">
+ </command>
+ <command
+ defaultHandler="org.eclipse.papyrus.toolsmiths.palette.handler.UndeployExtendedPaletteConfigurationHandler"
+ id="org.eclipse.papyrus.customization.palette.extended.undeploy"
+ name="Disable Extended Palette configuration">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.infra.gmfdiag.common.paletteCustomization">
+ <customizer
+ customizerDialog="org.eclipse.papyrus.customization.palette.dialog.PapyrusPaletteCustomizerDialog">
+ </customizer>
+ </extension>
+</plugin>
diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/pom.xml b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/pom.xml new file mode 100644 index 00000000000..b75de6cbfd9 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/pom.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.eclipse.papyrus</groupId> + <artifactId>org.eclipse.papyrus.toolsmiths</artifactId> + <version>0.0.1-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <artifactId>org.eclipse.papyrus.toolsmiths.palette</artifactId> + <version>3.0.0-SNAPSHOT</version> + <packaging>eclipse-plugin</packaging> +</project>
\ No newline at end of file diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/Messages.java b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/Messages.java new file mode 100644 index 00000000000..5e2bf596e15 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/Messages.java @@ -0,0 +1,301 @@ +/***************************************************************************** + * Copyright (c) 2010 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: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.toolsmiths.palette; + +import org.eclipse.osgi.util.NLS; + +/** + * Messages for the plugin + */ +public class Messages extends NLS { + + private static final String BUNDLE_NAME = "org.eclipse.papyrus.customization.palette.messages"; //$NON-NLS-1$ + + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } + + public static String BundleIconExplorerDialog_Message; + + public static String BundleIconExplorerDialog_Title; + + public static String BundleIconExplorerDialog_UnknownFileName; + + public static String ExportPaletteConfigurationWizard_error_cant_read_file; + + public static String ExportPaletteConfigurationWizard_error_file_not_existe; + + public static String ExportPaletteConfigurationWizard_Export_description; + + public static String ExportPaletteConfigurationWizard_ExportWiazrdLabel; + + public static String ExportPaletteConfigurationWizard_export_palette; + + public static String PaletteConfigurationWizard_EditionPaletteInfoPageWizard_Tilte; + + public static String PaletteConfigurationWizard_EditPaletteWizardLabel; + + public static String PaletteConfigurationWizard_NewPaletteContentPageWizard_Description; + + public static String PaletteConfigurationWizard_NewPaletteContentPageWizard_Title; + + public static String PaletteConfigurationWizard_NewPaletteDefaultName; + + public static String PaletteConfigurationWizard_PaletteInfoPageWizard_Description; + + public static String PaletteConfigurationWizard_NewPaletteInfoPageWizard_Title; + + public static String PaletteConfigurationWizard_NewPaletteWizardLabel; + + public static String PaletteConfigurationWizard_ImpossibleToReadDefinitionOfTheFile; + + public static String PaletteConfigurationWizard_FileDontExist; + + public static String PaletteConfigurationContentPage_NewTool; + + public static String PaletteConfigurationContentPage_Separator; + + public static String PaletteConfigurationContentPage_Stack; + + public static String PaletteConfigurationContentPage_UMLTools; + + public static String PaletteConfigurationContentPage_UnknownElement; + + public static String PaletteConfigurationContentPage_CreateAnElementWithAStereotype; + + public static String PaletteConfigurationContentPage_Drawer; + + // ///////////////////////// Palette Customisation + // ///////////////////////////////////// + + public static String Dialog_Export_Palette_Tooltip; + + /** Tooltip for the add button */ + public static String PapyrusPaletteCustomizerDialog_AddButtonTooltip; + + /** Tooltip for the remove button */ + public static String PapyrusPaletteCustomizerDialog_RemoveButtonTooltip; + + public static String AbstractDeployPaletteConfigurationHandler_ConfigureDeploymentOfThePalette; + + public static String AbstractDeployPaletteConfigurationHandler_Deploy; + + public static String AbstractDeployPaletteConfigurationHandler_Editor; + + public static String AbstractDeployPaletteConfigurationHandler_Error_UserCancelDialog; + + public static String AbstractDeployPaletteConfigurationHandler_Error_ContentDialogNotValid; + + public static String AbstractDeployPaletteConfigurationHandler_Error_SomeErrorsOccured; + + public static String AbstractDeployPaletteConfigurationHandler_Identifier; + + public static String AbstractDeployPaletteConfigurationHandler_Priority; + + public static String AbstractDeployPaletteConfigurationHandler_Profiles; + + public static String AbstractDeployPaletteConfigurationHandler_Success; + + public static String AbstractDeployPaletteConfigurationHandler_ThePaletteConfigurationHasBeenSuccessfullyDeployedAndActivated; + + public static String AbstractDeployPaletteConfigurationHandler_TheSelectedElementIsNotAFile; + + /** label for the available palettes viewer */ + public static String Available_Palettes; + + /** label for the palette tree viewer */ + public static String Palette_Viewer; + + /** label for the palette name in the wizard */ + public static String Local_Palette_Name; + + /** label for the palette id in the wizard */ + public static String Local_Palette_Id; + + /** label for the editor id in the palette wizard */ + public static String Local_Palette_Editor_Id; + + /** tooltip for the palette name in the palette wizard */ + public static String Local_Palette_Name_Tooltip; + + /** tooltip for the palette id in the palette wizard */ + public static String Local_Palette_Id_Tooltip; + + /** tooltip for the editor id in the palette wizard */ + public static String Local_Palette_Editor_Id_Tooltip; + + /** label for the provider priority in the palette wizard */ + public static String Local_Palette_Priority; + + /** tooltip for the provider priority in the palette wizard */ + public static String Local_Palette_Priority_Tooltip; + + /** label for the advanced button, when advanced are not shown */ + public static String Dialog_Advanced_Button_Closed; + + /** label for the advanced button, when advanced are shown */ + public static String Dialog_Advanced_Button_Opened; + + /** Error message for the wizard page, when priority is not correctly filled */ + public static String Local_Palette_Error_Priority; + + /** + * Error message for the wizard page, when palette ID is not correctly + * filled + */ + public static String Local_Palette_Error_PaletteId; + + /** Error message for the wizard page, when name is not correctly filled */ + public static String Local_Palette_Error_Name; + + /** + * Error message for the wizard page, when Editor ID is not correctly filled + */ + public static String Local_Palette_Error_EditorId; + + /** Name of the information page */ + public static String Local_Palette_InfoPage_Name; + + /** Title of the information page */ + public static String Local_Palette_InfoPage_Title; + + /** Name of the content page */ + public static String Local_Palette_ContentPage_Name; + + /** Title of the content page */ + public static String Local_Palette_ContentPage_Title; + + /** name of the available tools group */ + public static String Local_Palette_Available_Tools; + + /** tooltip for the show/hide drawer button */ + public static String Local_Palette_ShowDrawers_Tooltip; + + /** tooltip for the show/hide drawer button */ + public static String Local_Palette_ShowTools_Tooltip; + + /** palette preview label */ + public static String Local_Palette_Palette_Preview; + + /** Title for dialog box when palette to delete is not a local palette */ + public static String Dialog_Not_Local_Palette_Title; + + /** Message for dialog box when palette to delete is not a local palette */ + public static String Dialog_Not_Local_Palette_Message; + + /** Title for dialog box when palette to restore is not an extended palette */ + public static String Dialog_Not_Extended_Palette_Title; + + /** Message for dialog box when palette to restore is not an extended palette */ + public static String Dialog_Not_Extended_Palette_Message; + + /** Tooltip for the restore palette button. */ + public static String Dialog_Restore_Palette_Tooltip; + + /** tooltip for the delete palette button */ + public static String Dialog_Delete_Palette_Tooltip; + + /** tooltip for the create palette button */ + public static String Dialog_Create_Palette_Tooltip; + + /** tooltip for the edit palette button */ + public static String Dialog_Edit_Palette_Tooltip; + + /** tooltip for the create drawer button */ + public static String Local_Palette_Create_Drawer_Tooltip; + + /** tooltip for the create separator button */ + public static String Local_Palette_Create_Separator_Tooltip; + + /** tooltip for the create separator button */ + public static String Local_Palette_Create_Tool_Tooltip; + + /** tooltip for the create stack button */ + public static String Local_Palette_Create_Stack_Tooltip; + + /** name of the drawer wizard page */ + public static String Wizard_Drawer_Page_Name; + + /** title of the drawer wizard page */ + public static String Wizard_Drawer_Page_Title; + + /** error on the name in the drawer wizard */ + public static String Wizard_Drawer_Error_Name; + + /** error on the id in the drawer wizard */ + public static String Wizard_Drawer_Error_Id; + + /** error on the icon in the drawer wizard */ + public static String Wizard_Drawer_Error_Icon; + + /** label for the id field */ + public static String Wizard_Drawer_Id; + + /** tooltip for the id field */ + public static String Wizard_Drawer_Id_Tooltip; + + /** label for the name field */ + public static String Wizard_Drawer_Name; + + /** tooltip for the name field */ + public static String Wizard_Drawer_Name_Tooltip; + + /** tooltip for the icon field */ + public static String Wizard_Drawer_Icon_Tooltip; + + /** name for the icon field */ + public static String Wizard_Drawer_Icon; + + /** tooltip for the tool item */ + public static String Local_Palette_SwitchToolsContentProvider_Tooltip; + + /** + * tooltip for the edit local palette action disabled because of bad + * selection + */ + public static String PapyrusPaletteCustomizerDialog_EditButtonTooltip_LocalPaletteNotSelected; + + /** tooltip for the edit local palette action */ + public static String PapyrusPaletteCustomizerDialog_EditButtonTooltip_LocalPaletteSelected; + + /** + * tooltip for the edit local palette action disabled because of missing + * profiles + */ + public static String PapyrusPaletteCustomizerDialog_EditButtonTooltip_MissingProfile; + + /** label for the name text editor for a given proxy */ + public static String Local_Palette_Entry_Name; + + /** label for the description editor for a given proxy */ + public static String Local_Palette_Entry_Description; + + /** label for the group information about entry */ + public static String Local_Palette_Entry_Information; + + /** label for the icon information about entry */ + public static String Local_Palette_Entry_Icon; + + /** label for the referenced entry information about entry */ + public static String Local_Palette_Entry_Reference; + + /** label for the composite displaying the lis of aspect actions */ + public static String Aspect_Action_Information_List_Label; + + /** label for the tooltip of the edit drawer icon */ + public static String PapyrusPaletteCustomizerDialog_EditButtonTooltip; + +} diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/PaletteConstants.java b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/PaletteConstants.java new file mode 100644 index 00000000000..f0a252ae323 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/PaletteConstants.java @@ -0,0 +1,53 @@ +/***************************************************************************** + * 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: + * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation + *****************************************************************************/ + +package org.eclipse.papyrus.toolsmiths.palette; + +import java.util.Arrays; +import java.util.Collections; + +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.presentation.PaletteConfigurationEditorPlugin; +import org.eclipse.papyrus.infra.types.presentation.TypesConfigurationsEditorPlugin; + +/** + * The palette customization plugin constants. + */ +public class PaletteConstants { + + /** + * Constructor. + */ + private PaletteConstants() { + // to prevent instantiation + } + + /** the file extension for palette configuration */ + public static final String PALETTECONFIGURATION_EXTENSION = Collections.unmodifiableList(Arrays.asList(PaletteConfigurationEditorPlugin.INSTANCE.getString("_UI_PaletteconfigurationEditorFilenameExtensions").split("\\s*,\\s*"))).get(0); //$NON-NLS-1$ //$NON-NLS-2$ + + /** the file extension for element type files */ + public static final String ELEMENTTYPE_EXTENSION = Collections.unmodifiableList(Arrays.asList(TypesConfigurationsEditorPlugin.INSTANCE.getString("_UI_ElementtypesconfigurationsEditorFilenameExtensions").split("\\s*,\\s*"))).get(0); //$NON-NLS-1$ //$NON-NLS-2$ + + /** The postfix for semantic element type model file. */ + public static final String ELEMENTTYPE_SEMENTIC_IDENTIFIER_POSTFIX = "_Semantic"; //$NON-NLS-1$ + + /** The postfix for ui element type model file. */ + public static final String ELEMENTTYPE_UI_IDENTIFIER_POSTFIX = "_UI";//$NON-NLS-1$ + + /** The enumeration of the context of the palette configuration model in case of customization */ + public enum PaletteModelContextEnum { + New, // It's a new palette from scratch. Files will be place on local folder. + Workspace, // It's a workspace palette. Files will be place on WS. + Plugin, // It's a palette coming from a plugin definition. It's read-only, a copy and associated files will be placed on local folder + Local // It's come from the local folder + }; + +} diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/dialog/AbstractPaletteConfigurationWizard.java b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/dialog/AbstractPaletteConfigurationWizard.java new file mode 100644 index 00000000000..4107f4037c2 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/dialog/AbstractPaletteConfigurationWizard.java @@ -0,0 +1,466 @@ +/***************************************************************************** + * 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: + * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation + * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 507654 Change load order and add EcoreUtil.resolveAll(resource) to avoid absolute references + *****************************************************************************/ +package org.eclipse.papyrus.toolsmiths.palette.dialog; + +import java.io.File; +import java.io.IOException; +import java.util.Collection; +import java.util.Collections; + +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.CompoundCommand; +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.provider.EcoreItemProviderAdapterFactory; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.edit.command.AddCommand; +import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; +import org.eclipse.emf.edit.provider.ComposedAdapterFactory; +import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; +import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory; +import org.eclipse.emf.edit.provider.resource.ResourceSetItemProvider; +import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl; +import org.eclipse.gmf.runtime.common.core.service.ProviderPriority; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PaletteUtil; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPalettePreferences; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteService; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteService.ProviderDescriptor; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.PaletteConfiguration; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.PaletteRessourcesConstants; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.provider.CustomPaletteconfigurationItemProviderAdapterFactory; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.utils.CreatePaletteItemUtil; +import org.eclipse.papyrus.infra.types.ElementTypeSetConfiguration; +import org.eclipse.papyrus.infra.types.ElementTypesConfigurationsFactory; +import org.eclipse.papyrus.toolsmiths.palette.Messages; +import org.eclipse.papyrus.toolsmiths.palette.PaletteConstants; +import org.eclipse.papyrus.toolsmiths.palette.PaletteConstants.PaletteModelContextEnum; +import org.eclipse.papyrus.toolsmiths.palette.utils.PaletteUtils; +import org.eclipse.papyrus.infra.gmfdiag.common.Activator; +import org.eclipse.ui.IEditorPart; + +/** + * Abstract class for wizard of edition of palette configuration models. + */ +public abstract class AbstractPaletteConfigurationWizard extends Wizard { + + /** + * The dot string constant. + */ + protected static final String STR_DOT = "."; //$NON-NLS-1$ + + /** the palette resource */ + protected Resource paletteResource; + + /** the element type resource for the ui */ + protected Resource elementTypeUIResource; + + /** the element type resource for the semantic */ + protected Resource elementTypeSemResource; + + /** the string builder */ + protected StringBuilder stringBuilder = new StringBuilder(); + + /** customizer used by the palette viewer */ + protected ProviderDescriptor descriptor; + + /** the editing domain */ + protected AdapterFactoryEditingDomain editingDomain; + + /** the adapter factory */ + protected ComposedAdapterFactory adapterFactory; + + /** The context of the palette contribution */ + protected PaletteModelContextEnum paletteContext; + + /** Editor part in which the palette is displayed */ + protected IEditorPart editorPart; + + /** the provider priority */ + protected ProviderPriority priority; + + /** + * Constructor. + */ + public AbstractPaletteConfigurationWizard(final IEditorPart part, final ProviderDescriptor descriptor) { + this.editorPart = part; + this.descriptor = descriptor; + // initialize the context + paletteContext = PaletteUtils.getPaletteModelContext(descriptor); + + ProviderPriority localPalettePriority = null; + if (PaletteModelContextEnum.New.equals(paletteContext)) { + // Create New Palette + setWindowTitle(Messages.PaletteConfigurationWizard_NewPaletteWizardLabel); + } else { + // Edit Palette + localPalettePriority = PapyrusPalettePreferences.getLocalExtendedPalettePriority(descriptor.getContributionID()); + setWindowTitle(Messages.PaletteConfigurationWizard_EditPaletteWizardLabel); + } + + initPriority(localPalettePriority); + + initializeEditingDomain(); + + createResources(); + } + + /** + * inits the priority value + * + * @param value + * value to set + */ + protected void initPriority(final ProviderPriority value) { + if (null != value) { + this.priority = value; + } else { + // by default, Medium + this.priority = ProviderPriority.MEDIUM; + } + } + + /** + * unloads resources. + */ + protected void unloadRessources() { + if (null != paletteResource && paletteResource.isLoaded()) { + paletteResource.unload(); + } + if (null != elementTypeSemResource && elementTypeSemResource.isLoaded()) { + elementTypeSemResource.unload(); + } + if (null != elementTypeUIResource && elementTypeUIResource.isLoaded()) { + elementTypeUIResource.unload(); + } + } + + + /** + * delete resources. + */ + public void deleteResource() { + unloadRessources(); + try { + if (null != paletteResource) { + paletteResource.delete(Collections.EMPTY_MAP); + } + if (null != elementTypeSemResource) { + elementTypeSemResource.delete(Collections.EMPTY_MAP); + } + if (null != elementTypeUIResource) { + elementTypeUIResource.delete(Collections.EMPTY_MAP); + } + } catch (IOException e) { + Activator.log.error(e); + } + } + + + + /** + * Clear the string builder. + */ + protected void clearStringBuilder() { + stringBuilder.setLength(0); // set length of buffer to 0 + stringBuilder.trimToSize(); // trim the underlying buffer + } + + /** + * {@inheritDoc} + */ + @Override + public boolean performFinish() { + + // Save files + saveResources(); + + // Load models on papyrus( Palettes, element types, etc...) + deployModels(); + + // unload ressources + unloadRessources(); + + return true; + } + + /** + * Load models on papyrus( Palettes, element types, etc...). + */ + abstract protected void deployModels(); + + /** + * save resources() + */ + abstract protected void saveResources(); + + /** + * {@inheritDoc} + */ + @Override + public boolean performCancel() { + unloadRessources(); + return super.performCancel(); + } + + /** + * create the resource and set it the palette configuration model + */ + protected void createResources() { + createPaletteResource(); + createElementTypesResources(); + } + + + /** + * Create Element type resources. + */ + protected void createElementTypesResources() { + + URI elementTypeUIURI = null; + URI elementTypeSemURI = null; + + File elementTypeUIFile = null; + File elementTypeSemFile = null; + + switch (paletteContext) { + + case New: + PaletteConfiguration paletteModel = (PaletteConfiguration) paletteResource.getContents().get(0); + clearStringBuilder(); + stringBuilder.append(paletteModel.getId()); + stringBuilder.append(PaletteConstants.ELEMENTTYPE_UI_IDENTIFIER_POSTFIX); + stringBuilder.append(STR_DOT); + stringBuilder.append(PaletteConstants.ELEMENTTYPE_EXTENSION); + String pathUI = Activator.getInstance().getStateLocation().append(stringBuilder.toString()).toString(); + + clearStringBuilder(); + stringBuilder.append(paletteModel.getId()); + stringBuilder.append(PaletteConstants.ELEMENTTYPE_SEMENTIC_IDENTIFIER_POSTFIX); + stringBuilder.append(STR_DOT); + stringBuilder.append(PaletteConstants.ELEMENTTYPE_EXTENSION); + String pathSem = Activator.getInstance().getStateLocation().append(stringBuilder.toString()).toString(); + + elementTypeUIFile = new File(pathUI); + elementTypeSemFile = new File(pathSem); + break; + + case Local: + clearStringBuilder(); + stringBuilder.append(((PapyrusPaletteService.LocalExtendedProviderDescriptor) descriptor).getContributionID()); + stringBuilder.append(PaletteConstants.ELEMENTTYPE_UI_IDENTIFIER_POSTFIX); + stringBuilder.append(STR_DOT); + stringBuilder.append(PaletteConstants.ELEMENTTYPE_EXTENSION); + elementTypeUIFile = Activator.getInstance().getStateLocation().append(stringBuilder.toString()).toFile(); + + clearStringBuilder(); + stringBuilder.append(((PapyrusPaletteService.LocalExtendedProviderDescriptor) descriptor).getContributionID()); + stringBuilder.append(PaletteConstants.ELEMENTTYPE_SEMENTIC_IDENTIFIER_POSTFIX); + stringBuilder.append(STR_DOT); + stringBuilder.append(PaletteConstants.ELEMENTTYPE_EXTENSION); + elementTypeSemFile = Activator.getInstance().getStateLocation().append(stringBuilder.toString()).toFile(); + break; + + case Plugin: + String path = PapyrusPalettePreferences.getPaletteRedefinition(descriptor.getContributionID()); + path = path.substring(0, path.length() - PaletteConstants.PALETTECONFIGURATION_EXTENSION.length() - 1); + + clearStringBuilder(); + stringBuilder.append(path); + stringBuilder.append(PaletteConstants.ELEMENTTYPE_UI_IDENTIFIER_POSTFIX); + stringBuilder.append(STR_DOT); + stringBuilder.append(PaletteConstants.ELEMENTTYPE_EXTENSION); + elementTypeUIFile = Activator.getInstance().getStateLocation().append(stringBuilder.toString()).toFile(); + + clearStringBuilder(); + stringBuilder.append(path); + stringBuilder.append(PaletteConstants.ELEMENTTYPE_SEMENTIC_IDENTIFIER_POSTFIX); + stringBuilder.append(STR_DOT); + stringBuilder.append(PaletteConstants.ELEMENTTYPE_EXTENSION); + elementTypeSemFile = Activator.getInstance().getStateLocation().append(stringBuilder.toString()).toFile(); + break; + + case Workspace: + Object contributions = ((PapyrusPaletteService.LocalProviderDescriptor) descriptor).getDescription().getContributions(); + if (contributions instanceof String) { + + elementTypeUIFile = new File(((String) contributions).replace(STR_DOT + PaletteConstants.PALETTECONFIGURATION_EXTENSION, PaletteConstants.ELEMENTTYPE_UI_IDENTIFIER_POSTFIX + STR_DOT + + PaletteConstants.ELEMENTTYPE_EXTENSION)); + elementTypeSemFile = new File(((String) contributions).replace(STR_DOT + PaletteConstants.PALETTECONFIGURATION_EXTENSION, PaletteConstants.ELEMENTTYPE_SEMENTIC_IDENTIFIER_POSTFIX + STR_DOT + PaletteConstants.ELEMENTTYPE_EXTENSION)); + + elementTypeUIURI = URI.createPlatformResourceURI(elementTypeUIFile.getPath(), false); + elementTypeSemURI = URI.createPlatformResourceURI(elementTypeSemFile.getPath(), false); + } + break; + + default: + break; + } + + if (null == elementTypeUIFile || null == elementTypeSemURI) { + elementTypeUIURI = URI.createFileURI(elementTypeUIFile.getAbsolutePath()); + elementTypeSemURI = URI.createFileURI(elementTypeSemFile.getAbsolutePath()); + } + + // Create resource + elementTypeSemResource = editingDomain.getResourceSet().createResource(elementTypeSemURI); + elementTypeUIResource = editingDomain.getResourceSet().createResource(elementTypeUIURI); + + if (!PaletteUtils.notErrorOnFile(elementTypeUIFile) && !PaletteUtils.notErrorOnFile(elementTypeSemFile)) { + + ElementTypeSetConfiguration emptyElementTypeModelSem = getEmptyElementTypeModel(elementTypeSemResource.getURI().lastSegment().replace(STR_DOT + PaletteConstants.ELEMENTTYPE_EXTENSION, ""));//$NON-NLS-1$ + ElementTypeSetConfiguration emptyElementTypeModelUI = getEmptyElementTypeModel(elementTypeUIResource.getURI().lastSegment().replace(STR_DOT + PaletteConstants.ELEMENTTYPE_EXTENSION, ""));//$NON-NLS-1$ + + // Add it to the resource + CompoundCommand compoundCommand = new CompoundCommand(); + compoundCommand.append(new AddCommand(editingDomain, elementTypeSemResource.getContents(), emptyElementTypeModelSem)); + compoundCommand.append(new AddCommand(editingDomain, elementTypeUIResource.getContents(), emptyElementTypeModelUI)); + editingDomain.getCommandStack().execute(compoundCommand); + } + + if (null != elementTypeUIResource || null != elementTypeSemResource) { + try { + elementTypeSemResource.load(Collections.emptyMap()); + EcoreUtil.resolveAll(elementTypeSemResource); + elementTypeUIResource.load(Collections.emptyMap()); + EcoreUtil.resolveAll(elementTypeUIResource); + elementTypeSemResource.getResourceSet().getLoadOptions().put(PaletteRessourcesConstants.ELEMENTTYPE_SEMENTIC_RESSOURCE_IDENTIFIER, elementTypeSemResource); + elementTypeUIResource.getResourceSet().getLoadOptions().put(PaletteRessourcesConstants.ELEMENTTYPE_UI_RESSOURCE_IDENTIFIER, elementTypeUIResource); + } catch (IOException e) { + Activator.log.error(e); + } + } + } + + + + /** + * @return An empty Element type model with intialIdentifier as identifier. + */ + protected ElementTypeSetConfiguration getEmptyElementTypeModel(final String initialIdentifer) { + // Create elementType models + ElementTypeSetConfiguration elementTypeUI = ElementTypesConfigurationsFactory.eINSTANCE.createElementTypeSetConfiguration(); + elementTypeUI.setIdentifier(initialIdentifer); + elementTypeUI.setName(initialIdentifer); + elementTypeUI.setMetamodelNsURI(initialIdentifer); + return elementTypeUI; + } + + /** + * Create palette resource. + */ + protected void createPaletteResource() { + + URI fileURI = null; + + switch (paletteContext) { + + case New: + // Create a volatile default file (not to be save) + // Create a initial void model + PaletteConfiguration paletteModel = CreatePaletteItemUtil.createInitialModel(); + + clearStringBuilder(); + stringBuilder.append("NewPalette");//$NON-NLS-1$ + stringBuilder.append(STR_DOT); + stringBuilder.append(PaletteConstants.PALETTECONFIGURATION_EXTENSION); + + String path = Activator.getInstance().getStateLocation().append(stringBuilder.toString()).toString();// $NON-NLS-1$ + fileURI = URI.createFileURI(path); + + paletteResource = editingDomain.getResourceSet().createResource(fileURI); + // Add it to the resource + Command addCommand = new AddCommand(editingDomain, paletteResource.getContents(), paletteModel); + editingDomain.getCommandStack().execute(addCommand); + break; + + case Local: + clearStringBuilder(); + stringBuilder.append(((PapyrusPaletteService.LocalExtendedProviderDescriptor) descriptor).getContributionID()); + stringBuilder.append(STR_DOT); + stringBuilder.append(PaletteConstants.PALETTECONFIGURATION_EXTENSION); + + File file = Activator.getInstance().getStateLocation().append(stringBuilder.toString()).toFile(); + + if (PaletteUtils.notErrorOnFile(file)) { + fileURI = URI.createFileURI(file.getAbsolutePath()); + paletteResource = editingDomain.getResourceSet().createResource(fileURI); + } + break; + + case Plugin: + fileURI = PaletteUtil.getRedefinitionFileURI(descriptor.getContributionID()); + if (null != fileURI) { + paletteResource = editingDomain.getResourceSet().createResource(fileURI); + } + break; + + case Workspace: + Object contributions = ((PapyrusPaletteService.LocalProviderDescriptor) descriptor).getDescription().getContributions(); + if (contributions instanceof String) { + fileURI = URI.createPlatformResourceURI((String) contributions, false); + paletteResource = editingDomain.getResourceSet().createResource(fileURI); + } + break; + + default: + break; + + } + + if (null != paletteResource) { + try { + paletteResource.load(Collections.emptyMap()); + paletteResource.getResourceSet().getLoadOptions().put(PaletteRessourcesConstants.PALETTE_RESSOURCE_IDENTIFIER, paletteResource); + EcoreUtil.resolveAll(paletteResource); + + } catch (IOException e) { + Activator.log.error(e); + } + } + } + + /** + * This sets up the editing domain for the model editor. + */ + protected void initializeEditingDomain() { + // Create an adapter factory that yields item providers. + // + adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE); + + adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory() { + @Override + public Adapter createResourceSetAdapter() { + return new ResourceSetItemProvider(this) { + @Override + public Collection<?> getChildren(final Object object) { + ResourceSet resourceSet = (ResourceSet) object; + if (!resourceSet.getResources().isEmpty() && resourceSet.getResources().get(0).getContents().get(0) instanceof PaletteConfiguration) { + return ((PaletteConfiguration) resourceSet.getResources().get(0).getContents().get(0)).getDrawerConfigurations(); // For Drawers as root + } + return Collections.emptyList(); + } + }; + } + }); + adapterFactory.addAdapterFactory(new CustomPaletteconfigurationItemProviderAdapterFactory()); + adapterFactory.addAdapterFactory(new EcoreItemProviderAdapterFactory()); + adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory()); + + // Create the editing domain with a special command stack. + editingDomain = new TransactionalEditingDomainImpl(adapterFactory); + } + +} diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/dialog/ConfigurationInformationComposite.java b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/dialog/ConfigurationInformationComposite.java new file mode 100644 index 00000000000..d2587d5dff8 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/dialog/ConfigurationInformationComposite.java @@ -0,0 +1,336 @@ +/***************************************************************************** + * Copyright (c) 2010 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: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + *****************************************************************************/ +package org.eclipse.papyrus.toolsmiths.palette.dialog; + +import java.util.List; + +import org.eclipse.jface.window.Window; +import org.eclipse.papyrus.infra.gmfdiag.common.Activator; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.Configuration; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.IconDescriptor; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.PaletteconfigurationFactory; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.ToolConfiguration; +import org.eclipse.papyrus.infra.widgets.editors.BundleIconExplorerDialog; +import org.eclipse.papyrus.toolsmiths.palette.Messages; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +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; +import org.eclipse.uml2.uml.Profile; + + +/** + * Class in charge of the composite in the {@link LocalPaletteContentPage} + */ +public class ConfigurationInformationComposite { + + /** current selected entry proxy */ + protected Configuration selectedConfiguration; + + /** proxy name text */ + protected Text nameText; + + /** proxy description text */ + protected Text descriptionText; + + /** proxy icon text */ + protected Text iconText; + + /** referenced proxy text */ + protected Text referencedText; + + /** list of applied profiles */ + protected List<Profile> appliedProfiles; + + /** button for icon selection */ + protected Button iconButton; + + /** protocol for platform plugin URLs */ + protected static final String PLUGIN_PROTOCOL = "platform:/plugin/"; //$NON-NLS-1$ + + /** + * Creates the content of the information composite + * + * @param parent + * the composite where to add created controls + * @param appliedProfiles + * the list of applied profiles + * @return the newly created composite + */ + public Composite createComposite(final Composite parent, List<Profile> appliedProfiles) { + this.appliedProfiles = appliedProfiles; + Composite composite = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(3, false); + composite.setLayout(layout); + GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); + data.widthHint = 260; + data.horizontalIndent = 10; + composite.setLayoutData(data); + + Label entryInformationLabel = new Label(composite, SWT.NONE); + entryInformationLabel.setText(Messages.Local_Palette_Entry_Information); + data = new GridData(SWT.FILL, SWT.FILL, true, false); + data.horizontalSpan = 3; + entryInformationLabel.setLayoutData(data); + + Label nameLabel = new Label(composite, SWT.NONE); + nameLabel.setText(Messages.Local_Palette_Entry_Name); + data = new GridData(SWT.FILL, SWT.FILL, false, false); + nameLabel.setLayoutData(data); + nameText = new Text(composite, SWT.LEAD | SWT.BORDER); + data = new GridData(SWT.FILL, SWT.FILL, true, false); + nameText.setLayoutData(data); + nameText.addFocusListener(new NameFocusListener()); + data = new GridData(SWT.FILL, SWT.FILL, true, false); + data.horizontalSpan = 2; + nameText.setLayoutData(data); + + Label referencedLabel = new Label(composite, SWT.NONE); + referencedLabel.setText(Messages.Local_Palette_Entry_Reference); + data = new GridData(SWT.FILL, SWT.BEGINNING, true, false); + referencedLabel.setLayoutData(data); + referencedText = new Text(composite, SWT.LEAD | SWT.BORDER | SWT.READ_ONLY); + data = new GridData(SWT.FILL, SWT.FILL, true, false); + referencedText.setLayoutData(data); + data = new GridData(SWT.FILL, SWT.FILL, true, false); + data.horizontalSpan = 2; + referencedText.setLayoutData(data); + + Label descriptionLabel = new Label(composite, SWT.NONE); + descriptionLabel.setText(Messages.Local_Palette_Entry_Description); + data = new GridData(SWT.FILL, SWT.BEGINNING, true, false); + descriptionLabel.setLayoutData(data); + descriptionText = new Text(composite, SWT.WRAP | SWT.BORDER); + data = new GridData(SWT.FILL, SWT.FILL, true, true); + data.horizontalSpan = 2; + data.widthHint = 160; + descriptionText.setLayoutData(data); + descriptionText.addFocusListener(new DescriptionFocusListener()); + + + Label iconLabel = new Label(composite, SWT.NONE); + iconLabel.setText(Messages.Local_Palette_Entry_Icon); + data = new GridData(SWT.FILL, SWT.BEGINNING, true, false); + iconLabel.setLayoutData(data); + iconText = new Text(composite, SWT.LEAD | SWT.BORDER); + data = new GridData(SWT.FILL, SWT.FILL, true, false); + iconText.setLayoutData(data); + iconText.addFocusListener(new IconFocusListener()); + iconButton = new Button(composite, SWT.NONE); + iconButton.setText("Select..."); + iconButton.addMouseListener(new MouseAdapter() { + + /** + * @{inheritDoc + */ + @Override + public void mouseUp(MouseEvent e) { + BundleIconExplorerDialog dialog = new BundleIconExplorerDialog(parent.getShell(), iconText.getText()); + if (Window.OK == dialog.open()) { + Object[] values = dialog.getResult(); + if (values.length != 1) { + Activator.log.error("Waiting one icon path, but found " + values.length, null);//$NON-NLS-1$ + } else { + iconText.setText(values[0].toString()); + + String bundleId = dialog.getCurrentBundleName(); + String iconPath = dialog.getIconPath(); + updateIconInConfiguration(bundleId, iconPath); + } + } + } + + }); + + return composite; + } + + + private void updateIconInConfiguration(String bundleId, String iconPath) { + if (selectedConfiguration != null) { + IconDescriptor descriptor = PaletteconfigurationFactory.eINSTANCE.createIconDescriptor(); + if (bundleId != null && iconPath != null) { + descriptor.setPluginID(bundleId); + descriptor.setIconPath(iconPath); + } + selectedConfiguration.setIcon(descriptor); + } + } + + /** + * Updates the name field in the information area + */ + protected void updateNameEntryField() { + if (selectedConfiguration != null) { + nameText.setText((selectedConfiguration.getLabel() != null) ? selectedConfiguration.getLabel() : ""); + nameText.setEnabled(true); + } else { + nameText.setText(""); + nameText.setEnabled(false); + } + + } + + /** + * Updates the reference field in the information area + */ + protected void updateReferencedEntryField() { + if (selectedConfiguration instanceof ToolConfiguration) { + ToolConfiguration configuration = ((ToolConfiguration) selectedConfiguration); + } else { + referencedText.setText(""); + referencedText.setEnabled(false); + } + } + + /** + * Updates the description field in the information area + */ + protected void updateDescriptionEntryField() { + if (selectedConfiguration != null) { + descriptionText.setText((selectedConfiguration.getDescription() != null) ? selectedConfiguration.getDescription() : ""); + descriptionText.setEnabled(true); + } else { + descriptionText.setText(""); + descriptionText.setEnabled(false); + } + } + + /** + * Updates the icon field in the information area + */ + protected void updateIconEntryField() { + if (selectedConfiguration != null) { + IconDescriptor descriptor = selectedConfiguration.getIcon(); + if (descriptor != null) { + String iconPath = descriptor.getIconPath(); + String bundleId = descriptor.getPluginID(); + if (iconPath != null && bundleId != null) { + iconText.setText(PLUGIN_PROTOCOL + bundleId + iconPath); + } + } + iconText.setEnabled(true); + } else { + iconText.setText(""); + iconText.setEnabled(true); + } + } + + /** + * Sets the new Selected entry + * + * @param configuration + * the selectedConfiguration to set + */ + public void setSelectedConfiguration(Configuration configuration) { + this.selectedConfiguration = configuration; + + updateNameEntryField(); + updateIconEntryField(); + updateReferencedEntryField(); + updateDescriptionEntryField(); + } + + /** + * focus listener for the name text field + */ + protected class NameFocusListener implements FocusListener { + + /** + * @{inheritDoc + */ + @Override + public void focusGained(FocusEvent e) { + } + + /** + * @{inheritDoc + */ + @Override + public void focusLost(FocusEvent e) { + if (selectedConfiguration != null) { + selectedConfiguration.setLabel(nameText.getText().trim()); + } + } + + } + + /** + * focus listener for the name text field + */ + protected class DescriptionFocusListener implements FocusListener { + + /** + * @{inheritDoc + */ + @Override + public void focusGained(FocusEvent e) { + } + + /** + * @{inheritDoc + */ + @Override + public void focusLost(FocusEvent e) { + if (selectedConfiguration != null) { + selectedConfiguration.setDescription(descriptionText.getText().trim()); + } + } + } + + /** + * focus listener for the name text field + */ + protected class IconFocusListener implements FocusListener { + + /** + * @{inheritDoc + */ + @Override + public void focusGained(FocusEvent e) { + } + + /** + * @{inheritDoc + */ + @Override + public void focusLost(FocusEvent e) { + String text = iconText.getText(); + if (selectedConfiguration != null && text != null && !text.equals("")) { + + // parse the text.... + if (!text.startsWith(PLUGIN_PROTOCOL)) { + return; + } + + text = text.substring(PLUGIN_PROTOCOL.length(), text.length()); + + int i = text.indexOf("/"); + if (i < 1) { + return; + } + String bundlePath = text.substring(0, i); + String iconPath = text.substring(bundlePath.length(), text.length()); + + updateIconInConfiguration(bundlePath, iconPath); + } + } + } + +} diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/dialog/ExportPaletteConfigurationWizard.java b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/dialog/ExportPaletteConfigurationWizard.java new file mode 100644 index 00000000000..06deebbf6f9 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/dialog/ExportPaletteConfigurationWizard.java @@ -0,0 +1,119 @@ +/***************************************************************************** + * Copyright (c) 2016 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: + * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation + * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 507654 Change the save order + *****************************************************************************/ + +package org.eclipse.papyrus.toolsmiths.palette.dialog; + +import java.io.IOException; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteService.ProviderDescriptor; +import org.eclipse.papyrus.infra.types.ElementTypeSetConfiguration; +import org.eclipse.papyrus.toolsmiths.palette.Messages; +import org.eclipse.papyrus.toolsmiths.palette.PaletteConstants; +import org.eclipse.papyrus.toolsmiths.palette.utils.PaletteUtils; +import org.eclipse.papyrus.infra.gmfdiag.common.Activator; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.dialogs.WizardNewFileCreationPage; + +/** + * Wizard to export an existing Palette Definition and its associated models files. + */ +public class ExportPaletteConfigurationWizard extends AbstractPaletteConfigurationWizard { + + /** content page */ + protected PaletteConfigurationContentPage contentPage; + + /** the new file creation page of the wizard */ + private WizardNewFileCreationPage newFileCreationPage; + + /** + * Creates a new local Palette Wizard. + * + * @param part + * the editor part where the palette is available + * @param descriptor + * the descriptor to edit + */ + public ExportPaletteConfigurationWizard(final IEditorPart part, final ProviderDescriptor descriptor) { + super(part, descriptor); + setWindowTitle(Messages.ExportPaletteConfigurationWizard_ExportWiazrdLabel); + } + + /** + * {@inheritDoc} + */ + @Override + public void addPages() { + super.addPages(); + + newFileCreationPage = new WizardNewFileCreationPage("", new StructuredSelection());//$NON-NLS-1$ + + newFileCreationPage.setTitle(Messages.ExportPaletteConfigurationWizard_export_palette); + newFileCreationPage.setDescription(Messages.ExportPaletteConfigurationWizard_Export_description); + + addPage(newFileCreationPage); + } + + + /** + * {@inheritDoc} + */ + @Override + protected void saveResources() { + + // Get the wanted location + String selectedPath = newFileCreationPage.getContainerFullPath().append(newFileCreationPage.getFileName()).toString(); + + clearStringBuilder(); + stringBuilder.append(selectedPath); + stringBuilder.append(PaletteConstants.ELEMENTTYPE_SEMENTIC_IDENTIFIER_POSTFIX); + stringBuilder.append(STR_DOT); + stringBuilder.append(PaletteConstants.ELEMENTTYPE_EXTENSION); + elementTypeSemResource.setURI(URI.createFileURI(stringBuilder.toString())); + + clearStringBuilder(); + stringBuilder.append(selectedPath); + stringBuilder.append(PaletteConstants.ELEMENTTYPE_UI_IDENTIFIER_POSTFIX); + stringBuilder.append(STR_DOT); + stringBuilder.append(PaletteConstants.ELEMENTTYPE_EXTENSION); + elementTypeUIResource.setURI(URI.createFileURI(stringBuilder.toString())); + + clearStringBuilder(); + stringBuilder.append(selectedPath); + stringBuilder.append(STR_DOT); + stringBuilder.append(PaletteConstants.PALETTECONFIGURATION_EXTENSION); + // Set new path + paletteResource.setURI(URI.createFileURI(stringBuilder.toString())); + + // Save + try { + // Checks if model are not void and are useful + if (!((ElementTypeSetConfiguration) elementTypeUIResource.getContents().get(0)).getElementTypeConfigurations().isEmpty()) { + elementTypeSemResource.save(PaletteUtils.saveOptions); + elementTypeUIResource.save(PaletteUtils.saveOptions); + } + paletteResource.save(PaletteUtils.saveOptions); + } catch (IOException e) { + Activator.log.error(e); + } + } + + /** + * {@inheritDoc} + */ + @Override + protected void deployModels() { + // Nothings to loads + } +} diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/dialog/PaletteConfigurationContentPage.java b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/dialog/PaletteConfigurationContentPage.java new file mode 100644 index 00000000000..5aab7fc92d4 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/dialog/PaletteConfigurationContentPage.java @@ -0,0 +1,1498 @@ +/***************************************************************************** + * Copyright (c) 2009, 2014 CEA LIST, Christian W. Damus, 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: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + * Christian W. Damus - bug 454578 + * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - new implemenatation for palette configuration model case + * + *****************************************************************************/ +package org.eclipse.papyrus.toolsmiths.palette.dialog; + +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 org.eclipse.core.runtime.Assert; +import org.eclipse.emf.common.command.AbstractCommand; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.CompoundCommand; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.util.Diagnostic; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.util.Diagnostician; +import org.eclipse.emf.ecore.util.EContentAdapter; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.edit.command.AddCommand; +import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; +import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor; +import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter; +import org.eclipse.emf.edit.ui.dnd.LocalTransfer; +import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter; +import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; +import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; +import org.eclipse.gef.palette.PaletteContainer; +import org.eclipse.gef.palette.PaletteDrawer; +import org.eclipse.gef.palette.PaletteEntry; +import org.eclipse.gef.palette.PaletteRoot; +import org.eclipse.gef.palette.PaletteStack; +import org.eclipse.gef.palette.PaletteToolbar; +import org.eclipse.gef.palette.ToolEntry; +import org.eclipse.gmf.runtime.common.core.service.ProviderPriority; +import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFlyOutPalette; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.util.LocalSelectionTransfer; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITreeSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerComparator; +import org.eclipse.jface.viewers.ViewerFilter; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.osgi.util.NLS; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PaletteUtil; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.ChildConfiguration; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.Configuration; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.DrawerConfiguration; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.LeafConfiguration; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.PaletteConfiguration; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.PaletteconfigurationFactory; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.SeparatorConfiguration; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.StackConfiguration; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.ToolConfiguration; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.utils.CreatePaletteItemUtil; +import org.eclipse.papyrus.infra.properties.ui.runtime.DisplayEngine; +import org.eclipse.papyrus.infra.properties.ui.util.PropertiesDisplayHelper; +import org.eclipse.papyrus.infra.widgets.Activator; +import org.eclipse.papyrus.toolsmiths.palette.Messages; +import org.eclipse.papyrus.toolsmiths.palette.provider.PaletteLabelProvider; +import org.eclipse.papyrus.toolsmiths.palette.provider.ProfileToolsMetaclassStereotypeTreeContentProvider; +import org.eclipse.papyrus.toolsmiths.palette.provider.ProfileToolsStereotypeMetaclassTreeContentProvider; +import org.eclipse.papyrus.toolsmiths.palette.provider.UMLToolsTreeContentProvider; +import org.eclipse.swt.SWT; +import org.eclipse.swt.dnd.DND; +import org.eclipse.swt.dnd.DropTargetEvent; +import org.eclipse.swt.dnd.FileTransfer; +import org.eclipse.swt.dnd.Transfer; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +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.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.ToolBar; +import org.eclipse.swt.widgets.ToolItem; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.TreeItem; +import org.eclipse.ui.IEditorPart; +import org.eclipse.uml2.uml.Package; +import org.eclipse.uml2.uml.Profile; +import org.eclipse.uml2.uml.Stereotype; + +/** + * Wizard page for information about the new local palette definition + */ +public class PaletteConfigurationContentPage extends WizardPage { + + /** icon path for the add button */ + protected static final String ADD_ICON = "/icons/arrow_right.gif"; //$NON-NLS-1$ + + /** icon path for the create drawer button */ + protected static final String CREATE_DRAWERS_ICON = "/icons/new_drawer.gif";//$NON-NLS-1$ + + /** icon path for the create separator button */ + protected static final String CREATE_SEPARATOR_ICON = "/icons/new_separator.gif";//$NON-NLS-1$ + + /** icon path for the create stack button */ + protected static final String CREATE_STACK_ICON = "/icons/new_stack.gif";//$NON-NLS-1$ + + /** icon path for the create stack button */ + protected static final String CREATE_TOOL_ICON = "/icons/new_tool.gif";//$NON-NLS-1$ + + /** icon path for the delete button */ + protected static final String DELETE_ICON = "/icons/delete.gif";//$NON-NLS-1$ + + /** icon path for the remove button */ + protected static final String REMOVE_ICON = "/icons/arrow_left.gif"; //$NON-NLS-1$ + + /** icon path when tools are shown */ + protected static final String SHOWN_TOOLS_ICON = "/icons/tools_shown.gif"; //$NON-NLS-1$ + + /** path to the icon */ + protected static final String WIZARD_ICON = "/icons/local_desc_wiz.png"; //$NON-NLS-1$ + + /** icon for the content provider switch button */ + protected static final String SWITCH_CONTENT_PROVIDER_ICON = "/icons/switch_provider.gif"; //$NON-NLS-1$ + + /** the label for drawer */ + private static final String DRAWER_LABEL = Messages.PaletteConfigurationContentPage_Drawer; + + /** The label for new tool */ + private static final String NEW_TOOL_LABEL = Messages.PaletteConfigurationContentPage_NewTool; + + /** the label for separator */ + private static final String SEPARATOR_LABEL = Messages.PaletteConfigurationContentPage_Separator; + + /** the label for stack */ + private static final String STACK_LABEL = Messages.PaletteConfigurationContentPage_Stack; + + /** label for the standard tools */ + private static final String UML_TOOLS_LABEL = Messages.PaletteConfigurationContentPage_UMLTools; + + /** Validator key for toolbar items */ + private final static String VALIDATOR = "validator"; //$NON-NLS-1$ + + /** the add button */ + private Button addButton; + + /** the remove button */ + private Button removeButton; + + /** the tree viewer for available tools */ + private TreeViewer availableToolsViewer; + + /** combo to select which profile tools should be visible */ + private Combo profileCombo; + + /** list of profiles that can provide tools */ + private List<String> profileComboList = new ArrayList<String>(); + + /** the tree viewer for the edited palette */ + private TreeViewer paletteTreeViewer; + + /** the display engine */ + private DisplayEngine displayEngine; + + /** instance of the filter used to show/hide drawers */ + private final ViewerFilter drawerFilter = new DrawerFilter(); + + /** the editing domain */ + private AdapterFactoryEditingDomain editingDomain; + + /** editor part in which the palette is created */ + private IEditorPart editorPart; + + /** the label provider for the edited palette */ + private PaletteLabelProvider paletteLabelProvider; + + /** priority of the current edited palette */ + private ProviderPriority priority; + + /** the properties composite */ + private Composite propertiesComposite; + + /** tool item in charge of toggling content providers in the available tool viewer */ + protected ToolItem toggleContentProvider; + + /** the toolbar for actions on edited palette */ + private ToolBar toolbar; + + /** instance of the filter used to show/hide tools */ + private final ViewerFilter toolFilter = new ToolFilter(); + + /** enumeration of existing entry types */ + public enum EntryType { + ASPECT_TOOL, DRAWER, SEPARATOR, STACK, TOOL + } + + /** + * Filter for the viewer. Hide/show Drawers + */ + protected class DrawerFilter extends ViewerFilter { + + /** + * {@inheritDoc} + */ + @Override + public boolean select(final Viewer viewer, final Object parentElement, final Object element) { + boolean notDrawer = true; + if (element instanceof PaletteDrawer) { + notDrawer = false; + } + return notDrawer; + } + } + + /** + * A viewer comparator for label of Palette Entry + */ + protected class LabelViewerComparator extends ViewerComparator { + + /** + * Creates a new LabelViewerComparator. + */ + public LabelViewerComparator() { + super(); + } + + /** + * {@inheritDoc} + */ + @Override + public int compare(final Viewer testViewer, final Object e1, final Object e2) { + String label1 = "";//$NON-NLS-1$ + String label2 = "";//$NON-NLS-1$ + + if (e1 instanceof PaletteEntry) { + label1 = ((PaletteEntry) e1).getLabel(); + } else if (e1 instanceof Stereotype) { + label1 = ((Stereotype) e1).getName(); + } + if (e2 instanceof PaletteEntry) { + label2 = ((PaletteEntry) e2).getLabel(); + } else if (e2 instanceof Stereotype) { + label2 = ((Stereotype) e2).getName(); + } + + int comparaison; + if (null == label1 && null == label2) { + comparaison = 0; + } else if (null == label1) { + comparaison = 1; + } else if (null == label2) { + comparaison = -1; + } else { + comparaison = label1.compareTo(label2); + } + return comparaison; + } + } + + /** + * Validator for the create separator or stack tool item. Only valid when selection is a {@link PaletteEntryProxy} or a {@link PaletteLocalDrawerProxy} + */ + protected class PaletteConfigurationEntrySelectedValidator implements ToolBarItemValidator { + + /** + * @{inheritDoc + */ + @Override + public boolean isEnable() { + boolean enable = false; + // retrieve selection + if (null != paletteTreeViewer && !paletteTreeViewer.getControl().isDisposed()) { + // retrieve selection. first element should be a drawer + IStructuredSelection selection = (IStructuredSelection) paletteTreeViewer.getSelection(); + if (null != selection) { + Object object = selection.getFirstElement(); + enable = (object instanceof Configuration); + } + } + return enable; + } + } + + + /** + * validator for the create separator or stack tool item. Only valid when selection is a {@link PaletteEntryProxy} or a {@link PaletteLocalDrawerProxy} + */ + protected class PaletteConfigurationStackLeafSelectedValidator implements ToolBarItemValidator { + + /** + * @{inheritDoc + */ + @Override + public boolean isEnable() { + boolean enable = false; + // retrieve selection + if (paletteTreeViewer != null && !paletteTreeViewer.getControl().isDisposed()) { + // retrieve selection. first element should be a drawer + IStructuredSelection selection = (IStructuredSelection) paletteTreeViewer.getSelection(); + if (null != selection) { + Object object = selection.getFirstElement(); + enable = (object instanceof Configuration && !(((Configuration) object).eContainer() instanceof StackConfiguration)); + } + } + return enable; + } + } + + + + /** + * Listener for the profile combo. It changes the input of the following viewer. + */ + protected class ProfileComboSelectionListener implements SelectionListener, ModifyListener { + + /** + * handles the change selection for the combo + */ + protected void handleSelectionChanged() { + int index = profileCombo.getSelectionIndex(); + if (0 <= index && index < profileCombo.getItems().length) { + String name = profileComboList.get(index); + + Collection<PaletteEntry> standardEntries = getAllVisibleStandardEntries(); + // retrieve the profile or uml standards tools to display + if (UML_TOOLS_LABEL.equals(name)) { + // change content provider + availableToolsViewer.setContentProvider(new UMLToolsTreeContentProvider()); + availableToolsViewer.setInput(standardEntries); + toggleContentProvider.setEnabled(false); + } else { + if (null != toggleContentProvider && !toggleContentProvider.isDisposed()) { + toggleContentProvider.setEnabled(true); + } + // switch content provider + // this is a profile in case of uml2 tools + Profile profile = getAllAppliedProfiles().get(index); + if (toggleContentProvider.getSelection()) { + availableToolsViewer.setContentProvider(new ProfileToolsStereotypeMetaclassTreeContentProvider(profile, standardEntries)); + } else { + availableToolsViewer.setContentProvider(new ProfileToolsMetaclassStereotypeTreeContentProvider(profile, standardEntries)); + } + + // generate tools for given profile + availableToolsViewer.setInput(profile); + } + } + } + + /** + * {@inheritDoc} + */ + @Override + public void modifyText(final ModifyEvent e) { + handleSelectionChanged(); + } + + /** + * {@inheritDoc} + */ + @Override + public void widgetDefaultSelected(final SelectionEvent e) { + // Do nothing + } + + /** + * {@inheritDoc} + */ + @Override + public void widgetSelected(final SelectionEvent e) { + handleSelectionChanged(); + } + } + + + /** + * Item validator interface + */ + interface ToolBarItemValidator { + + /** + * Checks if the button should be enable or not + * + * @return <code>true</code> if the button should be enable + */ + public boolean isEnable(); + } + + /** + * Filter for the viewer. Hide/show Drawers + */ + protected class ToolFilter extends ViewerFilter { + + /** + * {@inheritDoc} + */ + @Override + public boolean select(final Viewer viewer, final Object parentElement, final Object element) { + return !(element instanceof ToolEntry); + } + } + + /** Listener to validate page on change. */ + EContentAdapter adapter = new EContentAdapter() { + /** + * @see org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification) + */ + @Override + public void notifyChanged(Notification msg) { + setPageComplete(validatePage()); + } + }; + + /** the palette configuration model */ + private PaletteConfiguration paletteConfigurationModel; + + /** + * Constructor. + * + * @param editorPart + * @param editingDomain + */ + public PaletteConfigurationContentPage(final IEditorPart editorPart, final AdapterFactoryEditingDomain editingDomain) { + super(Messages.Local_Palette_ContentPage_Name, Messages.Local_Palette_ContentPage_Title, Activator.imageDescriptorFromPlugin(org.eclipse.papyrus.infra.gmfdiag.common.Activator.ID, WIZARD_ICON)); + this.editorPart = editorPart; + this.editingDomain = editingDomain; + paletteConfigurationModel = getPaletteConfigurationModel(); + paletteConfigurationModel.eAdapters().add(adapter); + } + + /** + * Constructor. + * + * @param pageName + */ + protected PaletteConfigurationContentPage(final String pageName) { + super(pageName); + } + + /** + * Add drag support from the available tools viewer + */ + protected void addAvailableToolsDragSupport() { + // transfer types + Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() }; + int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; + // drag listener + + availableToolsViewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(availableToolsViewer)); + } + + + /** + * Adds drag ability to the palette preview composite + */ + protected void addPalettePreviewDragSupport() { + // transfer types + Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() }; + int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; + // drag listener + paletteTreeViewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(paletteTreeViewer)); + } + + /** + * Add drop behavior for the palette preview + */ + protected void addPalettePreviewDropSupport() { + // transfer types + Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() }; + int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; + EditingDomainViewerDropAdapter listener = new EditingDomainViewerDropAdapter(editingDomain, paletteTreeViewer) { + + /** + * {@inheritDoc} + */ + @Override + public void dragEnter(final DropTargetEvent event) { + super.dragEnter(event); + expandItem(event); + } + + /** + * {@inheritDoc} + */ + @Override + public void drop(final DropTargetEvent event) { + super.drop(event); + expandItem(event); + } + + /** + * Expand the TreeItem from the event + * + * @param event + */ + private void expandItem(final DropTargetEvent event) { + // Expands branch when over it to show children + if (event.item instanceof TreeItem) { + // Get the target Object of the drop + Object target = ((TreeItem) event.item).getData(); + if (target == null) { + target = paletteTreeViewer.getInput(); + } + // Expand tree + paletteTreeViewer.expandToLevel(target, 1); + } + } + + }; + + paletteTreeViewer.addDropSupport(dndOperations, transfers, listener); + } + + /** + * Creates the add button listener + */ + protected MouseListener createAddButtonListener() { + return new MouseAdapter() { + + @Override + public void mouseUp(MouseEvent e) { + // add the element selected on the left to the right tree + // check the selection. + IStructuredSelection selection = (IStructuredSelection) availableToolsViewer.getSelection(); + if (selection == null || selection.size() < 1) { + return; + } + PaletteEntry entry = (PaletteEntry) selection.getFirstElement(); + if (entry == null) { + return; + } + + // find the selection on the right + selection = (IStructuredSelection) paletteTreeViewer.getSelection(); + + Configuration target = (Configuration) selection.getFirstElement(); + + // Create Entry + CompoundCommand command = new CompoundCommand(); + ToolConfiguration node = CreatePaletteItemUtil.createToolConfiguration(entry, editingDomain.getResourceSet()); + if (null != node) { + if (target instanceof PaletteConfiguration) { + // ((PaletteConfiguration) target).getDrawerConfigurations().add((DrawerConfiguration) node); + command.append(new AddCommand(editingDomain, ((PaletteConfiguration) target).getDrawerConfigurations(), (DrawerConfiguration) node)); + } else if (target instanceof DrawerConfiguration) { + // ((DrawerConfiguration) target).getOwnedConfigurations().add((ChildConfiguration) node); + command.append(new AddCommand(editingDomain, ((DrawerConfiguration) target).getOwnedConfigurations(), (ChildConfiguration) node)); + } else if (target instanceof StackConfiguration) { + // ((StackConfiguration) target).getOwnedConfigurations().add((LeafConfiguration) node); + command.append(new AddCommand(editingDomain, ((StackConfiguration) target).getOwnedConfigurations(), (LeafConfiguration) node)); + } + } + command.append(CreatePaletteItemUtil.createElementTypesElement(editingDomain, (ToolEntry) entry, node)); + execute(command); + // Expand tree + paletteTreeViewer.expandToLevel(target, 1); + } + }; + } + + /** + * creates the buttons to add/remove entries from palette entrey and palette preview + */ + protected void createAddRemoveButtons() { + Composite composite = new Composite((Composite) getControl(), SWT.NONE); + GridLayout layout = new GridLayout(1, true); + composite.setLayout(layout); + + GridData data = new GridData(SWT.CENTER, SWT.CENTER, false, true); + composite.setLayoutData(data); + + addButton = new Button(composite, SWT.NONE); + addButton.setImage(Activator.getDefault().getImage(ADD_ICON)); + addButton.setToolTipText(Messages.PapyrusPaletteCustomizerDialog_AddButtonTooltip); + addButton.addMouseListener(createAddButtonListener()); + addButton.setEnabled(false); + + removeButton = new Button(composite, SWT.NONE); + removeButton.setImage(Activator.getDefault().getImage(REMOVE_ICON)); + removeButton.setToolTipText(Messages.PapyrusPaletteCustomizerDialog_RemoveButtonTooltip); + removeButton.addMouseListener(createRemoveButtonListener()); + removeButton.setEnabled(false); + } + + /** + * creates the available entries group + */ + protected void createAvailableToolsGroup() { + Composite parent = (Composite) getControl(); + Composite availableToolsComposite = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(2, true); + layout.marginHeight = 0; + layout.marginWidth = 0; + availableToolsComposite.setLayout(layout); + GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); + availableToolsComposite.setLayoutData(data); + + Label label = new Label(availableToolsComposite, SWT.NONE); + label.setText(Messages.Local_Palette_Available_Tools); + data = new GridData(SWT.LEFT, SWT.CENTER, true, false); + label.setLayoutData(data); + + ToolBar toolbar = new ToolBar(availableToolsComposite, SWT.HORIZONTAL); + data = new GridData(SWT.RIGHT, SWT.FILL, false, false); + toolbar.setLayoutData(data); + populateAvailableToolsToolBar(toolbar); + + createProfileCombo(availableToolsComposite); + + Tree tree = new Tree(availableToolsComposite, SWT.SINGLE | SWT.BORDER); + data = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1); + data.widthHint = 350; + // Make the tree this tall even when there is nothing in it. This will keep the + // dialog from shrinking to an unusually small size. + data.heightHint = 200; + tree.setLayoutData(data); + availableToolsViewer = new TreeViewer(tree); + availableToolsViewer.setContentProvider(new UMLToolsTreeContentProvider()); + paletteLabelProvider = new PaletteLabelProvider(); + availableToolsViewer.setLabelProvider(paletteLabelProvider); + ViewerComparator labelComparator = new LabelViewerComparator(); + availableToolsViewer.setComparator(labelComparator); + // remove the note stack and standard group + availableToolsViewer.addFilter(new ViewerFilter() { + + /** + * {@inheritDoc} + */ + @Override + public boolean select(final Viewer viewer, final Object parentElement, final Object element) { + boolean visible = true; + if (element instanceof PaletteStack && "noteStack".equals(((PaletteStack) element).getId())) {//$NON-NLS-1$ + visible = false; + } else if (element instanceof PaletteToolbar && "standardGroup".equals(((PaletteToolbar) element).getId())) {//$NON-NLS-1$ + visible = false; + } + return visible; + } + }); + availableToolsViewer.addFilter(new DrawerFilter()); + + // add drag support + addAvailableToolsDragSupport(); + + // init availableTools combo on the first element + profileCombo.deselectAll(); + profileCombo.select(profileCombo.getItems().length - 1); // select the last one (UML) + } + + + + /** + * Creates a toolbar item which can be checked. + * + * @param toolbar + * the parent toolbar + * @param shownElementsIcon + * path for shown elements icon + * @param listener + * listener for button action + * @param tooltip + * tooltip text for the toolbar item + */ + protected ToolItem createCheckToolBarItem(final ToolBar toolbar, final String shownElementsIcon, final String tooltip, final Listener listener) { + ToolItem item = new ToolItem(toolbar, SWT.CHECK | SWT.BORDER); + item.setImage(Activator.getDefault().getImage(shownElementsIcon)); + item.setToolTipText(tooltip); + item.addListener(SWT.Selection, listener); + return item; + } + + /** + * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) + * + * @param parent + */ + @Override + public void createControl(final Composite parent) { + + // initialize dialog units + initializeDialogUnits(parent); + + // Create a new composite as there is the title bar seperator + // to deal with + Composite control = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(3, false); + control.setLayout(layout); + control.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + setControl(control); + + // create Available Tools Group + createAvailableToolsGroup(); + + // create add/remove buttons + createAddRemoveButtons(); + + // Create palette preview + createPalettePreviewGroup(); + + // Create properties view + createPropertiesGroup(); + + // add listeners inter-groups + ISelectionChangedListener listener = createToolsViewerSelectionChangeListener(); + availableToolsViewer.addSelectionChangedListener(listener); + paletteTreeViewer.addSelectionChangedListener(listener); + + // end of the control creation + Dialog.applyDialogFont(control); + + // Show description on opening + setErrorMessage(null); + setMessage(null); + setPageComplete(validatePage()); + } + + /** + * Creates the listener for the new drawer tool item + * + * @return the listener created + */ + protected Listener createNewDrawerListener() { + return new Listener() { + + /** + * {@inheritDoc} + */ + @Override + public void handleEvent(final Event event) { + + EObject palette = editingDomain.getResourceSet().getResources().get(0).getContents().get(0); + if (palette instanceof PaletteConfiguration) { + // Create a void drawer + DrawerConfiguration drawer = PaletteconfigurationFactory.eINSTANCE.createDrawerConfiguration(); + // Set label + drawer.setLabel(DRAWER_LABEL); + // Set the drawer on the palette configuration + EList<DrawerConfiguration> drawerConfigurations = ((PaletteConfiguration) palette).getDrawerConfigurations(); + // Create add command + Command addCommand = new AddCommand(editingDomain, drawerConfigurations, drawer); + // Execute add command + execute(addCommand); + paletteTreeViewer.refresh(); + } + } + }; + } + + /** + * Creates the listener for the new separator tool item + * + * @return the listener created + */ + protected Listener createNewSeparatorListener() { + return new Listener() { + + /** + * {@inheritDoc} + */ + @Override + public void handleEvent(final Event event) { + // retrieve selected element + Object object = ((IStructuredSelection) paletteTreeViewer.getSelection()).getFirstElement(); + // Create a separator + SeparatorConfiguration separator = PaletteconfigurationFactory.eINSTANCE.createSeparatorConfiguration(); + // Set label & Id + separator.setLabel(SEPARATOR_LABEL); + separator.setId(CreatePaletteItemUtil.generateID(SEPARATOR_LABEL)); + Command addCommand = null; + if (object instanceof DrawerConfiguration) { + // Add separator at the end of drawer own configuration + addCommand = new AddCommand(editingDomain, ((DrawerConfiguration) object).getOwnedConfigurations(), separator); + } else if (object instanceof ChildConfiguration) { + // retrieve parent + EList<ChildConfiguration> ownedConfigurations = ((DrawerConfiguration) ((ChildConfiguration) object).eContainer()).getOwnedConfigurations(); + int index = ownedConfigurations.indexOf(object); + // adds the separator + addCommand = new AddCommand(editingDomain, ownedConfigurations, separator, index); + } + // Execute add command + execute(addCommand); + + paletteTreeViewer.expandToLevel(object, 1); + paletteTreeViewer.refresh(); + } + }; + } + + /** + * Creates the listener for the new stack tool item + * + * @return the listener created + */ + protected Listener createNewStackListener() { + return new Listener() { + + /** + * {@inheritDoc} + */ + @Override + public void handleEvent(final Event event) { + // retrieve selected element + Object object = ((IStructuredSelection) paletteTreeViewer.getSelection()).getFirstElement(); + // Create a separator + StackConfiguration stack = PaletteconfigurationFactory.eINSTANCE.createStackConfiguration(); + // Set label & Id + stack.setLabel(STACK_LABEL); + stack.setId(CreatePaletteItemUtil.generateID(STACK_LABEL)); + Command addCommand = null; + if (object instanceof DrawerConfiguration) { + // Add separator at the end of drawer own configuration + addCommand = new AddCommand(editingDomain, ((DrawerConfiguration) object).getOwnedConfigurations(), stack); + } else if (object instanceof ChildConfiguration) { + // retrieve parent + EList<ChildConfiguration> ownedConfigurations = ((DrawerConfiguration) ((ChildConfiguration) object).eContainer()).getOwnedConfigurations(); + int index = ownedConfigurations.indexOf(object); + // adds the stack + addCommand = new AddCommand(editingDomain, ownedConfigurations, stack, index); + } + execute(addCommand); + + paletteTreeViewer.expandToLevel(object, 1); + paletteTreeViewer.refresh(); + } + + }; + } + + /** + * Execute command in the command stack. + */ + protected void execute(final Command command) { + if (null != command && command.canExecute()) { + editingDomain.getCommandStack().execute(command); + } + } + + /** + * Creates the listener for the new tool item + * + * @return the listener created + */ + protected Listener createNewToolListener() { + return new Listener() { + + /** + * {@inheritDoc} + */ + @Override + public void handleEvent(Event event) { + // retrieve selected element + Object object = ((IStructuredSelection) paletteTreeViewer.getSelection()).getFirstElement(); + // Create a separator + ToolConfiguration tool = PaletteconfigurationFactory.eINSTANCE.createToolConfiguration(); + // Set label & Id + tool.setLabel(NEW_TOOL_LABEL); + Command addCommand = null; + if (object instanceof DrawerConfiguration || object instanceof StackConfiguration) { + // Add separator at the end of drawer own configuration + if (object instanceof DrawerConfiguration) { + addCommand = new AddCommand(editingDomain, ((DrawerConfiguration) object).getOwnedConfigurations(), tool); + } else if (object instanceof StackConfiguration) { + addCommand = new AddCommand(editingDomain, ((StackConfiguration) object).getOwnedConfigurations(), tool); + } + } else if (object instanceof ChildConfiguration) { + // retrieve parent + EObject eContainer = ((EObject) object).eContainer(); + // add as sibling of the object + if (eContainer instanceof DrawerConfiguration) { + EList<ChildConfiguration> ownedConfigurations = ((DrawerConfiguration) eContainer).getOwnedConfigurations(); + int index = ownedConfigurations.indexOf(object); + addCommand = new AddCommand(editingDomain, ownedConfigurations, tool, index); + } else if (eContainer instanceof StackConfiguration) { + EList<LeafConfiguration> ownedConfigurations = ((StackConfiguration) eContainer).getOwnedConfigurations(); + int index = ownedConfigurations.indexOf(object); + addCommand = new AddCommand(editingDomain, ownedConfigurations, tool, index); + } + } + execute(addCommand); + paletteTreeViewer.expandToLevel(object, 1); + paletteTreeViewer.refresh(); + } + }; + } + + /** + * creates the palette preview group + */ + protected void createPalettePreviewGroup() { + Composite parent = (Composite) getControl(); + Composite paletteComposite = new Composite(parent, SWT.NONE); + + GridLayout layout = new GridLayout(2, true); + layout.marginHeight = 0; + layout.marginWidth = 0; + paletteComposite.setLayout(layout); + GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); + paletteComposite.setLayoutData(data); + + Label label = new Label(paletteComposite, SWT.NONE); + label.setText(Messages.Local_Palette_Palette_Preview); + data = new GridData(SWT.LEFT, SWT.CENTER, true, false); + label.setLayoutData(data); + + toolbar = new ToolBar(paletteComposite, SWT.HORIZONTAL); + data = new GridData(SWT.RIGHT, SWT.FILL, false, false); + toolbar.setLayoutData(data); + populatePalettePreviewToolBar(toolbar); + + Tree tree = new Tree(paletteComposite, SWT.SINGLE | SWT.BORDER); + data = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1); + data.widthHint = 350; + // Make the tree this tall even when there is nothing in it. This will keep the + // dialog from shrinking to an unusually small size. + data.heightHint = 200; + tree.setLayoutData(data); + + paletteTreeViewer = new TreeViewer(tree); + + paletteTreeViewer.setContentProvider(new AdapterFactoryContentProvider(editingDomain.getAdapterFactory())); + paletteTreeViewer.setLabelProvider(new AdapterFactoryLabelProvider(editingDomain.getAdapterFactory())); + paletteTreeViewer.setInput(editingDomain.getResourceSet()); + + paletteTreeViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); + + new AdapterFactoryTreeEditor(paletteTreeViewer.getTree(), editingDomain.getAdapterFactory()); + + paletteTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { + + @Override + public void selectionChanged(SelectionChangedEvent event) { + handlePalettePreviewSelectionChanged(event); + } + }); + + // Refresh button + handlePalettePreviewSelectionChanged(null); + addPalettePreviewDropSupport(); + addPalettePreviewDragSupport(); + } + + /** + * Creates the profile combo + * + * @param availableToolsComposite + * the available tools composite + * @return the created combo + */ + protected Combo createProfileCombo(final Composite availableToolsComposite) { + // retrieve top package, to know which profiles are available + // creates the combo + profileCombo = new Combo(availableToolsComposite, SWT.BORDER | SWT.READ_ONLY); + GridData data = new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1); + profileCombo.setLayoutData(data); + + // retrieve all applied profiles + List<Profile> profiles = getAllAppliedProfiles(); + + int profileNumber = profiles.size(); + for (int i = 0; i < profileNumber; i++) { + String name; + if (profiles.get(i).eIsProxy()) { + name = NLS.bind("<unresolved: {0}>", URI.decode(EcoreUtil.getURI(profiles.get(i)).lastSegment())); //$NON-NLS-1$ + } else { + name = profiles.get(i).getName(); + if (name == null) { + name = NLS.bind("<unnamed: {0}>", URI.decode(EcoreUtil.getURI(profiles.get(i)).lastSegment())); //$NON-NLS-1$ + } + } + profileComboList.add(i, name); + } + profileComboList.add(UML_TOOLS_LABEL); + profileCombo.setItems(profileComboList.toArray(new String[] {})); + + // add selection listener for the combo. selects the "UML tools" item + ProfileComboSelectionListener listener = new ProfileComboSelectionListener(); + profileCombo.addSelectionListener(listener); + profileCombo.addModifyListener(listener); + + return profileCombo; + } + + /** + * create the properties group + */ + protected void createPropertiesGroup() { + Composite parent = (Composite) getControl(); + + Label entryInformationLabel = new Label(parent, SWT.NONE); + entryInformationLabel.setText(Messages.Local_Palette_Entry_Information); + { + GridData data = new GridData(SWT.FILL, SWT.FILL, true, false); + data.horizontalSpan = 3; + entryInformationLabel.setLayoutData(data); + } + + propertiesComposite = new Composite(parent, SWT.NONE); + FillLayout layout = new FillLayout(); + layout.marginHeight = 0; + layout.marginWidth = 0; + propertiesComposite.setLayout(layout); + { + GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); + data.horizontalSpan = 3; + data.heightHint = 340; + propertiesComposite.setLayoutData(data); + } + + } + + /** + * Creates the add button listener. + */ + protected MouseListener createRemoveButtonListener() { + return new MouseAdapter() { + + /** + * {@inheritDoc} + */ + @Override + public void mouseUp(final MouseEvent e) { + deleteSelectedConfiguration(); + } + }; + } + + /** + * Creates the listener for the remove item(s) button. + * + * @return the listener for the remove button + */ + protected Listener createRemoveElementListener() { + return new Listener() { + + /** + * {@inheritDoc} + */ + @Override + public void handleEvent(final Event event) { + deleteSelectedConfiguration(); + } + + }; + } + + /** + * Delete the selection configuration in the paletteTreeViewer. + */ + protected void deleteSelectedConfiguration() { + IStructuredSelection selection = (IStructuredSelection) paletteTreeViewer.getSelection(); + if (null != selection && 1 <= selection.size()) { + Iterator<?> it = selection.iterator(); + while (it.hasNext()) { + Object object = it.next(); + if (object instanceof Configuration) { + Command deleteCommand = new AbstractCommand() { + + @Override + public void redo() { + execute(); + } + + @Override + public void execute() { + EcoreUtil.delete((EObject) object); + } + + @Override + public boolean prepare() { + return true; + } + }; + deleteCommand.canExecute(); + editingDomain.getCommandStack().execute(deleteCommand); + } + } + paletteTreeViewer.refresh(); + // remove the properties view + if (null != displayEngine) { + displayEngine.removeSection(propertiesComposite); + } + } + } + + /** + * creates the tool item for drawers visibility listener + * + * @return the listener for the tool button + */ + protected Listener createShowDrawerListener() { + return new Listener() { + + /** + * {@inheritDoc} + */ + @Override + public void handleEvent(final Event event) { + if (event.widget instanceof ToolItem) { + ToolItem item = ((ToolItem) event.widget); + if (item.getSelection()) { + // elements should be hidden + availableToolsViewer.addFilter(drawerFilter); + item.setSelection(true); + } else { + availableToolsViewer.removeFilter(drawerFilter); + item.setSelection(false); + } + } + } + }; + } + + /** + * creates the tool item for tools visibility listener + * + * @return the listener for the tool button + */ + protected Listener createsShowToolListener() { + return new Listener() { + + /** + * {@inheritDoc} + */ + @Override + public void handleEvent(final Event event) { + if (event.widget instanceof ToolItem) { + ToolItem item = ((ToolItem) event.widget); + if (item.getSelection()) { + // elements should be hidden + availableToolsViewer.addFilter(toolFilter); + item.setSelection(true); + } else { + availableToolsViewer.removeFilter(toolFilter); + item.setSelection(false); + } + } + } + }; + } + + /** + * Creates the listener for the available tools content provider + * + * @return the listener created + */ + protected Listener createSwitchToolsContentProviderListener() { + return new Listener() { + + /** + * {@inheritDoc} + */ + @Override + public void handleEvent(final Event event) { + if (event.widget instanceof ToolItem) { + ToolItem item = ((ToolItem) event.widget); + // retrieve current profile selected in the combo profile + int index = profileCombo.getSelectionIndex(); + Collection<PaletteEntry> standardEntries = getAllVisibleStandardEntries(); + Profile profile = getAllAppliedProfiles().get(index); + + if (item.getSelection()) { + availableToolsViewer.setContentProvider(new ProfileToolsStereotypeMetaclassTreeContentProvider(profile, standardEntries)); + item.setSelection(true); + } else { + + availableToolsViewer.setContentProvider(new ProfileToolsMetaclassStereotypeTreeContentProvider(profile, standardEntries)); + item.setSelection(false); + } + + // generate tools for given profile + availableToolsViewer.setInput(profile); + } + } + }; + } + + /** + * Creates a toolbar item. + * + * @param toolbar + * the parent toolbar + * @param itemIcon + * path for icon + * @param tooltip + * tooltip text for the toolbar item + * @param listener + * listener for tool bar item + */ + protected void createToolBarItem(final ToolBar toolbar, final String itemIcon, final String tooltip, final Listener listener, final ToolBarItemValidator validator) { + ToolItem item = new ToolItem(toolbar, SWT.BORDER); + item.setImage(Activator.getDefault().getImage(org.eclipse.papyrus.infra.gmfdiag.common.Activator.ID, itemIcon)); + item.setToolTipText(tooltip); + item.addListener(SWT.Selection, listener); + item.setData(VALIDATOR, validator); + } + + /** + * selection listener for the tools viewer , to update the state of the add button + * + * @return the new created selection listener + */ + protected ISelectionChangedListener createToolsViewerSelectionChangeListener() { + return new ISelectionChangedListener() { + + /** + * Returns true if the source can be added to the target + * + * @param source + * the source object + * @param target + * the target object + * @return <code>true</code> if the source can be added to the target + */ + protected boolean isAddValidTarget(final Object source, final Object target) { + boolean isAddValidTarget = false; + if (source instanceof PaletteEntry) { + // case1: source is a drawer. + // it can only be added to the root element (no selection) + // case2: source is a palette tool + // it can't be added to the root element + // it can only be added to a container element (drawer or stack) + + if (source instanceof PaletteDrawer) { + isAddValidTarget = null == target; + } else if (source instanceof ToolEntry) { + isAddValidTarget = target instanceof DrawerConfiguration || target instanceof StackConfiguration; + } + } + return isAddValidTarget; + } + + /** + * Returns true if the source can be added to the target + * + * @param source + * the source object + * @return <code>true</code> if the source can be removed (not null and instanceof + * PaletteEntryProxy) + */ + protected boolean isRemoveValidSource(final Object source) { + return source instanceof Configuration; + } + + /** + * {@inheritDoc} + */ + @Override + public void selectionChanged(final SelectionChangedEvent event) { + // get source and target selection + // check source entry can be added to target entry + Object source = ((IStructuredSelection) availableToolsViewer.getSelection()).getFirstElement(); + Object target = ((IStructuredSelection) paletteTreeViewer.getSelection()).getFirstElement(); + + // manage add button + if (isAddValidTarget(source, target)) { + addButton.setEnabled(true); + } else { + addButton.setEnabled(false); + } + + // manage remove button + if (isRemoveValidSource(target)) { + removeButton.setEnabled(true); + } else { + removeButton.setEnabled(false); + } + + } + }; + + } + + /** + * @see org.eclipse.jface.dialogs.DialogPage#dispose() + * + */ + @Override + public void dispose() { + // dispose engine + if (null != displayEngine) { + displayEngine.dispose(); + } + // dispose adapter + paletteConfigurationModel.eAdapters().remove(adapter); + super.dispose(); + } + + /** + * returns the list of applied profile for the nearest package of the top element + * + * @return the list of applied profile for the nearest package of the top element or an empty + * list + */ + protected List<Profile> getAllAppliedProfiles() { + Package topPackage = null; + if (editorPart instanceof DiagramEditorWithFlyOutPalette) { + EObject element = ((DiagramEditorWithFlyOutPalette) editorPart).getDiagram().getElement(); + if (element instanceof org.eclipse.uml2.uml.Element) { + topPackage = ((org.eclipse.uml2.uml.Element) element).getNearestPackage(); + } + } + return null != topPackage ? topPackage.getAllAppliedProfiles() : Collections.emptyList(); + } + + /** + * Returns the list of all visible palette entries + * + * @return the list of all visible palette entries + */ + protected Collection<PaletteEntry> getAllVisibleStandardEntries() { + HashSet<PaletteEntry> result = new HashSet<PaletteEntry>(); + for (PaletteEntry entry : PaletteUtil.getAvailableEntriesSet(editorPart, priority).values()) { + // the entry is not just a defineOnly entry but a visible one + if (getRootParent(entry) != null) { + result.add(entry); + } + } + return result; + } + + /** + * Returns the Root element for the palette entry. It searches recursively from parent to parent, until it find the root element + * + * @param entry + * the palette entry for which root element is searched + * @return the root element or <code>null</code> if none was found + */ + protected PaletteRoot getRootParent(final PaletteEntry entry) { + PaletteRoot paletteRoot = null; + + PaletteContainer parent = entry.getParent(); + if (parent instanceof PaletteRoot) { + paletteRoot = (PaletteRoot) parent; + } else if (null != parent) { + paletteRoot = getRootParent(parent); + } + return paletteRoot; + } + + /** + * handle the selection change event for the palette preview + * + * @param event + * the event that is thrown by the palette viewer + */ + protected void handlePalettePreviewSelectionChanged(final SelectionChangedEvent event) { + // Properties view + if (null != event) { + // retrieve current selection + ITreeSelection selection = (TreeSelection) event.getSelection(); + Object firstSelected = selection.getFirstElement(); + + if (firstSelected instanceof Configuration) { + if (null != displayEngine) { + displayEngine.removeSection(propertiesComposite); + } + displayEngine = PropertiesDisplayHelper.display(firstSelected, propertiesComposite); + propertiesComposite.layout(); + } + } + // update toolbar + if (null != toolbar && !toolbar.isDisposed()) { + for (int i = 0; i < toolbar.getItemCount(); i++) { + ToolItem item = toolbar.getItem(i); + Object validator = item.getData(VALIDATOR); + if (validator instanceof ToolBarItemValidator) { + item.setEnabled(((ToolBarItemValidator) validator).isEnable()); + } + } + } + } + + /** + * Adds elements to the tool bar for available tools viewer + * + * @param toolbar + * the toolbar to populate + */ + protected void populateAvailableToolsToolBar(final ToolBar toolbar) { + toggleContentProvider = createCheckToolBarItem(toolbar, SWITCH_CONTENT_PROVIDER_ICON, Messages.Local_Palette_SwitchToolsContentProvider_Tooltip, createSwitchToolsContentProviderListener()); + toggleContentProvider.setSelection(true); + toggleContentProvider.setEnabled(false); + createCheckToolBarItem(toolbar, SHOWN_TOOLS_ICON, Messages.Local_Palette_ShowTools_Tooltip, createsShowToolListener()); + } + + /** + * populates the preview palette toolbar + * + * @param toolbar + * the toolbar to populate + */ + protected void populatePalettePreviewToolBar(final ToolBar toolbar) { + // create validator + PaletteConfigurationEntrySelectedValidator validator = new PaletteConfigurationEntrySelectedValidator(); + PaletteConfigurationStackLeafSelectedValidator validatorForNotStackChild = new PaletteConfigurationStackLeafSelectedValidator(); + + createToolBarItem(toolbar, DELETE_ICON, Messages.PapyrusPaletteCustomizerDialog_RemoveButtonTooltip, createRemoveElementListener(), validator); + createToolBarItem(toolbar, CREATE_DRAWERS_ICON, Messages.Local_Palette_Create_Drawer_Tooltip, createNewDrawerListener(), null); + createToolBarItem(toolbar, CREATE_SEPARATOR_ICON, Messages.Local_Palette_Create_Separator_Tooltip, createNewSeparatorListener(), validatorForNotStackChild); + createToolBarItem(toolbar, CREATE_TOOL_ICON, Messages.Local_Palette_Create_Tool_Tooltip, createNewToolListener(), validator); + createToolBarItem(toolbar, CREATE_STACK_ICON, Messages.Local_Palette_Create_Stack_Tooltip, createNewStackListener(), validatorForNotStackChild); + } + + /** + * Sets the priority of the current edited palette + * + * @param priority + * the priority of the current edited palette + */ + public void setPriority(final ProviderPriority priority) { + this.priority = priority; + } + + /** + * @return the priority + */ + public ProviderPriority getPriority() { + return priority; + } + + /** The model diagnostician. */ + Diagnostician diagnostician = new Diagnostician() { + + @Override + public String getObjectLabel(final EObject eObject) { + String label = null; + if (eObject instanceof Configuration) { + label = ((Configuration) eObject).getLabel(); + } + if (null == label || label.isEmpty()) { + label = EcoreUtil.getIdentification(eObject); + } + return label; + } + }; + + /** + * Validates the content of the fields in this page. + */ + protected boolean validatePage() { + // TODO Adds OCL validation to Configuration to have error if Id is empty. + Diagnostic validate = diagnostician.validate(paletteConfigurationModel); + boolean valid = Diagnostic.OK == validate.getSeverity(); + + if (!valid) { + setErrorMessage(validate.getChildren().get(0).getMessage()); + } else { + setErrorMessage(null); + } + return valid; + } + + /** + * @return The {@link PaletteConfiguration} model from resource set. + */ + protected PaletteConfiguration getPaletteConfigurationModel() { + PaletteConfiguration paletteModel = null; + EList<Resource> resources = editingDomain.getResourceSet().getResources(); + if (!resources.isEmpty()) { + EList<EObject> contents = resources.get(0).getContents(); + if (!contents.isEmpty()) { + EObject eObject = (EObject) contents.get(0); + if (eObject instanceof PaletteConfiguration) { + paletteModel = (PaletteConfiguration) eObject; + } + } + } + Assert.isNotNull(paletteModel); + return paletteModel; + } + +} diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/dialog/PaletteConfigurationInformationPage.java b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/dialog/PaletteConfigurationInformationPage.java new file mode 100644 index 00000000000..eaab30787ae --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/dialog/PaletteConfigurationInformationPage.java @@ -0,0 +1,108 @@ +/***************************************************************************** + * 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: + * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation + *****************************************************************************/ + +package org.eclipse.papyrus.toolsmiths.palette.dialog; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.impl.AdapterImpl; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.PaletteConfiguration; +import org.eclipse.papyrus.infra.properties.ui.runtime.DisplayEngine; +import org.eclipse.papyrus.infra.properties.ui.runtime.PropertiesRuntime; +import org.eclipse.papyrus.infra.properties.ui.util.PropertiesDisplayHelper; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Layout; + +/** + * {@link WizardPage} for informations of a {@link PaletteConfiguration} Model. + * + */ +public class PaletteConfigurationInformationPage extends WizardPage { + + /** The {@link PaletteConfiguration} model */ + private PaletteConfiguration paletteConfiguration; + + /** The display engine */ + private DisplayEngine displayEngine; + + /** + * Constructor. + */ + protected PaletteConfigurationInformationPage(final String pageName, final PaletteConfiguration paletteConfiguration) { + super(pageName); + this.paletteConfiguration = paletteConfiguration; + + // install adapter + AdapterImpl adapter = new AdapterImpl() { + + /** + * @see org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification) + */ + @Override + public void notifyChanged(final Notification msg) { + setPageComplete(validatePage()); + } + }; + paletteConfiguration.eAdapters().add(adapter); + adapter.setTarget(paletteConfiguration); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) + */ + @Override + public void createControl(final Composite parent) { + // initialize dialog units + initializeDialogUnits(parent); + + Composite control = new Composite(parent, SWT.NONE); + Layout layout = new FillLayout(); + control.setLayout(layout); + setControl(control); + + // Create the composite + if (!PropertiesRuntime.getConstraintEngine().getDisplayUnits(paletteConfiguration).isEmpty()) { + displayEngine = PropertiesDisplayHelper.display(paletteConfiguration, control); + } + setPageComplete(validatePage()); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.jface.dialogs.DialogPage#dispose() + */ + @Override + public void dispose() { + if (null != displayEngine) { + displayEngine.dispose(); + } + super.dispose(); + } + + + /** + * Validate the paletteConfiguration properties. paletteConfiguration must at leazst have a name and an id. + */ + protected boolean validatePage() { + return null != paletteConfiguration + && null != paletteConfiguration.getLabel() + && null != paletteConfiguration.getId() + && !paletteConfiguration.getLabel().isEmpty() + && !paletteConfiguration.getId().isEmpty(); + } + +} diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/dialog/PaletteConfigurationWizard.java b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/dialog/PaletteConfigurationWizard.java new file mode 100644 index 00000000000..91457e62082 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/dialog/PaletteConfigurationWizard.java @@ -0,0 +1,279 @@ +/***************************************************************************** + * Copyright (c) 2016 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: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - new implementation for palette configuration model case + * + *****************************************************************************/ + +package org.eclipse.papyrus.toolsmiths.palette.dialog; + +import java.io.IOException; +import java.util.Collections; +import java.util.HashSet; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFlyOutPalette; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.papyrus.infra.gmfdiag.common.Activator; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PaletteUtil; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPalettePreferences; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteService.ProviderDescriptor; +import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.PaletteConfiguration; +import org.eclipse.papyrus.infra.types.ElementTypeSetConfiguration; +import org.eclipse.papyrus.infra.types.core.registries.ElementTypeSetConfigurationRegistry; +import org.eclipse.papyrus.toolsmiths.palette.Messages; +import org.eclipse.papyrus.toolsmiths.palette.PaletteConstants; +import org.eclipse.papyrus.toolsmiths.palette.PaletteConstants.PaletteModelContextEnum; +import org.eclipse.papyrus.toolsmiths.palette.utils.PaletteUtils; +import org.eclipse.ui.IEditorPart; + +/** + * Wizard to update or create an Palette configuration + */ +public class PaletteConfigurationWizard extends AbstractPaletteConfigurationWizard { + + /** content page */ + protected WizardPage contentPage; + + /** info page */ + protected WizardPage infoPage; + + /** + * Creates a NewLocalPaletteWizard. + * + * @param part + * the editor part where the palette is available + * @param descriptor + * the descriptor to edit + */ + public PaletteConfigurationWizard(final IEditorPart part, final ProviderDescriptor descriptor) { + super(part, descriptor); + } + + /** constructor in case of new palette configuration model */ + public PaletteConfigurationWizard(final IEditorPart part) { + this(part, null); + } + + /** + * {@inheritDoc} + */ + @Override + public void addPages() { + super.addPages(); + + // create pages + infoPage = createPaletteInformationPage(); + contentPage = createPaletteContentPage(); + + // Add pages + addPage(infoPage); + addPage(contentPage); + } + + /** + * Create the content page. + */ + protected WizardPage createPaletteContentPage() { + // second page: describe the paletteContent + WizardPage page = new PaletteConfigurationContentPage(editorPart, editingDomain); + page.setTitle(Messages.PaletteConfigurationWizard_NewPaletteContentPageWizard_Title); + page.setDescription(Messages.PaletteConfigurationWizard_NewPaletteContentPageWizard_Description); + + // init content page + ((PaletteConfigurationContentPage) page).setPriority(priority); + return page; + } + + /** + * Create the information page. + */ + protected WizardPage createPaletteInformationPage() { + WizardPage page = new PaletteConfigurationInformationPage("", (PaletteConfiguration) paletteResource.getContents().get(0));//$NON-NLS-1$ + if (PaletteModelContextEnum.New.equals(paletteContext)) { + page.setTitle(Messages.PaletteConfigurationWizard_NewPaletteInfoPageWizard_Title); + } else { + page.setTitle(Messages.PaletteConfigurationWizard_EditionPaletteInfoPageWizard_Tilte); + } + page.setDescription(Messages.PaletteConfigurationWizard_PaletteInfoPageWizard_Description); + return page; + } + + /** + * {@inheritDoc} + */ + @Override + protected void deployModels() { + + // Loads element types models. + deployElementTypesModels(); + + // loads modified palette model + deployPaletteModel(); + + // Force the update + PaletteUtil.getAvailableEntriesSet(editorPart, priority); + } + + /** + * load palette models on Papyrus preferences. + */ + protected void deployPaletteModel() { + // Get the palette model + PaletteConfiguration paletteModel = (PaletteConfiguration) paletteResource.getContents().get(0); + + // The palette id + String paletteId = paletteModel.getId(); + + // Update palette preferences + switch (paletteContext) { + + case New: + // New model + PapyrusPalettePreferences.addLocalExtendedPalette(paletteId, paletteId, priority, PaletteUtils.getEditorIdValue(editorPart), new HashSet(paletteModel.getRequiredProfiles())); + break; + + case Local: + // Edition of a local extended palette + // Refresh by deletion and re add it. + PapyrusPalettePreferences.deleteLocalExtendedPalette(descriptor.getContributionID()); + PapyrusPalettePreferences.addLocalExtendedPalette(paletteId, paletteId, priority, PaletteUtils.getEditorIdValue(editorPart), new HashSet(paletteModel.getRequiredProfiles())); + break; + + case Plugin: + // Edition of palette redefinition from plugin + // Case of redefinition of read-only palette configuration model + String path = PapyrusPalettePreferences.getPaletteRedefinition(descriptor.getContributionID()); + if (null != path) { + // Register the redefinition + PapyrusPalettePreferences.registerLocalRedefinition(descriptor.getContributionID(), path); // if already exists: removes, then add + } + break; + + case Workspace: + // Workspace palette case + String pathWS = paletteResource.getURI().toPlatformString(false); + // If identifier is changed: need to delete palette + if (null != descriptor && !paletteId.equals(descriptor.getContributionID())) { + PapyrusPalettePreferences.deleteWorkspaceExtendedPalette(descriptor.getContributionID());// Delete it in case of id change + } + PapyrusPalettePreferences.addWorkspaceExtendedPalette(paletteId, paletteId, pathWS, priority, PaletteUtils.getEditorIdValue(editorPart), new HashSet(paletteModel.getRequiredProfiles())); + + break; + + default: + break; + } + + + // toggle visibility to refresh the content + if (editorPart instanceof DiagramEditorWithFlyOutPalette) { + PapyrusPalettePreferences.changePaletteVisibility(paletteId, editorPart, false); + PapyrusPalettePreferences.changePaletteVisibility(paletteId, editorPart, true); + } + + } + + /** + * deploy element types models. + */ + protected void deployElementTypesModels() { + // deploy element types configuration files + if (!elementTypeSemResource.getContents().isEmpty() && !elementTypeUIResource.getContents().isEmpty()) { + ElementTypeSetConfigurationRegistry.getInstance().unload(getClientContext(), ((ElementTypeSetConfiguration) elementTypeSemResource.getContents().get(0)).getIdentifier()); + ElementTypeSetConfigurationRegistry.getInstance().unload(getClientContext(), ((ElementTypeSetConfiguration) elementTypeUIResource.getContents().get(0)).getIdentifier()); + + ElementTypeSetConfigurationRegistry.getInstance().loadElementTypeSetConfiguration(getClientContext(), ((ElementTypeSetConfiguration) elementTypeSemResource.getContents().get(0))); + ElementTypeSetConfigurationRegistry.getInstance().loadElementTypeSetConfiguration(getClientContext(), ((ElementTypeSetConfiguration) elementTypeUIResource.getContents().get(0))); + } + } + + + /** + * {@inheritDoc} + */ + @Override + protected void saveResources() { + // Get the palette model + PaletteConfiguration paletteModel = (PaletteConfiguration) paletteResource.getContents().get(0); + + // The palette id + String paletteId = paletteModel.getId(); + + // Save resources + + // Id is changed => needs to rename files + if (PaletteModelContextEnum.Local.equals(paletteContext) && !paletteId.equals(descriptor.getContributionID())) { + + // needs to change the file name for local extended palette model + String newPalettePath = paletteResource.getURI().toFileString().replace(descriptor.getContributionID(), paletteId); + paletteResource.setURI(URI.createFileURI(newPalettePath)); + + String newElementTypeUIResourcePath = elementTypeUIResource.getURI().toFileString().replace(descriptor.getContributionID(), paletteId); + elementTypeUIResource.setURI(URI.createFileURI(newElementTypeUIResourcePath)); + + String newElementTypeSemResourcePath = elementTypeSemResource.getURI().toFileString().replace(descriptor.getContributionID(), paletteId); + elementTypeSemResource.setURI(URI.createFileURI(newElementTypeSemResourcePath)); + + } else if (PaletteModelContextEnum.New.equals(paletteContext)) { + // set file names for new palette and element type + clearStringBuilder(); + stringBuilder.append(paletteId); + stringBuilder.append(STR_DOT); + stringBuilder.append(PaletteConstants.PALETTECONFIGURATION_EXTENSION); + String newPalettePath = paletteResource.getURI().toFileString().replace(paletteResource.getURI().lastSegment().replace("%20", " "), stringBuilder.toString());//$NON-NLS-1$ //$NON-NLS-2$ + paletteResource.setURI(URI.createFileURI(newPalettePath)); + + clearStringBuilder(); + stringBuilder.append(paletteId); + stringBuilder.append(PaletteConstants.ELEMENTTYPE_UI_IDENTIFIER_POSTFIX); + stringBuilder.append(STR_DOT); + stringBuilder.append(PaletteConstants.ELEMENTTYPE_EXTENSION); + String newElementTypeUIResourcePath = elementTypeUIResource.getURI().toFileString().replace(elementTypeUIResource.getURI().lastSegment().replace("%20", " "), stringBuilder.toString());//$NON-NLS-1$ //$NON-NLS-2$ + elementTypeUIResource.setURI(URI.createFileURI(newElementTypeUIResourcePath)); + + clearStringBuilder(); + stringBuilder.append(paletteId); + stringBuilder.append(PaletteConstants.ELEMENTTYPE_SEMENTIC_IDENTIFIER_POSTFIX); + stringBuilder.append(STR_DOT); + stringBuilder.append(PaletteConstants.ELEMENTTYPE_EXTENSION); + String newElementTypeSemResourcePath = elementTypeSemResource.getURI().toFileString().replace(elementTypeSemResource.getURI().lastSegment().replace("%20", " "), stringBuilder.toString());//$NON-NLS-1$ //$NON-NLS-2$ + elementTypeSemResource.setURI(URI.createFileURI(newElementTypeSemResourcePath)); + } + + // Save if necessary + try { + paletteResource.save(PaletteUtils.saveOptions); + // Checks if model are not void and are useful + if (!((ElementTypeSetConfiguration) elementTypeUIResource.getContents().get(0)).getElementTypeConfigurations().isEmpty()) { + elementTypeUIResource.save(PaletteUtils.saveOptions); + elementTypeSemResource.save(PaletteUtils.saveOptions); + } else { + ElementTypeSetConfigurationRegistry.getInstance().unload(getClientContext(), ((ElementTypeSetConfiguration) elementTypeSemResource.getContents().get(0)).getIdentifier()); + ElementTypeSetConfigurationRegistry.getInstance().unload(getClientContext(), ((ElementTypeSetConfiguration) elementTypeUIResource.getContents().get(0)).getIdentifier()); + elementTypeUIResource.delete(Collections.EMPTY_MAP); + elementTypeSemResource.delete(Collections.EMPTY_MAP); + } + } catch (IOException e) { + Activator.log.error(e); + } + } + + /** + * @return The client context of element types. + * + * TODO: switch it with point of you context if needed. + */ + protected String getClientContext() { + return "org.eclipse.papyrus.infra.services.edit.TypeContext";//$NON-NLS-1$ + } + + +} diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/dialog/PapyrusPaletteCustomizerDialog.java b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/dialog/PapyrusPaletteCustomizerDialog.java new file mode 100644 index 00000000000..dfbfd31bcdc --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/dialog/PapyrusPaletteCustomizerDialog.java @@ -0,0 +1,860 @@ +/***************************************************************************** + * Copyright (c) 2016 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: + * Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation + * Gabriel Pascual (ALL4TEC) gabriel.pascual@gmail.com - Bug 350134 + * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Bug 482669 + * + *****************************************************************************/ + +package org.eclipse.papyrus.toolsmiths.palette.dialog; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; +import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.eclipse.gef.palette.PaletteRoot; +import org.eclipse.gef.ui.palette.PaletteCustomizer; +import org.eclipse.gmf.runtime.common.core.service.IProvider; +import org.eclipse.gmf.runtime.gef.ui.palette.customize.PaletteCustomizerDialogEx; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.ICheckStateProvider; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.papyrus.infra.core.sasheditor.editor.ISashWindowsContainer; +import org.eclipse.papyrus.infra.gmfdiag.common.Activator; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.ExtendedPluginPaletteProvider; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.IPapyrusPaletteConstant; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPalettePreferences; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteService; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteService.ExtendedProviderDescriptor; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteService.ProviderDescriptor; +import org.eclipse.papyrus.toolsmiths.palette.Messages; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; +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.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableItem; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.views.properties.tabbed.ITabbedPropertyConstants; + +/** + * Specific dialog window for the customisation of the palette. + */ +public class PapyrusPaletteCustomizerDialog extends PaletteCustomizerDialogEx implements IPreferenceChangeListener { + + /** Id for restore button of extended customization palette. */ + private static final int RESTORE_DEFAULT_PALETTE_BUTTON_ID = 23; + + /** Id for restore button of extended customization palette. */ + private static final int EXPORT_DEFAULT_PALETTE_BUTTON_ID = 24; + + /** Id for delete button of local palette. */ + private static final int DELETE_PALETTE_BUTTON_ID = 22; + + /** Id for edit button of extended and local palette. */ + private static final int EDIT_PALETTE_BUTTON_ID = 21; + + /** Id for new button to create local extended palette. */ + private static final int NEW_EXTENDED_PALETTE_BUTTON_ID = 25; + + /** new local palette icon */ + private static final String NEW_LOCAL_DESC_IMAGE = "/icons/local_desc_new.gif"; //$NON-NLS-1$ + + /** delete palette icon */ + private static final String DELETE_LOCAL_DESC_IMAGE = "/icons/local_desc_destroy.gif"; //$NON-NLS-1$ + + /** edit palette icon */ + private static final String EDIT_LOCAL_DESC_IMAGE = "/icons/local_desc_edit.gif"; //$NON-NLS-1$ + + /** restore palette icon */ + private static final String RESTORE_DEFAULT_DESC_IMAGE = "/icons/eraser.gif"; //$NON-NLS-1$ + + /** restore palette icon */ + private static final String EXPORT_DEFAULT_DESC_IMAGE = "/icons/Export.gif"; //$NON-NLS-1$ + + /** path to the local descriptor icon */ + protected static final String LOCAL_DESCRIPTOR = "/icons/local_desc.gif"; //$NON-NLS-1$ + + /** path to the plugin descriptor icon */ + protected static final String PLUGIN_DESCRIPTOR = "/icons/plugin_desc.gif"; //$NON-NLS-1$ + + /** path to the plugin descriptor icon */ + protected static final String EXTENDED_PLUGIN_DESCRIPTOR = "/icons/extended_plugin_desc.gif"; //$NON-NLS-1$ + + public static final String DEFAULT_IMAGE = "icons/PapyrusLogo16x16.gif";//$NON-NLS-1$ + + /** table viewed by the availablePalettesTreeViewer */ + protected Table availablePalettesTable; + + /** viewer for the available palettes */ + protected CheckboxTableViewer availablePalettesTableViewer; + + /** label provider for palette provider */ + protected PaletteLabelProvider providersLabelProvider; + + private Map<Integer, Button> paletteButtonsMap = new HashMap<Integer, Button>(); + + /** + * Creates a new PapyrusPaletteCustomizerDialog + * + * @param shell + * the shell that hosts the dialog window + * @param customizer + * the customizer used to customize the palette + * @param root + * the root of the palette + */ + public PapyrusPaletteCustomizerDialog(Shell shell, PaletteCustomizer customizer, PaletteRoot root) { + super(shell, customizer, root); + } + + /** + * {@inheritDoc} + */ + @Override + public int open() { + IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(Activator.ID); + prefs.addPreferenceChangeListener(this); + return super.open(); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean close() { + IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(Activator.ID); + prefs.removePreferenceChangeListener(this); + return super.close(); + } + + /** + * {@inheritDoc} + */ + @Override + protected Control createDialogArea(final Composite parent) { + // RS: does not call super, as the composite should not be drawn like they are in parent + Composite mainComposite = createMainComposite(parent); + + final Control availableToolsComposite = createAvailablePalettesViewer(mainComposite); + FormData data = new FormData(); + data.left = new FormAttachment(0, 0); + data.top = new FormAttachment(0, 0); + data.bottom = new FormAttachment(100, 0); + // data.right = new FormAttachment(40, 0); + availableToolsComposite.setLayoutData(data); + + final Label nameLabel = new Label(mainComposite, SWT.NONE); + nameLabel.setText(Messages.Palette_Viewer); + data = new FormData(); + data.left = new FormAttachment(availableToolsComposite, ITabbedPropertyConstants.HSPACE); + data.top = new FormAttachment(0, 0); + nameLabel.setLayoutData(data); + + // Create the tree + Control outline = createOutline(mainComposite); + data = new FormData(); + data.left = new FormAttachment(availableToolsComposite, ITabbedPropertyConstants.HSPACE); + data.top = new FormAttachment(nameLabel, 0); + data.bottom = new FormAttachment(100, 0); + // data.right = new FormAttachment(90, 0); + outline.setLayoutData(data); + + // Create the panel where the properties of the selected palette entry will + // be shown + Control properties = createPropertiesPanel(mainComposite); + data = new FormData(); + data.left = new FormAttachment(outline, ITabbedPropertyConstants.HSPACE); + data.right = new FormAttachment(100, 0); + data.top = new FormAttachment(0, 0); + data.bottom = new FormAttachment(100, 0); + properties.setLayoutData(data); + + // add listeners + ISelectionChangedListener listener = createSelectionChangedListener(); + if (listener != null) { + availablePalettesTableViewer.addSelectionChangedListener(listener); + } + return mainComposite; + } + + /** + * the selection changed listener to available tools, which update buttons status + * + * @return the listener + */ + protected ISelectionChangedListener createSelectionChangedListener() { + return new ISelectionChangedListener() { + + /** + * {@inheritDoc} + */ + @Override + public void selectionChanged(final SelectionChangedEvent event) { + // retrieve element selected + Object selectedElement = ((IStructuredSelection) event.getSelection()).getFirstElement(); + + // Plug-in contribution palette + if (selectedElement instanceof PapyrusPaletteService.ExtendedProviderDescriptor) { + IProvider provider = ((PapyrusPaletteService.ExtendedProviderDescriptor) selectedElement).getProvider(); + + // Modelconfiguration model definition + if (provider instanceof ExtendedPluginPaletteProvider) { + paletteButtonsMap.get(DELETE_PALETTE_BUTTON_ID).setEnabled(false); + paletteButtonsMap.get(EDIT_PALETTE_BUTTON_ID).setEnabled(true); + paletteButtonsMap.get(RESTORE_DEFAULT_PALETTE_BUTTON_ID).setEnabled(isRedefined((ExtendedProviderDescriptor) selectedElement)); + paletteButtonsMap.get(EXPORT_DEFAULT_PALETTE_BUTTON_ID).setEnabled(true); + } + } else + // Local Palette configuration model + if (selectedElement instanceof PapyrusPaletteService.LocalExtendedProviderDescriptor) { + paletteButtonsMap.get(DELETE_PALETTE_BUTTON_ID).setEnabled(true); + paletteButtonsMap.get(EDIT_PALETTE_BUTTON_ID).setEnabled(true); + paletteButtonsMap.get(RESTORE_DEFAULT_PALETTE_BUTTON_ID).setEnabled(false); + paletteButtonsMap.get(EXPORT_DEFAULT_PALETTE_BUTTON_ID).setEnabled(true); + } else { + paletteButtonsMap.get(DELETE_PALETTE_BUTTON_ID).setEnabled(false); + paletteButtonsMap.get(EDIT_PALETTE_BUTTON_ID).setEnabled(false); + paletteButtonsMap.get(RESTORE_DEFAULT_PALETTE_BUTTON_ID).setEnabled(false); + paletteButtonsMap.get(EXPORT_DEFAULT_PALETTE_BUTTON_ID).setEnabled(false); + } + } + }; + } + + /** + * Creates the available palettes viewer part of the dialog. + * + * @param container + * The Composite within which the viewer has to be created + * @return The newly created Control that has the viewer + */ + protected Control createAvailablePalettesViewer(final Composite container) { + // Create the Composite that will contain the available tools + Composite composite = new Composite(container, SWT.NONE); + composite.setFont(container.getFont()); + GridLayout layout = new GridLayout(6, false); + layout.horizontalSpacing = 0; + layout.verticalSpacing = 0; + layout.marginHeight = 0; + layout.marginWidth = 0; + composite.setLayout(layout); + + final Label nameLabel = new Label(composite, SWT.NONE); + nameLabel.setText(Messages.Available_Palettes); + GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false); + nameLabel.setLayoutData(data); + + // Create action buttons + createEditionPaletteButton(composite, NEW_EXTENDED_PALETTE_BUTTON_ID, Activator.getInstance().getBundledImage(NEW_LOCAL_DESC_IMAGE), Messages.Dialog_Create_Palette_Tooltip); + createEditionPaletteButton(composite, EDIT_PALETTE_BUTTON_ID, Activator.getInstance().getBundledImage(EDIT_LOCAL_DESC_IMAGE), Messages.Dialog_Edit_Palette_Tooltip); + createEditionPaletteButton(composite, DELETE_PALETTE_BUTTON_ID, Activator.getInstance().getBundledImage(DELETE_LOCAL_DESC_IMAGE), Messages.Dialog_Delete_Palette_Tooltip); + createEditionPaletteButton(composite, RESTORE_DEFAULT_PALETTE_BUTTON_ID, Activator.getInstance().getBundledImage(RESTORE_DEFAULT_DESC_IMAGE), Messages.Dialog_Restore_Palette_Tooltip); + createEditionPaletteButton(composite, EXPORT_DEFAULT_PALETTE_BUTTON_ID, Activator.getInstance().getBundledImage(EXPORT_DEFAULT_DESC_IMAGE), Messages.Dialog_Export_Palette_Tooltip); + + // initialize it + paletteButtonsMap.get(DELETE_PALETTE_BUTTON_ID).setEnabled(false); + paletteButtonsMap.get(EDIT_PALETTE_BUTTON_ID).setEnabled(false); + paletteButtonsMap.get(RESTORE_DEFAULT_PALETTE_BUTTON_ID).setEnabled(false); + paletteButtonsMap.get(EXPORT_DEFAULT_PALETTE_BUTTON_ID).setEnabled(false); + + availablePalettesTable = new Table(composite, SWT.BORDER | SWT.CHECK); + availablePalettesTable.setFont(composite.getFont()); + availablePalettesTable.addSelectionListener(new SelectionListener() { + + /** + * {@inheritDoc} + */ + @Override + public void widgetSelected(final SelectionEvent e) { + if (e.detail == SWT.CHECK) { + TableItem item = (TableItem) e.item; + // one item was checked => display/hide the given provider + changeProviderVisibility((PapyrusPaletteService.ProviderDescriptor) item.getData(), item.getChecked()); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void widgetDefaultSelected(final SelectionEvent e) { + // does nothing + } + }); + data = new GridData(GridData.FILL_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL); + data.horizontalSpan = 6; + data.widthHint = 185; + // Make the tree this tall even when there is nothing in it. This will keep the + // dialog from shrinking to an unusually small size. + data.heightHint = 200; + availablePalettesTable.setLayoutData(data); + availablePalettesTableViewer = new CheckboxTableViewer(availablePalettesTable); + AvailablePalettesCheckStateProvider availablePalettesCheckStateProvider = new AvailablePalettesCheckStateProvider(); + availablePalettesTableViewer.setCheckStateProvider(availablePalettesCheckStateProvider); + availablePalettesTableViewer.setContentProvider(new PalettesTableContentProvider(availablePalettesTableViewer)); + providersLabelProvider = new PaletteLabelProvider(availablePalettesTableViewer); + availablePalettesTableViewer.setLabelProvider(providersLabelProvider); + availablePalettesTableViewer.setInput(PapyrusPaletteService.getInstance()); + availablePalettesTableViewer.addDoubleClickListener(new IDoubleClickListener() { + + @Override + public void doubleClick(DoubleClickEvent event) { + // get selection. if local palette: open the wizard to edit this local palette + IStructuredSelection selection = (IStructuredSelection) event.getSelection(); + editSelectedPalette(selection); + } + }); + + return composite; + } + + /** + * Create button to edit palette in table. + * + * @param parentConposite + * @return the edition button + */ + protected Button createEditionPaletteButton(final Composite parentConposite, final int id, final Image icon, final String toolTip) { + Button button = new Button(parentConposite, SWT.NONE); + button.setData(new Integer(id)); + button.setImage(icon); + button.setToolTipText(toolTip); + button.addMouseListener(new MouseAdapter() { + + @Override + public void mouseUp(final MouseEvent e) { + buttonPressed(((Integer) e.widget.getData()).intValue()); + } + + }); + + // Register created button + paletteButtonsMap.put(new Integer(id), button); + + return button; + } + + /** + * {@inheritDoc} + * + * @param + */ + @Override + protected void buttonPressed(final int buttonId) { + if (paletteButtonsMap.containsKey(buttonId)) { + + switch (buttonId) { + case NEW_EXTENDED_PALETTE_BUTTON_ID: + createPaletteConfigurationPalette(); + break; + case EDIT_PALETTE_BUTTON_ID: { + IStructuredSelection selection = getPalettesTableSelection(); + editSelectedPalette(selection); + } + break; + case DELETE_PALETTE_BUTTON_ID: { + IStructuredSelection selection = getPalettesTableSelection(); + deleteSelectedPalette(selection); + } + break; + case RESTORE_DEFAULT_PALETTE_BUTTON_ID: + restoreExtendedPaletteToDefault(); + break; + + case EXPORT_DEFAULT_PALETTE_BUTTON_ID: { + IStructuredSelection selection = getPalettesTableSelection(); + exportSelectedPalette(selection); + break; + } + default: + break; + } + } else { + super.buttonPressed(buttonId); + } + } + + /** + * Open wizard to export palette configuration model file to the wanted location + * + * @param selection + * the selected palette + */ + protected void exportSelectedPalette(final IStructuredSelection selection) { + /* + * Two palettes type to export: + * - ExtendedProviderDescriptor : plug-in definition : needs to create local file if not exist + * - LocalExtendedProviderDescriptor : local definition + */ + + Object firstElement = selection.getFirstElement(); + if (firstElement instanceof PapyrusPaletteService.ExtendedProviderDescriptor) { + + if (!isRedefined((ExtendedProviderDescriptor) firstElement)) { + // create a local redefinition of this palette contribution + PapyrusPalettePreferences.createPaletteRedefinition((ExtendedProviderDescriptor) firstElement); + } + exportPalette((PapyrusPaletteService.ProviderDescriptor) firstElement); + + } else if (firstElement instanceof PapyrusPaletteService.LocalExtendedProviderDescriptor) { + exportPalette((PapyrusPaletteService.ProviderDescriptor) firstElement); + } + } + + /** + * export the palette corresponding to the descriptor. The ressource have to exist. + * + * @param descriptor + */ + protected void exportPalette(final PapyrusPaletteService.ProviderDescriptor descriptor) { + ExportPaletteConfigurationWizard wizard = new ExportPaletteConfigurationWizard(getActiveSashPage(), descriptor); + WizardDialog wizardDialog = new WizardDialog(new Shell(), wizard); + wizardDialog.open(); + } + + /** + * Get selection in palettes table viewer. + * + * @return The {@link IStructuredSelection} if there is one, otherwise <code>null</code> + */ + private IStructuredSelection getPalettesTableSelection() { + IStructuredSelection structuredSelection = null; + if (availablePalettesTableViewer != null) { + ISelection selection = availablePalettesTableViewer.getSelection(); + if (selection instanceof IStructuredSelection) { + structuredSelection = (IStructuredSelection) selection; + } + } + return structuredSelection; + } + + /** + * @see org.eclipse.jface.dialogs.Dialog#setButtonLayoutData(org.eclipse.swt.widgets.Button) + * + * @param button + */ + @Override + protected void setButtonLayoutData(final Button button) { + if (paletteButtonsMap.containsValue(button)) { + GridData data = new GridData(SWT.CENTER, SWT.CENTER, false, false); + button.setLayoutData(data); + button.setEnabled(false); + } else { + super.setButtonLayoutData(button); + } + } + + /** + * Launch the wizard for the palette creation + * + * @param shell + * the shell where to display the wizard + */ + protected void createPaletteConfigurationPalette() { + PaletteConfigurationWizard wizard = new PaletteConfigurationWizard(getActiveSashPage()); + WizardDialog wizardDialog = new WizardDialog(new Shell(), wizard); + wizardDialog.open(); + } + + /** + * Deletes the current selected local extended palette + */ + protected void deleteLocalExtendedPalette(final PapyrusPaletteService.LocalExtendedProviderDescriptor descriptor) { + if (null == descriptor) { + MessageDialog.openError(getShell(), Messages.Dialog_Not_Local_Palette_Title, Messages.Dialog_Not_Local_Palette_Message); + } else { + String id = descriptor.getContributionID(); + deleteAssociatedRessource(descriptor); + PapyrusPalettePreferences.deleteLocalExtendedPalette(id); + } + } + + /** + * Deletes the current selected local palette + */ + protected void deleteWorkspaceExtendedPalette(final PapyrusPaletteService.LocalProviderDescriptor descriptor) { + if (null == descriptor) { + MessageDialog.openError(getShell(), Messages.Dialog_Not_Extended_Palette_Title, Messages.Dialog_Not_Extended_Palette_Message); + } else { + String id = descriptor.getContributionID(); + PapyrusPalettePreferences.deleteWorkspaceExtendedPalette(id); + } + } + + /** + * Reset the current selected extended palette to the initial configuration in the plugin + */ + protected void restoreExtendedPaletteToDefault() { + IStructuredSelection selection = (IStructuredSelection) availablePalettesTableViewer.getSelection(); + if (null == selection || !(selection.getFirstElement() instanceof PapyrusPaletteService.ExtendedProviderDescriptor)) { + MessageDialog.openError(getShell(), Messages.Dialog_Not_Extended_Palette_Title, Messages.Dialog_Not_Extended_Palette_Message); + } else { + PapyrusPaletteService.ExtendedProviderDescriptor descriptor = ((PapyrusPaletteService.ExtendedProviderDescriptor) selection.getFirstElement()); + String id = descriptor.getContributionID(); + + deleteAssociatedRessource(descriptor); + + PapyrusPalettePreferences.unregisterLocalRedefinition(id); + + // Refresh element on Palette preview only if is checked + if (availablePalettesTableViewer.getChecked(descriptor)) { + // toggle visibility to refresh the content + changeProviderVisibility(descriptor, false); + changeProviderVisibility(descriptor, true); + } + + paletteButtonsMap.get(RESTORE_DEFAULT_PALETTE_BUTTON_ID).setEnabled(false); + } + } + + + /** + * Delete associated resource and unloads models. + * + * @param descriptor + * + */ + protected void deleteAssociatedRessource(ProviderDescriptor descriptor) { + PaletteConfigurationWizard wizard = new PaletteConfigurationWizard(getActiveSashPage(), descriptor); + wizard.deleteResource(); + wizard.dispose(); + } + + /** + * Method to launch edition dialog according to selection. + * + * @param selection + * Selection which determine kind of edition + */ + protected void editSelectedPalette(IStructuredSelection selection) { + if (null != selection) { + if (selection.getFirstElement() instanceof PapyrusPaletteService.WorkspaceExtendedProviderDescriptor || selection.getFirstElement() instanceof PapyrusPaletteService.LocalExtendedProviderDescriptor) { + editPaletteConfiguration((ProviderDescriptor) selection.getFirstElement()); + } else if (selection.getFirstElement() instanceof PapyrusPaletteService.ExtendedProviderDescriptor) { + editExtendedPalette((PapyrusPaletteService.ExtendedProviderDescriptor) selection.getFirstElement()); + } + } + } + + /** + * Method to delete palette according to selection. + * + * @param selection + * Selection which determine kind of delectino + */ + protected void deleteSelectedPalette(final IStructuredSelection selection) { + if (null != selection) { + if (selection.getFirstElement() instanceof PapyrusPaletteService.WorkspaceExtendedProviderDescriptor) { + deleteWorkspaceExtendedPalette((PapyrusPaletteService.LocalProviderDescriptor) selection.getFirstElement()); + } else if (selection.getFirstElement() instanceof PapyrusPaletteService.LocalExtendedProviderDescriptor) { + deleteLocalExtendedPalette((PapyrusPaletteService.LocalExtendedProviderDescriptor) selection.getFirstElement()); + } + availablePalettesTableViewer.refresh(); + } + } + + /** + * Open wizard to edit palette configuration model. + * + * @param descriptor + * the provider descriptor of the palette + */ + protected void editPaletteConfiguration(final ProviderDescriptor descriptor) { + PaletteConfigurationWizard wizard = new PaletteConfigurationWizard(getActiveSashPage(), descriptor); + WizardDialog wizardDialog = new WizardDialog(new Shell(), wizard); + wizardDialog.open(); + } + + /** + * Open wizard to edit palette configuration model for a read-only palette. + * + * @param descriptor + * the provider descriptor of the palette + */ + protected void editExtendedPalette(final ExtendedProviderDescriptor descriptor) { + if (!isRedefined(descriptor)) { + // create a local redefinition of this palette contribution + PapyrusPalettePreferences.createPaletteRedefinition(descriptor); + } + editPaletteConfiguration(descriptor); + } + + /** + * Test if a palette redefinition exist for the descriptor. + * + * @param descriptor + * the exttended provider desciptor to test + * @return true if redefined + */ + public Boolean isRedefined(final ExtendedProviderDescriptor descriptor) { + // check the file in plugin state area. + String contributionID = descriptor.getContributionID(); + String paletteRedefinition = PapyrusPalettePreferences.getPaletteRedefinition(contributionID); + return null != paletteRedefinition; + } + + + /** + * Changes the visibility of the given provider + * + * @param descriptor + * the provider to hide/show + * @param isChecked + * <code>true</code> if the descriptor should be visible + */ + protected void changeProviderVisibility(final PapyrusPaletteService.ProviderDescriptor descriptor, final boolean isChecked) { + PapyrusPalettePreferences.changePaletteVisibility(descriptor.getContributionID(), getActiveSashPage().getClass().getName(), isChecked); + } + + /** + * Creates the main composite for the dialog area + * + * @param parent + * the parent of the createrd composite + * @return the newly created Composite + */ + protected Composite createMainComposite(final Composite parent) { + // dialog window + // create a composite with standard margins and spacing + Composite composite = new Composite(parent, SWT.NONE); + FormLayout layout = new FormLayout(); + layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); + layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); + composite.setLayout(layout); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + applyDialogFont(composite); + return composite; + } + + /** + * Content provider for available tools viewer + */ + public class PalettesTableContentProvider implements IStructuredContentProvider { + + /** the palette root */ + private PapyrusPaletteService paletteService; + + /** tree viewer to fill */ + private final TableViewer viewer; + + /** + * Constructor + * + * @param tableViewer + * The TableViewer whose ContentProvider this PaletteTreeProvider is + */ + public PalettesTableContentProvider(final TableViewer tableViewer) { + this.viewer = tableViewer; + } + + /** + * {@inheritDoc} + */ + @Override + public void dispose() { + paletteService = null; + } + + /** + * {@inheritDoc} + */ + @Override + public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) { + if (newInput != null) { + paletteService = (PapyrusPaletteService) newInput; + } + } + + /** + * {@inheritDoc} + */ + @Override + public Object[] getElements(final Object inputElement) { + if (inputElement instanceof PapyrusPaletteService) { + List<PapyrusPaletteService.ProviderDescriptor> providers = ((PapyrusPaletteService) inputElement).getContributingProviders(getActiveSashPage(), getPaletteRoot()); + + return providers.toArray(); + } + return null; + } + } + + /** + * Returns the current active sash page + * + * @return the current active sash page + */ + protected IEditorPart getActiveSashPage() { + // Lookup ServiceRegistry + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + IEditorPart editorPart = page.getActiveEditor(); + assert editorPart != null; + ISashWindowsContainer sashWindowsContainer = editorPart.getAdapter(ISashWindowsContainer.class); + if (sashWindowsContainer != null) { + return sashWindowsContainer.getActiveEditor(); + } + return null; + } + + /** + * provider in charge of the check boxes in the available palettes table viewer + */ + protected class AvailablePalettesCheckStateProvider implements ICheckStateProvider { + + /** + * {@inheritDoc} + */ + @Override + public boolean isChecked(final Object element) { + boolean checked = false; + if (element instanceof PapyrusPaletteService.ProviderDescriptor) { + checked = !PapyrusPalettePreferences.getHiddenPalettes(getActiveSashPage()).contains(((PapyrusPaletteService.ProviderDescriptor) element).getContributionID()); + } + return checked; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isGrayed(final Object element) { + return false; + } + + } + + /** + * Label provider for available tools viewer + */ + protected class PaletteLabelProvider implements ILabelProvider { + + /** + * Creates a new PaletteLabelProvider. + * + * @param viewer + * the table viewer where the labels are displayed + */ + public PaletteLabelProvider(final TableViewer viewer) { + } + + private Map<ImageDescriptor, Image> imageCache = new HashMap<ImageDescriptor, Image>(); + + /** + * {@inheritDoc} + */ + @Override + public Image getImage(final Object element) { + if (element instanceof PapyrusPaletteService.LocalProviderDescriptor) { + return Activator.getInstance().getBundledImage(LOCAL_DESCRIPTOR); + } else if (element instanceof PapyrusPaletteService.ExtendedProviderDescriptor) { + // icon should be decorated if it is already defined in a local way or not. + return Activator.getInstance().getBundledImage(EXTENDED_PLUGIN_DESCRIPTOR); + } else if (element instanceof PapyrusPaletteService.ProviderDescriptor) { + return Activator.getInstance().getBundledImage(PLUGIN_DESCRIPTOR); + } + return Activator.getInstance().getBundledImage(DEFAULT_IMAGE); + } + + /** + * {@inheritDoc} + */ + @Override + public String getText(final Object element) { + String text = null; + if (element instanceof PapyrusPaletteService.ProviderDescriptor) { + text = ((PapyrusPaletteService.ProviderDescriptor) element).getContributionName(); + } + return null != text ? text : "<undefined>";//$NON-NLS-1$ + } + + /** + * {@inheritDoc} + */ + @Override + public void addListener(final ILabelProviderListener listener) { + } + + /** + * {@inheritDoc} + */ + @Override + public void dispose() { + Iterator<Image> images = imageCache.values().iterator(); + while (images.hasNext()) { + images.next().dispose(); + } + imageCache = null; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isLabelProperty(final Object element, final String property) { + return false; + } + + /** + * {@inheritDoc} + */ + @Override + public void removeListener(final ILabelProviderListener listener) { + } + + } + + /** + * {@inheritDoc} + */ + @Override + public void preferenceChange(final PreferenceChangeEvent event) { + String id = event.getKey(); + if (IPapyrusPaletteConstant.PALETTE_CUSTOMIZATIONS_ID.equals(id)) { + // refresh available palette table viewer + availablePalettesTableViewer.setInput(PapyrusPaletteService.getInstance()); + } + + } + +} diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/handler/AbstractDeployPaletteConfigurationHandler.java b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/handler/AbstractDeployPaletteConfigurationHandler.java new file mode 100644 index 00000000000..fdfeff6f05d --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/handler/AbstractDeployPaletteConfigurationHandler.java @@ -0,0 +1,442 @@ +/***************************************************************************** + * Copyright (c) 2016 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: + * Remi Schnekenburger (CEA LIST) - Initial API and implementation + * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Permits to display open diagram editor id + * + *****************************************************************************/ +package org.eclipse.papyrus.toolsmiths.palette.handler; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Status; +import org.eclipse.gmf.runtime.common.core.service.ProviderPriority; +import org.eclipse.gmf.runtime.common.ui.services.editor.EditorService; +import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.dialogs.TrayDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.window.Window; +import org.eclipse.papyrus.infra.gmfdiag.common.Activator; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PaletteUtil; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPalettePreferences; +import org.eclipse.papyrus.toolsmiths.palette.Messages; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CCombo; +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.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.XMLMemento; +import org.eclipse.ui.handlers.HandlerUtil; +import org.eclipse.ui.statushandlers.StatusManager; + +/** + * @author RS211865 + */ +public abstract class AbstractDeployPaletteConfigurationHandler extends AbstractHandler { + + public static class UpdateContentDialog extends TrayDialog { + + /** the palette name */ + public String paletteName; + + /** the provider priority */ + public ProviderPriority priority; + + /** the editor id */ + public String editorID; + + /** list of required profiles */ + public String requiredProfiles; + + /** file name */ + public String fileName; + + /** the name field */ + private Text nameText; + + /** the editor filed as a combo */ + private Combo editorIdCombo; + + /** the profiles text field */ + private Text profilesText; + + /** combo for priority */ + private CCombo priorityCombo; + + + /** + * Constructor. + * + * @param shell + * the shell + * @param priority + * the priority + * @param editorID + * the editor id + * @param requiredProfiles + * the required profiles + */ + protected UpdateContentDialog(final Shell shell, final String fileName, final String paletteName, final ProviderPriority priority, final String editorID, final Set<String> requiredProfiles) { + super(shell); + this.fileName = fileName; + this.paletteName = paletteName; + this.priority = priority; + this.editorID = editorID; + if (requiredProfiles != null) { + this.requiredProfiles = PaletteUtil.getSerializedProfileList(requiredProfiles); + } + } + + /** + * {@inheritDoc} + */ + @Override + protected void configureShell(final Shell newShell) { + super.configureShell(newShell); + if (newShell != null) { + newShell.setText(Messages.AbstractDeployPaletteConfigurationHandler_ConfigureDeploymentOfThePalette); + newShell.setSize(600, 400); + } + } + + /** + * {@inheritDoc} + */ + @Override + protected Control createDialogArea(final Composite parent) { + Composite superComposite = (Composite) super.createDialogArea(parent); + Composite composite = new Composite(superComposite, SWT.NONE); + composite.setLayout(new GridLayout(2, false)); + composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); + + // new grid data will all necessary info + Label nameLabel = new Label(composite, SWT.NONE); + nameLabel.setText(Messages.AbstractDeployPaletteConfigurationHandler_Identifier); + nameText = new Text(composite, SWT.BORDER); + if (paletteName == null) { + paletteName = fileName; + } + nameText.setText(paletteName); + nameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); + + Label priorityLabel = new Label(composite, SWT.NONE); + priorityLabel.setText(Messages.AbstractDeployPaletteConfigurationHandler_Priority); + priorityCombo = new CCombo(composite, SWT.BORDER); + priorityCombo.setEditable(false); + priorityCombo.setItems(new String[] { ProviderPriority.LOWEST.getName(), ProviderPriority.LOW.getName(), ProviderPriority.MEDIUM.getName(), ProviderPriority.HIGH.getName(), ProviderPriority.HIGHEST.getName() }); + if (ProviderPriority.LOWEST.equals(priority)) { + priorityCombo.select(0); + } else if (ProviderPriority.LOW.equals(priority)) { + priorityCombo.select(1); + } else if (ProviderPriority.MEDIUM.equals(priority)) { + priorityCombo.select(2); + } else if (ProviderPriority.HIGH.equals(priority)) { + priorityCombo.select(3); + } else if (ProviderPriority.HIGHEST.equals(priority)) { + priorityCombo.select(4); + } else { + priorityCombo.select(2); // default = medium + } + priorityCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); + + Label editorLabel = new Label(composite, SWT.NONE); + editorLabel.setText(Messages.AbstractDeployPaletteConfigurationHandler_Editor); + editorIdCombo = new Combo(composite, SWT.BORDER); + if (editorID == null) { + editorID = ""; //$NON-NLS-1$ + } + editorIdCombo.setItems(findOpenedDiagramEditor().toArray(new String[] {})); + editorIdCombo.setText(editorID); + editorIdCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); + + // list of profiles + Label profilesLabel = new Label(composite, SWT.NONE); + profilesLabel.setText(Messages.AbstractDeployPaletteConfigurationHandler_Profiles); + profilesText = new Text(composite, SWT.BORDER); + if (requiredProfiles != null) { + profilesText.setText(requiredProfiles); + } + profilesText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); + + return superComposite; + } + + /** + * Get the list of id of opened diagram editor + * + * @return the list of opened diagram editor + */ + public static List<String> findOpenedDiagramEditor() { + + // The list of diagram id + List<String> ids = new ArrayList<String>(); + + // The list of open editor part + List<?> diagramEditors = EditorService.getInstance().getRegisteredEditorParts(); + + // Filter it and fill the list with contribution id of each DiagramEditor + diagramEditors.stream() + .filter(diagram -> diagram instanceof DiagramEditor) + .forEach(diagram -> { + ids.add(((DiagramEditor) diagram).getContributorId()); + }); + + return ids; + } + + /** + * {@inheritDoc} + */ + @Override + protected void okPressed() { + // updates values + if (null != nameText && !nameText.isDisposed()) { + paletteName = nameText.getText(); + } + + if (null != editorIdCombo && !editorIdCombo.isDisposed()) { + editorID = editorIdCombo.getText(); + } + + if (null != priorityCombo && !priorityCombo.isDisposed()) { + priority = ProviderPriority.parse(priorityCombo.getText()); + } + + if (null != profilesText && !profilesText.isDisposed()) { + requiredProfiles = profilesText.getText(); + } + + super.okPressed(); + } + + } + + /** + * {@inheritDoc} + */ + @Override + public Object execute(final ExecutionEvent event) throws ExecutionException { + ISelection currentSelection = HandlerUtil.getCurrentSelection(event); + if (!(currentSelection instanceof IStructuredSelection) || currentSelection.isEmpty()) { + return null; + } + + final IStructuredSelection selection = (IStructuredSelection) currentSelection; + + final Shell activeShell = HandlerUtil.getActiveShell(event); + + + doExecute(selection, activeShell, new NullProgressMonitor()); + return null; + + } + + protected void doExecute(final IStructuredSelection selection, final Shell activeShell, final IProgressMonitor monitor) { + + Iterator<?> selectionIterator = selection.iterator(); + + MultiStatus result = new MultiStatus(Activator.ID, IStatus.OK, Messages.AbstractDeployPaletteConfigurationHandler_ThePaletteConfigurationHasBeenSuccessfullyDeployedAndActivated, null); + + while (selectionIterator.hasNext()) { + Object selectedElement = selectionIterator.next(); + if (selectedElement instanceof IAdaptable) { + IFile selectedFile = ((IAdaptable) selectedElement).getAdapter(IFile.class); + if (selectedFile == null) { + monitor.worked(1); + result.add(new Status(IStatus.ERROR, Activator.ID, Messages.AbstractDeployPaletteConfigurationHandler_TheSelectedElementIsNotAFile)); + continue; + } + + + String fileName = selectedFile.getFullPath().removeFileExtension().lastSegment(); + monitor.subTask(Messages.AbstractDeployPaletteConfigurationHandler_Deploy + fileName); + boolean alreadyDeployed = false; + // retrieve info => open a dialog, filled by current opened editor ? + ProviderPriority priority = getPriority(fileName); + if (null == priority) { + priority = ProviderPriority.MEDIUM; + } else { + alreadyDeployed = true; + } + + String editorID = getEditorID(fileName); + if (null != editorID) { + alreadyDeployed = true; + } + + String paletteName = getPaletteName(fileName); + if (null != paletteName) { + alreadyDeployed = true; + } + Set<String> requiredProfiles = getRequiredProfiles(fileName); + if (requiredProfiles != null && requiredProfiles.size() > 0) { + alreadyDeployed = true; + } + String path = selectedFile.getFullPath().toString(); + + + UpdateContentDialog dialog = new UpdateContentDialog(activeShell, fileName, paletteName, priority, editorID, requiredProfiles); + int returnCode = dialog.open(); + if (Window.OK == returnCode) { + boolean validUpdate = true; + + // update values from the editor + if (dialog.paletteName != null && dialog.paletteName.length() > 0) { + paletteName = dialog.paletteName; + } else { + validUpdate = false; + } + + if (dialog.priority != null) { + priority = dialog.priority; + } else { + validUpdate = false; + } + + if (dialog.editorID != null && dialog.editorID.length() > 0) { + editorID = dialog.editorID; + } else { + validUpdate = false; + } + + if (dialog.requiredProfiles != null && dialog.requiredProfiles.length() > 0) { + requiredProfiles = PaletteUtil.getProfileSetFromString(dialog.requiredProfiles); + } else { + requiredProfiles = Collections.emptySet(); + } + + if (validUpdate) { + if (alreadyDeployed) { + // update values and set visible again + result.add(activatePalette(fileName, paletteName, path, priority, editorID, requiredProfiles)); + } else { + result.add(deployPalette(fileName, paletteName, path, priority, editorID, requiredProfiles)); + } + } else { + result.add(new Status(IStatus.ERROR, Activator.ID, Messages.AbstractDeployPaletteConfigurationHandler_Error_ContentDialogNotValid)); + } + } else { + result.add(new Status(IStatus.ERROR, Activator.ID, Messages.AbstractDeployPaletteConfigurationHandler_Error_UserCancelDialog)); + } + + } + } + + if (result.getChildren().length == 1) { + if (result.isOK()) { + MessageDialog.openInformation(activeShell, Messages.AbstractDeployPaletteConfigurationHandler_Success, result.getMessage()); + } else if (result.getSeverity() < IStatus.ERROR) { // Errors are already logged + StatusManager.getManager().handle(result, StatusManager.SHOW); + } + } else { // Merge the result and specify an appropriate message based on the result + if (result.isOK()) { + MessageDialog.openInformation(activeShell, Messages.AbstractDeployPaletteConfigurationHandler_Success, result.getMessage()); + } else { + MultiStatus actualResult = new MultiStatus(Activator.ID, result.getCode(), Messages.AbstractDeployPaletteConfigurationHandler_Error_SomeErrorsOccured, result.getException()); + actualResult.merge(result); + } + } + } + + /** + * get the Required Profiles + * + * @param identifier + * the identifier + * @return the required profiles + */ + protected Set<String> getRequiredProfiles(final String identifier) { + return PapyrusPalettePreferences.getRequiredProfiles(identifier, getMemento()); + } + + /** + * get the Palette Name + * + * @param identifier + * the identifier + * @return the Palette Name + */ + protected String getPaletteName(final String identifier) { + return PapyrusPalettePreferences.getPaletteName(identifier, getMemento()); + } + + /** + * get the Editor ID + * + * @param identifier + * the identifier + * @return the Editor ID + */ + protected String getEditorID(final String identifier) { + return PapyrusPalettePreferences.getEditorID(identifier, getMemento()); + } + + /** + * get the priority + * + * Warning. Can be <code>null</code>! + * + * @param identifier + * the identifier + * @return the provider priority + */ + protected ProviderPriority getPriority(final String identifier) { + return PapyrusPalettePreferences.getPalettePriority(identifier, getMemento()); + } + + /** get the xml memento */ + protected abstract XMLMemento getMemento(); + + /** + * deploy the Palette + * + * @param fileName + * @param paletteName + * @param path + * @param priority + * @param editorID + * @param requiredProfiles + * @return + */ + protected abstract IStatus deployPalette(final String fileName, final String paletteName, final String path, final ProviderPriority priority, final String editorID, final Set<String> requiredProfiles); + + /** + * activate the Palette + * + * @param fileName + * @param paletteName + * @param path + * @param priority + * @param editorID + * @param requiredProfiles + * @return + */ + protected abstract IStatus activatePalette(final String fileName, final String paletteName, final String path, final ProviderPriority priority, final String editorID, final Set<String> requiredProfiles); + +} diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/handler/AbstractUndeployPaletteConfigurationHandler.java b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/handler/AbstractUndeployPaletteConfigurationHandler.java new file mode 100644 index 00000000000..c936f1fa986 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/handler/AbstractUndeployPaletteConfigurationHandler.java @@ -0,0 +1,136 @@ +/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Remi Schnekenburger (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.toolsmiths.palette.handler;
+
+import java.util.Iterator;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPalettePreferences;
+import org.eclipse.papyrus.infra.gmfdiag.paletteconfiguration.Activator;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.XMLMemento;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.statushandlers.StatusManager;
+
+/**
+ * @author RS211865
+ */
+public abstract class AbstractUndeployPaletteConfigurationHandler extends AbstractHandler {
+
+ /**
+ *
+ */
+ public AbstractUndeployPaletteConfigurationHandler() {
+ super();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection currentSelection = HandlerUtil.getCurrentSelection(event);
+ if (!(currentSelection instanceof IStructuredSelection) || currentSelection.isEmpty()) {
+ return null;
+ }
+
+ final IStructuredSelection selection = (IStructuredSelection) currentSelection;
+
+ final Shell activeShell = HandlerUtil.getActiveShell(event);
+
+
+ doExecute(selection, activeShell, new NullProgressMonitor());
+ return null;
+ }
+
+ protected void doExecute(IStructuredSelection selection, Shell activeShell, IProgressMonitor monitor) {
+ Iterator<?> selectionIterator = selection.iterator();
+
+ MultiStatus result = new MultiStatus(Activator.PLUGIN_ID, IStatus.OK, "The palette configuration has been successfully deactivated and undeployed", null);
+
+ while (selectionIterator.hasNext()) {
+ Object selectedElement = selectionIterator.next();
+ if (selectedElement instanceof IAdaptable) {
+ IFile selectedFile = (IFile) ((IAdaptable) selectedElement).getAdapter(IFile.class);
+ if (selectedFile == null) {
+ monitor.worked(1);
+ result.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "The selected element is not a file"));
+ continue;
+ }
+
+
+ String fileName = selectedFile.getFullPath().removeFileExtension().lastSegment();
+ monitor.subTask("Undeploy " + fileName);
+
+ // do not delete.
+ // PapyrusPalettePreferences.deleteWorkspacePalette(fileName);
+
+ // if not deploy, do nothing and onlyh warn
+ String editorId = getEditorID(fileName);
+ if (editorId == null) {
+ // not deployed: cancel the undeploy action
+ MessageDialog.openInformation(activeShell, "Not deployed", "This palette is currently not deployed");
+ result.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "The palette configuration " + fileName + " was not undeployed already"));
+ } else {
+ result.add(deactivatePalette(fileName, editorId));
+ }
+
+ }
+ }
+
+ if (result.getChildren().length == 1) {
+ if (result.isOK()) {
+ MessageDialog.openInformation(activeShell, "Success", result.getMessage());
+ } else if (result.getSeverity() < IStatus.ERROR) { // Errors are already logged
+ StatusManager.getManager().handle(result, StatusManager.SHOW);
+ }
+ } else { // Merge the result and specify an appropriate message based on the result
+ if (result.isOK()) {
+ MessageDialog.openInformation(activeShell, "Success", result.getMessage());
+ } else {
+ MultiStatus actualResult = new MultiStatus(Activator.PLUGIN_ID, result.getCode(), "Some errors occurred during the deployment", result.getException());
+ actualResult.merge(result);
+ }
+ }
+ }
+
+ /**
+ * @return
+ */
+ protected abstract XMLMemento getMemento();
+
+ /**
+ * @param fileName
+ * @return
+ */
+ protected abstract IStatus deactivatePalette(String identifier, String editorId);
+
+ /**
+ * @param identifier
+ * @return
+ */
+ protected String getEditorID(String identifier) {
+ return PapyrusPalettePreferences.getEditorID(identifier, getMemento());
+ }
+}
diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/handler/DeployExtendedPaletteConfigurationHandler.java b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/handler/DeployExtendedPaletteConfigurationHandler.java new file mode 100644 index 00000000000..ea07172cb94 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/handler/DeployExtendedPaletteConfigurationHandler.java @@ -0,0 +1,58 @@ +/***************************************************************************** + * Copyright (c) 2014 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: + * Remi Schnekenburger (CEA LIST) - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.toolsmiths.palette.handler; + +import java.util.Set; + +import org.eclipse.core.commands.IHandler; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.gmf.runtime.common.core.service.ProviderPriority; +import org.eclipse.papyrus.infra.gmfdiag.common.Activator; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPalettePreferences; +import org.eclipse.ui.XMLMemento; + + +/** + * Handler to deploy new configuration of palette based on a XML file + */ +public class DeployExtendedPaletteConfigurationHandler extends AbstractDeployPaletteConfigurationHandler implements IHandler { + + /** + * {@inheritDoc} + */ + @Override + protected IStatus deployPalette(String fileName, String paletteName, String path, ProviderPriority priority, String editorID, Set<String> requiredProfiles) { + // just add the palette + PapyrusPalettePreferences.addWorkspaceExtendedPalette(paletteName, paletteName, path, priority, editorID, requiredProfiles); + return new Status(IStatus.OK, Activator.ID, "The palette configuration has been successfully deployed and activated"); + } + + /** + * {@inheritDoc} + */ + @Override + protected IStatus activatePalette(String fileName, String paletteName, String path, ProviderPriority priority, String editorID, Set<String> requiredProfiles) { + PapyrusPalettePreferences.addWorkspaceExtendedPalette(paletteName, paletteName, path, priority, editorID, requiredProfiles); + PapyrusPalettePreferences.changePaletteVisibility(fileName, editorID, true); + return new Status(IStatus.OK, Activator.ID, "The palette configuration was already deployed, it has just been activated"); + } + + /** + * {@inheritDoc} + */ + @Override + protected XMLMemento getMemento() { + return PapyrusPalettePreferences.getExistingWorkspaceExtendedPalettes(); + } +}
\ No newline at end of file diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/handler/UndeployExtendedPaletteConfigurationHandler.java b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/handler/UndeployExtendedPaletteConfigurationHandler.java new file mode 100644 index 00000000000..fdaa9ff6856 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/handler/UndeployExtendedPaletteConfigurationHandler.java @@ -0,0 +1,44 @@ +/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Remi Schnekenburger (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.toolsmiths.palette.handler;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.papyrus.infra.gmfdiag.common.Activator;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPalettePreferences;
+import org.eclipse.ui.XMLMemento;
+
+
+
+/**
+ * Handler to undeploy a palette configured by a EMF model. similar implementation to the XML based palette, because visibility has the same implementation in our case.
+ */
+public class UndeployExtendedPaletteConfigurationHandler extends AbstractUndeployPaletteConfigurationHandler {
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected IStatus deactivatePalette(String identifier, String editorId) {
+ PapyrusPalettePreferences.changePaletteVisibility(identifier, editorId, false);
+ return new Status(IStatus.OK, Activator.ID, "The palette configuration " + identifier + " has been successfully deactivated and undeployed");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected XMLMemento getMemento() {
+ return PapyrusPalettePreferences.getExistingWorkspaceExtendedPalettes();
+ }
+}
diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/messages.properties b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/messages.properties new file mode 100644 index 00000000000..e41320270a2 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/messages.properties @@ -0,0 +1,123 @@ +############################################################################### +# Copyright (c) 2010 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: +# Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation +############################################################################### + +# Explorer dialog messages +BundleIconExplorerDialog_Message=Please select an icon in the following list +BundleIconExplorerDialog_Title=Icon selection +BundleIconExplorerDialog_UnknownFileName=<Unknown> + +########### Palette configuration model edition messages ########### +ExportPaletteConfigurationWizard_error_cant_read_file=Impossible to read local definition of the file +ExportPaletteConfigurationWizard_error_file_not_existe=local file does not exists : +ExportPaletteConfigurationWizard_Export_description=Choose where you want to export the selected palette configuration +ExportPaletteConfigurationWizard_ExportWiazrdLabel=Export +ExportPaletteConfigurationWizard_export_palette=Export Palette Configuration +PaletteConfigurationContentPage_CreateAnElementWithAStereotype=Create an element with a stereotype +PaletteConfigurationContentPage_Drawer=Drawer +PaletteConfigurationContentPage_NewTool=NewTool +PaletteConfigurationContentPage_Separator=Separator +PaletteConfigurationContentPage_Stack=Stack +PaletteConfigurationContentPage_UMLTools=UML tools +PaletteConfigurationContentPage_UnknownElement=unknown element +PaletteConfigurationWizard_EditionPaletteInfoPageWizard_Tilte=Edit the Palette +PaletteConfigurationWizard_EditPaletteWizardLabel=Edit Palette +PaletteConfigurationWizard_NewPaletteContentPageWizard_Description=Edit the content of the palette. +PaletteConfigurationWizard_NewPaletteContentPageWizard_Title=Palette Content +PaletteConfigurationWizard_NewPaletteDefaultName=New Palette +PaletteConfigurationWizard_PaletteInfoPageWizard_Description=Enter information of the new palette. +PaletteConfigurationWizard_NewPaletteInfoPageWizard_Title=New Local Palette +PaletteConfigurationWizard_NewPaletteWizardLabel=New Palette +PaletteConfigurationWizard_ImpossibleToReadDefinitionOfTheFile=Impossible to read definition of the file +PaletteConfigurationWizard_FileDontExist=File does not exists : +PapyrusPaletteCustomizerDialog_AddButtonTooltip=Create a new palette +PapyrusPaletteCustomizerDialog_RemoveButtonTooltip=Delete the selected palette + +############# Palette Customisation ################# +PapyrusPaletteCustomizerDialog_AddButtonTooltip=Add the selection to the palette +PapyrusPaletteCustomizerDialog_RemoveButtonTooltip=Remove the selection from the palette +PapyrusPaletteCustomizerDialog_EditButtonTooltip_LocalPaletteSelected=Edit the selected local palette +PapyrusPaletteCustomizerDialog_EditButtonTooltip_LocalPaletteNotSelected=Edit a local palette. Please select a local palette in the available palette viewer. +PapyrusPaletteCustomizerDialog_EditButtonTooltip_MissingProfile=Impossible to edit this local palette because some required profile are not applied. +PapyrusPaletteCustomizerDialog_EditButtonTooltip=Edit the current selected drawer +Available_Palettes=Available palettes +Palette_Viewer=Palette preview +Local_Palette_Name=Name*: +Local_Palette_Name_Tooltip=Enter a name for this palette contribution. This name will be displayed when selecting the visible palettes and the hidden ones. +Local_Palette_Id=Identifier*: +Local_Palette_Id_Tooltip=Enter a unique identifier for this palette contribution. This identifier is used to retrieve this palette among others, which means it should be unique. +Local_Palette_Editor_Id=EditorID*: +Local_Palette_Editor_Id_Tooltip=Sets the id of the editor for which this configuration is provided. +Local_Palette_Priority=Priority*: +Local_Palette_Priority_Tooltip=Sets the palette priority. It determines which palette provider is contributing first.\nThis contribution should have at least a priority higher than predefined tools contributions. +Dialog_Advanced_Button_Closed=Advanced >> +Dialog_Advanced_Button_Opened=<< Advanced +Local_Palette_Error_Priority=One priority should be selected in the list of availables priorities +Local_Palette_Error_Name=Name field shall not be empty +Local_Palette_Error_EditorId=Editor ID field shall not be empty +Local_Palette_Error_PaletteId=Palette ID field shall not be empty +Local_Palette_InfoPage_Name=LocalPaletteInformation +Local_Palette_InfoPage_Title=Local Palette Information +Local_Palette_ContentPage_Name=LocalPaletteContent +Local_Palette_ContentPage_Title=Local Palette Content +Local_Palette_Available_Tools=Available tools +Local_Palette_ShowDrawers_Tooltip=Toggle this button to show/hide the drawers in the list +Local_Palette_ShowTools_Tooltip=Toggle this button to show/hide the tools in the list +Local_Palette_SwitchToolsContentProvider_Tooltip=Toggle this button to change the way tools are shown in the list (Metaclass -> Stereotypes or Metaclass -> Stereotypes) +Local_Palette_Palette_Preview=Palette preview +Local_Palette_Entry_Name=Name: +Local_Palette_Entry_Description=Description: +Local_Palette_Entry_Icon=Icon: +Local_Palette_Entry_Information=Entry information +Local_Palette_Entry_Reference:Extended Tool: + +Aspect_Action_Information_List_Label=Aspect actions + +Dialog_Not_Local_Palette_Title=Bad selection (no item or bad item) +Dialog_Not_Local_Palette_Message=Please select a local palette to be deleted. +Dialog_Not_Extended_Palette_Title=Bad selection (no item or bad item) +Dialog_Not_Extended_Palette_Message=Please select an extended palette to be restored. +Dialog_Delete_Palette_Tooltip=Delete selected local palette definition +Dialog_Create_Palette_Tooltip=Create a new local palette +Dialog_Edit_Palette_Tooltip=Edit selected palette +Dialog_Restore_Palette_Tooltip=Restore default values of selected palette +Dialog_Export_Palette_Tooltip= Export configuration model of selected palette + +Local_Palette_Create_Drawer_Tooltip=Create a new drawer in the palette +Local_Palette_Create_Separator_Tooltip=Create a new separator in the palette +Local_Palette_Create_Tool_Tooltip=Create a new tool in the palette +Local_Palette_Create_Stack_Tooltip=Create a new stack in the palette + +Wizard_Drawer_Page_Name=DrawerWizardPage +Wizard_Drawer_Page_Title=Drawer Information Page +Wizard_Drawer_Error_Name=Name field shall not be empty +Wizard_Drawer_Error_Id=ID field shall not be empty +Wizard_Drawer_Error_Icon=Icon field shall not be empty +Wizard_Drawer_Id=Identifier* +Wizard_Drawer_Id_Tooltip=Enter a unique identifier for this drawer.\nThis identifier is used to retrieve this drawer among others, which means it should be unique. +Wizard_Drawer_Name=Name* +Wizard_Drawer_Name_Tooltip=Enter a name for this drawer. +Wizard_Drawer_Icon_Tooltip=Enter the path to the icon. It can be something like "/icon/drawer.gif" or like "platform:/plugin/org.eclipse.uml2.uml.edit/icons/full/obj16/PackageImport.gif" +Wizard_Drawer_Icon=Icon* + +########### Palette deploy wizard ########### +AbstractDeployPaletteConfigurationHandler_ConfigureDeploymentOfThePalette=Configure deployment of the palette +AbstractDeployPaletteConfigurationHandler_Deploy=Deploy +AbstractDeployPaletteConfigurationHandler_Editor=Editor: +AbstractDeployPaletteConfigurationHandler_Error_UserCancelDialog=The palette configuration was not deployed, because user did cancel the dialog +AbstractDeployPaletteConfigurationHandler_Error_ContentDialogNotValid=The palette configuration was not deployed, because dialog content was not valid +AbstractDeployPaletteConfigurationHandler_Error_SomeErrorsOccured=Some errors occurred during the deployment +AbstractDeployPaletteConfigurationHandler_Identifier=Identifier: +AbstractDeployPaletteConfigurationHandler_Priority=Priority: +AbstractDeployPaletteConfigurationHandler_Profiles=Profiles: +AbstractDeployPaletteConfigurationHandler_Success=Success +AbstractDeployPaletteConfigurationHandler_ThePaletteConfigurationHasBeenSuccessfullyDeployedAndActivated=The palette configuration has been successfully deployed and activated +AbstractDeployPaletteConfigurationHandler_TheSelectedElementIsNotAFile=The selected element is not a file diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/provider/PaletteLabelProvider.java b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/provider/PaletteLabelProvider.java new file mode 100644 index 00000000000..52be0a218df --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/provider/PaletteLabelProvider.java @@ -0,0 +1,100 @@ +/***************************************************************************** + * 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: + * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation + *****************************************************************************/ +package org.eclipse.papyrus.toolsmiths.palette.provider; + +import org.eclipse.gef.palette.PaletteEntry; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.ILabelProvider; +import org.eclipse.jface.viewers.ILabelProviderListener; +import org.eclipse.papyrus.infra.widgets.Activator; +import org.eclipse.papyrus.toolsmiths.palette.Messages; +import org.eclipse.swt.graphics.Image; +import org.eclipse.uml2.uml.Stereotype; + +/** + * Label provider for palette tools. + * <P> + * We should be using the Palette label provider from GEF, if it was not with visibility "package"... + * + * @see org.eclipse.gef.ui.palette.customize.PaletteLabelProvider + * </P> + * + */ +public class PaletteLabelProvider implements ILabelProvider { + + /** the icon for stereotypes */ + private static final String ICONS_STEREOTYPE = "/icons/stereotype.gif"; // $NON-NLS-N$ + + /** + * {@inheritDoc} + */ + @Override + public void addListener(final ILabelProviderListener listener) { + // Do nothing + } + + /** + * {@inheritDoc} + */ + @Override + public void dispose() { + // Do nothing + } + + /** + * {@inheritDoc} + */ + @Override + public Image getImage(final Object element) { + Image iconImage = null; + if (element instanceof PaletteEntry) { + ImageDescriptor descriptor = ((PaletteEntry) element).getSmallIcon(); + if (descriptor != null) { + iconImage = Activator.getDefault().getImage(descriptor); + } + } else if (element instanceof Stereotype) { + iconImage = Activator.getDefault().getImage("org.eclipse.papyrus.customization.palette", ICONS_STEREOTYPE); + } + return iconImage; + } + + /** + * {@inheritDoc} + */ + @Override + public String getText(final Object element) { + String text = null; + if (element instanceof PaletteEntry) { + text = ((PaletteEntry) element).getLabel(); + } else if (element instanceof Stereotype) { + text = ((Stereotype) element).getName(); + } + return null != text ? text : Messages.PaletteConfigurationContentPage_UnknownElement; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isLabelProperty(final Object element, final String property) { + return false; + } + + /** + * {@inheritDoc} + */ + @Override + public void removeListener(final ILabelProviderListener listener) { + // Do nothing + } + +}
\ No newline at end of file diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/provider/ProfileToolsMetaclassStereotypeTreeContentProvider.java b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/provider/ProfileToolsMetaclassStereotypeTreeContentProvider.java new file mode 100644 index 00000000000..4e39d0d5c67 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/provider/ProfileToolsMetaclassStereotypeTreeContentProvider.java @@ -0,0 +1,170 @@ +/***************************************************************************** + * 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: + * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation + *****************************************************************************/ +package org.eclipse.papyrus.toolsmiths.palette.provider; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.gef.palette.CombinedTemplateCreationEntry; +import org.eclipse.gef.palette.PaletteEntry; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.AspectCreationEntry; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.IPapyrusPaletteConstant; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PaletteUtil; +import org.eclipse.papyrus.uml.types.core.advices.applystereotype.ApplyStereotypeAdviceConfiguration; +import org.eclipse.papyrus.uml.types.core.advices.applystereotype.ApplyStereotypeAdviceConfigurationFactory; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Profile; +import org.eclipse.uml2.uml.Stereotype; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * Content provider for the available tools viewer, when the + * TODO + */ +public class ProfileToolsMetaclassStereotypeTreeContentProvider implements ITreeContentProvider { + + /** profile to display */ + final protected Profile profile; + + /** standard uml tools palette entries */ + final protected Collection<PaletteEntry> standardEntries; + + /** + * Creates a new ProfileToolsMetaclassStereotypeTreeContentProvider. + * + * @param profile + * the profile for which tools are built + * @param standardEntries + * list of standard uml tools palette entries + */ + public ProfileToolsMetaclassStereotypeTreeContentProvider(final Profile profile, final Collection<PaletteEntry> standardEntries) { + this.profile = profile; + this.standardEntries = standardEntries; + } + + /** + * {@inheritDoc} + */ + @Override + public void dispose() { + // nothing to do here + } + + /** + * {@inheritDoc} + */ + @Override + public Object[] getChildren(Object parentElement) { + Object[] children; + if (parentElement instanceof Profile) { + children = standardEntries.toArray(); + + } else if (parentElement instanceof AspectCreationEntry) { + children = new Object[0]; + + } else if (parentElement instanceof PaletteEntry) { + List<AspectCreationEntry> entries = new ArrayList<AspectCreationEntry>(); + // display all stereotypes applicable to the type of element created by this tool + if (parentElement instanceof CombinedTemplateCreationEntry) { + CombinedTemplateCreationEntry entry = (CombinedTemplateCreationEntry) parentElement; + EClass toolMetaclass = PaletteUtil.getToolMetaclass(entry); + if (toolMetaclass != null) { + for (Stereotype stereotype : profile.getOwnedStereotypes()) { + List<Class> metaclasses = stereotype.getAllExtendedMetaclasses(); + for (Class stMetaclass : metaclasses) { + // get Eclass + java.lang.Class<?> metaclassClass = stMetaclass.getClass(); + if (metaclassClass != null) { + EClassifier metaClassifier = UMLPackage.eINSTANCE.getEClassifier(stMetaclass.getName()); + if (((EClass) metaClassifier).isSuperTypeOf(toolMetaclass)) { + // should create the palette entry + Map<String, Object> properties = new HashMap<String, Object>(); + properties.put(IPapyrusPaletteConstant.STEREOTYPES_TO_APPLY_KEY, stereotype.getQualifiedName()); + ApplyStereotypeAdviceConfiguration applyStereotypeAdvice = ApplyStereotypeAdviceConfigurationFactory.createApplyStereotypeAdvice(Collections.singletonList(stereotype.getQualifiedName()), "", null);//$NON-NLS-1$ + properties.put(IPapyrusPaletteConstant.ADVICES_TO_APPLY, Collections.singletonList(applyStereotypeAdvice)); + + StringBuilder name = new StringBuilder(); + name.append(stereotype.getName()); + name.append(" (");//$NON-NLS-1$ + name.append(entry.getLabel()); + name.append(")");//$NON-NLS-1$ + + AspectCreationEntry aspectEntry = new AspectCreationEntry(name.toString(), "", // $NON-NLS-1$ + entry.getId(), + entry.getSmallIcon(), entry, properties); + entries.add(aspectEntry); + } + } + + } + } + } + } + children = entries.toArray(); + } else { + children = new Object[0]; + } + return children; + } + + /** + * {@inheritDoc} + */ + @Override + public Object[] getElements(final Object inputElement) { + + List<Object> elements = new ArrayList<>(); + + if (inputElement instanceof Profile) { + Object[] entries = standardEntries.toArray(); + for (Object entry : entries) { + if (hasChildren(entry)) { + elements.add(entry); + } + } + } + return null != elements ? elements.toArray() : new Object[0]; + } + + /** + * {@inheritDoc} + */ + @Override + public Object getParent(final Object element) { + return element instanceof Stereotype ? ((Stereotype) element).getProfile() : null; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean hasChildren(final Object element) { + return 0 < getChildren(element).length; + } + + /** + * {@inheritDoc} + */ + @Override + public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) { + // Do nothing + } + +}
\ No newline at end of file diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/provider/ProfileToolsStereotypeMetaclassTreeContentProvider.java b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/provider/ProfileToolsStereotypeMetaclassTreeContentProvider.java new file mode 100644 index 00000000000..6ae17ad215e --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/provider/ProfileToolsStereotypeMetaclassTreeContentProvider.java @@ -0,0 +1,164 @@ +/***************************************************************************** + * 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: + * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation + *****************************************************************************/ +package org.eclipse.papyrus.toolsmiths.palette.provider; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.gef.palette.CombinedTemplateCreationEntry; +import org.eclipse.gef.palette.PaletteEntry; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.AspectCreationEntry; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.IPapyrusPaletteConstant; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PaletteUtil; +import org.eclipse.papyrus.uml.types.core.advices.applystereotype.ApplyStereotypeAdviceConfiguration; +import org.eclipse.papyrus.uml.types.core.advices.applystereotype.ApplyStereotypeAdviceConfigurationFactory; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.Profile; +import org.eclipse.uml2.uml.Stereotype; +import org.eclipse.uml2.uml.UMLPackage; + +/** + * Content provider for the available tools viewer, when the tools to see are coming from a + * profile + * TODO + */ +public class ProfileToolsStereotypeMetaclassTreeContentProvider implements ITreeContentProvider { + + /** standard uml tools palette entries */ + final protected Collection<PaletteEntry> standardEntries; + + /** + * Creates a new ProfileToolsStereotypeMetaclassTreeContentProvider. + * + * @param profile + * the profile for which tools are built + * @param standardEntries + * list of standard uml tools palette entries + */ + public ProfileToolsStereotypeMetaclassTreeContentProvider(final Profile profile, final Collection<PaletteEntry> standardEntries) { + this.standardEntries = standardEntries; + } + + /** + * {@inheritDoc} + */ + @Override + public void dispose() { + // nothing to do here + } + + /** + * {@inheritDoc} + */ + @Override + public Object[] getChildren(final Object parentElement) { + Object[] children; + if (parentElement instanceof Profile) { + children = ((Profile) parentElement).getOwnedStereotypes().toArray(); + } else if (parentElement instanceof Stereotype) { + List<PaletteEntry> entries = new ArrayList<PaletteEntry>(); + Stereotype stereotype = (Stereotype) parentElement; + + for (PaletteEntry entry : standardEntries) { + // retrieve the element type created by the tool. + if (entry instanceof CombinedTemplateCreationEntry) { + + EClass toolMetaclass = PaletteUtil.getToolMetaclass((CombinedTemplateCreationEntry) entry); + if (toolMetaclass != null) { + List<Class> metaclasses = stereotype.getAllExtendedMetaclasses(); + for (Class stMetaclass : metaclasses) { + // get Eclass + java.lang.Class<?> metaclassClass = stMetaclass.getClass(); + if (metaclassClass != null) { + EClassifier metaClassifier = UMLPackage.eINSTANCE.getEClassifier(stMetaclass.getName()); + if (((EClass) metaClassifier).isSuperTypeOf(toolMetaclass)) { + // should create the palette entry + Map<String, Object> properties = new HashMap<String, Object>(); + properties.put(IPapyrusPaletteConstant.STEREOTYPES_TO_APPLY_KEY, stereotype.getQualifiedName()); + ApplyStereotypeAdviceConfiguration applyStereotypeAdvice = ApplyStereotypeAdviceConfigurationFactory.createApplyStereotypeAdvice(Collections.singletonList(stereotype.getQualifiedName()), "", null);//$NON-NLS-1$ + properties.put(IPapyrusPaletteConstant.ADVICES_TO_APPLY, Collections.singletonList(applyStereotypeAdvice)); + + StringBuilder name = new StringBuilder(); + name.append(stereotype.getName()); + name.append(" (");//$NON-NLS-1$ + name.append(entry.getLabel()); + name.append(")");//$NON-NLS-1$ + + AspectCreationEntry aspectEntry = new AspectCreationEntry(name.toString(), "", // $NON-NLS-1$ + entry.getId(), + entry.getSmallIcon(), (CombinedTemplateCreationEntry) entry, properties); + entries.add(aspectEntry); + } + } + + } + } + } + } + children = entries.toArray(); + } else { + children = new Object[0]; + } + return children; + } + + /** + * {@inheritDoc} + */ + @Override + public Object[] getElements(final Object inputElement) { + List<Object> elements = new ArrayList<>(); + + if (inputElement instanceof Profile) { + Object[] stereotypes = ((Profile) inputElement).getOwnedStereotypes().toArray(); + for (Object stereotype : stereotypes) { + if (hasChildren(stereotype)) { + elements.add(stereotype); + } + } + } + return null != elements ? elements.toArray() : new Object[0]; + } + + /** + * {@inheritDoc} + */ + @Override + public Object getParent(final Object element) { + return element instanceof Stereotype ? ((Stereotype) element).getProfile() : null; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean hasChildren(final Object element) { + return 0 < getChildren(element).length; + } + + /** + * {@inheritDoc} + */ + @Override + public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) { + // nothing to do here + } + +}
\ No newline at end of file diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/provider/UMLToolsTreeContentProvider.java b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/provider/UMLToolsTreeContentProvider.java new file mode 100644 index 00000000000..99cbf074f09 --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/provider/UMLToolsTreeContentProvider.java @@ -0,0 +1,105 @@ +/***************************************************************************** + * 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: + * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation + *****************************************************************************/ +package org.eclipse.papyrus.toolsmiths.palette.provider; + +import java.util.Collection; + +import org.eclipse.gef.palette.PaletteRoot; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PaletteUtil; + +/** + * Content provider for available tools viewer + */ +public class UMLToolsTreeContentProvider implements ITreeContentProvider { + + /** + * Constructor + * + * @param viewer + * The viewer whose ContentProvider this content provider is + */ + public UMLToolsTreeContentProvider() { + } + + /** + * {@inheritDoc} + */ + @Override + public void dispose() { + // Do nothing + } + + /** + * {@inheritDoc} + */ + @Override + public Object[] getChildren(final Object parentElement) { + Object[] elements = null; + + if (parentElement instanceof Collection<?>) { + elements = ((Collection<?>) parentElement).toArray(); + } else if (parentElement instanceof PaletteRoot) { + // paletteUil.getAllEntries(...) to add drawers + // if so, uncomment the addFilterbutton for drawers in populate tool bar + elements = PaletteUtil.getAllToolEntries(((PaletteRoot) parentElement)).toArray(); + } + + return elements; + } + + /** + * {@inheritDoc} + */ + @Override + public Object[] getElements(final Object inputElement) { + Object[] elements = null; + + if (inputElement instanceof Collection<?>) { + elements = ((Collection<?>) inputElement).toArray(); + } else if (inputElement instanceof PaletteRoot) { + // paletteUil.getAllEntries(...) to add drawers + // if so, uncomment the addFilterbutton for drawers in populate tool bar + elements = PaletteUtil.getAllToolEntries(((PaletteRoot) inputElement)).toArray(); + } + + if (elements == null) { + elements = new Object[0]; + } + return elements; + } + + /** + * {@inheritDoc} + */ + @Override + public Object getParent(final Object element) { + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean hasChildren(final Object element) { + return null != getChildren(element) && 0 < getChildren(element).length; + } + + /** + * {@inheritDoc} + */ + @Override + public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) { + // Do nothing + } +}
\ No newline at end of file diff --git a/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/utils/PaletteUtils.java b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/utils/PaletteUtils.java new file mode 100644 index 00000000000..b11c7df68ac --- /dev/null +++ b/plugins/toolsmiths/org.eclipse.papyrus.toolsmiths.palette/src/org/eclipse/papyrus/toolsmiths/palette/utils/PaletteUtils.java @@ -0,0 +1,102 @@ +/***************************************************************************** + * 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: + * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and Implementation + *****************************************************************************/ + +package org.eclipse.papyrus.toolsmiths.palette.utils; + +import java.io.File; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.xmi.XMLResource; +import org.eclipse.emf.ecore.xmi.impl.URIHandlerImpl; +import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorWithFlyOutPalette; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteService; +import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.PapyrusPaletteService.ProviderDescriptor; +import org.eclipse.papyrus.toolsmiths.palette.PaletteConstants.PaletteModelContextEnum; +import org.eclipse.ui.IEditorPart; + +/** + * Utils for palette customization. + * + */ +public class PaletteUtils { + + /** + * Save options for palette resources. + */ + public static final Map<Object, Object> saveOptions; + static { + Map<Object, Object> options = new HashMap<Object, Object>(); + options.put(Resource.OPTION_LINE_DELIMITER, Resource.OPTION_LINE_DELIMITER_UNSPECIFIED); + options.put(XMLResource.OPTION_URI_HANDLER, new URIHandlerImpl.PlatformSchemeAware()); + saveOptions = Collections.unmodifiableMap(options); + } + + /** + * set the status field which describe in which case of palette model we are. + * + * @param descriptor + */ + public static PaletteModelContextEnum getPaletteModelContext(ProviderDescriptor descriptor) { + PaletteModelContextEnum paletteContext; + // Case 1: WS + if (descriptor instanceof PapyrusPaletteService.WorkspaceExtendedProviderDescriptor) { + paletteContext = PaletteModelContextEnum.Workspace; + } else + // case 2: plugin + if (descriptor instanceof PapyrusPaletteService.ExtendedProviderDescriptor) { + paletteContext = PaletteModelContextEnum.Plugin; + } else + // case 3: local + if (descriptor instanceof PapyrusPaletteService.LocalExtendedProviderDescriptor) { + paletteContext = PaletteModelContextEnum.Local; + } else { + // case 4 : new + paletteContext = PaletteModelContextEnum.New; + } + return paletteContext; + } + + /** + * @param the + * file to test + * @return true if it exist and is readable. + */ + public static boolean notErrorOnFile(File file) { + boolean error = false; + if (null != file) { + if (!file.exists()) { + error = true; + } else if (!file.canRead()) { + error = true; + } + } + + return !error; + } + + /** + * Get the Id value of the current editor + * + * @return the editor id value as a String + */ + public static String getEditorIdValue(IEditorPart editorPart) { + String editorIDValue = ""; //$NON-NLS-1$ + if (editorPart instanceof DiagramEditorWithFlyOutPalette) { + editorIDValue = ((DiagramEditorWithFlyOutPalette) editorPart).getContributorId(); + } + return editorIDValue; + } + +} |