Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2015-06-24 18:31:41 +0000
committerTom Schindl2015-06-24 18:32:13 +0000
commita97a070b092bd61e14bebad332bb1d9970d629e3 (patch)
treed08d515e1dff10152320475c0e0470d752800995
parent84c1669c0a551c52c58cd064f640323f281997eb (diff)
downloadorg.eclipse.rap.incubator.e4-a97a070b092bd61e14bebad332bb1d9970d629e3.tar.gz
org.eclipse.rap.incubator.e4-a97a070b092bd61e14bebad332bb1d9970d629e3.tar.xz
org.eclipse.rap.incubator.e4-a97a070b092bd61e14bebad332bb1d9970d629e3.zip
Bug 470875 - [e4] Update to Mars
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/.classpath2
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/.settings/org.eclipse.jdt.core.prefs126
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/.settings/org.eclipse.jdt.ui.prefs18
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/META-INF/MANIFEST.MF9
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/build.properties3
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AbstractPartRenderer.java12
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AnimationEngine.java6
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AnimationFeedbackBase.java39
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/CSSConstants.java14
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java223
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/IEventLoopAdvisor.java4
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/MenuService.java25
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java451
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/SelectionAdapterFactory.java54
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/ShellActivationListener.java6
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/WorkbenchSWTActivator.java71
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/handlers/ThemeUtil.java6
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/BasicUIJob.java8
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/FilteredTree.java261
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/PatternFilter.java61
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/SearchPattern.java679
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/ShowViewDialog.java25
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/StringMatcher.java26
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/ViewComparator.java2
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/ViewContentProvider.java4
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/util/BindingProcessingAddon.java5
-rw-r--r--bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/util/ISWTResourceUtilities.java4
27 files changed, 1428 insertions, 716 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/.classpath b/bundles/org.eclipse.e4.ui.workbench.swt/.classpath
index 4c62a80..e8ea977 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/.classpath
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/.classpath
@@ -2,6 +2,6 @@
<classpath>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.e4.ui.workbench.swt/.settings/org.eclipse.jdt.core.prefs
index ae7061b..cb3755e 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/.settings/org.eclipse.jdt.core.prefs
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/.settings/org.eclipse.jdt.core.prefs
@@ -1,12 +1,107 @@
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.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
+org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
+org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.7
+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.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+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=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+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=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+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=warning
+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=warning
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=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=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+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=warning
+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=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+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.source=1.7
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
@@ -17,15 +112,18 @@ org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
org.eclipse.jdt.core.formatter.blank_lines_before_field=0
@@ -45,6 +143,7 @@ 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
@@ -61,10 +160,16 @@ org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
org.eclipse.jdt.core.formatter.comment.line_length=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=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
@@ -82,7 +187,9 @@ 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
@@ -130,6 +237,7 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=inser
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
@@ -148,12 +256,14 @@ org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invoca
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
@@ -177,6 +287,7 @@ org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invoc
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
@@ -204,6 +315,7 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do n
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
@@ -232,6 +344,7 @@ org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invoc
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
@@ -241,6 +354,7 @@ org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=inser
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
@@ -256,7 +370,7 @@ org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
-org.eclipse.jdt.core.formatter.lineSplit=80
+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
@@ -264,5 +378,9 @@ org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=tab
org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.use_on_off_tags=false
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
+org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
+org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/.settings/org.eclipse.jdt.ui.prefs b/bundles/org.eclipse.e4.ui.workbench.swt/.settings/org.eclipse.jdt.ui.prefs
index 7cdc626..2bb4b14 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/.settings/org.eclipse.jdt.ui.prefs
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/.settings/org.eclipse.jdt.ui.prefs
@@ -1,14 +1,14 @@
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=11
+formatter_settings_version=12
org.eclipse.jdt.ui.ignorelowercasenames=true
org.eclipse.jdt.ui.importorder=;
org.eclipse.jdt.ui.ondemandthreshold=99
org.eclipse.jdt.ui.staticondemandthreshold=99
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_annotations=false
sp_cleanup.add_missing_deprecated_annotations=true
sp_cleanup.add_missing_methods=false
sp_cleanup.add_missing_nls_tags=false
@@ -19,18 +19,20 @@ 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=false
sp_cleanup.convert_to_enhanced_for_loop=false
sp_cleanup.correct_indentation=false
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=false
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=true
+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=false
+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
@@ -38,10 +40,11 @@ sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=
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_trailing_whitespaces=false
+sp_cleanup.remove_redundant_type_arguments=false
+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_casts=false
sp_cleanup.remove_unnecessary_nls_tags=false
sp_cleanup.remove_unused_imports=false
sp_cleanup.remove_unused_local_variables=false
@@ -51,10 +54,13 @@ 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=false
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
+sp_cleanup.use_type_arguments=false
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.ui.workbench.swt/META-INF/MANIFEST.MF
index ddadffc..daa1ba4 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.eclipse.e4.ui.workbench.swt;singleton:=true
-Bundle-Version: 0.12.100.qualifier
+Bundle-Version: 0.13.0.qualifier
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -19,7 +19,7 @@ Require-Bundle: org.eclipse.equinox.registry;bundle-version="[3.5.0,4.0.0)",
org.eclipse.e4.core.di;bundle-version="1.1.0",
org.eclipse.core.expressions;bundle-version="[3.4.200,4.0.0)",
org.eclipse.osgi;bundle-version="[3.6.0,4.0.0)",
- org.eclipse.core.runtime;bundle-version="[3.6.0,4.0.0)",
+ org.eclipse.core.runtime;bundle-version="[3.11.0,4.0.0)",
org.eclipse.e4.core.commands;bundle-version="0.9.0",
org.eclipse.e4.ui.di;bundle-version="0.9.0",
org.eclipse.equinox.ds,
@@ -28,9 +28,10 @@ Require-Bundle: org.eclipse.equinox.registry;bundle-version="[3.5.0,4.0.0)",
org.eclipse.e4.ui.model.workbench;bundle-version="1.0.0",
org.eclipse.core.commands,
org.eclipse.rap.jface,
- org.eclipse.rap.jface.databinding
+ org.eclipse.rap.jface.databinding,
+ org.eclipse.e4.core.di.extensions
Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Export-Package: org.eclipse.e4.ui.internal.workbench.swt;x-friends:="org.eclipse.e4.ui.workbench.addons.swt,org.eclipse.e4.ui.workbench.renderers.swt,org.eclipse.ui.workbench",
org.eclipse.e4.ui.internal.workbench.swt.handlers;x-internal:=true,
org.eclipse.e4.ui.workbench.swt.factories;x-friends:="org.eclipse.e4.ui.workbench.renderers.swt,org.eclipse.ui.workbench",
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/build.properties b/bundles/org.eclipse.e4.ui.workbench.swt/build.properties
index f8d9729..aa6bb3f 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/build.properties
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/build.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2010, 2011 IBM Corporation and others.
+# Copyright (c) 2010, 2015 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -20,3 +20,4 @@ bin.includes = META-INF/,\
source.. = src/
src.includes = icons/,\
about.html
+jre.compilation.profile = JavaSE-1.7
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AbstractPartRenderer.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AbstractPartRenderer.java
index 1e07aae..025a261 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AbstractPartRenderer.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AbstractPartRenderer.java
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Lars Vogel <Lars.Vogel@gmail.com> - Bug 429728
@@ -67,7 +67,7 @@ public abstract class AbstractPartRenderer {
/**
* Return a parent context for this part.
- *
+ *
* @param element
* the part to start searching from
* @return the parent's closest context, or global context if none in the
@@ -79,7 +79,7 @@ public abstract class AbstractPartRenderer {
/**
* Return a context for this part.
- *
+ *
* @param part
* the part to start searching from
* @return the closest context, or global context if none in the hierarchy
@@ -94,7 +94,7 @@ public abstract class AbstractPartRenderer {
/**
* Activate the part in the hierarchy. This should either still be internal
* or be a public method somewhere else.
- *
+ *
* @param element
*/
public void activate(MPart element) {
@@ -109,7 +109,7 @@ public abstract class AbstractPartRenderer {
/**
* Check if activating {@code element} requires that the part set the focus.
- *
+ *
* @param element
* @return true if the part requires focus
*/
@@ -129,7 +129,7 @@ public abstract class AbstractPartRenderer {
* Force the UI focus into the element if possible. This method should not
* be called directly, it will be called by the IPresentationEngine#focusGui
* method if the normal process used to set the focus cannot be performed.
- *
+ *
* @param element
*/
public void forceFocus(MUIElement element) {
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AnimationEngine.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AnimationEngine.java
index bdfb3d0..28dce5a 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AnimationEngine.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AnimationEngine.java
@@ -24,9 +24,9 @@ import org.eclipse.swt.widgets.Display;
* This job creates an Animation Engine that uses an Animation Feedback to
* render the animation. To begin the animation, instantiate this object then
* call schedule().
- *
+ *
* @since 3.3
- *
+ *
*/
public class AnimationEngine extends Job {
public static final int TICK_TIMER = 1;
@@ -53,7 +53,7 @@ public class AnimationEngine extends Job {
/**
* Creates an Animation that will run for the given number of milliseconds.
- *
+ *
* @param animationFeedback
* provides renderStep(), initialize() and jobInit() methods
* @param durationIn
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AnimationFeedbackBase.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AnimationFeedbackBase.java
index 43856e5..3dba62b 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AnimationFeedbackBase.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AnimationFeedbackBase.java
@@ -16,13 +16,12 @@ import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Shell;
/**
- * AnimationFeedBackBase is an abstract class which provides renderStep(), jobInit() and
- * initialize() methods for AnimationEngine.
- * Its the base class for all the
- * animationFeedbacks
- *
+ * AnimationFeedBackBase is an abstract class which provides renderStep(),
+ * jobInit() and initialize() methods for AnimationEngine. Its the base class
+ * for all the animationFeedbacks
+ *
* @since 3.3
- *
+ *
*/
public abstract class AnimationFeedbackBase {
private AnimationEngine engine;
@@ -31,12 +30,13 @@ public abstract class AnimationFeedbackBase {
/**
* Creates an AnimationFeedback
- *
- * @param parentShell specifies the composite where the animation will be drawn
+ *
+ * @param parentShell
+ * specifies the composite where the animation will be drawn
*/
public AnimationFeedbackBase(Shell parentShell) {
baseShell = parentShell;
-
+
baseShell.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
@@ -49,24 +49,27 @@ public abstract class AnimationFeedbackBase {
/**
* Perform any initialization you want to do -prior- to the Job actually
* gets scheduled.
- *
- * @param animationEngine The engine we're hosted in.
+ *
+ * @param animationEngine
+ * The engine we're hosted in.
*/
public abstract void initialize(AnimationEngine animationEngine);
/**
* Its a draw method. All the code to render an animation goes in this
* method.
- *
+ *
* @param engine
*/
public abstract void renderStep(AnimationEngine engine);
/**
* Perform any initialization you want to have happen -before- the animation
- * starts. Subclasses may subclass but not override (i.e. you have to call super).
- *
- * @param engine The AnimationEngine hosting the feedback
+ * starts. Subclasses may subclass but not override (i.e. you have to call
+ * super).
+ *
+ * @param engine
+ * The AnimationEngine hosting the feedback
* @return 'true' iff the animation is capable of running
*/
public boolean jobInit(AnimationEngine engine) {
@@ -94,8 +97,8 @@ public abstract class AnimationFeedbackBase {
*/
public Shell getAnimationShell() {
if (animationShell == null) {
- animationShell = new Shell(getBaseShell(), SWT.NO_TRIM | SWT.ON_TOP);
-
+ animationShell = new Shell(getBaseShell(), SWT.NO_TRIM | SWT.ON_TOP);
+
animationShell.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
@@ -104,7 +107,7 @@ public abstract class AnimationFeedbackBase {
}
});
}
-
+
return animationShell;
}
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/CSSConstants.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/CSSConstants.java
index 75c6ce5..6eec483 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/CSSConstants.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/CSSConstants.java
@@ -1,20 +1,22 @@
/*******************************************************************************
- * Copyright (c) 2013 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
+ * Copyright (c) 2013, 2014 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
+ * which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
- * IBM Corporation - initial API and implementation
+ * Contributors:
+ * IBM Corporation - initial API and implementation
******************************************************************************/
package org.eclipse.e4.ui.internal.workbench.swt;
+import org.eclipse.e4.ui.workbench.IPresentationEngine;
+
public class CSSConstants {
public static final String CSS_BUSY_CLASS = "busy";
- public static final String CSS_ACTIVE_CLASS = "active";
+ public static final String CSS_ACTIVE_CLASS = IPresentationEngine.ACTIVE;
public static final String CSS_NO_FOCUS_CLASS = "noFocus";
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java
index 472ccfe..e62fcb8 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java
@@ -10,7 +10,9 @@
* Tristan Hume - <trishume@gmail.com> -
* Fix for Bug 2369 [Workbench] Would like to be able to save workspace without exiting
* Implemented workbench auto-save to correctly restore state in case of crash.
- * Lars Vogel <Lars.Vogel@gmail.com> - Bug 366364
+ * Lars Vogel <Lars.Vogel@vogella.com> - Bug 366364, 445724, 446088
+ * Terry Parker <tparker@google.com> - Bug 416673
+ * Christian Georgi (SAP) - Bug 432480
******************************************************************************/
package org.eclipse.e4.ui.internal.workbench.swt;
@@ -22,10 +24,10 @@ import java.io.IOException;
import java.io.OutputStream;
import java.net.URL;
import java.util.List;
+import java.util.Locale;
import java.util.Properties;
import java.util.UUID;
import org.eclipse.core.databinding.observable.Realm;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IProduct;
import org.eclipse.core.runtime.Platform;
@@ -108,6 +110,7 @@ public class E4Application implements IApplication {
private static final String WORKSPACE_VERSION_VALUE = "2"; //$NON-NLS-1$
private static final String APPLICATION_MODEL_PATH_DEFAULT = "Application.e4xmi";
private static final String PERSPECTIVE_ARG_NAME = "perspective";
+ private static final String SHOWLOCATION_ARG_NAME = "showLocation";
private static final String DEFAULT_THEME_ID = "org.eclipse.e4.ui.css.theme.e4_default";
public static final String HIGH_CONTRAST_THEME_ID = "org.eclipse.e4.ui.css.theme.high-contrast";
@@ -132,8 +135,7 @@ public class E4Application implements IApplication {
}
@Override
- public Object start(IApplicationContext applicationContext)
- throws Exception {
+ public Object start(IApplicationContext applicationContext) throws Exception {
// set the display name before the Display is
// created to ensure the app name is used in any
// platform menus, etc. See
@@ -145,15 +147,13 @@ public class E4Application implements IApplication {
Display display = getApplicationDisplay();
Location instanceLocation = null;
try {
- E4Workbench workbench = createE4Workbench(applicationContext,
- display);
+ E4Workbench workbench = createE4Workbench(applicationContext, display);
if (workbench == null) {
display.dispose();
return EXIT_OK;
}
- instanceLocation = (Location) workbench.getContext().get(
- E4Workbench.INSTANCE_LOCATION);
+ instanceLocation = (Location) workbench.getContext().get(E4Workbench.INSTANCE_LOCATION);
Shell shell = display.getActiveShell();
if (shell == null) {
shell = new Shell();
@@ -164,16 +164,9 @@ public class E4Application implements IApplication {
workbench.getContext()))
return EXIT_OK;
- IEclipseContext workbenchContext = workbench.getContext();
-
// Create and run the UI (if any)
workbench.createAndRunUI(workbench.getApplication());
- // Save the model into the targetURI
- if (lcManager != null) {
- ContextInjectionFactory.invoke(lcManager, PreSave.class,
- workbenchContext, null);
- }
saveModel();
workbench.close();
@@ -191,21 +184,34 @@ public class E4Application implements IApplication {
}
public void saveModel() {
+ // Save the model into the targetURI
+ if (lcManager != null && workbench != null) {
+ ContextInjectionFactory.invoke(lcManager, PreSave.class, workbench.getContext(), null);
+ }
+
try {
- handler.save();
+ if (!(handler instanceof ResourceHandler) || ((ResourceHandler) handler).hasTopLevelWindows()) {
+ handler.save();
+ } else {
+ Logger logger = new WorkbenchLogger(PLUGIN_ID);
+ logger.error(new Exception(), // log a stack trace for debugging
+ "Attempted to save a workbench model that had no top-level windows! " //$NON-NLS-1$
+ + "Skipped saving the model to avoid corruption."); //$NON-NLS-1$
+ }
+
} catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ Logger logger = new WorkbenchLogger(PLUGIN_ID);
+ logger.error(e, "Error saving the workbench model"); //$NON-NLS-1$
}
}
public E4Workbench createE4Workbench(
IApplicationContext applicationContext, final Display display) {
- args = (String[]) applicationContext.getArguments().get(
- IApplicationContext.APPLICATION_ARGS);
+ args = (String[]) applicationContext.getArguments().get(IApplicationContext.APPLICATION_ARGS);
final IEclipseContext appContext = createDefaultContext();
appContext.set(Display.class, display);
+ // FIXME RAP DisplayRealm not public!!!
appContext.set(Realm.class, SWTObservables.getRealm(display));
appContext.set(UISynchronize.class, new UISynchronize() {
@@ -230,13 +236,11 @@ public class E4Application implements IApplication {
ContextInjectionFactory.setDefault(appContext);
// Get the factory to create DI instances with
- IContributionFactory factory = (IContributionFactory) appContext
- .get(IContributionFactory.class.getName());
+ IContributionFactory factory = appContext.get(IContributionFactory.class);
// Install the life-cycle manager for this session if there's one
// defined
- String lifeCycleURI = getArgValue(IWorkbench.LIFE_CYCLE_URI_ARG,
- applicationContext, false);
+ String lifeCycleURI = getArgValue(IWorkbench.LIFE_CYCLE_URI_ARG, applicationContext, false);
if (lifeCycleURI != null) {
lcManager = factory.create(lifeCycleURI, appContext);
if (lcManager != null) {
@@ -251,16 +255,18 @@ public class E4Application implements IApplication {
}
}
- String forcedPerspectiveId = getArgValue(PERSPECTIVE_ARG_NAME,
- applicationContext, false);
+ String forcedPerspectiveId = getArgValue(PERSPECTIVE_ARG_NAME, applicationContext, false);
if (forcedPerspectiveId != null) {
- appContext.set(E4Workbench.FORCED_PERSPECTIVE_ID,
- forcedPerspectiveId);
+ appContext.set(E4Workbench.FORCED_PERSPECTIVE_ID, forcedPerspectiveId);
+ }
+
+ String showLocation = getLocationFromCommandLine();
+ if (showLocation != null) {
+ appContext.set(E4Workbench.FORCED_SHOW_LOCATION, showLocation);
}
// Create the app model and its context
- MApplication appModel = loadApplicationModel(applicationContext,
- appContext);
+ MApplication appModel = loadApplicationModel(applicationContext, appContext);
appModel.setContext(appContext);
// TODO RAP Unsupported
@@ -271,25 +277,21 @@ public class E4Application implements IApplication {
// for compatibility layer: set the application in the OSGi service
// context (see Workbench#getInstance())
- if (!E4Workbench.getServiceContext().containsKey(
- MApplication.class.getName())) {
+ if (!E4Workbench.getServiceContext().containsKey(MApplication.class)) {
// first one wins.
- E4Workbench.getServiceContext().set(MApplication.class.getName(),
- appModel);
+ E4Workbench.getServiceContext().set(MApplication.class, appModel);
}
// Set the app's context after adding itself
- appContext.set(MApplication.class.getName(), appModel);
+ appContext.set(MApplication.class, appModel);
// adds basic services to the contexts
initializeServices(appModel);
// let the life cycle manager add to the model
if (lcManager != null) {
- ContextInjectionFactory.invoke(lcManager, ProcessAdditions.class,
- appContext, null);
- ContextInjectionFactory.invoke(lcManager, ProcessRemovals.class,
- appContext, null);
+ ContextInjectionFactory.invoke(lcManager, ProcessAdditions.class, appContext, null);
+ ContextInjectionFactory.invoke(lcManager, ProcessRemovals.class, appContext, null);
}
// Create the addons
@@ -303,8 +305,7 @@ public class E4Application implements IApplication {
// Parse out parameters from both the command line and/or the product
// definition (if any) and put them in the context
- String xmiURI = getArgValue(IWorkbench.XMI_URI_ARG, applicationContext,
- false);
+ String xmiURI = getArgValue(IWorkbench.XMI_URI_ARG, applicationContext, false);
appContext.set(IWorkbench.XMI_URI_ARG, xmiURI);
String cssURI = getArgValue(IWorkbench.CSS_URI_ARG, applicationContext,
@@ -314,14 +315,11 @@ public class E4Application implements IApplication {
}
setCSSContextVariables(applicationContext, appContext);
- appContext.set(
- E4Workbench.RENDERER_FACTORY_URI,
- getArgValue(E4Workbench.RENDERER_FACTORY_URI,
- applicationContext, false));
+ String rendererFactoryURI = getArgValue(E4Workbench.RENDERER_FACTORY_URI, applicationContext, false);
+ appContext.set(E4Workbench.RENDERER_FACTORY_URI, rendererFactoryURI);
// This is a default arg, if missing we use the default rendering engine
- String presentationURI = getArgValue(IWorkbench.PRESENTATION_URI_ARG,
- applicationContext, false);
+ String presentationURI = getArgValue(IWorkbench.PRESENTATION_URI_ARG, applicationContext, false);
if (presentationURI == null) {
presentationURI = PartRenderingEngine.engineURI;
}
@@ -365,8 +363,7 @@ public class E4Application implements IApplication {
context.set(E4Application.THEME_ID, cssURI);
}
- String cssResourcesURI = getArgValue(IWorkbench.CSS_RESOURCE_URI_ARG,
- applicationContext, false);
+ String cssResourcesURI = getArgValue(IWorkbench.CSS_RESOURCE_URI_ARG, applicationContext, false);
context.set(IWorkbench.CSS_RESOURCE_URI_ARG, cssResourcesURI);
}
@@ -377,30 +374,8 @@ public class E4Application implements IApplication {
Location instanceLocation = WorkbenchSWTActivator.getDefault()
.getInstanceLocation();
- String appModelPath = getArgValue(IWorkbench.XMI_URI_ARG, appContext,
- false);
- if (appModelPath == null || appModelPath.length() == 0) {
- Bundle brandingBundle = appContext.getBrandingBundle();
- if (brandingBundle != null)
- appModelPath = brandingBundle.getSymbolicName() + "/"
- + E4Application.APPLICATION_MODEL_PATH_DEFAULT;
- }
- Assert.isNotNull(appModelPath, IWorkbench.XMI_URI_ARG
- + " argument missing"); //$NON-NLS-1$
-
- URI initialWorkbenchDefinitionInstance;
-
- // check if the appModelPath is already a platform-URI and if so use it
- if (URIHelper.isPlatformURI(appModelPath)) {
- initialWorkbenchDefinitionInstance = URI.createURI(appModelPath,
- true);
- } else {
- initialWorkbenchDefinitionInstance = URI.createPlatformPluginURI(
- appModelPath, true);
- }
-
- eclipseContext.set(E4Workbench.INITIAL_WORKBENCH_MODEL_URI,
- initialWorkbenchDefinitionInstance);
+ URI applicationModelURI = determineApplicationModelURI(appContext);
+ eclipseContext.set(E4Workbench.INITIAL_WORKBENCH_MODEL_URI, applicationModelURI);
// Save and restore
boolean saveAndRestore;
@@ -432,8 +407,7 @@ public class E4Application implements IApplication {
eclipseContext.set(E4Workbench.DELTA_RESTORE,
Boolean.valueOf(deltaRestore));
- String resourceHandler = getArgValue(IWorkbench.MODEL_RESOURCE_HANDLER,
- appContext, false);
+ String resourceHandler = getArgValue(IWorkbench.MODEL_RESOURCE_HANDLER, appContext, false);
if (resourceHandler == null) {
resourceHandler = "bundleclass://org.eclipse.e4.ui.workbench/"
@@ -453,8 +427,48 @@ public class E4Application implements IApplication {
return theApp;
}
- private String getArgValue(String argName, IApplicationContext appContext,
- boolean singledCmdArgValue) {
+ /**
+ * @param appContext
+ * @return
+ */
+ private URI determineApplicationModelURI(IApplicationContext appContext) {
+ String appModelPath = getArgValue(IWorkbench.XMI_URI_ARG, appContext, false);
+ if (appModelPath == null || appModelPath.length() == 0) {
+ Bundle brandingBundle = appContext.getBrandingBundle();
+ if (brandingBundle != null)
+ appModelPath = brandingBundle.getSymbolicName() + "/" + E4Application.APPLICATION_MODEL_PATH_DEFAULT;
+ else {
+ Logger logger = new WorkbenchLogger(PLUGIN_ID);
+ logger.error(new Exception(), // log a stack trace for debugging
+ "applicationXMI parameter not set and no branding plugin defined. "); //$NON-NLS-1$
+ }
+ }
+
+ URI applicationModelURI = null;
+
+ // check if the appModelPath is already a platform-URI and if so use it
+ if (URIHelper.isPlatformURI(appModelPath)) {
+ applicationModelURI = URI.createURI(appModelPath, true);
+ } else {
+ applicationModelURI = URI.createPlatformPluginURI(appModelPath, true);
+ }
+ return applicationModelURI;
+
+ }
+
+ /**
+ * Finds an argument's value in the app's command line arguments, branding,
+ * and system properties
+ *
+ * @param argName
+ * the argument name
+ * @param appContext
+ * the application context
+ * @param singledCmdArgValue
+ * whether it's a single-valued argument
+ * @return the value, or <code>null</code>
+ */
+ private String getArgValue(String argName, IApplicationContext appContext, boolean singledCmdArgValue) {
// Is it in the arg list ?
if (argName == null || argName.length() == 0)
return null;
@@ -476,6 +490,29 @@ public class E4Application implements IApplication {
: brandingProperty;
}
+ /**
+ * @return the value of the {@link E4Application#SHOWLOCATION_ARG_NAME
+ * showlocation} command line argument, or <code>null</code> if it
+ * is not set
+ */
+ private String getLocationFromCommandLine() {
+ final String fullArgName = "-" + SHOWLOCATION_ARG_NAME;
+ for (int i = 0; i < args.length; i++) {
+ // ignore case for compatibility reasons
+ if (fullArgName.equalsIgnoreCase(args[i])) { // $NON-NLS-1$
+ String name = null;
+ if (args.length > i + 1) {
+ name = args[i + 1];
+ }
+ if (name != null && name.indexOf("-") == -1) { //$NON-NLS-1$
+ return name;
+ }
+ return Platform.getLocation().toOSString();
+ }
+ }
+ return null;
+ }
+
@Override
public void stop() {
if (workbench != null) {
@@ -554,11 +591,7 @@ public class E4Application implements IApplication {
});
// translation
- String locale = RWT.getLocale().toString();
- appContext.set(TranslationService.LOCALE, locale);
- TranslationService bundleTranslationProvider = TranslationProviderFactory
- .bundleTranslationService(appContext);
- appContext.set(TranslationService.class, bundleTranslationProvider);
+ initializeLocalization(appContext);
// TODO RAP specific stuff
appContext.set(SettingStore.class, RWT.getSettingStore());
@@ -567,6 +600,20 @@ public class E4Application implements IApplication {
}
/**
+ * Initializes the given context with the locale and the TranslationService
+ * to use.
+ *
+ * @param appContext
+ * The application context to which the locale and the
+ * TranslationService should be set.
+ */
+ private static void initializeLocalization(IEclipseContext appContext) {
+ String locale = RWT.getLocale().toString();
+ appContext.set(TranslationService.LOCALE, new Locale(locale));
+ appContext.set(TranslationService.class, TranslationProviderFactory.bundleTranslationService(appContext));
+ }
+
+ /**
* Simplified copy of IDEAplication processing that does not offer to choose
* a workspace location.
*/
@@ -637,14 +684,14 @@ public class E4Application implements IApplication {
* // -data @noDefault or -data not specified, prompt and set
* ChooseWorkspaceData launchData = new ChooseWorkspaceData(instanceLoc
* .getDefault());
- *
+ *
* boolean force = false; while (true) { URL workspaceUrl =
* promptForWorkspace(shell, launchData, force); if (workspaceUrl ==
* null) { return false; }
- *
+ *
* // if there is an error with the first selection, then force the //
* dialog to open to give the user a chance to correct force = true;
- *
+ *
* try { // the operation will fail if the url is not a valid //
* instance data area, so other checking is unneeded if
* (instanceLocation.setURL(workspaceUrl, true)) {
@@ -653,7 +700,7 @@ public class E4Application implements IApplication {
* shell, IDEWorkbenchMessages.IDEApplication_workspaceCannotBeSetTitle,
* IDEWorkbenchMessages.IDEApplication_workspaceCannotBeSetMessage);
* return false; }
- *
+ *
* // by this point it has been determined that the workspace is //
* already in use -- force the user to choose again
* MessageDialog.openError(shell,
@@ -668,7 +715,7 @@ public class E4Application implements IApplication {
* false otherwise. A version check will be performed, and a confirmation
* box may be displayed on the argument shell if an older version is
* detected.
- *
+ *
* @return true if the argument URL is ok to use as a workspace and false
* otherwise.
*/
@@ -782,7 +829,7 @@ public class E4Application implements IApplication {
* The version file is stored in the metadata area of the workspace. This
* method returns an URL to the file or null if the directory or file does
* not exist (and the create parameter is false).
- *
+ *
* @param create
* If the directory and file does not exist this parameter
* controls whether it will be created.
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/IEventLoopAdvisor.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/IEventLoopAdvisor.java
index e87a855..0182309 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/IEventLoopAdvisor.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/IEventLoopAdvisor.java
@@ -29,7 +29,7 @@ public interface IEventLoopAdvisor {
* queue. Subclasses may override or extend this method. It is generally a
* bad idea to override with an empty method.
* </p>
- *
+ *
* @param display
* the main display of the rendering UI
*/
@@ -53,7 +53,7 @@ public interface IEventLoopAdvisor {
* a bad idea to override with an empty method, and you should be especially
* careful when handling Errors.
* </p>
- *
+ *
* @param exception
* the uncaught exception that was thrown inside the UI event
* loop
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/MenuService.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/MenuService.java
index 99f6853..b01b571 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/MenuService.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/MenuService.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2014 IBM Corporation and others.
+ * Copyright (c) 2010, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -47,19 +47,16 @@ public class MenuService implements EMenuService {
return false;
}
- public static Menu registerMenu(final Control parentControl,
- final MPopupMenu mmenu, IEclipseContext context) {
+ public static Menu registerMenu(final Control parentControl, final MPopupMenu mmenu, IEclipseContext context) {
if (mmenu.getWidget() != null) {
return (Menu) mmenu.getWidget();
}
// we need to delegate to the renderer so that it "processes" the
// MenuManager correctly
IRendererFactory rendererFactory = context.get(IRendererFactory.class);
- AbstractPartRenderer renderer = rendererFactory.getRenderer(mmenu,
- parentControl);
+ AbstractPartRenderer renderer = rendererFactory.getRenderer(mmenu, parentControl);
- IEclipseContext popupContext = context.createChild("popup:"
- + mmenu.getElementId());
+ IEclipseContext popupContext = context.createChild("popup:" + mmenu.getElementId());
mmenu.setContext(popupContext);
Object widget = renderer.createWidget(mmenu, parentControl);
if (!(widget instanceof Menu)) {
@@ -71,18 +68,20 @@ public class MenuService implements EMenuService {
// Process its internal structure through the renderer that created
// it
Object castObject = mmenu;
- renderer.processContents((MElementContainer<MUIElement>) castObject);
+ @SuppressWarnings("unchecked")
+ MElementContainer<MUIElement> container = (MElementContainer<MUIElement>) castObject;
+ renderer.processContents(container);
// Allow a final chance to set up
renderer.postProcess(mmenu);
// Now that we have a widget let the parent (if any) know
- if (mmenu.getParent() instanceof MUIElement) {
- MElementContainer<MUIElement> parentElement = mmenu.getParent();
- AbstractPartRenderer parentRenderer = rendererFactory.getRenderer(
- parentElement, null);
- if (parentRenderer != null)
+ MElementContainer<MUIElement> parentElement = mmenu.getParent();
+ if (parentElement != null) {
+ AbstractPartRenderer parentRenderer = rendererFactory.getRenderer(parentElement, null);
+ if (parentRenderer != null) {
parentRenderer.childRendered(parentElement, mmenu);
+ }
}
return (Menu) widget;
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java
index 5c23962..0230e5c 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java
@@ -14,7 +14,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Named;
import org.eclipse.core.databinding.observable.Realm;
@@ -24,6 +23,7 @@ import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.core.di.InjectionException;
import org.eclipse.e4.core.di.annotations.Optional;
+import org.eclipse.e4.core.di.extensions.EventTopic;
import org.eclipse.e4.core.services.contributions.IContributionFactory;
import org.eclipse.e4.core.services.events.IEventBroker;
import org.eclipse.e4.core.services.log.Logger;
@@ -74,7 +74,6 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
//import org.eclipse.ui.testing.TestableObject;
import org.osgi.service.event.Event;
-import org.osgi.service.event.EventHandler;
public class PartRenderingEngine implements IPresentationEngine {
public static final String EARLY_STARTUP_HOOK = "runEarlyStartup";
@@ -92,248 +91,252 @@ public class PartRenderingEngine implements IPresentationEngine {
org.eclipse.swt.widgets.Listener keyListener;
- // Life Cycle handlers
- private EventHandler toBeRenderedHandler = new EventHandler() {
- @Override
- public void handleEvent(Event event) {
+ @Inject
+ @Optional
+ private void subscribeTopicToBeRendered(@EventTopic(UIEvents.UIElement.TOPIC_TOBERENDERED) Event event) {
- MUIElement changedElement = (MUIElement) event
- .getProperty(UIEvents.EventTags.ELEMENT);
- MElementContainer<?> parent = changedElement.getParent();
+ MUIElement changedElement = (MUIElement) event.getProperty(UIEvents.EventTags.ELEMENT);
+ MElementContainer<?> parent = changedElement.getParent();
- // Handle Detached Windows
- if (parent == null) {
- parent = (MElementContainer<?>) ((EObject) changedElement)
- .eContainer();
- }
-
- // menus are not handled here... ??
- if (parent instanceof MMenu)
- return;
+ // Handle Detached Windows
+ if (parent == null) {
+ parent = (MElementContainer<?>) ((EObject) changedElement).eContainer();
+ }
- // If the parent isn't visible we don't care (The application is
- // never rendered)
- boolean okToRender = parent instanceof MApplication
- || parent.getWidget() != null;
+ // menus are not handled here... ??
+ if (parent instanceof MMenu) {
+ return;
+ }
- if (changedElement.isToBeRendered() && okToRender) {
- Activator.trace(Policy.DEBUG_RENDERER, "visible -> true", null); //$NON-NLS-1$
+ // If the parent isn't visible we don't care (The application is
+ // never rendered)
+ boolean okToRender = parent instanceof MApplication || parent.getWidget() != null;
- // Note that the 'createGui' protocol calls 'childAdded'
- Object w = createGui(changedElement);
- if (w instanceof Control && !(w instanceof Shell)) {
- fixZOrder(changedElement);
- }
- } else {
- Activator
- .trace(Policy.DEBUG_RENDERER, "visible -> false", null); //$NON-NLS-1$
+ if (changedElement.isToBeRendered() && okToRender) {
+ Activator.trace(Policy.DEBUG_RENDERER, "visible -> true", null); //$NON-NLS-1$
- // Ensure that the element about to be removed is not the
- // selected element
- if (parent.getSelectedElement() == changedElement)
- parent.setSelectedElement(null);
+ // Note that the 'createGui' protocol calls 'childAdded'
+ Object w = createGui(changedElement);
+ if (w instanceof Control && !(w instanceof Shell)) {
+ fixZOrder(changedElement);
+ }
+ } else {
+ Activator.trace(Policy.DEBUG_RENDERER, "visible -> false", null); //$NON-NLS-1$
- if (okToRender) {
- // Un-maximize the element before tearing it down
- if (changedElement.getTags().contains(MAXIMIZED))
- changedElement.getTags().remove(MAXIMIZED);
+ // Ensure that the element about to be removed is not the
+ // selected element
+ if (parent.getSelectedElement() == changedElement)
+ parent.setSelectedElement(null);
- // Note that the 'removeGui' protocol calls 'childRemoved'
- removeGui(changedElement);
+ if (okToRender) {
+ // Un-maximize the element before tearing it down
+ if (changedElement.getTags().contains(MAXIMIZED)) {
+ changedElement.getTags().remove(MAXIMIZED);
}
- }
- }
- };
-
- private EventHandler visibilityHandler = new EventHandler() {
- @Override
- public void handleEvent(Event event) {
- MUIElement changedElement = (MUIElement) event
- .getProperty(UIEvents.EventTags.ELEMENT);
- MUIElement parent = changedElement.getParent();
- if (parent == null) {
- parent = (MUIElement) ((EObject) changedElement).eContainer();
- if (parent == null) {
- return;
- }
+ // Note that the 'removeGui' protocol calls 'childRemoved'
+ removeGui(changedElement);
}
+ }
+ }
+
+ @Inject
+ @Optional
+ private void subscribeVisibilityHandler(@EventTopic(UIEvents.UIElement.TOPIC_VISIBLE) Event event) {
- AbstractPartRenderer renderer = (AbstractPartRenderer) parent
- .getRenderer();
- if (renderer == null || parent instanceof MToolBar)
+ MUIElement changedElement = (MUIElement) event.getProperty(UIEvents.EventTags.ELEMENT);
+ MUIElement parent = changedElement.getParent();
+ if (parent == null) {
+ parent = (MUIElement) ((EObject) changedElement).eContainer();
+ if (parent == null) {
return;
+ }
+ }
- // Re-parent the control based on the visible state
- if (changedElement.isVisible()) {
- if (changedElement.isToBeRendered()) {
- if (changedElement.getWidget() instanceof Control) {
- // Ensure that the control is under its 'real' parent if
- // it's visible
- Composite realComp = (Composite) renderer
- .getUIContainer(changedElement);
- Control ctrl = (Control) changedElement.getWidget();
-// RAP: re-parenting not supported
-// ctrl.setParent(realComp);
- ctrl.setVisible(true);
- fixZOrder(changedElement);
- }
+ AbstractPartRenderer renderer = (AbstractPartRenderer) parent.getRenderer();
+ if (renderer == null || parent instanceof MToolBar) {
+ return;
+ }
- if (parent instanceof MElementContainer<?>) {
- renderer.childRendered(
- (MElementContainer<MUIElement>) parent,
- changedElement);
- }
- }
- } else {
- // Put the control under the 'limbo' shell
+ // Re-parent the control based on the visible state
+ if (changedElement.isVisible()) {
+ if (changedElement.isToBeRendered()) {
if (changedElement.getWidget() instanceof Control) {
+ // Ensure that the control is under its 'real' parent if
+ // it's visible
+ Composite realComp = (Composite) renderer.getUIContainer(changedElement);
Control ctrl = (Control) changedElement.getWidget();
-
- if (!(ctrl instanceof Shell)) {
- ctrl.getShell().layout(new Control[] { ctrl },
- SWT.DEFER);
- }
-
-// RAP: re-parenting not supported
-// ctrl.setParent(getLimboShell());
- ctrl.setVisible(false);
+ ctrl.setParent(realComp);
+ fixZOrder(changedElement);
}
if (parent instanceof MElementContainer<?>) {
- renderer.hideChild((MElementContainer<MUIElement>) parent,
- changedElement);
+ @SuppressWarnings("unchecked")
+ MElementContainer<MUIElement> container = (MElementContainer<MUIElement>) parent;
+ renderer.childRendered(container, changedElement);
+ }
+ }
+ } else {
+ // Put the control under the 'limbo' shell
+ if (changedElement.getWidget() instanceof Control) {
+ Control ctrl = (Control) changedElement.getWidget();
+
+ if (!(ctrl instanceof Shell)) {
+ ctrl.getShell().layout(new Control[] { ctrl }, SWT.DEFER);
}
+
+ ctrl.setParent(getLimboShell());
+ }
+
+ if (parent instanceof MElementContainer<?>) {
+ @SuppressWarnings("unchecked")
+ MElementContainer<MUIElement> container = (MElementContainer<MUIElement>) parent;
+ renderer.hideChild(container, changedElement);
}
}
- };
+ }
- private EventHandler trimHandler = new EventHandler() {
- @Override
- public void handleEvent(Event event) {
- Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
- if (!(changedObj instanceof MTrimmedWindow))
- return;
+ @Inject
+ @Optional
+ private void subscribeTrimHandler(@EventTopic(UIEvents.TrimmedWindow.TOPIC_TRIMBARS) Event event) {
- MTrimmedWindow window = (MTrimmedWindow) changedObj;
- if (window.getWidget() == null)
- return;
+ Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
+ if (!(changedObj instanceof MTrimmedWindow)) {
+ return;
+ }
- if (UIEvents.isADD(event)) {
- for (Object o : UIEvents.asIterable(event,
- UIEvents.EventTags.NEW_VALUE)) {
- MUIElement added = (MUIElement) o;
- if (added.isToBeRendered())
- createGui(added, window.getWidget(),
- window.getContext());
+ MTrimmedWindow window = (MTrimmedWindow) changedObj;
+ if (window.getWidget() == null) {
+ return;
+ }
+
+ if (UIEvents.isADD(event)) {
+ for (Object o : UIEvents.asIterable(event, UIEvents.EventTags.NEW_VALUE)) {
+ MUIElement added = (MUIElement) o;
+ if (added.isToBeRendered()) {
+ createGui(added, window.getWidget(), window.getContext());
}
- } else if (UIEvents.isREMOVE(event)) {
- for (Object o : UIEvents.asIterable(event,
- UIEvents.EventTags.NEW_VALUE)) {
- MUIElement removed = (MUIElement) o;
- if (removed.getRenderer() != null)
- removeGui(removed);
+ }
+ } else if (UIEvents.isREMOVE(event)) {
+ for (Object o : UIEvents.asIterable(event, UIEvents.EventTags.NEW_VALUE)) {
+ MUIElement removed = (MUIElement) o;
+ if (removed.getRenderer() != null) {
+ removeGui(removed);
}
}
}
- };
+ }
- private EventHandler childrenHandler = new EventHandler() {
- @Override
- public void handleEvent(Event event) {
+ @Inject
+ @Optional
+ private void subscribeChildrenHandler(@EventTopic(UIEvents.ElementContainer.TOPIC_CHILDREN) Event event) {
- Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
- if (!(changedObj instanceof MElementContainer<?>))
- return;
+ Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
+ if (!(changedObj instanceof MElementContainer<?>)) {
+ return;
+ }
- MElementContainer<MUIElement> changedElement = (MElementContainer<MUIElement>) changedObj;
- boolean isApplication = changedObj instanceof MApplication;
+ @SuppressWarnings("unchecked")
+ MElementContainer<MUIElement> changedElement = (MElementContainer<MUIElement>) changedObj;
+ boolean isApplication = changedObj instanceof MApplication;
- boolean menuChild = changedObj instanceof MMenu;
- // If the parent isn't in the UI then who cares?
- AbstractPartRenderer renderer = getRendererFor(changedElement);
- if ((!isApplication && renderer == null) || menuChild)
- return;
+ boolean menuChild = changedObj instanceof MMenu;
+ // If the parent isn't in the UI then who cares?
+ AbstractPartRenderer renderer = getRendererFor(changedElement);
+ if ((!isApplication && renderer == null) || menuChild) {
+ return;
+ }
- if (UIEvents.isADD(event)) {
- Activator.trace(Policy.DEBUG_RENDERER, "Child Added", null); //$NON-NLS-1$
- for (Object o : UIEvents.asIterable(event,
- UIEvents.EventTags.NEW_VALUE)) {
- MUIElement added = (MUIElement) o;
-
- // OK, we have a new -visible- part we either have to create
- // it or host it under the correct parent. Note that we
- // explicitly do *not* render non-selected elements in
- // stacks (to support lazy loading).
- boolean isStack = changedObj instanceof MGenericStack<?>;
- boolean hasWidget = added.getWidget() != null;
- boolean isSelected = added == changedElement
- .getSelectedElement();
- boolean renderIt = !isStack || hasWidget || isSelected;
- if (renderIt) {
- // NOTE: createGui will call 'childAdded' if successful
- Object w = createGui(added);
- if (w instanceof Control && !(w instanceof Shell)) {
- final Control ctrl = (Control) w;
- fixZOrder(added);
- if (!ctrl.isDisposed()) {
- ctrl.getShell().layout(new Control[] { ctrl },
- SWT.DEFER);
- }
+ if (UIEvents.isADD(event)) {
+ Activator.trace(Policy.DEBUG_RENDERER, "Child Added", null); //$NON-NLS-1$
+ for (Object o : UIEvents.asIterable(event, UIEvents.EventTags.NEW_VALUE)) {
+ MUIElement added = (MUIElement) o;
+
+ // OK, we have a new -visible- part we either have to create
+ // it or host it under the correct parent. Note that we
+ // explicitly do *not* render non-selected elements in
+ // stacks (to support lazy loading).
+ boolean isStack = changedObj instanceof MGenericStack<?>;
+ boolean hasWidget = added.getWidget() != null;
+ boolean isSelected = added == changedElement.getSelectedElement();
+ boolean renderIt = !isStack || hasWidget || isSelected;
+ if (renderIt) {
+ // NOTE: createGui will call 'childAdded' if successful
+ Object w = createGui(added);
+ if (w instanceof Control && !(w instanceof Shell)) {
+ final Control ctrl = (Control) w;
+ fixZOrder(added);
+ if (!ctrl.isDisposed()) {
+ ctrl.getShell().layout(new Control[] { ctrl }, SWT.DEFER);
}
- } else {
- if (renderer != null && added.isToBeRendered())
- renderer.childRendered(changedElement, added);
}
-
- // If the element being added is a placeholder, check to see
- // if
- // it's 'globally visible' and, if so, remove all other
- // 'local' placeholders referencing the same element.
- int newLocation = modelService.getElementLocation(added);
- if (newLocation == EModelService.IN_SHARED_AREA
- || newLocation == EModelService.OUTSIDE_PERSPECTIVE) {
- MWindow topWin = modelService
- .getTopLevelWindowFor(added);
- modelService.hideLocalPlaceholders(topWin, null);
+ } else {
+ if (renderer != null && added.isToBeRendered()) {
+ renderer.childRendered(changedElement, added);
}
}
- } else if (UIEvents.isREMOVE(event)) {
- Activator.trace(Policy.DEBUG_RENDERER, "Child Removed", null); //$NON-NLS-1$
- for (Object o : UIEvents.asIterable(event,
- UIEvents.EventTags.OLD_VALUE)) {
- MUIElement removed = (MUIElement) o;
- // Removing invisible elements is a NO-OP as far as the
- // renderer is concerned
- if (!removed.isToBeRendered())
- continue;
- if (removed.getWidget() instanceof Control) {
- Control ctrl = (Control) removed.getWidget();
- ctrl.setLayoutData(null);
- ctrl.getParent().layout(new Control[] { ctrl },
- SWT.CHANGED | SWT.DEFER);
- }
+ // If the element being added is a placeholder, check to see
+ // if
+ // it's 'globally visible' and, if so, remove all other
+ // 'local' placeholders referencing the same element.
+ int newLocation = modelService.getElementLocation(added);
+ if (newLocation == EModelService.IN_SHARED_AREA || newLocation == EModelService.OUTSIDE_PERSPECTIVE) {
+ MWindow topWin = modelService.getTopLevelWindowFor(added);
+ modelService.hideLocalPlaceholders(topWin, null);
+ }
+ }
+ } else if (UIEvents.isREMOVE(event)) {
+ Activator.trace(Policy.DEBUG_RENDERER, "Child Removed", null); //$NON-NLS-1$
+ for (Object o : UIEvents.asIterable(event, UIEvents.EventTags.OLD_VALUE)) {
+ MUIElement removed = (MUIElement) o;
+ // Removing invisible elements is a NO-OP as far as the
+ // renderer is concerned
+ if (!removed.isToBeRendered()) {
+ continue;
+ }
- // Ensure that the element about to be removed is not the
- // selected element
- if (changedElement.getSelectedElement() == removed)
- changedElement.setSelectedElement(null);
+ if (removed.getWidget() instanceof Control) {
+ Control ctrl = (Control) removed.getWidget();
+ ctrl.setLayoutData(null);
+ ctrl.getParent().layout(new Control[] { ctrl }, SWT.CHANGED | SWT.DEFER);
+ }
- if (renderer != null)
- renderer.hideChild(changedElement, removed);
+ // Ensure that the element about to be removed is not the
+ // selected element
+ if (changedElement.getSelectedElement() == removed) {
+ changedElement.setSelectedElement(null);
+ }
+
+ if (renderer != null) {
+ renderer.hideChild(changedElement, removed);
}
}
}
- };
+ }
+
+ @Inject
+ @Optional
+ private void subscribeWindowsHandler(@EventTopic(UIEvents.Window.TOPIC_WINDOWS) Event event) {
+
+ subscribeChildrenHandler(event);
+ }
+
+ @Inject
+ @Optional
+ private void subscribePerspectiveWindowsHandler(@EventTopic(UIEvents.Perspective.TOPIC_WINDOWS) Event event) {
+ subscribeChildrenHandler(event);
+ }
- private EventHandler windowsHandler = new EventHandler() {
- @Override
- public void handleEvent(Event event) {
- childrenHandler.handleEvent(event);
- }
- };
// FIXME RAP unsupported
+ // @Inject
+ // @Optional
+ // private void
+ // subscribeCssThemeChanged(@EventTopic(IThemeEngine.Events.THEME_CHANGED)
+ // Event event) {
+ // cssThemeChangedHandler.handleEvent(event);
+ // }
+
// private StylingPreferencesHandler cssThemeChangedHandler;
private IEclipseContext appContext;
@@ -368,22 +371,26 @@ public class PartRenderingEngine implements IPresentationEngine {
protected void fixZOrder(MUIElement element) {
MElementContainer<MUIElement> parent = element.getParent();
if (parent == null) {
- Object container = ((EObject) element).eContainer();
- if (container instanceof MElementContainer<?>) {
- parent = (MElementContainer<MUIElement>) container;
+ Object econtainer = ((EObject) element).eContainer();
+ if (econtainer instanceof MElementContainer<?>) {
+ @SuppressWarnings("unchecked")
+ MElementContainer<MUIElement> container = (MElementContainer<MUIElement>) econtainer;
+ parent = container;
}
}
- if (parent == null || !(element.getWidget() instanceof Control))
+ if (parent == null || !(element.getWidget() instanceof Control)) {
return;
+ }
Control elementCtrl = (Control) element.getWidget();
Control prevCtrl = null;
for (MUIElement kid : parent.getChildren()) {
if (kid == element) {
- if (prevCtrl != null)
+ if (prevCtrl != null) {
elementCtrl.moveBelow(prevCtrl);
- else
+ } else {
elementCtrl.moveAbove(null);
+ }
break;
} else if (kid.getWidget() instanceof Control && kid.isVisible()) {
prevCtrl = (Control) kid.getWidget();
@@ -409,7 +416,7 @@ public class PartRenderingEngine implements IPresentationEngine {
/**
* Initialize a part renderer from the extension point.
- *
+ *
* @param context
* the context for the part factories
*/
@@ -452,38 +459,8 @@ public class PartRenderingEngine implements IPresentationEngine {
curFactory = factory;
context.set(IRendererFactory.class, curFactory);
- // Hook up the widget life-cycle subscriber
- if (eventBroker != null) {
- eventBroker.subscribe(UIEvents.UIElement.TOPIC_TOBERENDERED,
- toBeRenderedHandler);
- eventBroker.subscribe(UIEvents.UIElement.TOPIC_VISIBLE,
- visibilityHandler);
- eventBroker.subscribe(UIEvents.ElementContainer.TOPIC_CHILDREN,
- childrenHandler);
- eventBroker
- .subscribe(UIEvents.Window.TOPIC_WINDOWS, windowsHandler);
- eventBroker.subscribe(UIEvents.Perspective.TOPIC_WINDOWS,
- windowsHandler);
- eventBroker.subscribe(UIEvents.TrimmedWindow.TOPIC_TRIMBARS,
- trimHandler);
- // FIXME RAP unsupported
- // cssThemeChangedHandler = new StylingPreferencesHandler(
- // context.get(Display.class));
- // eventBroker.subscribe(IThemeEngine.Events.THEME_CHANGED,
- // cssThemeChangedHandler);
- }
- }
-
- @PreDestroy
- void contextDisposed() {
- if (eventBroker == null)
- return;
- eventBroker.unsubscribe(toBeRenderedHandler);
- eventBroker.unsubscribe(visibilityHandler);
- eventBroker.unsubscribe(childrenHandler);
- eventBroker.unsubscribe(trimHandler);
- // FIXME RAP unsupported
- // eventBroker.unsubscribe(cssThemeChangedHandler);
+ // cssThemeChangedHandler = new
+ // StylingPreferencesHandler(context.get(Display.class));
}
private static void populateModelInterfaces(MContext contextModel,
@@ -754,7 +731,7 @@ public class PartRenderingEngine implements IPresentationEngine {
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.e4.ui.workbench.IPresentationEngine#focusGui(org.eclipse.
* e4.ui.model.application.ui.MUIElement)
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/SelectionAdapterFactory.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/SelectionAdapterFactory.java
index 4c0e0e1..3805f22 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/SelectionAdapterFactory.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/SelectionAdapterFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Simon Scholz <simon.scholz@vogella.com> - Bug 460405
*******************************************************************************/
package org.eclipse.e4.ui.internal.workbench.swt;
@@ -23,85 +24,72 @@ import org.eclipse.jface.viewers.IStructuredSelection;
/**
* Adapts ISelection instances to either IIterable or ICountable. For use with
* core expressions.
- *
+ *
* @since 3.3
*/
public class SelectionAdapterFactory implements IAdapterFactory {
+
private static final ICountable ICOUNT_0 = new ICountable() {
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.expressions.ICountable#count()
- */
@Override
public int count() {
return 0;
}
};
+
private static final ICountable ICOUNT_1 = new ICountable() {
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.expressions.ICountable#count()
- */
@Override
public int count() {
return 1;
}
};
- private static final IIterable ITERATE_EMPTY = new IIterable() {
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.expressions.IIterable#iterator()
- */
+
+ private static final IIterable<?> ITERATE_EMPTY = new IIterable<Object>() {
@Override
- public Iterator iterator() {
- return Collections.EMPTY_LIST.iterator();
+ public Iterator<Object> iterator() {
+ return Collections.emptyList().iterator();
}
};
/**
* The classes we can adapt to.
*/
- private static final Class[] CLASSES = new Class[] { IIterable.class,
- ICountable.class };
+ private static final Class<?>[] CLASSES = new Class[] { IIterable.class, ICountable.class };
@Override
- public Object getAdapter(Object adaptableObject, Class adapterType) {
+ public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) {
if (adaptableObject instanceof ISelection) {
if (adapterType == IIterable.class) {
- return iterable((ISelection) adaptableObject);
+ return adapterType.cast(iterable((ISelection) adaptableObject));
} else if (adapterType == ICountable.class) {
- return countable((ISelection) adaptableObject);
+ return adapterType.cast(countable((ISelection) adaptableObject));
}
}
return null;
}
- private Object iterable(final ISelection sel) {
+ private IIterable<?> iterable(final ISelection sel) {
if (sel.isEmpty()) {
return ITERATE_EMPTY;
}
if (sel instanceof IStructuredSelection) {
- return new IIterable() {
+ return new IIterable<Object>() {
@Override
- public Iterator iterator() {
+ public Iterator<Object> iterator() {
return ((IStructuredSelection) sel).iterator();
}
};
}
- final List list = Arrays.asList(new Object[] { sel });
- return new IIterable() {
+ final List<Object> list = Arrays.asList(new Object[] { sel });
+ return new IIterable<Object>() {
@Override
- public Iterator iterator() {
+ public Iterator<Object> iterator() {
return list.iterator();
}
};
}
- private Object countable(final ISelection sel) {
+ private ICountable countable(final ISelection sel) {
if (sel.isEmpty()) {
return ICOUNT_0;
}
@@ -118,7 +106,7 @@ public class SelectionAdapterFactory implements IAdapterFactory {
}
@Override
- public Class[] getAdapterList() {
+ public Class<?>[] getAdapterList() {
return CLASSES;
}
}
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/ShellActivationListener.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/ShellActivationListener.java
index e69bad4..16820cd 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/ShellActivationListener.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/ShellActivationListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2014 IBM Corporation and others.
+ * Copyright (c) 2010, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -82,7 +82,7 @@ public class ShellActivationListener implements Listener {
private void processWindow(Event event, Shell shell, MWindow window) {
switch (event.type) {
case SWT.Activate:
- final IEclipseContext local = ((MWindow) window).getContext();
+ final IEclipseContext local = window.getContext();
WorkbenchSWTActivator.trace("/trace/workbench",
"setting mwindow context " + local, null);
// record this shell's context
@@ -149,7 +149,7 @@ public class ShellActivationListener implements Listener {
* Retrieves the eclipse context for the specified shell. If one cannot be
* found, a child context will be created off of the provided parent
* context.
- *
+ *
* @param shell
* the shell of interest, must not be <code>null</code>
* @param parentContext
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/WorkbenchSWTActivator.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/WorkbenchSWTActivator.java
index f8dd9ac..6c99977 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/WorkbenchSWTActivator.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/WorkbenchSWTActivator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2010, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -25,7 +25,6 @@ import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.service.debug.DebugOptions;
import org.eclipse.osgi.service.debug.DebugTrace;
-import org.eclipse.osgi.service.resolver.PlatformAdmin;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
@@ -42,17 +41,16 @@ public class WorkbenchSWTActivator implements BundleActivator { // extends
public static final String PI_RENDERERS = "org.eclipse.e4.ui.workbench.swt"; //$NON-NLS-1$
private BundleContext context;
- private ServiceTracker pkgAdminTracker;
- private ServiceTracker locationTracker;
+ private ServiceTracker<?, PackageAdmin> pkgAdminTracker;
+ private ServiceTracker<?, Location> locationTracker;
private static WorkbenchSWTActivator activator;
- private ServiceTracker debugTracker;
+ private ServiceTracker<?, DebugOptions> debugTracker;
private DebugTrace trace;
- private ServiceTracker<PlatformAdmin, PlatformAdmin> platformAdminTracker;
/**
* Get the default activator.
- *
+ *
* @return a BundleActivator
*/
public static WorkbenchSWTActivator getDefault() {
@@ -79,15 +77,12 @@ public class WorkbenchSWTActivator implements BundleActivator { // extends
pkgAdminTracker.close();
pkgAdminTracker = null;
}
- if (platformAdminTracker != null) {
- platformAdminTracker.close();
- platformAdminTracker = null;
- }
}
public Bundle getBundle() {
- if (context == null)
+ if (context == null) {
return null;
+ }
return context.getBundle();
}
@@ -96,24 +91,13 @@ public class WorkbenchSWTActivator implements BundleActivator { // extends
*/
public PackageAdmin getBundleAdmin() {
if (pkgAdminTracker == null) {
- if (context == null)
+ if (context == null) {
return null;
- pkgAdminTracker = new ServiceTracker(context, PackageAdmin.class
- .getName(), null);
+ }
+ pkgAdminTracker = new ServiceTracker<>(context, PackageAdmin.class, null);
pkgAdminTracker.open();
}
- return (PackageAdmin) pkgAdminTracker.getService();
- }
-
- public PlatformAdmin getPlatformAdmin() {
- if (platformAdminTracker == null) {
- if (context == null)
- return null;
- platformAdminTracker = new ServiceTracker<PlatformAdmin, PlatformAdmin>(
- context, PlatformAdmin.class, null);
- platformAdminTracker.open();
- }
- return platformAdminTracker.getService();
+ return pkgAdminTracker.getService();
}
/**
@@ -128,10 +112,10 @@ public class WorkbenchSWTActivator implements BundleActivator { // extends
// ignore this. It should never happen as we have tested the
// above format.
}
- locationTracker = new ServiceTracker(context, filter, null);
+ locationTracker = new ServiceTracker<>(context, filter, null);
locationTracker.open();
}
- return (Location) locationTracker.getService();
+ return locationTracker.getService();
}
/**
@@ -141,8 +125,9 @@ public class WorkbenchSWTActivator implements BundleActivator { // extends
*/
public Bundle getBundleForName(String bundleName) {
Bundle[] bundles = getBundleAdmin().getBundles(bundleName, null);
- if (bundles == null)
+ if (bundles == null) {
return null;
+ }
// Return the first bundle that is not installed or uninstalled
for (int i = 0; i < bundles.length; i++) {
if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
@@ -166,13 +151,13 @@ public class WorkbenchSWTActivator implements BundleActivator { // extends
public DebugOptions getDebugOptions() {
if (debugTracker == null) {
- if (context == null)
+ if (context == null) {
return null;
- debugTracker = new ServiceTracker(context, DebugOptions.class
- .getName(), null);
+ }
+ debugTracker = new ServiceTracker<>(context, DebugOptions.class, null);
debugTracker.open();
}
- return (DebugOptions) debugTracker.getService();
+ return debugTracker.getService();
}
public DebugTrace getTrace() {
@@ -207,7 +192,7 @@ public class WorkbenchSWTActivator implements BundleActivator { // extends
* <p>
* Subclasses may override this method but are not expected to.
* </p>
- *
+ *
* @return the dialog settings
*/
public IDialogSettings getDialogSettings() {
@@ -237,8 +222,7 @@ public class WorkbenchSWTActivator implements BundleActivator { // extends
IPath dataLocation = getStateLocationOrNull();
if (dataLocation != null) {
// try r/w state area in the local file system
- String readWritePath = dataLocation.append(FN_DIALOG_SETTINGS)
- .toOSString();
+ String readWritePath = dataLocation.append(FN_DIALOG_SETTINGS).toOSString();
File settingsFile = new File(readWritePath);
if (settingsFile.exists()) {
try {
@@ -254,8 +238,7 @@ public class WorkbenchSWTActivator implements BundleActivator { // extends
// otherwise look for bundle specific dialog settings
Bundle bundle = context.getBundle();
- URL dsURL = FileLocator
- .find(bundle, new Path(FN_DIALOG_SETTINGS), null);
+ URL dsURL = FileLocator.find(bundle, new Path(FN_DIALOG_SETTINGS), null);
if (dsURL == null) {
return;
}
@@ -263,8 +246,7 @@ public class WorkbenchSWTActivator implements BundleActivator { // extends
InputStream is = null;
try {
is = dsURL.openStream();
- BufferedReader reader = new BufferedReader(new InputStreamReader(
- is, "utf-8")); //$NON-NLS-1$
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is, "utf-8")); //$NON-NLS-1$
dialogSettings.load(reader);
} catch (IOException e) {
// load failed so ensure we have an empty settings
@@ -305,12 +287,12 @@ public class WorkbenchSWTActivator implements BundleActivator { // extends
/**
* FOR INTERNAL WORKBENCH USE ONLY.
- *
+ *
* Returns the path to a location in the file system that can be used to
* persist/restore state between workbench invocations. If the location did
* not exist prior to this call it will be created. Returns
* <code>null</code> if no such location is available.
- *
+ *
* @return path to a location in the file system where this plug-in can
* persist data between sessions, or <code>null</code> if no such
* location is available.
@@ -321,8 +303,7 @@ public class WorkbenchSWTActivator implements BundleActivator { // extends
// However, using it causes problems in the activation order
// So, for now, we get it directly.
try {
- return InternalPlatform.getDefault().getStateLocation(
- context.getBundle(), true);
+ return InternalPlatform.getDefault().getStateLocation(context.getBundle(), true);
} catch (IllegalStateException e) {
// This occurs if -data=@none is explicitly specified, so ignore
// this silently.
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/handlers/ThemeUtil.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/handlers/ThemeUtil.java
index e53e092..03949ca 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/handlers/ThemeUtil.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/handlers/ThemeUtil.java
@@ -1,11 +1,11 @@
/*******************************************************************************
* Copyright (c) 2009, 2010 Siemens AG and others.
- *
- * All rights reserved. This program and the accompanying materials
+ *
+ * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html.
- *
+ *
* Contributors:
* Kai Tödter - initial implementation
******************************************************************************/
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/BasicUIJob.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/BasicUIJob.java
index 8e7e7f9..44b266f 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/BasicUIJob.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/BasicUIJob.java
@@ -28,10 +28,10 @@ public abstract class BasicUIJob extends Job {
* Create a new instance of the receiver with the supplied name. The display
* used will be the one from the workbench if this is available. UIJobs with
* this constructor will determine their display at runtime.
- *
+ *
* @param name
* the job name
- *
+ *
*/
public BasicUIJob(String name, Display display) {
super(name);
@@ -76,7 +76,7 @@ public abstract class BasicUIJob extends Job {
/**
* Run the job in the UI Thread.
- *
+ *
* @param monitor
* @return IStatus
*/
@@ -86,7 +86,7 @@ public abstract class BasicUIJob extends Job {
* Returns the display for use by the receiver when running in an asyncExec.
* If it is not set then the display set in the workbench is used. If the
* display is null the job will not be run.
- *
+ *
* @return Display or <code>null</code>.
*/
public Display getDisplay() {
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/FilteredTree.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/FilteredTree.java
index c991b46..a9d98ad 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/FilteredTree.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/FilteredTree.java
@@ -9,6 +9,7 @@
* IBM Corporation - initial API and implementation
* Jacek Pospychala - bug 187762
* Mohamed Tarief - tarief@eg.ibm.com - IBM - Bug 174481
+ * Lars Vogel <Lars.Vogel@gmail.com> - Bug 440381
*******************************************************************************/
package org.eclipse.e4.ui.workbench.swt.internal.copy;
@@ -20,8 +21,6 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.JFaceResources;
@@ -95,7 +94,7 @@ public class FilteredTree extends Composite {
* <p>
* <strong>Note:</strong> This is only used if the new look is chosen.
* </p>
- *
+ *
* @since 3.5
*/
protected Control clearButtonControl;
@@ -131,7 +130,7 @@ public class FilteredTree extends Composite {
/**
* The parent composite of the filtered tree.
- *
+ *
* @since 3.3
*/
protected Composite parent;
@@ -141,7 +140,7 @@ public class FilteredTree extends Composite {
* default is to show these controls. This can be overridden by providing a
* setting in the product configuration file. The setting to add to not show
* these controls is:
- *
+ *
* org.eclipse.ui/SHOW_FILTERED_TEXTS=false
*/
protected boolean showFilterControls;
@@ -152,13 +151,6 @@ public class FilteredTree extends Composite {
protected Composite treeComposite;
/**
- * Tells whether to use the pre 3.5 or the new look.
- *
- * @since 3.5
- */
- private boolean useNewLook = false;
-
- /**
* Image descriptor for enabled clear button.
*/
private static final String CLEAR_ICON = "org.eclipse.ui.internal.dialogs.CLEAR_ICON"; //$NON-NLS-1$
@@ -198,19 +190,15 @@ public class FilteredTree extends Composite {
/**
* Create a new instance of the receiver.
- *
+ *
* @param parent
* the parent <code>Composite</code>
* @param treeStyle
* the style bits for the <code>Tree</code>
* @param filter
* the filter to be used
- *
- * @deprecated As of 3.5, replaced by
- * {@link #FilteredTree(Composite, int, PatternFilter, boolean)}
- * where using the new look is encouraged
+ * @since 3.5
*/
- @Deprecated
public FilteredTree(Composite parent, int treeStyle, PatternFilter filter) {
super(parent, SWT.NONE);
this.parent = parent;
@@ -219,7 +207,7 @@ public class FilteredTree extends Composite {
/**
* Create a new instance of the receiver.
- *
+ *
* @param parent
* the parent <code>Composite</code>
* @param treeStyle
@@ -227,16 +215,16 @@ public class FilteredTree extends Composite {
* @param filter
* the filter to be used
* @param useNewLook
- * <code>true</code> if the new 3.5 look should be used
+ * ignored, look introduced in 3.5 is always used
* @since 3.5
+ *
+ * @deprecated use FilteredTree(Composite parent, int treeStyle,
+ * PatternFilter filter)
*/
@Deprecated
public FilteredTree(Composite parent, int treeStyle, PatternFilter filter,
boolean useNewLook) {
- super(parent, SWT.NONE);
- this.parent = parent;
- this.useNewLook = useNewLook;
- init(treeStyle, filter);
+ this(parent, treeStyle, filter);
}
/**
@@ -244,15 +232,12 @@ public class FilteredTree extends Composite {
* the default creation behavior may use this constructor, but must ensure
* that the <code>init(composite, int, PatternFilter)</code> method is
* called in the overriding constructor.
- *
+ *
* @param parent
* the parent <code>Composite</code>
* @see #init(int, PatternFilter)
- *
- * @since 3.3
- * @deprecated As of 3.5, replaced by
- * {@link #FilteredTree(Composite, boolean)} where using the
- * look is encouraged
+ *
+ * @since 3.5
*/
protected FilteredTree(Composite parent) {
super(parent, SWT.NONE);
@@ -264,29 +249,30 @@ public class FilteredTree extends Composite {
* the default creation behavior may use this constructor, but must ensure
* that the <code>init(composite, int, PatternFilter)</code> method is
* called in the overriding constructor.
- *
+ *
* @param parent
* the parent <code>Composite</code>
* @param useNewLook
- * <code>true</code> if the new 3.5 look should be used
+ * ignored, look introduced in 3.5 is always used
* @see #init(int, PatternFilter)
- *
+ *
* @since 3.5
+ *
+ * @deprecated use FilteredTree(Composite parent) instead
*/
+ @Deprecated
protected FilteredTree(Composite parent, boolean useNewLook) {
- super(parent, SWT.NONE);
- this.parent = parent;
- this.useNewLook = useNewLook;
+ this(parent);
}
/**
* Create the filtered tree.
- *
+ *
* @param treeStyle
* the style bits for the <code>Tree</code>
* @param filter
* the filter to be used
- *
+ *
* @since 3.3
*/
protected void init(int treeStyle, PatternFilter filter) {
@@ -301,7 +287,7 @@ public class FilteredTree extends Composite {
/**
* Create the filtered tree's controls. Subclasses should override.
- *
+ *
* @param parent
* @param treeStyle
*/
@@ -313,7 +299,7 @@ public class FilteredTree extends Composite {
setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
if (showFilterControls) {
- if (!useNewLook || useNativeSearchField(parent)) {
+ if (useNativeSearchField(parent)) {
filterComposite = new Composite(this, SWT.NONE);
} else {
filterComposite = new Composite(this, SWT.BORDER);
@@ -365,17 +351,14 @@ public class FilteredTree extends Composite {
* Create the filter controls. By default, a text and corresponding tool bar
* button that clears the contents of the text is created. Subclasses may
* override.
- *
+ *
* @param parent
* parent <code>Composite</code> of the filter controls
* @return the <code>Composite</code> that contains the filter controls
*/
protected Composite createFilterControls(Composite parent) {
createFilterText(parent);
- if (useNewLook)
- createClearTextNew(parent);
- else
- createClearTextOld(parent);
+ createClearText(parent);
if (clearButtonControl != null) {
// initially there is no text to clear
clearButtonControl.setVisible(false);
@@ -393,7 +376,7 @@ public class FilteredTree extends Composite {
* {@link #doCreateTreeViewer(Composite, int)} to create the tree viewer.
* Subclasses should override {@link #doCreateTreeViewer(Composite, int)}
* instead of overriding this method.
- *
+ *
* @param parent
* parent <code>Composite</code>
* @param style
@@ -419,13 +402,13 @@ public class FilteredTree extends Composite {
/**
* Creates the tree viewer. Subclasses may override.
- *
+ *
* @param parent
* the parent composite
* @param style
* SWT style bits used to create the tree viewer
* @return the tree viewer
- *
+ *
* @since 3.3
*/
protected TreeViewer doCreateTreeViewer(Composite parent, int style) {
@@ -434,7 +417,7 @@ public class FilteredTree extends Composite {
/**
* Return the first item in the tree that matches the filter pattern.
- *
+ *
* @param items
* @return the first matching TreeItem
*/
@@ -454,7 +437,7 @@ public class FilteredTree extends Composite {
/**
* Create the refresh job for the receiver.
- *
+ *
*/
private void createRefreshJob() {
refreshJob = doCreateRefreshJob();
@@ -464,9 +447,9 @@ public class FilteredTree extends Composite {
/**
* Creates a workbench job that will refresh the tree based on the current
* filter text. Subclasses may override.
- *
+ *
* @return a workbench job that can be scheduled to refresh the tree
- *
+ *
* @since 3.4
*/
protected BasicUIJob doCreateRefreshJob() {
@@ -559,7 +542,7 @@ public class FilteredTree extends Composite {
/**
* Returns true if the job should be canceled (because of timeout or
* actual cancellation).
- *
+ *
* @param items
* @param monitor
* @param cancelTime
@@ -612,7 +595,7 @@ public class FilteredTree extends Composite {
* {@link #doCreateFilterText(Composite)} to create the text control.
* Subclasses should override {@link #doCreateFilterText(Composite)} instead
* of overriding this method.
- *
+ *
* @param parent
* <code>Composite</code> of the filter text
*/
@@ -637,10 +620,10 @@ public class FilteredTree extends Composite {
}
/**
- * Return the number of filtered items
- *
- * @return int
- */
+ * Return the number of filtered items
+ *
+ * @return int
+ */
private int getFilteredItemsCount() {
int total = 0;
TreeItem[] items = getViewer().getTree().getItems();
@@ -652,12 +635,11 @@ public class FilteredTree extends Composite {
}
/**
- * Return the count of treeItem and it's children to
- * infinite depth.
- *
- * @param treeItem
- * @return int
- */
+ * Return the count of treeItem and it's children to infinite depth.
+ *
+ * @param treeItem
+ * @return int
+ */
private int itemCount(TreeItem treeItem) {
int count = 1;
TreeItem[] children = treeItem.getItems();
@@ -670,34 +652,9 @@ public class FilteredTree extends Composite {
});
filterText.addFocusListener(new FocusAdapter() {
- @Override
- public void focusGained(FocusEvent e) {
- if (!useNewLook) {
- /*
- * Running in an asyncExec because the selectAll() does not
- * appear to work when using mouse to give focus to text.
- */
- Display display = filterText.getDisplay();
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- if (!filterText.isDisposed()) {
- if (getInitialText().equals(
- filterText.getText().trim())) {
- filterText.selectAll();
- }
- }
- }
- });
- return;
- }
- }
@Override
public void focusLost(FocusEvent e) {
- if (!useNewLook) {
- return;
- }
if (filterText.getText().equals(initialText)) {
setFilterText(""); //$NON-NLS-1$
textChanged();
@@ -705,19 +662,17 @@ public class FilteredTree extends Composite {
}
});
- if (useNewLook) {
- filterText.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseDown(MouseEvent e) {
- if (filterText.getText().equals(initialText)) {
- // XXX: We cannot call clearText() due to
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=260664
- setFilterText(""); //$NON-NLS-1$
- textChanged();
- }
+ filterText.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseDown(MouseEvent e) {
+ if (filterText.getText().equals(initialText)) {
+ // XXX: We cannot call clearText() due to
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=260664
+ setFilterText(""); //$NON-NLS-1$
+ textChanged();
}
- });
- }
+ }
+ });
filterText.addKeyListener(new KeyAdapter() {
@Override
@@ -733,6 +688,7 @@ public class FilteredTree extends Composite {
// enter key set focus to tree
filterText.addTraverseListener(new TraverseListener() {
+ @Override
public void keyTraversed(TraverseEvent e) {
if (e.detail == SWT.TRAVERSE_RETURN) {
e.doit = false;
@@ -764,13 +720,7 @@ public class FilteredTree extends Composite {
});
filterText.addModifyListener(new ModifyListener() {
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.
- * swt.events.ModifyEvent)
- */
+ @Override
public void modifyText(ModifyEvent e) {
textChanged();
}
@@ -781,13 +731,7 @@ public class FilteredTree extends Composite {
// pressed)
if ((filterText.getStyle() & SWT.ICON_CANCEL) != 0) {
filterText.addSelectionListener(new SelectionAdapter() {
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.swt.events.SelectionAdapter#widgetDefaultSelected
- * (org.eclipse.swt.events.SelectionEvent)
- */
+ @Override
public void widgetDefaultSelected(SelectionEvent e) {
if (e.detail == SWT.ICON_CANCEL)
clearText();
@@ -806,15 +750,15 @@ public class FilteredTree extends Composite {
/**
* Creates the text control for entering the filter text. Subclasses may
* override.
- *
+ *
* @param parent
* the parent composite
* @return the text widget
- *
+ *
* @since 3.3
*/
protected Text doCreateFilterText(Composite parent) {
- if (!useNewLook || useNativeSearchField(parent)) {
+ if (useNativeSearchField(parent)) {
return new Text(parent, SWT.SINGLE | SWT.BORDER | SWT.SEARCH
| SWT.ICON_CANCEL);
}
@@ -842,9 +786,9 @@ public class FilteredTree extends Composite {
/**
* Return the time delay that should be used when scheduling the filter
* refresh job. Subclasses may override.
- *
+ *
* @return a time delay in milliseconds before the job should run
- *
+ *
* @since 3.5
*/
protected long getRefreshJobDelay() {
@@ -853,15 +797,14 @@ public class FilteredTree extends Composite {
/**
* Set the background for the widgets that support the filter text area.
- *
+ *
* @param background
* background <code>Color</code> to set
*/
@Override
public void setBackground(Color background) {
super.setBackground(background);
- if (filterComposite != null
- && (!useNewLook || useNativeSearchField(filterComposite))) {
+ if (filterComposite != null && (useNativeSearchField(filterComposite))) {
filterComposite.setBackground(background);
}
if (filterToolBar != null && filterToolBar.getControl() != null) {
@@ -869,44 +812,14 @@ public class FilteredTree extends Composite {
}
}
- /**
- * Create the button that clears the text.
- *
- * @param parent
- * parent <code>Composite</code> of toolbar button
- */
- private void createClearTextOld(Composite parent) {
- // only create the button if the text widget doesn't support one
- // natively
- if ((filterText.getStyle() & SWT.ICON_CANCEL) == 0) {
- filterToolBar = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL);
- filterToolBar.createControl(parent);
-
- IAction clearTextAction = new Action("", IAction.AS_PUSH_BUTTON) {//$NON-NLS-1$
- @Override
- public void run() {
- clearText();
- }
- };
-
- clearTextAction
- .setToolTipText(WorkbenchSWTMessages.FilteredTree_ClearToolTip);
- clearTextAction.setImageDescriptor(JFaceResources
- .getImageRegistry().getDescriptor(CLEAR_ICON));
- clearTextAction.setDisabledImageDescriptor(JFaceResources
- .getImageRegistry().getDescriptor(DISABLED_CLEAR_ICON));
-
- filterToolBar.add(clearTextAction);
- }
- }
/**
* Create the button that clears the text.
- *
+ *
* @param parent
* parent <code>Composite</code> of toolbar button
*/
- private void createClearTextNew(Composite parent) {
+ private void createClearText(Composite parent) {
// only create the button if the text widget doesn't support one
// natively
if ((filterText.getStyle() & SWT.ICON_CANCEL) == 0) {
@@ -914,11 +827,8 @@ public class FilteredTree extends Composite {
.getDescriptor(DISABLED_CLEAR_ICON).createImage();
final Image activeImage = JFaceResources.getImageRegistry()
.getDescriptor(CLEAR_ICON).createImage();
- // TODO RAP Unsupported
- // final Image pressedImage = new Image(getDisplay(), activeImage,
- // SWT.IMAGE_GRAY);
final Image pressedImage = new Image(getDisplay(), activeImage,
- SWT.IMAGE_COPY);
+ SWT.IMAGE_GRAY);
final Label clearButton = new Label(parent, SWT.NONE);
clearButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER,
@@ -931,6 +841,7 @@ public class FilteredTree extends Composite {
clearButton.addMouseListener(new MouseAdapter() {
private MouseMoveListener fMoveListener;
+ @Override
public void mouseDown(MouseEvent e) {
clearButton.setImage(pressedImage);
fMoveListener = new MouseMoveListener() {
@@ -947,14 +858,14 @@ public class FilteredTree extends Composite {
}
}
};
- // TODO RAP unsupported
+ // FIXME RAP
// clearButton.addMouseMoveListener(fMoveListener);
}
@Override
public void mouseUp(MouseEvent e) {
if (fMoveListener != null) {
- // TODO RAP unsupported
+ // FIXME RAP
// clearButton.removeMouseMoveListener(fMoveListener);
fMoveListener = null;
boolean mouseInButton = isMouseInButton(e);
@@ -973,7 +884,7 @@ public class FilteredTree extends Composite {
&& e.y < buttonSize.y;
}
});
- // TODO RAP Unsupported
+ // FIXME RAP
// clearButton.addMouseTrackListener(new MouseTrackListener() {
// @Override
// public void mouseEnter(MouseEvent e) {
@@ -1025,7 +936,7 @@ public class FilteredTree extends Composite {
/**
* Set the text in the filter control.
- *
+ *
* @param string
*/
protected void setFilterText(String string) {
@@ -1037,7 +948,7 @@ public class FilteredTree extends Composite {
/**
* Returns the pattern filter used by this tree.
- *
+ *
* @return The pattern filter; never <code>null</code>.
*/
public final PatternFilter getPatternFilter() {
@@ -1046,7 +957,7 @@ public class FilteredTree extends Composite {
/**
* Get the tree viewer of the receiver.
- *
+ *
* @return the tree viewer
*/
public TreeViewer getViewer() {
@@ -1056,7 +967,7 @@ public class FilteredTree extends Composite {
/**
* Get the filter text for the receiver, if it was created. Otherwise return
* <code>null</code>.
- *
+ *
* @return the filter Text, or null if it was not created
*/
public Text getFilterControl() {
@@ -1066,7 +977,7 @@ public class FilteredTree extends Composite {
/**
* Convenience method to return the text of the filter control. If the text
* widget is not created, then null is returned.
- *
+ *
* @return String in the text, or null if the text does not exist
*/
protected String getFilterString() {
@@ -1077,13 +988,13 @@ public class FilteredTree extends Composite {
* Set the text that will be shown until the first focus. A default value is
* provided, so this method only need be called if overriding the default
* initial text is desired.
- *
+ *
* @param text
* initial text to appear in text field
*/
public void setInitialText(String text) {
initialText = text;
- if (useNewLook && filterText != null) {
+ if (filterText != null) {
filterText.setMessage(text);
if (filterText.isFocusControl()) {
setFilterText(initialText);
@@ -1108,7 +1019,7 @@ public class FilteredTree extends Composite {
/**
* Select all text in the filter text field.
- *
+ *
*/
protected void selectAll() {
if (filterText != null) {
@@ -1118,7 +1029,7 @@ public class FilteredTree extends Composite {
/**
* Get the initial text for the receiver.
- *
+ *
* @return String
*/
protected String getInitialText() {
@@ -1129,14 +1040,14 @@ public class FilteredTree extends Composite {
* Return a bold font if the given element matches the given pattern.
* Clients can opt to call this method from a Viewer's label provider to get
* a bold font for which to highlight the given element in the tree.
- *
+ *
* @param element
* element for which a match should be determined
* @param tree
* FilteredTree in which the element resides
* @param filter
* PatternFilter which determines a match
- *
+ *
* @return bold font
*/
public static Font getBoldFont(Object element, FilteredTree tree,
@@ -1171,9 +1082,9 @@ public class FilteredTree extends Composite {
/**
* Custom tree viewer subclass that clears the caches in patternFilter on
* any change to the tree. See bug 187200.
- *
+ *
* @since 3.3
- *
+ *
*/
class NotifyingTreeViewer extends TreeViewer {
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/PatternFilter.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/PatternFilter.java
index 4a0e287..a2ea942 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/PatternFilter.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/PatternFilter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2014 IBM Corporation and others.
+ * Copyright (c) 2004, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -29,12 +29,12 @@ public class PatternFilter extends ViewerFilter {
/*
* Cache of filtered elements in the tree
*/
- private Map cache = new HashMap();
+ private Map<Object, Object[]> cache = new HashMap<>();
/*
* Maps parent elements to TRUE or FALSE
*/
- private Map foundAnyCache = new HashMap();
+ private Map<Object, Boolean> foundAnyCache = new HashMap<>();
private boolean useCache = false;
@@ -66,9 +66,9 @@ public class PatternFilter extends ViewerFilter {
return super.filter(viewer, parent, elements);
}
- Object[] filtered = (Object[]) cache.get(parent);
+ Object[] filtered = cache.get(parent);
if (filtered == null) {
- Boolean foundAny = (Boolean) foundAnyCache.get(parent);
+ Boolean foundAny = foundAnyCache.get(parent);
if (foundAny != null && !foundAny.booleanValue()) {
filtered = EMPTY;
} else {
@@ -83,7 +83,7 @@ public class PatternFilter extends ViewerFilter {
* Returns true if any of the elements makes it through the filter. This
* method uses caching if enabled; the computation is done in
* computeAnyVisible.
- *
+ *
* @param viewer
* @param parent
* @param elements
@@ -99,14 +99,13 @@ public class PatternFilter extends ViewerFilter {
return computeAnyVisible(viewer, elements);
}
- Object[] filtered = (Object[]) cache.get(parent);
+ Object[] filtered = cache.get(parent);
if (filtered != null) {
return filtered.length > 0;
}
- Boolean foundAny = (Boolean) foundAnyCache.get(parent);
+ Boolean foundAny = foundAnyCache.get(parent);
if (foundAny == null) {
- foundAny = computeAnyVisible(viewer, elements) ? Boolean.TRUE
- : Boolean.FALSE;
+ foundAny = computeAnyVisible(viewer, elements) ? Boolean.TRUE : Boolean.FALSE;
foundAnyCache.put(parent, foundAny);
}
return foundAny.booleanValue();
@@ -114,7 +113,7 @@ public class PatternFilter extends ViewerFilter {
/**
* Returns true if any of the elements makes it through the filter.
- *
+ *
* @param viewer
* the viewer
* @param elements
@@ -132,27 +131,25 @@ public class PatternFilter extends ViewerFilter {
}
@Override
- public final boolean select(Viewer viewer, Object parentElement,
- Object element) {
+ public final boolean select(Viewer viewer, Object parentElement, Object element) {
return isElementVisible(viewer, element);
}
/**
* Sets whether a leading wildcard should be attached to each pattern
* string.
- *
+ *
* @param includeLeadingWildcard
* Whether a leading wildcard should be added.
*/
- public final void setIncludeLeadingWildcard(
- final boolean includeLeadingWildcard) {
+ public final void setIncludeLeadingWildcard(final boolean includeLeadingWildcard) {
this.includeLeadingWildcard = includeLeadingWildcard;
}
/**
* The pattern string for which this filter should select elements in the
* viewer.
- *
+ *
* @param patternString
*/
public void setPattern(String patternString) {
@@ -188,10 +185,10 @@ public class PatternFilter extends ViewerFilter {
/**
* Answers whether the given String matches the pattern.
- *
+ *
* @param string
* the String to test
- *
+ *
* @return whether the string matches the pattern
*/
private boolean match(String string) {
@@ -206,7 +203,7 @@ public class PatternFilter extends ViewerFilter {
* tree. For example, if a tree has items that are categorized, the category
* itself may not be a valid selection since it is used merely to organize
* the elements.
- *
+ *
* @param element
* @return true if this element is eligible for automatic selection
*/
@@ -220,14 +217,14 @@ public class PatternFilter extends ViewerFilter {
* in the tree based on whether the provided filter text matches the text of
* the given element's text, or that of it's children (if the element has
* any).
- *
+ *
* Subclasses may override this method.
- *
+ *
* @param viewer
* the tree viewer in which the element resides
* @param element
* the element in the tree to check for a match
- *
+ *
* @return true if the element matches the filter pattern
*/
public boolean isElementVisible(Viewer viewer, Object element) {
@@ -238,9 +235,9 @@ public class PatternFilter extends ViewerFilter {
* Check if the parent (category) is a match to the filter text. The default
* behavior returns true if the element has at least one child element that
* is a match with the filter text.
- *
+ *
* Subclasses may override this method.
- *
+ *
* @param viewer
* the viewer that contains the element
* @param element
@@ -261,9 +258,9 @@ public class PatternFilter extends ViewerFilter {
/**
* Check if the current (leaf) element is a match with the filter text. The
* default behavior checks that the label of the element is a match.
- *
+ *
* Subclasses should override this method.
- *
+ *
* @param viewer
* the viewer that contains the element
* @param element
@@ -283,12 +280,12 @@ public class PatternFilter extends ViewerFilter {
/**
* Take the given filter text and break it down into words using a
* BreakIterator.
- *
+ *
* @param text
* @return an array of words
*/
private String[] getWords(String text) {
- List words = new ArrayList();
+ List<String> words = new ArrayList<>();
// Break the text up into words, separating based on whitespace and
// common punctuation.
// Previously used String.split(..., "\\W"), where "\W" is a regular
@@ -312,13 +309,13 @@ public class PatternFilter extends ViewerFilter {
}
i = j;
}
- return (String[]) words.toArray(new String[words.size()]);
+ return words.toArray(new String[words.size()]);
}
/**
* Return whether or not if any of the words in text satisfy the match
* critera.
- *
+ *
* @param text
* the text to match
* @return boolean <code>true</code> if one of the words in text satisifes
@@ -348,7 +345,7 @@ public class PatternFilter extends ViewerFilter {
/**
* Can be called by the filtered tree to turn on caching.
- *
+ *
* @param useCache
* The useCache to set.
*/
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/SearchPattern.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/SearchPattern.java
new file mode 100644
index 0000000..9eb6429
--- /dev/null
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/SearchPattern.java
@@ -0,0 +1,679 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.e4.ui.workbench.swt.internal.copy;
+
+import org.eclipse.jface.util.Util;
+
+/**
+ * A copy of org.eclipse.ui.dialogs.SearchPattern
+ */
+public class SearchPattern {
+
+ // Rules for pattern matching: (exact, prefix, pattern) [ | case sensitive]
+ /**
+ * Match rule: The search pattern matches exactly the search result, that
+ * is, the source of the search result equals the search pattern. Search pattern
+ * should start from lowerCase char.
+ */
+ public static final int RULE_EXACT_MATCH = 0;
+
+ /**
+ * Match rule: The search pattern is a prefix of the search result.
+ */
+ public static final int RULE_PREFIX_MATCH = 0x0001;
+
+ /**
+ * Match rule: The search pattern contains one or more wild cards ('*' or
+ * '?'). A '*' wild-card can replace 0 or more characters in the search
+ * result. A '?' wild-card replaces exactly 1 character in the search
+ * result.
+ */
+ public static final int RULE_PATTERN_MATCH = 0x0002;
+
+ /**
+ * Match rule: The search pattern matches the search result only if cases
+ * are the same. Can be combined to previous rules, e.g.
+ * {@link #RULE_EXACT_MATCH} | {@link #RULE_CASE_SENSITIVE}
+ */
+ public static final int RULE_CASE_SENSITIVE = 0x0008;
+
+ /**
+ * Match rule: The search pattern is blank.
+ */
+ public static final int RULE_BLANK_MATCH = 0x0020;
+
+ /**
+ * Match rule: The search pattern contains a Camel Case expression. <br>
+ * Examples:
+ * <ul>
+ * <li><code>NPE</code> type string pattern will match
+ * <code>NullPointerException</code> and
+ * <code>NpPermissionException</code> types,</li>
+ * <li><code>NuPoEx</code> type string pattern will only match
+ * <code>NullPointerException</code> type.</li>
+ * </ul>
+ *
+ *
+ * <br>
+ * Can be combined to {@link #RULE_PREFIX_MATCH} match rule. For example,
+ * when prefix match rule is combined with Camel Case match rule,
+ * <code>"nPE"</code> pattern will match <code>nPException</code>. <br>
+ * Match rule {@link #RULE_PATTERN_MATCH} may also be combined but both
+ * rules will not be used simultaneously as they are mutually exclusive.
+ * Used match rule depends on whether string pattern contains specific
+ * pattern characters (e.g. '*' or '?') or not. If it does, then only
+ * Pattern match rule will be used, otherwise only Camel Case match will be
+ * used. For example, with <code>"NPE"</code> string pattern, search will
+ * only use Camel Case match rule, but with <code>N*P*E*</code> string
+ * pattern, it will use only Pattern match rule.
+ *
+ */
+ public static final int RULE_CAMELCASE_MATCH = 0x0080;
+
+ private int matchRule;
+
+ private String stringPattern;
+
+ private String initialPattern;
+
+ private StringMatcher stringMatcher;
+
+ private static final char END_SYMBOL = '<';
+
+ private static final char ANY_STRING = '*';
+
+ private static final char BLANK = ' ';
+
+ private int allowedRules;
+
+ /**
+ * Creates new instance of SearchPattern Default allowedRules for it is
+ * result of belong logic operation: ( RULE_EXACT_MATCH | RULE_PREFIX_MATCH |
+ * RULE_PATTERN_MATCH | RULE_CAMELCASE_MATCH )
+ *
+ */
+ public SearchPattern() {
+ this(RULE_EXACT_MATCH | RULE_PREFIX_MATCH | RULE_PATTERN_MATCH
+ | RULE_CAMELCASE_MATCH | RULE_BLANK_MATCH);
+ }
+
+ /**
+ * Creates a search pattern with the rule to apply for matching index keys.
+ * It can be exact match, prefix match, pattern match or camelCase match.
+ * Rule can also be combined with a case sensitivity flag.
+ *
+ * @param allowedRules
+ * one of {@link #RULE_EXACT_MATCH}, {@link #RULE_PREFIX_MATCH},
+ * {@link #RULE_PATTERN_MATCH}, {@link #RULE_CASE_SENSITIVE},
+ * {@link #RULE_CAMELCASE_MATCH} combined with one of following
+ * values: {@link #RULE_EXACT_MATCH}, {@link #RULE_PREFIX_MATCH},
+ * {@link #RULE_PATTERN_MATCH} or {@link #RULE_CAMELCASE_MATCH}.
+ * e.g. {@link #RULE_EXACT_MATCH} | {@link #RULE_CASE_SENSITIVE}
+ * if an exact and case sensitive match is requested,
+ * {@link #RULE_PREFIX_MATCH} if a prefix non case sensitive
+ * match is requested or {@link #RULE_EXACT_MATCH} if a non case
+ * sensitive and erasure match is requested.<br>
+ * Note also that default behavior for generic types/methods
+ * search is to find exact matches.
+ */
+ public SearchPattern(int allowedRules) {
+ this.allowedRules = allowedRules;
+ }
+
+ /**
+ * Gets string pattern used by matcher
+ *
+ * @return pattern
+ */
+ public String getPattern() {
+ return this.stringPattern;
+ }
+
+ /**
+ * @param stringPattern
+ * The stringPattern to set.
+ */
+ public void setPattern(String stringPattern) {
+ this.initialPattern = stringPattern;
+ this.stringPattern = stringPattern;
+ initializePatternAndMatchRule(stringPattern);
+ matchRule = matchRule & this.allowedRules;
+ if (matchRule == RULE_PATTERN_MATCH) {
+ stringMatcher = new StringMatcher(this.stringPattern, true, false);
+ }
+ }
+
+ /**
+ * Matches text with pattern. matching is determine by matchKind.
+ *
+ * @param text
+ * @return true if search pattern was matched with text false in other way
+ */
+ public boolean matches(String text) {
+ switch (matchRule) {
+ case RULE_BLANK_MATCH:
+ return true;
+ case RULE_PATTERN_MATCH:
+ return stringMatcher.match(text);
+ case RULE_EXACT_MATCH:
+ return stringPattern.equalsIgnoreCase(text);
+ case RULE_CAMELCASE_MATCH:
+ if (camelCaseMatch(stringPattern, text)) {
+ return true;
+ }
+ //$FALL-THROUGH$
+ default:
+ return startsWithIgnoreCase(text, stringPattern);
+ }
+ }
+
+ private void initializePatternAndMatchRule(String pattern) {
+ int length = pattern.length();
+ if (length == 0) {
+ matchRule = RULE_BLANK_MATCH;
+ stringPattern = pattern;
+ return;
+ }
+ char last = pattern.charAt(length - 1);
+
+ if (pattern.indexOf('*') != -1 || pattern.indexOf('?') != -1) {
+ matchRule = RULE_PATTERN_MATCH;
+ switch (last) {
+ case END_SYMBOL:
+ case BLANK:
+ stringPattern = pattern.substring(0, length - 1);
+ break;
+ case ANY_STRING:
+ stringPattern = pattern;
+ break;
+ default:
+ stringPattern = pattern + ANY_STRING;
+ }
+ return;
+ }
+
+ if (validateMatchRule(pattern, RULE_CAMELCASE_MATCH) == RULE_CAMELCASE_MATCH) {
+ matchRule = RULE_CAMELCASE_MATCH;
+ stringPattern = pattern;
+ return;
+ }
+
+ if (last == END_SYMBOL || last == BLANK) {
+ matchRule = RULE_EXACT_MATCH;
+ stringPattern = pattern.substring(0, length - 1);
+ return;
+ }
+
+ matchRule = RULE_PREFIX_MATCH;
+ stringPattern = pattern;
+
+ }
+
+ /**
+ * @param text
+ * @param prefix
+ * @return true if text starts with given prefix, ignoring case false in
+ * other way
+ */
+ private boolean startsWithIgnoreCase(String text, String prefix) {
+ int textLength = text.length();
+ int prefixLength = prefix.length();
+ if (textLength < prefixLength)
+ return false;
+ for (int i = prefixLength - 1; i >= 0; i--) {
+ if (Character.toLowerCase(prefix.charAt(i)) != Character
+ .toLowerCase(text.charAt(i)))
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Answers true if the pattern matches the given name using CamelCase rules,
+ * or false otherwise. CamelCase matching does NOT accept explicit
+ * wild-cards '*' and '?' and is inherently case sensitive. <br>
+ * CamelCase denotes the convention of writing compound names without
+ * spaces, and capitalizing every term. This function recognizes both upper
+ * and lower CamelCase, depending whether the leading character is
+ * capitalized or not. The leading part of an upper CamelCase pattern is
+ * assumed to contain a sequence of capitals which are appearing in the
+ * matching name; e.g. 'NPE' will match 'NullPointerException', but not
+ * 'NewPerfData'. A lower CamelCase pattern uses a lowercase first
+ * character. In Java, type names follow the upper CamelCase convention,
+ * whereas method or field names follow the lower CamelCase convention. <br>
+ * The pattern may contain lowercase characters, which will be match in a
+ * case sensitive way. These characters must appear in sequence in the name.
+ * For instance, 'NPExcep' will match 'NullPointerException', but not
+ * 'NullPointerExCEPTION' or 'NuPoEx' will match 'NullPointerException', but
+ * not 'NoPointerException'. <br>
+ * <br>
+ * Examples:
+ * <ol>
+ * <li>
+ *
+ * <pre>
+ * pattern = &quot;NPE&quot;
+ * name = NullPointerException / NoPermissionException
+ * result =&gt; true
+ * </pre>
+ *
+ * </li>
+ * <li>
+ *
+ * <pre>
+ * pattern = &quot;NuPoEx&quot;
+ * name = NullPointerException
+ * result =&gt; true
+ * </pre>
+ *
+ * </li>
+ * <li>
+ *
+ * <pre>
+ * pattern = &quot;npe&quot;
+ * name = NullPointerException
+ * result =&gt; false
+ * </pre>
+ *
+ * </li>
+ * </ol>
+ *
+ * @param pattern
+ * the given pattern
+ * @param name
+ * the given name
+ * @return true if the pattern matches the given name, false otherwise
+ *
+ */
+ private boolean camelCaseMatch(String pattern, String name) {
+ if (pattern == null)
+ return true; // null pattern is equivalent to '*'
+ if (name == null)
+ return false; // null name cannot match
+
+ return camelCaseMatch(pattern, 0, pattern.length(), name, 0, name
+ .length());
+ }
+
+ /**
+ * Answers true if a sub-pattern matches the subpart of the given name using
+ * CamelCase rules, or false otherwise. CamelCase matching does NOT accept
+ * explicit wild-cards '*' and '?' and is inherently case sensitive. Can
+ * match only subset of name/pattern, considering end positions as
+ * non-inclusive. The subpattern is defined by the patternStart and
+ * patternEnd positions. <br>
+ * CamelCase denotes the convention of writing compound names without
+ * spaces, and capitalizing every term. This function recognizes both upper
+ * and lower CamelCase, depending whether the leading character is
+ * capitalized or not. The leading part of an upper CamelCase pattern is
+ * assumed to contain a sequence of capitals which are appearing in the
+ * matching name; e.g. 'NPE' will match 'NullPointerException', but not
+ * 'NewPerfData'. A lower CamelCase pattern uses a lowercase first
+ * character. In Java, type names follow the upper CamelCase convention,
+ * whereas method or field names follow the lower CamelCase convention. <br>
+ * The pattern may contain lowercase characters, which will be match in a
+ * case sensitive way. These characters must appear in sequence in the name.
+ * For instance, 'NPExcep' will match 'NullPointerException', but not
+ * 'NullPointerExCEPTION' or 'NuPoEx' will match 'NullPointerException', but
+ * not 'NoPointerException'. <br>
+ * <br>
+ * Examples:
+ * <ol>
+ * <li>
+ *
+ * <pre>
+ * pattern = &quot;NPE&quot;
+ * patternStart = 0
+ * patternEnd = 3
+ * name = NullPointerException
+ * nameStart = 0
+ * nameEnd = 20
+ * result =&gt; true
+ * </pre>
+ *
+ * </li>
+ * <li>
+ *
+ * <pre>
+ * pattern = &quot;NPE&quot;
+ * patternStart = 0
+ * patternEnd = 3
+ * name = NoPermissionException
+ * nameStart = 0
+ * nameEnd = 21
+ * result =&gt; true
+ * </pre>
+ *
+ * </li>
+ * <li>
+ *
+ * <pre>
+ * pattern = &quot;NuPoEx&quot;
+ * patternStart = 0
+ * patternEnd = 6
+ * name = NullPointerException
+ * nameStart = 0
+ * nameEnd = 20
+ * result =&gt; true
+ * </pre>
+ *
+ * </li>
+ * <li>
+ *
+ * <pre>
+ * pattern = &quot;NuPoEx&quot;
+ * patternStart = 0
+ * patternEnd = 6
+ * name = NoPermissionException
+ * nameStart = 0
+ * nameEnd = 21
+ * result =&gt; false
+ * </pre>
+ *
+ * </li>
+ * <li>
+ *
+ * <pre>
+ * pattern = &quot;npe&quot;
+ * patternStart = 0
+ * patternEnd = 3
+ * name = NullPointerException
+ * nameStart = 0
+ * nameEnd = 20
+ * result =&gt; false
+ * </pre>
+ *
+ * </li>
+ * </ol>
+ *
+ * @param pattern
+ * the given pattern
+ * @param patternStart
+ * the start index of the pattern, inclusive
+ * @param patternEnd
+ * the end index of the pattern, exclusive
+ * @param name
+ * the given name
+ * @param nameStart
+ * the start index of the name, inclusive
+ * @param nameEnd
+ * the end index of the name, exclusive
+ * @return true if a sub-pattern matches the subpart of the given name,
+ * false otherwise
+ */
+ private boolean camelCaseMatch(String pattern, int patternStart,
+ int patternEnd, String name, int nameStart, int nameEnd) {
+ if (name == null)
+ return false; // null name cannot match
+ if (pattern == null)
+ return true; // null pattern is equivalent to '*'
+ if (patternEnd < 0)
+ patternEnd = pattern.length();
+ if (nameEnd < 0)
+ nameEnd = name.length();
+
+ if (patternEnd <= patternStart)
+ return nameEnd <= nameStart;
+ if (nameEnd <= nameStart)
+ return false;
+ // check first pattern char
+ if (name.charAt(nameStart) != pattern.charAt(patternStart)) {
+ // first char must strictly match (upper/lower)
+ return false;
+ }
+
+ int patternLength = patternEnd;
+
+ if (pattern.charAt(patternEnd - 1) == END_SYMBOL || pattern.charAt(patternEnd - 1) == BLANK )
+ patternLength = patternEnd - 1;
+
+
+ char patternChar, nameChar;
+ int iPattern = patternStart;
+ int iName = nameStart;
+
+ // Main loop is on pattern characters
+ while (true) {
+
+ iPattern++;
+ iName++;
+
+ if (iPattern == patternEnd) {
+ // We have exhausted pattern, so it's a match
+ return true;
+ }
+
+ if (iName == nameEnd) {
+ if (iPattern == patternLength)
+ return true;
+ // We have exhausted name (and not pattern), so it's not a match
+ return false;
+ }
+
+ // For as long as we're exactly matching, bring it on (even if it's
+ // a lower case character)
+ if ((patternChar = pattern.charAt(iPattern)) == name.charAt(iName)) {
+ continue;
+ }
+
+ // If characters are not equals, then it's not a match if
+ // patternChar is lowercase
+ if (!isPatternCharAllowed(patternChar))
+ return false;
+
+ // patternChar is uppercase, so let's find the next uppercase in
+ // name
+ while (true) {
+ if (iName == nameEnd) {
+ if ((iPattern == patternLength) && (patternChar == END_SYMBOL || patternChar == BLANK))
+ return true;
+ return false;
+ }
+
+ nameChar = name.charAt(iName);
+
+ if ((iPattern == patternLength) && (patternChar == END_SYMBOL || patternChar == BLANK)) {
+ if (isNameCharAllowed(nameChar)) {
+ return false;
+ }
+ iName++;
+ continue;
+ }
+
+ if (Character.isDigit(nameChar)) {
+ // nameChar is digit => break if the digit is current pattern character otherwise consume it
+ if (patternChar == nameChar) break;
+ iName++;
+ } else if (!isNameCharAllowed(nameChar)) {
+ // nameChar is lowercase
+ iName++;
+ // nameChar is uppercase...
+ } else if (patternChar != nameChar) {
+ // .. and it does not match patternChar, so it's not a match
+ return false;
+ } else {
+ // .. and it matched patternChar. Back to the big loop
+ break;
+ }
+ }
+ // At this point, either name has been exhausted, or it is at an
+ // uppercase letter.
+ // Since pattern is also at an uppercase letter
+ }
+ }
+
+ /**
+ * Checks pattern's character is allowed for specified set. It could be
+ * override if you want change logic of camelCaseMatch methods.
+ *
+ * @param patternChar
+ * @return true if patternChar is in set of allowed characters for pattern
+ */
+ protected boolean isPatternCharAllowed(char patternChar) {
+ return patternChar == END_SYMBOL || patternChar == BLANK
+ || Character.isUpperCase(patternChar) || Character.isDigit(patternChar);
+ }
+
+ /**
+ * Checks character of element's name is allowed for specified set. It could
+ * be override if you want change logic of camelCaseMatch methods.
+ *
+ * @param nameChar -
+ * name of searched element
+ * @return if nameChar is in set of allowed characters for name of element
+ */
+ protected boolean isNameCharAllowed(char nameChar) {
+ return Character.isUpperCase(nameChar);
+ }
+
+ /**
+ * Returns the rule to apply for matching keys. Can be exact match, prefix
+ * match, pattern match or camelcase match. Rule can also be combined with a
+ * case sensitivity flag.
+ *
+ * @return one of RULE_EXACT_MATCH, RULE_PREFIX_MATCH, RULE_PATTERN_MATCH,
+ * RULE_CAMELCASE_MATCH, combined with RULE_CASE_SENSITIVE, e.g.
+ * RULE_EXACT_MATCH | RULE_CASE_SENSITIVE if an exact and case
+ * sensitive match is requested, or RULE_PREFIX_MATCH if a prefix
+ * non case sensitive match is requested.
+ */
+ public final int getMatchRule() {
+ return this.matchRule;
+ }
+
+ /**
+ * Validate compatibility between given string pattern and match rule. <br>
+ * Optimized (ie. returned match rule is modified) combinations are:
+ * <ul>
+ * <li>{@link #RULE_PATTERN_MATCH} without any '*' or '?' in string pattern: pattern match bit
+ * is unset,</li>
+ * <li>{@link #RULE_PATTERN_MATCH} and {@link #RULE_PREFIX_MATCH} bits simultaneously set:
+ * prefix match bit is unset,</li>
+ * <li>{@link #RULE_PATTERN_MATCH} and {@link #RULE_CAMELCASE_MATCH} bits simultaneously set:
+ * camel case match bit is unset,</li>
+ * <li>{@link #RULE_CAMELCASE_MATCH} with invalid combination of uppercase and lowercase
+ * characters: camel case match bit is unset and replaced with prefix match pattern,</li>
+ * <li>{@link #RULE_CAMELCASE_MATCH} combined with {@link #RULE_PREFIX_MATCH} and
+ * {@link #RULE_CASE_SENSITIVE} bits is reduced to only {@link #RULE_CAMELCASE_MATCH} as Camel
+ * Case search is already prefix and case sensitive,</li>
+ * </ul>
+ * <br>
+ * Rejected (ie. returned match rule -1) combinations are:
+ * <ul>
+ * <li>{@link #RULE_PATTERN_MATCH} with any other match mode bit set,</li>
+ * </ul>
+ *
+ * @param stringPattern The string pattern
+ * @param matchRule The match rule
+ * @return Optimized valid match rule or -1 if an incompatibility was detected.
+ */
+ private int validateMatchRule(String stringPattern, int matchRule) {
+
+ // Verify Pattern match rule
+ int starIndex = stringPattern.indexOf('*');
+ int questionIndex = stringPattern.indexOf('?');
+ if (starIndex < 0 && questionIndex < 0) {
+ // reset pattern match bit if any
+ matchRule &= ~RULE_PATTERN_MATCH;
+ } else {
+ // force Pattern rule
+ matchRule |= RULE_PATTERN_MATCH;
+ }
+ if ((matchRule & RULE_PATTERN_MATCH) != 0) {
+ // remove Camel Case and Prefix match bits if any
+ matchRule &= ~RULE_CAMELCASE_MATCH;
+ matchRule &= ~RULE_PREFIX_MATCH;
+ }
+
+ // Verify Camel Case match rule
+ if ((matchRule & RULE_CAMELCASE_MATCH) != 0) {
+ // Verify sting pattern validity
+ int length = stringPattern.length();
+ boolean validCamelCase = true;
+ for (int i = 0; i < length && validCamelCase; i++) {
+ char ch = stringPattern.charAt(i);
+ validCamelCase = isValidCamelCaseChar(ch);
+ }
+ validCamelCase = validCamelCase && Character.isUpperCase(stringPattern.charAt(0));
+ // Verify bits compatibility
+ if (validCamelCase) {
+ if ((matchRule & RULE_PREFIX_MATCH) != 0) {
+ if ((matchRule & RULE_CASE_SENSITIVE) != 0) {
+ // This is equivalent to Camel Case match rule
+ matchRule &= ~RULE_PREFIX_MATCH;
+ matchRule &= ~RULE_CASE_SENSITIVE;
+ }
+ }
+ } else {
+ matchRule &= ~RULE_CAMELCASE_MATCH;
+ if ((matchRule & RULE_PREFIX_MATCH) == 0) {
+ matchRule |= RULE_PREFIX_MATCH;
+ matchRule |= RULE_CASE_SENSITIVE;
+ }
+ }
+ }
+ return matchRule;
+ }
+
+ /**
+ * Check if character is valid camelCase character
+ *
+ * @param ch
+ * character to be validated
+ * @return true if character is valid
+ */
+ protected boolean isValidCamelCaseChar(char ch) {
+ return true;
+ }
+
+ /**
+ * Tells whether the given <code>SearchPattern</code> equals this pattern.
+ *
+ * @param pattern
+ * pattern to be checked
+ * @return true if the given pattern equals this search pattern
+ */
+ public boolean equalsPattern(SearchPattern pattern) {
+ return trimWildcardCharacters(pattern.initialPattern).equals(
+ trimWildcardCharacters(this.initialPattern));
+ }
+
+ /**
+ * Tells whether the given <code>SearchPattern</code> is a sub-pattern of
+ * this pattern.
+ * <p>
+ * <i>WARNING: This method is <b>not</b> defined in reading order, i.e.
+ * <code>a.isSubPattern(b)</code> is <code>true</code> iff
+ * <code>b</code> is a sub-pattern of <code>a</code>, and not vice-versa.
+ * </i>
+ * </p>
+ *
+ * @param pattern
+ * pattern to be checked
+ * @return true if the given pattern is a sub pattern of this search pattern
+ */
+ public boolean isSubPattern(SearchPattern pattern) {
+ return trimWildcardCharacters(pattern.initialPattern).startsWith(
+ trimWildcardCharacters(this.initialPattern));
+ }
+
+ /**
+ * Trims sequences of '*' characters
+ *
+ * @param pattern
+ * string to be trimmed
+ * @return trimmed pattern
+ */
+ private String trimWildcardCharacters(String pattern) {
+ return Util.replaceAll(pattern, "\\*+", "\\*"); //$NON-NLS-1$ //$NON-NLS-2$ }
+ }
+
+}
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/ShowViewDialog.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/ShowViewDialog.java
index 2e2a482..64a4925 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/ShowViewDialog.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/ShowViewDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Sebastian Davids - bug 128526, bug 128529
+ * Lars Vogel <Lars.Vogel@gmail.com> - Bug 440381
*******************************************************************************/
package org.eclipse.e4.ui.workbench.swt.internal.copy;
@@ -80,7 +81,7 @@ public class ShowViewDialog extends Dialog implements
/**
* Constructs a new ShowViewDialog.
- *
+ *
* @param window
* the workbench window
* @param viewReg
@@ -178,14 +179,14 @@ public class ShowViewDialog extends Dialog implements
/**
* Create a new filtered tree viewer in the parent.
- *
+ *
* @param parent
* the parent <code>Composite</code>.
*/
private void createFilteredTreeViewer(Composite parent) {
PatternFilter filter = new ViewPatternFilter(context);
int styleBits = SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER;
- filteredTree = new FilteredTree(parent, styleBits, filter, true);
+ filteredTree = new FilteredTree(parent, styleBits, filter);
filteredTree.setBackground(parent.getDisplay().getSystemColor(
SWT.COLOR_WIDGET_BACKGROUND));
@@ -216,7 +217,7 @@ public class ShowViewDialog extends Dialog implements
/**
* Return whether or not there are less than two views in the list.
- *
+ *
* @param tree
* @return <code>true</code> if there are less than two views in the list.
*/
@@ -265,7 +266,7 @@ public class ShowViewDialog extends Dialog implements
/**
* Returns the descriptors for the selected views.
- *
+ *
* @return the descriptors for the selected views
*/
public MPartDescriptor[] getSelection() {
@@ -274,7 +275,7 @@ public class ShowViewDialog extends Dialog implements
/**
* Layout the top control.
- *
+ *
* @param control
* the control.
*/
@@ -377,12 +378,12 @@ public class ShowViewDialog extends Dialog implements
* Update the selection object.
*/
protected void updateSelection(SelectionChangedEvent event) {
- ArrayList descs = new ArrayList();
+ ArrayList<MPartDescriptor> descs = new ArrayList<>();
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
- for (Iterator i = sel.iterator(); i.hasNext();) {
+ for (Iterator<?> i = sel.iterator(); i.hasNext();) {
Object o = i.next();
if (o instanceof MPartDescriptor) {
- descs.add(o);
+ descs.add((MPartDescriptor) o);
}
}
@@ -399,8 +400,8 @@ public class ShowViewDialog extends Dialog implements
// popup the description for the selected view
if (descriptionHint.isVisible() && event.keyCode == SWT.F2
&& event.stateMask == 0) {
- ITreeSelection selection = (ITreeSelection) filteredTree
- .getViewer().getSelection();
+ // FIXME RAP getStructuredSelection()
+ ITreeSelection selection = (ITreeSelection) filteredTree.getViewer().getSelection();
// only show description if one view is selected
if (selection.size() == 1) {
Object o = selection.getFirstElement();
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/StringMatcher.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/StringMatcher.java
index 2dbff53..670185d 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/StringMatcher.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/StringMatcher.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2014 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -59,17 +59,17 @@ public class StringMatcher {
* StringMatcher constructor takes in a String object that is a simple
* pattern which may contain '*' for 0 and many characters and '?' for
* exactly one character.
- *
- * Literal '*' and '?' characters must be escaped in the pattern e.g.,
- * "\*" means literal "*", etc.
- *
+ *
+ * Literal '*' and '?' characters must be escaped in the pattern e.g., "\*"
+ * means literal "*", etc.
+ *
* Escaping any other character (including the escape character itself),
* just results in that character in the pattern. e.g., "\a" means "a" and
* "\\" means "\"
- *
+ *
* If invoking the StringMatcher with string literals in Java, don't forget
* escape characters are represented by "\\".
- *
+ *
* @param pattern
* the pattern to match text against
* @param ignoreCase
@@ -98,7 +98,7 @@ public class StringMatcher {
/**
* Find the first occurrence of the pattern between <code>start</code
* )(inclusive) and <code>end</code>(exclusive).
- *
+ *
* @param text
* the String object to search in
* @param start
@@ -167,7 +167,7 @@ public class StringMatcher {
/**
* match the given <code>text</code> with the pattern
- *
+ *
* @return true if matched otherwise false
* @param text
* a String object
@@ -183,7 +183,7 @@ public class StringMatcher {
* Given the starting (inclusive) and the ending (exclusive) positions in
* the <code>text</code>, determine if the given substring matches with
* aPattern
- *
+ *
* @return true if the specified portion of the text matches the pattern
* @param text
* a String object that contains the substring to match
@@ -289,7 +289,7 @@ public class StringMatcher {
/**
* Parses the given pattern into segments seperated by wildcard '*'
* characters.
- *
+ *
* @param p
* , a String object that is a simple regular expression with '*'
* and/or '?'
@@ -305,7 +305,7 @@ public class StringMatcher {
}
}
- Vector temp = new Vector();
+ Vector<String> temp = new Vector<>();
int pos = 0;
StringBuffer buf = new StringBuffer();
@@ -410,7 +410,7 @@ public class StringMatcher {
}
/**
- *
+ *
* @return boolean
* @param text
* a String to match
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/ViewComparator.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/ViewComparator.java
index 8448830..d6a0590 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/ViewComparator.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/ViewComparator.java
@@ -23,7 +23,7 @@ public class ViewComparator extends ViewerComparator {
/**
* ViewSorter constructor comment.
- *
+ *
* @param reg
* an IViewRegistry
*/
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/ViewContentProvider.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/ViewContentProvider.java
index c24119c..9d5651a 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/ViewContentProvider.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/internal/copy/ViewContentProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -73,7 +73,7 @@ public class ViewContentProvider implements ITreeContentProvider {
@Override
public Object[] getChildren(Object element) {
- Object[] children = (Object[]) childMap.get(element);
+ Object[] children = childMap.get(element);
if (children == null) {
children = createChildren(element);
childMap.put(element, children);
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/util/BindingProcessingAddon.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/util/BindingProcessingAddon.java
index 74f1ca8..6d2d6b0 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/util/BindingProcessingAddon.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/util/BindingProcessingAddon.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2014 IBM Corporation and others.
+ * Copyright (c) 2010, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -137,7 +137,8 @@ public class BindingProcessingAddon {
}
}
if (me instanceof MElementContainer) {
- List<MUIElement> children = ((MElementContainer) me).getChildren();
+ @SuppressWarnings("unchecked")
+ List<MUIElement> children = ((MElementContainer<MUIElement>) me).getChildren();
Iterator<MUIElement> i = children.iterator();
while (i.hasNext()) {
MUIElement e = i.next();
diff --git a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/util/ISWTResourceUtilities.java b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/util/ISWTResourceUtilities.java
index 7d28d8c..3093c91 100644
--- a/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/util/ISWTResourceUtilities.java
+++ b/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/workbench/swt/util/ISWTResourceUtilities.java
@@ -20,12 +20,12 @@ public interface ISWTResourceUtilities extends
/**
* Low-level utility to stamp an adornment onto a given Image.
- *
+ *
* @param toAdorn
* The image to be adorned (must not be null)
* @param adornment
* The image to adorn with.
- *
+ *
* @return The adorned image or 'toAdorn' if 'adornment' is null
*/
public Image adornImage(Image toAdorn, Image adornment);

Back to the top