Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2016-02-11 02:48:20 +0000
committerGerrit Code Review @ Eclipse.org2016-02-12 15:31:41 +0000
commitecd4928b327f5561364c5068c9ff5f1668e92d13 (patch)
tree7c34f46cf82a1d65ac753fa92c2a5d55371b8dba /plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui
parent751a204d74e15eb2db6b41c937691fc56dcc1252 (diff)
downloadorg.eclipse.papyrus-ecd4928b327f5561364c5068c9ff5f1668e92d13.tar.gz
org.eclipse.papyrus-ecd4928b327f5561364c5068c9ff5f1668e92d13.tar.xz
org.eclipse.papyrus-ecd4928b327f5561364c5068c9ff5f1668e92d13.zip
Bug 485220: [Architecture] Provide a more modular architecture
https://bugs.eclipse.org/bugs/show_bug.cgi?id=485220 Factor UI dependencies out of the UML Element Types bundle. This includes moving some advices that interact with the user into a new org.eclipse.papyrus.uml.service.types.ui bundle. Pull up the PasteCommandService and IPasteCommandProvider API into the Infra Diagram layer where the extension point is defined. Deprecate the old API in the UML layer. Introduce a service for participation of languages in CSS styling: * styling reset actions in the Reset Style command * access to semantic model classes and properties to make available to CSS Factor PapyrusObservableValue and cohorts out of the UML Tools bundle into the Infra Layer for more general reuse and to relieve the Diagram Infrastructure layer of UML dependencies. The old API remains as deprecated. Remove the Infra Diagram Layer dependency on UML Layer for property testers governing deletion in the diagram. Includes introduction of a new IGraphicalDeletionHelper OSGi service for delegation of the determination of whether an element can be deleted from the diagram and replacement of the XML expression properties * org.eclipse.papyrus.uml.diagram.common.isSemanticDeletion * org.eclipse.papyrus.uml.diagram.common.isReadOnly by * org.eclipse.papyrus.infra.gmfdiag.common.isSemanticDeletion * org.eclipse.papyrus.infra.gmfdiag.common.canDelete (where the latter is the negation of the property that it supersedes) Extract UML dependencies from the Diagram Outline and CSS Editor bundles. Remove unused MDTUtil APIs that referenced a UML-specific annotation. Move the Diagram Infrastructure CSS Palette bundle into the UML layer because it serves to provide extensions on the Palette Service, which is an overtly UML-specific capability. All client APIs for the Properties View are moved from org.eclipse.papyrus.views.properties bundle to a new org.eclipse.papyrus.infra.properties.ui bundle. This includes renaming of: * extension points * label-provider contexts * XWT namespaces Add an "all UI tests" suite. Define a componentized hierarchical build layout of the main plug-ins Change-Id: I43f8f3644857a18b69715f5a2f1da9b1cf286d67
Diffstat (limited to 'plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui')
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/.classpath7
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/.project28
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/.settings/org.eclipse.jdt.core.prefs291
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/.settings/org.eclipse.jdt.ui.prefs68
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/META-INF/MANIFEST.MF30
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/META-INF/p2.inf5
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/about.html28
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/build.properties12
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/messages.properties6
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/plugin.properties15
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/plugin.xml71
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/pom.xml12
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/UIPlugin.java67
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/editor/UnloadResourcesEditorFactory.java44
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/editor/UnloadResourcesEditorModel.java168
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/expressions/LoadingTester.java154
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/CorePreferenceInitializer.java52
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/ICorePreferenceConstants.java27
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/LoadedAuthorizedResourceGroup.java40
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/LoadinStrategyGroup.java73
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/LoadingStrategyPreferencePage.java94
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/Messages.java40
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/ResourcePreferencePathEditor.java60
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/strategy/AskUserStrategy.java849
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/strategy/LoadedAuthorizedResourceManager.java221
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/strategy/PreferenceLoadingStrategyExtension.java33
-rw-r--r--plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/strategy/StrategyChooser.java69
27 files changed, 2564 insertions, 0 deletions
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/.classpath b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/.classpath
new file mode 100644
index 00000000000..64c5e31b7a2
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/.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/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/.project b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/.project
new file mode 100644
index 00000000000..291c5bcfcf8
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.papyrus.infra.services.resourceloading.ui</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>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/.settings/org.eclipse.jdt.core.prefs b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..c585cc455ae
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/.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.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=0
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=0
+org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.format_block_comments=true
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
+org.eclipse.jdt.core.formatter.comment.format_line_comments=true
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
+org.eclipse.jdt.core.formatter.comment.line_length=260
+org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
+org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
+org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=2
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
+org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
+org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.join_lines_in_comments=false
+org.eclipse.jdt.core.formatter.join_wrapped_lines=false
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.lineSplit=260
+org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=5
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
+org.eclipse.jdt.core.formatter.tabulation.char=tab
+org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.use_on_off_tags=false
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
+org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/.settings/org.eclipse.jdt.ui.prefs b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 00000000000..954281dbc31
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/.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/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/META-INF/MANIFEST.MF b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..0cdc5618cba
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,30 @@
+Manifest-Version: 1.0
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.ui,
+ org.eclipse.papyrus.infra.core;bundle-version="1.2.0",
+ org.eclipse.core.resources;bundle-version="3.8.0",
+ org.eclipse.emf.common.ui;bundle-version="2.7.0",
+ org.eclipse.papyrus.infra.services.resourceloading;bundle-version="1.2.0",
+ org.eclipse.emf.common;bundle-version="2.12.0",
+ org.eclipse.papyrus.infra.ui;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.core.sasheditor;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.core.sashwindows.di;bundle-version="1.2.0",
+ org.eclipse.papyrus.infra.widgets.toolbox;bundle-version="1.2.0",
+ org.eclipse.core.expressions;bundle-version="3.5.0",
+ org.eclipse.papyrus.infra.emf;bundle-version="1.2.0",
+ org.eclipse.gmf.runtime.emf.core;bundle-version="1.7.0",
+ org.eclipse.gmf.runtime.notation;bundle-version="1.8.0"
+Bundle-Vendor: %providerName
+Bundle-ActivationPolicy: lazy
+Bundle-Version: 1.2.0.qualifier
+Bundle-Localization: plugin
+Bundle-Name: %pluginName
+Bundle-Activator: org.eclipse.papyrus.infra.services.resourceloading.internal.ui.UIPlugin
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.eclipse.papyrus.infra.services.resourceloading.ui;singleton:=true
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.papyrus.infra.services.resourceloading.internal.ui;x-internal:=true,
+ org.eclipse.papyrus.infra.services.resourceloading.internal.ui.editor;x-internal:=true,
+ org.eclipse.papyrus.infra.services.resourceloading.internal.ui.expressions;x-internal:=true,
+ org.eclipse.papyrus.infra.services.resourceloading.internal.ui.preferences;x-internal:=true,
+ org.eclipse.papyrus.infra.services.resourceloading.internal.ui.strategy;x-internal:=true
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/META-INF/p2.inf b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/META-INF/p2.inf
new file mode 100644
index 00000000000..4af251b571a
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/META-INF/p2.inf
@@ -0,0 +1,5 @@
+# Inform p2 of the bundle renaming
+update.matchExp=providedCapabilities.exists(pc | \
+ pc.namespace == 'org.eclipse.equinox.p2.iu' \
+ && (pc.name == 'org.eclipse.papyrus.infra.services.resourceloading.preferences' \
+ || pc.name == 'org.eclipse.papyrus.infra.services.resourceloading.ui'))
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/about.html b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/about.html
new file mode 100644
index 00000000000..d35d5aed64c
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/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>June 5, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). 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, &quot;Program&quot; 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 (&quot;Redistributor&quot;) 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>
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/build.properties b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/build.properties
new file mode 100644
index 00000000000..f0b3f3014f2
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/build.properties
@@ -0,0 +1,12 @@
+#
+#Mon Sep 12 09:29:40 CEST 2011
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ about.html,\
+ plugin.properties,\
+ messages.properties
+output..=bin/
+src.includes = about.html
+source..=src/
+bin..=bin/
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/messages.properties b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/messages.properties
new file mode 100644
index 00000000000..0c9dafc12ec
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/messages.properties
@@ -0,0 +1,6 @@
+LoadedAssociatedResourceGroup_0=Automatically load the following associated resources
+LoadedAuthorizedResourceGroup_0=Automatically authorize the following resources
+LoadedAuthorizedResourceGroup_1=Select authorized elements
+LoadedAuthorizedResourceGroup_2=Select authorized elements
+LoadinStrategyGroup_0=Loading strategy :
+LoadinStrategyGroup_1=Select the loading strategy when model is opened
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/plugin.properties b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/plugin.properties
new file mode 100644
index 00000000000..38c652833f2
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/plugin.properties
@@ -0,0 +1,15 @@
+#/*****************************************************************************
+# * Copyright (c) 2010 Atos Origin.
+# *
+# *
+# * All rights reserved. This program and the accompanying materials
+# * are made available under the terms of the Eclipse Public License v1.0
+# * which accompanies this distribution, and is available at
+# * http://www.eclipse.org/legal/epl-v10.html
+# *
+# * Contributors:
+# * Emilien Perico emilien.perico@atosorigin.com - Initial API and implementation
+# *
+# *****************************************************************************/
+pluginName=Preferences for resource loading feature
+providerName=Eclipse Modeling Project \ No newline at end of file
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/plugin.xml b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/plugin.xml
new file mode 100644
index 00000000000..9e41302230d
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/plugin.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.core.runtime.preferences">
+ <initializer
+ class="org.eclipse.papyrus.infra.services.resourceloading.internal.ui.preferences.CorePreferenceInitializer">
+ </initializer>
+ </extension>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ category="org.eclipse.papyrus.infra.core.sasheditor.preferences.generalcategory"
+ class="org.eclipse.papyrus.infra.services.resourceloading.internal.ui.preferences.LoadingStrategyPreferencePage"
+ id="org.eclipse.papyrus.infra.services.resourceloading.ui.ModelLoadingPreferencePage"
+ name="Model loading">
+ </page>
+ </extension>
+ <extension
+ point="org.eclipse.ui.propertyPages">
+ <page
+ category="org.eclipse.papyrus.infra.gmfdiag.preferences.properties.generalcategory"
+ class="org.eclipse.papyrus.infra.services.resourceloading.internal.ui.preferences.LoadingStrategyPreferencePage"
+ id="org.eclipse.papyrus.infra.services.resourceloading.properties.ModelLoadingPreferencePage2"
+ name="Model loading">
+ <enabledWhen>
+ <adapt
+ type="org.eclipse.core.resources.IProject">
+ </adapt>
+ </enabledWhen>
+ </page>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.infra.services.resourceloading.currentStrategyChooser">
+ <CurrentStrategyChooser
+ chooser="org.eclipse.papyrus.infra.services.resourceloading.internal.ui.strategy.StrategyChooser">
+ </CurrentStrategyChooser>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.infra.services.resourceloading.loadingStrategyExtender">
+ <strategyExtender
+ description="User preference resource loading strategy extender"
+ strategyExtension="org.eclipse.papyrus.infra.services.resourceloading.internal.ui.strategy.PreferenceLoadingStrategyExtension">
+ </strategyExtender>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.infra.ui.papyrusDiagram">
+ <editorDiagram
+ factoryClass="org.eclipse.papyrus.infra.services.resourceloading.internal.ui.editor.UnloadResourcesEditorFactory">
+ </editorDiagram>
+ </extension>
+ <extension
+ point="org.eclipse.papyrus.infra.services.resourceloading.loadingStrategy">
+ <loadingStrategy
+ description="Ask the user if a resource has to be loaded"
+ id="3"
+ strategy="org.eclipse.papyrus.infra.services.resourceloading.internal.ui.strategy.AskUserStrategy">
+ </loadingStrategy>
+ </extension>
+ <extension
+ point="org.eclipse.core.expressions.propertyTesters">
+ <!-- the property tester is used to enable/disable handlers for loading/unloading a resource -->
+ <propertyTester
+ class="org.eclipse.papyrus.infra.services.resourceloading.internal.ui.expressions.LoadingTester"
+ id="org.eclipse.papyrus.infra.core.resourceloading.tester"
+ namespace="org.eclipse.papyrus.infra.core.resourceloading.tester"
+ properties="isAllLoaded, isAllNotLoaded"
+ type="org.eclipse.jface.viewers.IStructuredSelection">
+ </propertyTester>
+ </extension>
+</plugin>
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/pom.xml b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/pom.xml
new file mode 100644
index 00000000000..1d40d989c48
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/pom.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>org.eclipse.papyrus.infra-services</artifactId>
+ <groupId>org.eclipse.papyrus</groupId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>org.eclipse.papyrus.infra.services.resourceloading.ui</artifactId>
+ <version>1.2.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+</project>
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/UIPlugin.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/UIPlugin.java
new file mode 100644
index 00000000000..91d892f23fc
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/UIPlugin.java
@@ -0,0 +1,67 @@
+/*****************************************************************************
+ * Copyright (c) 2010, 2016 Atos Origin, 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:
+ * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
+ * Christian W. Damus - bug 485220
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.resourceloading.internal.ui;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class UIPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.papyrus.infra.services.resourceloading.ui"; //$NON-NLS-1$
+
+ // The shared instance
+ private static UIPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public UIPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static UIPlugin getDefault() {
+ return plugin;
+ }
+
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/editor/UnloadResourcesEditorFactory.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/editor/UnloadResourcesEditorFactory.java
new file mode 100644
index 00000000000..bdbef4b1548
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/editor/UnloadResourcesEditorFactory.java
@@ -0,0 +1,44 @@
+package org.eclipse.papyrus.infra.services.resourceloading.internal.ui.editor;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.xml.type.AnyType;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel;
+import org.eclipse.papyrus.infra.core.services.ServicesRegistry;
+import org.eclipse.papyrus.infra.ui.extension.diagrameditor.EditorDescriptor;
+import org.eclipse.papyrus.infra.ui.extension.diagrameditor.IPluggableEditorFactory;
+
+
+public class UnloadResourcesEditorFactory implements IPluggableEditorFactory {
+
+ private EditorDescriptor editorDescriptor;
+
+ private ServicesRegistry serviceRegistry;
+
+ public IPageModel createIPageModel(Object pageIdentifier) {
+ URI uri = null;
+ if (pageIdentifier instanceof InternalEObject) {
+ InternalEObject internal = (InternalEObject) pageIdentifier;
+ uri = internal.eProxyURI();
+ }
+ return new UnloadResourcesEditorModel(uri);
+ }
+
+ public boolean isPageModelFactoryFor(Object pageIdentifier) {
+ boolean result = false;
+ // AnyType is a Proxy, but it is already handled by another EditorFactory.
+ // Ignore it to avoid conflicts
+ if (pageIdentifier instanceof EObject && !(pageIdentifier instanceof AnyType)) {
+ EObject eObjectPageIdentifier = (EObject) pageIdentifier;
+ result = eObjectPageIdentifier.eIsProxy();
+ }
+ return result;
+ }
+
+ public void init(ServicesRegistry serviceRegistry, EditorDescriptor editorDescriptor) {
+ this.editorDescriptor = editorDescriptor;
+ this.serviceRegistry = serviceRegistry;
+ }
+
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/editor/UnloadResourcesEditorModel.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/editor/UnloadResourcesEditorModel.java
new file mode 100644
index 00000000000..6a1cdc34ca1
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/editor/UnloadResourcesEditorModel.java
@@ -0,0 +1,168 @@
+/*****************************************************************************
+ * Copyright (c) 2010 Atos Origin, CEA, 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:
+ *
+ * Atos Origin - Initial API and implementation
+ * Christian W. Damus (CEA) - bug 392301
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.resourceloading.internal.ui.editor;
+
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel;
+import org.eclipse.papyrus.infra.widgets.toolbox.notification.builders.NotificationBuilder;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.EditorActionBarContributor;
+import org.eclipse.ui.part.EditorPart;
+
+
+/**
+ * A simple model that can be used as editor in tests.
+ *
+ * @author cedric dumoulin
+ *
+ */
+public class UnloadResourcesEditorModel implements IEditorModel {
+
+
+ private String name;
+
+ private final URI uri;
+
+ public UnloadResourcesEditorModel(URI uri) {
+ this.uri = uri;
+ name = "Unresolved tab";
+ }
+
+ public void dispose() {
+ // Pass. The tab icon is a workbench-shared image
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel#getTabTitle()
+ *
+ * @return
+ */
+ public String getTabTitle() {
+ return name;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel#getTabIcon()
+ *
+ * @return
+ */
+ public Image getTabIcon() {
+ return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_INFO_TSK);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IPageModel#getRawModel()
+ *
+ * @return
+ */
+ public Object getRawModel() {
+ // TODO Auto-generated method stub
+ return this;
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel#createIEditorPart()
+ *
+ * @return
+ * @throws PartInitException
+ */
+ public IEditorPart createIEditorPart() throws PartInitException {
+ return new UnloadResourcesEditorPart(uri);
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IEditorModel#getActionBarContributor()
+ *
+ * @return
+ */
+ public EditorActionBarContributor getActionBarContributor() {
+ return null;
+ }
+
+ /**
+ * A class implementing a fake editor.
+ *
+ * @author dumoulin
+ *
+ */
+ public static class UnloadResourcesEditorPart extends EditorPart {
+
+ private final URI unloadedUri;
+
+ public UnloadResourcesEditorPart(URI uri) {
+ unloadedUri = uri;
+ }
+
+ @Override
+ public void doSave(IProgressMonitor monitor) {
+ }
+
+ @Override
+ public void doSaveAs() {
+ }
+
+ @Override
+ public void init(IEditorSite site, IEditorInput input) throws PartInitException {
+ setSite(site);
+ setInput(input);
+ setPartName(input.getName());
+ }
+
+ @Override
+ public boolean isDirty() {
+ return false;
+ }
+
+ @Override
+ public boolean isSaveAsAllowed() {
+ return false;
+ }
+
+ @Override
+ public void createPartControl(Composite parent) {
+ Composite compo = new Composite(parent, SWT.NONE);
+ compo.setLayout(new GridLayout(2, false));
+ Image image = NotificationBuilder.getSWTImage(SWT.ICON_INFORMATION, parent.getShell());
+ Label label = new Label(compo, SWT.NONE);
+ label.setImage(image);
+ label.setLayoutData(new GridData(SWT.CENTER, SWT.TOP, false, false));
+ Text t = new Text(compo, SWT.None);
+ t.setText("This diagram is contained in an unresolved resource : " + URI.decode(unloadedUri.trimFragment().toString()));
+ t.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ t.setEditable(false);
+ label.setBackground(t.getBackground());
+ compo.setBackground(t.getBackground());
+ }
+
+ @Override
+ public void setFocus() {
+ }
+
+ }
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/expressions/LoadingTester.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/expressions/LoadingTester.java
new file mode 100644
index 00000000000..12501ebb521
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/expressions/LoadingTester.java
@@ -0,0 +1,154 @@
+/*****************************************************************************
+ * Copyright (c) 2011, 2016 Atos, 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:
+ * Vincent Hemery (Atos) vincent.hemery@atos.net - Initial API and implementation
+ * Christian W. Damus - bug 485220
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.resourceloading.internal.ui.expressions;
+
+import java.util.Iterator;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.transaction.util.TransactionUtil;
+import org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+
+/**
+ * This class provides test to perform on resources to know their loading
+ * status.
+ */
+public class LoadingTester extends PropertyTester {
+
+ /**
+ * property to test if the selected elements are in loaded resources (at
+ * least one other than the opened one)
+ */
+ public static final String IS_ALL_LOADED = "isAllLoaded"; //$NON-NLS-1$
+
+ /** property to test if the selected elements are in not loaded resources */
+ public static final String IS_ALL_NOTLOADED = "isAllNotLoaded"; //$NON-NLS-1$
+
+ /**
+ * Test a property
+ *
+ * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
+ *
+ * @param receiver
+ * @param property
+ * @param args
+ * @param expectedValue
+ * @return
+ */
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if (IS_ALL_LOADED.equals(property) && receiver instanceof IStructuredSelection) {
+ boolean answer = isInLoadedResource((IStructuredSelection) receiver);
+ return new Boolean(answer).equals(expectedValue);
+ }
+ if (IS_ALL_NOTLOADED.equals(property) && receiver instanceof IStructuredSelection) {
+ boolean answer = isInNotLoadedResource((IStructuredSelection) receiver);
+ return new Boolean(answer).equals(expectedValue);
+ }
+ return false;
+ }
+
+ /**
+ * Tests the selection in order to know if it is in a loaded resource
+ *
+ * @param selection
+ * selected elements
+ * @return <code>true</code> if all selected elements are in loaded
+ * resources ; <code>false</code otherwise or if empty selection
+ */
+ private boolean isInLoadedResource(IStructuredSelection selection) {
+ if (!selection.isEmpty()) {
+ boolean atLeastOneInSubmodel = false;
+ URI mainURI = null;
+ Iterator<?> iter = selection.iterator();
+ while (iter.hasNext()) {
+ Object obj = iter.next();
+ EObject eObject = EMFHelper.getEObject(obj);
+ if (eObject != null && !eObject.eIsProxy()) {
+ // test that there is at least one not loaded resource
+ // object
+ if (!atLeastOneInSubmodel) {
+ Resource containingResource = eObject.eResource();
+ if (mainURI == null && containingResource != null && containingResource.getResourceSet() instanceof ModelSet) {
+ mainURI = ((ModelSet) containingResource.getResourceSet()).getURIWithoutExtension();
+ }
+ if (mainURI != null) {
+ URI uriTrim = containingResource.getURI().trimFileExtension();
+ atLeastOneInSubmodel = !uriTrim.equals(mainURI);
+ }
+ }
+ continue;
+ }
+
+ // a step failed
+ return false;
+ }
+ return atLeastOneInSubmodel;
+ }
+ return false;
+ }
+
+ /**
+ * Tests the selection in order to know if it is in a not loaded resource
+ *
+ * @param selection
+ * selected elements
+ * @return <code>true</code> if all selected elements are in not loaded
+ * resources ; <code>false</code otherwise or if empty selection
+ */
+ private boolean isInNotLoadedResource(IStructuredSelection selection) {
+ if (!selection.isEmpty()) {
+ Iterator<?> iter = selection.iterator();
+ while (iter.hasNext()) {
+ Object obj = iter.next();
+ EObject eObject = EMFHelper.getEObject(obj);
+ if (eObject != null && eObject.eIsProxy()) {
+ continue;
+ } else if (obj instanceof IAdaptable) {
+ View view = ((IAdaptable) obj).getAdapter(View.class);
+
+ if (view instanceof Edge) {
+ View target = ((Edge) view).getTarget();
+ if (target != null && resolveSemanticElement(target) == null) {
+ // there is a backslash decorator
+ continue;
+ }
+ }
+ }
+ // a step failed
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ private EObject resolveSemanticElement(View view) {
+ EObject result = view.getElement();
+
+ if ((result != null) && result.eIsProxy()) {
+ // Try harder to resolve it
+ result = EMFCoreUtil.resolve(TransactionUtil.getEditingDomain(view), result);
+ }
+
+ return result;
+ }
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/CorePreferenceInitializer.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/CorePreferenceInitializer.java
new file mode 100644
index 00000000000..ec6edbf881d
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/CorePreferenceInitializer.java
@@ -0,0 +1,52 @@
+/*****************************************************************************
+ * Copyright (c) 2010, 2016 Atos Origin, 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:
+ * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
+ * Christian W. Damus - bug 485220
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.resourceloading.internal.ui.preferences;
+
+import static org.eclipse.papyrus.infra.services.resourceloading.internal.ui.preferences.ICorePreferenceConstants.PREF_CORE_DEFINE_LOADING_STRATEGY;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.infra.services.resourceloading.internal.ui.UIPlugin;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+
+/**
+ * This preference initializer initializes diagram preferences specific to the
+ * activity diagram.
+ */
+public class CorePreferenceInitializer extends AbstractPreferenceInitializer {
+
+ /**
+ * Initialize default preferences
+ */
+ @Override
+ public void initializeDefaultPreferences() {
+ IPreferenceStore store = getPreferenceStore();
+ store.setDefault(PREF_CORE_DEFINE_LOADING_STRATEGY, 0);
+
+ // Migrate from the diagram bundle for upgrade from Papyrus 1.1 or earlier
+ IPreferenceStore legacy = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.papyrus.infra.gmfdiag.preferences"); //$NON-NLS-1$
+ if (legacy.contains(PREF_CORE_DEFINE_LOADING_STRATEGY)) {
+ store.setValue(PREF_CORE_DEFINE_LOADING_STRATEGY, legacy.getInt(PREF_CORE_DEFINE_LOADING_STRATEGY));
+ legacy.setToDefault(PREF_CORE_DEFINE_LOADING_STRATEGY); // Removes it because now it has no default
+ }
+ }
+
+ /**
+ * Get the preference store
+ */
+ protected IPreferenceStore getPreferenceStore() {
+ return UIPlugin.getDefault().getPreferenceStore();
+ }
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/ICorePreferenceConstants.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/ICorePreferenceConstants.java
new file mode 100644
index 00000000000..7cc3547579d
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/ICorePreferenceConstants.java
@@ -0,0 +1,27 @@
+/*****************************************************************************
+ * Copyright (c) 2010 Atos Origin.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.resourceloading.internal.ui.preferences;
+
+/**
+ * Defines specific preference constants for papyrus core.
+ *
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface ICorePreferenceConstants {
+
+ /**
+ * the preference to define the model loading strategy.
+ */
+ public static final String PREF_CORE_DEFINE_LOADING_STRATEGY = "org.eclipse.papyrus.infra.services.resourceloading.preferences.loadingStrategy"; //$NON-NLS-1$
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/LoadedAuthorizedResourceGroup.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/LoadedAuthorizedResourceGroup.java
new file mode 100644
index 00000000000..4f2b2ec3ca9
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/LoadedAuthorizedResourceGroup.java
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * Copyright (c) 2012 Atos.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Laurent Devernay (Atos) laurent.devernay@atos.net
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.resourceloading.internal.ui.preferences;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.papyrus.infra.services.resourceloading.internal.ui.strategy.LoadedAuthorizedResourceManager;
+import org.eclipse.papyrus.infra.ui.preferences.AbstractPreferenceGroup;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+public class LoadedAuthorizedResourceGroup extends AbstractPreferenceGroup {
+
+ public LoadedAuthorizedResourceGroup(Composite parent, String key, DialogPage dialogPage) {
+ super(parent, key, dialogPage);
+ createContent(parent);
+ }
+
+ public void createContent(Composite parent) {
+ Group group = new Group(parent, SWT.SCROLL_PAGE);
+ group.setLayout(new GridLayout());
+ group.setText(Messages.LoadedAuthorizedResourceGroup_0);
+
+ ResourcePreferencePathEditor pathEditor = new ResourcePreferencePathEditor(LoadedAuthorizedResourceManager.URI_PREF_PREFIX, Messages.LoadedAuthorizedResourceGroup_1, Messages.LoadedAuthorizedResourceGroup_2, group);
+
+ addFieldEditor(pathEditor);
+ }
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/LoadinStrategyGroup.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/LoadinStrategyGroup.java
new file mode 100644
index 00000000000..6a0f17954e0
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/LoadinStrategyGroup.java
@@ -0,0 +1,73 @@
+/*****************************************************************************
+ * Copyright (c) 2010 Atos Origin.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.resourceloading.internal.ui.preferences;
+
+import java.util.Map;
+
+import org.eclipse.jface.dialogs.DialogPage;
+import org.eclipse.jface.preference.RadioGroupFieldEditor;
+import org.eclipse.papyrus.infra.services.resourceloading.impl.ProxyManager;
+import org.eclipse.papyrus.infra.ui.preferences.AbstractPreferenceGroup;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+public class LoadinStrategyGroup extends AbstractPreferenceGroup {
+
+ private static final String LABEL_LOADING_STRATEGY = "Loading strategy :";
+
+ private static final String SELECT_LOADING_STRATEGY = "Select the loading strategy when model is opened";
+
+ private RadioGroupFieldEditor fStrategyRadio;
+
+ public LoadinStrategyGroup(Composite parent, String title, DialogPage dialogPage) {
+ super(parent, title, dialogPage);
+ createContent(parent);
+ }
+
+ public void createContent(Composite parent) {
+ Group group = new Group(parent, SWT.SCROLL_PAGE);
+ group.setLayout(new GridLayout());
+ group.setText(SELECT_LOADING_STRATEGY);
+ fStrategyRadio = createStrategyRadio(group);
+ addFieldEditor(fStrategyRadio);
+ }
+
+ private static RadioGroupFieldEditor createStrategyRadio(Group group) {
+ String[][] values = getValuesFromExtensionPoint();
+ RadioGroupFieldEditor radio = new RadioGroupFieldEditor(ICorePreferenceConstants.PREF_CORE_DEFINE_LOADING_STRATEGY, LABEL_LOADING_STRATEGY, 1, values, group);
+ return radio;
+ }
+
+ /**
+ * Gets the strategies value from extension point.
+ *
+ * @return the strategies value
+ */
+ private static String[][] getValuesFromExtensionPoint() {
+ Map<Integer, String> allStrategies = ProxyManager.getAllStrategies();
+ String[][] result = new String[allStrategies.size()][2];
+ int i = 0;
+ for (Integer val : allStrategies.keySet()) {
+ result[i][0] = allStrategies.get(val);
+ result[i][1] = String.valueOf(val);
+ i++;
+ }
+ return result;
+ }
+
+
+
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/LoadingStrategyPreferencePage.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/LoadingStrategyPreferencePage.java
new file mode 100644
index 00000000000..15fa16eea4d
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/LoadingStrategyPreferencePage.java
@@ -0,0 +1,94 @@
+/*****************************************************************************
+ * Copyright (c) 2010 Atos Origin.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.resourceloading.internal.ui.preferences;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.infra.services.resourceloading.Activator;
+import org.eclipse.papyrus.infra.services.resourceloading.internal.ui.UIPlugin;
+import org.eclipse.papyrus.infra.services.resourceloading.internal.ui.strategy.StrategyChooser;
+import org.eclipse.papyrus.infra.ui.preferences.AbstractPapyrusPreferencePage;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+
+public class LoadingStrategyPreferencePage extends AbstractPapyrusPreferencePage {
+
+ private LoadinStrategyGroup groupComposite;
+
+ private IProject project;
+
+ /**
+ * @generated
+ */
+ @Override
+ protected String getBundleId() {
+ return UIPlugin.PLUGIN_ID;
+ }
+
+ /**
+ * @generated
+ */
+ public static void initDefaults(IPreferenceStore store) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void createPageContents(Composite parent) {
+ groupComposite = new LoadinStrategyGroup(parent, getTitle(), this);
+ addPreferenceGroup(groupComposite);
+ LoadedAuthorizedResourceGroup loadedAuthorizedResourceGroup = new LoadedAuthorizedResourceGroup(parent, getTitle(), this);
+ addPreferenceGroup(loadedAuthorizedResourceGroup);
+ // TODO : if no value is set for the radio buttons (loading strategy) on
+ // a project, use the workspace loading strategy.
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean performOk() {
+ boolean result = super.performOk();
+ StrategyChooser.setCurrentStrategy(doGetPreferenceStore().getInt(ICorePreferenceConstants.PREF_CORE_DEFINE_LOADING_STRATEGY));
+ IPreferenceStore modifiedPrefStore = doGetPreferenceStore();
+ try {
+ if (modifiedPrefStore instanceof ScopedPreferenceStore) {
+ ((ScopedPreferenceStore) modifiedPrefStore).save();
+ }
+ } catch (Exception e) {
+ Activator.logError(e);
+ }
+
+ return result;
+ }
+
+ /**
+ * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
+ */
+ @Override
+ public IAdaptable getElement() {
+ return project;
+ }
+
+ /**
+ * @see org.eclipse.ui.IWorkbenchPropertyPage#setElement(org.eclipse.core.runtime.IAdaptable)
+ */
+ @Override
+ public void setElement(IAdaptable element) {
+ project = (IProject) element.getAdapter(IResource.class);
+ }
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/Messages.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/Messages.java
new file mode 100644
index 00000000000..40119003ffd
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/Messages.java
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * Copyright (c) 2012 Atos.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Laurent Devernay (Atos) laurent.devernay@atos.net
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.resourceloading.internal.ui.preferences;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+
+ private static final String BUNDLE_NAME = "messages"; //$NON-NLS-1$
+
+ public static String LoadedAssociatedResourceGroup_0;
+
+ public static String LoadedAuthorizedResourceGroup_0;
+
+ public static String LoadedAuthorizedResourceGroup_1;
+
+ public static String LoadedAuthorizedResourceGroup_2;
+
+ public static String LoadinStrategyGroup_0;
+
+ public static String LoadinStrategyGroup_1;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/ResourcePreferencePathEditor.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/ResourcePreferencePathEditor.java
new file mode 100644
index 00000000000..97e655b2435
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/preferences/ResourcePreferencePathEditor.java
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * Copyright (c) 2012 Atos.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Laurent Devernay (Atos) laurent.devernay@atos.net
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.resourceloading.internal.ui.preferences;
+
+import org.eclipse.emf.common.ui.dialogs.ResourceDialog;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jface.preference.PathEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+public class ResourcePreferencePathEditor extends PathEditor {
+
+ public ResourcePreferencePathEditor() {
+ super();
+ }
+
+ public ResourcePreferencePathEditor(String name, String labelText, String dirChooserLabelText, Composite parent) {
+ super(name, labelText, dirChooserLabelText, parent);
+ }
+
+ @Override
+ protected String getNewInputObject() {
+ String labelText = getLabelText();
+ ResourceDialog dialog = new ResourceDialog(getShell(), labelText, SWT.OPEN | SWT.SINGLE);
+ dialog.open();
+ String uriTexte = dialog.getURIText();
+ URI uri = URI.createURI(uriTexte);
+ return uri.trimFileExtension().toString();
+ }
+
+ @Override
+ protected void doLoad() {
+ if (getList() != null) {
+ getList().removeAll();
+ }
+ super.doLoad();
+ }
+
+ @Override
+ protected void doLoadDefault() {
+ if (getList() != null) {
+ getList().removeAll();
+ }
+ super.doLoadDefault();
+ }
+
+
+
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/strategy/AskUserStrategy.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/strategy/AskUserStrategy.java
new file mode 100644
index 00000000000..4c2e00f2940
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/strategy/AskUserStrategy.java
@@ -0,0 +1,849 @@
+/*****************************************************************************
+ * Copyright (c) 2010, 2013 ATOS ORIGIN, 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:
+ * Tristan Faure (ATOS ORIGIN INTEGRATION) tristan.faure@atosorigin.com - Initial API and implementation
+ * Christian W. Damus (CEA) - manage models by URI, not IFile (CDO)
+ * Christian W. Damus (CEA LIST) - support control mode in CDO resources
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.resourceloading.internal.ui.strategy;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+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.EcoreUtil;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.sashwindows.di.service.IPageManager;
+import org.eclipse.papyrus.infra.core.services.ServiceException;
+import org.eclipse.papyrus.infra.services.resourceloading.ILoadingStrategy;
+import org.eclipse.papyrus.infra.services.resourceloading.strategies.Messages;
+import org.eclipse.papyrus.infra.ui.editor.IMultiDiagramEditor;
+import org.eclipse.papyrus.infra.widgets.toolbox.notification.INotification;
+import org.eclipse.papyrus.infra.widgets.toolbox.notification.NotificationRunnable;
+import org.eclipse.papyrus.infra.widgets.toolbox.notification.Type;
+import org.eclipse.papyrus.infra.widgets.toolbox.notification.builders.IContext;
+import org.eclipse.papyrus.infra.widgets.toolbox.notification.builders.NotificationBuilder;
+import org.eclipse.swt.SWT;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.IPerspectiveDescriptor;
+import org.eclipse.ui.IPerspectiveListener;
+import org.eclipse.ui.IWindowListener;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * The strategy which ask user if the resource has to be loaded or not
+ *
+ * @author tfaure
+ *
+ */
+public class AskUserStrategy implements ILoadingStrategy {
+
+ /**
+ * the uris linked to the uri of an editor already guessed to the user
+ */
+ private Map<URI, Set<URI>> alreadyGuessed = new HashMap<URI, Set<URI>>();
+
+ /**
+ * the uris linked to the uri of an editor already authorized
+ */
+ Map<URI, Set<URI>> authorized = new HashMap<URI, Set<URI>>();
+
+ /**
+ * The extensions needed to load for each resource
+ */
+ Map<URI, Map<URI, Set<String>>> mappingURIExtensions = new HashMap<URI, Map<URI, Set<String>>>();
+
+ /**
+ * Listeners triggered when the editors are closed
+ */
+ Map<URI, EditorCloseListener> listeners = new HashMap<URI, AskUserStrategy.EditorCloseListener>();
+
+ /**
+ * All the notifications created for each editor
+ */
+ Map<URI, List<INotification>> notifications = new HashMap<URI, List<INotification>>();
+
+ /**
+ * Constant URI for Yes For All Option
+ */
+ public static final URI YesForAllURI = URI.createURI(Messages.AskUserStrategy_YES_FOR_ALL_URI);
+
+ /**
+ * Constant URI for No For All Option
+ */
+ private static final URI NoForAllURI = URI.createURI(Messages.AskUserStrategy_NO_FOR_ALL_URI);
+
+ /**
+ * @see org.eclipse.papyrus.infra.services.resourceloading.ILoadingStrategy#loadResource(org.eclipse.papyrus.infra.core.resource.ModelSet, org.eclipse.emf.common.util.URI)
+ *
+ * @param modelSet
+ * @param uri
+ * @return
+ */
+ public boolean loadResource(ModelSet modelSet, URI uri) {
+ // pathmap resource are always loaded
+ boolean result = !modelSet.isUserModelResource(uri);
+ URI initialURI = modelSet.getURIWithoutExtension();
+ // if no listener is registered, a listener is added on the editor to remove the notifications
+ // when the editor is closed the listener removes too the choices made by the user.
+ addClosingEditorListener(initialURI);
+
+ // all the verification are made with the uri without the file extension
+ // each load is performed for a set of resources
+ URI trimFileExtensionAndFragment = uri.trimFragment().trimFileExtension();
+ if (!result) {
+ result = initialURI.equals(trimFileExtensionAndFragment);
+ }
+ if (!result) {
+ manageExtensions(initialURI, uri);
+ Set<URI> uris = authorized.get(initialURI);
+ if (uris != null && (uris.contains(YesForAllURI) || uris.contains(trimFileExtensionAndFragment))) {
+ result = true;
+ }
+ if (uris != null && (uris.contains(NoForAllURI))) {
+ // in this case always false !
+ return false;
+ }
+ if (!result) {
+ manageGuess(modelSet, initialURI, trimFileExtensionAndFragment);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Create the ask notification to the user
+ *
+ * @param modelSet
+ * @param initialURI
+ * @param trimFragment
+ */
+ protected void manageGuess(ModelSet modelSet, URI initialURI, URI trimFragment) {
+ if (!alreadyGuessed(initialURI, trimFragment) && !alreadyGuessed(initialURI, YesForAllURI) && !alreadyGuessed(initialURI, NoForAllURI)) {
+ String message = new StringBuffer(Messages.AskUserStrategy_MESSAGE_PART_1).append(initialURI.lastSegment()).append(Messages.AskUserStrategy_MESSAGE_PART_2).append(trimFragment.toString()).append(Messages.AskUserStrategy_MESSAGE_PART3).toString();
+ addGuessed(initialURI, trimFragment);
+ NotificationBuilder builder = getNotification(message, trimFragment, modelSet, initialURI);
+ INotification notification = builder.run();
+ addNotification(initialURI, new EncapsulatedNotification(notification, trimFragment));
+ // notification
+ }
+ }
+
+ /**
+ * Add a listener closing the uri parameter
+ *
+ * @param initialURI
+ */
+ private void addClosingEditorListener(URI initialURI) {
+ if (!listeners.containsKey(initialURI)) {
+ EditorCloseListener value = new EditorCloseListener();
+ if (addPageListener(value)) {
+ listeners.put(initialURI, value);
+ }
+ }
+ }
+
+ /**
+ * Remember that an uri has already be asked
+ *
+ * @param initialURI
+ * , the uri opened by the editor
+ * @param guessed
+ */
+ private void addGuessed(URI initialURI, URI guessed) {
+ Set<URI> set = alreadyGuessed.get(initialURI);
+ if (set == null) {
+ set = new HashSet<URI>();
+ alreadyGuessed.put(initialURI, set);
+ }
+ set.add(guessed);
+ }
+
+ /**
+ * Check if the uri is already asked
+ *
+ * @param initialURI
+ * , the uri opened by the editor
+ * @param toLoad
+ * , the uri to load
+ * @return
+ */
+ private boolean alreadyGuessed(URI initialURI, URI toLoad) {
+ Set<URI> guessed = alreadyGuessed.get(initialURI);
+ if (guessed != null) {
+ return guessed.contains(toLoad);
+ }
+ return false;
+ }
+
+ /**
+ * The extensions are saved to load all the specified resource if the user
+ * wants to load a set of resources
+ *
+ * @param uri
+ * , the file to load
+ * @param trimFragment
+ */
+ private void manageExtensions(URI initialURI, URI toLoad) {
+ Map<URI, Set<String>> map = mappingURIExtensions.get(initialURI);
+ if (map == null) {
+ map = new HashMap<URI, Set<String>>();
+ mappingURIExtensions.put(initialURI, map);
+ }
+ Set<String> extensions = map.get(toLoad.trimFileExtension());
+ if (extensions == null) {
+ extensions = new HashSet<String>();
+ map.put(toLoad.trimFileExtension(), extensions);
+ }
+ extensions.add(toLoad.fileExtension());
+ }
+
+ /**
+ * Get the current editor
+ *
+ * @return
+ */
+ protected IMultiDiagramEditor getCurrentEditor() {
+ IEditorPart editor = getEditor();
+ if (editor instanceof IMultiDiagramEditor) {
+ return (IMultiDiagramEditor) editor;
+ }
+ return null;
+ }
+
+ /**
+ * Create the notification with Yes/No/Yes For All/No For All option
+ *
+ * @param message
+ * , the message to display
+ * @param uri
+ * , the uri to load
+ * @param modelSet
+ * , the model set of the editor
+ * @param initialURI
+ * , the uri opened by the editor
+ * @return a {@link NotificationBuilder} to build
+ */
+ protected NotificationBuilder getNotification(String message, final URI uri, final ModelSet modelSet, final URI initialURI) {
+ NotificationRunnable yes = getYesRunnable(uri, modelSet, initialURI);
+ NotificationRunnable no = getNoRunnable(uri, modelSet, initialURI);
+ NotificationRunnable yesForAll = getYesForAllRunnable(uri, modelSet, initialURI);
+ NotificationRunnable noForAll = getNoForAllRunnable(uri, modelSet, initialURI);
+ return new NotificationBuilder().setType(Type.QUESTION).setAsynchronous(true).setTemporary(false).setMessage(message).setHTML(true).setAsynchronous(true).setTitle(Messages.AskUserStrategy_LOAD_RESOURCE + uri.toString()).addAction(yes).addAction(no)
+ .addAction(yesForAll).addAction(noForAll);
+ }
+
+ /**
+ * NO for all registers the NoForAll URI and do nothing
+ *
+ * @param uri
+ * @param modelSet
+ * @param initialURI
+ * @return
+ */
+ protected LoadAndRefreshRunnable getNoForAllRunnable(final URI uri, final ModelSet modelSet, final URI initialURI) {
+ return new LoadAndRefreshRunnable(initialURI, uri, modelSet, Messages.AskUserStrategy_NO_FOR_ALL) {
+
+ @Override
+ public void run(IContext context) {
+ addGuessed(getInitialURI(), NoForAllURI);
+ super.run(context);
+ }
+
+ @Override
+ protected void manageRefresh(IEditorReference ref, IEditorPart part) {
+ addAuthorized(getInitialURI(), NoForAllURI);
+
+ List<INotification> list = notifications.get(getInitialURI());
+ if (list != null) {
+ for (INotification n : notifications.get(getInitialURI())) {
+ if (n != getNotification()) {
+ n.delete();
+ }
+ }
+ }
+ // DO NOTHING
+ }
+
+ @Override
+ public int getActionValue() {
+ return SWT.NO;
+ }
+ };
+ }
+
+ /**
+ * Yes for All registers Yes For All URI and refresh the tabs to take in account the loaded elements
+ *
+ * @param uri
+ * @param modelSet
+ * @param initialURI
+ * @return
+ */
+ protected LoadAndRefreshRunnable getYesForAllRunnable(final URI uri, final ModelSet modelSet, final URI initialURI) {
+ return new LoadAndRefreshRunnable(initialURI, uri, modelSet, Messages.AskUserStrategy_0) {
+
+ @Override
+ public void run(IContext context) {
+ addGuessed(getInitialURI(), YesForAllURI);
+ super.run(context);
+ }
+
+ @Override
+ RefreshRunnable getRunnable() {
+ return new RefreshRunnable(modelSet, uri, initialURI, true, true) {
+
+ @Override
+ public void run(IMultiDiagramEditor editor) {
+ List<INotification> list = notifications.get(getInitialURI());
+ if (list != null) {
+ for (INotification n : notifications.get(getInitialURI())) {
+ if (n instanceof EncapsulatedNotification) {
+ EncapsulatedNotification encapsulated = (EncapsulatedNotification) n;
+ new RefreshRunnable(modelSet, encapsulated.getURIToLoad(), getInitialURI(), false, false).run(editor);
+ }
+ }
+ }
+ new RefreshRunnable(modelSet, null, getInitialURI(), true, true).run(editor);
+ }
+ };
+
+ }
+
+ @Override
+ protected void manageRefresh(IEditorReference ref, IEditorPart part) {
+ addAuthorized(getInitialURI(), YesForAllURI);
+ INotification currentNotification = getNotification();
+ List<INotification> list = notifications.get(getInitialURI());
+ if (list != null) {
+ for (INotification n : notifications.get(getInitialURI())) {
+ if (n != currentNotification) {
+ n.delete();
+ }
+ }
+ }
+ super.manageRefresh(ref, part);
+ }
+
+ @Override
+ public int getActionValue() {
+ return SWT.YES;
+ }
+ };
+ }
+
+ /**
+ * No runnable does not accept the URI asked
+ *
+ * @param uri
+ * @param modelSet
+ * @param initialURI
+ * @return
+ */
+ protected LoadAndRefreshRunnable getNoRunnable(final URI uri, final ModelSet modelSet, final URI initialURI) {
+ return new LoadAndRefreshRunnable(initialURI, uri, modelSet, Messages.AskUserStrategy_NO) {
+
+ @Override
+ protected void manageRefresh(IEditorReference ref, IEditorPart part) {
+ // DO NOTHING
+ // inheritance for close listener
+ }
+
+ @Override
+ public int getActionValue() {
+ return SWT.NO;
+ }
+ };
+ }
+
+ /**
+ * Yes registers the URI and refresh the tab to take in account the loaded elements
+ *
+ * @param uri
+ * @param modelSet
+ * @param initialURI
+ * @return
+ */
+ protected LoadAndRefreshRunnable getYesRunnable(final URI uri, final ModelSet modelSet, final URI initialURI) {
+ return new LoadAndRefreshRunnable(initialURI, uri, modelSet, Messages.AskUserStrategy_YES);
+ }
+
+ /**
+ * Register the notification created to the URI open by the editor
+ *
+ * @param initialURI
+ * @param notification
+ */
+ protected void addNotification(URI initialURI, INotification notification) {
+ List<INotification> notifs = notifications.get(initialURI);
+ if (notifs == null) {
+ notifs = new LinkedList<INotification>();
+ notifications.put(initialURI, notifs);
+ }
+ notifs.add(notification);
+ }
+
+ protected IEditorPart getEditor() {
+ IWorkbenchWindow activeWorkbenchWindow = getActiveWorkbenchWindow();
+ if (activeWorkbenchWindow != null) {
+ IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
+ if (activePage != null) {
+ return activePage.getActiveEditor();
+ }
+ }
+ return null;
+ }
+
+ protected IWorkbenchWindow getActiveWorkbenchWindow() {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ if (workbench != null) {
+ return workbench.getActiveWorkbenchWindow();
+ }
+ return null;
+ }
+
+ protected IWorkbenchPage getActivePage() {
+ IWorkbenchWindow activeWorkbenchWindow = getActiveWorkbenchWindow();
+ if (activeWorkbenchWindow != null) {
+ return activeWorkbenchWindow.getActivePage();
+ }
+ return null;
+ }
+
+ /**
+ * A basic runnable managing the load of a resource and a refresh of the tabs
+ * If the editor is not opened or activated some listeners will be triggered to launch the refresh
+ *
+ * @author tfaure
+ *
+ */
+ private class LoadAndRefreshRunnable implements NotificationRunnable {
+
+ protected URI initialURI;
+
+ protected URI uri;
+
+ protected ModelSet modelSet;
+
+ protected final String label;
+
+ protected IContext theContext;
+
+ public LoadAndRefreshRunnable(URI initialURI, URI uri, ModelSet modelSet, String label) {
+ this(initialURI, uri, modelSet, label, false);
+ }
+
+ public LoadAndRefreshRunnable(URI initialURI, URI uri, ModelSet modelSet, String label, boolean refreshAll) {
+ this.initialURI = initialURI;
+ this.uri = uri;
+ this.modelSet = modelSet;
+ this.label = label;
+ }
+
+ public URI getInitialURI() {
+ return initialURI;
+ }
+
+ public void run(IContext context) {
+ context.put(IContext.ACTION_ID, getActionValue());
+ theContext = context;
+ IWorkbenchPage activePage = getActivePage();
+ if (activePage != null) {
+ // search the editor which opened the given URI
+ for (IEditorReference ref : activePage.getEditorReferences()) {
+ try {
+ URI uri = getURI(ref.getEditorInput());
+ if ((uri != null) && uri.trimFileExtension().equals(initialURI)) {
+ IEditorPart part = (IEditorPart) ref.getPart(false);
+ manageRefresh(ref, part);
+ // add the uris to load in authorized list
+ }
+ } catch (PartInitException e) {
+ e.printStackTrace();
+ }
+ }
+ } else {
+ PlatformUI.getWorkbench().addWindowListener(new IWindowListener() {
+
+ public void windowOpened(IWorkbenchWindow window) {
+ }
+
+ public void windowDeactivated(IWorkbenchWindow window) {
+ }
+
+ public void windowClosed(IWorkbenchWindow window) {
+ }
+
+ public void windowActivated(IWorkbenchWindow window) {
+ if (window.getActivePage() != null) {
+ run(new IContext.Context());
+ PlatformUI.getWorkbench().removeWindowListener(this);
+ }
+ }
+ });
+ }
+ }
+
+ public int getActionValue() {
+ return SWT.YES;
+ }
+
+ public INotification getNotification() {
+ return new EncapsulatedNotification((INotification) theContext.get(IContext.NOTIFICATION_OBJECT), uri);
+ }
+
+ protected void manageRefresh(IEditorReference ref, IEditorPart part) {
+ addAuthorized(initialURI, uri);
+ if (part != null) {
+ getRunnable().run((IMultiDiagramEditor) part);
+ } else {
+ addPageListener(new EditorActivateListener(ref, modelSet, uri, initialURI, getRunnable()));
+ }
+ }
+
+ RefreshRunnable getRunnable() {
+ return new RefreshRunnable(modelSet, uri, initialURI, false, true);
+
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ }
+
+ /**
+ * Add a page listener
+ *
+ * @param listener
+ * @return
+ */
+ protected boolean addPageListener(IPartListener listener) {
+ IWorkbenchPage page = getActivePage();
+ if (page != null) {
+ page.addPartListener(listener);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Register a listener of the perspective to know when the editor is finally closed
+ *
+ * @param listener
+ * @return
+ */
+ protected boolean addPerspectiveListener(IPerspectiveListener listener) {
+ if (PlatformUI.getWorkbench() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().addPerspectiveListener(listener);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Unregister a perspective listener
+ *
+ * @param listener
+ * @return
+ */
+ protected void removePerspectiveListener(IPerspectiveListener listener) {
+ if (PlatformUI.getWorkbench() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().removePerspectiveListener(listener);
+ }
+ }
+
+ protected void removePageListener(IPartListener listener) {
+ IWorkbenchPage page = getActivePage();
+ if (page != null) {
+ page.removePartListener(listener);
+ }
+ }
+
+ protected void addAuthorized(URI initial, URI toAutorized) {
+ Set<URI> uris = authorized.get(initial);
+ if (uris == null) {
+ uris = new HashSet<URI>();
+ authorized.put(initial, uris);
+ }
+ uris.add(toAutorized);
+ }
+
+ protected static URI getURI(final IEditorInput input) {
+ URI result;
+
+ IFile file = (IFile) input.getAdapter(IFile.class);
+ if ((file != null) && (file.getFullPath() != null)) {
+ result = URI.createPlatformResourceURI(file.getFullPath().removeFileExtension().toString(), true);
+ } else {
+ result = (URI) input.getAdapter(URI.class);
+ }
+
+ return result;
+ }
+
+ /**
+ * Notification containing the {@link URI} loaded
+ *
+ */
+ public class EncapsulatedNotification implements INotification {
+
+ private final INotification notification;
+
+ private final URI uri;
+
+ public EncapsulatedNotification(INotification notification, URI uri) {
+ this.notification = notification;
+ this.uri = uri;
+ }
+
+ public void delete() {
+ this.notification.delete();
+ }
+
+ public boolean isDeleted() {
+ return this.notification.isDeleted();
+ }
+
+ public URI getURIToLoad() {
+ return uri;
+ }
+ }
+
+ /**
+ * An empty {@link IPartListener} implementation
+ *
+ * @author tfaure
+ *
+ */
+ private class EditorAdapter implements IPartListener {
+
+ public void partActivated(IWorkbenchPart part) {
+ }
+
+ public void partBroughtToTop(IWorkbenchPart part) {
+ }
+
+ public void partClosed(IWorkbenchPart part) {
+ }
+
+ public void partDeactivated(IWorkbenchPart part) {
+ }
+
+ public void partOpened(IWorkbenchPart part) {
+ }
+
+ }
+
+ /**
+ * Listener which is notifid when an editor is activated
+ *
+ * @author tfaure
+ *
+ */
+ private class EditorActivateListener extends EditorAdapter {
+
+ private final IEditorReference reference;
+
+ private final RefreshRunnable refreshRunnable;
+
+ public EditorActivateListener(IEditorReference reference, ModelSet set, URI uri, URI initialURI, RefreshRunnable refreshRunnable) {
+ this.reference = reference;
+ this.refreshRunnable = refreshRunnable;
+ }
+
+ @Override
+ public void partActivated(IWorkbenchPart part) {
+ if (reference.getPart(false) == part && part instanceof IMultiDiagramEditor) {
+ refreshRunnable.run((IMultiDiagramEditor) part);
+ removePageListener(this);
+ }
+ }
+
+ }
+
+ /**
+ * Listener which is notifid when an editor is closed
+ *
+ * @author tfaure
+ *
+ */
+ private class EditorCloseListener extends EditorAdapter {
+
+ @Override
+ public void partClosed(IWorkbenchPart part) {
+ super.partClosed(part);
+ if (part instanceof IMultiDiagramEditor) {
+ IMultiDiagramEditor editor = (IMultiDiagramEditor) part;
+
+ URI uri = getURI(editor.getEditorInput());
+ if (uri != null) {
+ uri = uri.trimFileExtension();
+ addPerspectiveListener(new EditorClosePerspectiveListener(uri));
+ removePageListener(this);
+ listeners.remove(uri);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * A perspective listener which choices of an user
+ *
+ * @author tfaure
+ *
+ */
+ protected class EditorClosePerspectiveListener implements IPerspectiveListener {
+
+ private final URI uri;
+
+ public EditorClosePerspectiveListener(URI uri) {
+ this.uri = uri;
+ }
+
+ public void perspectiveActivated(IWorkbenchPage page, IPerspectiveDescriptor perspective) {
+ }
+
+ public void perspectiveChanged(IWorkbenchPage page, IPerspectiveDescriptor perspective, String changeId) {
+ authorized.remove(uri);
+ mappingURIExtensions.remove(uri);
+ alreadyGuessed.remove(uri);
+ List<INotification> list = notifications.get(uri);
+ if (list != null) {
+ for (INotification n : list) {
+ n.delete();
+ }
+ }
+ notifications.remove(uri);
+ removePerspectiveListener(this);
+ }
+
+ }
+
+ /**
+ * A runnable refreshing resource and/or pages
+ *
+ * @author tfaure
+ *
+ */
+ public class RefreshRunnable {
+
+ protected IPageManager pageMngr;
+
+ protected URI uri;
+
+ protected final ModelSet modelSet;
+
+ protected final URI initialURI;
+
+ private final boolean refreshAll;
+
+ private final boolean refreshTab;
+
+ public RefreshRunnable(ModelSet modelSet, URI uriToLoad, URI initialURI, boolean refreshAll, boolean refreshTab) {
+ this.modelSet = modelSet;
+ uri = uriToLoad;
+ this.initialURI = initialURI;
+ this.refreshAll = refreshAll;
+ this.refreshTab = refreshTab;
+ }
+
+ public void run(IMultiDiagramEditor editor) {
+ final Set<URI> alreadyLoaded = new HashSet<URI>();
+ try {
+ pageMngr = editor.getServicesRegistry().getService(IPageManager.class);
+ List<Object> allPages = pageMngr.allPages();
+ // the uri is added after getting all the pages. If it is done
+ // before, the eobjects are resolved
+ NotificationBuilder error = NotificationBuilder.createAsyncPopup(Messages.AskUserStrategy_ERROR, String.format(Messages.AskUserStrategy_UNABLE_TO_LOAD, uri != null ? uri.toString() : Messages.AskUserStrategy_12)).setType(Type.ERROR)
+ .setDelay(2000);
+ // load associated resources
+ // the extensions needed for each element are saved so it is not needed to check filesystem
+ Set<String> extensions = getExtensions();
+ if (extensions != null) {
+ for (String s : extensions) {
+ try {
+ if (s != null) {
+ URI uriToLoad = URI.createURI(uri.toString());
+ if (s != null) {
+ uriToLoad = uriToLoad.appendFileExtension(s);
+ }
+ // the resource is loaded only if it is needed
+ if (!alreadyLoaded.contains(uriToLoad)) {
+ Resource r = modelSet.getResource(uriToLoad, true);
+ alreadyLoaded.add(uriToLoad);
+ if (r == null) {
+ error.run();
+ }
+ }
+ }
+ } catch (Exception re) {
+ error.run();
+ re.printStackTrace();
+ }
+ }
+ }
+ // refresh tabs
+ for (Object o : allPages) {
+ if (o instanceof EObject) {
+ EObject eobject = (EObject) o;
+ URI eobjectURI = EcoreUtil.getURI(eobject);
+ if (refreshAll || (refreshTab && eobjectURI.trimFileExtension().trimFragment().equals(uri))) {
+ // TODO improve this when an update is created
+ pageMngr.selectPage(eobject);
+ }
+ }
+ }
+
+ } catch (ServiceException e1) {
+ e1.printStackTrace();
+ }
+
+ }
+
+ public Set<String> getExtensions() {
+ Map<URI, Set<String>> map = mappingURIExtensions.get(initialURI);
+ if (map != null) {
+ return map.get(uri);
+ }
+ return null;
+ }
+
+ public IWorkbenchPage getActivePage() {
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ if (workbench != null) {
+ IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
+ if (activeWorkbenchWindow != null) {
+ if (activeWorkbenchWindow.getActivePage() != null) {
+ return activeWorkbenchWindow.getActivePage();
+ }
+ }
+ }
+ return null;
+ }
+
+ }
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/strategy/LoadedAuthorizedResourceManager.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/strategy/LoadedAuthorizedResourceManager.java
new file mode 100644
index 00000000000..3ed9da2c45a
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/strategy/LoadedAuthorizedResourceManager.java
@@ -0,0 +1,221 @@
+/*****************************************************************************
+ * Copyright (c) 2012, 2013 Atos, 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:
+ * Laurent Devernay (Atos) laurent.devernay@atos.net
+ * Christian W. Damus (CEA LIST) - support control mode in CDO resources
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.resourceloading.internal.ui.strategy;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.papyrus.infra.core.resource.AbstractBaseModel;
+import org.eclipse.papyrus.infra.core.resource.IModel;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel;
+import org.eclipse.papyrus.infra.services.resourceloading.Activator;
+import org.eclipse.papyrus.infra.services.resourceloading.internal.ui.UIPlugin;
+import org.eclipse.papyrus.infra.services.resourceloading.util.LoadingUtils;
+import org.eclipse.ui.preferences.ScopedPreferenceStore;
+import org.osgi.service.prefs.BackingStoreException;
+
+public class LoadedAuthorizedResourceManager implements IPropertyChangeListener {
+
+ public static class LoadedAuthorizedResource {
+
+ private URI uri;
+
+ public LoadedAuthorizedResource(URI uri) {
+ this.uri = uri;
+ }
+
+ public URI getUri() {
+ return uri;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof LoadedAuthorizedResource && uri != null) {
+ return uri.equals(((LoadedAuthorizedResource) obj).uri);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ if (uri != null) {
+ return uri.hashCode();
+ }
+ return 0;
+ }
+ }
+
+ private static final String LOADED_AUTHORIZED_RESOURCE_ELEMENT_ID = "loadedAuthorizedResource"; //$NON-NLS-1$
+
+ private static final String URI_ID = "uri"; //$NON-NLS-1$
+
+ private static final String PREFERENCE_PREFIX = LOADED_AUTHORIZED_RESOURCE_ELEMENT_ID + "."; //$NON-NLS-1$
+
+ public static final String URI_PREF_PREFIX = PREFERENCE_PREFIX + URI_ID + "."; //$NON-NLS-1$
+
+ private static final String pluginId = UIPlugin.PLUGIN_ID;
+
+ private static class Holder {
+
+ static final LoadedAuthorizedResourceManager instance = new LoadedAuthorizedResourceManager();
+ }
+
+ public static LoadedAuthorizedResourceManager getInstance() {
+ return Holder.instance;
+ }
+
+ private IPreferenceStore prefStore;
+
+ private IPreferenceStore projectPrefStore;
+
+ private Map<String, LoadedAuthorizedResource> loadedAuthorizedResources = null;
+
+ private Set<URI> loadedAuthorizedResourcesSet = null;
+
+ public LoadedAuthorizedResourceManager() {
+ prefStore = UIPlugin.getDefault().getPreferenceStore();
+ prefStore.addPropertyChangeListener(this);
+ }
+
+ public synchronized Map<String, LoadedAuthorizedResource> getLoadedAuthorizedResources() {
+ readAuthorizedResources();
+ return loadedAuthorizedResources;
+ }
+
+ public synchronized Set<URI> getLoadedAuthorizedResourcesSet(ModelSet modelSet) {
+ readAuthorizedResources(modelSet);
+ return loadedAuthorizedResourcesSet;
+ }
+
+ public synchronized void propertyChange(PropertyChangeEvent event) {
+ Object newValue = event.getNewValue();
+ // Insertion of the new value in the PreferenceStore
+ if (event.getProperty().startsWith(URI_PREF_PREFIX) && newValue instanceof String) {
+ String[] newURIs = parseString((String) newValue);
+ if (newURIs.length > 0) {
+ for (int i = 0; i < newURIs.length; i++) {
+ String newURI = newURIs[i];
+ if (!getLoadedAuthorizedResources().containsKey(newURI)) {
+ getLoadedAuthorizedResources().put(newURI, new LoadedAuthorizedResource(URI.createURI(newURI)));
+ }
+ }
+ }
+ }
+ }
+
+ private void readAuthorizedResources(ModelSet modelSet) {
+ IModel mainDiModel = modelSet.getModel(DiModel.MODEL_ID);
+ URI mainUri = null;
+ if (mainDiModel instanceof AbstractBaseModel) {
+ AbstractBaseModel resourceMainModel = (AbstractBaseModel) mainDiModel;
+ mainUri = resourceMainModel.getResourceURI();
+
+ }
+ if (loadedAuthorizedResourcesSet == null) {
+ loadedAuthorizedResourcesSet = new HashSet<URI>();
+ }
+
+ if (loadedAuthorizedResources == null) {
+ loadedAuthorizedResources = new HashMap<String, LoadedAuthorizedResourceManager.LoadedAuthorizedResource>();
+ }
+
+ loadedAuthorizedResources.clear();
+ loadedAuthorizedResourcesSet.clear();
+
+ // the mainUri may not yet be known because, depending on the order in which
+ // models are initialized, the loading of an earlier model than the main DI
+ // model may trigger proxy resolutions in the UML CacheAdapter's crawl
+ IFile currentFile = (mainUri == null) ? null : LoadingUtils.getFile(mainUri);
+ if (currentFile != null) {
+ IProject project = currentFile.getProject();
+ IEclipsePreferences root = Platform.getPreferencesService().getRootNode();
+ if (project != null && root != null) {
+ try {
+ // For the project preferences :
+ if (root.node(ProjectScope.SCOPE).node(project.getName()).nodeExists(pluginId)) {
+ projectPrefStore = new ScopedPreferenceStore(new ProjectScope(project), pluginId);
+ String s = projectPrefStore.getString(URI_PREF_PREFIX);
+ String[] array = parseString(s);
+ for (int i = 0; i < array.length; i++) {
+ URI uri = URI.createURI(array[i]);
+
+ loadedAuthorizedResources.put(uri.toString(), new LoadedAuthorizedResource(uri));
+
+ loadedAuthorizedResourcesSet.add(uri);
+ }
+ }
+ } catch (BackingStoreException e) {
+ Activator.logError(e);
+ }
+ }
+ }
+ // For the workspace preferences :
+ String s = prefStore.getString(URI_PREF_PREFIX);
+ String[] array = parseString(s);
+ for (int i = 0; i < array.length; i++) {
+ URI uri = URI.createURI(array[i]);
+
+ loadedAuthorizedResources.put(uri.toString(), new LoadedAuthorizedResource(uri));
+
+ loadedAuthorizedResourcesSet.add(uri);
+ }
+ }
+
+ private void readAuthorizedResources() {
+ if (loadedAuthorizedResources == null) {
+ loadedAuthorizedResources = new HashMap<String, LoadedAuthorizedResourceManager.LoadedAuthorizedResource>();
+ }
+ String s;
+ loadedAuthorizedResources.clear();
+
+ if (projectPrefStore == null) {
+ s = prefStore.getString(URI_PREF_PREFIX);
+ } else {
+ s = projectPrefStore.getString(URI_PREF_PREFIX);
+ }
+
+ String[] array = parseString(s);
+ for (int i = 0; i < array.length; i++) {
+ URI uri = URI.createURI(array[i]);
+
+ loadedAuthorizedResources.put(uri.toString(), new LoadedAuthorizedResource(uri));
+
+ }
+ }
+
+ protected String[] parseString(String stringList) {
+ StringTokenizer st = new StringTokenizer(stringList, File.pathSeparator + "\n\r");//$NON-NLS-1$
+ ArrayList v = new ArrayList();
+ while (st.hasMoreElements()) {
+ v.add(st.nextElement());
+ }
+ return (String[]) v.toArray(new String[v.size()]);
+ }
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/strategy/PreferenceLoadingStrategyExtension.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/strategy/PreferenceLoadingStrategyExtension.java
new file mode 100644
index 00000000000..37c72c97825
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/strategy/PreferenceLoadingStrategyExtension.java
@@ -0,0 +1,33 @@
+/*****************************************************************************
+ * Copyright (c) 2012 Atos.
+ *
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Laurent Devernay (Atos) laurent.devernay@atos.net
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.resourceloading.internal.ui.strategy;
+
+import java.util.Set;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.papyrus.infra.core.resource.ModelSet;
+import org.eclipse.papyrus.infra.services.resourceloading.ILoadingStrategyExtension;
+
+public class PreferenceLoadingStrategyExtension implements ILoadingStrategyExtension {
+
+ public boolean loadResource(ModelSet modelSet, URI uri) {
+ Set<URI> loadedAuthorizedResourcesSet = LoadedAuthorizedResourceManager.getInstance().getLoadedAuthorizedResourcesSet(modelSet);
+
+ if (loadedAuthorizedResourcesSet.contains(uri.trimFileExtension())) {
+ return true;
+ }
+ return false;
+ }
+
+}
diff --git a/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/strategy/StrategyChooser.java b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/strategy/StrategyChooser.java
new file mode 100644
index 00000000000..a8f2dc122af
--- /dev/null
+++ b/plugins/infra/services/org.eclipse.papyrus.infra.services.resourceloading.ui/src/org/eclipse/papyrus/infra/services/resourceloading/internal/ui/strategy/StrategyChooser.java
@@ -0,0 +1,69 @@
+/*****************************************************************************
+ * Copyright (c) 2010, 2016 Atos Origin, 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:
+ * Emilien Perico (Atos Origin) emilien.perico@atosorigin.com - Initial API and implementation
+ * Christian W. Damus - bug 485220
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.services.resourceloading.internal.ui.strategy;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.papyrus.infra.services.resourceloading.IStrategyChooser;
+import org.eclipse.papyrus.infra.services.resourceloading.internal.ui.UIPlugin;
+import org.eclipse.papyrus.infra.services.resourceloading.internal.ui.preferences.ICorePreferenceConstants;
+
+
+/**
+ * The Class StrategyChooser.
+ */
+public class StrategyChooser implements IStrategyChooser {
+
+ /** The current strategy. */
+ private static Integer currentStrategy = -1;
+
+ /**
+ * Instantiates a new strategy chooser.
+ */
+ public StrategyChooser() {
+ }
+
+ /**
+ * @see org.eclipse.papyrus.infra.services.resourceloading.IStrategyChooser#getCurrentStrategy()
+ */
+ public int getCurrentStrategy() {
+ if (currentStrategy == -1) {
+ // set the current strategy at the first time
+ currentStrategy = UIPlugin.getDefault().getPreferenceStore().getInt(ICorePreferenceConstants.PREF_CORE_DEFINE_LOADING_STRATEGY);
+ }
+ return currentStrategy;
+ }
+
+ /**
+ * Sets the current strategy.
+ *
+ * @param strategy
+ * the new current strategy ID
+ */
+ public static void setCurrentStrategy(int strategy) {
+ currentStrategy = strategy;
+ IPreferenceStore store = UIPlugin.getDefault().getPreferenceStore();
+ if (store.getInt(ICorePreferenceConstants.PREF_CORE_DEFINE_LOADING_STRATEGY) != strategy) {
+ store.setValue(ICorePreferenceConstants.PREF_CORE_DEFINE_LOADING_STRATEGY, String.valueOf(strategy));
+ }
+ }
+
+ public boolean setStrategy(int strategy) {
+ if (currentStrategy != strategy) {
+ setCurrentStrategy(strategy);
+ }
+
+ return true;
+ }
+
+}

Back to the top