diff --git a/.gitignore b/.gitignore index 9c58ac0..27012af 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,7 @@ bin/* build/* +/bin +/target +.metadata/* +.recommenders/* +RemoteSystemsTempFiles/* diff --git a/README b/README index f84ebc1..62c62fe 100644 --- a/README +++ b/README @@ -1,20 +1,34 @@ This is an Eclipse plugin that allows creating a dynamic Classpath Container that observes a folder -and loads all .jar (or .zip etc) files into the classpath. +and loads all .jar (or .zip etc) files into the classpath. This plugin is helpful to use a bunch of jar files in one folder as your classpath, without setting it manually. +We use it to get rid of the buggy IvyDE plugin for our IVY dependency management. It is an evolution of original code I got from here: - https://www.ibm.com/developerworks/opensource/tutorials/os-eclipse-classpath/ - Thus it originates from Aaron Tarter (aarontar@us.ibm.com). -The primary modification I made (besides renaming things to no longer say 'example') was making it handle +The primary modification Ben Christensen made (besides renaming things to no longer say 'example') was making it handle filenames that had multiple dots (such as com.company.library.name.v2.jar). +The improvements I made (Darko Palic) are to allow multiple directory containers in the classpaths and of course therefore in the eclipse launches. +The previous version had bigger issues about it. + The binary in downloads on GitHub just needs to be dropped into the eclipse /plugins/ folder and it will then allow adding a "Directory Container" library to the Java Build Path. -https://github.com/downloads/benjchristensen/SimpleDirectoryContainer_EclipsePlugin/DirectoryClasspathContainer_1.0.0_EclipsePlugin.jar +You can find the latest verion here: +https://github.com/dpalic/SimpleDirectoryContainer_EclipsePlugin/tree/master/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin + +or directly (but maybe outdated): +https://github.com/dpalic/SimpleDirectoryContainer_EclipsePlugin/tree/master/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer_1.1.3.jar I created this jar by exporting a "Deployable plug-ins and fragments" from Eclipse at the project level. -Hope it helps someone other than me. +############### +# INSTALLATION +############### +1. Download the latest jar file (see above) +2. stop your eclipse (ensure it is really stopped in taskmanager) +3. put the downloaded jar file into your eclipse\plugin folder +4. restart your eclipse +5. in Eclipse go to you Java Build Path settings and go to the tab Libraries +6. "Add Library..." will provide you now a new entry "Directory container" diff --git a/SimpleDirectoryContainer_EclipseFeature/.project b/SimpleDirectoryContainer_EclipseFeature/.project new file mode 100644 index 0000000..319d8a3 --- /dev/null +++ b/SimpleDirectoryContainer_EclipseFeature/.project @@ -0,0 +1,17 @@ + + + SimpleDirectoryContainer_EclipseFeature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/SimpleDirectoryContainer_EclipseFeature/README b/SimpleDirectoryContainer_EclipseFeature/README new file mode 100644 index 0000000..c41dd70 --- /dev/null +++ b/SimpleDirectoryContainer_EclipseFeature/README @@ -0,0 +1,34 @@ +This is an Eclipse plugin that allows creating a dynamic Classpath Container that observes a folder +and loads all .jar (or .zip etc) files into the classpath. This plugin is helpful to use a bunch of jar files in one folder as your classpath, without setting it manually. +We use it to get rid of the buggy IvyDE plugin for our IVY dependency management. + +It is an evolution of original code I got from here: + https://www.ibm.com/developerworks/opensource/tutorials/os-eclipse-classpath/ +Thus it originates from Aaron Tarter (aarontar@us.ibm.com). + +The primary modification Ben Christensen made (besides renaming things to no longer say 'example') was making it handle +filenames that had multiple dots (such as com.company.library.name.v2.jar). + +The improvements I made (Darko Palic) are to allow multiple directory containers in the classpaths and of course therefore in the eclipse launches. +The previous version had bigger issues about it. + +The binary in downloads on GitHub just needs to be dropped into the eclipse /plugins/ folder and it will +then allow adding a "Directory Container" library to the Java Build Path. + +You can find the latest verion here: +https://github.com/dpalic/SimpleDirectoryContainer_EclipsePlugin/tree/master/ExportedPlugin + +or directly (but maybe outdated): +https://github.com/dpalic/SimpleDirectoryContainer_EclipsePlugin/raw/master/ExportedPlugin/DirectoryClasspathContainer_1.1.2.jar + +I created this jar by exporting a "Deployable plug-ins and fragments" from Eclipse at the project level. + +############### +# INSTALLATION +############### +1. Download the latest jar file (see above) +2. stop your eclipse (ensure it is really stopped in taskmanager) +3. put the downloaded jar file into your eclipse\plugin folder +4. restart your eclipse +5. in Eclipse go to you Java Build Path settings and go to the tab Libraries +6. "Add Library..." will provide you now a new entry "Directory container" diff --git a/SimpleDirectoryContainer_EclipseFeature/build.properties b/SimpleDirectoryContainer_EclipseFeature/build.properties new file mode 100644 index 0000000..64f93a9 --- /dev/null +++ b/SimpleDirectoryContainer_EclipseFeature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/SimpleDirectoryContainer_EclipseFeature/feature.xml b/SimpleDirectoryContainer_EclipseFeature/feature.xml new file mode 100644 index 0000000..b1269e2 --- /dev/null +++ b/SimpleDirectoryContainer_EclipseFeature/feature.xml @@ -0,0 +1,27 @@ + + + + + [Enter Feature Description here.] + + + + [Enter Copyright Description here.] + + + + [Enter License Description here.] + + + + + diff --git a/.classpath b/SimpleDirectoryContainer_EclipsePlugin/.classpath similarity index 77% rename from .classpath rename to SimpleDirectoryContainer_EclipsePlugin/.classpath index 751c8f2..098194c 100755 --- a/.classpath +++ b/SimpleDirectoryContainer_EclipsePlugin/.classpath @@ -1,7 +1,7 @@ - - + + diff --git a/SimpleDirectoryContainer_EclipsePlugin/.gitignore b/SimpleDirectoryContainer_EclipsePlugin/.gitignore new file mode 100644 index 0000000..4ee5adb --- /dev/null +++ b/SimpleDirectoryContainer_EclipsePlugin/.gitignore @@ -0,0 +1,4 @@ +bin/* +build/* +/bin +/target diff --git a/.project b/SimpleDirectoryContainer_EclipsePlugin/.project similarity index 100% rename from .project rename to SimpleDirectoryContainer_EclipsePlugin/.project diff --git a/SimpleDirectoryContainer_EclipsePlugin/.settings/org.eclipse.jdt.core.prefs b/SimpleDirectoryContainer_EclipsePlugin/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..b98a5bb --- /dev/null +++ b/SimpleDirectoryContainer_EclipsePlugin/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,301 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.codeComplete.argumentPrefixes= +org.eclipse.jdt.core.codeComplete.argumentSuffixes= +org.eclipse.jdt.core.codeComplete.fieldPrefixes= +org.eclipse.jdt.core.codeComplete.fieldSuffixes= +org.eclipse.jdt.core.codeComplete.localPrefixes= +org.eclipse.jdt.core.codeComplete.localSuffixes= +org.eclipse.jdt.core.codeComplete.staticFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFieldSuffixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes= +org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes= +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +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 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=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 +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=3 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=140 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=3 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true diff --git a/SimpleDirectoryContainer_EclipsePlugin/.settings/org.eclipse.jdt.ui.prefs b/SimpleDirectoryContainer_EclipsePlugin/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000..3d10491 --- /dev/null +++ b/SimpleDirectoryContainer_EclipsePlugin/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +formatter_profile=_SimpleDirectoryContainer +formatter_settings_version=12 +org.eclipse.jdt.ui.exception.name=e +org.eclipse.jdt.ui.gettersetter.use.is=true +org.eclipse.jdt.ui.keywordthis=false +org.eclipse.jdt.ui.overrideannotation=true diff --git a/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer.source_1.1.0.jar b/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer.source_1.1.0.jar new file mode 100644 index 0000000..714ebbc Binary files /dev/null and b/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer.source_1.1.0.jar differ diff --git a/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer.source_1.1.2.jar b/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer.source_1.1.2.jar new file mode 100644 index 0000000..ac48700 Binary files /dev/null and b/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer.source_1.1.2.jar differ diff --git a/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer.source_1.1.3.jar b/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer.source_1.1.3.jar new file mode 100644 index 0000000..2f1dbcb Binary files /dev/null and b/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer.source_1.1.3.jar differ diff --git a/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer_1.0.1.jar b/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer_1.0.1.jar new file mode 100644 index 0000000..713ba6b Binary files /dev/null and b/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer_1.0.1.jar differ diff --git a/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer_1.1.0.jar b/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer_1.1.0.jar new file mode 100644 index 0000000..f7a6b0d Binary files /dev/null and b/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer_1.1.0.jar differ diff --git a/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer_1.1.2.jar b/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer_1.1.2.jar new file mode 100644 index 0000000..d7c58b1 Binary files /dev/null and b/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer_1.1.2.jar differ diff --git a/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer_1.1.3.jar b/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer_1.1.3.jar new file mode 100644 index 0000000..9bc1ebe Binary files /dev/null and b/SimpleDirectoryContainer_EclipsePlugin/ExportedPlugin/DirectoryClasspathContainer_1.1.3.jar differ diff --git a/META-INF/MANIFEST.MF b/SimpleDirectoryContainer_EclipsePlugin/META-INF/MANIFEST.MF similarity index 55% rename from META-INF/MANIFEST.MF rename to SimpleDirectoryContainer_EclipsePlugin/META-INF/MANIFEST.MF index f9e3507..30b522f 100755 --- a/META-INF/MANIFEST.MF +++ b/SimpleDirectoryContainer_EclipsePlugin/META-INF/MANIFEST.MF @@ -2,11 +2,16 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Directory Container Bundle-SymbolicName: DirectoryClasspathContainer;singleton:=true -Bundle-Version: 1.0.0 +Bundle-Version: 1.1.3 Bundle-Localization: plugin Require-Bundle: org.eclipse.core.resources, org.eclipse.core.runtime, org.eclipse.jdt.core, org.eclipse.jdt.ui, - org.eclipse.jface + org.eclipse.jface, + org.eclipse.ui +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Export-Package: org.container.directory +Bundle-Activator: org.container.directory.Activator +Bundle-ActivationPolicy: lazy diff --git a/SimpleDirectoryContainer_EclipsePlugin/README b/SimpleDirectoryContainer_EclipsePlugin/README new file mode 100644 index 0000000..c41dd70 --- /dev/null +++ b/SimpleDirectoryContainer_EclipsePlugin/README @@ -0,0 +1,34 @@ +This is an Eclipse plugin that allows creating a dynamic Classpath Container that observes a folder +and loads all .jar (or .zip etc) files into the classpath. This plugin is helpful to use a bunch of jar files in one folder as your classpath, without setting it manually. +We use it to get rid of the buggy IvyDE plugin for our IVY dependency management. + +It is an evolution of original code I got from here: + https://www.ibm.com/developerworks/opensource/tutorials/os-eclipse-classpath/ +Thus it originates from Aaron Tarter (aarontar@us.ibm.com). + +The primary modification Ben Christensen made (besides renaming things to no longer say 'example') was making it handle +filenames that had multiple dots (such as com.company.library.name.v2.jar). + +The improvements I made (Darko Palic) are to allow multiple directory containers in the classpaths and of course therefore in the eclipse launches. +The previous version had bigger issues about it. + +The binary in downloads on GitHub just needs to be dropped into the eclipse /plugins/ folder and it will +then allow adding a "Directory Container" library to the Java Build Path. + +You can find the latest verion here: +https://github.com/dpalic/SimpleDirectoryContainer_EclipsePlugin/tree/master/ExportedPlugin + +or directly (but maybe outdated): +https://github.com/dpalic/SimpleDirectoryContainer_EclipsePlugin/raw/master/ExportedPlugin/DirectoryClasspathContainer_1.1.2.jar + +I created this jar by exporting a "Deployable plug-ins and fragments" from Eclipse at the project level. + +############### +# INSTALLATION +############### +1. Download the latest jar file (see above) +2. stop your eclipse (ensure it is really stopped in taskmanager) +3. put the downloaded jar file into your eclipse\plugin folder +4. restart your eclipse +5. in Eclipse go to you Java Build Path settings and go to the tab Libraries +6. "Add Library..." will provide you now a new entry "Directory container" diff --git a/SimpleDirectoryContainer_EclipsePlugin/SimpleDirectoryContainer.launch b/SimpleDirectoryContainer_EclipsePlugin/SimpleDirectoryContainer.launch new file mode 100644 index 0000000..7628611 --- /dev/null +++ b/SimpleDirectoryContainer_EclipsePlugin/SimpleDirectoryContainer.launch @@ -0,0 +1,289 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build.properties b/SimpleDirectoryContainer_EclipsePlugin/build.properties similarity index 100% rename from build.properties rename to SimpleDirectoryContainer_EclipsePlugin/build.properties diff --git a/lib/annotations-api.jar b/SimpleDirectoryContainer_EclipsePlugin/lib/annotations-api.jar similarity index 100% rename from lib/annotations-api.jar rename to SimpleDirectoryContainer_EclipsePlugin/lib/annotations-api.jar diff --git a/lib/catalina-ant.jar b/SimpleDirectoryContainer_EclipsePlugin/lib/catalina-ant.jar similarity index 100% rename from lib/catalina-ant.jar rename to SimpleDirectoryContainer_EclipsePlugin/lib/catalina-ant.jar diff --git a/lib/catalina-ha.jar b/SimpleDirectoryContainer_EclipsePlugin/lib/catalina-ha.jar similarity index 100% rename from lib/catalina-ha.jar rename to SimpleDirectoryContainer_EclipsePlugin/lib/catalina-ha.jar diff --git a/lib/catalina-tribes.jar b/SimpleDirectoryContainer_EclipsePlugin/lib/catalina-tribes.jar similarity index 100% rename from lib/catalina-tribes.jar rename to SimpleDirectoryContainer_EclipsePlugin/lib/catalina-tribes.jar diff --git a/lib/catalina.jar b/SimpleDirectoryContainer_EclipsePlugin/lib/catalina.jar similarity index 100% rename from lib/catalina.jar rename to SimpleDirectoryContainer_EclipsePlugin/lib/catalina.jar diff --git a/lib/ecj-3.3.1.jar b/SimpleDirectoryContainer_EclipsePlugin/lib/ecj-3.3.1.jar similarity index 100% rename from lib/ecj-3.3.1.jar rename to SimpleDirectoryContainer_EclipsePlugin/lib/ecj-3.3.1.jar diff --git a/lib/el-api.jar b/SimpleDirectoryContainer_EclipsePlugin/lib/el-api.jar similarity index 100% rename from lib/el-api.jar rename to SimpleDirectoryContainer_EclipsePlugin/lib/el-api.jar diff --git a/lib/jasper-el.jar b/SimpleDirectoryContainer_EclipsePlugin/lib/jasper-el.jar similarity index 100% rename from lib/jasper-el.jar rename to SimpleDirectoryContainer_EclipsePlugin/lib/jasper-el.jar diff --git a/lib/jasper.jar b/SimpleDirectoryContainer_EclipsePlugin/lib/jasper.jar similarity index 100% rename from lib/jasper.jar rename to SimpleDirectoryContainer_EclipsePlugin/lib/jasper.jar diff --git a/lib/jsp-api.jar b/SimpleDirectoryContainer_EclipsePlugin/lib/jsp-api.jar similarity index 100% rename from lib/jsp-api.jar rename to SimpleDirectoryContainer_EclipsePlugin/lib/jsp-api.jar diff --git a/lib/servlet-api.jar b/SimpleDirectoryContainer_EclipsePlugin/lib/servlet-api.jar similarity index 100% rename from lib/servlet-api.jar rename to SimpleDirectoryContainer_EclipsePlugin/lib/servlet-api.jar diff --git a/lib/tomcat-coyote.jar b/SimpleDirectoryContainer_EclipsePlugin/lib/tomcat-coyote.jar similarity index 100% rename from lib/tomcat-coyote.jar rename to SimpleDirectoryContainer_EclipsePlugin/lib/tomcat-coyote.jar diff --git a/lib/tomcat-dbcp.jar b/SimpleDirectoryContainer_EclipsePlugin/lib/tomcat-dbcp.jar similarity index 100% rename from lib/tomcat-dbcp.jar rename to SimpleDirectoryContainer_EclipsePlugin/lib/tomcat-dbcp.jar diff --git a/lib/tomcat-i18n-es.jar b/SimpleDirectoryContainer_EclipsePlugin/lib/tomcat-i18n-es.jar similarity index 100% rename from lib/tomcat-i18n-es.jar rename to SimpleDirectoryContainer_EclipsePlugin/lib/tomcat-i18n-es.jar diff --git a/lib/tomcat-i18n-fr.jar b/SimpleDirectoryContainer_EclipsePlugin/lib/tomcat-i18n-fr.jar similarity index 100% rename from lib/tomcat-i18n-fr.jar rename to SimpleDirectoryContainer_EclipsePlugin/lib/tomcat-i18n-fr.jar diff --git a/lib/tomcat-i18n-ja.jar b/SimpleDirectoryContainer_EclipsePlugin/lib/tomcat-i18n-ja.jar similarity index 100% rename from lib/tomcat-i18n-ja.jar rename to SimpleDirectoryContainer_EclipsePlugin/lib/tomcat-i18n-ja.jar diff --git a/plugin.properties b/SimpleDirectoryContainer_EclipsePlugin/plugin.properties similarity index 100% rename from plugin.properties rename to SimpleDirectoryContainer_EclipsePlugin/plugin.properties diff --git a/plugin.xml b/SimpleDirectoryContainer_EclipsePlugin/plugin.xml similarity index 100% rename from plugin.xml rename to SimpleDirectoryContainer_EclipsePlugin/plugin.xml diff --git a/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/Activator.java b/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/Activator.java new file mode 100644 index 0000000..047a620 --- /dev/null +++ b/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/Activator.java @@ -0,0 +1,61 @@ +package org.container.directory; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "DirectoryClasspathContainer"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } +} diff --git a/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/ClasspathExtraAttribute.java b/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/ClasspathExtraAttribute.java new file mode 100644 index 0000000..32d7e42 --- /dev/null +++ b/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/ClasspathExtraAttribute.java @@ -0,0 +1,18 @@ +package org.container.directory; + +/** + * Enums for the additional attributes. + * @author Darko Palic + */ +public enum ClasspathExtraAttribute { + FILE_EXTENSTIONS("extensions"); + + private String value; + private ClasspathExtraAttribute(String pValue) { + value = pValue; + } + + public String getValue() { + return value; + } +} diff --git a/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/ContainerDirFilter.java b/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/ContainerDirFilter.java new file mode 100755 index 0000000..3d50f2c --- /dev/null +++ b/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/ContainerDirFilter.java @@ -0,0 +1,57 @@ +package org.container.directory; + +import org.eclipse.core.resources.IFile; +import org.eclipse.jdt.core.IClasspathEntry; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerFilter; + +/** + * This element filter filters files from the Java Package View if they are + * included in a SimpleDirContainer that is on the parent Java project's + * classpath. This will prevent the user from right-clicking hte file and adding + * it to the build path as a CPE_LIBRARY classpath entry and thus prevent + * duplication on the classpath. + * + * @author Aaron J Tarter + */ +public class ContainerDirFilter extends ViewerFilter { + + /* + * @ return false if the Java element is a file that is contained in a + * SimpleDirContainer that is in the classpath of the owning Java project + * (non-Javadoc) + * + * @see org.eclipse.jface.viewers.ViewerFilter#select( + * org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) + */ + @Override + public boolean select(Viewer viewer, Object parentElement, Object element) { + if (element instanceof IFile) { + IFile f = (IFile) element; + IJavaProject jp = JavaCore.create(f.getProject()); + try { + // lets see if this file is included in a SimpleDirContainer + IClasspathEntry[] entries = jp.getRawClasspath(); + for (IClasspathEntry entry : entries) { + if (entry.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { + if (SimpleDirContainer.ID.isPrefixOf(entry.getPath())) { + // we know this is a SimpleDirContainer so lets get the instance + SimpleDirContainer con = (SimpleDirContainer) JavaCore.getClasspathContainer(entry.getPath(), jp); + if (con.isFileExtensionContained(f.getLocation().toFile())) { + // this file will is included in the container, so dont show it + return false; + } + } + } + } + } catch (JavaModelException e) { + Logger.log(Logger.ERROR, e); + } + } + return true; + } + +} diff --git a/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/Logger.java b/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/Logger.java new file mode 100755 index 0000000..d8782b9 --- /dev/null +++ b/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/Logger.java @@ -0,0 +1,52 @@ +package org.container.directory; + +import org.eclipse.core.runtime.ILog; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; + +/** + * This is a simple logger that logs messages and stack traces to the Eclipse + * error log. + * + * @author Aaron J Tarter + */ +public class Logger { + public final static String PLUGIN_ID = "org.container.directory"; + // logging severities + public static final int OK = IStatus.OK; + public static final int ERROR = IStatus.ERROR; + public static final int CANCEL = IStatus.CANCEL; + public static final int INFO = IStatus.INFO; + public static final int WARNING = IStatus.WARNING; + + // reference to the Eclipse error log + private static ILog log; + + /** + * Use the Activator, to get the logger. + * This ensures, that the logger will never be null. + */ + private static ILog getLog() { + if (log == null) { + log = Activator.getDefault().getLog(); + } + return log; + } + + /* + * Prints stack trace to Eclipse error log + */ + public static void log(int severity, Throwable e) { + Status s = new Status(severity, PLUGIN_ID, IStatus.OK, e.getMessage(), e); + getLog().log(s); + } + + /* + * Prints a message to the Eclipse error log + */ + public static void log(int severity, String msg) { + Status s = new Status(severity, PLUGIN_ID, IStatus.OK, msg, null); + getLog().log(s); + } + +} diff --git a/src/org/container/directory/Messages.java b/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/Messages.java similarity index 100% rename from src/org/container/directory/Messages.java rename to SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/Messages.java diff --git a/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/SimpleDirContainer.java b/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/SimpleDirContainer.java new file mode 100755 index 0000000..c396875 --- /dev/null +++ b/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/SimpleDirContainer.java @@ -0,0 +1,467 @@ +package org.container.directory; + +import java.io.File; +import java.io.FilenameFilter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.jdt.core.ClasspathContainerInitializer; +import org.eclipse.jdt.core.IClasspathAttribute; +import org.eclipse.jdt.core.IClasspathContainer; +import org.eclipse.jdt.core.IClasspathEntry; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.internal.core.ClasspathAttribute; +import org.eclipse.jdt.internal.core.ClasspathEntry; + +/** + * * This classpath container add archive files from a configured project + * directory to the classpath as CPE_LIBRARY entries, and it attaches -src + * archives as source attachments. + * + * @author Aaron J Tarter + * @author benjchristensen (modified handling of filenames with multiple .'s in + * them) + * @author Darko Palic + */ +public class SimpleDirContainer implements IClasspathContainer { + public final static Path ID = new Path("org.container.directory.SIMPLE_DIR_CONTAINER"); + // use this string to represent the root project directory + public final static String ROOT_DIR = "-"; + + // user-fiendly name for the container that shows on the UI + private String _desc; + + // Project of this path + private IJavaProject _project; + // path string that uniquiely identifies this container instance + private IPath _path; + // directory that will hold files for inclusion in this container + private File _dir; + // Filename extensions to include in container + private HashSet _exts; + + private IClasspathEntry[] classpathEntries; + + private Status currentStatus = Status.Initializing; + + /** + * Define the current status of this instance. + * + * @author Darko Palic + */ + private enum Status { + Initializing, InUse, RequestedContainerUpdate + } + + /** + * This filename filter will be used to determine which files will be + * included in the container + */ + private FilenameFilter _dirFilter = new FilenameFilter() { + + /** + * This File filter is used to filter files that are not in the configured + * extension set. Also, filters out files that have the correct extension + * but end in -src, since filenames with this pattern will be attached as + * source. + * + * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String) + */ + public boolean accept(File dir, String name) { + // if there is no dot then we don't have an extension and we'll skip + // this + if (name.lastIndexOf('.') == -1) { + return false; + } + + String ext = name.substring(name.lastIndexOf('.') + 1, name.length()).toLowerCase(); + String prefix = name.substring(0, name.lastIndexOf('.')); + + // lets avoid including filnames that end with -src since + // we will use this as the convention for attaching source + if (prefix.endsWith("-src")) { + return false; + } + // Darko TODO: handling of dir container extension must be improved at + // all. Just a hack for the previous code + if (_exts == null) { + // Logger.log(Logger.WARNING, + // "Directory Container could not read the extensions from .classpath for: " + // + dir.toString() + // + " of name " + name); + return true; + } else { + if (_exts.contains(ext)) { + return true; + } + } + + return false; + } + }; + + /** + * This constructor uses the provided IPath and IJavaProject arguments to + * assign the instance variables that are used for determining the classpath + * entries included in this container. The provided IPath comes from the + * classpath entry element in project's .classpath file. It is a three + * segment path with the following segments: [0] - Unique container ID [1] - + * project relative directory that this container will collect files from [2] + * - comma separated list of extensions to include in this container + * (extensions do not include the preceding ".") + * + * @param containerPath + * unique path for this container instance, including directory and + * extensions a segments + * @param project + * the Java project that is referencing this container + */ + public SimpleDirContainer(final IPath containerPath, IJavaProject project) { + _path = containerPath; + _project = project; + + // // extract the extension types for this container from the path + // String extString = path.lastSegment(); + // _exts = new HashSet(); + // String[] extArray = extString.split(","); + // for (String ext : extArray) { + // _exts.add(ext.toLowerCase()); + // } + + File classPathFolder = getClasspathDirectory(containerPath, project); + _dir = classPathFolder; + + // Create UI String for this container that reflects the directory being + // used + _desc = createDescription(containerPath, project); + + classpathEntries = resolveLibsFromDir(_dir); + + currentStatus = Status.InUse; + } + + /** + * extract the directory string from the PATH and create the directory + * relative to the project. + * + * @param containerPath + * the full path of the container + * @param project + * the container project + * @return the file reference to the dir + */ + private File getClasspathDirectory(final IPath containerPath, IJavaProject project) { + IPath libsPath = createDescriptionPath(containerPath, project); + File rootProj = project.getProject().getLocation().makeAbsolute().toFile(); + // remove indicator path of project + IPath relativePath = libsPath.removeFirstSegments(1); + File classPathFolder = new File(rootProj, relativePath.toString()); + if (!classPathFolder.exists()) { + Logger.log(Logger.WARNING, + "Folder of Directory Container missing: " + libsPath.toString() + " of project " + project.getElementName() + + " creating it now to avoid errors in eclipse"); + + classPathFolder.mkdirs(); + } + return classPathFolder; + } + + /** + * This method is used to determine if the directory specified in the + * container path is valid, i.e. it exists relative to the project and it is + * a directory. + * + * @return true if the configured directory is valid + */ + public boolean isValid() { + if (_dir.exists() && _dir.isDirectory()) { + return true; + } + return false; + } + + /** + * Returns a set of CPE_LIBRARY entries from the configured project directory + * that conform to the configured set of file extensions and attaches a + * source archive to the libraries entries if a file with same name ending + * with -src is found in the directory. + * + * @see org.eclipse.jdt.core.IClasspathContainer#getClasspathEntries() + */ + public IClasspathEntry[] getClasspathEntries() { + if (isClasspathChanged() && (currentStatus != Status.RequestedContainerUpdate)) { + try { + // okay fine, we have an change in the classpath, so request an update to eclipse + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IProject project = root.getProject(_project.getElementName()); + IJavaProject javaProject = JavaCore.create(project); + + // a very nice info, which is completly missing in the eclipse docs. + // http://stackoverflow.com/questions/12806888/refreshing-classpath-container-name-in-eclipse + // means this class may never change, so we will update the container and + // set a new one. + // The container must be immutable, so we have to request a update + ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(ID.toString()); + initializer.requestClasspathContainerUpdate(_path, _project, new SimpleDirContainer(_path, javaProject)); + + currentStatus = Status.RequestedContainerUpdate; + } catch (CoreException e) { + Logger.log(Logger.ERROR, "getClasspathEntries - ERROR: " + e.getMessage()); + } + } + + return classpathEntries; + } + + /** + * TODO: this is a evil hack, should be refactored properly to do only small steps. + * + * @param classpathDirectory the directory of the given classpath folder in eclipse. + * @return the array of the classpath entries in the given folder + */ + private IClasspathEntry[] resolveLibsFromDir(File classpathDirectory) { + ArrayList entryList = new ArrayList(); + // fetch the names of all files that match our filter + + File resolvedDir = classpathDirectory; + if (resolvedDir.isDirectory()) { + + // get the files and sort the files to be in correct lexical order in eclipse classpath later + File[] libs = resolvedDir.listFiles(_dirFilter); + Arrays.sort(libs); + + try { + for (File lib : libs) { + // strip off the file extension + String[] splittedName = lib.getName().split("[.]"); + String ext = splittedName[splittedName.length - 1]; + + // TODO: this is really a awful check against sources + // now see if this archive has an associated src jar + File srcArc = new File(lib.getAbsolutePath().replace("." + ext, "-src." + ext)); + Path srcPath = null; + // if the source archive exists then get the path to attach it + if (srcArc.exists()) { + srcPath = new Path(srcArc.getAbsolutePath()); + } + // create a new CPE_LIBRARY type of cp entry with an attached + // source + // archive if it exists + + IClasspathEntry entry = JavaCore.newLibraryEntry(new Path(lib.getAbsolutePath()), srcPath, new Path("/")); + entryList.add(entry); + } + } catch (Exception e) { + e.printStackTrace(); + Logger.log(Logger.ERROR, "getClasspathEntries - ERROR: " + e.getMessage()); + } + } + + + // convert the list to an array and return it + IClasspathEntry[] entryArray = new IClasspathEntry[entryList.size()]; + + return (IClasspathEntry[]) entryList.toArray(entryArray); + } + + private boolean isClasspathChanged() { + boolean result = false; + + List current = Arrays.asList(classpathEntries); + IClasspathEntry[] newlyResolved = resolveLibsFromDir(_dir); + List difference = new ArrayList(); + difference.addAll(current); + difference.removeAll(Arrays.asList(newlyResolved)); + + if (newlyResolved.length != classpathEntries.length) { + // okay trivial test + result = true; + } else if (difference.size() > 0) { + // maybe same mount of references reside, but the libs have changed (e.g. filename, version, ...) + result = true; + } + return result; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jdt.core.IClasspathContainer#getDescription() + */ + public String getDescription() { + return _desc; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jdt.core.IClasspathContainer#getKind() + */ + public int getKind() { + return IClasspathContainer.K_APPLICATION; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jdt.core.IClasspathContainer#getPath() + */ + public IPath getPath() { + return _path; + } + + /* + * @return configured directory for this container + */ + public File getDir() { + return _dir; + } + + /* + * @return whether or not this container would include the file + */ + public boolean isFileExtensionContained(File file) { + if (file.getParentFile().equals(_dir)) { + // peel off file extension + String fExt = file.toString().substring(file.toString().lastIndexOf('.') + 1); + // check is it is in the set of cofigured extensions + if ((_exts != null) && (_exts.contains(fExt.toLowerCase()))) { + return true; + } + } + return false; + } + + /** + * Get the full path of the the given path and project. + * + * @param path + * the path + * @param project + * the java project + * @return the full path to this classpathContainer + */ + public static String getFullPath(IPath path, IJavaProject project) { + String result; + + String projDir = project.getProject().getLocation().toString(); + + if (path != null && !path.makeRelativeTo(SimpleDirContainer.ID).isEmpty()) { + result = projDir + IPath.SEPARATOR + path.makeRelativeTo(SimpleDirContainer.ID); + } else { + result = projDir; + } + + return result; + + } + + public static IClasspathEntry getClasspathEntry(IJavaProject project, String projectRelativeLibFolder, String fileExtensions) { + String dir = projectRelativeLibFolder; + if (dir.equals("")) { + dir = SimpleDirContainer.ROOT_DIR; + } + IPath containerPath = SimpleDirContainer.ID.append("/" + project.getElementName() + "/" + dir); + + Set attrList = new HashSet(); + attrList.addAll(Arrays.asList(ClasspathEntry.NO_EXTRA_ATTRIBUTES)); + ClasspathAttribute extensions = new ClasspathAttribute(ClasspathExtraAttribute.FILE_EXTENSTIONS.getValue(), fileExtensions); + attrList.add(extensions); + IClasspathAttribute[] attributes = new IClasspathAttribute[attrList.size()]; + attrList.toArray(attributes); + + IClasspathEntry entry = JavaCore.newContainerEntry(containerPath, ClasspathEntry.NO_ACCESS_RULES, attributes, false); + + return entry; + } + + public static String getExtraAttributeValue(SimpleDirContainer simpleDirContainer, ClasspathExtraAttribute attribute) { + String result = null; + if (simpleDirContainer.getClasspathEntries().length > 0) { + for (IClasspathAttribute attr : simpleDirContainer.getClasspathEntries()[0].getExtraAttributes()) { + if (attr.getName().equalsIgnoreCase(attribute.getValue())) { + result = attr.getValue(); + } + } + } + return result; + } + + /** + * Lookup in eclipse project settings the corresponding ClasspathContainer. + * + * @param containerPath + * the containerpath of SimpleDirContainer + * @param project + * the project there the container is registered + * @return null or the found container + */ + public static SimpleDirContainer lookupExistingContainer(IPath containerPath, IJavaProject project) { + SimpleDirContainer result = null; + + try { + IClasspathContainer storedContainer = JavaCore.getClasspathContainer(containerPath, project); + + if (storedContainer != null) { + IPath pluginID = storedContainer.getPath().removeLastSegments(storedContainer.getPath().segmentCount() - 1); + String storedPath = storedContainer.getPath().toString(); + // IPath prj = containerPath.removeFirstSegments(1); + // prj = prj.removeLastSegments(prj.segmentCount() - 1); + // String storedProjectName = prj.toString(); + + if (storedContainer instanceof SimpleDirContainer) { + result = (SimpleDirContainer) storedContainer; + } else if ((storedContainer instanceof IClasspathContainer) && (pluginID.equals(ID)) && + // Darko TODO: fix this really awful hack + (storedContainer.getClass().getSimpleName().equals("PersistedClasspathContainer"))) { + result = new SimpleDirContainer(storedContainer.getPath(), project); + } else { + Logger.log(Logger.ERROR, "Classpath container " + SimpleDirContainer.class.getSimpleName() + " lookup failed: " + + containerPath.toString() + " of project " + project.getElementName() + + " found a corresponding path-value to SimpleDirContainer but not a instance of it"); + } + } + } catch (JavaModelException modelEx) { + Logger.log(Logger.ERROR, + "Classpath container " + SimpleDirContainer.class.getSimpleName() + " lookup failed: " + containerPath.toString() + + " of project " + project.getElementName()); + } + + return result; + } + + private static IPath createDescriptionPath(IPath containerPath, IJavaProject project) { + IPath result = containerPath.removeFirstSegments(1); + if (result.segmentCount() == 1 && result.segment(0).equals(ROOT_DIR)) { + result = result.removeFirstSegments(1); + } + return result; + } + + public static String createDescription(IPath containerPath, IJavaProject project) { + String result = null; + + result = "Directory Classpath: /" + createDescriptionPath(containerPath, project); + + return result; + } + + @Override + public String toString() { + return "SimpleDirContainer [_desc=" + _desc + ", _project=" + _project + ", _path=" + _path + ", _dir=" + _dir + ", _exts=" + _exts + + ", _dirFilter=" + _dirFilter + "]"; + } + +} diff --git a/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/SimpleDirContainerInitializer.java b/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/SimpleDirContainerInitializer.java new file mode 100755 index 0000000..2e2e1aa --- /dev/null +++ b/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/SimpleDirContainerInitializer.java @@ -0,0 +1,110 @@ +package org.container.directory; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.jdt.core.ClasspathContainerInitializer; +import org.eclipse.jdt.core.IClasspathContainer; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.JavaCore; + +/** + * This classpath container initializer constructs a SimpleDirContainer with the + * give container path and Java project. It then validates the container before + * setting it in the classpath. If the container is invalid, it fails silently + * and logs an error to the Eclipse error log. + * + * @author Aaron J Tarter + */ +public class SimpleDirContainerInitializer extends ClasspathContainerInitializer { + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jdt.core.ClasspathContainerInitializer#initialize(org.eclipse + * .core.runtime.IPath, org.eclipse.jdt.core.IJavaProject) + */ + @Override + public void initialize(IPath containerPath, IJavaProject project) throws CoreException { + SimpleDirContainer container = null; + // Darko TODO: unsure about this code to read from storage, since the lifecycle of the containers is not clear defined. +// if (project.isOpen()) { +// container = SimpleDirContainer.lookupExistingContainer(containerPath, project); +// } + + if (container == null) { + container = new SimpleDirContainer(containerPath, project); + if (container.isValid()) { + JavaCore.setClasspathContainer(containerPath, new IJavaProject[] { project }, new IClasspathContainer[] { container }, null); + } else { + Logger.log(Logger.WARNING, Messages.InvalidContainer + containerPath); + } + } + + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jdt.core.ClasspathContainerInitializer#canUpdateClasspathContainer + * (org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject) + */ + @Override + public boolean canUpdateClasspathContainer(IPath containerPath, IJavaProject project) { + return true; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jdt.core.ClasspathContainerInitializer# + * requestClasspathContainerUpdate(org.eclipse.core.runtime.IPath, + * org.eclipse.jdt.core.IJavaProject, + * org.eclipse.jdt.core.IClasspathContainer) + */ + @Override + public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) + throws CoreException { + JavaCore + .setClasspathContainer(containerPath, new IJavaProject[] { project }, new IClasspathContainer[] { containerSuggestion }, null); + } + + @Override + public Object getComparisonID(IPath containerPath, IJavaProject project) { + IPath result = containerPath; + // result = project.getElementName() + "/" + containerPath.toString(); + return result; + } + + @Override + public IStatus getAccessRulesStatus(IPath containerPath, IJavaProject project) { + // TODO Auto-generated method stub + return super.getAccessRulesStatus(containerPath, project); + } + + @Override + public String getDescription(IPath containerPath, IJavaProject project) { + return SimpleDirContainer.createDescription(containerPath, project); + } + + @Override + public IStatus getAttributeStatus(IPath containerPath, IJavaProject project, String attributeKey) { + // TODO Auto-generated method stub + return super.getAttributeStatus(containerPath, project, attributeKey); + } + + @Override + public IStatus getSourceAttachmentStatus(IPath containerPath, IJavaProject project) { + // TODO Auto-generated method stub + return super.getSourceAttachmentStatus(containerPath, project); + } + + @Override + public IClasspathContainer getFailureContainer(IPath containerPath, IJavaProject project) { + // TODO Auto-generated method stub + return super.getFailureContainer(containerPath, project); + } + +} diff --git a/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/SimpleDirContainerPage.java b/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/SimpleDirContainerPage.java new file mode 100755 index 0000000..a544e7e --- /dev/null +++ b/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/SimpleDirContainerPage.java @@ -0,0 +1,280 @@ +package org.container.directory; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.jdt.core.IClasspathEntry; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.ui.wizards.IClasspathContainerPage; +import org.eclipse.jdt.ui.wizards.IClasspathContainerPageExtension; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.osgi.util.NLS; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +/** + * This classpath container page colects the directory and the file extensions + * for a new or existing SimpleDirContainer. + * + * @author Aaron J Tarter + */ +public class SimpleDirContainerPage extends WizardPage implements IClasspathContainerPage, IClasspathContainerPageExtension { + + private final static String DEFAULT_EXTS = "jar,zip"; + + private IJavaProject _proj; + private IClasspathEntry[] _classpathEntries; + + private Combo _dirCombo; + private Button _dirBrowseButton; + private Text _extText; + private IPath _initPath = null; + private Composite composite; + + /** + * Default Constructor - sets title, page name, description + */ + public SimpleDirContainerPage() { + super(Messages.PageName, Messages.PageTitle, null); + setDescription(Messages.PageDesc); + setPageComplete(true); + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jdt.ui.wizards.IClasspathContainerPageExtension#initialize + * (org.eclipse.jdt.core.IJavaProject, + * org.eclipse.jdt.core.IClasspathEntry[]) + */ + public void initialize(IJavaProject project, IClasspathEntry[] currentEntries) { + _proj = project; + _classpathEntries = currentEntries; + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets + * .Composite) + */ + public void createControl(Composite parent) { + composite = new Composite(parent, SWT.NULL); + GridLayout gl_composite = new GridLayout(); + gl_composite.numColumns = 4; + composite.setLayout(gl_composite); + composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL)); + composite.setFont(parent.getFont()); + + createDirGroup(composite); + + createExtGroup(composite); + + setControl(composite); + + Label label = new Label(composite, SWT.NONE); + label.setText(Messages.DirLabel); + + _dirCombo = new Combo(composite, SWT.SINGLE | SWT.BORDER); + GridData gd__dirCombo = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1); + gd__dirCombo.widthHint = 307; + _dirCombo.setLayoutData(gd__dirCombo); + _dirCombo.setText(getInitDir()); + + _dirBrowseButton = new Button(composite, SWT.PUSH); + _dirBrowseButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); + _dirBrowseButton.setText(Messages.Browse); + _dirBrowseButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + handleDirBrowseButtonPressed(); + } + }); + + Label label_1 = new Label(composite, SWT.NONE); + label_1.setText(Messages.ExtLabel); + + _extText = new Text(composite, SWT.BORDER); + _extText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); + _extText.setText(getInitExts()); + new Label(composite, SWT.NONE); + new Label(composite, SWT.NONE); + } + + /** + * Creates the directory label, combo, and browse button + * + * @param parent + * the parent widget + */ + private void createDirGroup(Composite parent) { + } + + /** + * Creates the extensions label and text box + * + * @param parent + * parent widget + */ + private void createExtGroup(Composite parent) { + } + + /** + * Creates a directory dialog + */ + protected void handleDirBrowseButtonPressed() { + DirectoryDialog dialog = new DirectoryDialog(getContainer().getShell(), SWT.SAVE); + dialog.setMessage(Messages.DirSelect); + dialog.setFilterPath(getLibDirectoryValue()); + String dir = dialog.open(); + if (dir != null) { + _dirCombo.setText(dir); + } + } + + /** + * Extracts the initial directory value from a path passed in setSelection() + * + * @return the inital directory value + */ + private String getInitDir() { + String result; + + result = SimpleDirContainer.getFullPath(_initPath, _proj); + + return result; + } + + /** + * Extracts the initial extensions list from a path passed in setSelection() + * + * @return the intial comma separated list of extensions + */ + private String getInitExts() { + String result = null; + + IPath defaultPath; + if (_initPath == null) { + // we have no entry and we are creating now a new one, so provide a default initPath + defaultPath = _proj.getPath(); + } else { + defaultPath = _initPath; + } + + SimpleDirContainer found = SimpleDirContainer.lookupExistingContainer(defaultPath, _proj); + if (found == null) { + result = DEFAULT_EXTS; + } else { + String exts = SimpleDirContainer.getExtraAttributeValue(found, ClasspathExtraAttribute.FILE_EXTENSTIONS); + if (exts == null) { + result = DEFAULT_EXTS; + } else { + result = exts; + } + } + + return result; + } + + /** + * @return the current extension list + */ + protected String getExtensionValue() { + return _extText.getText().trim(); + } + + /** + * @return the current directory + */ + protected String getLibDirectoryValue() { + return _dirCombo.getText(); + } + + /** + * @return directory relative to the parent project + */ + protected String getRelativeDirValue() { + int projDirLen = _proj.getProject().getLocation().toString().length(); + return getLibDirectoryValue().substring(projDirLen); + } + + /** + * Checks that the directory is a subdirectory of the project being + * configured + * + * @param dir + * a directory to validate + * @return true if the directory is valid + */ + private boolean isDirValid(String dir) { + Path dirPath = new Path(dir); + return _proj.getProject().getLocation().makeAbsolute().isPrefixOf(dirPath); + } + + /** + * Checks that the list of comma separated extensions are valid. Must meet + * the following: - non-null and non-empty - match the regex [a-z_][a-z_,]* + * + * @param exts + * comma separated list of extensions + * @return true if the extension list is valid + */ + private boolean areExtsValid(String exts) { + if (exts == null || exts.equals("")) { + return false; + } + // else + return exts.matches("[a-z_][a-z_,]*"); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jdt.ui.wizards.IClasspathContainerPage#finish() + */ + public boolean finish() { + if (!areExtsValid(getExtensionValue())) { + setErrorMessage(Messages.ExtErr); + return false; + } else if (!isDirValid(getLibDirectoryValue())) { + setErrorMessage(NLS.bind(Messages.DirErr, _proj.getProject().getName())); + return false; + } + return true; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.jdt.ui.wizards.IClasspathContainerPage#getSelection() + */ + public IClasspathEntry getSelection() { + String dir = getRelativeDirValue(); + + IClasspathEntry entry = SimpleDirContainer.getClasspathEntry(_proj, dir, getExtensionValue()); + + return entry; + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jdt.ui.wizards.IClasspathContainerPage#setSelection(org.eclipse + * .jdt.core.IClasspathEntry) + */ + public void setSelection(IClasspathEntry containerEntry) { + if (containerEntry != null) { + _initPath = containerEntry.getPath(); + } + } +} diff --git a/src/org/container/directory/messages.properties b/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/messages.properties similarity index 66% rename from src/org/container/directory/messages.properties rename to SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/messages.properties index 48d5e95..c04d73c 100755 --- a/src/org/container/directory/messages.properties +++ b/SimpleDirectoryContainer_EclipsePlugin/src/org/container/directory/messages.properties @@ -1,11 +1,13 @@ -Browse=Browse... -DirErr=The directory must be a subdirectory of the project {0} -DirLabel=Directory: -DirSelect=Select the directory for the Directory Container -ExtErr=Extensions are not valid. Verify that the extensions are comma separated and do not include the preceding '.' -ExtLabel=Extensions (comma separated, not including .): -InvalidContainer=Invalid container: -PageDesc=A classpath container that collects files with configured extensions from a configured directory -PageName=Directory Container Wizard -PageTitle=Directory Container -ContainerName = Directory Container +#Eclipse modern messages class +#Sat Sep 20 12:25:24 CEST 2014 +Browse=Browse... +ContainerName=Directory Container +DirErr=The directory must be a subdirectory of the project {0} +DirLabel=Directory\: +DirSelect=Select the directory for the Directory Container +ExtErr=Extensions are not valid. Verify that the extensions are comma separated and do not include the preceding '.' +ExtLabel=Extensions (comma separated, not including .)\: +InvalidContainer=Invalid container\: +PageDesc=A classpath container that collects files with configured extensions from a configured directory +PageName=Directory Container Wizard +PageTitle=Directory Container diff --git a/SimpleDirectoryContainer_EclipseUpdateSite/.project b/SimpleDirectoryContainer_EclipseUpdateSite/.project new file mode 100644 index 0000000..9523eb5 --- /dev/null +++ b/SimpleDirectoryContainer_EclipseUpdateSite/.project @@ -0,0 +1,17 @@ + + + SimpleDirectoryContainer_EclipseUpdateSite + + + + + + org.eclipse.pde.UpdateSiteBuilder + + + + + + org.eclipse.pde.UpdateSiteNature + + diff --git a/SimpleDirectoryContainer_EclipseUpdateSite/README b/SimpleDirectoryContainer_EclipseUpdateSite/README new file mode 100644 index 0000000..c41dd70 --- /dev/null +++ b/SimpleDirectoryContainer_EclipseUpdateSite/README @@ -0,0 +1,34 @@ +This is an Eclipse plugin that allows creating a dynamic Classpath Container that observes a folder +and loads all .jar (or .zip etc) files into the classpath. This plugin is helpful to use a bunch of jar files in one folder as your classpath, without setting it manually. +We use it to get rid of the buggy IvyDE plugin for our IVY dependency management. + +It is an evolution of original code I got from here: + https://www.ibm.com/developerworks/opensource/tutorials/os-eclipse-classpath/ +Thus it originates from Aaron Tarter (aarontar@us.ibm.com). + +The primary modification Ben Christensen made (besides renaming things to no longer say 'example') was making it handle +filenames that had multiple dots (such as com.company.library.name.v2.jar). + +The improvements I made (Darko Palic) are to allow multiple directory containers in the classpaths and of course therefore in the eclipse launches. +The previous version had bigger issues about it. + +The binary in downloads on GitHub just needs to be dropped into the eclipse /plugins/ folder and it will +then allow adding a "Directory Container" library to the Java Build Path. + +You can find the latest verion here: +https://github.com/dpalic/SimpleDirectoryContainer_EclipsePlugin/tree/master/ExportedPlugin + +or directly (but maybe outdated): +https://github.com/dpalic/SimpleDirectoryContainer_EclipsePlugin/raw/master/ExportedPlugin/DirectoryClasspathContainer_1.1.2.jar + +I created this jar by exporting a "Deployable plug-ins and fragments" from Eclipse at the project level. + +############### +# INSTALLATION +############### +1. Download the latest jar file (see above) +2. stop your eclipse (ensure it is really stopped in taskmanager) +3. put the downloaded jar file into your eclipse\plugin folder +4. restart your eclipse +5. in Eclipse go to you Java Build Path settings and go to the tab Libraries +6. "Add Library..." will provide you now a new entry "Directory container" diff --git a/SimpleDirectoryContainer_EclipseUpdateSite/artifacts.jar b/SimpleDirectoryContainer_EclipseUpdateSite/artifacts.jar new file mode 100644 index 0000000..8946b47 Binary files /dev/null and b/SimpleDirectoryContainer_EclipseUpdateSite/artifacts.jar differ diff --git a/SimpleDirectoryContainer_EclipseUpdateSite/content.jar b/SimpleDirectoryContainer_EclipseUpdateSite/content.jar new file mode 100644 index 0000000..b427170 Binary files /dev/null and b/SimpleDirectoryContainer_EclipseUpdateSite/content.jar differ diff --git a/SimpleDirectoryContainer_EclipseUpdateSite/features/SimpleDirectoryContainer_EclipseFeature_1.0.0.201501211826.jar b/SimpleDirectoryContainer_EclipseUpdateSite/features/SimpleDirectoryContainer_EclipseFeature_1.0.0.201501211826.jar new file mode 100644 index 0000000..6dbac9c Binary files /dev/null and b/SimpleDirectoryContainer_EclipseUpdateSite/features/SimpleDirectoryContainer_EclipseFeature_1.0.0.201501211826.jar differ diff --git a/SimpleDirectoryContainer_EclipseUpdateSite/plugins/DirectoryClasspathContainer_1.1.3.jar b/SimpleDirectoryContainer_EclipseUpdateSite/plugins/DirectoryClasspathContainer_1.1.3.jar new file mode 100644 index 0000000..8b8ab5a Binary files /dev/null and b/SimpleDirectoryContainer_EclipseUpdateSite/plugins/DirectoryClasspathContainer_1.1.3.jar differ diff --git a/SimpleDirectoryContainer_EclipseUpdateSite/site.xml b/SimpleDirectoryContainer_EclipseUpdateSite/site.xml new file mode 100644 index 0000000..c5dea6f --- /dev/null +++ b/SimpleDirectoryContainer_EclipseUpdateSite/site.xml @@ -0,0 +1,4 @@ + + + + diff --git a/src/org/container/directory/ContainerDirFilter.java b/src/org/container/directory/ContainerDirFilter.java deleted file mode 100755 index dff6fa2..0000000 --- a/src/org/container/directory/ContainerDirFilter.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.container.directory; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; - -/** - * This element filter filters files from the Java Package View if they are included in a - * SimpleDirContainer that is on the parent Java project's classpath. This will prevent - * the user from right-clicking hte file and adding it to the build path as a CPE_LIBRARY - * classpath entry and thus prevent duplication on the classpath. - * - * @author Aaron J Tarter - */ -public class ContainerDirFilter extends ViewerFilter { - - /* - * @ return false if the Java element is a file that is contained in a - * SimpleDirContainer that is in the classpath of the owning Java project - * (non-Javadoc) - * @see org.eclipse.jface.viewers.ViewerFilter#select( - * org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ - @Override - public boolean select(Viewer viewer, Object parentElement, Object element) { - if(element instanceof IFile) { - IFile f = (IFile)element; - IJavaProject jp = JavaCore.create(f.getProject()); - try { - // lets see if this file is included in a SimpleDirContainer - IClasspathEntry[] entries = jp.getRawClasspath(); - for(IClasspathEntry entry: entries) { - if(entry.getEntryKind()==IClasspathEntry.CPE_CONTAINER) { - if(SimpleDirContainer.ID.isPrefixOf(entry.getPath())) { - // we know this is a SimpleDirContainer so lets get the - // instance - SimpleDirContainer con = (SimpleDirContainer)JavaCore. - getClasspathContainer(entry.getPath(), jp); - if(con.isContained(f.getLocation().toFile())){ - // this file will is included in the container, so dont - // show it - return false; - } - } - } - } - } catch(JavaModelException e) { - Logger.log(Logger.ERROR, e); - } - } - return true; - } - -} diff --git a/src/org/container/directory/Logger.java b/src/org/container/directory/Logger.java deleted file mode 100755 index 16816b3..0000000 --- a/src/org/container/directory/Logger.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.container.directory; - -import org.eclipse.core.runtime.ILog; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; - -/** - * This is a simple logger that logs messages and stack traces to the Eclipse error log. - * - * @author Aaron J Tarter - */ -public class Logger { - public final static String PLUGIN_ID = "org.container.directory"; - // logging severities - public static final int OK = IStatus.OK; - public static final int ERROR = IStatus.ERROR; - public static final int CANCEL = IStatus.CANCEL; - public static final int INFO = IStatus.INFO; - public static final int WARNING = IStatus.WARNING; - // reference to the Eclipse error log - private static ILog log; - - /* - * Get a reference to the Eclipse error log - */ - static { - log = Platform.getLog(Platform.getBundle(PLUGIN_ID)); - } - - /* - * Prints stack trace to Eclipse error log - */ - public static void log(int severity, Throwable e) { - Status s = new Status(severity, PLUGIN_ID, IStatus.OK, e.getMessage(), e); - log.log(s); - } - - /* - * Prints a message to the Eclipse error log - */ - public static void log(int severity, String msg) { - Status s = new Status(severity, PLUGIN_ID, IStatus.OK, msg, null); - log.log(s); - } - -} diff --git a/src/org/container/directory/SimpleDirContainer.java b/src/org/container/directory/SimpleDirContainer.java deleted file mode 100755 index 7293561..0000000 --- a/src/org/container/directory/SimpleDirContainer.java +++ /dev/null @@ -1,224 +0,0 @@ -package org.container.directory; - -import java.io.File; -import java.io.FilenameFilter; -import java.util.ArrayList; -import java.util.HashSet; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IClasspathContainer; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; - -/** - * * This classpath container add archive files from a configured project - * directory to the classpath as CPE_LIBRARY entries, and it attaches -src - * archives as source attachments. - * - * @author Aaron J Tarter - * @author benjchristensen (modified handling of filenames with multiple .'s in them) - */ -public class SimpleDirContainer implements IClasspathContainer { - public final static Path ID = new Path( - "org.container.directory.SIMPLE_DIR_CONTAINER"); - // use this string to represent the root project directory - public final static String ROOT_DIR = "-"; - - // user-fiendly name for the container that shows on the UI - private String _desc; - // path string that uniquiely identifies this container instance - private IPath _path; - // directory that will hold files for inclusion in this container - private File _dir; - // Filename extensions to include in container - private HashSet _exts; - - /** - * This filename filter will be used to determine which files will be - * included in the container - */ - private FilenameFilter _dirFilter = new FilenameFilter() { - - /** - * This File filter is used to filter files that are not in the - * configured extension set. Also, filters out files that have the - * correct extension but end in -src, since filenames with this pattern - * will be attached as source. - * - * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String) - */ - public boolean accept(File dir, String name) { - // if there is no dot then we don't have an extension and we'll skip this - if (name.lastIndexOf('.') == -1) { - return false; - } - - String ext = name.substring(name.lastIndexOf('.') + 1, name.length()).toLowerCase(); - String prefix = name.substring(0, name.lastIndexOf('.')); - - // lets avoid including filnames that end with -src since - // we will use this as the convention for attaching source - if (prefix.endsWith("-src")) { - return false; - } - if (_exts.contains(ext)) { - return true; - } - - return false; - } - }; - - /** - * This constructor uses the provided IPath and IJavaProject arguments to - * assign the instance variables that are used for determining the classpath - * entries included in this container. The provided IPath comes from the - * classpath entry element in project's .classpath file. It is a three - * segment path with the following segments: [0] - Unique container ID [1] - - * project relative directory that this container will collect files from - * [2] - comma separated list of extensions to include in this container - * (extensions do not include the preceding ".") - * - * @param path - * unique path for this container instance, including directory - * and extensions a segments - * @param project - * the Java project that is referencing this container - */ - public SimpleDirContainer(IPath path, IJavaProject project) { - _path = path; - - // extract the extension types for this container from the path - String extString = path.lastSegment(); - _exts = new HashSet(); - String[] extArray = extString.split(","); - for (String ext : extArray) { - _exts.add(ext.toLowerCase()); - } - // extract the directory string from the PATH and create the directory - // relative - // to the project - path = path.removeLastSegments(1).removeFirstSegments(1); - File rootProj = project.getProject().getLocation().makeAbsolute().toFile(); - if (path.segmentCount() == 1 && path.segment(0).equals(ROOT_DIR)) { - _dir = rootProj; - path = path.removeFirstSegments(1); - } else { - _dir = new File(rootProj, path.toString()); - } - - // Create UI String for this container that reflects the directory being used - _desc = "Directory Classpath: /" + path; - - } - - /** - * This method is used to determine if the directory specified in the - * container path is valid, i.e. it exists relative to the project and it is - * a directory. - * - * @return true if the configured directory is valid - */ - public boolean isValid() { - if (_dir.exists() && _dir.isDirectory()) { - return true; - } - return false; - } - - /** - * Returns a set of CPE_LIBRARY entries from the configured project - * directory that conform to the configured set of file extensions and - * attaches a source archive to the libraries entries if a file with same - * name ending with -src is found in the directory. - * - * @see org.eclipse.jdt.core.IClasspathContainer#getClasspathEntries() - */ - public IClasspathEntry[] getClasspathEntries() { - ArrayList entryList = new ArrayList(); - // fetch the names of all files that match our filter - File[] libs = _dir.listFiles(_dirFilter); - - try { - for (File lib : libs) { - // strip off the file extension - String ext = lib.getName().split("[.]")[1]; - - // now see if this archive has an associated src jar - File srcArc = new File(lib.getAbsolutePath().replace("." + ext, "-src." + ext)); - Path srcPath = null; - // if the source archive exists then get the path to attach it - if (srcArc.exists()) { - srcPath = new Path(srcArc.getAbsolutePath()); - } - // create a new CPE_LIBRARY type of cp entry with an attached - // source - // archive if it exists - - entryList - .add(JavaCore.newLibraryEntry( - new Path(lib.getAbsolutePath()), srcPath, - new Path("/"))); - } - } catch (Exception e) { - e.printStackTrace(); - Logger.log(Logger.ERROR, "getClasspathEntries - ERROR: " + e.getMessage()); - } - // convert the list to an array and return it - IClasspathEntry[] entryArray = new IClasspathEntry[entryList.size()]; - - return (IClasspathEntry[]) entryList.toArray(entryArray); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jdt.core.IClasspathContainer#getDescription() - */ - public String getDescription() { - return _desc; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jdt.core.IClasspathContainer#getKind() - */ - public int getKind() { - return IClasspathContainer.K_APPLICATION; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jdt.core.IClasspathContainer#getPath() - */ - public IPath getPath() { - return _path; - } - - /* - * @return configured directory for this container - */ - public File getDir() { - return _dir; - } - - /* - * @return whether or not this container would include the file - */ - public boolean isContained(File file) { - if (file.getParentFile().equals(_dir)) { - // peel off file extension - String fExt = file.toString().substring( - file.toString().lastIndexOf('.') + 1); - // check is it is in the set of cofigured extensions - if (_exts.contains(fExt.toLowerCase())) { - return true; - } - } - return false; - } -} diff --git a/src/org/container/directory/SimpleDirContainerInitializer.java b/src/org/container/directory/SimpleDirContainerInitializer.java deleted file mode 100755 index f3f4bc6..0000000 --- a/src/org/container/directory/SimpleDirContainerInitializer.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.container.directory; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jdt.core.ClasspathContainerInitializer; -import org.eclipse.jdt.core.IClasspathContainer; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; - -/** - * This classpath container initializer constructs a SimpleDirContainer with the give - * container path and Java project. It then validates the container before setting - * it in the classpath. If the container is invalid, it fails silently and logs an - * error to the Eclipse error log. - * - * @author Aaron J Tarter - */ -public class SimpleDirContainerInitializer extends - ClasspathContainerInitializer { - - /* - * (non-Javadoc) - * - * @see org.eclipse.jdt.core.ClasspathContainerInitializer#initialize(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject) - */ - @Override - public void initialize(IPath containerPath, IJavaProject project) - throws CoreException { - SimpleDirContainer container = new SimpleDirContainer(containerPath, project); - if (container.isValid()) { - JavaCore.setClasspathContainer(containerPath, new IJavaProject[] { project }, new IClasspathContainer[] { container }, null); - } else { - Logger.log(Logger.WARNING, Messages.InvalidContainer + containerPath); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jdt.core.ClasspathContainerInitializer#canUpdateClasspathContainer(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject) - */ - @Override - public boolean canUpdateClasspathContainer(IPath containerPath, - IJavaProject project) { - return true; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jdt.core.ClasspathContainerInitializer#requestClasspathContainerUpdate(org.eclipse.core.runtime.IPath, org.eclipse.jdt.core.IJavaProject, org.eclipse.jdt.core.IClasspathContainer) - */ - @Override - public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion) throws CoreException { - JavaCore.setClasspathContainer(containerPath, new IJavaProject[] { project }, new IClasspathContainer[] { containerSuggestion }, null); - } - -} diff --git a/src/org/container/directory/SimpleDirContainerPage.java b/src/org/container/directory/SimpleDirContainerPage.java deleted file mode 100755 index a3928c6..0000000 --- a/src/org/container/directory/SimpleDirContainerPage.java +++ /dev/null @@ -1,249 +0,0 @@ -package org.container.directory; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.ui.wizards.IClasspathContainerPage; -import org.eclipse.jdt.ui.wizards.IClasspathContainerPageExtension; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.osgi.util.NLS; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.DirectoryDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -/** - * This classpath container page colects the directory and the file extensions for a new - * or existing SimpleDirContainer. - * - * @author Aaron J Tarter - */ -public class SimpleDirContainerPage extends WizardPage - implements IClasspathContainerPage, IClasspathContainerPageExtension { - - private final static String DEFAULT_EXTS = "jar,zip"; - - private IJavaProject _proj; - private Combo _dirCombo; - private Button _dirBrowseButton; - private Text _extText; - private IPath _initPath = null; - - /** - * Default Constructor - sets title, page name, description - */ - public SimpleDirContainerPage() { - super(Messages.PageName, Messages.PageTitle, null); - setDescription(Messages.PageDesc); - setPageComplete(true); - } - - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.wizards.IClasspathContainerPageExtension#initialize(org.eclipse.jdt.core.IJavaProject, org.eclipse.jdt.core.IClasspathEntry[]) - */ - public void initialize(IJavaProject project, IClasspathEntry[] currentEntries) { - _proj = project; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) - */ - public void createControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout()); - composite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_FILL - | GridData.HORIZONTAL_ALIGN_FILL)); - composite.setFont(parent.getFont()); - - createDirGroup(composite); - - createExtGroup(composite); - - setControl(composite); - } - - /** - * Creates the directory label, combo, and browse button - * - * @param parent the parent widget - */ - private void createDirGroup(Composite parent) { - Composite dirSelectionGroup = new Composite(parent, SWT.NONE); - GridLayout layout= new GridLayout(); - layout.numColumns = 3; - dirSelectionGroup.setLayout(layout); - dirSelectionGroup.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL| GridData.VERTICAL_ALIGN_FILL)); - - new Label(dirSelectionGroup, SWT.NONE).setText(Messages.DirLabel); - - _dirCombo = new Combo(dirSelectionGroup, SWT.SINGLE | SWT.BORDER); - _dirCombo.setText( getInitDir() ); - - _dirBrowseButton= new Button(dirSelectionGroup, SWT.PUSH); - _dirBrowseButton.setText( Messages.Browse ); - _dirBrowseButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); - _dirBrowseButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - handleDirBrowseButtonPressed(); - } - }); - setControl(dirSelectionGroup); - } - - /** - * Creates the extensions label and text box - * - * @param parent parent widget - */ - private void createExtGroup(Composite parent) { - Composite extSelectionGroup = new Composite(parent, SWT.NONE); - GridLayout layout= new GridLayout(); - layout.numColumns = 2; - extSelectionGroup.setLayout(layout); - extSelectionGroup.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL| GridData.VERTICAL_ALIGN_FILL)); - - new Label(extSelectionGroup, SWT.NONE).setText(Messages.ExtLabel); - - _extText = new Text(extSelectionGroup,SWT.BORDER); - _extText.setText(getInitExts()+" "); - - setControl(extSelectionGroup); - } - - /** - * Creates a directory dialog - */ - protected void handleDirBrowseButtonPressed() { - DirectoryDialog dialog = new DirectoryDialog(getContainer().getShell(), SWT.SAVE); - dialog.setMessage(Messages.DirSelect); - dialog.setFilterPath(getDirValue()); - String dir = dialog.open(); - if (dir != null) { - _dirCombo.setText(dir); - } - } - - /** - * Extracts the initial directory value from a path passed in setSelection() - * - * @return the inital directory value - */ - private String getInitDir() { - String projDir = _proj.getProject().getLocation().toString(); - if(_initPath != null && _initPath.segmentCount() > 1 ) { - return projDir + IPath.SEPARATOR + _initPath.segment(1); - } - // else - return projDir; - - } - - /** - * Extracts the initial extensions list from a path passed in setSelection() - * - * @return the intial comma separated list of extensions - */ - private String getInitExts() { - if(_initPath != null && _initPath.segmentCount() > 2 ) { - return _initPath.segment(2); - } - // else - return DEFAULT_EXTS; - } - - /** - * @return the current extension list - */ - protected String getExtValue() { - return _extText.getText().trim().toLowerCase(); - } - - /** - * @return the current directory - */ - protected String getDirValue() { - return _dirCombo.getText(); - } - - /** - * @return directory relative to the parent project - */ - protected String getRelativeDirValue() { - int projDirLen = _proj.getProject().getLocation().toString().length(); - return getDirValue().substring( projDirLen ); - } - - /** - * Checks that the directory is a subdirectory of the project being configured - * - * @param dir a directory to validate - * @return true if the directory is valid - */ - private boolean isDirValid(String dir) { - Path dirPath = new Path(dir); - return _proj.getProject().getLocation().makeAbsolute().isPrefixOf(dirPath); - } - - /** - * Checks that the list of comma separated extensions are valid. Must meet the - * following: - * - non-null and non-empty - * - match the regex [a-z_][a-z_,]* - * - * @param exts comma separated list of extensions - * @return true if the extension list is valid - */ - private boolean areExtsValid(String exts) { - if(exts==null || exts.equals("")) { - return false; - } - //else - return exts.matches("[a-z_][a-z_,]*"); - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.wizards.IClasspathContainerPage#finish() - */ - public boolean finish() { - if(!areExtsValid(getExtValue())) { - setErrorMessage(Messages.ExtErr); - return false; - } else if(!isDirValid(getDirValue())) { - setErrorMessage( NLS.bind(Messages.DirErr, _proj.getProject().getName())); - return false; - } - return true; - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.wizards.IClasspathContainerPage#getSelection() - */ - public IClasspathEntry getSelection() { - String dir = getRelativeDirValue(); - if(dir.equals("")) { - dir = SimpleDirContainer.ROOT_DIR; - } - IPath containerPath = SimpleDirContainer.ID.append( "/" + dir + "/" + - getExtValue()); - return JavaCore.newContainerEntry(containerPath); - } - - /* (non-Javadoc) - * @see org.eclipse.jdt.ui.wizards.IClasspathContainerPage#setSelection(org.eclipse.jdt.core.IClasspathEntry) - */ - public void setSelection(IClasspathEntry containerEntry) { - if(containerEntry != null) { - _initPath = containerEntry.getPath(); - } - } -}