Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2018-11-09 07:42:21 -0500
committerAlexander Kurtakov2018-11-09 09:10:40 -0500
commit8fa37eb7e058e001361d829989660c1e3a8a7171 (patch)
treec0758242b3af1d3007cc44b0a954fc1da7f488e6
parent5016236989cc010743af96885fdca75566cf55cb (diff)
downloadeclipse.platform.team-8fa37eb7e058e001361d829989660c1e3a8a7171.tar.gz
eclipse.platform.team-8fa37eb7e058e001361d829989660c1e3a8a7171.tar.xz
eclipse.platform.team-8fa37eb7e058e001361d829989660c1e3a8a7171.zip
-rw-r--r--examples/org.eclipse.team.examples.filesystem/.settings/org.eclipse.jdt.core.prefs365
-rw-r--r--examples/org.eclipse.team.examples.filesystem/.settings/org.eclipse.jdt.ui.prefs63
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileModificationValidator.java16
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemOperations.java91
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemSubscriber.java54
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/CompoundResourceTraversal.java87
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemAction.java25
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemMainPage.java71
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemOperation.java55
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ModelPutAction.java15
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/NonSyncModelMergePage.java116
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ProjectSetSerializer.java47
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySubscriber.java19
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelContainer.java18
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelObjectDefinitionFile.java77
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelProject.java12
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/PluginManifestChangeTracker.java41
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ExampleModelProvider.java81
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModResourceMapping.java55
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelMerger.java91
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorContentProvider.java152
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelSaveablesProvider.java16
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/CompareAdapter.java38
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelMergeActionHandler.java31
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelSyncContentProvider.java120
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ThirdPartyActionProvider.java27
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java282
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProviderPlugin.java53
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticModificationValidator.java242
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceChangeListener.java172
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceSetContentProvider.java33
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/AddToControlAction.java25
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/DisconnectAction.java46
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticProviderAction.java68
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/RemoveFromControlAction.java21
-rw-r--r--examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/SourceManagementAction.java22
36 files changed, 1628 insertions, 1119 deletions
diff --git a/examples/org.eclipse.team.examples.filesystem/.settings/org.eclipse.jdt.core.prefs b/examples/org.eclipse.team.examples.filesystem/.settings/org.eclipse.jdt.core.prefs
index 874381319..c281c8a64 100644
--- a/examples/org.eclipse.team.examples.filesystem/.settings/org.eclipse.jdt.core.prefs
+++ b/examples/org.eclipse.team.examples.filesystem/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,13 @@
eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
+org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
+org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
@@ -7,56 +16,412 @@ org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.APILeak=warning
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=warning
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
org.eclipse.jdt.core.compiler.problem.deprecation=warning
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=error
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=error
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=error
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=error
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=error
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error
org.eclipse.jdt.core.compiler.problem.parameterAssignment=warning
+org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
+org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
+org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning
+org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled
+org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=enabled
+org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedImport=error
org.eclipse.jdt.core.compiler.problem.unusedLabel=error
org.eclipse.jdt.core.compiler.problem.unusedLocal=error
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=enabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=enabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
+org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
+org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=false
+org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=false
+org.eclipse.jdt.core.formatter.align_with_spaces=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_compact_loops=16
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
+org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
+org.eclipse.jdt.core.formatter.alignment_for_module_statements=16
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0
+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_type_arguments=0
+org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0
+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.align_tags_descriptions_grouped=true
+org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false
+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.count_line_length_from_starting_position=true
+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=false
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=false
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert
+org.eclipse.jdt.core.formatter.comment.line_length=80
+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=false
+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_enum_constant=insert
+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=do not 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=true
+org.eclipse.jdt.core.formatter.join_wrapped_lines=true
+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_simple_do_while_body_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.lineSplit=120
+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=1
+org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines
+org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines
+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_assignment_operator=false
+org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
+org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
+org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter
diff --git a/examples/org.eclipse.team.examples.filesystem/.settings/org.eclipse.jdt.ui.prefs b/examples/org.eclipse.team.examples.filesystem/.settings/org.eclipse.jdt.ui.prefs
index b35e41ad6..90186753d 100644
--- a/examples/org.eclipse.team.examples.filesystem/.settings/org.eclipse.jdt.ui.prefs
+++ b/examples/org.eclipse.team.examples.filesystem/.settings/org.eclipse.jdt.ui.prefs
@@ -1,3 +1,64 @@
-#Wed Mar 15 21:17:48 EST 2006
eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_profile=org.eclipse.jdt.ui.default.eclipse_profile
+formatter_settings_version=14
internal.default.compliance=user
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_functional_interfaces=true
+sp_cleanup.convert_to_enhanced_for_loop=true
+sp_cleanup.correct_indentation=true
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=true
+sp_cleanup.insert_inferred_type_arguments=false
+sp_cleanup.make_local_variable_final=true
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_redundant_modifiers=true
+sp_cleanup.remove_redundant_semicolons=true
+sp_cleanup.remove_redundant_type_arguments=true
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=true
+sp_cleanup.remove_unused_imports=true
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_anonymous_class_creation=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_lambda=true
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileModificationValidator.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileModificationValidator.java
index 180fb6353..130b77d43 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileModificationValidator.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileModificationValidator.java
@@ -31,7 +31,7 @@ import org.eclipse.team.core.TeamException;
* only has two methods and their implementation is straight forward.
*/
public final class FileModificationValidator extends org.eclipse.core.resources.team.FileModificationValidator {
-
+
private FileSystemOperations operations;
/**
@@ -60,17 +60,18 @@ public final class FileModificationValidator extends org.eclipse.core.resources.
* The idea is to prevent anyone from accidentally working on a file that they won't be able to check in changes to.
* @see org.eclipse.core.resources.IFileModificationValidator#validateEdit(IFile[], Object)
*/
+ @Override
public IStatus validateEdit(IFile[] files, FileModificationValidationContext context) {
- Collection toBeCheckedOut = new ArrayList();
+ Collection<IResource> toBeCheckedOut = new ArrayList<>();
//Make a list of all the files that need to be checked out:
- for (int i = 0; i < files.length; i++) {
- if (!operations.isCheckedOut(files[i])) {
- toBeCheckedOut.add(files[i]);
+ for (IFile file : files) {
+ if (!operations.isCheckedOut(file)) {
+ toBeCheckedOut.add(file);
}
}
-
- return checkout((IResource[]) toBeCheckedOut.toArray(new IResource[toBeCheckedOut.size()]));
+
+ return checkout(toBeCheckedOut.toArray(new IResource[toBeCheckedOut.size()]));
}
/**
@@ -78,6 +79,7 @@ public final class FileModificationValidator extends org.eclipse.core.resources.
* It should not attempt to save any files that don't receive an OK status here.
* @see org.eclipse.core.resources.IFileModificationValidator#validateSave(IFile)
*/
+ @Override
public IStatus validateSave(IFile file) {
if (file.isReadOnly()) {
return checkout(new IResource[] { file });
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemOperations.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemOperations.java
index 97de4357a..46276b40a 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemOperations.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/FileSystemOperations.java
@@ -10,7 +10,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
- * Andreas Voss <av@tonbeller.com> - Bug 181141 [Examples] Team: filesystem provider example can not handle deletions
+ * Andreas Voss <av@tonbeller.com> - Bug 181141 [Examples] Team: filesystem provider example can not handle deletions
*******************************************************************************/
package org.eclipse.team.examples.filesystem;
@@ -19,7 +19,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IContainer;
@@ -51,7 +50,7 @@ public class FileSystemOperations {
}
/**
- * Make the local state of the project match the remote state by getting any out-of-sync
+ * Make the local state of the project match the remote state by getting any out-of-sync
* resources. The overrideOutgoing flag is used to indicate whether locally modified
* files should also be replaced or left alone.
* @param resources the resources to get
@@ -74,7 +73,7 @@ public class FileSystemOperations {
}
/**
- * Make the local state of the traversals match the remote state by getting any out-of-sync
+ * Make the local state of the traversals match the remote state by getting any out-of-sync
* resources. The overrideOutgoing flag is used to indicate whether locally modified
* files should also be replaced or left alone.
* @param traversals the traversals that cover the resources to get
@@ -87,15 +86,14 @@ public class FileSystemOperations {
// ensure the progress monitor is not null
monitor = Policy.monitorFor(monitor);
monitor.beginTask(null, 100* traversals.length);
- for (int i = 0; i < traversals.length; i++) {
- ResourceTraversal traversal = traversals[i];
+ for (ResourceTraversal traversal : traversals) {
get(traversal.getResources(), traversal.getDepth(), overrideOutgoing, SubMonitor.convert(monitor, 100));
}
} finally {
monitor.done();
}
}
-
+
/**
* Checkout the given resources to the given depth by setting any files
* to writable (i.e set read-only to <code>false</code>.
@@ -108,16 +106,14 @@ public class FileSystemOperations {
try {
progress = Policy.monitorFor(progress);
progress.beginTask(Policy.bind("FileSystemSimpleAccessOperations.1"), resources.length); //$NON-NLS-1$
- for (int i = 0; i < resources.length; i++) {
+ for (IResource resource2 : resources) {
Policy.checkCanceled(progress);
- resources[i].accept(new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- if (resource.getType() == IResource.FILE) {
- //TODO: lock the file on the 'server'.
- resource.setReadOnly(false);
- }
- return true;
+ resource2.accept((IResourceVisitor) resource -> {
+ if (resource.getType() == IResource.FILE) {
+ //TODO: lock the file on the 'server'.
+ resource.setReadOnly(false);
}
+ return true;
}, depth, false /* include phantoms */);
progress.worked(1);
}
@@ -130,7 +126,7 @@ public class FileSystemOperations {
/**
* Check-in the given resources to the given depth by replacing the remote (i.e. file system)
- * contents with the local workspace contents.
+ * contents with the local workspace contents.
* @param resources the resources
* @param depth the depth of the operation
* @param overrideIncoming indicate whether incoming remote changes should be replaced
@@ -152,7 +148,7 @@ public class FileSystemOperations {
/**
* Check-in the given resources to the given depth by replacing the remote (i.e. file system)
- * contents with the local workspace contents.
+ * contents with the local workspace contents.
* @param traversals the traversals that cover the resources to check in
* @param overrideIncoming indicate whether incoming remote changes should be replaced
* @param progress a progress monitor
@@ -163,15 +159,14 @@ public class FileSystemOperations {
// ensure the progress monitor is not null
monitor = Policy.monitorFor(monitor);
monitor.beginTask(null, 100* traversals.length);
- for (int i = 0; i < traversals.length; i++) {
- ResourceTraversal traversal = traversals[i];
+ for (ResourceTraversal traversal : traversals) {
checkin(traversal.getResources(), traversal.getDepth(), overrideIncoming, SubMonitor.convert(monitor, 100));
}
} finally {
monitor.done();
}
}
-
+
/**
* Return whether the local resource is checked out. A resource
* is checked out if it is a file that is not read-only. Folders
@@ -190,16 +185,16 @@ public class FileSystemOperations {
private FileSystemResourceVariant getResourceVariant(IResource resource) {
return (FileSystemResourceVariant)provider.getResourceVariant(resource);
}
-
+
private void internalGet(IResource[] resources, int depth, boolean overrideOutgoing, IProgressMonitor progress) throws TeamException {
// Traverse the resources and get any that are out-of-sync
progress.beginTask(Policy.bind("GetAction.working"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
- for (int i = 0; i < resources.length; i++) {
+ for (IResource resource : resources) {
Policy.checkCanceled(progress);
- if (resources[i].getType() == IResource.FILE) {
- internalGet((IFile) resources[i], overrideOutgoing, progress);
+ if (resource.getType() == IResource.FILE) {
+ internalGet((IFile) resource, overrideOutgoing, progress);
} else if (depth != IResource.DEPTH_ZERO) {
- internalGet((IContainer)resources[i], depth, overrideOutgoing, progress);
+ internalGet((IContainer)resource, depth, overrideOutgoing, progress);
}
progress.worked(1);
}
@@ -212,7 +207,7 @@ public class FileSystemOperations {
try {
ThreeWaySynchronizer synchronizer = FileSystemSubscriber.getInstance().getSynchronizer();
// Make the local folder state match the remote folder state
- List toDelete = new ArrayList();
+ List<IFolder> toDelete = new ArrayList<>();
if (container.getType() == IResource.FOLDER) {
IFolder folder = (IFolder)container;
FileSystemResourceVariant remote = getResourceVariant(container);
@@ -226,16 +221,15 @@ public class FileSystemOperations {
toDelete.add(folder);
}
}
-
+
// Get the children
IResource[] children = synchronizer.members(container);
if (children.length > 0) {
internalGet(children, depth == IResource.DEPTH_INFINITE ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO, overrideOutgoing, progress);
}
-
+
// Remove any empty folders
- for (Iterator iter = toDelete.iterator(); iter.hasNext(); ) {
- IFolder folder = (IFolder) iter.next();
+ for (IFolder folder : toDelete) {
if (folder.members().length == 0) {
folder.delete(false, true, progress);
synchronizer.flush(folder, IResource.DEPTH_INFINITE);
@@ -255,7 +249,7 @@ public class FileSystemOperations {
FileSystemResourceVariant remote = getResourceVariant(localFile);
byte[] baseBytes = synchronizer.getBaseBytes(localFile);
IResourceVariant base = provider.getResourceVariant(localFile, baseBytes);
- if (!synchronizer.hasSyncBytes(localFile)
+ if (!synchronizer.hasSyncBytes(localFile)
|| (isLocallyModified(localFile) && !overrideOutgoing)) {
// Do not overwrite the local modification
return;
@@ -270,9 +264,9 @@ public class FileSystemOperations {
throw TeamException.asTeamException(e);
}
}
- if (!synchronizer.isLocallyModified(localFile)
- && base != null
- && remote != null
+ if (!synchronizer.isLocallyModified(localFile)
+ && base != null
+ && remote != null
&& comparator.compare(base, remote)) {
// The base and remote are the same and there's no local changes
// so nothing needs to be done
@@ -302,23 +296,23 @@ public class FileSystemOperations {
throw FileSystemPlugin.wrapException(e);
}
}
-
+
private void internalPut(IResource[] resources, int depth, boolean overrideIncoming, IProgressMonitor progress) throws TeamException {
// ensure the progress monitor is not null
progress = Policy.monitorFor(progress);
progress.beginTask(Policy.bind("PutAction.working"), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
- for (int i = 0; i < resources.length; i++) {
+ for (IResource resource : resources) {
Policy.checkCanceled(progress);
- if (resources[i].getType() == IResource.FILE) {
- internalPut((IFile)resources[i], overrideIncoming, progress);
+ if (resource.getType() == IResource.FILE) {
+ internalPut((IFile)resource, overrideIncoming, progress);
} else if (depth > 0) { //Assume that resources are either files or containers.
- internalPut((IContainer)resources[i], depth, overrideIncoming, progress);
+ internalPut((IContainer)resource, depth, overrideIncoming, progress);
}
progress.worked(1);
}
progress.done();
}
-
+
/**
* Put the file if the sync state allows it.
* @param localFile the local file
@@ -333,7 +327,7 @@ public class FileSystemOperations {
FileSystemResourceVariant remote = getResourceVariant(localFile);
byte[] baseBytes = synchronizer.getBaseBytes(localFile);
IResourceVariant base = provider.getResourceVariant(localFile, baseBytes);
-
+
// Check whether we are overriding a remote change
if (base == null && remote != null && !overrideIncoming) {
// The remote is an incoming (or conflicting) addition.
@@ -360,10 +354,10 @@ public class FileSystemOperations {
return false;
}
}
-
+
// Handle an outgoing deletion
File diskFile = provider.getFile(localFile);
- if (!localFile.exists()) {
+ if (!localFile.exists()) {
diskFile.delete();
synchronizer.flush(localFile, IResource.DEPTH_ZERO);
} else {
@@ -399,7 +393,7 @@ public class FileSystemOperations {
}
return true;
}
-
+
private boolean isLocallyModified(IFile localFile) throws TeamException {
ThreeWaySynchronizer synchronizer = FileSystemSubscriber.getInstance().getSynchronizer();
if (!localFile.exists()) {
@@ -416,7 +410,7 @@ public class FileSystemOperations {
try {
ThreeWaySynchronizer synchronizer = FileSystemSubscriber.getInstance().getSynchronizer();
// Make the local folder state match the remote folder state
- List toDelete = new ArrayList();
+ List<File> toDelete = new ArrayList<>();
if (container.getType() == IResource.FOLDER) {
IFolder folder = (IFolder)container;
File diskFile = provider.getFile(container);
@@ -431,16 +425,15 @@ public class FileSystemOperations {
synchronizer.setBaseBytes(folder, provider.getResourceVariant(folder).asBytes());
}
}
-
+
// Get the children
IResource[] children = synchronizer.members(container);
if (children.length > 0) {
internalPut(children, depth == IResource.DEPTH_INFINITE ? IResource.DEPTH_INFINITE : IResource.DEPTH_ZERO, overrideIncoming, progress);
}
-
+
// Remove any empty folders
- for (Iterator iter = toDelete.iterator(); iter.hasNext(); ) {
- File diskFile = (File) iter.next();
+ for (File diskFile : toDelete) {
File[] fileList = diskFile.listFiles();
if(fileList == null) {
throw new TeamException("Content from directory '" + diskFile.getAbsolutePath() + "' can not be listed."); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemSubscriber.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemSubscriber.java
index 974256a01..4aacbeb34 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemSubscriber.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/subscriber/FileSystemSubscriber.java
@@ -16,12 +16,19 @@ package org.eclipse.team.examples.filesystem.subscriber;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.synchronize.SyncInfo;
-import org.eclipse.team.core.variants.*;
+import org.eclipse.team.core.variants.IResourceVariant;
+import org.eclipse.team.core.variants.ThreeWayRemoteTree;
+import org.eclipse.team.core.variants.ThreeWaySubscriber;
+import org.eclipse.team.core.variants.ThreeWaySynchronizer;
import org.eclipse.team.examples.filesystem.FileSystemPlugin;
import org.eclipse.team.examples.filesystem.FileSystemProvider;
@@ -32,7 +39,7 @@ import org.eclipse.team.examples.filesystem.FileSystemProvider;
* manage the roots and to create resource variants. It also makes
* use of a file system specific remote tree (<code>FileSystemRemoteTree</code>)
* for provided the remote tree access and refresh.
- *
+ *
* @see ThreeWaySubscriber
* @see ThreeWaySynchronizer
* @see FileSystemProvider
@@ -41,7 +48,7 @@ import org.eclipse.team.examples.filesystem.FileSystemProvider;
public class FileSystemSubscriber extends ThreeWaySubscriber {
private static FileSystemSubscriber instance;
-
+
/**
* Return the file system subscriber singleton.
* @return the file system subscriber singleton.
@@ -52,7 +59,7 @@ public class FileSystemSubscriber extends ThreeWaySubscriber {
}
return instance;
}
-
+
/**
* Create the file system subscriber.
*/
@@ -60,9 +67,7 @@ public class FileSystemSubscriber extends ThreeWaySubscriber {
super(new ThreeWaySynchronizer(new QualifiedName(FileSystemPlugin.ID, "workpsace-sync"))); //$NON-NLS-1$
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.ThreeWaySubscriber#getResourceVariant(org.eclipse.core.resources.IResource, byte[])
- */
+ @Override
public IResourceVariant getResourceVariant(IResource resource, byte[] bytes) {
RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject(), FileSystemPlugin.PROVIDER_ID);
if (provider != null) {
@@ -71,28 +76,21 @@ public class FileSystemSubscriber extends ThreeWaySubscriber {
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.ThreeWaySubscriber#createRemoteTree()
- */
+ @Override
protected ThreeWayRemoteTree createRemoteTree() {
return new FileSystemRemoteTree(this);
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.Subscriber#getName()
- */
+ @Override
public String getName() {
return "File System Example"; //$NON-NLS-1$
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.subscribers.Subscriber#roots()
- */
+ @Override
public IResource[] roots() {
- List result = new ArrayList();
+ List<IProject> result = new ArrayList<>();
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for (int i = 0; i < projects.length; i++) {
- IProject project = projects[i];
+ for (IProject project : projects) {
if(project.isAccessible()) {
RepositoryProvider provider = RepositoryProvider.getProvider(project, FileSystemPlugin.PROVIDER_ID);
if(provider != null) {
@@ -100,20 +98,16 @@ public class FileSystemSubscriber extends ThreeWaySubscriber {
}
}
}
- return (IProject[]) result.toArray(new IProject[result.size()]);
+ return result.toArray(new IProject[result.size()]);
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.ThreeWaySubscriber#handleRootChanged(org.eclipse.core.resources.IResource, boolean)
- */
+ @Override
public void handleRootChanged(IResource resource, boolean added) {
// Override to allow FileSystemProvider to signal the addition and removal of roots
super.handleRootChanged(resource, added);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.variants.ResourceVariantTreeSubscriber#getSyncInfo(org.eclipse.core.resources.IResource, org.eclipse.team.core.variants.IResourceVariant, org.eclipse.team.core.variants.IResourceVariant)
- */
+
+ @Override
protected SyncInfo getSyncInfo(IResource local, IResourceVariant base, IResourceVariant remote) throws TeamException {
// Override to use a custom sync info
FileSystemSyncInfo info = new FileSystemSyncInfo(local, base, remote, this.getResourceComparator());
@@ -140,7 +134,7 @@ public class FileSystemSubscriber extends ThreeWaySubscriber {
/**
* Make the change an outgoing change
* @param resource
- * @throws TeamException
+ * @throws TeamException
*/
public void markAsMerged(IResource resource, IProgressMonitor monitor) throws TeamException {
makeInSync(resource);
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/CompoundResourceTraversal.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/CompoundResourceTraversal.java
index 143fc396d..4a009a85c 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/CompoundResourceTraversal.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/CompoundResourceTraversal.java
@@ -13,7 +13,11 @@
*******************************************************************************/
package org.eclipse.team.examples.filesystem.ui;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.mapping.ResourceTraversal;
@@ -23,28 +27,26 @@ import org.eclipse.core.runtime.IPath;
* Helper class that accumulates several traversals in order
* to generate a final set of traversals and to perform certain
* queries on a set of traversals.
- *
+ *
* TODO: This class was copied from the Team Core plugin since it was an internal
* class. It should probably be made API at some point.
*/
public class CompoundResourceTraversal {
-
- private Set deepFolders = new HashSet();
- private Set shallowFolders = new HashSet();
- private Set zeroFolders = new HashSet();
- private Set files = new HashSet();
-
+
+ private Set<IResource> deepFolders = new HashSet<>();
+ private Set<IResource> shallowFolders = new HashSet<>();
+ private Set<IResource> zeroFolders = new HashSet<>();
+ private Set<IResource> files = new HashSet<>();
+
public void addTraversals(ResourceTraversal[] traversals) {
- for (int i = 0; i < traversals.length; i++) {
- ResourceTraversal traversal = traversals[i];
+ for (ResourceTraversal traversal : traversals) {
addTraversal(traversal);
}
}
public void addTraversal(ResourceTraversal traversal) {
IResource[] resources = traversal.getResources();
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
+ for (IResource resource : resources) {
addResource(resource, traversal.getDepth());
}
}
@@ -77,8 +79,8 @@ public class CompoundResourceTraversal {
public boolean isCovered(IResource resource, int depth) {
IPath fullPath = resource.getFullPath();
// Regardless of the depth, look for a deep folder that covers the resource
- for (Iterator iter = deepFolders.iterator(); iter.hasNext();) {
- IResource deepFolder = (IResource) iter.next();
+ for (Object element : deepFolders) {
+ IResource deepFolder = (IResource) element;
if (deepFolder.getFullPath().isPrefixOf(fullPath)) {
return true;
}
@@ -157,25 +159,24 @@ public class CompoundResourceTraversal {
public void add(CompoundResourceTraversal compoundTraversal) {
addResources(
- (IResource[]) compoundTraversal.deepFolders.toArray(new IResource[compoundTraversal.deepFolders.size()]),
+ compoundTraversal.deepFolders.toArray(new IResource[compoundTraversal.deepFolders.size()]),
IResource.DEPTH_INFINITE);
addResources(
- (IResource[]) compoundTraversal.shallowFolders.toArray(new IResource[compoundTraversal.shallowFolders.size()]),
+ compoundTraversal.shallowFolders.toArray(new IResource[compoundTraversal.shallowFolders.size()]),
IResource.DEPTH_ONE);
addResources(
- (IResource[]) compoundTraversal.zeroFolders.toArray(new IResource[compoundTraversal.zeroFolders.size()]),
+ compoundTraversal.zeroFolders.toArray(new IResource[compoundTraversal.zeroFolders.size()]),
IResource.DEPTH_ZERO);
addResources(
- (IResource[]) compoundTraversal.files.toArray(new IResource[compoundTraversal.files.size()]),
+ compoundTraversal.files.toArray(new IResource[compoundTraversal.files.size()]),
IResource.DEPTH_ZERO);
}
public void addResources(IResource[] resources, int depth) {
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
+ for (IResource resource : resources) {
addResource(resource, depth);
}
-
+
}
/**
@@ -193,58 +194,54 @@ public class CompoundResourceTraversal {
* Return any resources in the other traversal that are not covered by this traversal
*/
private IResource[] getUncoveredResources(CompoundResourceTraversal otherTraversal) {
- Set result = new HashSet();
- for (Iterator iter = otherTraversal.files.iterator(); iter.hasNext();) {
- IResource resource = (IResource) iter.next();
+ Set<IResource> result = new HashSet<>();
+ for (IResource resource : otherTraversal.files) {
if (!isCovered(resource, IResource.DEPTH_ZERO)) {
result.add(resource);
}
}
- for (Iterator iter = otherTraversal.zeroFolders.iterator(); iter.hasNext();) {
- IResource resource = (IResource) iter.next();
+ for (IResource resource : otherTraversal.zeroFolders) {
if (!isCovered(resource, IResource.DEPTH_ZERO)) {
result.add(resource);
}
}
- for (Iterator iter = otherTraversal.shallowFolders.iterator(); iter.hasNext();) {
- IResource resource = (IResource) iter.next();
+ for (IResource resource : otherTraversal.shallowFolders) {
if (!isCovered(resource, IResource.DEPTH_ONE)) {
result.add(resource);
}
}
- for (Iterator iter = otherTraversal.deepFolders.iterator(); iter.hasNext();) {
- IResource resource = (IResource) iter.next();
+ for (IResource resource : otherTraversal.deepFolders) {
if (!isCovered(resource, IResource.DEPTH_INFINITE)) {
result.add(resource);
}
}
- return (IResource[]) result.toArray(new IResource[result.size()]);
+ return result.toArray(new IResource[result.size()]);
}
public ResourceTraversal[] asTraversals() {
- List result = new ArrayList();
+ List<ResourceTraversal> result = new ArrayList<>();
if (!files.isEmpty() || ! zeroFolders.isEmpty()) {
- Set combined = new HashSet();
+ Set<IResource> combined = new HashSet<>();
combined.addAll(files);
combined.addAll(zeroFolders);
- result.add(new ResourceTraversal((IResource[]) combined.toArray(new IResource[combined.size()]), IResource.DEPTH_ZERO, IResource.NONE));
+ result.add(new ResourceTraversal(combined.toArray(new IResource[combined.size()]), IResource.DEPTH_ZERO, IResource.NONE));
}
if (!shallowFolders.isEmpty()) {
- result.add(new ResourceTraversal((IResource[]) shallowFolders.toArray(new IResource[shallowFolders.size()]), IResource.DEPTH_ONE, IResource.NONE));
+ result.add(new ResourceTraversal(shallowFolders.toArray(new IResource[shallowFolders.size()]), IResource.DEPTH_ONE, IResource.NONE));
}
if (!deepFolders.isEmpty()) {
- result.add(new ResourceTraversal((IResource[]) deepFolders.toArray(new IResource[deepFolders.size()]), IResource.DEPTH_INFINITE, IResource.NONE));
+ result.add(new ResourceTraversal(deepFolders.toArray(new IResource[deepFolders.size()]), IResource.DEPTH_INFINITE, IResource.NONE));
}
- return (ResourceTraversal[]) result.toArray(new ResourceTraversal[result.size()]);
+ return result.toArray(new ResourceTraversal[result.size()]);
}
public IResource[] getRoots() {
- List result = new ArrayList();
+ List<IResource> result = new ArrayList<>();
result.addAll(files);
result.addAll(zeroFolders);
result.addAll(shallowFolders);
result.addAll(deepFolders);
- return (IResource[]) result.toArray(new IResource[result.size()]);
+ return result.toArray(new IResource[result.size()]);
}
public ResourceTraversal[] getUncoveredTraversals(ResourceTraversal[] traversals) {
@@ -255,26 +252,22 @@ public class CompoundResourceTraversal {
public ResourceTraversal[] getUncoveredTraversals(CompoundResourceTraversal otherTraversal) {
CompoundResourceTraversal uncovered = new CompoundResourceTraversal();
- for (Iterator iter = otherTraversal.files.iterator(); iter.hasNext();) {
- IResource resource = (IResource) iter.next();
+ for (IResource resource : otherTraversal.files) {
if (!isCovered(resource, IResource.DEPTH_ZERO)) {
uncovered.addResource(resource, IResource.DEPTH_ZERO);
}
}
- for (Iterator iter = otherTraversal.zeroFolders.iterator(); iter.hasNext();) {
- IResource resource = (IResource) iter.next();
+ for (IResource resource : otherTraversal.zeroFolders) {
if (!isCovered(resource, IResource.DEPTH_ZERO)) {
uncovered.addResource(resource, IResource.DEPTH_ZERO);
}
}
- for (Iterator iter = otherTraversal.shallowFolders.iterator(); iter.hasNext();) {
- IResource resource = (IResource) iter.next();
+ for (IResource resource : otherTraversal.shallowFolders) {
if (!isCovered(resource, IResource.DEPTH_ONE)) {
uncovered.addResource(resource, IResource.DEPTH_ONE);
}
}
- for (Iterator iter = otherTraversal.deepFolders.iterator(); iter.hasNext();) {
- IResource resource = (IResource) iter.next();
+ for (IResource resource : otherTraversal.deepFolders) {
if (!isCovered(resource, IResource.DEPTH_INFINITE)) {
uncovered.addResource(resource, IResource.DEPTH_INFINITE);
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemAction.java
index 47c5fd3d2..573bec373 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemAction.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemAction.java
@@ -13,7 +13,10 @@
*******************************************************************************/
package org.eclipse.team.examples.filesystem.ui;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.mapping.ResourceMapping;
@@ -27,9 +30,7 @@ import org.eclipse.team.internal.ui.actions.TeamAction;
*/
public abstract class FileSystemAction extends TeamAction {
- /**
- * @see org.eclipse.team.internal.ui.actions.TeamAction#isEnabled()
- */
+ @Override
public boolean isEnabled() {
return getSelectedMappings().length > 0;
}
@@ -38,20 +39,20 @@ public abstract class FileSystemAction extends TeamAction {
* Split the resources into sets associated with their project/provider
*/
protected Map getRepositoryProviderMapping() {
- HashMap result = new HashMap();
+ HashMap<RepositoryProvider, List<IResource>> result = new HashMap<>();
IResource[] resources = getSelectedResources();
- for (int i = 0; i < resources.length; i++) {
- RepositoryProvider provider = RepositoryProvider.getProvider(resources[i].getProject());
- List list = (List) result.get(provider);
+ for (IResource resource : resources) {
+ RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject());
+ List<IResource> list = result.get(provider);
if (list == null) {
- list = new ArrayList();
+ list = new ArrayList<>();
result.put(provider, list);
}
- list.add(resources[i]);
+ list.add(resource);
}
return result;
}
-
+
/**
* Return the selected resource mappings that are associated with the
* file system provider.
@@ -61,5 +62,5 @@ public abstract class FileSystemAction extends TeamAction {
protected ResourceMapping[] getSelectedMappings() {
return getSelectedResourceMappings(FileSystemPlugin.PROVIDER_ID);
}
-
+
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemMainPage.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemMainPage.java
index fb980c41b..9718fe19b 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemMainPage.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemMainPage.java
@@ -40,12 +40,12 @@ import org.eclipse.team.examples.filesystem.Policy;
* location can be accessed using the <code>getLocation()</code> method.
*/
public class FileSystemMainPage extends WizardPage {
-
+
private static final int COMBO_HISTORY_LENGTH = 5;
-
+
String location;
Combo locationCombo;
-
+
/*
* WizardPage constructor comment.
* @param pageName the name of the page
@@ -59,14 +59,14 @@ public class FileSystemMainPage extends WizardPage {
setDescription(description);
setTitle(title);
}
-
+
/*
* Creates a new checkbox instance and sets the default layout data.
*
* @param group the composite in which to create the checkbox
* @param label the string to set into the checkbox
* @return the new checkbox
- */
+ */
protected Button createCheckBox(Composite group, String label) {
Button button = new Button(group, SWT.CHECK | SWT.LEFT);
button.setText(label);
@@ -75,7 +75,7 @@ public class FileSystemMainPage extends WizardPage {
button.setLayoutData(data);
return button;
}
-
+
/*
* Utility method that creates a combo box
*
@@ -89,7 +89,7 @@ public class FileSystemMainPage extends WizardPage {
combo.setLayoutData(data);
return combo;
}
-
+
/*
* Creates composite control and sets the default layout data.
*
@@ -99,12 +99,12 @@ public class FileSystemMainPage extends WizardPage {
*/
protected Composite createComposite(Composite parent, int numColumns) {
Composite composite = new Composite(parent, SWT.NULL);
-
+
// GridLayout
GridLayout layout = new GridLayout();
layout.numColumns = numColumns;
composite.setLayout(layout);
-
+
// GridData
GridData data = new GridData();
data.verticalAlignment = GridData.FILL;
@@ -112,7 +112,7 @@ public class FileSystemMainPage extends WizardPage {
composite.setLayoutData(data);
return composite;
}
-
+
/*
* Utility method that creates a label instance
* and sets the default layout data.
@@ -130,7 +130,7 @@ public class FileSystemMainPage extends WizardPage {
label.setLayoutData(data);
return label;
}
-
+
/*
* Create a text field specific for this application
*
@@ -146,7 +146,7 @@ public class FileSystemMainPage extends WizardPage {
text.setLayoutData(data);
return text;
}
-
+
/*
* Adds an entry to a history, while taking care of duplicate history items
* and excessively long histories. The assumption is made that all histories
@@ -157,13 +157,13 @@ public class FileSystemMainPage extends WizardPage {
* @return the history with the new entry appended
*/
protected String[] addToHistory(String[] history, String newEntry) {
- ArrayList l = new ArrayList(Arrays.asList(history));
+ ArrayList<String> l = new ArrayList<>(Arrays.asList(history));
addToHistory(l, newEntry);
String[] r = new String[l.size()];
l.toArray(r);
return r;
}
-
+
/*
* Adds an entry to a history, while taking care of duplicate history items
* and excessively long histories. The assumption is made that all histories
@@ -172,19 +172,19 @@ public class FileSystemMainPage extends WizardPage {
* @param history the current history
* @param newEntry the entry to add to the history
*/
- protected void addToHistory(List history, String newEntry) {
+ protected void addToHistory(List<String> history, String newEntry) {
history.remove(newEntry);
history.add(0,newEntry);
-
+
// since only one new item was added, we can be over the limit
// by at most one item
if (history.size() > COMBO_HISTORY_LENGTH)
history.remove(COMBO_HISTORY_LENGTH);
}
-
+
/*
* Utility method to create an editable combo box
- *
+ *
* @param parent the parent of the combo box
* @return the created combo
*/
@@ -195,11 +195,12 @@ public class FileSystemMainPage extends WizardPage {
combo.setLayoutData(data);
return combo;
}
-
+
// Dialog store id constants
private static final String STORE_LOCATION =
- "ExamplesFSWizardMainPage.STORE_LOCATION";//$NON-NLS-1$
-
+ "ExamplesFSWizardMainPage.STORE_LOCATION";//$NON-NLS-1$
+
+ @Override
public void createControl(Composite parent) {
Composite composite = new Composite(parent, SWT.NULL);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
@@ -207,20 +208,20 @@ public class FileSystemMainPage extends WizardPage {
layout.numColumns = 2;
composite.setLayout(layout);
setControl(composite);
-
+
Label label = new Label(composite, SWT.NULL);
label.setText(Policy.bind("FileSystemMainPage.location")); //$NON-NLS-1$
label.setLayoutData(new GridData());
-
+
locationCombo = createEditableCombo(composite);
locationCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
locationCombo.addListener(SWT.Modify, e -> {
location = ((Combo)e.widget).getText();
- FileSystemMainPage.this.validateFields();
+ FileSystemMainPage.this.validateFields();
});
-
+
locationCombo.setFocus();
-
+
new Label(composite, SWT.NULL);
Button browse = new Button(composite, SWT.NULL);
browse.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
@@ -230,13 +231,13 @@ public class FileSystemMainPage extends WizardPage {
String directory = d.open();
if(directory!=null) {
locationCombo.setText(directory);
- }
+ }
});
-
+
initializeValues();
validateFields();
}
-
+
public String getLocation() {
return location;
}
@@ -253,8 +254,8 @@ public class FileSystemMainPage extends WizardPage {
if (settings != null) {
String[] locations = settings.getArray(STORE_LOCATION);
if (locations != null) {
- for (int i = 0; i < locations.length; i++) {
- locationCombo.add(locations[i]);
+ for (String location2 : locations) {
+ locationCombo.add(location2);
}
locationCombo.select(0);
}
@@ -270,12 +271,12 @@ public class FileSystemMainPage extends WizardPage {
String[] locations = settings.getArray(STORE_LOCATION);
if (locations == null) locations = new String[0];
locations = addToHistory(locations, locationCombo.getText());
- settings.put(STORE_LOCATION, locations);
+ settings.put(STORE_LOCATION, locations);
}
}
-
+
/*
- * Validates the contents of the editable fields and set page completion
+ * Validates the contents of the editable fields and set page completion
* and error messages appropriately.
*/
void validateFields() {
@@ -289,7 +290,7 @@ public class FileSystemMainPage extends WizardPage {
if(!file.exists() || !file.isDirectory()) {
setErrorMessage(Policy.bind("FileSystemMainPage.notValidLocation")); //$NON-NLS-1$
setPageComplete(false);
- return;
+ return;
}
setErrorMessage(null);
setPageComplete(true);
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemOperation.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemOperation.java
index a1e6e5cb3..0f485c77f 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemOperation.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemOperation.java
@@ -14,13 +14,16 @@
package org.eclipse.team.examples.filesystem.ui;
import java.lang.reflect.InvocationTargetException;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceTraversal;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.mapping.ISynchronizationScope;
import org.eclipse.team.core.subscribers.SubscriberScopeManager;
@@ -41,7 +44,7 @@ public abstract class FileSystemOperation extends ModelOperation {
public static SubscriberScopeManager createScopeManager(String name, ResourceMapping[] inputMappings) {
return new SubscriberScopeManager(name, inputMappings, FileSystemSubscriber.getInstance(), true);
}
-
+
/**
* Create a file system operation.
* @param part the part from which the operation was launched
@@ -51,19 +54,16 @@ public abstract class FileSystemOperation extends ModelOperation {
super(part, manager);
}
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.synchronize.ModelOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
+ @Override
protected void execute(IProgressMonitor monitor) throws InvocationTargetException {
try {
- Map providerToTraversals = getProviderToTraversalsMap();
+ Map<FileSystemProvider, CompoundResourceTraversal> providerToTraversals = getProviderToTraversalsMap();
monitor.beginTask(getTaskName(), providerToTraversals.size() * 100);
monitor.setTaskName(getTaskName());
- for (Iterator iter = providerToTraversals.keySet().iterator(); iter.hasNext();) {
- FileSystemProvider provider = (FileSystemProvider) iter.next();
+ for (FileSystemProvider provider : providerToTraversals.keySet()) {
ResourceTraversal[] traversals = getTraversals(providerToTraversals, provider);
- execute(provider,
- traversals,
+ execute(provider,
+ traversals,
SubMonitor.convert(monitor, 100));
}
} catch (CoreException e) {
@@ -77,25 +77,22 @@ public abstract class FileSystemOperation extends ModelOperation {
* Return a map of FileSystemProvider to ResourceTraversals.
* @return a map of FileSystemProvider to ResourceTraversals
*/
- private Map getProviderToTraversalsMap() {
- HashMap result = new HashMap();
+ private Map<FileSystemProvider, CompoundResourceTraversal> getProviderToTraversalsMap() {
+ HashMap<FileSystemProvider, CompoundResourceTraversal> result = new HashMap<>();
ISynchronizationScope scope = getScope();
ResourceMapping[] mappings = scope.getMappings();
- for (int i = 0; i < mappings.length; i++) {
- ResourceMapping mapping = mappings[i];
+ for (ResourceMapping mapping : mappings) {
ResourceTraversal[] traversals = scope.getTraversals(mapping);
- for (int j = 0; j < traversals.length; j++) {
- ResourceTraversal traversal = traversals[j];
+ for (ResourceTraversal traversal : traversals) {
IResource[] resources = traversal.getResources();
- for (int k = 0; k < resources.length; k++) {
- IResource resource = resources[k];
+ for (IResource resource : resources) {
recordResourceAndDepth(result, resource, traversal.getDepth());
}
}
}
return result;
}
-
+
/**
* Return the file system provider associated with the given project or <code>null</code>
* if the project is not mapped to the file system provider.
@@ -105,11 +102,12 @@ public abstract class FileSystemOperation extends ModelOperation {
protected FileSystemProvider getProviderFor(IProject project) {
return (FileSystemProvider)RepositoryProvider.getProvider(project, FileSystemPlugin.PROVIDER_ID);
}
-
- private void recordResourceAndDepth(HashMap providerToTraversals, IResource resource, int depth) {
+
+ private void recordResourceAndDepth(HashMap<FileSystemProvider, CompoundResourceTraversal> providerToTraversals,
+ IResource resource, int depth) {
FileSystemProvider provider = getProviderFor(resource.getProject());
if (provider != null) {
- CompoundResourceTraversal traversal = (CompoundResourceTraversal)providerToTraversals.get(provider);
+ CompoundResourceTraversal traversal = providerToTraversals.get(provider);
if (traversal == null) {
traversal = new CompoundResourceTraversal();
providerToTraversals.put(provider, traversal);
@@ -125,8 +123,9 @@ public abstract class FileSystemOperation extends ModelOperation {
* @param provider the provider
* @return the traversals for the given provider
*/
- private ResourceTraversal[] getTraversals(Map providerToTraversals, FileSystemProvider provider) {
- CompoundResourceTraversal traversal = (CompoundResourceTraversal)providerToTraversals.get(provider);
+ private ResourceTraversal[] getTraversals(Map<FileSystemProvider, CompoundResourceTraversal> providerToTraversals,
+ FileSystemProvider provider) {
+ CompoundResourceTraversal traversal = providerToTraversals.get(provider);
return traversal.asTraversals();
}
@@ -144,10 +143,8 @@ public abstract class FileSystemOperation extends ModelOperation {
* @return the task name for this operation
*/
protected abstract String getTaskName();
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.TeamOperation#canRunAsJob()
- */
+
+ @Override
protected boolean canRunAsJob() {
return true;
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ModelPutAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ModelPutAction.java
index 037b2e44d..c9233bb46 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ModelPutAction.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ModelPutAction.java
@@ -14,7 +14,9 @@
package org.eclipse.team.examples.filesystem.ui;
import java.lang.reflect.InvocationTargetException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.runtime.IStatus;
@@ -36,6 +38,7 @@ public class ModelPutAction extends ModelParticipantAction {
super(text, configuration);
}
+ @Override
protected boolean isEnabledForSelection(IStructuredSelection selection) {
// Only enable the put in outgoing or both modes
int mode = getConfiguration().getMode();
@@ -46,19 +49,17 @@ public class ModelPutAction extends ModelParticipantAction {
}
private ResourceMapping[] getResourceMappings(IStructuredSelection selection) {
- List mappings = new ArrayList();
+ List<ResourceMapping> mappings = new ArrayList<>();
for (Iterator iter = selection.iterator(); iter.hasNext();) {
Object element = iter.next();
ResourceMapping mapping = Utils.getResourceMapping(element);
if (mapping != null)
mappings.add(mapping);
}
- return (ResourceMapping[]) mappings.toArray(new ResourceMapping[mappings.size()]);
+ return mappings.toArray(new ResourceMapping[mappings.size()]);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.Action#run()
- */
+
+ @Override
public void run() {
ResourceMapping[] resourceMappings = getResourceMappings(getStructuredSelection());
SubscriberScopeManager manager = FileSystemOperation.createScopeManager("Put", resourceMappings);
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/NonSyncModelMergePage.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/NonSyncModelMergePage.java
index cbc4b0c12..b6cba56b9 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/NonSyncModelMergePage.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/NonSyncModelMergePage.java
@@ -14,17 +14,38 @@
package org.eclipse.team.examples.filesystem.ui;
import java.lang.reflect.InvocationTargetException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.resources.mapping.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jface.action.*;
-import org.eclipse.jface.viewers.*;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.mapping.IModelProviderDescriptor;
+import org.eclipse.core.resources.mapping.ModelProvider;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
import org.eclipse.team.core.diff.IDiff;
import org.eclipse.team.core.mapping.IMergeContext;
import org.eclipse.team.core.mapping.provider.ResourceDiffTree;
@@ -39,15 +60,16 @@ import org.eclipse.ui.part.Page;
* This class provides the page for the {@link NonSyncMergePart}.
*/
public class NonSyncModelMergePage extends Page {
-
+
IMergeContext context;
TreeViewer viewer;
List mappings;
-
+
/*
* Content provider that returns the list of conflicting mappings
*/
class PageContentProvider implements ITreeContentProvider {
+ @Override
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof IMergeContext) {
if (mappings == null)
@@ -57,33 +79,39 @@ public class NonSyncModelMergePage extends Page {
}
return new Object[0];
}
+ @Override
public Object getParent(Object element) {
if (element instanceof ResourceMapping) {
return context;
}
return null;
}
+ @Override
public boolean hasChildren(Object element) {
if (element instanceof IMergeContext) {
return true;
}
return false;
}
+ @Override
public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}
+ @Override
public void dispose() {
// Nothing to do
}
+ @Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// Nothing to do
}
}
-
+
/*
* Label provider that provides a label and image for conflicting resource mappings
*/
class PageLabelProvider extends LabelProvider {
+ @Override
public String getText(Object element) {
if (element instanceof ResourceMapping) {
ResourceMapping mapping = (ResourceMapping) element;
@@ -97,6 +125,7 @@ public class NonSyncModelMergePage extends Page {
}
return super.getText(element);
}
+ @Override
public Image getImage(Object element) {
if (element instanceof ICompareInput) {
ICompareInput ci = (ICompareInput) element;
@@ -116,7 +145,8 @@ public class NonSyncModelMergePage extends Page {
/*
* Sorter that sorts mappings by model and then name
*/
- class PageSorter extends ViewerSorter {
+ class PageSorter extends ViewerComparator {
+ @Override
public int compare(Viewer viewer, Object e1, Object e2) {
if (e1 instanceof ResourceMapping && e2 instanceof ResourceMapping) {
ResourceMapping m1 = (ResourceMapping) e1;
@@ -139,45 +169,43 @@ public class NonSyncModelMergePage extends Page {
return "";
}
}
-
+
public NonSyncModelMergePage(IMergeContext context) {
super();
this.context = context;
}
-
+
/**
* Create the list of all mappings that overlap with the out-of-sync files.
*/
public void computeMappings(IProgressMonitor monitor) {
- IModelProviderDescriptor[] descriptors = ModelProvider.getModelProviderDescriptors();
- mappings = new ArrayList();
- for (int i = 0; i < descriptors.length; i++) {
- IModelProviderDescriptor descriptor = descriptors[i];
- // Get the subset of files that this model provider cares about
- try {
+ IModelProviderDescriptor[] descriptors = ModelProvider.getModelProviderDescriptors();
+ mappings = new ArrayList();
+ for (IModelProviderDescriptor descriptor : descriptors) {
+ // Get the subset of files that this model provider cares about
+ try {
IResource[] resources = descriptor.getMatchingResources(getOutOfSyncFiles());
if (resources.length > 0) {
- ModelProvider provider = descriptor.getModelProvider();
- // Get the mappings for those resources
- ResourceMapping[] mappings = provider.getMappings(resources, new SynchronizationResourceMappingContext(context), monitor);
- this.mappings.addAll(Arrays.asList(mappings ));
+ ModelProvider provider = descriptor.getModelProvider();
+ // Get the mappings for those resources
+ ResourceMapping[] mappings = provider.getMappings(resources, new SynchronizationResourceMappingContext(context), monitor);
+ this.mappings.addAll(Arrays.asList(mappings ));
}
} catch (CoreException e) {
FileSystemPlugin.log(e);
}
- }
+ }
}
private IResource[] getOutOfSyncFiles() {
IDiff[] diffs = getContext().getDiffTree().getDiffs(ResourcesPlugin.getWorkspace().getRoot(), IResource.DEPTH_INFINITE);
- List result = new ArrayList();
- for (int i = 0; i < diffs.length; i++) {
- IDiff diff = diffs[i];
+ List<IResource> result = new ArrayList<>();
+ for (IDiff diff : diffs) {
IResource resource = ResourceDiffTree.getResourceFor(diff);
if (resource.getType() == IResource.FILE)
result.add(resource);
}
- return (IResource[]) result.toArray(new IResource[result.size()]);
+ return result.toArray(new IResource[result.size()]);
}
/**
@@ -188,14 +216,12 @@ public class NonSyncModelMergePage extends Page {
return context;
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.Page#createControl(org.eclipse.swt.widgets.Composite)
- */
+ @Override
public void createControl(Composite parent) {
viewer = new TreeViewer(parent);
viewer.setContentProvider(new PageContentProvider());
viewer.setLabelProvider(new PageLabelProvider());
- viewer.setSorter(new PageSorter());
+ viewer.setComparator(new PageSorter());
hookContextMenu(viewer);
viewer.setInput(context);
}
@@ -204,7 +230,7 @@ public class NonSyncModelMergePage extends Page {
* Hook the context menu to display the Overwrite and Mark-as-merged actions
*/
private void hookContextMenu(final TreeViewer viewer) {
- final MenuManager menuMgr = new MenuManager();
+ final MenuManager menuMgr = new MenuManager();
menuMgr.setRemoveAllWhenShown(true);
menuMgr.addMenuListener(manager -> fillContextMenu(manager));
Menu menu = menuMgr.createContextMenu(viewer.getControl());
@@ -217,7 +243,7 @@ public class NonSyncModelMergePage extends Page {
*/
protected void fillContextMenu(IMenuManager manager) {
/*
- * Add a mark as merged action. Because we are not using the
+ * Add a mark as merged action. Because we are not using the
* Synchronization framework and, more specifically, the
* Common Navigator content provider for the model providers,
* we do not have access to the merge handlers of the model.
@@ -226,6 +252,7 @@ public class NonSyncModelMergePage extends Page {
* unselected model elements.
*/
Action markAsMerged = new Action("Mark as Merged") {
+ @Override
public void run() {
try {
final IStructuredSelection selection = viewer.getStructuredSelection();
@@ -256,9 +283,8 @@ public class NonSyncModelMergePage extends Page {
}
private IDiff[] getDiffs(Object[] elements, IProgressMonitor monitor) {
- Set result = new HashSet();
- for (int i = 0; i < elements.length; i++) {
- Object element = elements[i];
+ Set<IDiff> result = new HashSet<>();
+ for (Object element : elements) {
try {
if (element instanceof ResourceMapping) {
ResourceMapping mapping = (ResourceMapping) element;
@@ -269,7 +295,7 @@ public class NonSyncModelMergePage extends Page {
FileSystemPlugin.log(e);
}
}
- return (IDiff[]) result.toArray(new IDiff[result.size()]);
+ return result.toArray(new IDiff[result.size()]);
}
/**
@@ -278,23 +304,19 @@ public class NonSyncModelMergePage extends Page {
* @return
*/
protected boolean checkForModelOverlap(IDiff[] diffs, IProgressMonitor monitor) {
- // TODO: This check should see if the diffs are also part of mappings
- // that are not included in the selection.
+ // TODO: This check should see if the diffs are also part of mappings
+ // that are not included in the selection.
return true;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.Page#getControl()
- */
+
+ @Override
public Control getControl() {
if (viewer != null)
return viewer.getControl();
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.Page#setFocus()
- */
+ @Override
public void setFocus() {
if (viewer != null)
viewer.getControl().setFocus();
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ProjectSetSerializer.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ProjectSetSerializer.java
index 54f469c9f..3d5e11bdf 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ProjectSetSerializer.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ProjectSetSerializer.java
@@ -18,41 +18,40 @@ import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.*;
-import org.eclipse.team.examples.filesystem.*;
+import org.eclipse.team.core.IProjectSetSerializer;
+import org.eclipse.team.core.RepositoryProvider;
+import org.eclipse.team.examples.filesystem.FileSystemPlugin;
+import org.eclipse.team.examples.filesystem.FileSystemProvider;
+import org.eclipse.team.examples.filesystem.Policy;
/**
* This is an old-style (pre-3.0) project set serializer used to test backwards compatibility
*/
public class ProjectSetSerializer implements IProjectSetSerializer {
- /* (non-Javadoc)
- * @see org.eclipse.team.core.IProjectSetSerializer#asReference(org.eclipse.core.resources.IProject[], java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
- */
+ @Override
public String[] asReference(IProject[] providerProjects, Object context, IProgressMonitor monitor) {
Assert.isTrue(context instanceof Shell);
- List refs = new ArrayList();
- for (int i = 0; i < providerProjects.length; i++) {
- IProject project = providerProjects[i];
+ List<String> refs = new ArrayList<>();
+ for (IProject project : providerProjects) {
FileSystemProvider provider = (FileSystemProvider)RepositoryProvider.getProvider(project, FileSystemPlugin.PROVIDER_ID);
if (provider != null) {
refs.add(asReference(provider));
}
}
- return (String[]) refs.toArray(new String[refs.size()]);
+ return refs.toArray(new String[refs.size()]);
}
- /* (non-Javadoc)
- * @see org.eclipse.team.core.IProjectSetSerializer#addToWorkspace(java.lang.String[], java.lang.String, java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
- */
+ @Override
public IProject[] addToWorkspace(String[] referenceStrings, String filename, Object context, IProgressMonitor monitor) {
Assert.isTrue(context instanceof Shell);
- List projects = new ArrayList();
- for (int i = 0; i < referenceStrings.length; i++) {
- String string = referenceStrings[i];
+ List<IProject> projects = new ArrayList<>();
+ for (String string : referenceStrings) {
String projectName = getProjectName(string);
String path = getPath(string);
if (projectName != null && path != null) {
@@ -64,14 +63,14 @@ public class ProjectSetSerializer implements IProjectSetSerializer {
projects.add(project);
} catch (CoreException e) {
ErrorDialog.openError(
- (Shell)context,
- Policy.bind("ConfigurationWizard.errorMapping"), //$NON-NLS-1$
- Policy.bind("ConfigurationWizard.error"), //$NON-NLS-1$
- e.getStatus());
+ (Shell)context,
+ Policy.bind("ConfigurationWizard.errorMapping"), //$NON-NLS-1$
+ Policy.bind("ConfigurationWizard.error"), //$NON-NLS-1$
+ e.getStatus());
}
}
}
- return (IProject[]) projects.toArray(new IProject[projects.size()]);
+ return projects.toArray(new IProject[projects.size()]);
}
/**
@@ -81,7 +80,7 @@ public class ProjectSetSerializer implements IProjectSetSerializer {
private String asReference(FileSystemProvider provider) {
return provider.getProject().getName() + "," + provider.getRoot().toString(); //$NON-NLS-1$
}
-
+
/**
* @param string
* @return
@@ -91,7 +90,7 @@ public class ProjectSetSerializer implements IProjectSetSerializer {
if (i == -1) return null;
return string.substring(0, i);
}
-
+
/**
* @param string
* @return
@@ -101,7 +100,7 @@ public class ProjectSetSerializer implements IProjectSetSerializer {
if (i == -1) return null;
return string.substring(i + 1);
}
-
+
/**
* @param projectName
* @return
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySubscriber.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySubscriber.java
index 182ac5755..a0d5c53d1 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySubscriber.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/localhistory/LocalHistorySubscriber.java
@@ -33,40 +33,45 @@ import org.eclipse.team.core.variants.IResourceVariantComparator;
public class LocalHistorySubscriber extends Subscriber {
private LocalHistoryVariantComparator comparator;
-
+
public LocalHistorySubscriber() {
this.comparator = new LocalHistoryVariantComparator();
}
-
+
+ @Override
public String getName() {
return "Local History Subscriber"; //$NON-NLS-1$
}
/**
- * @param resource the resource being tested
+ * @param resource the resource being tested
*/
+ @Override
public boolean isSupervised(IResource resource) {
// all resources in the workspace can potentially have resource history
return true;
}
+ @Override
public IResource[] members(IResource resource) throws TeamException {
try {
if(resource.getType() == IResource.FILE)
return new IResource[0];
IContainer container = (IContainer)resource;
- List existingChildren = new ArrayList(Arrays.asList(container.members()));
+ List<IResource> existingChildren = new ArrayList<>(Arrays.asList(container.members()));
existingChildren.addAll(Arrays.asList(container.findDeletedMembersWithHistory(IResource.DEPTH_INFINITE, null)));
- return (IResource[]) existingChildren.toArray(new IResource[existingChildren.size()]);
+ return existingChildren.toArray(new IResource[existingChildren.size()]);
} catch (CoreException e) {
throw TeamException.asTeamException(e);
}
}
+ @Override
public IResource[] roots() {
return ResourcesPlugin.getWorkspace().getRoot().getProjects();
}
+ @Override
public SyncInfo getSyncInfo(IResource resource) throws TeamException {
try {
IResourceVariant variant = null;
@@ -76,7 +81,7 @@ public class LocalHistorySubscriber extends Subscriber {
if(states.length > 0) {
// last state only
variant = new LocalHistoryVariant(states[0]);
- }
+ }
}
SyncInfo info = new LocalHistorySyncInfo(resource, variant, comparator);
info.init();
@@ -86,6 +91,7 @@ public class LocalHistorySubscriber extends Subscriber {
}
}
+ @Override
public IResourceVariantComparator getResourceComparator() {
return comparator;
}
@@ -99,6 +105,7 @@ public class LocalHistorySubscriber extends Subscriber {
* progress monitor, or <code>null</code> if progress reporting
* and cancellation are not desired
*/
+ @Override
public void refresh(IResource[] resources, int depth, IProgressMonitor monitor) {
// do nothing
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelContainer.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelContainer.java
index 3cb6e9bbf..8bbee3cd9 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelContainer.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelContainer.java
@@ -16,7 +16,11 @@ package org.eclipse.team.examples.model;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.resources.*;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
public abstract class ModelContainer extends ModelResource {
@@ -24,16 +28,16 @@ public abstract class ModelContainer extends ModelResource {
protected ModelContainer(IContainer container) {
super(container);
}
-
+
protected IContainer getContainer() {
return (IContainer)getResource();
}
-
+
+ @Override
public ModelObject[] getChildren() throws CoreException {
IResource[] members = getContainer().members();
- List result = new ArrayList();
- for (int i = 0; i < members.length; i++) {
- IResource resource = members[i];
+ List<ModelObject> result = new ArrayList<>();
+ for (IResource resource : members) {
if (resource instanceof IFolder) {
result.add(new ModelFolder((IFolder) resource));
} else if (ModelObjectDefinitionFile.isModFile(resource)) {
@@ -42,7 +46,7 @@ public abstract class ModelContainer extends ModelResource {
result.add(new ModelProject((IProject) resource));
}
}
- return (ModelObject[]) result.toArray(new ModelObject[result.size()]);
+ return result.toArray(new ModelObject[result.size()]);
}
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelObjectDefinitionFile.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelObjectDefinitionFile.java
index 204012122..34e117628 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelObjectDefinitionFile.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelObjectDefinitionFile.java
@@ -13,12 +13,23 @@
*******************************************************************************/
package org.eclipse.team.examples.model;
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.examples.filesystem.FileSystemPlugin;
@@ -34,40 +45,36 @@ public class ModelObjectDefinitionFile extends ModelFile {
}
return false;
}
-
+
public static IResource[] getReferencedResources(String projectName, IStorage storage) throws CoreException {
if (storage == null)
return new IResource[0];
- List result = new ArrayList();
+ List<IResource> result = new ArrayList<>();
String[] filePaths = readLines(storage);
- for (int i = 0; i < filePaths.length; i++) {
- String path = filePaths[i];
+ for (String path : filePaths) {
IFile file = getFile(projectName, path);
- if (file != null
- && file.getFileExtension() != null
+ if (file != null
+ && file.getFileExtension() != null
&& file.getFileExtension().equals(ModelObjectElementFile.MODEL_OBJECT_ELEMENTFILE_EXTENSION)) {
result.add(file);
}
}
- return (IResource[]) result.toArray(new IResource[result.size()]);
+ return result.toArray(new IResource[result.size()]);
}
-
+
public ModelObjectDefinitionFile(IFile file) {
super(file);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.team.examples.model.ModelObject#getChildren()
- */
+
+ @Override
public ModelObject[] getChildren() throws CoreException {
return getModelObjectElementFiles();
}
public ModelObjectElementFile[] getModelObjectElementFiles() throws CoreException {
- List result = new ArrayList();
+ List<ModelObjectElementFile> result = new ArrayList<>();
String[] filePaths = readLines((IFile)getResource());
- for (int i = 0; i < filePaths.length; i++) {
- String path = filePaths[i];
+ for (String path : filePaths) {
IFile file = getFile(getResource().getProject().getName(), path);
if (file != null) {
ModelObjectElementFile moeFile = getMoeFile(file);
@@ -75,19 +82,19 @@ public class ModelObjectDefinitionFile extends ModelFile {
result.add(moeFile);
}
}
- return (ModelObjectElementFile[]) result.toArray(new ModelObjectElementFile[result.size()]);
+ return result.toArray(new ModelObjectElementFile[result.size()]);
}
private static String[] readLines(IStorage file) throws CoreException {
BufferedReader reader = new BufferedReader(new InputStreamReader(file.getContents()));
String line = null;
- List result = new ArrayList();
+ List<String> result = new ArrayList<>();
try {
while ((line = reader.readLine()) != null) {
result.add(line.trim());
}
} catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, FileSystemPlugin.ID, 0,
+ throw new CoreException(new Status(IStatus.ERROR, FileSystemPlugin.ID, 0,
NLS.bind("Error reading from file {0}", file.getFullPath()), e));
} finally {
try {
@@ -96,19 +103,18 @@ public class ModelObjectDefinitionFile extends ModelFile {
// Ignore
}
}
- return (String[]) result.toArray(new String[result.size()]);
+ return result.toArray(new String[result.size()]);
}
private void writeLines(String[] strings) throws CoreException {
StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < strings.length; i++) {
- String string = strings[i];
+ for (String string : strings) {
buffer.append(string);
buffer.append("\n");
}
((IFile)getResource()).setContents(new ByteArrayInputStream(buffer.toString().getBytes()), false, true, null);
}
-
+
private ModelObjectElementFile getMoeFile(IFile file) {
if (ModelObjectElementFile.isMoeFile(file)) {
return new ModelObjectElementFile(this, file);
@@ -135,38 +141,35 @@ public class ModelObjectDefinitionFile extends ModelFile {
public void remove(ModelObjectElementFile file) throws CoreException {
ModelObjectElementFile[] files = getModelObjectElementFiles();
- List paths = new ArrayList();
- for (int i = 0; i < files.length; i++) {
- ModelObjectElementFile child = files[i];
+ List<String> paths = new ArrayList<>();
+ for (ModelObjectElementFile child : files) {
if (!child.equals(file)) {
paths.add(child.getResource().getProjectRelativePath().toString());
}
}
- writeLines((String[]) paths.toArray(new String[paths.size()]));
+ writeLines(paths.toArray(new String[paths.size()]));
}
+ @Override
public void delete() throws CoreException {
ModelObjectElementFile[] files = getModelObjectElementFiles();
super.delete();
- for (int i = 0; i < files.length; i++) {
- ModelObjectElementFile file = files[i];
+ for (ModelObjectElementFile file : files) {
file.getResource().delete(false, null);
}
}
public void setElements(IResource[] resources) throws CoreException {
- List paths = new ArrayList();
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
+ List<String> paths = new ArrayList<>();
+ for (IResource resource : resources) {
paths.add(resource.getProjectRelativePath().toString());
}
- writeLines((String[]) paths.toArray(new String[paths.size()]));
+ writeLines(paths.toArray(new String[paths.size()]));
}
public boolean hasMoe(IFile file) throws CoreException {
ModelObjectElementFile[] files = getModelObjectElementFiles();
- for (int i = 0; i < files.length; i++) {
- ModelObjectElementFile child = files[i];
+ for (ModelObjectElementFile child : files) {
if (child.getResource().equals(file))
return true;
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelProject.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelProject.java
index e40914a7c..00aa326fe 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelProject.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ModelProject.java
@@ -29,19 +29,19 @@ public class ModelProject extends ModelContainer {
IProjectDescription description = project.getDescription();
return description.hasNature(ModelNature.NATURE_ID);
}
-
+
public static void makeModProject(IProject project, IProgressMonitor monitor) throws CoreException {
IProjectDescription description = project.getDescription();
String[] natureIds = description.getNatureIds();
- List result = new ArrayList();
- for (int i = 0; i < natureIds.length; i++) {
- result.add(natureIds[i]);
+ List<String> result = new ArrayList<>();
+ for (String natureId : natureIds) {
+ result.add(natureId);
}
result.add(ModelNature.NATURE_ID);
- description.setNatureIds((String[]) result.toArray(new String[result.size()]));
+ description.setNatureIds(result.toArray(new String[result.size()]));
project.setDescription(description, monitor);
}
-
+
public ModelProject(IProject project) {
super(project);
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/PluginManifestChangeTracker.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/PluginManifestChangeTracker.java
index 93614788c..7b8e57f83 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/PluginManifestChangeTracker.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/PluginManifestChangeTracker.java
@@ -13,60 +13,70 @@
*******************************************************************************/
package org.eclipse.team.examples.model;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.mapping.ChangeTracker;
import org.eclipse.team.examples.filesystem.FileSystemPlugin;
public class PluginManifestChangeTracker extends ChangeTracker {
-
- Set manifestFilePaths;
-
+
+ Set<IPath> manifestFilePaths;
+
public PluginManifestChangeTracker() {
- manifestFilePaths = new HashSet();
+ manifestFilePaths = new HashSet<>();
manifestFilePaths.add(new Path(null, "plugin.xml"));
manifestFilePaths.add(new Path(null, "plugin.properties"));
manifestFilePaths.add(new Path(null, "build.properties"));
manifestFilePaths.add(new Path(null, "META-INF/MANIFEST.MF"));
}
+ @Override
protected boolean isProjectOfInterest(IProject project) {
return super.isProjectOfInterest(project) && hasPDENature(project);
}
-
+
private boolean hasPDENature(IProject project) {
try {
return project.getDescription().hasNature("org.eclipse.pde.PluginNature");
} catch (CoreException e) {
- FileSystemPlugin.log(new Status(e.getStatus().getSeverity(), FileSystemPlugin.ID, 0,
+ FileSystemPlugin.log(new Status(e.getStatus().getSeverity(), FileSystemPlugin.ID, 0,
NLS.bind("Could not obtain project description for {0}", project.getName()), e));
}
return false;
}
+ @Override
protected void handleChanges(IProject project, IResource[] resources) {
handleProjectChange(project);
}
+ @Override
protected void handleProjectChange(IProject project) {
- List changes = new ArrayList();
- for (Iterator iter = manifestFilePaths.iterator(); iter.hasNext();) {
- IPath path = (IPath) iter.next();
+ List<IFile> changes = new ArrayList<>();
+ for (IPath path : manifestFilePaths) {
IFile file = project.getFile(path);
try {
if (isModified(file)) {
changes.add(file);
}
} catch (CoreException e) {
- FileSystemPlugin.log(new Status(e.getStatus().getSeverity(), FileSystemPlugin.ID, 0,
+ FileSystemPlugin.log(new Status(e.getStatus().getSeverity(), FileSystemPlugin.ID, 0,
NLS.bind("Could not obtain diff for {0}", file.getFullPath().toString()), e));
}
}
if (changes.size() > 1) {
- groupInSet(project, (IFile[]) changes.toArray(new IFile[changes.size()]));
+ groupInSet(project, changes.toArray(new IFile[changes.size()]));
}
}
@@ -75,7 +85,7 @@ public class PluginManifestChangeTracker extends ChangeTracker {
try {
ensureGrouped(project, name, files);
} catch (CoreException e) {
- FileSystemPlugin.log(new Status(e.getStatus().getSeverity(), FileSystemPlugin.ID, 0,
+ FileSystemPlugin.log(new Status(e.getStatus().getSeverity(), FileSystemPlugin.ID, 0,
NLS.bind("Could not create change set {0}", name), e));
}
}
@@ -84,6 +94,7 @@ public class PluginManifestChangeTracker extends ChangeTracker {
return "Plugin manifest files for " + project.getName();
}
+ @Override
protected boolean isResourceOfInterest(IResource resource) {
return manifestFilePaths.contains(resource.getProjectRelativePath());
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ExampleModelProvider.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ExampleModelProvider.java
index d9c5db69f..1dd2c5d1d 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ExampleModelProvider.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ExampleModelProvider.java
@@ -16,70 +16,79 @@ package org.eclipse.team.examples.model.mapping;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.resources.mapping.*;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.mapping.ModelStatus;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceMappingContext;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.examples.filesystem.FileSystemPlugin;
-import org.eclipse.team.examples.model.*;
+import org.eclipse.team.examples.model.ModelObject;
+import org.eclipse.team.examples.model.ModelObjectDefinitionFile;
+import org.eclipse.team.examples.model.ModelObjectElementFile;
+import org.eclipse.team.examples.model.ModelProject;
/**
* The model provider for our example
*/
public class ExampleModelProvider extends
- org.eclipse.core.resources.mapping.ModelProvider {
+org.eclipse.core.resources.mapping.ModelProvider {
public static final String ID = "org.eclipse.team.examples.filesystem.modelProvider";
public ExampleModelProvider() {
super();
}
-
+
+ @Override
public IStatus validateChange(IResourceDelta delta, IProgressMonitor monitor) {
// Visit the changes in the delta to look for changes we care about
- final List problems = new ArrayList();
+ final List<IStatus> problems = new ArrayList<>();
try {
- delta.accept(new IResourceDeltaVisitor() {
- public boolean visit(IResourceDelta delta) throws CoreException {
- IResource resource = delta.getResource();
- if (ModelObjectElementFile.isMoeFile(resource)) {
- // Removal may leave a stale reference in a MOD file
- if (delta.getKind() == IResourceDelta.REMOVED) {
- IStatus status = new ModelStatus(IStatus.ERROR, FileSystemPlugin.ID, getDescriptor().getId(),
- NLS.bind("Deleting file {0} may corrupt any model definition that references it.", resource.getFullPath()));
- problems.add(status);
- }
+ delta.accept(delta1 -> {
+ IResource resource = delta1.getResource();
+ if (ModelObjectElementFile.isMoeFile(resource)) {
+ // Removal may leave a stale reference in a MOD file
+ if (delta1.getKind() == IResourceDelta.REMOVED) {
+ IStatus status1 = new ModelStatus(IStatus.ERROR, FileSystemPlugin.ID, getDescriptor().getId(),
+ NLS.bind("Deleting file {0} may corrupt any model definition that references it.", resource.getFullPath()));
+ problems.add(status1);
+ }
+ }
+ if (ModelObjectDefinitionFile.isModFile(resource)) {
+ // Removal may leave unreferenced MOE files around
+ if (delta1.getKind() == IResourceDelta.REMOVED) {
+ IStatus status2 = new ModelStatus(IStatus.WARNING, FileSystemPlugin.ID, getDescriptor().getId(),
+ NLS.bind("Deleting file {0} may result in unreferenced element files.", resource.getFullPath()));
+ problems.add(status2);
}
- if (ModelObjectDefinitionFile.isModFile(resource)) {
- // Removal may leave unreferenced MOE files around
- if (delta.getKind() == IResourceDelta.REMOVED) {
- IStatus status = new ModelStatus(IStatus.WARNING, FileSystemPlugin.ID, getDescriptor().getId(),
- NLS.bind("Deleting file {0} may result in unreferenced element files.", resource.getFullPath()));
- problems.add(status);
- }
- if (delta.getKind() == IResourceDelta.ADDED
- && ((delta.getFlags() & IResourceDelta.COPIED_FROM) > 0)) {
- // Copying will result in two MOD files that reference the same elements
- IStatus status = new ModelStatus(IStatus.ERROR, FileSystemPlugin.ID, getDescriptor().getId(),
- NLS.bind("Copying file {0} may corrupt the model defintion.", delta.getMovedFromPath()));
- problems.add(status);
- }
+ if (delta1.getKind() == IResourceDelta.ADDED
+ && ((delta1.getFlags() & IResourceDelta.COPIED_FROM) > 0)) {
+ // Copying will result in two MOD files that reference the same elements
+ IStatus status3 = new ModelStatus(IStatus.ERROR, FileSystemPlugin.ID, getDescriptor().getId(),
+ NLS.bind("Copying file {0} may corrupt the model defintion.", delta1.getMovedFromPath()));
+ problems.add(status3);
}
- return delta.getResource().getType() == IResource.ROOT
- || ModelProject.isModProject(delta.getResource().getProject());
}
+ return delta1.getResource().getType() == IResource.ROOT
+ || ModelProject.isModProject(delta1.getResource().getProject());
});
} catch (CoreException e) {
FileSystemPlugin.log(e);
}
if (problems.size() == 1)
- return (IStatus)problems.get(0);
+ return problems.get(0);
else if (problems.size() > 1) {
- return new MultiStatus(FileSystemPlugin.ID, 0, (IStatus[]) problems.toArray(new IStatus[problems.size()]), "Multiple potential side effects have been found.", null);
+ return new MultiStatus(FileSystemPlugin.ID, 0, problems.toArray(new IStatus[problems.size()]), "Multiple potential side effects have been found.", null);
}
return super.validateChange(delta, monitor);
}
-
+
+ @Override
public ResourceMapping[] getMappings(IResource resource, ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
if (ModelProject.isModProject(resource.getProject())) {
ModelObject object = ModelObject.create(resource);
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModResourceMapping.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModResourceMapping.java
index 2b347a177..02d97dcc4 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModResourceMapping.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModResourceMapping.java
@@ -18,10 +18,18 @@ import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.mapping.*;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.resources.mapping.RemoteResourceMappingContext;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceMappingContext;
+import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.team.examples.filesystem.FileSystemPlugin;
-import org.eclipse.team.examples.model.*;
+import org.eclipse.team.examples.model.ModelObject;
+import org.eclipse.team.examples.model.ModelObjectDefinitionFile;
+import org.eclipse.team.examples.model.ModelObjectElementFile;
+import org.eclipse.team.examples.model.ModelResource;
public class ModResourceMapping extends ModelResourceMapping {
@@ -29,63 +37,56 @@ public class ModResourceMapping extends ModelResourceMapping {
super(file);
}
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.mapping.ResourceMapping#getTraversals(org.eclipse.core.resources.mapping.ResourceMappingContext, org.eclipse.core.runtime.IProgressMonitor)
- */
+ @Override
public ResourceTraversal[] getTraversals(ResourceMappingContext context,
IProgressMonitor monitor) throws CoreException {
- Set resources = getLocalResources();
+ Set<IResource> resources = getLocalResources();
if (context instanceof RemoteResourceMappingContext) {
monitor.beginTask(null, IProgressMonitor.UNKNOWN);
RemoteResourceMappingContext remoteContext = (RemoteResourceMappingContext) context;
if (remoteContext.hasRemoteChange(getResource(), SubMonitor.convert(monitor, IProgressMonitor.UNKNOWN))) {
IResource[] remoteResources = ModelObjectDefinitionFile.getReferencedResources(
- getResource().getProject().getName(),
- remoteContext.fetchRemoteContents((IFile)getResource(),
+ getResource().getProject().getName(),
+ remoteContext.fetchRemoteContents((IFile)getResource(),
SubMonitor.convert(monitor, IProgressMonitor.UNKNOWN)));
- for (int i = 0; i < remoteResources.length; i++) {
- IResource resource = remoteResources[i];
+ for (IResource resource : remoteResources) {
resources.add(resource);
}
}
- if (remoteContext.isThreeWay()
+ if (remoteContext.isThreeWay()
&& remoteContext.hasLocalChange(getResource(), SubMonitor.convert(monitor, IProgressMonitor.UNKNOWN))) {
IResource[] remoteResources = ModelObjectDefinitionFile.getReferencedResources(
getResource().getProject().getName(),
- remoteContext.fetchBaseContents((IFile)getResource(),
+ remoteContext.fetchBaseContents((IFile)getResource(),
SubMonitor.convert(monitor, IProgressMonitor.UNKNOWN)));
- for (int i = 0; i < remoteResources.length; i++) {
- IResource resource = remoteResources[i];
+ for (IResource resource : remoteResources) {
resources.add(resource);
}
}
monitor.done();
}
- return new ResourceTraversal[] {
- new ResourceTraversal((IResource[]) resources.toArray(new IResource[resources.size()]),
+ return new ResourceTraversal[] {
+ new ResourceTraversal(resources.toArray(new IResource[resources.size()]),
IResource.DEPTH_ZERO, IResource.NONE)
- };
+ };
}
private IResource getResource() {
return ((ModelResource)getModelObject()).getResource();
}
-
- private Set getLocalResources() throws CoreException {
+
+ private Set<IResource> getLocalResources() throws CoreException {
ModelObjectDefinitionFile mdf = (ModelObjectDefinitionFile)getModelObject();
- Set resources = new HashSet();
+ Set<IResource> resources = new HashSet<>();
resources.add(mdf.getResource());
ModelObjectElementFile[] files = mdf.getModelObjectElementFiles();
- for (int i = 0; i < files.length; i++) {
- ModelObjectElementFile file = files[i];
+ for (ModelObjectElementFile file : files) {
resources.add(file.getResource());
}
return resources;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.mapping.ResourceMapping#contains(org.eclipse.core.resources.mapping.ResourceMapping)
- */
+
+ @Override
public boolean contains(ResourceMapping mapping) {
if (mapping instanceof ModelResourceMapping) {
ModelObject object = (ModelObject)mapping.getModelObject();
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelMerger.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelMerger.java
index 3e31fad77..7ddbe9a34 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelMerger.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/mapping/ModelMerger.java
@@ -33,7 +33,6 @@ import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.team.core.diff.FastDiffFilter;
import org.eclipse.team.core.diff.IDiff;
-import org.eclipse.team.core.diff.IDiffVisitor;
import org.eclipse.team.core.diff.IThreeWayDiff;
import org.eclipse.team.core.history.IFileRevision;
import org.eclipse.team.core.mapping.IMergeContext;
@@ -48,7 +47,7 @@ import org.eclipse.team.examples.model.ModelObjectDefinitionFile;
import org.eclipse.team.examples.model.ModelProject;
/**
- * A resource mapping merger for our example model
+ * A resource mapping merger for our example model
*/
public class ModelMerger extends ResourceMappingMerger {
@@ -61,13 +60,15 @@ public class ModelMerger extends ResourceMappingMerger {
/* (non-Javadoc)
* @see org.eclipse.team.core.mapping.ResourceMappingMerger#getModelProvider()
*/
+ @Override
protected org.eclipse.core.resources.mapping.ModelProvider getModelProvider() {
return provider;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.team.core.mapping.ResourceMappingMerger#merge(org.eclipse.team.core.mapping.IMergeContext, org.eclipse.core.runtime.IProgressMonitor)
*/
+ @Override
public IStatus merge(IMergeContext mergeContext, IProgressMonitor monitor) throws CoreException {
try {
IStatus status;
@@ -103,10 +104,9 @@ public class ModelMerger extends ResourceMappingMerger {
private IStatus mergeModelElements(IMergeContext mergeContext, IProgressMonitor monitor) throws CoreException {
try {
IDiff[] modeDiffs = getModDiffs(mergeContext);
- List failures = new ArrayList();
+ List<IDiff> failures = new ArrayList<>();
monitor.beginTask(null, 100 * modeDiffs.length);
- for (int i = 0; i < modeDiffs.length; i++) {
- IDiff diff = modeDiffs[i];
+ for (IDiff diff : modeDiffs) {
if (!mergeModelElement(mergeContext, diff, SubMonitor.convert(monitor, 100))) {
failures.add(diff);
}
@@ -121,32 +121,29 @@ public class ModelMerger extends ResourceMappingMerger {
}
private ResourceMapping[] getMappings(List failures) {
- List mappings = new ArrayList();
+ List<ResourceMapping> mappings = new ArrayList<>();
for (Iterator iter = failures.iterator(); iter.hasNext();) {
IDiff diff = (IDiff) iter.next();
IResource resource = ResourceDiffTree.getResourceFor(diff);
ModelObjectDefinitionFile file = (ModelObjectDefinitionFile)ModelObject.create(resource);
mappings.add(file.getAdapter(ResourceMapping.class));
}
- return (ResourceMapping[]) mappings.toArray(new ResourceMapping[mappings.size()]);
+ return mappings.toArray(new ResourceMapping[mappings.size()]);
}
/*
* Return all the diffs for MOD files.
*/
private IDiff[] getModDiffs(IMergeContext mergeContext) {
- final List result = new ArrayList();
- mergeContext.getDiffTree().accept(getModelProjectTraversals(mergeContext), new IDiffVisitor() {
- public boolean visit(IDiff diff) {
- IResource resource = ResourceDiffTree.getResourceFor(diff);
- if (ModelObjectDefinitionFile.isModFile(resource)) {
- result.add(diff);
- }
- return true;
+ final List<IDiff> result = new ArrayList<>();
+ mergeContext.getDiffTree().accept(getModelProjectTraversals(mergeContext), diff -> {
+ IResource resource = ResourceDiffTree.getResourceFor(diff);
+ if (ModelObjectDefinitionFile.isModFile(resource)) {
+ result.add(diff);
}
-
+ return true;
});
- return (IDiff[]) result.toArray(new IDiff[result.size()]);
+ return result.toArray(new IDiff[result.size()]);
}
/*
@@ -154,9 +151,8 @@ public class ModelMerger extends ResourceMappingMerger {
*/
private ResourceTraversal[] getModelProjectTraversals(IMergeContext mergeContext) {
IProject[] scopeProjects = mergeContext.getScope().getProjects();
- List modelProjects = new ArrayList();
- for (int i = 0; i < scopeProjects.length; i++) {
- IProject project = scopeProjects[i];
+ List<IResource> modelProjects = new ArrayList<>();
+ for (IProject project : scopeProjects) {
try {
if (ModelProject.isModProject(project)) {
modelProjects.add(project);
@@ -167,9 +163,9 @@ public class ModelMerger extends ResourceMappingMerger {
}
if (modelProjects.isEmpty())
return new ResourceTraversal[0];
- return new ResourceTraversal[] {
- new ResourceTraversal((IResource[]) modelProjects.toArray(new IResource[modelProjects.size()]),
- IResource.DEPTH_INFINITE, IResource.NONE)
+ return new ResourceTraversal[] {
+ new ResourceTraversal(modelProjects.toArray(new IResource[modelProjects.size()]),
+ IResource.DEPTH_INFINITE, IResource.NONE)
};
}
@@ -182,7 +178,7 @@ public class ModelMerger extends ResourceMappingMerger {
if (twd.getDirection() == IThreeWayDiff.INCOMING
|| twd.getDirection() == IThreeWayDiff.CONFLICTING) {
IResource resource = ResourceDiffTree.getResourceFor(diff);
-
+
// First, check if a change conflicts with a deletion
if (twd.getDirection() == IThreeWayDiff.CONFLICTING) {
if (!resource.exists())
@@ -190,7 +186,7 @@ public class ModelMerger extends ResourceMappingMerger {
if (((IResourceDiff)twd.getRemoteChange()).getAfterState() == null)
return false;
}
-
+
// First determine the element files and element file changes
IResourceDiff remoteChange = (IResourceDiff)twd.getRemoteChange();
IResource[] localElements = getReferencedResources(resource);
@@ -199,21 +195,21 @@ public class ModelMerger extends ResourceMappingMerger {
IResource[] addedElements = getAddedElements(baseElements, remoteElements);
// Trick: The removed elements can be obtained by reversing the base and remote and looking for added
IResource[] removedElements = getAddedElements(remoteElements, baseElements);
-
+
// Check to see if any removed elements have changed locally
if (hasOutgoingChanges(mergeContext, removedElements)) {
return false;
}
-
+
// Now try to merge all the element files involved
- Set elementFiles = new HashSet();
+ Set<IResource> elementFiles = new HashSet<>();
elementFiles.addAll(Arrays.asList(baseElements));
elementFiles.addAll(Arrays.asList(localElements));
elementFiles.addAll(Arrays.asList(remoteElements));
- if (!mergeElementFiles(mergeContext, (IResource[]) elementFiles.toArray(new IResource[elementFiles.size()]), monitor)) {
+ if (!mergeElementFiles(mergeContext, elementFiles.toArray(new IResource[elementFiles.size()]), monitor)) {
return false;
}
-
+
// Finally, merge the model definition
if (!resource.exists()) {
// This is a new model definition so just merge it
@@ -223,11 +219,11 @@ public class ModelMerger extends ResourceMappingMerger {
} else {
// Update the contents of the model definition file
ModelObjectDefinitionFile file = (ModelObjectDefinitionFile)ModelObject.create(resource);
- elementFiles = new HashSet();
+ elementFiles = new HashSet<>();
elementFiles.addAll(Arrays.asList(localElements));
elementFiles.addAll(Arrays.asList(addedElements));
elementFiles.removeAll(Arrays.asList(removedElements));
- file.setElements((IResource[]) elementFiles.toArray(new IResource[elementFiles.size()]));
+ file.setElements(elementFiles.toArray(new IResource[elementFiles.size()]));
// Let the merge context know we handled the file
mergeContext.markAsMerged(diff, false, monitor);
}
@@ -243,17 +239,17 @@ public class ModelMerger extends ResourceMappingMerger {
}
private IDiff[] getDiffs(IMergeContext mergeContext, IResource[] resources) {
- Set diffSet = new HashSet();
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
+ Set<IDiff> diffSet = new HashSet<>();
+ for (IResource resource : resources) {
IDiff[] diffs = mergeContext.getDiffTree().getDiffs(resource, IResource.DEPTH_ZERO);
diffSet.addAll(Arrays.asList(diffs));
}
- return (IDiff[]) diffSet.toArray(new IDiff[diffSet.size()]);
+ return diffSet.toArray(new IDiff[diffSet.size()]);
}
private boolean hasOutgoingChanges(IMergeContext mergeContext, IResource[] removedElements) {
FastDiffFilter fastDiffFilter = new FastDiffFilter() {
+ @Override
public boolean select(IDiff diff) {
if (diff instanceof IThreeWayDiff) {
IThreeWayDiff twd = (IThreeWayDiff) diff;
@@ -262,27 +258,24 @@ public class ModelMerger extends ResourceMappingMerger {
return false;
}
};
- for (int i = 0; i < removedElements.length; i++) {
- IResource resource = removedElements[i];
+ for (IResource resource : removedElements) {
if (mergeContext.getDiffTree().hasMatchingDiffs(resource.getFullPath(), fastDiffFilter))
- return true;
+ return true;
}
return false;
}
private IResource[] getAddedElements(IResource[] baseElements, IResource[] remoteElements) {
- List result = new ArrayList();
- Set base = new HashSet();
- for (int i = 0; i < baseElements.length; i++) {
- IResource resource = baseElements[i];
+ List<IResource> result = new ArrayList<>();
+ Set<IResource> base = new HashSet<>();
+ for (IResource resource : baseElements) {
base.add(resource);
}
- for (int i = 0; i < remoteElements.length; i++) {
- IResource resource = remoteElements[i];
+ for (IResource resource : remoteElements) {
if (!base.contains(resource))
result.add(resource);
}
- return (IResource[]) result.toArray(new IResource[result.size()]);
+ return result.toArray(new IResource[result.size()]);
}
private IResource[] getReferencedResources(IResource resource) throws CoreException {
@@ -291,11 +284,11 @@ public class ModelMerger extends ResourceMappingMerger {
}
return new IResource[0];
}
-
+
private IResource[] getReferencedResources(String projectName, IFileRevision revision, IProgressMonitor monitor) throws CoreException {
if (revision != null) {
return ModelObjectDefinitionFile.getReferencedResources(projectName, revision.getStorage(monitor));
- }
+ }
return new IResource[0];
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorContentProvider.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorContentProvider.java
index 94be06133..b98783cc7 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorContentProvider.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorContentProvider.java
@@ -13,29 +13,50 @@
*******************************************************************************/
package org.eclipse.team.examples.model.ui;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Display;
import org.eclipse.team.examples.filesystem.FileSystemPlugin;
-import org.eclipse.team.examples.model.*;
-import org.eclipse.team.ui.mapping.*;
+import org.eclipse.team.examples.model.ModelObject;
+import org.eclipse.team.examples.model.ModelProject;
+import org.eclipse.team.examples.model.ModelWorkspace;
+import org.eclipse.team.ui.mapping.ITeamStateChangeEvent;
+import org.eclipse.team.ui.mapping.ITeamStateChangeListener;
+import org.eclipse.team.ui.mapping.SynchronizationStateTester;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.model.BaseWorkbenchContentProvider;
-import org.eclipse.ui.navigator.*;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+import org.eclipse.ui.navigator.ICommonContentProvider;
+import org.eclipse.ui.navigator.IPipelinedTreeContentProvider;
+import org.eclipse.ui.navigator.PipelinedShapeModification;
+import org.eclipse.ui.navigator.PipelinedViewerUpdate;
+import org.eclipse.ui.navigator.SaveablesProvider;
/**
* Model content provider for use with the Common Navigator framework.
- * It makes use of an IWorkbenchAdapter to get the children and parent
- * of model objects. It also makes use of the Common Navigator pipeline
+ * It makes use of an IWorkbenchAdapter to get the children and parent
+ * of model objects. It also makes use of the Common Navigator pipeline
* to override the resource content extension so that model projects will
* replace the corresponding resource project in the Project Explorer.
*/
public class ModelNavigatorContentProvider extends BaseWorkbenchContentProvider
- implements ICommonContentProvider, IResourceChangeListener, IPipelinedTreeContentProvider, ITeamStateChangeListener, IAdaptable {
+implements ICommonContentProvider, IResourceChangeListener, IPipelinedTreeContentProvider, ITeamStateChangeListener, IAdaptable {
private ICommonContentExtensionSite extensionSite;
private boolean isWorkspaceRoot;
@@ -48,7 +69,7 @@ public class ModelNavigatorContentProvider extends BaseWorkbenchContentProvider
super();
updateViewer = true;
}
-
+
/**
* Create a contentProvider
* @param updateViewer whether this content provider is reponsible for updating the viewer
@@ -57,9 +78,7 @@ public class ModelNavigatorContentProvider extends BaseWorkbenchContentProvider
this.updateViewer = updateViewer;
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.ICommonContentProvider#init(org.eclipse.ui.navigator.ICommonContentExtensionSite)
- */
+ @Override
public void init(ICommonContentExtensionSite aConfig) {
extensionSite = aConfig;
if (updateViewer) {
@@ -70,26 +89,20 @@ public class ModelNavigatorContentProvider extends BaseWorkbenchContentProvider
}
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.BaseWorkbenchContentProvider#dispose()
- */
+ @Override
public void dispose() {
super.dispose();
ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
if (syncStateTester != null)
syncStateTester.getTeamStateProvider().removeDecoratedStateChangeListener(this);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.IMementoAware#restoreState(org.eclipse.ui.IMemento)
- */
+
+ @Override
public void restoreState(IMemento aMemento) {
// Nothing to do
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.IMementoAware#saveState(org.eclipse.ui.IMemento)
- */
+ @Override
public void saveState(IMemento aMemento) {
// Nothing to do
}
@@ -101,24 +114,20 @@ public class ModelNavigatorContentProvider extends BaseWorkbenchContentProvider
public ICommonContentExtensionSite getExtensionSite() {
return extensionSite;
}
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.BaseWorkbenchContentProvider#getElements(java.lang.Object)
- */
+
+ @Override
public Object[] getElements(Object element) {
- // Since we are used in the project explorer, the root may be
+ // Since we are used in the project explorer, the root may be
// an IWorkspaceRoot. We need to change it to the ModelWorkspace
if (element instanceof IWorkspaceRoot) {
isWorkspaceRoot = true;
return super.getElements(ModelObject.create((IWorkspaceRoot)element));
-
+
}
return super.getElements(element);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.model.BaseWorkbenchContentProvider#getParent(java.lang.Object)
- */
+
+ @Override
public Object getParent(Object element) {
Object parent = super.getParent(element);
if (isWorkspaceRoot && parent instanceof ModelWorkspace) {
@@ -127,77 +136,69 @@ public class ModelNavigatorContentProvider extends BaseWorkbenchContentProvider
return parent;
}
+ @Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
this.viewer = viewer;
super.inputChanged(viewer, oldInput, newInput);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.mapping.ITeamStateChangeListener#teamStateChanged(org.eclipse.team.ui.mapping.ITeamStateChangeEvent)
- */
+
+ @Override
public void teamStateChanged(ITeamStateChangeEvent event) {
// We need to listen to team state changes in order to determine when we need
// to perform label updates on model elements.
// We actually just refresh all projects that contain changes.
// This is inefficient but will do for an example
- Set refreshProjects = new HashSet();
+ Set<ModelProject> refreshProjects = new HashSet<>();
IResource[] addedRoots = event.getAddedRoots();
- for (int i = 0; i < addedRoots.length; i++) {
- IResource resource = addedRoots[i];
+ for (IResource resource : addedRoots) {
if (isModelProject(resource.getProject())) {
- refreshProjects.add(ModelObject.create(resource.getProject()));
+ refreshProjects.add((ModelProject) ModelObject.create(resource.getProject()));
}
}
IResource[] removedRoots = event.getRemovedRoots();
- for (int i = 0; i < removedRoots.length; i++) {
- IResource resource = removedRoots[i];
+ for (IResource resource : removedRoots) {
if (isModelProject(resource.getProject())) {
- refreshProjects.add(ModelObject.create(resource.getProject()));
+ refreshProjects.add((ModelProject) ModelObject.create(resource.getProject()));
}
}
IResource[] changed = event.getChangedResources();
- for (int i = 0; i < changed.length; i++) {
- IResource resource = changed[i];
+ for (IResource resource : changed) {
if (isModelProject(resource.getProject())) {
- refreshProjects.add(ModelObject.create(resource.getProject()));
+ refreshProjects.add((ModelProject) ModelObject.create(resource.getProject()));
}
}
-
- refreshProjects((ModelProject[]) refreshProjects.toArray(new ModelProject[refreshProjects.size()]));
+
+ refreshProjects(refreshProjects.toArray(new ModelProject[refreshProjects.size()]));
}
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
- */
+
+ @Override
public void resourceChanged(IResourceChangeEvent event) {
if (viewer == null) return;
IResourceDelta delta = event.getDelta();
IResourceDelta[] children = delta.getAffectedChildren();
boolean refreshAll = false;
- List refreshProjects = new ArrayList();
- for (int i = 0; i < children.length; i++) {
- IResourceDelta childDelta = children[i];
+ List<ModelProject> refreshProjects = new ArrayList<>();
+ for (IResourceDelta childDelta : children) {
if (isModelProject(childDelta.getResource())) {
if (isProjectChange(childDelta)) {
refreshAll = true;
break;
}
- refreshProjects.add(ModelObject.create(childDelta.getResource()));
+ refreshProjects.add((ModelProject) ModelObject.create(childDelta.getResource()));
}
}
if (refreshAll || !refreshProjects.isEmpty()) {
if (refreshAll)
refreshViewer();
- else
- refreshProjects((ModelProject[]) refreshProjects.toArray(new ModelProject[refreshProjects.size()]));
+ else
+ refreshProjects(refreshProjects.toArray(new ModelProject[refreshProjects.size()]));
}
}
private void refreshProjects(final ModelProject[] projects) {
Display.getDefault().asyncExec(() -> {
if (!getViewer().getControl().isDisposed()) {
- for (int i = 0; i < projects.length; i++) {
- ModelProject project = projects[i];
+ for (ModelProject project : projects) {
((AbstractTreeViewer)getViewer()).refresh(project, true);
}
}
@@ -231,16 +232,12 @@ public class ModelNavigatorContentProvider extends BaseWorkbenchContentProvider
return viewer;
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedChildren(java.lang.Object, java.util.Set)
- */
+ @Override
public void getPipelinedChildren(Object aParent, Set theCurrentChildren) {
// Nothing to do
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedElements(java.lang.Object, java.util.Set)
- */
+ @Override
public void getPipelinedElements(Object anInput, Set theCurrentElements) {
// Replace any model projects with a ModelProject
if (anInput instanceof IWorkspaceRoot) {
@@ -263,17 +260,13 @@ public class ModelNavigatorContentProvider extends BaseWorkbenchContentProvider
}
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedParent(java.lang.Object, java.lang.Object)
- */
+ @Override
public Object getPipelinedParent(Object anObject, Object aSuggestedParent) {
// We're not changing the parenting of any resources
return aSuggestedParent;
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptAdd(org.eclipse.ui.navigator.PipelinedShapeModification)
- */
+ @Override
public PipelinedShapeModification interceptAdd(PipelinedShapeModification anAddModification) {
if (anAddModification.getParent() instanceof IWorkspaceRoot) {
for (Iterator iter = anAddModification.getChildren().iterator(); iter.hasNext();) {
@@ -293,30 +286,25 @@ public class ModelNavigatorContentProvider extends BaseWorkbenchContentProvider
return null;
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptRefresh(org.eclipse.ui.navigator.PipelinedViewerUpdate)
- */
+ @Override
public boolean interceptRefresh(PipelinedViewerUpdate aRefreshSynchronization) {
// No need to intercept the refresh
return false;
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptRemove(org.eclipse.ui.navigator.PipelinedShapeModification)
- */
+ @Override
public PipelinedShapeModification interceptRemove(PipelinedShapeModification aRemoveModification) {
// No need to intercept the remove
return aRemoveModification;
}
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptUpdate(org.eclipse.ui.navigator.PipelinedViewerUpdate)
- */
+ @Override
public boolean interceptUpdate(PipelinedViewerUpdate anUpdateSynchronization) {
// No need to intercept the update
return false;
}
+ @Override
public <T> T getAdapter(Class<T> adapter) {
if (adapter == SaveablesProvider.class) {
return adapter.cast(saveablesProvider);
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelSaveablesProvider.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelSaveablesProvider.java
index 8ec2beec3..64489bf8f 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelSaveablesProvider.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelSaveablesProvider.java
@@ -13,20 +13,22 @@
*******************************************************************************/
package org.eclipse.team.examples.model.ui;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.team.examples.model.ModelObjectDefinitionFile;
import org.eclipse.ui.Saveable;
import org.eclipse.ui.navigator.SaveablesProvider;
/**
- * Provider used by the Common Navigator framework to link saveables to
+ * Provider used by the Common Navigator framework to link saveables to
* model elements.
*/
public class ModelSaveablesProvider extends SaveablesProvider {
- private List saveables = new ArrayList();
+ private List<Saveable> saveables = new ArrayList<>();
+ @Override
public Object[] getElements(Saveable saveable) {
if (saveable instanceof ModelSaveable) {
ModelSaveable ms = (ModelSaveable) saveable;
@@ -35,17 +37,19 @@ public class ModelSaveablesProvider extends SaveablesProvider {
return new Object[0];
}
+ @Override
public Saveable getSaveable(Object element) {
- for (Iterator iterator = saveables.iterator(); iterator.hasNext();) {
- ModelSaveable saveable = (ModelSaveable) iterator.next();
+ for (Object element2 : saveables) {
+ ModelSaveable saveable = (ModelSaveable) element2;
if (saveable.getModelObject().equals(element))
return saveable;
}
return null;
}
+ @Override
public Saveable[] getSaveables() {
- return (Saveable[]) saveables.toArray(new Saveable[saveables.size()]);
+ return saveables.toArray(new Saveable[saveables.size()]);
}
public void makeDirty(ModelObjectDefinitionFile mo) {
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/CompareAdapter.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/CompareAdapter.java
index cf266a4bf..7f6d5b2fe 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/CompareAdapter.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/CompareAdapter.java
@@ -17,12 +17,17 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
-import org.eclipse.core.resources.*;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.runtime.Path;
import org.eclipse.team.core.mapping.ISynchronizationContext;
-import org.eclipse.team.examples.model.*;
+import org.eclipse.team.examples.model.ModelObject;
+import org.eclipse.team.examples.model.ModelObjectDefinitionFile;
+import org.eclipse.team.examples.model.ModelObjectElementFile;
+import org.eclipse.team.examples.model.ModelResource;
import org.eclipse.team.examples.model.mapping.ExampleModelProvider;
import org.eclipse.team.ui.mapping.SynchronizationCompareAdapter;
import org.eclipse.ui.IMemento;
@@ -33,13 +38,14 @@ import org.eclipse.ui.IMemento;
public class CompareAdapter extends SynchronizationCompareAdapter {
private static final String CTX_MODEL_MAPPINGS = "org.eclipse.team.examples.filesystem.modelMappings";
-
+
private final ExampleModelProvider provider;
public CompareAdapter(ExampleModelProvider provider) {
this.provider = provider;
}
-
+
+ @Override
public String getName(ResourceMapping mapping) {
Object o = mapping.getModelObject();
if (o instanceof ModelObject) {
@@ -47,7 +53,8 @@ public class CompareAdapter extends SynchronizationCompareAdapter {
}
return super.getName(mapping);
}
-
+
+ @Override
public String getPathString(ResourceMapping mapping) {
Object o = mapping.getModelObject();
if (o instanceof ModelObject) {
@@ -56,6 +63,7 @@ public class CompareAdapter extends SynchronizationCompareAdapter {
return super.getPathString(mapping);
}
+ @Override
public ICompareInput asCompareInput(ISynchronizationContext context, Object o) {
if (o instanceof ModelObjectElementFile) {
ModelObjectElementFile moeFile = (ModelObjectElementFile) o;
@@ -64,29 +72,29 @@ public class CompareAdapter extends SynchronizationCompareAdapter {
}
return super.asCompareInput(context, o);
}
-
+
+ @Override
public ResourceMapping[] restore(IMemento memento) {
- List result = new ArrayList();
+ List<ResourceMapping> result = new ArrayList<>();
IMemento[] children = memento.getChildren(CTX_MODEL_MAPPINGS);
- for (int i = 0; i < children.length; i++) {
- IMemento child = children[i];
+ for (IMemento child : children) {
ResourceMapping mapping = restoreMapping(child);
if (mapping != null)
result.add(mapping);
}
- return (ResourceMapping[]) result.toArray(new ResourceMapping[result.size()]);
+ return result.toArray(new ResourceMapping[result.size()]);
}
+ @Override
public void save(ResourceMapping[] mappings, IMemento memento) {
- for (int i = 0; i < mappings.length; i++) {
- ResourceMapping mapping = mappings[i];
+ for (ResourceMapping mapping : mappings) {
Object o = mapping.getModelObject();
if (o instanceof ModelObject) {
ModelObject mo = (ModelObject) o;
save(mo, memento.createChild(CTX_MODEL_MAPPINGS));
}
}
-
+
}
private ResourceMapping restoreMapping(IMemento child) {
@@ -103,10 +111,10 @@ public class CompareAdapter extends SynchronizationCompareAdapter {
}
return null;
}
-
+
private IResource getResource(String path) {
Path resourcePath = new Path(path);
- if (path.endsWith(ModelObjectDefinitionFile.MODEL_OBJECT_DEFINITION_FILE_EXTENSION)
+ if (path.endsWith(ModelObjectDefinitionFile.MODEL_OBJECT_DEFINITION_FILE_EXTENSION)
|| path.endsWith(ModelObjectElementFile.MODEL_OBJECT_ELEMENTFILE_EXTENSION))
return ResourcesPlugin.getWorkspace().getRoot().getFile(resourcePath);
if (resourcePath.segmentCount() == 1)
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelMergeActionHandler.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelMergeActionHandler.java
index 846a7e3ec..f800d6232 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelMergeActionHandler.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelMergeActionHandler.java
@@ -18,9 +18,13 @@ import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.team.core.diff.*;
+import org.eclipse.team.core.diff.FastDiffFilter;
+import org.eclipse.team.core.diff.IDiff;
+import org.eclipse.team.core.diff.IThreeWayDiff;
import org.eclipse.team.core.mapping.IMergeContext;
import org.eclipse.team.examples.model.ModelObjectDefinitionFile;
import org.eclipse.team.examples.model.ModelObjectElementFile;
@@ -40,9 +44,7 @@ public class ModelMergeActionHandler extends MergeActionHandler {
super(configuration, selection);
}
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.mapping.SynchronizationOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
+ @Override
protected void execute(IProgressMonitor monitor) throws InvocationTargetException {
// We need to perform special handling for any MOE file whose parent MOD is not included in the merge
try {
@@ -53,8 +55,7 @@ public class ModelMergeActionHandler extends MergeActionHandler {
if (!status.isOK())
throw new CoreException(status);
// For now, just cycle through each lonely MOE and update the parent
- for (int i = 0; i < moeMerges.length; i++) {
- ModelObjectElementFile file = moeMerges[i];
+ for (ModelObjectElementFile file : moeMerges) {
ModelObjectDefinitionFile modFile = (ModelObjectDefinitionFile)file.getParent();
if (file.getResource().exists() && !modFile.hasMoe((IFile)file.getResource()))
modFile.addMoe((IFile)file.getResource());
@@ -67,23 +68,21 @@ public class ModelMergeActionHandler extends MergeActionHandler {
}
private ModelObjectElementFile[] getMoeOnlyMerges() {
- List result = new ArrayList();
+ List<ModelObjectElementFile> result = new ArrayList<>();
Object[] elements = getElements();
- for (int i = 0; i < elements.length; i++) {
- Object object = elements[i];
+ for (Object object : elements) {
if (object instanceof ModelObjectElementFile) {
ModelObjectElementFile moeFile = (ModelObjectElementFile) object;
result.add(moeFile);
}
}
- return (ModelObjectElementFile[]) result.toArray(new ModelObjectElementFile[result.size()]);
+ return result.toArray(new ModelObjectElementFile[result.size()]);
}
- /* (non-Javadoc)
- * @see org.eclipse.team.internal.ui.mapping.ResourceModelProviderOperation#getDiffFilter()
- */
+ @Override
protected FastDiffFilter getDiffFilter() {
return new FastDiffFilter() {
+ @Override
public boolean select(IDiff node) {
if (node instanceof IThreeWayDiff) {
IThreeWayDiff twd = (IThreeWayDiff) node;
@@ -107,13 +106,15 @@ public class ModelMergeActionHandler extends MergeActionHandler {
this.overwrite = overwrite;
}
+ @Override
protected SynchronizationOperation getOperation() {
if (operation == null) {
operation = new ModelSynchronizeOperation(getConfiguration(), getStructuredSelection());
}
return operation;
}
-
+
+ @Override
protected void updateEnablement(IStructuredSelection selection) {
synchronized (this) {
operation = null;
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelSyncContentProvider.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelSyncContentProvider.java
index e4fb3a66f..3a9c796df 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelSyncContentProvider.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ModelSyncContentProvider.java
@@ -13,65 +13,97 @@
*******************************************************************************/
package org.eclipse.team.examples.model.ui.mapping;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.resources.mapping.*;
-import org.eclipse.core.runtime.*;
-import org.eclipse.jface.viewers.*;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceMappingContext;
+import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.team.core.diff.*;
+import org.eclipse.team.core.diff.FastDiffFilter;
+import org.eclipse.team.core.diff.IDiff;
+import org.eclipse.team.core.diff.IDiffChangeEvent;
+import org.eclipse.team.core.diff.IDiffTree;
import org.eclipse.team.core.mapping.ISynchronizationContext;
import org.eclipse.team.core.mapping.ISynchronizationScope;
import org.eclipse.team.core.mapping.provider.ResourceDiffTree;
import org.eclipse.team.examples.filesystem.FileSystemPlugin;
-import org.eclipse.team.examples.model.*;
+import org.eclipse.team.examples.model.ModelContainer;
+import org.eclipse.team.examples.model.ModelObject;
+import org.eclipse.team.examples.model.ModelObjectDefinitionFile;
+import org.eclipse.team.examples.model.ModelObjectElementFile;
+import org.eclipse.team.examples.model.ModelProject;
+import org.eclipse.team.examples.model.ModelWorkspace;
import org.eclipse.team.examples.model.mapping.ExampleModelProvider;
import org.eclipse.team.examples.model.ui.ModelNavigatorContentProvider;
import org.eclipse.team.internal.ui.Utils;
import org.eclipse.team.internal.ui.mapping.SynchronizationResourceMappingContext;
import org.eclipse.team.ui.mapping.SynchronizationContentProvider;
-import org.eclipse.ui.navigator.*;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+import org.eclipse.ui.navigator.IPipelinedTreeContentProvider;
+import org.eclipse.ui.navigator.PipelinedShapeModification;
+import org.eclipse.ui.navigator.PipelinedViewerUpdate;
/**
* The content provider that is used for synchronizations.
- * It also makes use of the Common Navigator pipeline
+ * It also makes use of the Common Navigator pipeline
* to override the resource content extension so that model projects will
* replace the corresponding resource project in the Synchronize view.
*/
public class ModelSyncContentProvider extends SynchronizationContentProvider implements IPipelinedTreeContentProvider {
private ModelNavigatorContentProvider delegate;
-
+
public ModelSyncContentProvider() {
super();
}
+ @Override
public void init(ICommonContentExtensionSite site) {
super.init(site);
delegate = new ModelNavigatorContentProvider(getContext() != null);
delegate.init(site);
}
-
+
+ @Override
public void dispose() {
super.dispose();
if (delegate != null)
delegate.dispose();
}
-
+
+ @Override
protected ITreeContentProvider getDelegateContentProvider() {
return delegate;
}
+ @Override
protected String getModelProviderId() {
return ExampleModelProvider.ID;
}
+ @Override
protected Object getModelRoot() {
return ModelWorkspace.getRoot();
}
+ @Override
protected ResourceTraversal[] getTraversals(
ISynchronizationContext context, Object object) {
if (object instanceof ModelObject) {
@@ -88,17 +120,17 @@ public class ModelSyncContentProvider extends SynchronizationContentProvider imp
}
return new ResourceTraversal[0];
}
-
+
+ @Override
protected Object[] getChildrenInContext(ISynchronizationContext context, Object parent, Object[] children) {
- Set allChildren = new HashSet();
+ Set<Object> allChildren = new HashSet<>();
allChildren.addAll(Arrays.asList(super.getChildrenInContext(context, parent, children)));
// We need to override this method in order to ensure that any elements
// that exist in the context but do not exist locally are included
if (parent instanceof ModelContainer) {
ModelContainer mc = (ModelContainer) parent;
IDiff[] diffs = context.getDiffTree().getDiffs(mc.getResource(), IResource.DEPTH_ONE);
- for (int i = 0; i < diffs.length; i++) {
- IDiff diff = diffs[i];
+ for (IDiff diff : diffs) {
IResource resource = ResourceDiffTree.getResourceFor(diff);
if (!resource.exists() && ModelObjectDefinitionFile.isModFile(resource)) {
ModelObject o = ModelObject.create(resource);
@@ -110,8 +142,7 @@ public class ModelSyncContentProvider extends SynchronizationContentProvider imp
if (parent instanceof ModelObjectDefinitionFile) {
ResourceTraversal[] traversals = getTraversals(context, parent);
IDiff[] diffs = context.getDiffTree().getDiffs(traversals);
- for (int i = 0; i < diffs.length; i++) {
- IDiff diff = diffs[i];
+ for (IDiff diff : diffs) {
IResource resource = ResourceDiffTree.getResourceFor(diff);
if (!resource.exists() && ModelObjectElementFile.isMoeFile(resource)) {
ModelObject o = new ModelObjectElementFile((ModelObjectDefinitionFile)parent, (IFile)resource);
@@ -123,15 +154,17 @@ public class ModelSyncContentProvider extends SynchronizationContentProvider imp
return allChildren.toArray(new Object[allChildren.size()]);
}
+ @Override
public void getPipelinedChildren(Object aParent, Set theCurrentChildren) {
// Nothing to do
}
+ @Override
public void getPipelinedElements(Object anInput, Set theCurrentElements) {
// Replace any model projects with a ModelProject if the input
// is a synchronization context
if (anInput instanceof ISynchronizationContext) {
- List newProjects = new ArrayList();
+ List<ModelObject> newProjects = new ArrayList<>();
for (Iterator iter = theCurrentElements.iterator(); iter.hasNext();) {
Object element = iter.next();
if (element instanceof IProject) {
@@ -155,11 +188,13 @@ public class ModelSyncContentProvider extends SynchronizationContentProvider imp
}
}
+ @Override
public Object getPipelinedParent(Object anObject, Object aSuggestedParent) {
// We're not changing the parenting of any resources
return aSuggestedParent;
}
+ @Override
public PipelinedShapeModification interceptAdd(PipelinedShapeModification anAddModification) {
if (anAddModification.getParent() instanceof ISynchronizationContext) {
for (Iterator iter = anAddModification.getChildren().iterator(); iter.hasNext();) {
@@ -179,21 +214,25 @@ public class ModelSyncContentProvider extends SynchronizationContentProvider imp
return null;
}
+ @Override
public boolean interceptRefresh(PipelinedViewerUpdate aRefreshSynchronization) {
// No need to intercept the refresh
return false;
}
+ @Override
public PipelinedShapeModification interceptRemove(PipelinedShapeModification aRemoveModification) {
// No need to intercept the remove
return aRemoveModification;
}
+ @Override
public boolean interceptUpdate(PipelinedViewerUpdate anUpdateSynchronization) {
// No need to intercept the update
return false;
}
-
+
+ @Override
public void diffsChanged(final IDiffChangeEvent event, IProgressMonitor monitor) {
// Override in order to perform custom viewer updates when the diff tree changes
Utils.syncExec((Runnable) () -> handleChange(event), (StructuredViewer)getViewer());
@@ -202,11 +241,10 @@ public class ModelSyncContentProvider extends SynchronizationContentProvider imp
void handleChange(IDiffChangeEvent event) {
Set existingProjects = getVisibleModelProjects();
IProject[] changedProjects = getChangedModelProjects(event);
- List refreshes = new ArrayList(changedProjects.length);
- List additions = new ArrayList(changedProjects.length);
- List removals = new ArrayList(changedProjects.length);
- for (int i = 0; i < changedProjects.length; i++) {
- IProject project = changedProjects[i];
+ List<ModelObject> refreshes = new ArrayList<>(changedProjects.length);
+ List<ModelObject> additions = new ArrayList<>(changedProjects.length);
+ List<ModelObject> removals = new ArrayList<>(changedProjects.length);
+ for (IProject project : changedProjects) {
if (hasVisibleChanges(event.getTree(), project)) {
if (existingProjects.contains(project)) {
refreshes.add(ModelObject.create(project));
@@ -215,7 +253,7 @@ public class ModelSyncContentProvider extends SynchronizationContentProvider imp
}
} else if (existingProjects.contains(project)) {
removals.add(ModelObject.create(project));
-
+
}
}
if (!removals.isEmpty() || !additions.isEmpty() || !refreshes.isEmpty()) {
@@ -228,8 +266,7 @@ public class ModelSyncContentProvider extends SynchronizationContentProvider imp
if (!removals.isEmpty())
viewer.remove(viewer.getInput(), removals.toArray());
if (!refreshes.isEmpty()) {
- for (Iterator iter = refreshes.iterator(); iter.hasNext();) {
- Object element = iter.next();
+ for (Object element : refreshes) {
viewer.refresh(element);
}
}
@@ -241,6 +278,7 @@ public class ModelSyncContentProvider extends SynchronizationContentProvider imp
private boolean hasVisibleChanges(IDiffTree tree, IProject project) {
return tree.hasMatchingDiffs(project.getFullPath(), new FastDiffFilter() {
+ @Override
public boolean select(IDiff diff) {
return isVisible(diff);
}
@@ -251,33 +289,30 @@ public class ModelSyncContentProvider extends SynchronizationContentProvider imp
* Return the list of all projects that are model projects
*/
private IProject[] getChangedModelProjects(IDiffChangeEvent event) {
- Set result = new HashSet();
+ Set<IProject> result = new HashSet<>();
IDiff[] changes = event.getChanges();
- for (int i = 0; i < changes.length; i++) {
- IDiff diff = changes[i];
+ for (IDiff diff : changes) {
IResource resource = ResourceDiffTree.getResourceFor(diff);
if (resource != null && isModProject(resource.getProject())) {
result.add(resource.getProject());
}
}
IDiff[] additions = event.getAdditions();
- for (int i = 0; i < additions.length; i++) {
- IDiff diff = additions[i];
+ for (IDiff diff : additions) {
IResource resource = ResourceDiffTree.getResourceFor(diff);
if (resource != null && isModProject(resource.getProject())) {
result.add(resource.getProject());
}
}
IPath[] removals = event.getRemovals();
- for (int i = 0; i < removals.length; i++) {
- IPath path = removals[i];
+ for (IPath path : removals) {
if (path.segmentCount() > 0) {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0));
if (isModProject(project))
result.add(project);
}
}
- return (IProject[]) result.toArray(new IProject[result.size()]);
+ return result.toArray(new IProject[result.size()]);
}
private boolean isModProject(IProject project) {
@@ -297,8 +332,7 @@ public class ModelSyncContentProvider extends SynchronizationContentProvider imp
Tree tree = viewer.getTree();
TreeItem[] children = tree.getItems();
Set result = new HashSet();
- for (int i = 0; i < children.length; i++) {
- TreeItem control = children[i];
+ for (TreeItem control : children) {
Object data = control.getData();
if (data instanceof ModelProject) {
result.add(((ModelProject) data).getProject());
@@ -306,16 +340,16 @@ public class ModelSyncContentProvider extends SynchronizationContentProvider imp
}
return result;
}
-
+
+ @Override
public void propertyChanged(IDiffTree tree, int property, IPath[] paths) {
// We're overriding this message so that label updates occur for any elements
// whose labels may have changed
if (getContext() == null)
return;
- final Set updates = new HashSet();
+ final Set<ModelObject> updates = new HashSet<>();
boolean refresh = false;
- for (int i = 0; i < paths.length; i++) {
- IPath path = paths[i];
+ for (IPath path : paths) {
IDiff diff = tree.getDiff(path);
if (diff != null) {
IResource resource = ResourceDiffTree.getResourceFor(diff);
@@ -336,7 +370,7 @@ public class ModelSyncContentProvider extends SynchronizationContentProvider imp
if (refreshAll)
viewer.refresh(true);
else
- viewer.update(updates.toArray(new Object[updates.size()]), null);
+ viewer.update(updates.toArray(new ModelObject[updates.size()]), null);
}, viewer);
}
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ThirdPartyActionProvider.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ThirdPartyActionProvider.java
index 105399c28..6ce278e2a 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ThirdPartyActionProvider.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/mapping/ThirdPartyActionProvider.java
@@ -30,7 +30,9 @@ import org.eclipse.team.ui.mapping.ITeamContentProviderManager;
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
import org.eclipse.ui.IContributorResourceAdapter;
import org.eclipse.ui.ide.IContributorResourceAdapter2;
-import org.eclipse.ui.navigator.*;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.IExtensionStateModel;
public class ThirdPartyActionProvider extends CommonActionProvider {
@@ -39,7 +41,7 @@ public class ThirdPartyActionProvider extends CommonActionProvider {
public ThirdPartyActionProvider() {
// Nothing to do
}
-
+
/**
* Return the configuration from the synchronize page that contains
* the common viewer.
@@ -59,7 +61,7 @@ public class ThirdPartyActionProvider extends CommonActionProvider {
protected final IExtensionStateModel getExtensionStateModel() {
return getActionSite().getExtensionStateModel();
}
-
+
/**
* Return the synchronization context to which the actions of this provider
* apply.
@@ -69,17 +71,18 @@ public class ThirdPartyActionProvider extends CommonActionProvider {
protected final ISynchronizationContext getSynchronizationContext() {
return (ISynchronizationContext)getExtensionStateModel().getProperty(ITeamContentProviderManager.P_SYNCHRONIZATION_CONTEXT);
}
-
+
+ @Override
public void init(ICommonActionExtensionSite aSite) {
super.init(aSite);
exampleAction = new Action("3rd Party Action") {
+ @Override
public void run() {
StringBuffer buffer = new StringBuffer();
boolean addComma = false;
IStructuredSelection selection = (IStructuredSelection)getContext().getSelection();
ResourceMapping[] mappings = getResourceMappings(selection.toArray());
- for (int i = 0; i < mappings.length; i++) {
- ResourceMapping mapping = mappings[i];
+ for (ResourceMapping mapping : mappings) {
ISynchronizationCompareAdapter adapter = getCompareAdpater(mapping);
if (adapter != null) {
String name = adapter.getName(mapping);
@@ -94,7 +97,7 @@ public class ThirdPartyActionProvider extends CommonActionProvider {
}
};
}
-
+
protected ISynchronizationCompareAdapter getCompareAdpater(ResourceMapping mapping) {
if (mapping != null) {
ModelProvider provider = mapping.getModelProvider();
@@ -108,22 +111,22 @@ public class ThirdPartyActionProvider extends CommonActionProvider {
return null;
}
+ @Override
public void fillContextMenu(IMenuManager menu) {
super.fillContextMenu(menu);
menu.add(exampleAction);
}
private ResourceMapping[] getResourceMappings(Object[] objects) {
- List result = new ArrayList();
- for (int i = 0; i < objects.length; i++) {
- Object object = objects[i];
+ List<ResourceMapping> result = new ArrayList<>();
+ for (Object object : objects) {
ResourceMapping mapping = getResourceMapping(object);
if (mapping != null)
result.add(mapping);
}
- return (ResourceMapping[]) result.toArray(new ResourceMapping[result.size()]);
+ return result.toArray(new ResourceMapping[result.size()]);
}
-
+
private ResourceMapping getResourceMapping(Object o) {
if (o instanceof ResourceMapping) {
return (ResourceMapping) o;
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java
index 33d390713..cb01bf474 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProvider.java
@@ -12,24 +12,46 @@
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.team.examples.pessimistic;
-
-import java.io.*;
-import java.util.*;
-import org.eclipse.core.resources.*;
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFileModificationValidator;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.team.FileModificationValidator;
-import org.eclipse.core.runtime.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.team.core.RepositoryProvider;
/**
* The <code>PessimisticFilesystemProvider</code> is a repository provider.
- *
+ *
* The provider manages a file named ".pessimistic" in each container it
* controls. This is where it stores metadata on which files it controls
* in that container. This file is considered to be controlled by the
* provider and may be deleted.
- *
+ *
* The provider provides very simple checkin/checkout facilities by marking
* files read-only to check them in and read-write to check them out. It
* also supports ignoring derived files.
@@ -38,7 +60,7 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
/**
* The name of the file used to store metadata on which
* files are controlled by this provider.
- */
+ */
private static final String CONTROL_FILE_NAME= ".pessimistic";
/**
* The file modification validator for this provider.
@@ -48,16 +70,16 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
* The cache of resources that are currently controlled.
* The cache is a map of parent resource -> set of controlled children.
*/
- Map fControlledResources;
-
+ Map<IContainer, Set<IResource>> fControlledResources;
+
/**
* Creates a new provider, required for team repository extension.
*/
public PessimisticFilesystemProvider() {
validator = new PessimisticModificationValidator(this);
- fControlledResources= new HashMap(1);
- }
-
+ fControlledResources = new HashMap<>(1);
+ }
+
/**
* Adds the resources to the control of this provider.
*/
@@ -65,8 +87,8 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging()) {
System.out.println("Add to control:");
if (resources != null) {
- for (int i= 0; i < resources.length; i++) {
- System.out.println("\t" + resources[i]);
+ for (IResource resource : resources) {
+ System.out.println("\t" + resource);
}
} else {
System.out.println("null resources");
@@ -75,28 +97,27 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
if (resources == null || resources.length == 0) {
return;
}
- final Set toAdd= new HashSet(resources.length);
+ final Set<IResource> toAdd = new HashSet<>(resources.length);
IWorkspaceRunnable runnable= monitor1 -> {
- for (int i1 = 0; i1 < resources.length; i1++) {
- IResource resource= resources[i1];
+ for (IResource resource : resources) {
if (!isControlled(resource)) {
toAdd.add(resource);
}
}
- Map byParent= sortByParent(toAdd);
+ Map<IContainer, Set<IResource>> byParent = sortByParent(toAdd);
monitor1.beginTask("Adding to control", 1000);
- for (Iterator i2= byParent.keySet().iterator(); i2.hasNext();) {
- IContainer parent= (IContainer) i2.next();
- Set controlledResources= (Set)fControlledResources.get(parent);
+ for (Object element : byParent.keySet()) {
+ IContainer parent= (IContainer) element;
+ Set<IResource> controlledResources = fControlledResources.get(parent);
if (controlledResources == null) {
- controlledResources= new HashSet(1);
+ controlledResources = new HashSet<>(1);
fControlledResources.put(parent, controlledResources);
}
- controlledResources.addAll((Set)byParent.get(parent));
+ controlledResources.addAll(byParent.get(parent));
writeControlFile(parent, monitor1);
}
- monitor1.done();
+ monitor1.done();
};
run(runnable, monitor);
fireStateChanged(toAdd, false);
@@ -109,8 +130,8 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging()) {
System.out.println("Remove from control:");
if (resources != null) {
- for (int i= 0; i < resources.length; i++) {
- System.out.println("\t" + resources[i]);
+ for (IResource resource : resources) {
+ System.out.println("\t" + resource);
}
} else {
System.out.println("null resources");
@@ -119,24 +140,23 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
if (resources == null || resources.length == 0) {
return;
}
- final Set toRemove= new HashSet(resources.length);
+ final Set<IResource> toRemove = new HashSet<>(resources.length);
IWorkspaceRunnable runnable= monitor1 -> {
- for (int i1 = 0; i1 < resources.length; i1++) {
- IResource resource1= resources[i1];
- if (isControlled(resource1)) {
+ for (IResource resource1 : resources) {
+ if (isControlled(resource1)) {
toRemove.add(resource1);
}
}
- Map byParent= sortByParent(toRemove);
+ Map<IContainer, Set<IResource>> byParent = sortByParent(toRemove);
monitor1.beginTask("Removing from control", 1000);
- for (Iterator i2= byParent.keySet().iterator(); i2.hasNext();) {
- IContainer parent= (IContainer) i2.next();
- Set controlledResources= (Set)fControlledResources.get(parent);
+ for (Object element : byParent.keySet()) {
+ IContainer parent= (IContainer) element;
+ Set<IResource> controlledResources = fControlledResources.get(parent);
if (controlledResources == null) {
deleteControlFile(parent, monitor1);
} else {
- Set toRemove1= (Set)byParent.get(parent);
+ Set<IResource> toRemove1 = byParent.get(parent);
controlledResources.removeAll(toRemove1);
if (controlledResources.isEmpty()) {
fControlledResources.remove(parent);
@@ -161,20 +181,19 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
/*
* Returns a map of IContainer -> Set of IResource.
*/
- private Map sortByParent(Set resources) {
- Map byParent= new HashMap(1);
- for (Iterator i = resources.iterator(); i.hasNext();) {
- IResource resource= (IResource) i.next();
+ private Map<IContainer, Set<IResource>> sortByParent(Set<IResource> resources) {
+ Map<IContainer, Set<IResource>> byParent = new HashMap<>(1);
+ for (IResource resource : resources) {
IContainer parent= resource.getParent();
- Set set= (Set)byParent.get(parent);
+ Set<IResource> set = byParent.get(parent);
if (set == null) {
- set= new HashSet(1);
+ set = new HashSet<>(1);
byParent.put(parent, set);
}
set.add(resource);
}
return byParent;
- }
+ }
/*
* Deletes the control file for the given container.
@@ -215,9 +234,9 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
/*
* Reads the contents of a control file, answering the set of
* resources that was specified in the file.
- */
- Set readControlFile(IFile controlFile) {
- Set controlledResources= new HashSet(1);
+ */
+ Set<IResource> readControlFile(IFile controlFile) {
+ Set<IResource> controlledResources = new HashSet<>(1);
if (controlFile.exists()) {
InputStream in= null;
try {
@@ -260,7 +279,7 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
}
}
}
- }
+ }
return controlledResources;
}
@@ -269,7 +288,7 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
*/
private void writeControlFile(IContainer container, IProgressMonitor monitor) throws CoreException {
IFile controlFile= getControlFile(container, monitor);
- Set controlledResources= (Set)fControlledResources.get(container);
+ Set controlledResources= fControlledResources.get(container);
InputStream contents= generateControlFileContents(controlledResources);
monitor.beginTask("Writing control file " + controlFile, 1000);
if (contents == null) {
@@ -281,7 +300,7 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
}
/*
- * Generates an InputStream on a byte array which specifies
+ * Generates an InputStream on a byte array which specifies
* the resources given in controlledResources.
*/
private InputStream generateControlFileContents(Set controlledResources) {
@@ -306,52 +325,46 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
/*
* @see IProjectNature#setProject(IProject)
*/
+ @Override
public void setProject(IProject project) {
if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging()) {
System.out.println("Set project to " + project);
}
super.setProject(project);
- configureProject();
+ configureProject();
}
-
- /*
- * @see IRepositoryProvider#getID()
- */
+
+ @Override
public String getID() {
return PessimisticFilesystemProviderPlugin.NATURE_ID;
}
- /*
- * @see IRepositoryProvider#getFileModificationValidator()
- */
+ @Override
public IFileModificationValidator getFileModificationValidator() {
return getFileModificationValidator();
}
-
+
+ @Override
public FileModificationValidator getFileModificationValidator2() {
return validator;
}
-
- /*
- * @see IRepositoryProvider#deconfigure()
- */
+
+ @Override
public void deconfigure() {
if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging()) {
System.out.println("Deconfigure " + getProject());
}
-
+
fControlledResources.clear();
fireStateChanged(getSubtreeMembers(getProject()), true);
}
- /*
- * @see IRepositoryProvider#configure()
- */
+ @Override
public void configureProject() {
if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging()) {
System.out.println("Configure " + getProject());
}
-
+
readControlFiles();
fireStateChanged(getSubtreeMembers(getProject()), true);
}
@@ -361,14 +374,14 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
*/
private void readControlFiles() {
IProject project= getProject();
- Set set= new HashSet(1);
+ Set<IResource> set = new HashSet<>(1);
set.add(project);
fControlledResources.put(project.getParent(), set);
try {
getProject().accept(resource -> {
if (resource.getType() == IResource.FILE) {
if (CONTROL_FILE_NAME.equals(resource.getName())) {
- Set controlledResources= readControlFile((IFile)resource);
+ Set<IResource> controlledResources = readControlFile((IFile) resource);
fControlledResources.put(resource.getParent(), controlledResources);
}
return false;
@@ -382,13 +395,13 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
/**
* Checks the resources in by marking them read-only.
- */
+ */
public void checkin(final IResource[] resources, IProgressMonitor monitor) {
if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging()) {
System.out.println("Check in:");
if (resources != null) {
- for (int i= 0; i < resources.length; i++) {
- System.out.println("\t" + resources[i]);
+ for (IResource resource : resources) {
+ System.out.println("\t" + resource);
}
} else {
System.out.println("null resources");
@@ -397,12 +410,11 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
if (resources == null || resources.length == 0) {
return;
}
- final Set modified= new HashSet(1);
+ final Set<IResource> modified = new HashSet<>(1);
IWorkspaceRunnable runnable= monitor1 -> {
monitor1.beginTask("Checking in resources", 1000);
- for(int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
- if (isControlled(resource)) {
+ for (IResource resource : resources) {
+ if (isControlled(resource)) {
if (resource.exists()) {
resource.setReadOnly(true);
modified.add(resource);
@@ -414,19 +426,19 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
run(runnable, monitor);
fireStateChanged(modified, false);
}
-
+
/**
- * Unchecks the resources out. In this provider this operation is
+ * Unchecks the resources out. In this provider this operation is
* equivalent to checkin.
- *
+ *
* @see PessimisticFilesystemProvider#checkin(IResource[], IProgressMonitor)
*/
public void uncheckout(final IResource[] resources, IProgressMonitor monitor) {
if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging()) {
System.out.println("Uncheckout:");
if (resources != null) {
- for (int i= 0; i < resources.length; i++) {
- System.out.println("\t" + resources[i]);
+ for (IResource resource : resources) {
+ System.out.println("\t" + resource);
}
} else {
System.out.println("null resources");
@@ -435,11 +447,10 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
if (resources == null || resources.length == 0) {
return;
}
- final Set modified= new HashSet(1);
+ final Set<IResource> modified = new HashSet<>(1);
IWorkspaceRunnable runnable= monitor1 -> {
monitor1.beginTask("Unchecking in resources", 1000);
- for(int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
+ for (IResource resource : resources) {
if (isControlled(resource)) {
if (resource.exists()) {
resource.setReadOnly(true);
@@ -460,8 +471,8 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging()) {
System.out.println("Check out:");
if (resources != null) {
- for (int i= 0; i < resources.length; i++) {
- System.out.println("\t" + resources[i]);
+ for (IResource resource : resources) {
+ System.out.println("\t" + resource);
}
} else {
System.out.println("null resources");
@@ -470,14 +481,13 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
if (resources == null || resources.length == 0) {
return;
}
- final Set modified= new HashSet(1);
+ final Set<IResource> modified = new HashSet<>(1);
IWorkspaceRunnable runnable= monitor1 -> {
monitor1.beginTask("Checking out resources", 1000);
- for(int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
+ for (IResource resource : resources) {
if (isControlled(resource)) {
if(resource.exists()) {
- resource.setReadOnly(false);
+ resource.setReadOnly(false);
modified.add(resource);
}
}
@@ -486,10 +496,10 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
};
run(runnable, monitor);
fireStateChanged(modified, false);
- }
+ }
/**
- * Answers <code>true</code> if and only if the resource is
+ * Answers <code>true</code> if and only if the resource is
* not <code>null</code>, controlled, not ignored, and checked out.
* Otherwise this method answers <code>false</code>.
*/
@@ -507,7 +517,7 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
return false;
}
return !resource.isReadOnly();
- }
+ }
/**
* Answers <code>true</code> if the resource is not <code>null</code>,
@@ -524,13 +534,13 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
if (!project.equals(resource.getProject())) {
return false;
}
- Set controlled= (Set)fControlledResources.get(resource.getParent());
+ Set controlled= fControlledResources.get(resource.getParent());
if (controlled == null) {
return false;
}
return controlled.contains(resource);
}
-
+
/**
* Answers <code>true</code> if the resource is ignored.
* Resources are ignored if they are derived.
@@ -549,7 +559,7 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
}
return false;
}
-
+
/**
* Answers <code>true</code> if the preference to change the content
* of the file has been set to <code>true</code>, <code>false</code>
@@ -592,7 +602,7 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
}
file.setContents(new ByteArrayInputStream(buffer.toString().getBytes()), false, false, null);
}
-
+
public static String getFileContents(IFile file) throws IOException, CoreException {
StringBuffer buf = new StringBuffer();
Reader reader = new InputStreamReader(new BufferedInputStream(file.getContents()));
@@ -602,45 +612,45 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
} finally {
reader.close();
}
- return buf.toString();
+ return buf.toString();
}
-
+
public static String getRandomSnippet() {
switch ((int) Math.round(Math.random() * 10)) {
- case 0 :
- return "este e' o meu conteudo (portuguese)";
- case 1 :
- return "Dann brauchen wir aber auch einen deutschen Satz!";
- case 2 :
- return "I'll be back";
- case 3 :
- return "don't worry, be happy";
- case 4 :
- return "there is no imagination for more sentences";
- case 5 :
- return "customize yours";
- case 6 :
- return "foo";
- case 7 :
- return "bar";
- case 8 :
- return "foobar";
- case 9 :
- return "case 9";
- default :
- return "these are my contents";
+ case 0 :
+ return "este e' o meu conteudo (portuguese)";
+ case 1 :
+ return "Dann brauchen wir aber auch einen deutschen Satz!";
+ case 2 :
+ return "I'll be back";
+ case 3 :
+ return "don't worry, be happy";
+ case 4 :
+ return "there is no imagination for more sentences";
+ case 5 :
+ return "customize yours";
+ case 6 :
+ return "foo";
+ case 7 :
+ return "bar";
+ case 8 :
+ return "foobar";
+ case 9 :
+ return "case 9";
+ default :
+ return "these are my contents";
}
}
/*
* Notifies listeners that the state of the resources has changed.
- *
+ *
* @param resources A collection of resources whose state has changed.
- * @param queueAfterWorkspaceOperation If <code>true</code>, indicates that the
+ * @param queueAfterWorkspaceOperation If <code>true</code>, indicates that the
* notification should occur after the current workspace runnable
* has completed.
*/
- private void fireStateChanged(final Collection resources, boolean queueAfterWorkspaceOperation) {
+ private void fireStateChanged(final Collection<IResource> resources, boolean queueAfterWorkspaceOperation) {
if (resources == null || resources.isEmpty()) {
return;
}
@@ -649,9 +659,9 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
Thread t= new Thread(() -> {
try {
ResourcesPlugin.getWorkspace().run(
- (IWorkspaceRunnable) monitor -> {
- },
- null);
+ (IWorkspaceRunnable) monitor -> {
+ },
+ null);
} catch (CoreException e) {
PessimisticFilesystemProviderPlugin.getInstance().logError(e, "Problem during empty runnable");
}
@@ -660,23 +670,23 @@ public class PessimisticFilesystemProvider extends RepositoryProvider {
t.start();
} else {
PessimisticFilesystemProviderPlugin.getInstance().fireResourcesChanged(
- (IResource[])resources.toArray(new IResource[resources.size()]));
- }
+ resources.toArray(new IResource[resources.size()]));
+ }
}
-
+
/*
* Answers a collection of all of the resources contained below
* the given resource and the resource itself.
*/
private Collection getSubtreeMembers(IResource resource) {
- final Set resources= new HashSet(1);
+ final Set<IResource> resources = new HashSet<>(1);
IResourceVisitor visitor= resource1 -> {
switch (resource1.getType()) {
- case IResource.PROJECT:
- case IResource.FOLDER:
- case IResource.FILE:
- resources.add(resource1);
- return true;
+ case IResource.PROJECT:
+ case IResource.FOLDER:
+ case IResource.FILE:
+ resources.add(resource1);
+ return true;
}
return true;
};
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProviderPlugin.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProviderPlugin.java
index ff910d872..819a30a6a 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProviderPlugin.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticFilesystemProviderPlugin.java
@@ -12,9 +12,8 @@
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.team.examples.pessimistic;
-
+
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IResource;
@@ -32,14 +31,14 @@ public class PessimisticFilesystemProviderPlugin extends AbstractUIPlugin {
*/
private static PessimisticFilesystemProviderPlugin instance;
/*
- * The resource change listener which notifies the provider of
+ * The resource change listener which notifies the provider of
* added and deleted files.
*/
private ResourceChangeListener fListener;
/*
* The provider listeners
*/
- private List fListeners;
+ private List<IResourceStateListener> fListeners;
/**
* The plugin identifier
@@ -56,13 +55,13 @@ public class PessimisticFilesystemProviderPlugin extends AbstractUIPlugin {
public PessimisticFilesystemProviderPlugin() {
super();
instance = this;
- fListeners= new ArrayList(1);
+ fListeners = new ArrayList<>(1);
//setDebugging(true);
}
/**
* Answers the singleton instance of this plugin.
- */
+ */
public static PessimisticFilesystemProviderPlugin getInstance() {
return instance;
}
@@ -72,23 +71,23 @@ public class PessimisticFilesystemProviderPlugin extends AbstractUIPlugin {
*/
protected void initializeDefaultPreferences() {
IPreferenceStore store = getPreferenceStore();
-
+
store.setDefault(
- IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_EDITED,
- IPessimisticFilesystemConstants.OPTION_PROMPT);
+ IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_EDITED,
+ IPessimisticFilesystemConstants.OPTION_PROMPT);
store.setDefault(
- IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_EDITED_NOPROMPT,
- IPessimisticFilesystemConstants.OPTION_AUTOMATIC);
+ IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_EDITED_NOPROMPT,
+ IPessimisticFilesystemConstants.OPTION_AUTOMATIC);
store.setDefault(
- IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_SAVED,
- IPessimisticFilesystemConstants.OPTION_DO_NOTHING);
+ IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_SAVED,
+ IPessimisticFilesystemConstants.OPTION_DO_NOTHING);
store.setDefault(
- IPessimisticFilesystemConstants.PREF_ADD_TO_CONTROL,
- IPessimisticFilesystemConstants.OPTION_PROMPT);
+ IPessimisticFilesystemConstants.PREF_ADD_TO_CONTROL,
+ IPessimisticFilesystemConstants.OPTION_PROMPT);
store.setDefault(IPessimisticFilesystemConstants.PREF_FAIL_VALIDATE_EDIT, false);
store.setDefault(IPessimisticFilesystemConstants.PREF_TOUCH_DURING_VALIDATE_EDIT, true);
}
-
+
/**
* Convenience method for logging errors.
*/
@@ -99,12 +98,13 @@ public class PessimisticFilesystemProviderPlugin extends AbstractUIPlugin {
if (isDebugging()) {
System.out.println(message);
exception.printStackTrace();
- }
+ }
}
/**
* Starts the resource listener.
*/
+ @Override
public void start(BundleContext context) throws Exception {
fListener= new ResourceChangeListener();
fListener.startup();
@@ -115,31 +115,32 @@ public class PessimisticFilesystemProviderPlugin extends AbstractUIPlugin {
/**
* Stops the resource listener.
*/
+ @Override
public void stop(BundleContext context) throws Exception {
fListener.shutdown();
fListener= null;
super.stop(context);
}
-
+
/**
* Notifies the registered <code>IResourceStateListener</code> objects
* that the repository state for the resources has changed.
- *
+ *
* @param resources Collection of resources that have changed.
*/
public void fireResourcesChanged(IResource[] resources) {
if (resources == null || resources.length == 0 || fListeners.isEmpty())
return;
- for (Iterator i= fListeners.iterator(); i.hasNext();) {
- IResourceStateListener listener= (IResourceStateListener) i.next();
+ for (Object element : fListeners) {
+ IResourceStateListener listener= (IResourceStateListener) element;
listener.stateChanged(resources);
}
}
-
+
/**
* Adds the listener to the list of listeners that are notified when
* the repository state of resources change.
- *
+ *
* @param listener
*/
public void addProviderListener(IResourceStateListener listener) {
@@ -147,12 +148,12 @@ public class PessimisticFilesystemProviderPlugin extends AbstractUIPlugin {
return;
fListeners.add(listener);
}
-
-
+
+
/**
* Removes the listener from the list of listeners that are notified when
* the repository state of resources change.
- *
+ *
* @param listener
*/
public void removeProviderListener(IResourceStateListener listener) {
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticModificationValidator.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticModificationValidator.java
index 427d39f7e..ee77e88b9 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticModificationValidator.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/PessimisticModificationValidator.java
@@ -12,10 +12,9 @@
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.team.examples.pessimistic;
-
+
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -43,17 +42,17 @@ import org.eclipse.ui.views.navigator.ResourceComparator;
* The <code>PessimisticModificationValidator</code> is an
* implementation of the <code>IFileModificationValidator</code> for the
* <code>PessimisticFilesystemProvider</code>.
- *
+ *
* @see PessimiticFilesystemProvider
* @see IFileModificationValidator
*/
public class PessimisticModificationValidator
- extends FileModificationValidator {
+extends FileModificationValidator {
/*
* The provider for this validator
*/
private PessimisticFilesystemProvider fProvider;
-
+
public PessimisticModificationValidator(PessimisticFilesystemProvider provider) {
fProvider= provider;
}
@@ -61,98 +60,96 @@ public class PessimisticModificationValidator
/**
* @see IFileModificationValidator#validateEdit(IFile[], Object)
*/
- public IStatus validateEdit(IFile[] files, FileModificationValidationContext context) {
- if (files.length == 0) {
- return new Status( IStatus.OK, getUid(), IStatus.OK, "OK", null);
- }
-
- Set checkOut = new HashSet();
+ @Override
+ public IStatus validateEdit(IFile[] files, FileModificationValidationContext context) {
+ if (files.length == 0) {
+ return new Status( IStatus.OK, getUid(), IStatus.OK, "OK", null);
+ }
+
+ Set<IFile> checkOut = new HashSet<>();
int reloadCount = 0;
- int checkoutFailCount = 0;
-
- Map validateEditStatusMap= new HashMap(files.length);
-
- for ( int i = 0 ; i < files.length; i++ ) {
- IFile file= files[i];
-
- if (fProvider.isControlled(file) ) {
- if (fProvider.isCheckedout(file)) {
- setValidateEditStatus(validateEditStatusMap, file,
- IPessimisticFilesystemConstants.STATUS_OK_TO_EDIT );
- } else {
- checkOut.add(file);
- }
- } else {
- setValidateEditStatus(validateEditStatusMap, file,
- IPessimisticFilesystemConstants.STATUS_OK_TO_EDIT);
- }
- }
-
- if (!checkOut.isEmpty()) {
- if (context != null) {
- boolean shouldFail= shouldFailValidateEdit();
- int statusCode = checkout(checkOut, IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_EDITED, shouldFail, context);
- if (shouldFail) {
+ int checkoutFailCount = 0;
+
+ Map<IFile, Integer> validateEditStatusMap = new HashMap<>(files.length);
+
+ for (IFile file : files) {
+ if (fProvider.isControlled(file) ) {
+ if (fProvider.isCheckedout(file)) {
+ setValidateEditStatus(validateEditStatusMap, file,
+ IPessimisticFilesystemConstants.STATUS_OK_TO_EDIT );
+ } else {
+ checkOut.add(file);
+ }
+ } else {
+ setValidateEditStatus(validateEditStatusMap, file,
+ IPessimisticFilesystemConstants.STATUS_OK_TO_EDIT);
+ }
+ }
+
+ if (!checkOut.isEmpty()) {
+ if (context != null) {
+ boolean shouldFail= shouldFailValidateEdit();
+ int statusCode = checkout(checkOut, IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_EDITED, shouldFail, context);
+ if (shouldFail) {
return new Status( IStatus.ERROR, getUid(), IStatus.ERROR, "Fail Validate Edit Preference true", null);
- }
- if(statusCode == IStatus.CANCEL) {
- return new Status( IStatus.CANCEL, getUid(), IStatus.ERROR, "Checkout canceled by user", null);
- }
- } else {
- if (isAutomaticCheckout()) {
- if (shouldFailValidateEdit()) {
+ }
+ if(statusCode == IStatus.CANCEL) {
+ return new Status( IStatus.CANCEL, getUid(), IStatus.ERROR, "Checkout canceled by user", null);
+ }
+ } else {
+ if (isAutomaticCheckout()) {
+ if (shouldFailValidateEdit()) {
return new Status( IStatus.ERROR, getUid(), IStatus.ERROR, "Fail Validate Edit Preference true", null);
- }
-
+ }
+
checkout(checkOut);
- }
- }
-
- for (Iterator i= checkOut.iterator(); i.hasNext(); ) {
- IFile file = (IFile) i.next();
-
+ }
+ }
+
+ for (IFile file : checkOut) {
if ( fProvider.isCheckedout(file) ) {
- if ( !fProvider.hasContentChanged(file) ) {
+ if ( !fProvider.hasContentChanged(file) ) {
setValidateEditStatus(validateEditStatusMap, file,
- IPessimisticFilesystemConstants.STATUS_OK_TO_EDIT );
- } else {
- reloadCount++;
+ IPessimisticFilesystemConstants.STATUS_OK_TO_EDIT );
+ } else {
+ reloadCount++;
setValidateEditStatus(validateEditStatusMap, file,
- IPessimisticFilesystemConstants.STATUS_PROMPT_FOR_RELOAD );
- }
- } else {
- checkoutFailCount++;
+ IPessimisticFilesystemConstants.STATUS_PROMPT_FOR_RELOAD );
+ }
+ } else {
+ checkoutFailCount++;
}
- }
- }
-
- if (reloadCount + checkoutFailCount == 0) {
- return new Status( IStatus.OK, getUid(), IStatus.OK, "OK", null);
- }
-
- if (checkoutFailCount == files.length) {
- return new Status( IStatus.ERROR, getUid(), IStatus.ERROR, "No files were checked out.", null);
- }
-
- IStatus children[] = new Status[ files.length ];
-
- int mask = IPessimisticFilesystemConstants.STATUS_OK_TO_EDIT |
- IPessimisticFilesystemConstants.STATUS_PROMPT_FOR_RELOAD;
-
- for (int i = 0; i < files.length; i++) {
- int result = getValidateEditStatus(validateEditStatusMap, files[i]);
- if ((result & mask) != 0) {
- children[i] = new Status( IStatus.OK, getUid(), IStatus.OK, "OK", null);
- } else {
- children[i] = new Status( IStatus.ERROR, getUid(), IStatus.ERROR, "File " + files[i].getName() + " could not be checked out.", null);
- }
- }
- return new MultiStatus( getUid(), IStatus.OK, children, "Some files were not successfully checked out", null);
+ }
+ }
+
+ if (reloadCount + checkoutFailCount == 0) {
+ return new Status( IStatus.OK, getUid(), IStatus.OK, "OK", null);
+ }
+
+ if (checkoutFailCount == files.length) {
+ return new Status( IStatus.ERROR, getUid(), IStatus.ERROR, "No files were checked out.", null);
+ }
+
+ IStatus children[] = new Status[ files.length ];
+
+ int mask = IPessimisticFilesystemConstants.STATUS_OK_TO_EDIT |
+ IPessimisticFilesystemConstants.STATUS_PROMPT_FOR_RELOAD;
+
+ for (int i = 0; i < files.length; i++) {
+ int result = getValidateEditStatus(validateEditStatusMap, files[i]);
+ if ((result & mask) != 0) {
+ children[i] = new Status( IStatus.OK, getUid(), IStatus.OK, "OK", null);
+ } else {
+ children[i] = new Status( IStatus.ERROR, getUid(), IStatus.ERROR, "File " + files[i].getName() + " could not be checked out.", null);
+ }
+ }
+ return new MultiStatus( getUid(), IStatus.OK, children, "Some files were not successfully checked out", null);
}
/**
* @see IFileModificationValidator#validateSave(IFile)
*/
+ @Override
public IStatus validateSave(IFile file) {
int checkedInFilesSaved = getPreferences().getInt(IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_SAVED);
if (checkedInFilesSaved == IPessimisticFilesystemConstants.OPTION_DO_NOTHING) {
@@ -160,43 +157,43 @@ public class PessimisticModificationValidator
}
- IStatus status = new Status( IStatus.OK, getUid(), IStatus.OK,
- "File is writable", null);
-
+ IStatus status = new Status( IStatus.OK, getUid(), IStatus.OK,
+ "File is writable", null);
+
if (!fProvider.isControlled(file)) {
return status;
}
-
+
if (fProvider.isIgnored(file)) {
return status;
}
-
+
if (fProvider.isCheckedout(file)) {
return status;
}
- Set files= new HashSet(1);
+ Set<IFile> files = new HashSet<>(1);
files.add(file);
-
+
checkout(files, IPessimisticFilesystemConstants.PREF_CHECKED_IN_FILES_SAVED, false, null);
-
+
if (fProvider.isCheckedout(file)) {
return status;
}
return new Status(
- IStatus.ERROR,
- getUid(),
- IStatus.ERROR,
- file.getProjectRelativePath() + " could not be checked out",
- null);
+ IStatus.ERROR,
+ getUid(),
+ IStatus.ERROR,
+ file.getProjectRelativePath() + " could not be checked out",
+ null);
}
-
+
/*
* Convenience method to get the plugin id
*/
private String getUid() {
return PessimisticFilesystemProviderPlugin.PLUGIN_ID;
}
-
+
/*
* Convenience method to answer if the fail validate edit preference
* has been set.
@@ -213,22 +210,21 @@ public class PessimisticModificationValidator
}
/*
- * Optionally prompts the user to select which resources should be
+ * Optionally prompts the user to select which resources should be
* checked out, and then checks the selected resources.
*/
- private int promptAndCheckout(Set resources, boolean beQuiet, boolean shouldFail, Object context) {
+ private int promptAndCheckout(Set<IFile> resources, boolean beQuiet, boolean shouldFail, Object context) {
if (resources.isEmpty()) {
return IStatus.OK;
}
- Set temp= new HashSet(resources.size());
- for(Iterator i= resources.iterator(); i.hasNext(); ) {
- IFile resource= (IFile)i.next();
+ Set<IFile> temp = new HashSet<>(resources.size());
+ for (IFile resource : resources) {
if (fProvider.isControlled(resource) && !fProvider.isCheckedout(resource))
temp.add(resource);
}
resources= temp;
- final int[] statusCode = new int[] {IStatus.OK};
+ final int[] statusCode = new int[] {IStatus.OK};
if (!beQuiet && !resources.isEmpty()) {
final Shell shell= getShell(context);
if (shell != null && !shell.isDisposed()) {
@@ -252,14 +248,14 @@ public class PessimisticModificationValidator
if (status == Window.OK) {
Object[] results= dialog.getResult();
result[0] = new HashSet(results.length);
- for (int i= 0; i < results.length; i++) {
- result[0].add(results[i]);
+ for (Object result2 : results) {
+ result[0].add(result2);
}
} else if(status == Window.CANCEL) {
statusCode[0] = IStatus.CANCEL;
}
});
- resources= result[0];
+ resources= result[0];
} else {
resources= null;
PessimisticFilesystemProviderPlugin.getInstance().logError(new RuntimeException(), "Context is invalid: " + context);
@@ -275,7 +271,7 @@ public class PessimisticModificationValidator
/*
* Checks out the files contained in the resources set
*/
- private void checkout(Set resources) {
+ private void checkout(Set<IFile> resources) {
if (resources.isEmpty())
return;
IFile[] checkOut= new IFile[resources.size()];
@@ -291,32 +287,32 @@ public class PessimisticModificationValidator
}
/*
- * Checks out the files if necessary and if the preferences allow.
+ * Checks out the files if necessary and if the preferences allow.
*/
- private int checkout(Set resources, String itemId, boolean shouldFail, Object context) {
+ private int checkout(Set<IFile> resources, String itemId, boolean shouldFail, Object context) {
if (resources.isEmpty()) {
return IStatus.OK;
}
int preference= getPreferences().getInt(itemId);
-
+
if (preference == IPessimisticFilesystemConstants.OPTION_DO_NOTHING)
return IStatus.OK;
-
- boolean beQuiet= false;
+
+ boolean beQuiet= false;
if (preference == IPessimisticFilesystemConstants.OPTION_AUTOMATIC) {
beQuiet= true;
- }
+ }
return promptAndCheckout(resources, beQuiet, shouldFail, context);
}
-
+
/*
* Convenience method to set the validate edit status for the given resource.
*/
- private static void setValidateEditStatus(Map map, IFile resource, int status) {
+ private static void setValidateEditStatus(Map<IFile, Integer> map, IFile resource, int status) {
map.put(resource, Integer.valueOf(status));
}
-
+
/*
* Convenience method to get the validate edit status for the given resource.
*/
@@ -329,27 +325,27 @@ public class PessimisticModificationValidator
/*
* Convenience method to get a shell from an object.
- */
+ */
private Shell getShell(Object context) {
if (context instanceof FileModificationValidationContext) {
FileModificationValidationContext fmvc = (FileModificationValidationContext) context;
return (Shell)fmvc.getShell();
}
-
+
if (context instanceof Shell) {
return (Shell)context;
}
-
+
if (context instanceof Control) {
Control control= (Control)context;
return control.getShell();
}
-
+
if (context instanceof Widget) {
Widget widget= (Widget)context;
return widget.getDisplay().getActiveShell();
}
-
+
return null;
}
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceChangeListener.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceChangeListener.java
index 9c54c219a..4c35307e0 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceChangeListener.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceChangeListener.java
@@ -12,11 +12,10 @@
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.team.examples.pessimistic;
-
+
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -44,23 +43,23 @@ import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.ui.views.navigator.ResourceComparator;
/**
- * The <code>ResourceChangeListener</code> listens for resource changes
- * and (optionally) prompts the user to add the new resources to the
+ * The <code>ResourceChangeListener</code> listens for resource changes
+ * and (optionally) prompts the user to add the new resources to the
* control of the repository provider.
*/
public class ResourceChangeListener implements IResourceDeltaVisitor, IResourceChangeListener {
/*
* Set of added resources
*/
- private Set fAdded;
+ private Set<IResource> fAdded;
/*
* Set of removed resources
*/
- private Set fRemoved;
-
+ private Set<IResource> fRemoved;
+
public ResourceChangeListener() {
- fAdded= new HashSet(1);
- fRemoved= new HashSet(1);
+ fAdded = new HashSet<>(1);
+ fRemoved = new HashSet<>(1);
}
/**
@@ -71,6 +70,7 @@ public class ResourceChangeListener implements IResourceDeltaVisitor, IResourceC
* </ul>
* @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(IResourceDelta)
*/
+ @Override
public boolean visit(IResourceDelta delta) {
IResource resource= delta.getResource();
if (resource != null) {
@@ -81,37 +81,37 @@ public class ResourceChangeListener implements IResourceDeltaVisitor, IResourceC
return false;
if (provider.isControlled(resource)) {
switch (delta.getKind()) {
- case IResourceDelta.CHANGED:
- case IResourceDelta.ADDED:
- return true;
- case IResourceDelta.REMOVED:
- fRemoved.add(resource);
- return false;
+ case IResourceDelta.CHANGED:
+ case IResourceDelta.ADDED:
+ return true;
+ case IResourceDelta.REMOVED:
+ fRemoved.add(resource);
+ return false;
}
} else {
switch (delta.getKind()) {
- case IResourceDelta.CHANGED:
- case IResourceDelta.REMOVED:
- return true;
- case IResourceDelta.ADDED:
- // don't prompt for ignored resources
- if (!provider.isIgnored(resource)) {
- fAdded.add(resource);
- }
- return true;
- }
+ case IResourceDelta.CHANGED:
+ case IResourceDelta.REMOVED:
+ return true;
+ case IResourceDelta.ADDED:
+ // don't prompt for ignored resources
+ if (!provider.isIgnored(resource)) {
+ fAdded.add(resource);
+ }
+ return true;
+ }
}
} else {
return true;
}
- }
+ }
return false;
}
/*
* Convenience method to return a resource array from a collection
*/
- private IResource[] toResourceArray(Collection collection) {
+ private IResource[] toResourceArray(Collection<IResource> collection) {
if (collection.isEmpty()) {
return new IResource[0];
}
@@ -123,6 +123,7 @@ public class ResourceChangeListener implements IResourceDeltaVisitor, IResourceC
/**
* @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
*/
+ @Override
public void resourceChanged (IResourceChangeEvent event) {
try {
event.getDelta().accept(this);
@@ -136,10 +137,10 @@ public class ResourceChangeListener implements IResourceDeltaVisitor, IResourceC
if (!fRemoved.isEmpty()) {
remove(monitor);
}
-
+
if (!fAdded.isEmpty()) {
add(monitor);
- }
+ }
};
// must fork since we are in resource callback.
Runnable run= () -> {
@@ -164,7 +165,7 @@ public class ResourceChangeListener implements IResourceDeltaVisitor, IResourceC
Preferences preferences= PessimisticFilesystemProviderPlugin.getInstance().getPluginPreferences();
return preferences.getInt(IPessimisticFilesystemConstants.PREF_ADD_TO_CONTROL);
}
-
+
/*
* Adds the resources to the control of the provider.
* If the add to control preference is:
@@ -175,46 +176,46 @@ public class ResourceChangeListener implements IResourceDeltaVisitor, IResourceC
*/
private void add(final IProgressMonitor monitor) {
switch (getAddToControlPreference()) {
- case IPessimisticFilesystemConstants.OPTION_DO_NOTHING:
- break;
- case IPessimisticFilesystemConstants.OPTION_AUTOMATIC:
- addToControl(fAdded, monitor);
- break;
- case IPessimisticFilesystemConstants.OPTION_PROMPT:
- final Shell shell= getShell();
- if (shell != null && !shell.isDisposed()) {
- final Set resources= new HashSet(fAdded);
- Runnable run= () -> {
- CheckedTreeSelectionDialog dialog= new CheckedTreeSelectionDialog(shell, new WorkbenchLabelProvider(), new ResourceSetContentProvider(resources));
- dialog.setMessage("Select the resources to be added to the control of the repository.");
- dialog.setTitle("Add resources to control");
- dialog.setContainerMode(true);
- dialog.setBlockOnOpen(true);
- dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
- Object[] resourceArray= resources.toArray();
- dialog.setExpandedElements(resourceArray);
- dialog.setInitialSelections(resourceArray);
- dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
- int status= dialog.open();
-
- if (status == Window.OK) {
- Object[] results= dialog.getResult();
- if (results != null) {
- Set resources1= new HashSet(results.length);
- for (int i= 0; i < results.length; i++) {
- resources1.add(results[i]);
- }
- addToControl(resources1, monitor);
+ case IPessimisticFilesystemConstants.OPTION_DO_NOTHING:
+ break;
+ case IPessimisticFilesystemConstants.OPTION_AUTOMATIC:
+ addToControl(fAdded, monitor);
+ break;
+ case IPessimisticFilesystemConstants.OPTION_PROMPT:
+ final Shell shell= getShell();
+ if (shell != null && !shell.isDisposed()) {
+ final Set<IResource> resources = new HashSet<>(fAdded);
+ Runnable run= () -> {
+ CheckedTreeSelectionDialog dialog= new CheckedTreeSelectionDialog(shell, new WorkbenchLabelProvider(), new ResourceSetContentProvider(resources));
+ dialog.setMessage("Select the resources to be added to the control of the repository.");
+ dialog.setTitle("Add resources to control");
+ dialog.setContainerMode(true);
+ dialog.setBlockOnOpen(true);
+ dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
+ Object[] resourceArray= resources.toArray();
+ dialog.setExpandedElements(resourceArray);
+ dialog.setInitialSelections(resourceArray);
+ dialog.setInput(ResourcesPlugin.getWorkspace().getRoot());
+ int status= dialog.open();
+
+ if (status == Window.OK) {
+ Object[] results= dialog.getResult();
+ if (results != null) {
+ Set<IResource> resources1 = new HashSet<>(results.length);
+ for (Object result : results) {
+ resources1.add((IResource) result);
}
+ addToControl(resources1, monitor);
}
- };
-
- Display display= shell.getDisplay();
- display.asyncExec(run);
- } else {
- PessimisticFilesystemProviderPlugin.getInstance().logError(null, "Could not aquire a shell");
- }
- break;
+ }
+ };
+
+ Display display= shell.getDisplay();
+ display.asyncExec(run);
+ } else {
+ PessimisticFilesystemProviderPlugin.getInstance().logError(null, "Could not aquire a shell");
+ }
+ break;
}
fAdded.clear();
}
@@ -222,28 +223,26 @@ public class ResourceChangeListener implements IResourceDeltaVisitor, IResourceC
/*
* Adds the resources to the control of the provider.
*/
- private void addToControl(Collection resources, final IProgressMonitor monitor) {
- Map byProject= sortByProject(resources);
- for (Iterator i= byProject.keySet().iterator(); i.hasNext();) {
- IProject project= (IProject) i.next();
+ private void addToControl(Collection<IResource> resources, final IProgressMonitor monitor) {
+ Map<IProject, Set<IResource>> byProject = sortByProject(resources);
+ for (IProject project : byProject.keySet()) {
PessimisticFilesystemProvider provider= (PessimisticFilesystemProvider)RepositoryProvider.getProvider(project, PessimisticFilesystemProviderPlugin.NATURE_ID);
if (provider != null) {
- provider.addToControl(toResourceArray((Collection)byProject.get(project)), monitor);
+ provider.addToControl(toResourceArray(byProject.get(project)), monitor);
}
-
+
}
}
-
+
/*
* Removes the resources from the control of the provider.
*/
private void remove(IProgressMonitor monitor) {
- Map byProject= sortByProject(fRemoved);
- for (Iterator i= byProject.keySet().iterator(); i.hasNext();) {
- IProject project= (IProject) i.next();
+ Map<IProject, Set<IResource>> byProject = sortByProject(fRemoved);
+ for (IProject project : byProject.keySet()) {
PessimisticFilesystemProvider provider= (PessimisticFilesystemProvider)RepositoryProvider.getProvider(project, PessimisticFilesystemProviderPlugin.NATURE_ID);
if (provider != null) {
- provider.removeFromControl(toResourceArray((Collection)byProject.get(project)), monitor);
+ provider.removeFromControl(toResourceArray(byProject.get(project)), monitor);
}
}
fRemoved.clear();
@@ -252,14 +251,13 @@ public class ResourceChangeListener implements IResourceDeltaVisitor, IResourceC
/*
* Convenience method to sort the resources by project
*/
- private Map sortByProject(Collection resources) {
- Map byProject= new HashMap();
- for (Iterator i= resources.iterator(); i.hasNext();) {
- IResource resource= (IResource) i.next();
+ private Map<IProject, Set<IResource>> sortByProject(Collection<IResource> resources) {
+ Map<IProject, Set<IResource>> byProject = new HashMap<>();
+ for (IResource resource : resources) {
IProject project= resource.getProject();
- Set set= (Set)byProject.get(project);
+ Set<IResource> set = byProject.get(project);
if (set == null) {
- set= new HashSet(1);
+ set = new HashSet<>(1);
byProject.put(project, set);
}
set.add(resource);
@@ -300,13 +298,13 @@ public class ResourceChangeListener implements IResourceDeltaVisitor, IResourceC
if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging())
System.out.println ("Resource callback registered");
}
-
+
/**
* Stops listening for changes.
*/
public void shutdown() {
ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging())
- System.out.println ("Resource callback unregistered");
+ System.out.println ("Resource callback unregistered");
}
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceSetContentProvider.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceSetContentProvider.java
index b879d909f..91266c499 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceSetContentProvider.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ResourceSetContentProvider.java
@@ -12,8 +12,11 @@
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.team.examples.pessimistic;
-
-import java.util.*;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import org.eclipse.core.resources.IResource;
import org.eclipse.jface.viewers.ITreeContentProvider;
@@ -21,39 +24,41 @@ import org.eclipse.jface.viewers.Viewer;
public class ResourceSetContentProvider implements ITreeContentProvider {
private static final Object[] EMPTY_ARRAY= new Object[0];
- private Map fResourceTree;
+ private Map<IResource, Set<IResource>> fResourceTree;
private IResource[] fRoots;
- public ResourceSetContentProvider(Set resources) {
- fResourceTree= new HashMap(1);
- Set roots= new HashSet(resources);
- for(Iterator i= resources.iterator(); i.hasNext(); ) {
- IResource resource= (IResource)i.next();
+ public ResourceSetContentProvider(Set<IResource> resources) {
+ fResourceTree = new HashMap<>(1);
+ Set<IResource> roots= new HashSet<>(resources);
+ for (Object element : resources) {
+ IResource resource= (IResource)element;
if(resource.getType() == IResource.ROOT) {
continue; // root cannot be displayed
}
IResource parent= resource.getParent();
if (roots.contains(parent)) {
roots.remove(resource);
- Set set= (Set)fResourceTree.get(parent);
+ Set<IResource> set= fResourceTree.get(parent);
if (set == null) {
- set= new HashSet(1);
+ set= new HashSet<>(1);
fResourceTree.put(parent, set);
}
set.add(resource);
}
}
- fRoots= (IResource[])roots.toArray(new IResource[roots.size()]);
+ fRoots= roots.toArray(new IResource[roots.size()]);
}
+ @Override
public Object[] getChildren(Object parentElement) {
- Set set= (Set) fResourceTree.get(parentElement);
+ Set<IResource> set= fResourceTree.get(parentElement);
if (set != null) {
return set.toArray();
}
return EMPTY_ARRAY;
}
+ @Override
public Object getParent(Object element) {
if (element instanceof IResource) {
return ((IResource)element).getParent();
@@ -61,18 +66,22 @@ public class ResourceSetContentProvider implements ITreeContentProvider {
return null;
}
+ @Override
public boolean hasChildren(Object element) {
return fResourceTree.get(element) != null;
}
+ @Override
public Object[] getElements(Object inputElement) {
return fRoots;
}
+ @Override
public void dispose() {
fResourceTree= null;
}
+ @Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/AddToControlAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/AddToControlAction.java
index 654a17ad5..5932d946b 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/AddToControlAction.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/AddToControlAction.java
@@ -12,9 +12,8 @@
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.team.examples.pessimistic.ui;
-
+
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -34,29 +33,30 @@ public class AddToControlAction extends PessimisticProviderAction {
/**
* Collects the selected resources, sorts them by project
* and adds them to their respective repository providers.
- *
+ *
* @see IActionDelegate#run(IAction)
*/
+ @Override
public void run(IAction action) {
IResource[] resources= getSelectedResources();
if (resources == null || resources.length == 0)
return;
- Set resourceSet= new HashSet(resources.length);
- for(int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
+ Set<IResource> resourceSet = new HashSet<>(resources.length);
+ for (IResource resource2 : resources) {
+ IResource resource= resource2;
while (resource.getType() != IResource.PROJECT && !isControlled(resource)) {
resourceSet.add(resource);
resource= resource.getParent();
}
}
if (!resourceSet.isEmpty()) {
- final Map byProject= sortByProject(resourceSet);
+ final Map<IProject, Set<IResource>> byProject = sortByProject(resourceSet);
IRunnableWithProgress runnable= monitor -> {
- for (Iterator i= byProject.keySet().iterator(); i.hasNext();) {
- IProject project= (IProject) i.next();
+ for (Object element : byProject.keySet()) {
+ IProject project= (IProject) element;
PessimisticFilesystemProvider provider= getProvider(project);
if (provider != null) {
- Set set= (Set)byProject.get(project);
+ Set<IResource> set = byProject.get(project);
IResource[] resources1= new IResource[set.size()];
set.toArray(resources1);
provider.addToControl(resources1, monitor);
@@ -70,16 +70,17 @@ public class AddToControlAction extends PessimisticProviderAction {
/**
* Answers <code>true</code> if the selected resource is not
* a project (or the workspace root) and is not controlled.
- *
+ *
* @see PessimisticProviderAction#shouldEnableFor(IResource)
*/
+ @Override
protected boolean shouldEnableFor(IResource resource) {
if (resource == null) {
return false;
}
if ((resource.getType() & (IResource.ROOT | IResource.PROJECT)) != 0) {
return false;
- }
+ }
PessimisticFilesystemProvider provider= getProvider(resource);
if (provider == null)
return false;
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/DisconnectAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/DisconnectAction.java
index 2a3f8ea27..82772f62f 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/DisconnectAction.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/DisconnectAction.java
@@ -12,9 +12,8 @@
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.team.examples.pessimistic.ui;
-
+
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
import org.eclipse.core.resources.IProject;
@@ -34,19 +33,19 @@ public class DisconnectAction extends PessimisticProviderAction {
/**
* Collects the selected resources, extracts the projects selected
* and disconnects the projects from their respective providers.
- *
+ *
* @see IActionDelegate#run(IAction)
*/
+ @Override
public void run(IAction action) {
if (PessimisticFilesystemProviderPlugin.getInstance().isDebugging())
System.out.println("Disconnect");
-
+
IResource[] resources= getSelectedResources();
if (resources == null || resources.length == 0)
return;
- final Set projects= new HashSet(resources.length);
- for(int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
+ final Set<IProject> projects = new HashSet<>(resources.length);
+ for (IResource resource : resources) {
if (resource.getType() == IResource.PROJECT) {
projects.add(resource.getProject());
}
@@ -54,35 +53,36 @@ public class DisconnectAction extends PessimisticProviderAction {
if (!projects.isEmpty()) {
IRunnableWithProgress runnable= monitor -> {
IWorkspaceRunnable runnable1= monitor1 -> {
- for (Iterator i= projects.iterator(); i.hasNext();) {
- IProject project= (IProject) i.next();
- PessimisticFilesystemProvider provider= getProvider(project);
- if (provider != null) {
- try {
- RepositoryProvider.unmap(project);
- } catch (TeamException e1) {
- PessimisticFilesystemProviderPlugin.getInstance().logError(e1, "Could not unmap " + project);
- }
+ for (Object element : projects) {
+ IProject project= (IProject) element;
+ PessimisticFilesystemProvider provider= getProvider(project);
+ if (provider != null) {
+ try {
+ RepositoryProvider.unmap(project);
+ } catch (TeamException e1) {
+ PessimisticFilesystemProviderPlugin.getInstance().logError(e1, "Could not unmap " + project);
+ }
+ }
}
- }
-};
+ };
try {
ResourcesPlugin.getWorkspace().run(runnable1, monitor);
} catch (CoreException e2) {
- PessimisticFilesystemProviderPlugin.getInstance().logError(e2, "Problem during unmap runnable");
+ PessimisticFilesystemProviderPlugin.getInstance().logError(e2, "Problem during unmap runnable");
}
-
+
};
runWithProgressDialog(runnable);
}
}
-
+
/**
- * Answers <code>true</code> if and only if the resource is a
+ * Answers <code>true</code> if and only if the resource is a
* project and is controlled by the pessimistic filesystem provider.
- *
+ *
* @see PessimisticProviderAction#shouldEnableFor(IResource)
*/
+ @Override
protected boolean shouldEnableFor(IResource resource) {
if (resource.getType() == IResource.PROJECT) {
PessimisticFilesystemProvider provider= getProvider(resource);
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticProviderAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticProviderAction.java
index 0c1b79a27..82258ab42 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticProviderAction.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/PessimisticProviderAction.java
@@ -14,9 +14,16 @@
package org.eclipse.team.examples.pessimistic.ui;
import java.lang.reflect.InvocationTargetException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
-import org.eclipse.core.resources.*;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.action.IAction;
@@ -37,7 +44,7 @@ import org.eclipse.ui.IWorkbenchPart;
* Provides convenience methods an abstractions.
*/
public abstract class PessimisticProviderAction
- implements IObjectActionDelegate {
+implements IObjectActionDelegate {
/*
* The current selection.
@@ -48,31 +55,27 @@ public abstract class PessimisticProviderAction
*/
protected Shell fShell;
- /*
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
- */
+ @Override
public void selectionChanged(IAction action, ISelection selection) {
fSelection = selection;
-
+
boolean enabled= action.isEnabled();
if (enabled != checkEnablement()) {
action.setEnabled(!enabled);
}
}
-
- /*
- * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
- */
+
+ @Override
public void setActivePart(IAction action, IWorkbenchPart part) {
fShell= part.getSite().getShell();
- }
+ }
/**
* Answers <code>true</code> if this action should be enabled
* for the given <code>resource</code>.
*/
protected abstract boolean shouldEnableFor(IResource resource);
-
+
/*
* Checks to see if this action should be enabled.
*/
@@ -89,26 +92,26 @@ public abstract class PessimisticProviderAction
}
return enabled;
}
-
+
/**
* Convenience method to get an array of resources from the selection.
*/
protected IResource[] getSelectedResources() {
- ArrayList resources = null;
+ ArrayList<IResource> resources = null;
if (!fSelection.isEmpty()) {
- resources = new ArrayList();
+ resources = new ArrayList<>();
Iterator elements = ((IStructuredSelection) fSelection).iterator();
while (elements.hasNext()) {
Object next = elements.next();
if (next instanceof IResource) {
- resources.add(next);
+ resources.add((IResource) next);
continue;
}
if (next instanceof IAdaptable) {
IAdaptable a = (IAdaptable) next;
Object adapter = a.getAdapter(IResource.class);
if (adapter instanceof IResource) {
- resources.add(adapter);
+ resources.add((IResource) adapter);
continue;
}
}
@@ -119,9 +122,9 @@ public abstract class PessimisticProviderAction
resources.toArray(result);
return result;
}
- return new IResource[0];
+ return new IResource[0];
}
-
+
/**
* Convenience method which answers <code>true</code> if the
* resource is controlled by a <code>PessimisticFilesystemProvider</code>.
@@ -132,7 +135,7 @@ public abstract class PessimisticProviderAction
return false;
return provider.isControlled(resource);
}
-
+
/**
* Convenience method which answers <code>true</code> if and only if the
* resource is controlled by a <code>PessimisticFilesystemProvider</code>
@@ -159,7 +162,7 @@ public abstract class PessimisticProviderAction
/**
* Convenience method which answers the <code>PessimisticFilesystemProvider</code>
- * for the given <code>resource</code> or <code>null</code> if the
+ * for the given <code>resource</code> or <code>null</code> if the
* <code>resource</code> is not associated with a <code>PessimisticFilesystemProvider</code>.
*/
protected PessimisticFilesystemProvider getProvider(IResource resource) {
@@ -177,7 +180,7 @@ public abstract class PessimisticProviderAction
* Convenience method which walks a resource tree and collects the
* resources that this action would enable for.
*/
- protected void recursivelyAdd(IResource resource, Set resources) {
+ protected void recursivelyAdd(IResource resource, Set<IResource> resources) {
if (isControlled(resource) && !isIgnored(resource)) {
if (shouldEnableFor(resource)) {
resources.add(resource);
@@ -192,27 +195,26 @@ public abstract class PessimisticProviderAction
PessimisticFilesystemProviderPlugin.getInstance().logError(e, "Exception traversing members");
}
if (members != null) {
- for (int i = 0; i < members.length; i++) {
- recursivelyAdd(members[i], resources);
+ for (IResource member : members) {
+ recursivelyAdd(member, resources);
}
}
}
- }
+ }
}
/**
* Convenience method which sorts the given <code>resources</code>
* into a map of IProject -> Set of IResource objects.
*/
- protected Map sortByProject(Set resources) {
- Map byProject= new HashMap();
+ protected Map<IProject, Set<IResource>> sortByProject(Set<IResource> resources) {
+ Map<IProject, Set<IResource>> byProject = new HashMap<>();
if (resources != null) {
- for (Iterator i= resources.iterator(); i.hasNext();) {
- IResource resource= (IResource) i.next();
+ for (IResource resource : resources) {
IProject project= resource.getProject();
- Set set= (Set)byProject.get(project);
+ Set<IResource> set = byProject.get(project);
if (set == null) {
- set= new HashSet(1);
+ set = new HashSet<>(1);
byProject.put(project, set);
}
set.add(resource);
@@ -220,7 +222,7 @@ public abstract class PessimisticProviderAction
}
return byProject;
}
-
+
/**
* Convenience method for displaying runnable progress
* with a <code>ProgressMonitorDialog</code>.
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/RemoveFromControlAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/RemoveFromControlAction.java
index ba24b1251..da3c9c320 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/RemoveFromControlAction.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/RemoveFromControlAction.java
@@ -14,7 +14,6 @@
package org.eclipse.team.examples.pessimistic.ui;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -29,31 +28,30 @@ import org.eclipse.team.examples.pessimistic.PessimisticFilesystemProvider;
* the control of the provider.
*/
public class RemoveFromControlAction extends PessimisticProviderAction {
-
+
/**
* Collects the selected resources into sets by project,
* then removes the resources from the provider associated
* with their containing project.
- *
+ *
* @see org.eclipse.ui.IActionDelegate#run(IAction)
*/
+ @Override
public void run(IAction action) {
IResource[] resources= getSelectedResources();
if (resources == null || resources.length == 0)
return;
- Set resourceSet= new HashSet(resources.length);
- for(int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
+ Set<IResource> resourceSet = new HashSet<>(resources.length);
+ for (IResource resource : resources) {
recursivelyAdd(resource, resourceSet);
}
if (!resourceSet.isEmpty()) {
- final Map byProject= sortByProject(resourceSet);
+ final Map<IProject, Set<IResource>> byProject = sortByProject(resourceSet);
IRunnableWithProgress runnable= monitor -> {
- for (Iterator i= byProject.keySet().iterator(); i.hasNext();) {
- IProject project= (IProject) i.next();
+ for (IProject project : byProject.keySet()) {
PessimisticFilesystemProvider provider= getProvider(project);
if (provider != null) {
- Set set= (Set)byProject.get(project);
+ Set<IResource> set = byProject.get(project);
IResource[] resources1= new IResource[set.size()];
set.toArray(resources1);
provider.removeFromControl(resources1, monitor);
@@ -67,9 +65,10 @@ public class RemoveFromControlAction extends PessimisticProviderAction {
/**
* Answers <code>true</code> if and only if the resource is not <code>null</code>,
* not a project or the workspace root, and is controlled by the provider.
- *
+ *
* @see org.eclipse.team.examples.pessimistic.ui.PessimisticProviderAction#shouldEnableFor(IResource)
*/
+ @Override
protected boolean shouldEnableFor(IResource resource) {
if (resource == null) {
return false;
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/SourceManagementAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/SourceManagementAction.java
index ffe6985cd..94aff96e4 100644
--- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/SourceManagementAction.java
+++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/pessimistic/ui/SourceManagementAction.java
@@ -14,7 +14,6 @@
package org.eclipse.team.examples.pessimistic.ui;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@@ -33,29 +32,28 @@ public abstract class SourceManagementAction extends PessimisticProviderAction {
/**
* Collects the selected resources by project, then iterates
- * over the projects finding the associated provider. If a
+ * over the projects finding the associated provider. If a
* provider is found it requests that this action manage the resources
* using the found provider.
- *
+ *
* @see org.eclipse.ui.IActionDelegate#run(IAction)
*/
+ @Override
public void run(IAction action) {
IResource[] resources= getSelectedResources();
if (resources == null || resources.length == 0)
return;
- Set resourceSet= new HashSet(resources.length);
- for(int i= 0; i < resources.length; i++) {
- IResource resource= resources[i];
+ Set<IResource> resourceSet = new HashSet<>(resources.length);
+ for (IResource resource : resources) {
recursivelyAdd(resource, resourceSet);
}
if (!resourceSet.isEmpty()) {
- final Map byProject= sortByProject(resourceSet);
+ final Map<IProject, Set<IResource>> byProject = sortByProject(resourceSet);
IRunnableWithProgress runnable= monitor -> {
- for (Iterator i= byProject.keySet().iterator(); i.hasNext();) {
- IProject project= (IProject) i.next();
+ for (IProject project : byProject.keySet()) {
PessimisticFilesystemProvider provider= getProvider(project);
if (provider != null) {
- Set set= (Set)byProject.get(project);
+ Set<IResource> set = byProject.get(project);
IResource[] resources1= new IResource[set.size()];
set.toArray(resources1);
manageResources(provider, resources1, monitor);
@@ -63,12 +61,12 @@ public abstract class SourceManagementAction extends PessimisticProviderAction {
}
};
runWithProgressDialog(runnable);
- }
+ }
}
/**
* Manages the <code>resources</code> using the given <code>provider</code>.
- *
+ *
* @param provider The provider associated with the resources.
* @param resources The resources to be managed.
* @param monitor A progress monitor to give feedback.

Back to the top