From c704ba9bcf8ee71e47bb02eb9134ffde3f7fedcd Mon Sep 17 00:00:00 2001 From: Shobhan Mandal Date: Sun, 13 May 2018 19:19:24 +0530 Subject: [PATCH] A new Module is created for placing the codes for Python and a new nearly empty Python project is created under New Extension Wizard. --- .../internal/helpers/UnoidlProjectHelper.java | 14 +- .../core/wizards/NewUnoProjectWizard.java | 16 +- .../org.eclipse.ltk.core.refactoring.prefs | 2 + python/.checkstyle | 9 + python/.classpath | 10 + python/.settings/org.eclipse.jdt.core.prefs | 316 +++++++++++ python/.settings/org.eclipse.jdt.ui.prefs | 61 +++ .../org.eclipse.ltk.core.refactoring.prefs | 2 + python/META-INF/MANIFEST.MF | 21 + python/build.properties | 6 + python/build.xml | 146 +++++ python/doc/cheatsheets/unoclient.xml | 46 ++ python/icons/export_ant.gif | Bin 0 -> 581 bytes python/icons/java_app_wiz.png | Bin 0 -> 5277 bytes python/icons/uno_client.png | Bin 0 -> 611 bytes python/plugin.xml | 66 +++ .../AbstractOpenOfficeConnection.java | 143 +++++ .../connection/OpenOfficeConfiguration.java | 91 ++++ .../connection/OpenOfficeConnection.java | 53 ++ .../connection/OpenOfficeException.java | 29 + .../connection/PipeOpenOfficeConnection.java | 38 ++ .../SocketOpenOfficeConnection.java | 34 ++ .../python/JavaDebugExtraOptionsProvider.java | 42 ++ .../ide/eclipse/python/JavaMainProvider.java | 149 ++++++ .../python/JavaResourceDeltaVisitor.java | 206 +++++++ .../python/JavaUnoResourceChangeHandler.java | 80 +++ .../ide/eclipse/python/Language.java | 124 +++++ .../ide/eclipse/python/Messages.java | 79 +++ .../ide/eclipse/python/OOoJavaPlugin.java | 121 +++++ .../ide/eclipse/python/PythonBuilder.java | 322 +++++++++++ .../eclipse/python/PythonProjectHandler.java | 387 ++++++++++++++ .../ide/eclipse/python/PythonWizardPage.java | 125 +++++ .../eclipse/python/build/FilesVisitor.java | 84 +++ .../ide/eclipse/python/build/Messages.java | 66 +++ .../python/build/OOoClasspathContainer.java | 119 +++++ .../python/build/OOoContainerPage.java | 266 +++++++++ .../OooClasspathContainerInitializer.java | 96 ++++ .../python/build/UnoManifestProvider.java | 86 +++ .../eclipse/python/build/messages.properties | 8 + .../eclipse/python/client/ClientWizard.java | 171 ++++++ .../python/client/ClientWizardPageTwo.java | 116 ++++ .../ide/eclipse/python/client/Messages.java | 67 +++ .../eclipse/python/client/UnoClient.java.tpl | 39 ++ .../python/client/UnoConnectionPage.java | 49 ++ .../client/license-jodconnector.txt.tpl | 504 ++++++++++++++++++ .../eclipse/python/client/messages.properties | 6 + .../python/export/AntScriptExportWizard.java | 135 +++++ .../export/AntScriptExportWizardPage.java | 255 +++++++++ .../python/export/JavaExportPageControl.java | 76 +++ .../eclipse/python/export/JavaExportPart.java | 196 +++++++ .../ide/eclipse/python/export/build.xml.tpl | 182 +++++++ .../ide/eclipse/python/messages.properties | 18 + .../python/registration/FileRefreshJob.java | 90 ++++ .../eclipse/python/registration/Messages.java | 66 +++ .../registration/RegistrationHandler.java.tpl | 175 ++++++ .../registration/RegistrationHelper.java | 231 ++++++++ .../python/registration/messages.properties | 2 + .../test/JavaExportPageControlTest.java | 63 +++ .../ide/eclipse/python/tests/Messages.java | 67 +++ .../ide/eclipse/python/tests/TestsHelper.java | 93 ++++ .../eclipse/python/tests/UnoTests.java.tpl | 13 + .../python/tests/base/UnoSuite.java.tpl | 75 +++ .../python/tests/helper/UnoHelper.java.tpl | 28 + .../eclipse/python/tests/messages.properties | 1 + .../python/tests/uno/WriterTest.java.tpl | 26 + .../ide/eclipse/python/utils/Messages.java | 79 +++ .../eclipse/python/utils/TemplatesHelper.java | 161 ++++++ .../eclipse/python/utils/messages.properties | 3 + 68 files changed, 6440 insertions(+), 10 deletions(-) create mode 100644 java/.settings/org.eclipse.ltk.core.refactoring.prefs create mode 100644 python/.checkstyle create mode 100644 python/.classpath create mode 100644 python/.settings/org.eclipse.jdt.core.prefs create mode 100644 python/.settings/org.eclipse.jdt.ui.prefs create mode 100644 python/.settings/org.eclipse.ltk.core.refactoring.prefs create mode 100644 python/META-INF/MANIFEST.MF create mode 100644 python/build.properties create mode 100644 python/build.xml create mode 100644 python/doc/cheatsheets/unoclient.xml create mode 100644 python/icons/export_ant.gif create mode 100644 python/icons/java_app_wiz.png create mode 100644 python/icons/uno_client.png create mode 100644 python/plugin.xml create mode 100644 python/source/com/artofsolving/jodconverter/openoffice/connection/AbstractOpenOfficeConnection.java create mode 100644 python/source/com/artofsolving/jodconverter/openoffice/connection/OpenOfficeConfiguration.java create mode 100644 python/source/com/artofsolving/jodconverter/openoffice/connection/OpenOfficeConnection.java create mode 100644 python/source/com/artofsolving/jodconverter/openoffice/connection/OpenOfficeException.java create mode 100644 python/source/com/artofsolving/jodconverter/openoffice/connection/PipeOpenOfficeConnection.java create mode 100644 python/source/com/artofsolving/jodconverter/openoffice/connection/SocketOpenOfficeConnection.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/JavaDebugExtraOptionsProvider.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/JavaMainProvider.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/JavaResourceDeltaVisitor.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/JavaUnoResourceChangeHandler.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/Language.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/Messages.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/OOoJavaPlugin.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/PythonBuilder.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/PythonProjectHandler.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/PythonWizardPage.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/build/FilesVisitor.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/build/Messages.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/build/OOoClasspathContainer.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/build/OOoContainerPage.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/build/OooClasspathContainerInitializer.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/build/UnoManifestProvider.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/build/messages.properties create mode 100644 python/source/org/libreoffice/ide/eclipse/python/client/ClientWizard.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/client/ClientWizardPageTwo.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/client/Messages.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/client/UnoClient.java.tpl create mode 100644 python/source/org/libreoffice/ide/eclipse/python/client/UnoConnectionPage.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/client/license-jodconnector.txt.tpl create mode 100644 python/source/org/libreoffice/ide/eclipse/python/client/messages.properties create mode 100644 python/source/org/libreoffice/ide/eclipse/python/export/AntScriptExportWizard.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/export/AntScriptExportWizardPage.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/export/JavaExportPageControl.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/export/JavaExportPart.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/export/build.xml.tpl create mode 100644 python/source/org/libreoffice/ide/eclipse/python/messages.properties create mode 100644 python/source/org/libreoffice/ide/eclipse/python/registration/FileRefreshJob.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/registration/Messages.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/registration/RegistrationHandler.java.tpl create mode 100644 python/source/org/libreoffice/ide/eclipse/python/registration/RegistrationHelper.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/registration/messages.properties create mode 100644 python/source/org/libreoffice/ide/eclipse/python/test/JavaExportPageControlTest.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/tests/Messages.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/tests/TestsHelper.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/tests/UnoTests.java.tpl create mode 100644 python/source/org/libreoffice/ide/eclipse/python/tests/base/UnoSuite.java.tpl create mode 100644 python/source/org/libreoffice/ide/eclipse/python/tests/helper/UnoHelper.java.tpl create mode 100644 python/source/org/libreoffice/ide/eclipse/python/tests/messages.properties create mode 100644 python/source/org/libreoffice/ide/eclipse/python/tests/uno/WriterTest.java.tpl create mode 100644 python/source/org/libreoffice/ide/eclipse/python/utils/Messages.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/utils/TemplatesHelper.java create mode 100644 python/source/org/libreoffice/ide/eclipse/python/utils/messages.properties diff --git a/core/source/org/libreoffice/ide/eclipse/core/internal/helpers/UnoidlProjectHelper.java b/core/source/org/libreoffice/ide/eclipse/core/internal/helpers/UnoidlProjectHelper.java index 9f94da6..32afad5 100644 --- a/core/source/org/libreoffice/ide/eclipse/core/internal/helpers/UnoidlProjectHelper.java +++ b/core/source/org/libreoffice/ide/eclipse/core/internal/helpers/UnoidlProjectHelper.java @@ -196,14 +196,16 @@ public class UnoidlProjectHelper { // Save all the properties to the configuration file unoProject.saveAllProperties(); - // Creation of the unoidl package - createUnoidlPackage(unoProject, pMonitor); + if (!language.getName().contains("Python")) { + // Creation of the unoidl package + createUnoidlPackage(unoProject, pMonitor); - // Creation of the Code Packages - createCodePackage(unoProject, pMonitor); + // Creation of the Code Packages + createCodePackage(unoProject, pMonitor); - // Creation of the urd output directory - createUrdDir(unoProject, pMonitor); + // Creation of the urd output directory + createUrdDir(unoProject, pMonitor); + } return unoProject; } diff --git a/core/source/org/libreoffice/ide/eclipse/core/wizards/NewUnoProjectWizard.java b/core/source/org/libreoffice/ide/eclipse/core/wizards/NewUnoProjectWizard.java index a1f586f..86b2ee3 100755 --- a/core/source/org/libreoffice/ide/eclipse/core/wizards/NewUnoProjectWizard.java +++ b/core/source/org/libreoffice/ide/eclipse/core/wizards/NewUnoProjectWizard.java @@ -237,6 +237,9 @@ public class NewUnoProjectWizard extends BasicNewProjectResourceWizard implement } else { // Could be null next = mServiceSet.getPage(ServiceWizardSet.SERVICE_PAGE_ID); + if (mMainPage.getChosenLanguage().toString().contains("python")) { + next = null; + } } } else if (mLanguagePage != null && mLanguagePage.equals(pPage)) { next = mServiceSet.getPage(ServiceWizardSet.SERVICE_PAGE_ID); @@ -309,7 +312,7 @@ public class NewUnoProjectWizard extends BasicNewProjectResourceWizard implement private void updateLoanguagePage() { // Create/Remove the language page if needed AbstractLanguage lang = mMainPage.getChosenLanguage(); - if (lang != null) { + if (lang != null && !lang.toString().contains("python")) { UnoFactoryData data = new UnoFactoryData(); LanguageWizardPage page = lang.getNewWizardPage(); if (page != null) { @@ -363,10 +366,15 @@ public class NewUnoProjectWizard extends BasicNewProjectResourceWizard implement try { IUnoidlProject prj = UnoFactory.createProject(mData, pMonitor); - mServiceSet.mProject = prj; - mServiceSet.doFinish(pMonitor, mActivePage); + AbstractLanguage language = (AbstractLanguage) mData.getProperty(IUnoFactoryConstants.PROJECT_LANGUAGE); - UnoidlProjectHelper.setProjectBuilders(prj); + if (!language.getName().contains("Python")) { + mServiceSet.mProject = prj; + mServiceSet.doFinish(pMonitor, mActivePage); + + UnoidlProjectHelper.setProjectBuilders(prj); + + } } catch (Exception e) { Object o = mData.getProperty(IUnoFactoryConstants.PROJECT_HANDLE); diff --git a/java/.settings/org.eclipse.ltk.core.refactoring.prefs b/java/.settings/org.eclipse.ltk.core.refactoring.prefs new file mode 100644 index 0000000..b196c64 --- /dev/null +++ b/java/.settings/org.eclipse.ltk.core.refactoring.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false diff --git a/python/.checkstyle b/python/.checkstyle new file mode 100644 index 0000000..2de2377 --- /dev/null +++ b/python/.checkstyle @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/python/.classpath b/python/.classpath new file mode 100644 index 0000000..9bc49fa --- /dev/null +++ b/python/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/python/.settings/org.eclipse.jdt.core.prefs b/python/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..f33fddb --- /dev/null +++ b/python/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,316 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.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_expressions_in_for_loop_header=0 +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_parameterized_type_references=0 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 +org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.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=false +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=false +org.eclipse.jdt.core.formatter.comment.format_line_comments=false +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=120 +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=1 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=1 +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=true +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=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=false +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=120 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/python/.settings/org.eclipse.jdt.ui.prefs b/python/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000..d5badc6 --- /dev/null +++ b/python/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,61 @@ +cleanup.add_default_serial_version_id=false +cleanup.add_generated_serial_version_id=true +cleanup.add_missing_annotations=true +cleanup.add_missing_deprecated_annotations=true +cleanup.add_missing_methods=false +cleanup.add_missing_nls_tags=false +cleanup.add_missing_override_annotations=true +cleanup.add_missing_override_annotations_interface_methods=true +cleanup.add_serial_version_id=true +cleanup.always_use_blocks=true +cleanup.always_use_parentheses_in_expressions=false +cleanup.always_use_this_for_non_static_field_access=false +cleanup.always_use_this_for_non_static_method_access=false +cleanup.convert_functional_interfaces=false +cleanup.convert_to_enhanced_for_loop=false +cleanup.correct_indentation=true +cleanup.format_source_code=false +cleanup.format_source_code_changes_only=false +cleanup.insert_inferred_type_arguments=false +cleanup.make_local_variable_final=true +cleanup.make_parameters_final=false +cleanup.make_private_fields_final=true +cleanup.make_type_abstract_if_missing_method=false +cleanup.make_variable_declarations_final=false +cleanup.never_use_blocks=false +cleanup.never_use_parentheses_in_expressions=true +cleanup.organize_imports=true +cleanup.qualify_static_field_accesses_with_declaring_class=false +cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true +cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true +cleanup.qualify_static_member_accesses_with_declaring_class=true +cleanup.qualify_static_method_accesses_with_declaring_class=false +cleanup.remove_private_constructors=true +cleanup.remove_redundant_type_arguments=false +cleanup.remove_trailing_whitespaces=true +cleanup.remove_trailing_whitespaces_all=true +cleanup.remove_trailing_whitespaces_ignore_empty=false +cleanup.remove_unnecessary_casts=true +cleanup.remove_unnecessary_nls_tags=true +cleanup.remove_unused_imports=true +cleanup.remove_unused_local_variables=false +cleanup.remove_unused_private_fields=true +cleanup.remove_unused_private_members=false +cleanup.remove_unused_private_methods=true +cleanup.remove_unused_private_types=true +cleanup.sort_members=false +cleanup.sort_members_all=false +cleanup.use_anonymous_class_creation=false +cleanup.use_blocks=true +cleanup.use_blocks_only_for_return_and_throw=false +cleanup.use_lambda=true +cleanup.use_parentheses_in_expressions=true +cleanup.use_this_for_non_static_field_access=false +cleanup.use_this_for_non_static_field_access_only_if_necessary=true +cleanup.use_this_for_non_static_method_access=false +cleanup.use_this_for_non_static_method_access_only_if_necessary=true +cleanup_profile=_OOEclipse +cleanup_settings_version=2 +eclipse.preferences.version=1 +formatter_profile=_OOEclipse +formatter_settings_version=12 diff --git a/python/.settings/org.eclipse.ltk.core.refactoring.prefs b/python/.settings/org.eclipse.ltk.core.refactoring.prefs new file mode 100644 index 0000000..b196c64 --- /dev/null +++ b/python/.settings/org.eclipse.ltk.core.refactoring.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false diff --git a/python/META-INF/MANIFEST.MF b/python/META-INF/MANIFEST.MF new file mode 100644 index 0000000..08b3c5f --- /dev/null +++ b/python/META-INF/MANIFEST.MF @@ -0,0 +1,21 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Java Plug-in for LibreOffice eclipse integration +Bundle-SymbolicName: org.libreoffice.ide.eclipse.python;singleton:=true +Bundle-Vendor: The Document Foundation +Bundle-Version: 2.2.6 +Bundle-Activator: org.libreoffice.ide.eclipse.python.OOoJavaPlugin +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Require-Bundle: org.eclipse.ui, + org.libreoffice.ide.eclipse.core, + org.eclipse.core.resources, + org.eclipse.jdt.core, + org.eclipse.jdt.launching, + org.eclipse.jdt, + org.eclipse.jdt.ui, + org.eclipse.jface.text, + org.eclipse.jdt.junit, + org.eclipse.ui.ide, + org.eclipse.ui.cheatsheets, + org.eclipse.jdt.debug.ui;bundle-version="3.4.1" diff --git a/python/build.properties b/python/build.properties new file mode 100644 index 0000000..e590bc6 --- /dev/null +++ b/python/build.properties @@ -0,0 +1,6 @@ +source.. = source/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + icons/ diff --git a/python/build.xml b/python/build.xml new file mode 100644 index 0000000..8029f96 --- /dev/null +++ b/python/build.xml @@ -0,0 +1,146 @@ + + + + + + + + Wrong target! + + This script should not be executed directly. + Please, use the one in the build project + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/python/doc/cheatsheets/unoclient.xml b/python/doc/cheatsheets/unoclient.xml new file mode 100644 index 0000000..85571a3 --- /dev/null +++ b/python/doc/cheatsheets/unoclient.xml @@ -0,0 +1,46 @@ + + + + + LibreOffice can be used as well as a server. Creating clients connecting to it is not an easy task for beginners and the informations are split all over the web. +

+Follow the next steps to create a new Java UNO Client really quickly. +
+
+ + + Create a new project of type Java UNO Client application . +

+Configure the LibreOffice instance and SDK used to build to program and configure the LibreOffice connection. +
+ +
+ + + Replace the TODO comment by the code using the UNO connection to LibreOffice. + + + + + LibreOffice needs to be started with the following parameter depending on your connection configuration: +

+Pipe connection:
-accept="pipe,name=pipename;urp;StarOffice.ServiceManager" +

+Socket connection:
-accept="socket,host=host,port=port;urp;StarOffice.ServiceManager" +
+
+ + + Everything is done! Now run the new UNO client program. +

+To run your application, right-click on your class in the Package Explorer and select Run As > Java Application. The Console view should appear at the bottom and display the output. +
+
+
diff --git a/python/icons/export_ant.gif b/python/icons/export_ant.gif new file mode 100644 index 0000000000000000000000000000000000000000..5b079936ebfd8af146148e85109bc17aed538c3a GIT binary patch literal 581 zcmZ?wbhEHb6krfwc*el6?7;J~iCgxZd3gE3$H#AeeERzH002S=1^@s6A3-Z300009a7bBm000XU z000XU0RWnu7ytkYO=&|zP*7-ZbZ>KLZ*U+5Lu!Sk^o_Z5E4Meg@_7P6crJiNL9pw)e1;Xm069{HJUZAPk55R%$-RIA z6-eL&AQ0xu!e<4=008gy@A0LT~suv4>S3ILP<0Bm`DLLvaF4FK%)Nj?Pt*r}7;7Xa9z9H|HZjR63e zC`Tj$K)V27Re@400>HumpsYY5E(E}?0f1SyGDiY{y#)Yvj#!WnKwtoXnL;eg03bL5 z07D)V%>y7z1E4U{zu>7~aD})?0RX_umCct+(lZpemCzb@^6=o|A>zVpu|i=NDG+7} zl4`aK{0#b-!z=TL9Wt0BGO&T{GJWpjryhdijfaIQ&2!o}p04JRKYg3k&Tf zVxhe-O!X z{f;To;xw^bEES6JSc$k$B2CA6xl)ltA<32E66t?3@gJ7`36pmX0IY^jz)rRYwaaY4 ze(nJRiw;=Qb^t(r^DT@T3y}a2XEZW-_W%Hszxj_qD**t_m!#tW0KDiJT&R>6OvVTR z07RgHDzHHZ48atvzz&?j9lXF70$~P3Knx_nJP<+#`N z#-MZ2bTkiLfR>_b(HgWKJ%F~Nr_oF3b#wrIijHG|(J>BYjM-sajE6;FiC7vY#};Gd zST$CUHDeuEH+B^pz@B062qXfFfD`NpUW5?BY=V%GM_5c)L#QR}BeW8_2v-S%gfYS= zB9o|3v?Y2H`NVi)In3rTB8+ej^> zQ=~r95NVuDChL%G$=>7$vVg20myx%S50Foi`^m%Pw-h?Xh~i8Mq9jtJloCocWk2Nv zrJpiFnV_ms&8eQ$2&#xWpIS+6pmtC%Q-`S&GF4Q#^mhymh7E(qNMa}%YZ-ePrx>>xFPTiH1=E+A$W$=bG8>s^ zm=Bn5Rah$aDtr}@$`X}2l~$F0mFKEdRdZE8)p@E5RI61Ft6o-prbbn>P~)iy)E2AN zsU20jsWz_8Qg>31P|s0cqrPALg8E|(vWA65poU1JRAaZs8I2(p#xiB`SVGovRs-uS zYnV-9TeA7=Om+qP8+I>yOjAR1s%ETak!GFdam@h^# z)@rS0t$wXH+Irf)+G6c;?H29p+V6F6oj{!|o%K3xI`?%6x;DB|x`n#ibhIR?(H}Q3Gzd138Ei2)WAMz7W9Vy`X}HnwgyEn!VS)>mv$8&{hQn>w4zwy3R}t;BYlZQm5)6pty=DfLrs+A-|>>;~;Q z_F?uV_HFjh9n2gO9o9Q^JA86v({H5aB!kjoO6 zc9$1ZZKsN-Zl8L~mE{`ly3)1N^`o1+o7}D0ZPeY&J;i;i`%NyJ8_8Y6J?}yE@b_5a zam?eLr<8@mESk|3$_SkmS{wQ>%qC18))9_|&j{ZT zes8AvOzF(F2#DZEY>2oYX&IRp`F#{ADl)1r>QS^)ba8a|EY_^#S^HO&t^Rgqwv=MZThqqEWH8 zxJo>d=ABlR_Bh=;eM9Tw|Ih34~oTE|= zX_mAr*D$vzw@+p(E0Yc6dFE}(8oqt`+R{gE3x4zjX+Sb3_cYE^= zgB=w+-tUy`ytONMS8KgRef4hA?t0j zufM;t32jm~jUGrkaOInTZ`zyfns>EuS}G30LFK_G-==(f<51|K&cocp&EJ`SxAh3? zNO>#LI=^+SEu(FqJ)ynt=!~PC9bO$rzPJB=?=j6w@a-(u02P7 zaQ)#(uUl{HW%tYNS3ItC^iAtK(eKlL`f9+{bJzISE?u8_z3;~C8@FyI-5j_jy7l;W z_U#vU3hqqYU3!mrul&B+{ptt$59)uk{;_4iZQ%G|z+lhASr6|H35TBkl>gI*;nGLU zN7W-nBaM%pA0HbH8olyl&XeJ%vZoWz%6?Y=dFykl=imL}`%BMQ{Mhgd`HRoLu6e2R za__6DuR6yg#~-}Tc|Gx_{H@O0eebyMy5GmWADJlpK>kqk(fVV@r_fLLKIeS?{4e)} z^ZO;zpECde00d`2O+f$vv5tKEQIh}w03c&XQcVB=dL;k=fP(-4`Tqa_faw4Lbua(` z>RI+y?e7jKeZ#YO-C3A#x{K~#9!?3+!D97h$$|L;}x?99&Yj(65}5<4-rm0S#j z96}%xM80uBNX+&gpZGb#}9wKWK>aB)tV}1 z0aWbASo#1(04l1O6Va+FD%tyYJ**%7_Nq}uRTO0rt*B^K6s1Amy=!6p_=Rf~5lpLU zNdW`ZS*T8Z)H8P#tmpr@%%Yf5)mc>-B0v?>P@MrlyFGu`!20Q*-k%lKX#!XkKv2^h z0VUdF9up7iXMcXbB8s3S02(AzQDBw;(joGiSXe(ld%dKJIaQ5F10)1cvmi`o|998I z`o-T?jHu43qPz_T5#a!Ul4`!ZCkoat|GrXH#S8)5$Ae&*P*Z``5%Ql1SigB`HA>V} z0)TDGu}r9|4(FdH64se>t5s3V5Que~7b3tCQC(F>26acn`rY|87QwtiOM{#>1=FjG zf>ets^Nxh|`X~Pms4l7`3Wxxr3K2!P&ZN?R?UPg$5Y4HqQ>RWnbtfoJ z!LI>thRQeSICTzV-$h`%nj}u&QbS(5|p5 zl?s@7y!{n3D&@*(uoNVUNJOnFB30P!q1D(1rDx8Z0RTMx^wU^bS;4t;=WyuIA)G#a zddGD>HUW#LZ#k@s7cchC8;u4oUc89o$Bz%ZR#kZK0kaDr zh4F&Odo6j7QW}Kr_4Rg*;Ln~t`_iM2K6-lGeb#Gl{PXo2rANNmAE^Ugl$_To?{&(H zMjsZzi-u@_BxO10uzY_0Z! zZFuL9o$d32QUD}VBE@v4_hg2zzWE_Fj)p+zRdjAm_E>M9U&zDcF1L2^JfMwHEiEd=Si>ymUyJ!Z|UA z7iLaWmBJu^!o5EAQL3t};?RRNth;tzP3&|*6u51DL+2dWM2MmY_kZH}nD(L--n)H| zZ+3+h$1zN)jL2FP@oQdx^F4gyd(RKN_w}!S0pI=Bleu8UvAg{dymJl_Gor|XY4ifq zES~xDBLr^GMEW$%(%b`W>|=_Xq&Q<@e)zwR~8Y>IKX1&V1}k3WnrhXvT2?& z4B?gxQ0`4xhG7lwgU?E|m9&UNqbO@^V1-Yip@Swp-o(MDBLum877>`uIKe7LSxo)P z%EnsxeHO;UXKk5b!J&ip!%E@hHA8ESEpewN0F;7Kl>t@htzS@42mqDLb#JW$iT2_? zzzg|U$h94JhjQ>Ku);%!)VZU#ia56!8s@0X@q%RX)8vmT5=dJxQZ;8&0n`gQCvZ+E zHl8~}!Ae0HF2)T1^6~}L=Bhi*a1>=R!5U*DatDD#Q7NpDf9Q%5cECzI^`a23aGoe; zqK+!b_Ek-Lf@PRtd3a_0hz^5NN0swgN`~^IJ<~$xec{EX0uRX*kPaXz=@`Vln z*qF$YENtZ%%n_PN`vE2jhZjZcg}P95M9GVgYsTEz?ApfAah73*F+6m??ZuZb;KKi| zqcjzv*=)lagOewYU}2%w3rf?PJ$a;_jKk;fgB;AzB(Sz{Wk#4O0Tt9GP^c(k09{oQ zBCvSsHe=pcZAPnE^BXcKWmq1*)-PXMN3Ax4g9mF{&Yft>xhLu2`V1cb)B|BNP0m1< z*#uarlD5MN17D%DpcD(xC6I)FP`4SI>uW8$ywSFsUIvfi@7WCV_^ivzAK;;f9tbK* zXS}q3v;Y9U{p4qZndkJ0%mmA98M@H7id50taH1dq;6>3^s0YY31)P(Ea&5&rQmwEG@s{nwhsZ!5B5z-$YoXAY2gztRib9mz6<0y^LT`@#p!x2Ll z6n)c>iAhpSsvQ9}0d&3cM#u5BMr^LFwMt8y9lq&g_YEq$!V-}X^bKi-^D`Cv>IYxL zW-NGbX&uXJH+ye!UwsCjdGJ1b@!?~bua*&w*smifRHQ_thcfjks&D{W3d90xI-%uQ z_-f0Us~eqYalI9-bv-%RBAX;uzl> zh6#C@B1RJdi1%o>+vY%3Ydugv8=#JWHoef*Sb3@A&C-o-bY;CAEjMG+mLX?h?Epv- zfEfS_#C%Vy**c)&L;ovxAeuU?V&Dvd)oeBi3&FlMv~btG@{&_p?0U1<@b>aXr?hmV z8{PDhZ>5XPsAw9%0RV>q90G8dnI331TeEM!^%gE&y0lNPI{Iy;NhcqtZM?1)`#xM*=Rj#fI(bVWxmIEB>(unE8cSYzf&Wv03e;O)mh z|HMCxjpm5R>VPO%G9ip0D76plDT@+S#tYZpmoP6e`)BBoP`xF_PW~S+| z+d-0@3_Eu>Xm2+}Htk<)B_c`r{l8`BcekEVmBIIOtk2rvvm0$+1*n{~$aRdcl#&24 zhANnlqYqZA<4tG@m2^Z<01#QO5RGlSFdD3+H8e$lA_Cb7QdJ+UcGp(`Oa;@UkykNK znyPxRy0I{U4iurNNmbRBvIz4EEP#qx7jF$s5hhDj0Km>m8Nhu-fdWFffC)SpzzHgF jr$xk6A|jqdSpOdYqd&nSSp+@K00000NkvXXu0mjffwKF8 literal 0 HcmV?d00001 diff --git a/python/icons/uno_client.png b/python/icons/uno_client.png new file mode 100644 index 0000000000000000000000000000000000000000..2cae06b725e46e66594d81355826b044de0283c7 GIT binary patch literal 611 zcmV-p0-XJcP)rp&?iwHHixYLTHho(yrZz8(-i;TK0` zt+Z&tjf#XyWC#k~sZbk`papA-MX?e}2O676hMDUklQ2%k`on>9hjV|v`OgeM3Q)e< z;5%!;Is(*ssFXq})jXO&r)SP_jQ}WQlOtY}RO7xVEyF#&&LYc z%T}p0bN2VU!_O?sP61e!eLjD8XZ0_Fro1F>#a`Un zF>F_g%B~cZz2a7-s5*jz5kj;wajBLjJ{@>ay>nnCLjVZJNt9@@RiNefm`^GL1)nGcKA2om8NOUHVoKn zeMsAYJ|OP)vEJTY;Y>O+s^@erojUi;rDzYl*<2hP*RG`xhF4c>I1ZKLPcn7?@T)T; zk$60^vaqnEmF9nhbNSZ|13jlt1AD#0nW<5Z^lzspx{;YhgO^j^x!s=*&LEmdv;|Om zTf+oS_8sMNew>PX=6hY2KL*6TbP8bV5mlyV*^ x%Tmg+;2+w0VgDC}hzX&Z>$_3D_vX5P?hjRbFh8+ep{oD@002ovPDHLkV1i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/python/source/com/artofsolving/jodconverter/openoffice/connection/AbstractOpenOfficeConnection.java b/python/source/com/artofsolving/jodconverter/openoffice/connection/AbstractOpenOfficeConnection.java new file mode 100644 index 0000000..bf5e10d --- /dev/null +++ b/python/source/com/artofsolving/jodconverter/openoffice/connection/AbstractOpenOfficeConnection.java @@ -0,0 +1,143 @@ +// +// JODConverter - Java OpenDocument Converter +// Copyright (C) 2004-2007 - Mirko Nasato +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// http://www.gnu.org/copyleft/lesser.html +// +// Contributor: +// Laurent Godard +// +package com.artofsolving.jodconverter.openoffice.connection; + +import java.net.ConnectException; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.bridge.XBridge; +import com.sun.star.bridge.XBridgeFactory; +import com.sun.star.comp.helper.Bootstrap; +import com.sun.star.connection.NoConnectException; +import com.sun.star.connection.XConnection; +import com.sun.star.connection.XConnector; +import com.sun.star.frame.XComponentLoader; +import com.sun.star.lang.EventObject; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XEventListener; +import com.sun.star.lang.XMultiComponentFactory; +import com.sun.star.ucb.XFileIdentifierConverter; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; + +public abstract class AbstractOpenOfficeConnection implements OpenOfficeConnection, XEventListener { + + private String connectionString; + private XComponent bridgeComponent; + private XMultiComponentFactory serviceManager; + private XComponentContext componentContext; + private XBridge bridge; + private boolean connected = false; + private boolean expectingDisconnection = false; + + protected AbstractOpenOfficeConnection(String connectionString) { + this.connectionString = connectionString; + } + + @Override + public synchronized void connect() throws ConnectException { + try { + XComponentContext localContext = Bootstrap.createInitialComponentContext(null); + XMultiComponentFactory localServiceManager = localContext.getServiceManager(); + XConnector connector = UnoRuntime.queryInterface(XConnector.class, + localServiceManager.createInstanceWithContext("com.sun.star.connection.Connector", localContext)); + XConnection connection = connector.connect(connectionString); + XBridgeFactory bridgeFactory = UnoRuntime.queryInterface(XBridgeFactory.class, + localServiceManager.createInstanceWithContext("com.sun.star.bridge.BridgeFactory", localContext)); + bridge = bridgeFactory.createBridge("", "urp", connection, null); + bridgeComponent = UnoRuntime.queryInterface(XComponent.class, bridge); + bridgeComponent.addEventListener(this); + serviceManager = UnoRuntime.queryInterface(XMultiComponentFactory.class, + bridge.getInstance("StarOffice.ServiceManager")); + XPropertySet properties = UnoRuntime.queryInterface(XPropertySet.class, serviceManager); + componentContext = UnoRuntime.queryInterface(XComponentContext.class, + properties.getPropertyValue("DefaultContext")); + connected = true; + } catch (NoConnectException connectException) { + throw new ConnectException("connection failed: " + connectionString + ": " + connectException.getMessage()); + } catch (Exception exception) { + throw new OpenOfficeException("connection failed: " + connectionString, exception); + } + } + + @Override + public synchronized void disconnect() { + expectingDisconnection = true; + bridgeComponent.dispose(); + } + + @Override + public boolean isConnected() { + return connected; + } + + @Override + public void disposing(EventObject event) { + connected = false; + if (!expectingDisconnection) { + throw new OpenOfficeException("disconnected unexpectedly"); + } + expectingDisconnection = false; + } + + // for unit tests only + void simulateUnexpectedDisconnection() { + disposing(null); + bridgeComponent.dispose(); + } + + private Object getService(String className) { + try { + if (!connected) { + connect(); + } + return serviceManager.createInstanceWithContext(className, componentContext); + } catch (Exception exception) { + throw new OpenOfficeException("could not obtain service: " + className, exception); + } + } + + @Override + public XComponentLoader getDesktop() { + return UnoRuntime.queryInterface(XComponentLoader.class, + getService("com.sun.star.frame.Desktop")); + } + + @Override + public XFileIdentifierConverter getFileContentProvider() { + return UnoRuntime.queryInterface(XFileIdentifierConverter.class, + getService("com.sun.star.ucb.FileContentProvider")); + } + + @Override + public XBridge getBridge() { + return bridge; + } + + @Override + public XMultiComponentFactory getRemoteServiceManager() { + return serviceManager; + } + + @Override + public XComponentContext getComponentContext() { + return componentContext; + } + +} diff --git a/python/source/com/artofsolving/jodconverter/openoffice/connection/OpenOfficeConfiguration.java b/python/source/com/artofsolving/jodconverter/openoffice/connection/OpenOfficeConfiguration.java new file mode 100644 index 0000000..e374e6f --- /dev/null +++ b/python/source/com/artofsolving/jodconverter/openoffice/connection/OpenOfficeConfiguration.java @@ -0,0 +1,91 @@ +// +// JODConverter - Java OpenDocument Converter +// OpenOffice.org Configuration checker +// Copyright (C) 2007 - Laurent Godard +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// http://www.gnu.org/copyleft/lesser.html +// +// Contributor: +// Mirko Nasato +// + +package com.artofsolving.jodconverter.openoffice.connection; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** + * Utility class to access OpenOffice.org configuration properties at runtime + */ +public class OpenOfficeConfiguration { + + public static final String NODE_L10N = "org.openoffice.Setup/L10N"; + public static final String NODE_PRODUCT = "org.openoffice.Setup/Product"; + + private OpenOfficeConnection connection; + + public OpenOfficeConfiguration(OpenOfficeConnection connection) { + this.connection = connection; + } + + public String getOpenOfficeProperty(String nodePath, String node) { + if (!nodePath.startsWith("/")) { + nodePath = "/" + nodePath; + } + String property = ""; + // create the provider and remember it as a XMultiServiceFactory + try { + final String sProviderService = "com.sun.star.configuration.ConfigurationProvider"; + Object configProvider = connection.getRemoteServiceManager().createInstanceWithContext( + sProviderService, connection.getComponentContext()); + XMultiServiceFactory xConfigProvider = UnoRuntime.queryInterface( + com.sun.star.lang.XMultiServiceFactory.class, configProvider); + + // The service name: Need only read access: + final String sReadOnlyView = "com.sun.star.configuration.ConfigurationAccess"; + // creation arguments: nodepath + PropertyValue aPathArgument = new PropertyValue(); + aPathArgument.Name = "nodepath"; + aPathArgument.Value = nodePath; + Object[] aArguments = new Object[1]; + aArguments[0] = aPathArgument; + + // create the view + XInterface xElement = (XInterface) xConfigProvider.createInstanceWithArguments(sReadOnlyView, aArguments); + XNameAccess xChildAccess = UnoRuntime.queryInterface(XNameAccess.class, xElement); + + // get the value + property = (String) xChildAccess.getByName(node); + } catch (Exception exception) { + throw new OpenOfficeException("Could not retrieve property", exception); + } + return property; + } + + public String getOpenOfficeVersion() { + try { + // OOo >= 2.2 returns major.minor.micro + return getOpenOfficeProperty(NODE_PRODUCT, "ooSetupVersionAboutBox"); + } catch (OpenOfficeException noSuchElementException) { + // OOo < 2.2 only returns major.minor + return getOpenOfficeProperty(NODE_PRODUCT, "ooSetupVersion"); + } + } + + public String getOpenOfficeLocale() { + return getOpenOfficeProperty(NODE_L10N, "ooLocale"); + } + +} diff --git a/python/source/com/artofsolving/jodconverter/openoffice/connection/OpenOfficeConnection.java b/python/source/com/artofsolving/jodconverter/openoffice/connection/OpenOfficeConnection.java new file mode 100644 index 0000000..b11ecb9 --- /dev/null +++ b/python/source/com/artofsolving/jodconverter/openoffice/connection/OpenOfficeConnection.java @@ -0,0 +1,53 @@ +// +// JODConverter - Java OpenDocument Converter +// Copyright (C) 2004-2007 - Mirko Nasato +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// http://www.gnu.org/copyleft/lesser.html +// +package com.artofsolving.jodconverter.openoffice.connection; + +import java.net.ConnectException; + +import com.sun.star.bridge.XBridge; +import com.sun.star.frame.XComponentLoader; +import com.sun.star.lang.XMultiComponentFactory; +import com.sun.star.ucb.XFileIdentifierConverter; +import com.sun.star.uno.XComponentContext; + +/** + * A UNO remote protocol connection to a listening OpenOffice.org instance + */ +public interface OpenOfficeConnection { + + public void connect() throws ConnectException; + + public void disconnect(); + + public boolean isConnected(); + + /** + * @return the com.sun.star.frame.Desktop service + */ + public XComponentLoader getDesktop(); + + /** + * @return the com.sun.star.ucb.FileContentProvider service + */ + public XFileIdentifierConverter getFileContentProvider(); + + public XBridge getBridge(); + + public XMultiComponentFactory getRemoteServiceManager(); + + public XComponentContext getComponentContext(); + +} diff --git a/python/source/com/artofsolving/jodconverter/openoffice/connection/OpenOfficeException.java b/python/source/com/artofsolving/jodconverter/openoffice/connection/OpenOfficeException.java new file mode 100644 index 0000000..6f5fd48 --- /dev/null +++ b/python/source/com/artofsolving/jodconverter/openoffice/connection/OpenOfficeException.java @@ -0,0 +1,29 @@ +// +// JODConverter - Java OpenDocument Converter +// Copyright (C) 2004-2007 - Mirko Nasato +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// http://www.gnu.org/copyleft/lesser.html +// +package com.artofsolving.jodconverter.openoffice.connection; + +public class OpenOfficeException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + public OpenOfficeException(String message) { + super(message); + } + + public OpenOfficeException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/python/source/com/artofsolving/jodconverter/openoffice/connection/PipeOpenOfficeConnection.java b/python/source/com/artofsolving/jodconverter/openoffice/connection/PipeOpenOfficeConnection.java new file mode 100644 index 0000000..bfea393 --- /dev/null +++ b/python/source/com/artofsolving/jodconverter/openoffice/connection/PipeOpenOfficeConnection.java @@ -0,0 +1,38 @@ +// +// JODConverter - Java OpenDocument Converter +// Copyright (C) 2004-2007 - Mirko Nasato +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// http://www.gnu.org/copyleft/lesser.html +// +package com.artofsolving.jodconverter.openoffice.connection; + +/** + * OpenOffice connection using a named pipe + *

+ * Warning! This requires the sal3 native library shipped with OpenOffice.org; + * it must be made available via the java.library.path parameter, e.g. + *

+ *   java -Djava.library.path=/opt/openoffice.org/program my.App
+ * 
+ */ +public class PipeOpenOfficeConnection extends AbstractOpenOfficeConnection { + + public static final String DEFAULT_PIPE_NAME = "jodconverter"; + + public PipeOpenOfficeConnection() { + this(DEFAULT_PIPE_NAME); + } + + public PipeOpenOfficeConnection(String pipeName) { + super("pipe,name=" + pipeName); + } +} diff --git a/python/source/com/artofsolving/jodconverter/openoffice/connection/SocketOpenOfficeConnection.java b/python/source/com/artofsolving/jodconverter/openoffice/connection/SocketOpenOfficeConnection.java new file mode 100644 index 0000000..842366f --- /dev/null +++ b/python/source/com/artofsolving/jodconverter/openoffice/connection/SocketOpenOfficeConnection.java @@ -0,0 +1,34 @@ +// +// JODConverter - Java OpenDocument Converter +// Copyright (C) 2004-2007 - Mirko Nasato +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// http://www.gnu.org/copyleft/lesser.html +// +package com.artofsolving.jodconverter.openoffice.connection; + +public class SocketOpenOfficeConnection extends AbstractOpenOfficeConnection { + + public static final String DEFAULT_HOST = "localhost"; + public static final int DEFAULT_PORT = 8100; + + public SocketOpenOfficeConnection() { + this(DEFAULT_HOST, DEFAULT_PORT); + } + + public SocketOpenOfficeConnection(int port) { + this(DEFAULT_HOST, port); + } + + public SocketOpenOfficeConnection(String host, int port) { + super("socket,host=" + host + ",port=" + port + ",tcpNoDelay=1"); + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/JavaDebugExtraOptionsProvider.java b/python/source/org/libreoffice/ide/eclipse/python/JavaDebugExtraOptionsProvider.java new file mode 100644 index 0000000..3c62328 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/JavaDebugExtraOptionsProvider.java @@ -0,0 +1,42 @@ +package org.libreoffice.ide.eclipse.python; + +import org.libreoffice.ide.eclipse.core.model.config.IExtraOptionsProvider; +import org.libreoffice.ide.eclipse.core.model.utils.SystemHelper; + +/** + * Adds extra env variables to start LibreOffice with Java setup to run in debug mode. + */ +public class JavaDebugExtraOptionsProvider implements IExtraOptionsProvider { + + private String mPort; + private String OOO_EXTRA_JAVA_TOOL_OPTIONS = "OOO_EXTRA_JAVA_TOOL_OPTIONS"; //$NON-NLS-1$ + + /** + * + * @param pPort + * the port to listen to. + */ + public JavaDebugExtraOptionsProvider(String pPort) { + this.mPort = pPort; + } + + /** + * {@inheritDoc} + */ + @Override + public String[] addEnv(String[] pEnv) { + String extraJavaOptEnv = System.getenv(OOO_EXTRA_JAVA_TOOL_OPTIONS); + if (extraJavaOptEnv == null) { + extraJavaOptEnv = new String(); + } else { + extraJavaOptEnv = extraJavaOptEnv.replaceAll("\"", "\\\""); //$NON-NLS-1$//$NON-NLS-2$ + } + + pEnv = SystemHelper.addEnv(pEnv, "JAVA_TOOL_OPTIONS", //$NON-NLS-1$ + extraJavaOptEnv + "\"-Xdebug\" " + //$NON-NLS-1$ + "\"-Xrunjdwp:transport=dt_socket,address=localhost:" + mPort + "\"", //$NON-NLS-1$//$NON-NLS-2$ + null); + return pEnv; + } + +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/JavaMainProvider.java b/python/source/org/libreoffice/ide/eclipse/python/JavaMainProvider.java new file mode 100644 index 0000000..31d2f53 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/JavaMainProvider.java @@ -0,0 +1,149 @@ +/************************************************************************* + * + * $RCSfile: JavaMainProvider.java,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: cedricbosdo $ $Date: 2007/11/25 20:32:38 $ + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * Sun Microsystems Inc., October, 2000 + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): Cedric Bosdonnat + * + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python; + +import java.util.Vector; + +import org.eclipse.core.resources.IProject; +import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.IJavaElement; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.IPackageFragmentRoot; +import org.eclipse.jdt.core.IParent; +import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.ITypeHierarchy; +import org.eclipse.jdt.core.JavaCore; +import org.libreoffice.ide.eclipse.core.launch.IMainProvider; + +/** + * Class providing the XMain implementations in Java. + */ +public class JavaMainProvider implements IMainProvider { + + /** + * {@inheritDoc} + */ + @Override + public Vector getMainNames(IProject pProject) { + Vector mains = new Vector(); + + IJavaProject javaPrj = JavaCore.create(pProject); + try { + mains.addAll(getInternalMainNames(javaPrj)); + } catch (Exception e) { + } + + return mains; + } + + /** + * Recursive method to find the Classes and check their hierarchy. + * + * @param pElement the Java AST element for scan for XMain implementations + * @return the names of the classes implementing the XMain interface in the + * Java AST element. + */ + private Vector getInternalMainNames(IParent pElement) { + Vector mains = new Vector(); + + try { + for (IJavaElement child : pElement.getChildren()) { + + boolean visit = true; + + if (child instanceof IPackageFragmentRoot) { + IPackageFragmentRoot root = (IPackageFragmentRoot) child; + if (root.getKind() != IPackageFragmentRoot.K_SOURCE) { + visit = false; + } + } + + if (visit) { + if (child instanceof ICompilationUnit) { + ICompilationUnit unit = (ICompilationUnit) child; + IType type = unit.findPrimaryType(); + + if (isMainImplementation(type)) { + mains.add(type.getFullyQualifiedName()); + } + } else if (child instanceof IParent) { + mains.addAll(getInternalMainNames((IParent) child)); + } + } + } + } catch (Exception e) { + } + + return mains; + } + + /** + * Checks if the Java type implements the com.sun.star.lang.XMain + * interface. + * + * @param pType the Java type to check + * @return true if the type implements XMain, + * false otherwise. + */ + private boolean isMainImplementation(IType pType) { + boolean isMainImplementation = false; + + try { + ITypeHierarchy hierarchy = pType.newSupertypeHierarchy(null); + IType[] superInterfaces = hierarchy.getAllSuperInterfaces(pType); + + int i = 0; + while (!isMainImplementation && i < superInterfaces.length) { + if (superInterfaces[i].getFullyQualifiedName().equals("com.sun.star.lang.XMain")) { //$NON-NLS-1$ + isMainImplementation = true; + } else { + i++; + } + } + } catch (Exception e) { + } + + return isMainImplementation; + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/JavaResourceDeltaVisitor.java b/python/source/org/libreoffice/ide/eclipse/python/JavaResourceDeltaVisitor.java new file mode 100644 index 0000000..936a01e --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/JavaResourceDeltaVisitor.java @@ -0,0 +1,206 @@ +/************************************************************************* + * + * $RCSfile: JavaResourceDeltaVisitor.java,v $ + * + * $Revision: 1.3 $ + * + * last change: $Author: cedricbosdo $ $Date: 2007/12/07 07:31:20 $ + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * Sun Microsystems Inc., October, 2000 + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): Cedric Bosdonnat + * + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStreamReader; +import java.util.Vector; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceDelta; +import org.eclipse.core.resources.IResourceDeltaVisitor; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.runtime.CoreException; +import org.libreoffice.ide.eclipse.core.model.IUnoidlProject; +import org.libreoffice.ide.eclipse.core.model.ProjectsManager; +import org.libreoffice.ide.eclipse.python.registration.RegistrationHelper; + +/** + * This class will visit a resource delta and perform the necessary changes + * on Java resources included in UNO projects. + */ +public class JavaResourceDeltaVisitor implements IResourceDeltaVisitor { + + /** + * {@inheritDoc} + */ + @Override + public boolean visit(IResourceDelta pDelta) throws CoreException { + + boolean visitChildren = true; + + if (!(pDelta.getResource() instanceof IWorkspaceRoot)) { + + IProject project = pDelta.getResource().getProject(); + IUnoidlProject unoprj = ProjectsManager.getProject(project.getName()); + if (unoprj != null) { + // The resource is a UNO project or is contained in a UNO project + visitChildren = true; + + // Check if the resource is a service implementation + if (pDelta.getKind() == IResourceDelta.ADDED) { + addImplementation(pDelta, unoprj); + + } else if (pDelta.getKind() == IResourceDelta.REMOVED) { + removeImplementation(pDelta, unoprj); + } + } + } + + return visitChildren; + } + + /** + * Remove the delta resource from the implementations. + * + * @param pDelta the delta to remove + * @param pUnoprj the concerned UNO project + */ + private void removeImplementation(IResourceDelta pDelta, + IUnoidlProject pUnoprj) { + IResource res = pDelta.getResource(); + if (res.getName().endsWith(".java")) { //$NON-NLS-1$ + String prjPath = pDelta.getProjectRelativePath().toString(); + prjPath = prjPath.replace(".java", ""); //$NON-NLS-1$ //$NON-NLS-2$ + prjPath = prjPath.replace("/", "."); //$NON-NLS-1$ //$NON-NLS-2$ + + Vector classes = RegistrationHelper.readClassesList(pUnoprj); + for (String implName : classes) { + if (prjPath.endsWith(implName)) { + RegistrationHelper.removeImplementation(pUnoprj, implName); + } + } + } + } + + /** + * Add the delta resource to the implementations. + * + * @param pDelta the delta resource to add. + * @param pUnoProject the concerned UNO project + */ + private void addImplementation(IResourceDelta pDelta, IUnoidlProject pUnoProject) { + String className = isJavaServiceImpl(pDelta.getResource()); + if (className != null) { + RegistrationHelper.addImplementation(pUnoProject, className); + } + } + + /** + * Check whether a resource is a UNO implementation. + * + * @param pResource the resource to check. + * @return true if it contains the necessary static methods for Java + * UNO service implementation registration. + */ + private String isJavaServiceImpl(IResource pResource) { + + String className = null; + if (pResource.getType() == IResource.FILE && pResource.getName().endsWith(".java")) { //$NON-NLS-1$ + /* + * For sure the resource is a Java class file. + * Now the file has to be read to find out if it contains the two + * following methods: + * + * + public static XSingleComponentFactory __getComponentFactory + * + public static boolean __writeRegistryServiceInfo(XRegistryKey xRegistryKey ) + */ + FileInputStream in = null; + BufferedReader reader = null; + try { + File file = pResource.getLocation().toFile(); + in = new FileInputStream(file); + reader = new BufferedReader(new InputStreamReader(in)); + + // Read the file into a string without line delimiters + String line = reader.readLine(); + String fileContent = ""; //$NON-NLS-1$ + while (line != null) { + fileContent = fileContent + line; + line = reader.readLine(); + } + + String getFactoryRegex = "public\\s+static\\s+XSingleComponentFactory" + //$NON-NLS-1$ + "\\s+__getComponentFactory"; //$NON-NLS-1$ + boolean containsGetFactory = fileContent.split(getFactoryRegex).length > 1; + + String writeServiceRegex = "public\\s+static\\s+boolean\\s+__writeRegistryServiceInfo"; //$NON-NLS-1$ + boolean containsWriteService = fileContent.split(writeServiceRegex).length > 1; + + // Do not consider the RegistrationHandler class as a service implementation + if (containsGetFactory && containsWriteService && + !pResource.getName().equals("RegistrationHandler.java")) { //$NON-NLS-1$ + /* + * Computes the class name + */ + Matcher m3 = Pattern.compile("[^;]*package\\s+([^;]+);.*").matcher(fileContent); //$NON-NLS-1$ + if (m3.matches()) { + String packageName = m3.group(1); + + String fileName = pResource.getName(); + className = fileName.substring(0, fileName.length() - ".java".length()); //$NON-NLS-1$ + + className = packageName + "." + className; //$NON-NLS-1$ + } + } + + } catch (Exception e) { + // nothing to log + } finally { + try { + reader.close(); + in.close(); + } catch (Exception e) { + } + } + } + + return className; + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/JavaUnoResourceChangeHandler.java b/python/source/org/libreoffice/ide/eclipse/python/JavaUnoResourceChangeHandler.java new file mode 100644 index 0000000..7618cf0 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/JavaUnoResourceChangeHandler.java @@ -0,0 +1,80 @@ +/************************************************************************* + * + * $RCSfile: JavaUnoResourceChangeHandler.java,v $ + * + * $Revision: 1.3 $ + * + * last change: $Author: cedricbosdo $ $Date: 2007/11/25 20:32:38 $ + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * Sun Microsystems Inc., October, 2000 + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): Cedric Bosdonnat + * + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python; + +import org.eclipse.core.resources.IResourceChangeEvent; +import org.eclipse.core.resources.IResourceChangeListener; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.ui.IStartup; +import org.libreoffice.ide.eclipse.core.PluginLogger; + +/** + * This class is responsible for reacting to the changes on the Java resources + * in UNO projects. Its main activity is to maintain the implementation classes + * list for the services registration. + */ +public class JavaUnoResourceChangeHandler implements IStartup, IResourceChangeListener { + + /** + * {@inheritDoc} + */ + @Override + public void earlyStartup() { + // Start listening the java resources changes + ResourcesPlugin.getWorkspace().addResourceChangeListener(this); + PluginLogger.info("Java UNO resources changes are now listened"); //$NON-NLS-1$ + } + + /** + * {@inheritDoc} + */ + @Override + public void resourceChanged(IResourceChangeEvent pEvent) { + try { + pEvent.getDelta().accept(new JavaResourceDeltaVisitor()); + } catch (Exception e) { + // Do nothing + } + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/Language.java b/python/source/org/libreoffice/ide/eclipse/python/Language.java new file mode 100644 index 0000000..253a494 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/Language.java @@ -0,0 +1,124 @@ +/************************************************************************* + * + * $RCSfile: Language.java,v $ + * + * $Revision: 1.6 $ + * + * last change: $Author: cedricbosdo $ $Date: 2007/11/25 20:32:38 $ + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * Sun Microsystems Inc., October, 2000 + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): Cedric Bosdonnat + * + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.sourcelookup.ISourcePathComputer; +import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; +import org.eclipse.jdt.launching.IVMConnector; +import org.eclipse.jdt.launching.JavaRuntime; +import org.libreoffice.ide.eclipse.core.PluginLogger; +import org.libreoffice.ide.eclipse.core.launch.office.IOfficeLaunchConstants; +import org.libreoffice.ide.eclipse.core.model.IUnoidlProject; +import org.libreoffice.ide.eclipse.core.model.language.AbstractLanguage; +import org.libreoffice.ide.eclipse.core.model.language.ILanguageBuilder; +import org.libreoffice.ide.eclipse.core.model.language.IProjectHandler; + +/** + * Implementation for the Java language. + */ +public class Language extends AbstractLanguage { + + private static final String DEFAULT_JAVA_DEBUG_PORT = "7861"; + + /** + * {@inheritDoc} + */ + @Override + public ILanguageBuilder getLanguageBuidler() { + return new PythonBuilder(this); + } + + /** + * {@inheritDoc} + */ + @Override + public IProjectHandler getProjectHandler() { + return new PythonProjectHandler(); + } + + /** + * {@inheritDoc} + */ + @Override + public void connectDebuggerToOffice(IUnoidlProject pPrj, ILaunch pLaunch, IPath pUserInstallation, + IProgressMonitor pMonitor) { + + try { + // org.eclipse.jdt.launching.socketListenConnector + // SocketListenConnector + String connectorId = "org.eclipse.jdt.launching.socketListenConnector"; + IVMConnector connector = JavaRuntime.getVMConnector(connectorId); + Map argMap = new HashMap<>(); + argMap.put("timeout", "80000"); + //FIXME implement some kind of port pickup/retry mechanism in case the default port is already used. + argMap.put("port", DEFAULT_JAVA_DEBUG_PORT); + + connector.connect(argMap, pMonitor, pLaunch); + + pPrj.getOOo().runOffice(pPrj, pLaunch, pUserInstallation, + new JavaDebugExtraOptionsProvider(DEFAULT_JAVA_DEBUG_PORT), pMonitor); + } catch (Exception e) { + PluginLogger.error("Could not start remote debugger.", e); + } + } + + @Override + public void configureSourceLocator(ILaunchConfigurationWorkingCopy pConfiguration) throws CoreException { + String projectName = pConfiguration.getAttribute(IOfficeLaunchConstants.PROJECT_NAME, ""); + pConfiguration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, + "org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"); + pConfiguration.setAttribute(ISourcePathComputer.ATTR_SOURCE_PATH_COMPUTER_ID, + "org.eclipse.jdt.launching.sourceLookup.javaSourcePathComputer"); + pConfiguration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName); + }; +} \ No newline at end of file diff --git a/python/source/org/libreoffice/ide/eclipse/python/Messages.java b/python/source/org/libreoffice/ide/eclipse/python/Messages.java new file mode 100644 index 0000000..3a4bbfe --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/Messages.java @@ -0,0 +1,79 @@ +/************************************************************************* + * + * $RCSfile: Messages.java,v $ + * + * $Revision: 1.3 $ + * + * last change: $Author: cedricbosdo $ $Date: 2007/11/25 20:32:38 $ + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * Sun Microsystems Inc., October, 2000 + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): Cedric Bosdonnat + * + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * Messages for the package. + */ +public class Messages { + private static final String BUNDLE_NAME = "org.libreoffice.ide.eclipse.python.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + /** + * Default constructor. + */ + private Messages() { + } + + /** + * Get the string from it's key. + * + * @param pKey the key of the string + * + * @return the internationalized string + */ + public static String getString(String pKey) { + String string = '!' + pKey + '!'; + try { + string = RESOURCE_BUNDLE.getString(pKey); + } catch (MissingResourceException e) { + } + return string; + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/OOoJavaPlugin.java b/python/source/org/libreoffice/ide/eclipse/python/OOoJavaPlugin.java new file mode 100644 index 0000000..de9cf76 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/OOoJavaPlugin.java @@ -0,0 +1,121 @@ +/************************************************************************* + * + * $RCSfile: OOoJavaPlugin.java,v $ + * + * $Revision: 1.4 $ + * + * last change: $Author: cedricbosdo $ $Date: 2007/11/25 20:32:38 $ + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * Sun Microsystems Inc., October, 2000 + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): Cedric Bosdonnat + * + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The main plugin class to be used in the desktop. + */ +public class OOoJavaPlugin extends AbstractUIPlugin { + + public static final String PLUGIN_ID = "org.libreoffice.ide.eclipse.java"; //$NON-NLS-1$ + public static final String WIZBAN = "wizban"; //$NON-NLS-1$ + public static final String LIBS_DIR = "lib/"; //$NON-NLS-1$ + + //The shared instance. + private static OOoJavaPlugin sPlugin; + + /** + * The constructor. + */ + public OOoJavaPlugin() { + sPlugin = this; + } + + /** + * This method is called upon plug-in activation. + * + * @param pContext the bundle context + * @throws Exception if the plugin can't be started + */ + @Override + public void start(BundleContext pContext) throws Exception { + super.start(pContext); + } + + /** + * This method is called when the plug-in is stopped. + * + * @param pContext the bundle context + * @throws Exception if the plugin can't be stopped + */ + @Override + public void stop(BundleContext pContext) throws Exception { + super.stop(pContext); + sPlugin = null; + } + + /** + * @return the shared instance. + */ + public static OOoJavaPlugin getDefault() { + return sPlugin; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path. + * + * @param pPath the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String pPath) { + return AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, pPath); + } + + /** + * @return the image registry of the plugin. + */ + @Override + protected ImageRegistry createImageRegistry() { + ImageRegistry reg = super.createImageRegistry(); + + reg.put(WIZBAN, getImageDescriptor("/icons/java_app_wiz.png")); //$NON-NLS-1$ + return reg; + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/PythonBuilder.java b/python/source/org/libreoffice/ide/eclipse/python/PythonBuilder.java new file mode 100644 index 0000000..891d542 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/PythonBuilder.java @@ -0,0 +1,322 @@ +/************************************************************************* + * + * $RCSfile: JavaBuilder.java,v $ + * + * $Revision: 1.7 $ + * + * last change: $Author: cedricbosdo $ $Date: 2008/12/13 13:43:02 $ + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * Sun Microsystems Inc., October, 2000 + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): Cedric Bosdonnat + * + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python; + +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.LineNumberReader; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.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.core.JavaModelException; +import org.eclipse.jdt.launching.IVMInstall; +import org.eclipse.jdt.launching.JavaRuntime; +import org.eclipse.jdt.ui.jarpackager.IJarExportRunnable; +import org.eclipse.jdt.ui.jarpackager.JarPackageData; +import org.libreoffice.ide.eclipse.core.PluginLogger; +import org.libreoffice.ide.eclipse.core.model.IUnoidlProject; +import org.libreoffice.ide.eclipse.core.model.ProjectsManager; +import org.libreoffice.ide.eclipse.core.model.config.IOOo; +import org.libreoffice.ide.eclipse.core.model.config.ISdk; +import org.libreoffice.ide.eclipse.core.model.language.ILanguageBuilder; +import org.libreoffice.ide.eclipse.core.model.utils.SystemHelper; +import org.libreoffice.ide.eclipse.python.build.FilesVisitor; +import org.libreoffice.ide.eclipse.python.build.UnoManifestProvider; +import org.libreoffice.plugin.core.model.UnoPackage; + +/** + * The language builder implementation for Java. + */ +public class PythonBuilder implements ILanguageBuilder { + + private Language mLanguage; + + /** + * Constructor. + * + * @param pLanguage the Java Language object + */ + public PythonBuilder(Language pLanguage) { + mLanguage = pLanguage; + } + + /** + * {@inheritDoc} + */ + @Override + public IFile createLibrary(IUnoidlProject pUnoProject) throws Exception { + IFile jarFile = ((PythonProjectHandler) mLanguage.getProjectHandler()).getJarFile(pUnoProject); + + // Add all the jar dependencies + IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject(pUnoProject.getName()); + IJavaProject javaPrj = JavaCore.create(prj); + List externalJars = getLibs(javaPrj); + + JarPackageData description = new JarPackageData(); + description.setGenerateManifest(true); + description.setJarLocation(jarFile.getLocation()); + + String regClassname = ((PythonProjectHandler) mLanguage.getProjectHandler()) + .getRegistrationClassName(pUnoProject); + description.setManifestProvider(new UnoManifestProvider(regClassname, pUnoProject, externalJars)); + description.setManifestLocation(pUnoProject.getFile("MANIFEST.MF").getFullPath()); //$NON-NLS-1$ + description.setSaveManifest(false); + description.setReuseManifest(false); + description.setExportOutputFolders(true); + description.setExportClassFiles(true); + description.setExportWarnings(true); + description.setOverwrite(true); + + // Get the files to export: javamaker output + project classes + FilesVisitor visitor = new FilesVisitor(); + visitor.addException(pUnoProject.getFolder(pUnoProject.getUrdPath())); + + IFolder buildDir = pUnoProject.getFolder(pUnoProject.getBuildPath()); + buildDir.accept(visitor); + description.setElements(visitor.getFiles()); + + // Create the Jar file + IJarExportRunnable runnable = description.createJarExportRunnable(null); + runnable.run(new NullProgressMonitor()); + + return jarFile; + } + + /** + * {@inheritDoc} + */ + @Override + public void generateFromTypes(ISdk pSdk, IOOo pOoo, IProject pPrj, File pTypesFile, + File pBuildFolder, String pRootModule, IProgressMonitor pMonitor) { + + if (pTypesFile.exists()) { + + if (null != pSdk && null != pOoo) { + + String[] paths = pOoo.getTypesPath(); + String oooTypesArgs = ""; //$NON-NLS-1$ + for (String path : paths) { + IPath ooTypesPath = new Path(path); + oooTypesArgs += " -X\"" + ooTypesPath.toOSString() + "\""; //$NON-NLS-1$ //$NON-NLS-2$ + } + + // TODO What if the user creates other root modules ? + String firstModule = pRootModule.split("::")[0]; //$NON-NLS-1$ + + runJavamaker(firstModule, oooTypesArgs, pSdk, pPrj, pTypesFile, pBuildFolder, pMonitor); + } + } + } + + private void runJavamaker(String firstModule, String oooTypesArgs, + ISdk pSdk, IProject pPrj, File pTypesFile, + File pBuildFolder, IProgressMonitor pMonitor) { + + StringBuffer errBuf = new StringBuffer(); + try { + String cmdPattern = "javamaker -T {0}.* -nD -Gc -O {1} \"{2}\" {3}"; //$NON-NLS-1$ + String command = MessageFormat.format(cmdPattern, firstModule, + pBuildFolder.getAbsolutePath(), + pTypesFile.getAbsolutePath(), + oooTypesArgs); + + IUnoidlProject unoprj = ProjectsManager.getProject(pPrj.getName()); + Process process = pSdk.runTool(unoprj, command, pMonitor); + + process.waitFor(); + + LineNumberReader lineReader = new LineNumberReader( + new InputStreamReader(process.getErrorStream())); + + String line = lineReader.readLine(); + while (null != line) { + errBuf.append(line + '\n'); + line = lineReader.readLine(); + } + + PluginLogger.debug(errBuf.toString()); + } catch (InterruptedException e) { + PluginLogger.error( + Messages.getString("Language.CreateCodeError"), e); //$NON-NLS-1$ + } catch (IOException e) { + PluginLogger.warning( + Messages.getString("Language.UnreadableOutputError")); //$NON-NLS-1$ + } + } + + /** + * {@inheritDoc} + */ + @Override + public String[] getBuildEnv(IUnoidlProject pUnoProject) { + + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(pUnoProject.getName()); + + String[] env = new String[2]; + + // compute the classpath for the project's OOo instance + String classpath = "CLASSPATH="; //$NON-NLS-1$ + String sep = System.getProperty("path.separator"); //$NON-NLS-1$ + + File javaHomeFile = null; + + // Compute the classpath for the project dependencies + IJavaProject javaProject = JavaCore.create(project); + if (javaProject != null) { + try { + IClasspathEntry[] cpEntry = javaProject.getResolvedClasspath(true); + for (int i = 0; i < cpEntry.length; i++) { + IClasspathEntry entry = cpEntry[i]; + + // Transform into the correct path for the entry. + if (entry.getEntryKind() != IClasspathEntry.CPE_SOURCE) { + classpath += entry.getPath().toOSString(); + } + if (i < cpEntry.length - 1) { + classpath += sep; + } + } + + IVMInstall vmInstall = JavaRuntime.getVMInstall(javaProject); + javaHomeFile = vmInstall.getInstallLocation(); + + } catch (JavaModelException e) { + PluginLogger.error( + Messages.getString("Language.GetClasspathError"), e); //$NON-NLS-1$ + } catch (CoreException e) { + // TODO log a problem to find the JVM associated to the project + } + } + + env[0] = classpath; + if (javaHomeFile != null) { + String libs = ""; //$NON-NLS-1$ + String filesep = System.getProperty("file.separator"); //$NON-NLS-1$ + try { + String arch = System.getProperty("os.arch"); //$NON-NLS-1$ + libs = javaHomeFile.getCanonicalPath() + filesep + "lib" + filesep + arch; //$NON-NLS-1$ + } catch (IOException e) { + } + env[1] = "LD_LIBRARY_PATH=" + libs; //$NON-NLS-1$ + } + + return env; + } + + /** + * {@inheritDoc} + */ + @Override + public void fillUnoPackage(UnoPackage pUnoPackage, IUnoidlProject pUnoPrj) { + // Add the component Jar file + PythonProjectHandler handler = (PythonProjectHandler) mLanguage.getProjectHandler(); + File libFile = SystemHelper.getFile(handler.getJarFile(pUnoPrj)); + File prjFile = SystemHelper.getFile(pUnoPrj); + + pUnoPackage.addComponentFile( + UnoPackage.getPathRelativeToBase(libFile, prjFile), + libFile, "Java"); //$NON-NLS-1$ + + // Add all the jar dependencies + IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject(pUnoPrj.getName()); + IJavaProject javaPrj = JavaCore.create(prj); + ArrayList libs = getLibs(javaPrj); + for (IFile lib : libs) { + File jarFile = SystemHelper.getFile(lib); + pUnoPackage.addOtherFile(UnoPackage.getPathRelativeToBase(jarFile, prjFile), jarFile); + } + + } + + /** + * Get the libraries in the classpath that are located in the project + * directory or one of its subfolder. + * + * @param pJavaPrj the project from which to extract the libraries + * @return a list of all the File pointing to the libraries. + */ + private ArrayList getLibs(IJavaProject pJavaPrj) { + ArrayList libs = new ArrayList(); + try { + IClasspathEntry[] entries = pJavaPrj.getResolvedClasspath(true); + for (IClasspathEntry entry : entries) { + if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) { + /* + * At first, add only the libraries located in the project + * or one of its children. All others libraries have to be + * managed by the user. + */ + IPath path = entry.getPath(); + if (!new File(path.toOSString()).exists() && path.isAbsolute() && + path.toString().startsWith("/" + pJavaPrj.getProject().getName())) { //$NON-NLS-1$ + // Relative to the project + IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); + if (file != null && file.exists()) { + libs.add(file); + } + } + } + } + + } catch (JavaModelException e) { + // Enable to add some missing library + } + + return libs; + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/PythonProjectHandler.java b/python/source/org/libreoffice/ide/eclipse/python/PythonProjectHandler.java new file mode 100644 index 0000000..634e9c4 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/PythonProjectHandler.java @@ -0,0 +1,387 @@ +/************************************************************************* + * + * $RCSfile: JavaProjectHandler.java,v $ + * + * $Revision: 1.10 $ + * + * last change: $Author: cedricbosdo $ $Date: 2008/12/13 13:43:02 $ + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * Sun Microsystems Inc., October, 2000 + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): Cedric Bosdonnat + * + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Vector; + +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathException; +import javax.xml.xpath.XPathExpression; +import javax.xml.xpath.XPathFactory; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +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.IProgressMonitor; +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.core.JavaModelException; +import org.eclipse.jdt.launching.JavaRuntime; +import org.libreoffice.ide.eclipse.core.PluginLogger; +import org.libreoffice.ide.eclipse.core.model.IUnoFactoryConstants; +import org.libreoffice.ide.eclipse.core.model.IUnoidlProject; +import org.libreoffice.ide.eclipse.core.model.ProjectsManager; +import org.libreoffice.ide.eclipse.core.model.UnoFactoryData; +import org.libreoffice.ide.eclipse.core.model.config.IOOo; +import org.libreoffice.ide.eclipse.core.model.language.IProjectHandler; +import org.libreoffice.ide.eclipse.python.build.OOoContainerPage; +import org.libreoffice.ide.eclipse.python.registration.RegistrationHelper; +import org.libreoffice.ide.eclipse.python.tests.TestsHelper; +import org.w3c.dom.Node; +import org.xml.sax.InputSource; + +/** + * The Project handler implementation for Java. + */ +public class PythonProjectHandler implements IProjectHandler { + + private static final String P_REGISTRATION_CLASSNAME = "regclassname"; //$NON-NLS-1$ + private static final String P_JAVA_VERSION = "javaversion"; //$NON-NLS-1$ + + private static final String[] KEPT_JARS = { "unoil.jar", //$NON-NLS-1$ + "ridl.jar", //$NON-NLS-1$ + "juh.jar", //$NON-NLS-1$ + "jurt.jar", //$NON-NLS-1$ + "unoloader.jar", //$NON-NLS-1$ + "officebean.jar" //$NON-NLS-1$ + }; + + /** + * {@inheritDoc} + */ + @Override + public void addOOoDependencies(IOOo pOoo, IProject pProject) { + + // IJavaProject javaProject = JavaCore.create(pProject); + // + // OOoContainerPage.addOOoDependencies(pOoo, javaProject); + } + + /** + * {@inheritDoc} + */ + @Override + public void addProjectNature(IProject pProject) { + // try { + // if (!pProject.exists()) { + // pProject.create(null); + // PluginLogger.debug("Project created during language specific operation"); //$NON-NLS-1$ + // } + // + // if (!pProject.isOpen()) { + // pProject.open(null); + // PluginLogger.debug("Project opened"); //$NON-NLS-1$ + // } + // + // IProjectDescription description = pProject.getDescription(); + // String[] natureIds = description.getNatureIds(); + // String[] newNatureIds = new String[natureIds.length + 1]; + // System.arraycopy(natureIds, 0, newNatureIds, 0, natureIds.length); + // + // // Adding the nature + // newNatureIds[natureIds.length] = JavaCore.NATURE_ID; + // + // description.setNatureIds(newNatureIds); + // pProject.setDescription(description, null); + // PluginLogger.debug(Messages.getString("Language.JavaNatureSet")); //$NON-NLS-1$ + // + // } catch (CoreException e) { + // PluginLogger.error(Messages.getString("Language.NatureSettingFailed")); //$NON-NLS-1$ + // } + } + + /** + * {@inheritDoc} + */ + @Override + public void configureProject(UnoFactoryData pData, IProgressMonitor pMonitor) throws Exception { + + // Get the project from data + IProject prj = (IProject) pData.getProperty(IUnoFactoryConstants.PROJECT_HANDLE); + IUnoidlProject unoprj = ProjectsManager.getProject(prj.getName()); + + // Set some properties on the project + + // The registration class name is always computed in the same way + // String regclass = RegistrationHelper.getRegistrationClassName(unoprj); + // unoprj.setProperty(P_REGISTRATION_CLASSNAME, regclass); + + // // Java version + // String javaversion = (String) pData.getProperty(PythonWizardPage.JAVA_VERSION); + // unoprj.setProperty(P_JAVA_VERSION, javaversion); + + // IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(unoprj.getName()); + // + // // Create the project structure + // IJavaProject javaProject = JavaCore.create(project); + // javaProject.open(pMonitor); + // + // IPath sourcePath = unoprj.getFolder(unoprj.getSourcePath()).getFullPath(); + // IPath buildPath = unoprj.getFolder(unoprj.getBuildPath()).getFullPath(); + // System.out.println("SourcePath::" + sourcePath + "BuildPath::" + buildPath); + // + // IClasspathEntry[] entries = new IClasspathEntry[] { JavaCore.newSourceEntry(sourcePath), + // JavaRuntime.getDefaultJREContainerEntry(), + // JavaCore.newLibraryEntry(buildPath, null, null, false) }; + // + // javaProject.setRawClasspath(entries, pMonitor); + // + // // Add the registration files + // RegistrationHelper.generateFiles(unoprj); + // + // // Tests creation + // Boolean usetests = (Boolean) pData.getProperty(PythonWizardPage.JAVA_TESTS); + // if (usetests.booleanValue()) { + // TestsHelper.writeTestClasses(unoprj); + // + // IJavaProject javaprj = JavaCore.create(prj); + // TestsHelper.addJUnitLibraries(javaprj); + // } + } + + /** + * {@inheritDoc} + */ + @Override + public String getImplementationName(IUnoidlProject pPrj, String pService) throws Exception { + String prefix = pPrj.getCompanyPrefix(); + String comp = pPrj.getOutputExtension(); + + String implementationName = null; + + if (pService.startsWith(prefix)) { + String localName = pService.substring(prefix.length()); + implementationName = prefix + "." + comp + localName + "Impl"; //$NON-NLS-1$ //$NON-NLS-2$ + } else { + throw new Exception("Cannot find implementation name for service: " + pService); //$NON-NLS-1$ + } + + return implementationName; + } + + /** + * {@inheritDoc} + */ + @Override + public IPath getImplementationFile(String pImplementationName) { + + return new Path(pImplementationName.replace(".", "/") + ".java"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + } + + /** + * {@inheritDoc} + */ + @Override + public String getSkeletonMakerLanguage(UnoFactoryData pData) throws Exception { + // Get the project from data + String name = (String) pData.getProperty(IUnoFactoryConstants.PROJECT_NAME); + IUnoidlProject unoprj = ProjectsManager.getProject(name); + + return "--" + unoprj.getProperty(P_JAVA_VERSION); //$NON-NLS-1$ + } + + /** + * {@inheritDoc} + */ + @Override + public void removeOOoDependencies(IOOo pOoo, IProject pProject) { + // IJavaProject javaProject = JavaCore.create(pProject); + // + // OOoContainerPage.removeOOoDependencies(javaProject); + } + + /** + * {@inheritDoc} + */ + @Override + public String getLibraryPath(IUnoidlProject pProject) { + return getJarFile(pProject).getLocation().toOSString(); + } + + /** + * Returns a handle to the project jar file. Beware that this handle may refer to a non-existing file. Users have to + * create it if necessary. + * + * @param pProject + * the concerned UNO project + * @return a handle to the jar file of the project + */ + public IFile getJarFile(IUnoidlProject pProject) { + String filename = pProject.getName().replace(" ", "") + ".jar"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + return pProject.getFile(filename); + } + + /** + * Returns a handle to the project jar file. Beware that this handle may refer to a non-existing file. Users have to + * create it if necessary. + * + * @param pProjectDir + * the concerned UNO project directory + * @return a handle to the jar file of the project + */ + public File getJarFile(File pProjectDir) throws IOException, XPathException { + String filename = getName(pProjectDir).replace(" ", "") + ".jar"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + return new File(pProjectDir, filename); + } + + private String getName(File projectDir) throws IOException, XPathException { + File projectFile = new File(projectDir, ".project"); + if (!projectFile.exists()) { + return null; + } + final FileInputStream byteStream = new FileInputStream(projectFile); + InputSource source = new InputSource(byteStream); + + // evaluation de l'expression XPath + XPathFactory factory = XPathFactory.newInstance(); + javax.xml.xpath.XPath xpath = factory.newXPath(); + final String xPathExpr = "//projectDescription/name"; + XPathExpression exp = xpath.compile(xPathExpr); + Node node = (Node) exp.evaluate(source, XPathConstants.NODE); + if (node == null) { + return null; + } + return node.getTextContent(); + } + + /** + * Get the UNO registration class name of the project. + * + * @param pProject + * the project for witch to get the registration class. + * + * @return the registration class name + */ + public String getRegistrationClassName(IUnoidlProject pProject) { + return pProject.getProperty(P_REGISTRATION_CLASSNAME); + } + + /** + * {@inheritDoc} + */ + @Override + public IFolder[] getBinFolders(IUnoidlProject pUnoidlProject) { + ArrayList folders = new ArrayList(); + + IWorkspaceRoot workspace = ResourcesPlugin.getWorkspace().getRoot(); + IProject prj = workspace.getProject(pUnoidlProject.getName()); + IJavaProject javaPrj = JavaCore.create(prj); + try { + folders.add(workspace.getFolder(javaPrj.getOutputLocation())); + + IClasspathEntry[] entries = javaPrj.getRawClasspath(); + for (IClasspathEntry entry : entries) { + if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE && entry.getOutputLocation() != null) { + folders.add(workspace.getFolder(entry.getOutputLocation())); + } + } + } catch (JavaModelException e) { + } + + return folders.toArray(new IFolder[folders.size()]); + } + + // --------------------------------------------- Jar finding private methods + + /** + * returns the path of all the kept jars contained in the folder pointed by path. + * + * @param pOoo + * the OOo instance from which to get the jars + * @return a vector of Path pointing to each jar. + */ + public static Vector findJarsFromPath(IOOo pOoo) { + Vector jarsPath = new Vector(); + + String[] paths = pOoo.getClassesPath(); + for (String path : paths) { + Path folderPath = new Path(path); + File programFolder = folderPath.toFile(); + + String[] content = programFolder.list(); + for (int i = 0, length = content.length; i < length; i++) { + String contenti = content[i]; + if (isKeptJar(contenti)) { + Path jariPath = new Path(path + "/" + contenti); //$NON-NLS-1$ + jarsPath.add(jariPath); + } + } + } + + return jarsPath; + } + + /** + * Check if the specified jar file is one of those define in the KEPT_JARS constant. + * + * @param pJarName + * name of the jar file to check + * @return true if jarName is one of those defined in KEPT_JARS, false otherwise. + */ + private static boolean isKeptJar(String pJarName) { + + int i = 0; + boolean isKept = false; + + while (i < KEPT_JARS.length && !isKept) { + if (pJarName.equals(KEPT_JARS[i])) { + isKept = true; + } else { + i++; + } + } + return isKept; + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/PythonWizardPage.java b/python/source/org/libreoffice/ide/eclipse/python/PythonWizardPage.java new file mode 100644 index 0000000..e6d0d11 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/PythonWizardPage.java @@ -0,0 +1,125 @@ +/************************************************************************* + * + * $RCSfile: PythonWizardPage.java,v $ + * + * $Revision: 1.5 $ + * + * last change: $Author: cedricbosdo $ $Date: 2007/11/25 20:32:38 $ + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * Sun Microsystems Inc., October, 2000 + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): Cedric Bosdonnat + * + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.libreoffice.ide.eclipse.core.gui.rows.BooleanRow; +import org.libreoffice.ide.eclipse.core.gui.rows.FieldEvent; +import org.libreoffice.ide.eclipse.core.gui.rows.IFieldChangedListener; +import org.libreoffice.ide.eclipse.core.model.UnoFactoryData; +import org.libreoffice.ide.eclipse.core.model.language.LanguageWizardPage; + +/** + * Java configuration page of the new UNO project wizard. + */ +public class PythonWizardPage extends LanguageWizardPage { + + public static final String JAVA_VERSION = "java_version"; //$NON-NLS-1$ + public static final String JAVA_TESTS = "java_tests"; //$NON-NLS-1$ + + private BooleanRow mJavaTestsRow; + + private boolean mUseTests; + + /** + * Constructor. + */ + public PythonWizardPage() { + super(); + setImageDescriptor(OOoJavaPlugin.getDefault().getImageRegistry().getDescriptor(OOoJavaPlugin.WIZBAN)); + setTitle(Messages.getString("PythonWizardPage.PageTitle")); //$NON-NLS-1$ + setDescription(Messages.getString("PythonWizardPage.PageDescription")); //$NON-NLS-1$ + } + + /** + * {@inheritDoc} + */ + @Override + public void setProjectInfos(UnoFactoryData pData) { + // default value + mUseTests = true; + } + + /** + * {@inheritDoc} + */ + @Override + public UnoFactoryData fillData(UnoFactoryData pData) { + + if (pData != null) { + pData.setProperty(JAVA_VERSION, "java5"); // default java version + pData.setProperty(JAVA_TESTS, mUseTests); + } + + return pData; + } + + /** + * {@inheritDoc} + */ + @Override + public void createControl(Composite pParent) { + + Composite body = new Composite(pParent, SWT.NONE); + body.setLayout(new GridLayout(1, false)); + body.setLayoutData(new GridData(GridData.FILL_BOTH)); + + // Create the test row + mJavaTestsRow = new BooleanRow(body, JAVA_TESTS, + Messages.getString("PythonWizardPage.IncludeTestClasses")); //$NON-NLS-1$ + mJavaTestsRow.setValue(true); + mJavaTestsRow.setFieldChangedListener(new IFieldChangedListener() { + + @Override + public void fieldChanged(FieldEvent pEvent) { + mUseTests = mJavaTestsRow.getBooleanValue(); + } + }); + + setControl(body); + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/build/FilesVisitor.java b/python/source/org/libreoffice/ide/eclipse/python/build/FilesVisitor.java new file mode 100644 index 0000000..cd14520 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/build/FilesVisitor.java @@ -0,0 +1,84 @@ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2009 by Cédric Bosdonnat + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Cédric Bosdonnat. + * + * Copyright: 2009 by Cédric Bosdonnat + * + * All Rights Reserved. + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.build; + +import java.util.ArrayList; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IResourceVisitor; +import org.eclipse.core.runtime.CoreException; + +/** + * Resource visitor collecting the files of a directory. + */ +public class FilesVisitor implements IResourceVisitor { + + ArrayList mFiles = new ArrayList(); + ArrayList mExceptions = new ArrayList(); + + /** + * Adds a resource to skip during the visit. + * + * @param pRes the resource to skip + */ + public void addException(IResource pRes) { + mExceptions.add(pRes); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean visit(IResource pResource) throws CoreException { + + if (pResource.getType() == IResource.FILE) { + mFiles.add((IFile) pResource); + } + + boolean visitChildren = true; + + int i = 0; + while (visitChildren && i < mExceptions.size()) { + visitChildren = !mExceptions.get(i).equals(pResource); + i++; + } + + return visitChildren; + } + + /** + * @return all the files found during the visit. + */ + public IFile[] getFiles() { + return mFiles.toArray(new IFile[mFiles.size()]); + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/build/Messages.java b/python/source/org/libreoffice/ide/eclipse/python/build/Messages.java new file mode 100644 index 0000000..fe36471 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/build/Messages.java @@ -0,0 +1,66 @@ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2009 by Novell, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Cédric Bosdonnat. + * + * Copyright: 2009 by Novell, Inc. + * + * All Rights Reserved. + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.build; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * Messages for the package. + */ +public class Messages { + private static final String BUNDLE_NAME = "org.libreoffice.ide.eclipse.python.build.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + /** + * Default constructor. + */ + private Messages() { + } + + /** + * Get the string from it's key. + * + * @param pKey the key of the string + * + * @return the internationalized string + */ + public static String getString(String pKey) { + String string = '!' + pKey + '!'; + try { + string = RESOURCE_BUNDLE.getString(pKey); + } catch (MissingResourceException e) { + } + return string; + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/build/OOoClasspathContainer.java b/python/source/org/libreoffice/ide/eclipse/python/build/OOoClasspathContainer.java new file mode 100644 index 0000000..d6717b8 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/build/OOoClasspathContainer.java @@ -0,0 +1,119 @@ +/************************************************************************* + * + * $RCSfile: OOoClasspathContainer.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: cedricbosdo $ $Date: 2007/12/26 14:40:18 $ + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * Sun Microsystems Inc., October, 2000 + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): Cedric Bosdonnat + * + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.build; + +import java.text.MessageFormat; +import java.util.Vector; + +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.JavaCore; +import org.libreoffice.ide.eclipse.core.model.config.IOOo; +import org.libreoffice.ide.eclipse.python.PythonProjectHandler; + +/** + * Container for the OOo classes jars. + */ +public class OOoClasspathContainer implements IClasspathContainer { + + public static final String ID = "org.libreoffice.ide.eclipse.java.OOO_CONTAINER"; //$NON-NLS-1$ + + private IOOo mOOo; + + private IPath mPath; + + /** + * Constructor. + * + * @param pOoo the OOo represented by the container. + * @param pPath the path used for the container. + */ + public OOoClasspathContainer(IOOo pOoo, IPath pPath) { + mOOo = pOoo; + mPath = pPath; + } + + /** + * {@inheritDoc} + */ + @Override + public IClasspathEntry[] getClasspathEntries() { + Vector jars = PythonProjectHandler.findJarsFromPath(mOOo); + Vector entries = new Vector(); + + for (Path path : jars) { + entries.add(JavaCore.newLibraryEntry(path, null, null)); + } + return entries.toArray(new IClasspathEntry[entries.size()]); + } + + /** + * {@inheritDoc} + */ + @Override + public String getDescription() { + String pattern = Messages.getString("OOoClasspathContainer.LibrariesName"); //$NON-NLS-1$ + String descr = MessageFormat.format(pattern, mOOo.getName()); + return descr; + } + + /** + * {@inheritDoc} + */ + @Override + public int getKind() { + return K_APPLICATION; + } + + /** + * {@inheritDoc} + */ + @Override + public IPath getPath() { + return mPath; + } + +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/build/OOoContainerPage.java b/python/source/org/libreoffice/ide/eclipse/python/build/OOoContainerPage.java new file mode 100644 index 0000000..7450c0d --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/build/OOoContainerPage.java @@ -0,0 +1,266 @@ +/************************************************************************* + * + * $RCSfile: OOoContainerPage.java,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: cedricbosdo $ $Date: 2007/12/26 14:40:18 $ + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * Sun Microsystems Inc., October, 2000 + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): Cedric Bosdonnat + * + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.build; + +import java.util.Vector; + +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.core.JavaModelException; +import org.eclipse.jdt.ui.wizards.IClasspathContainerPage; +import org.eclipse.jdt.ui.wizards.IClasspathContainerPageExtension; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.libreoffice.ide.eclipse.core.PluginLogger; +import org.libreoffice.ide.eclipse.core.gui.rows.OOoRow; +import org.libreoffice.ide.eclipse.core.model.IUnoidlProject; +import org.libreoffice.ide.eclipse.core.model.OOoContainer; +import org.libreoffice.ide.eclipse.core.model.ProjectsManager; +import org.libreoffice.ide.eclipse.core.model.config.IOOo; +import org.libreoffice.ide.eclipse.python.OOoJavaPlugin; + +/** + * Edition and creation page for the LibreOffice libraries container. + */ +public class OOoContainerPage extends WizardPage implements + IClasspathContainerPage, IClasspathContainerPageExtension { + + private static final int LAYOUT_COLUMNS = 3; + + private static final String OOO = "ooo"; //$NON-NLS-1$ + + private IClasspathEntry mContainer; + private IJavaProject mProject; + + private OOoRow mOOoRow; + + /** + * Needed default constructor. + */ + public OOoContainerPage() { + super("oocontainer"); //$NON-NLS-1$ + + setTitle(Messages.getString("OOoContainerPage.DialogTitle")); //$NON-NLS-1$ + setDescription(Messages.getString("OOoContainerPage.DialogDescription")); //$NON-NLS-1$ + ImageDescriptor image = OOoJavaPlugin.getImageDescriptor( + Messages.getString("OOoContainerPage.DialogImage")); //$NON-NLS-1$ + setImageDescriptor(image); + + mContainer = getDefaultEntry(); + } + + /** + * @return the default OOo container path + */ + private IClasspathEntry getDefaultEntry() { + IClasspathEntry result = null; + + IOOo someOOo = OOoContainer.getSomeOOo(null); + if (someOOo != null) { + String name = someOOo.getName(); + IPath path = new Path(OOoClasspathContainer.ID + IPath.SEPARATOR + name); + result = JavaCore.newContainerEntry(path); + } + return result; + } + + /** + * {@inheritDoc} + */ + @Override + public boolean finish() { + boolean result = true; + try { + IOOo ooo = OOoContainer.getOOo(mOOoRow.getValue()); + + String prjName = mProject.getProject().getName(); + IUnoidlProject unoPrj = ProjectsManager.getProject(prjName); + if (unoPrj != null) { + // The project is a UNO project + unoPrj.setOOo(ooo); + unoPrj.saveAllProperties(); + } else { + // remove the previous libraries + removeOOoDependencies(mProject); + + // Add the new library + IPath path = new Path(OOoClasspathContainer.ID + IPath.SEPARATOR + ooo.getName()); + IClasspathEntry containerEntry = JavaCore.newContainerEntry(path); + setSelection(containerEntry); + } + } catch (Exception e) { + result = false; + } + return result; + } + + /** + * {@inheritDoc} + */ + @Override + public IClasspathEntry getSelection() { + return mContainer; + } + + /** + * {@inheritDoc} + */ + @Override + public void setSelection(IClasspathEntry pContainerEntry) { + mContainer = pContainerEntry; + + if (mContainer == null) { + mContainer = getDefaultEntry(); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void createControl(Composite pParent) { + Composite body = new Composite(pParent, SWT.NONE); + body.setLayout(new GridLayout(LAYOUT_COLUMNS, false)); + + // Add a list to select the OOo configuration. + String oooName = mContainer.getPath().segment( + OooClasspathContainerInitializer.HINT_SEGMENT); + IOOo ooo = OOoContainer.getOOo(oooName); + mOOoRow = new OOoRow(body, OOO, ooo); + + setControl(body); + } + + /** + * {@inheritDoc} + */ + @Override + public void initialize(IJavaProject pProject, IClasspathEntry[] pCurrentEntries) { + mProject = pProject; + + boolean found = false; + int i = 0; + while (i < pCurrentEntries.length && !found) { + IClasspathEntry entry = pCurrentEntries[i]; + if (entry.getPath().segment(0).startsWith(OOoClasspathContainer.ID)) { + found = true; + mContainer = entry; + } + i++; + } + } + + /** + * {@inheritDoc} + */ + @Override + public void dispose() { + mOOoRow.dispose(); + + super.dispose(); + } + + /** + * Add the LibreOffice common JARs to a projects build path. + * + * @param pOoo the ooo to use for the classpath + * @param pProject the project to change + */ + public static void addOOoDependencies(IOOo pOoo, IJavaProject pProject) { + + if (null != pOoo) { + try { + IClasspathEntry[] oldEntries = pProject.getRawClasspath(); + IClasspathEntry[] entries = new IClasspathEntry[oldEntries.length + 1]; + + System.arraycopy(oldEntries, 0, entries, 0, oldEntries.length); + + IPath path = new Path(OOoClasspathContainer.ID + IPath.SEPARATOR + pOoo.getName()); + IClasspathEntry containerEntry = JavaCore.newContainerEntry(path); + entries[entries.length - 1] = containerEntry; + + pProject.setRawClasspath(entries, null); + } catch (JavaModelException e) { + PluginLogger.error( + Messages.getString("OOoContainerPage.ClasspathSetFailed"), e); //$NON-NLS-1$ + } + } + } + + /** + * Remove all the OOo user libraries from the project build path. + * + * @param pProject the project to change + */ + public static void removeOOoDependencies(IJavaProject pProject) { + try { + IClasspathEntry[] entries = pProject.getRawClasspath(); + Vector newEntries = new Vector(); + + // Copy all the sources in a new entry container + for (int i = 0, length = entries.length; i < length; i++) { + IClasspathEntry entry = entries[i]; + + if (!entry.getPath().segment(0).equals(OOoClasspathContainer.ID)) { + newEntries.add(entry); + } + } + + IClasspathEntry[] result = new IClasspathEntry[newEntries.size()]; + result = newEntries.toArray(result); + + pProject.setRawClasspath(result, null); + + } catch (JavaModelException e) { + PluginLogger.error( + Messages.getString("OOoContainerPage.ClasspathSetFailed"), e); //$NON-NLS-1$ + } + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/build/OooClasspathContainerInitializer.java b/python/source/org/libreoffice/ide/eclipse/python/build/OooClasspathContainerInitializer.java new file mode 100644 index 0000000..2b924cf --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/build/OooClasspathContainerInitializer.java @@ -0,0 +1,96 @@ +/************************************************************************* + * + * $RCSfile: OooClasspathContainerInitializer.java,v $ + * + * $Revision: 1.3 $ + * + * last change: $Author: cedricbosdo $ $Date: 2009/04/20 06:15:53 $ + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * Sun Microsystems Inc., October, 2000 + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): Cedric Bosdonnat + * + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.build; + +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; +import org.libreoffice.ide.eclipse.core.model.OOoContainer; +import org.libreoffice.ide.eclipse.core.model.config.IOOo; + +/** + * Initializes a classpath container for OOo instances. + */ +public class OooClasspathContainerInitializer extends + ClasspathContainerInitializer { + + static final int HINT_SEGMENT = 1; + + /** + * {@inheritDoc} + */ + @Override + public void initialize(IPath pContainerPath, IJavaProject pProject) + throws CoreException { + + String hint = pContainerPath.segment(HINT_SEGMENT); + IOOo ooo = OOoContainer.getOOo(hint); + + if (ooo != null) { + OOoClasspathContainer container = new OOoClasspathContainer(ooo, pContainerPath); + + IJavaProject[] projects = new IJavaProject[] { pProject }; + IClasspathContainer[] containers = new IClasspathContainer[] { container }; + + JavaCore.setClasspathContainer(pContainerPath, projects, containers, null); + } + } + + /** + * Always allow container modification: it could be necessary to add additional OOo + * jars or set the sources path. + * + * @param pContainerPath the path of the container + * @param pProject the project for which to change the container + * + * @return always true + */ + @Override + public boolean canUpdateClasspathContainer(IPath pContainerPath, IJavaProject pProject) { + return true; + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/build/UnoManifestProvider.java b/python/source/org/libreoffice/ide/eclipse/python/build/UnoManifestProvider.java new file mode 100644 index 0000000..6a185d0 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/build/UnoManifestProvider.java @@ -0,0 +1,86 @@ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2009 by Novell, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Cédric Bosdonnat. + * + * Copyright: 2009 by Novell, Inc. + * + * All Rights Reserved. + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.build; + +import java.util.ArrayList; +import java.util.List; +import java.util.jar.Attributes; +import java.util.jar.Attributes.Name; +import java.util.jar.Manifest; + +import org.eclipse.core.resources.IFile; +import org.eclipse.jdt.internal.ui.jarpackager.ManifestProvider; +import org.eclipse.jdt.ui.jarpackager.JarPackageData; +import org.libreoffice.ide.eclipse.core.model.IUnoidlProject; +import org.libreoffice.ide.eclipse.core.model.utils.SystemHelper; +import org.libreoffice.plugin.core.model.UnoPackage; +import org.libreoffice.plugin.core.utils.FilenameUtils; + +/** + * Class providing the MANIFEST.MF contents to the Jar writer. + */ +@SuppressWarnings("restriction") +public class UnoManifestProvider extends ManifestProvider { + + private String mRegClass; + private IUnoidlProject mUnoProject; + private List mExternalJars; + + /** + * Constructor. + * + * @param pRegClassname the registration class name + */ + public UnoManifestProvider(String pRegClassname, IUnoidlProject unoProject, List externalJars) { + mRegClass = pRegClassname; + mUnoProject = unoProject; + mExternalJars = externalJars; + } + + /** + * {@inheritDoc} + */ + @Override + protected void putAdditionalEntries(Manifest pManifest, JarPackageData pJarPackage) { + Name regClassName = new Attributes.Name("RegistrationClassName"); //$NON-NLS-1$ + pManifest.getMainAttributes().put(regClassName, mRegClass); + + Name classPath = new Attributes.Name("Class-Path"); + List classPathList = new ArrayList<>(); + for (IFile file:mExternalJars) { + String relativePath = UnoPackage.getPathRelativeToBase(SystemHelper.getFile(file), + SystemHelper.getFile(mUnoProject)); + relativePath = FilenameUtils.separatorsToUnix(relativePath); + classPathList.add(relativePath); + } + pManifest.getMainAttributes().put(classPath, String.join(" ", classPathList)); + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/build/messages.properties b/python/source/org/libreoffice/ide/eclipse/python/build/messages.properties new file mode 100644 index 0000000..883ea22 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/build/messages.properties @@ -0,0 +1,8 @@ +JODContainerPage.SLF4JLabel=Add the SLF4J JDK14 implementation +JODContainerPage.Title=LibreOffice UNO Connector +OOoClasspathContainer.LibrariesName={0} libraries + +OOoContainerPage.DialogDescription=LibreOffice Library edition page +OOoContainerPage.DialogImage=/icons/library_wiz.png +OOoContainerPage.DialogTitle=LibreOffice Libraries +OOoContainerPage.ClasspathSetFailed=Error while setting the project classpath diff --git a/python/source/org/libreoffice/ide/eclipse/python/client/ClientWizard.java b/python/source/org/libreoffice/ide/eclipse/python/client/ClientWizard.java new file mode 100644 index 0000000..2531edf --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/client/ClientWizard.java @@ -0,0 +1,171 @@ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2009 by Novell, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Cédric Bosdonnat. + * + * Copyright: 2009 by Novell, Inc. + * + * All Rights Reserved. + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.client; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.jdt.core.IClasspathEntry; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.ui.wizards.NewJavaProjectWizardPageOne; +import org.eclipse.jdt.ui.wizards.NewJavaProjectWizardPageTwo; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard; +import org.libreoffice.ide.eclipse.core.PluginLogger; +import org.libreoffice.ide.eclipse.core.utils.WorkbenchHelper; +import org.libreoffice.ide.eclipse.python.OOoJavaPlugin; +import org.libreoffice.ide.eclipse.python.utils.TemplatesHelper; + +/** + * Class for the Java UNO client wizard. + */ +public class ClientWizard extends BasicNewResourceWizard { + + public static final String JODCONNECTOR_LIBNAME = "jodconnector.jar"; //$NON-NLS-1$ + private static final String DEST_PACKAGE = "org.libreoffice.client"; //$NON-NLS-1$ + private static final String CLIENT_CLASS = "UnoClient"; //$NON-NLS-1$ + private static final String LICENSE_DIR = "third-party licenses"; //$NON-NLS-1$ + private static final String[] LICENSE_FILES = new String[] { + "license-jodconnector.txt", //$NON-NLS-1$ + }; + + private IWorkbenchPage mActivePage; + + private NewJavaProjectWizardPageOne mFirstPage; + private NewJavaProjectWizardPageTwo mThirdPage; + private UnoConnectionPage mCnxPage; + + /** + * Default constructor. + */ + public ClientWizard() { + super(); + setWindowTitle(Messages.getString("ClientWizard.Title")); //$NON-NLS-1$ + mActivePage = WorkbenchHelper.getActivePage(); + } + + @Override + public boolean performCancel() { + boolean ret = super.performCancel(); + mThirdPage.performCancel(); + return ret; + } + + @Override + public boolean performFinish() { + boolean res = true; + + Job job = new Job(Messages.getString("ClientWizard.CreationJobTitle")) { //$NON-NLS-1$ + @Override + protected IStatus run(IProgressMonitor pMonitor) { + + Status status = new Status(IStatus.OK, OOoJavaPlugin.PLUGIN_ID, + Messages.getString("ClientWizard.ProjectCreated")); //$NON-NLS-1$ + + try { + mThirdPage.performFinish(pMonitor); + setupClientProject(mThirdPage.getJavaProject(), pMonitor); + } catch (Exception e) { + PluginLogger.error(Messages.getString("ClientWizard.ProjectCreationError"), e); //$NON-NLS-1$ + status = new Status(IStatus.ERROR, OOoJavaPlugin.PLUGIN_ID, + Messages.getString("ClientWizard.ProjectCreationError")); //$NON-NLS-1$ + } + return status; + } + }; + + job.schedule(); + + return res; + } + + /** + * Configure the Java project in order to have a Java UNO client project. + * + * @param pJavaProject the Java project to configure + * @param pMonitor progress monitor to update + * + * @throws Exception if anything wrong happens + */ + protected void setupClientProject(IJavaProject pJavaProject, IProgressMonitor pMonitor) throws Exception { + + // Generate the sample classes in org.libreoffice.connection + IProject prj = pJavaProject.getProject(); + + IClasspathEntry[] srcEntries = mFirstPage.getSourceClasspathEntries(); + IFolder srcFolder = ResourcesPlugin.getWorkspace().getRoot().getFolder(srcEntries[0].getPath()); + IPath srcPath = srcFolder.getProjectRelativePath(); + + String path = srcPath.append(DEST_PACKAGE.replace('.', '/')).toString(); + TemplatesHelper.copyTemplate(prj, CLIENT_CLASS + TemplatesHelper.JAVA_EXT, + ClientWizard.class, path, DEST_PACKAGE, mCnxPage.getConnectionCode()); + + // Copy the third-party licenses + IFolder licensesFolder = prj.getFolder(LICENSE_DIR); + licensesFolder.create(true, true, pMonitor); + IPath licPath = licensesFolder.getProjectRelativePath(); + for (String license : LICENSE_FILES) { + TemplatesHelper.copyTemplate(prj, license, ClientWizard.class, licPath.toString()); + } + + // Refresh the project + try { + prj.refreshLocal(IResource.DEPTH_INFINITE, null); + } catch (Exception e) { + } + + // Show the Uno client class + IFolder srcDir = prj.getFolder(path); + IFile javaClientFile = srcDir.getFile(CLIENT_CLASS + ".java"); //$NON-NLS-1$ + selectAndReveal(javaClientFile); + WorkbenchHelper.showFile(javaClientFile, mActivePage); + } + + @Override + public void addPages() { + + mCnxPage = new UnoConnectionPage(); + mFirstPage = new NewJavaProjectWizardPageOne(); + addPage(mFirstPage); + + addPage(mCnxPage); + + mThirdPage = new ClientWizardPageTwo(mFirstPage, mCnxPage); + addPage(mThirdPage); + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/client/ClientWizardPageTwo.java b/python/source/org/libreoffice/ide/eclipse/python/client/ClientWizardPageTwo.java new file mode 100644 index 0000000..94e9aa2 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/client/ClientWizardPageTwo.java @@ -0,0 +1,116 @@ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2009 by Cédric Bosdonnat + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Cédric Bosdonnat. + * + * Copyright: 2013 by SUSE + * + * All Rights Reserved. + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.client; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.net.URL; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.FileLocator; +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.NewJavaProjectWizardPageOne; +import org.eclipse.jdt.ui.wizards.NewJavaProjectWizardPageTwo; +import org.libreoffice.ide.eclipse.core.model.config.IOOo; +import org.libreoffice.ide.eclipse.python.OOoJavaPlugin; +import org.libreoffice.ide.eclipse.python.build.OOoClasspathContainer; + +/** + * Overrides NewJavaProjectWizardPageTwo to add jodconnector.jar to the temporary project. + */ +public class ClientWizardPageTwo extends NewJavaProjectWizardPageTwo { + + private UnoConnectionPage mCnxPage; + + public ClientWizardPageTwo(NewJavaProjectWizardPageOne mainPage, UnoConnectionPage cnxPage) { + super(mainPage); + mCnxPage = cnxPage; + } + + @Override + public void setVisible(boolean visible) { + super.setVisible(visible); + + if (getContainer().getCurrentPage() == mCnxPage) { + removeProvisonalProject(); + } + } + + @Override + public void init(IJavaProject jproject, IPath defaultOutputLocation, IClasspathEntry[] defaultEntries, + boolean defaultsOverrideExistingClasspath) { + + IProject project = jproject.getProject(); + + // Copy the jodconnector.jar file to the new project + try { + URL libUrl = OOoJavaPlugin.getDefault().getBundle().getResource(ClientWizard.JODCONNECTOR_LIBNAME); + URL libFileUrl = FileLocator.toFileURL(libUrl); + File libFile = new File(libFileUrl.toURI()); + InputStream in = new FileInputStream(libFile); + IFile destLib = project.getFile(ClientWizard.JODCONNECTOR_LIBNAME); + destLib.create(in, true, null); + } catch (Exception e) { + } + + // Refresh the project + try { + project.refreshLocal(IResource.DEPTH_INFINITE, null); + } catch (Exception e) { + } + + // Update the classpath + IOOo ooo = mCnxPage.getOoo(); + IPath path = new Path(OOoClasspathContainer.ID + IPath.SEPARATOR + ooo.getName()); + IClasspathEntry oooEntry = JavaCore.newContainerEntry(path); + + IPath jodPath = project.getFolder(ClientWizard.JODCONNECTOR_LIBNAME).getFullPath(); + + IClasspathEntry[] newEntries = new IClasspathEntry[] { + oooEntry, + JavaCore.newLibraryEntry(jodPath, jodPath, jodPath) + }; + + IClasspathEntry[] entries = new IClasspathEntry[defaultEntries.length + newEntries.length]; + + System.arraycopy(defaultEntries, 0, entries, 0, defaultEntries.length); + System.arraycopy(newEntries, 0, entries, defaultEntries.length, newEntries.length); + + super.init(jproject, defaultOutputLocation, entries, defaultsOverrideExistingClasspath); + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/client/Messages.java b/python/source/org/libreoffice/ide/eclipse/python/client/Messages.java new file mode 100644 index 0000000..1e777f3 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/client/Messages.java @@ -0,0 +1,67 @@ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2009 by Novell, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Cédric Bosdonnat. + * + * Copyright: 2009 by Novell, Inc. + * + * All Rights Reserved. + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.client; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * Messages for the package. + */ +public class Messages { + + private static final String BUNDLE_NAME = "org.libreoffice.ide.eclipse.java.client.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + /** + * Default constructor. + */ + private Messages() { + } + + /** + * Get the string from it's key. + * + * @param pKey the key of the string + * + * @return the internationalized string + */ + public static String getString(String pKey) { + String string = '!' + pKey + '!'; + try { + string = RESOURCE_BUNDLE.getString(pKey); + } catch (MissingResourceException e) { + } + return string; + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/client/UnoClient.java.tpl b/python/source/org/libreoffice/ide/eclipse/python/client/UnoClient.java.tpl new file mode 100644 index 0000000..79bf86e --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/client/UnoClient.java.tpl @@ -0,0 +1,39 @@ +package {0}; + +import com.artofsolving.jodconverter.openoffice.connection.AbstractOpenOfficeConnection; +import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection; +import com.artofsolving.jodconverter.openoffice.connection.PipeOpenOfficeConnection; + +import com.sun.star.uno.XComponentContext; + +// Make sure LibreOffice is started with the proper arguments to have it listen before +// running this client application. Use one of the following commands to start it: +// * For socket connection: soffice --accept="socket,host=localhost,port=8100,tcpNoDelay=1;urp;" +// * For pipe connection: soffice --accept="pipe,name=yourpipename;urp;" +public class UnoClient '{' + + public static void main(String[] args) '{' + AbstractOpenOfficeConnection cnx = null; + + try '{' + {1} + System.out.println("Connecting to OOo..."); + cnx.connect(); + + System.out.println( "Trying to get the component context" ); + if ( cnx.getComponentContext() != null ) '{' + XComponentContext xCtx = cnx.getComponentContext(); + + // TODO Use the UNO connection here + + } + } catch (Exception e) '{' + e.printStackTrace(); + } finally '{' + if ( cnx != null ) '{' + System.out.println( "Disconnecting from OOo..." ); + cnx.disconnect(); + } + } + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/client/UnoConnectionPage.java b/python/source/org/libreoffice/ide/eclipse/python/client/UnoConnectionPage.java new file mode 100644 index 0000000..fce89d2 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/client/UnoConnectionPage.java @@ -0,0 +1,49 @@ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2009 by Novell, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Cédric Bosdonnat. + * + * Copyright: 2009 by Novell, Inc. + * + * All Rights Reserved. + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.client; + +import org.eclipse.swt.widgets.Composite; +import org.libreoffice.ide.eclipse.core.wizards.pages.BaseUnoConnectionPage; + +/** + * Wizard page for the UNO Client configuration. + */ +public class UnoConnectionPage extends BaseUnoConnectionPage { + + private static final String PIPE_PATTERN = "cnx = new PipeOpenOfficeConnection( \"{0}\" );"; //$NON-NLS-1$ + private static final String SOCKET_PATTERN = "cnx = new SocketOpenOfficeConnection( \"{0}\", {1} );"; //$NON-NLS-1$ + + @Override + public void createControl(Composite pParent) { + super.createControl(pParent); + setConnectionPatterns(PIPE_PATTERN, SOCKET_PATTERN); + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/client/license-jodconnector.txt.tpl b/python/source/org/libreoffice/ide/eclipse/python/client/license-jodconnector.txt.tpl new file mode 100644 index 0000000..5ab7695 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/client/license-jodconnector.txt.tpl @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/python/source/org/libreoffice/ide/eclipse/python/client/messages.properties b/python/source/org/libreoffice/ide/eclipse/python/client/messages.properties new file mode 100644 index 0000000..0444d12 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/client/messages.properties @@ -0,0 +1,6 @@ +ClientWizard.CreationJobTitle=Java UNO client creation +ClientWizard.ProjectCreated=Project created +ClientWizard.ProjectCreationError=Error creating UNO client application +ClientWizard.Title=Java UNO Client wizard +JODContainer.Description=LibreOffice UNO connector +JODContainer.GetLibraryError=Failed to get library: diff --git a/python/source/org/libreoffice/ide/eclipse/python/export/AntScriptExportWizard.java b/python/source/org/libreoffice/ide/eclipse/python/export/AntScriptExportWizard.java new file mode 100644 index 0000000..ff7ac5c --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/export/AntScriptExportWizard.java @@ -0,0 +1,135 @@ +/************************************************************************* + * + *$RCSfile: BuildScriptExportWizard.java,v $ + * + * $Revision: 1.0 $ + * + * last change: $Author: shobhanmandal $ $Date: 2018/03/03 18:36:29 $ + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2009 by Cédric Bosdonnat + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Cédric Bosdonnat. + * + * Copyright: 2009 by Cédric Bosdonnat + * + * All Rights Reserved. + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.export; + +import java.io.File; +import java.util.Iterator; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.IExportWizard; +import org.eclipse.ui.IWorkbench; +import org.libreoffice.ide.eclipse.core.OOEclipsePlugin; +import org.libreoffice.ide.eclipse.core.PluginLogger; +import org.libreoffice.ide.eclipse.core.model.IUnoidlProject; +import org.libreoffice.ide.eclipse.core.model.ProjectsManager; +import org.libreoffice.ide.eclipse.python.Messages; +import org.libreoffice.plugin.core.model.UnoPackage; + +/** + * Class for the new Ant Script Generation wizard. + */ +public class AntScriptExportWizard extends Wizard implements IExportWizard { + + private static final String ANT_EXPORT_SETTINGS_KEY = "oxt.export"; //$NON-NLS-1$ + + private boolean mHasNewDialogSettings; + + private AntScriptExportWizardPage mAntScriptPage; + + /** + * Constructor. + */ + public AntScriptExportWizard() { + IDialogSettings workbenchSettings = OOEclipsePlugin.getDefault().getDialogSettings(); + IDialogSettings section = workbenchSettings.getSection(ANT_EXPORT_SETTINGS_KEY); + if (section == null) { + mHasNewDialogSettings = true; + } else { + mHasNewDialogSettings = false; + setDialogSettings(section); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void init(IWorkbench pWorkbench, IStructuredSelection pSelection) { + // Try hard to find a selected UNO project + IUnoidlProject prj = null; + Iterator it = pSelection.iterator(); + while (it.hasNext() && prj == null) { + Object o = it.next(); + if (o instanceof IAdaptable) { + IResource res = ((IAdaptable) o).getAdapter(IResource.class); + if (res != null) { + prj = ProjectsManager.getProject(res.getProject().getName()); + } + } + } + setWindowTitle(Messages.getString("AntScriptExportWizard.DialogTitle")); //$NON-NLS-1$ + + mAntScriptPage = new AntScriptExportWizardPage("page1", prj); //$NON-NLS-1$ + addPage(mAntScriptPage); + + } + + @Override + public boolean performFinish() { + boolean finished = false; + String directory = mAntScriptPage.getPath(); + String tempPath = directory + "/temporary/temp.oxt"; + UnoPackage model = mAntScriptPage.getPackageModel(tempPath); + if (model != null) { + try { + mAntScriptPage.createBuildScripts(model); + + mAntScriptPage.refreshProject(); + + if (mHasNewDialogSettings) { + IDialogSettings workbenchSettings = OOEclipsePlugin.getDefault().getDialogSettings(); + IDialogSettings section = workbenchSettings.getSection(ANT_EXPORT_SETTINGS_KEY); + section = workbenchSettings.addNewSection(ANT_EXPORT_SETTINGS_KEY); + setDialogSettings(section); + } + + } catch (Exception e) { + PluginLogger.error("The Ant Script couldn't be built", e); + } + } + + File antFile = new File(directory + "/build.xml"); + finished = antFile.exists(); + + return finished; + } + +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/export/AntScriptExportWizardPage.java b/python/source/org/libreoffice/ide/eclipse/python/export/AntScriptExportWizardPage.java new file mode 100644 index 0000000..8af24da --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/export/AntScriptExportWizardPage.java @@ -0,0 +1,255 @@ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2009 by Cédric Bosdonnat + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Cédric Bosdonnat. + * + * Copyright: 2009 by Cédric Bosdonnat + * + * All Rights Reserved. + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.export; + +import java.io.File; +import java.util.ArrayList; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.libreoffice.ide.eclipse.core.PluginLogger; +import org.libreoffice.ide.eclipse.core.gui.PackageContentSelector; +import org.libreoffice.ide.eclipse.core.model.IUnoidlProject; +import org.libreoffice.ide.eclipse.core.model.ProjectsManager; +import org.libreoffice.ide.eclipse.core.model.language.LanguageExportPart; +import org.libreoffice.ide.eclipse.python.Messages; +import org.libreoffice.plugin.core.model.UnoPackage; + +public class AntScriptExportWizardPage extends WizardPage { + + private IUnoidlProject sSelectedProject; + private LanguageExportPart sLangPart; + private Combo sProjectsList; + private boolean checkAntSectionDisplay = false; + + /** + * Constructor. + * + * @param pPageName + * the page name + * @param pProject + * the project to export + */ + public AntScriptExportWizardPage(String pPageName, IUnoidlProject pProject) { + super(pPageName); + + setTitle(Messages.getString("AntScriptExportWizard.Title")); //$NON-NLS-1$ + setDescription(Messages.getString("AntScriptExportWizard.Description")); //$NON-NLS-1$ + + sSelectedProject = pProject; + } + + /** + * Create the build scripts for the package model. + * + * @param pModel + * the model to be used to build script + */ + public void createBuildScripts(UnoPackage pModel) { + sLangPart.doFinish(pModel); + checkAntSectionDisplay = false; + JavaExportPart.setCheckAntSectionDisplay(checkAntSectionDisplay); + } + + /** + * @return the UNO project to be used for building the ant script + */ + public IUnoidlProject getProject() { + return sSelectedProject; + } + + /** + * @param pProject + * the UNO project selected for the wizard. + */ + public void setProject(IUnoidlProject pProject) { + sSelectedProject = pProject; + reloadLanguagePart(); + } + + /** + * {@inheritDoc} + */ + @Override + public void createControl(Composite pParent) { + + Composite body = new Composite(pParent, SWT.NONE); + body.setLayout(new GridLayout()); + body.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + setControl(body); + + createProjectSelection(); + + setPageComplete(checkPageCompletion()); + + // Load the data into the fields + loadData(); + } + + /** + * Loads the data in the controls of the page. + */ + private void loadData() { + // Select the project + String[] items = sProjectsList.getItems(); + int i = 0; + while (sSelectedProject != null && i < items.length) { + if (items[i].equals(sSelectedProject.getName())) { + sProjectsList.select(i); + } + i++; + } + } + + /** + * Creates the project selection part of the dialog. + */ + private void createProjectSelection() { + Composite body = (Composite) getControl(); + Composite selectionBody = new Composite(body, SWT.NONE); + selectionBody.setLayout(new GridLayout(2, false)); + selectionBody.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); + + Label lbl = new Label(selectionBody, SWT.NORMAL); + lbl.setText(Messages.getString("AntScriptExportWizard.Project")); //$NON-NLS-1$ + lbl.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); + + IUnoidlProject[] prjs = ProjectsManager.getProjects(); + String[] prjNames = new String[prjs.length]; + for (int i = 0; i < prjs.length; i++) { + IUnoidlProject prj = prjs[i]; + prjNames[i] = prj.getName(); + } + + sProjectsList = new Combo(selectionBody, SWT.DROP_DOWN | SWT.READ_ONLY); + sProjectsList.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + sProjectsList.setItems(prjNames); + + sProjectsList.addModifyListener(new ModifyListener() { + + @Override + public void modifyText(ModifyEvent pE) { + int id = sProjectsList.getSelectionIndex(); + if (id != -1) { + String name = sProjectsList.getItem(id); + IUnoidlProject unoprj = ProjectsManager.getProject(name); + sSelectedProject = unoprj; + + // Change the project in the AntScriptExportPage + setProject(unoprj); + } + setPageComplete(checkPageCompletion()); + } + }); + } + + /** + * @return true if the page is complete, false otherwise. + */ + private boolean checkPageCompletion() { + return (sProjectsList.getSelectionIndex() != -1); + } + + /** + * Change the language specific part from the selected project. + */ + private void reloadLanguagePart() { + + // Add the language specific controls + if (sSelectedProject != null) { + sLangPart = sSelectedProject.getLanguage().getExportBuildPart(); + if (sLangPart != null) { + //****sLangPart.setPage(this); <--- Can be used When the class LanguageExportPart is using the Object Class rather than ManifestExportPage + JavaExportPart.setAntScriptExportPage(this); + Composite body = (Composite) getControl(); + + if (body != null) { + // The body can be null before the page creation + sLangPart.createControls(body); + body.layout(); + checkAntSectionDisplay = true; + JavaExportPart.setCheckAntSectionDisplay(checkAntSectionDisplay); + } + } + } + } + + /** + * @return the package model built from the data provided by the user or null if something blocked the + * process. + */ + public UnoPackage getPackageModel(String tempPath) { + UnoPackage pack = null; + + try { + File destFile = new File(tempPath); + pack = PackageContentSelector.createPackage(sSelectedProject, destFile, new ArrayList()); + } catch (Exception e) { + PluginLogger.error(Messages.getString("AntScriptExportWizard.LibraryCreationError"), e); //$NON-NLS-1$ + } + + return pack; + } + + /** + * Refresh the selected project. + */ + public void refreshProject() { + try { + // Refresh the project and return the status + String prjName = sSelectedProject.getName(); + IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject(prjName); + prj.refreshLocal(IResource.DEPTH_INFINITE, null); + } catch (CoreException e) { + } + } + + /** + * Returns the path of the selected Project + */ + public String getPath() { + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(sSelectedProject.getName()); + File dir = project.getFile("build.xml").getLocation().toFile().getParentFile(); + return dir.toString(); + } + +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/export/JavaExportPageControl.java b/python/source/org/libreoffice/ide/eclipse/python/export/JavaExportPageControl.java new file mode 100644 index 0000000..6283bb1 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/export/JavaExportPageControl.java @@ -0,0 +1,76 @@ +/************************************************************************* + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program. + * If not, see . + * + * Copyright: 2010 by Cédric Bosdonnat + * + * All Rights Reserved. + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.export; + +/** + * Controller object for the fields of the {@link JavaExportPart} view. + */ +public class JavaExportPageControl { + + public static final String DEFAULT_ANT_FILENAME = "build.xml"; //$NON-NLS-1$ + + private boolean mSaveAntScript; + private String mSavePath; + + /** + * Default constructor. + */ + public JavaExportPageControl() { + setSaveAntScript(false); + setSavePath(DEFAULT_ANT_FILENAME); + } + + /** + * @param pSave the state of the save ant script box. + */ + public void setSaveAntScript(boolean pSave) { + mSaveAntScript = pSave; + } + + /** + * @param pPath the path to set in the save field + */ + public void setSavePath(String pPath) { + mSavePath = pPath; + } + + /** + * @return the state of the save ant script box + */ + public boolean getSaveAntScript() { + return mSaveAntScript; + } + + /** + * @return the value of the save path text field + */ + public String getSavePath() { + return mSavePath; + } + + /** + * @return whether the save path field is enabled + */ + public boolean isSavePathEnabled() { + return mSaveAntScript; + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/export/JavaExportPart.java b/python/source/org/libreoffice/ide/eclipse/python/export/JavaExportPart.java new file mode 100644 index 0000000..e737954 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/export/JavaExportPart.java @@ -0,0 +1,196 @@ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2009 by Cédric Bosdonnat + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Cédric Bosdonnat. + * + * Copyright: 2009 by Cédric Bosdonnat + * + * All Rights Reserved. + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.export; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.Properties; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.libreoffice.ide.eclipse.core.PluginLogger; +import org.libreoffice.ide.eclipse.core.model.IUnoidlProject; +import org.libreoffice.ide.eclipse.core.model.language.LanguageExportPart; +import org.libreoffice.ide.eclipse.python.Messages; +import org.libreoffice.ide.eclipse.python.utils.TemplatesHelper; +import org.libreoffice.ide.eclipse.core.model.OOoContainer; +import org.libreoffice.ide.eclipse.core.model.SDKContainer; +import org.libreoffice.plugin.core.model.UnoPackage; + +/** + * Dialog part for the Ant scripts export configuration. + */ +public class JavaExportPart extends LanguageExportPart { + + private Composite mNameRow; + private Label mNameRowLbl; + private Label mNameRowValueLbl; + private Label titleLbl; + + private JavaExportPageControl mController; + private static AntScriptExportWizardPage mAntScriptPage; + private static boolean mAntSectionDisplay = false; + + public static final int HORIZONTAL_INDENT = 20; + + /** + * @param pAntScriptPage + * Helps in retrieving the project selected in this part. + */ + public static void setAntScriptExportPage(AntScriptExportWizardPage pAntScriptPage) { + mAntScriptPage = pAntScriptPage; + } + + /** + * @param pAntSectionDisplay + * Helps in blocking the Title and Other Displays in wizard after 1st time + */ + public static void setCheckAntSectionDisplay(boolean pAntSectionDisplay) { + mAntSectionDisplay = pAntSectionDisplay; + } + + /** + * {@inheritDoc} + */ + @Override + public void createControls(Composite pParent) { + + mController = new JavaExportPageControl(); + mController.setSaveAntScript(true); + + if (!mAntSectionDisplay) { + titleLbl = new Label(pParent, SWT.NONE); + titleLbl.setText(Messages.getString("JavaExportPart.Title")); //$NON-NLS-1$ + titleLbl.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false)); + + Composite content = new Composite(pParent, SWT.NONE); + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); + gd.horizontalIndent = HORIZONTAL_INDENT; + content.setLayoutData(gd); + content.setLayout(new GridLayout()); + + mNameRow = new Composite(content, SWT.NONE); + mNameRow.setLayout(new GridLayout(2, false)); + gd = new GridData(SWT.FILL, SWT.BEGINNING, true, false); + gd.horizontalIndent = HORIZONTAL_INDENT; + mNameRow.setLayoutData(gd); + + mNameRowLbl = new Label(mNameRow, SWT.NONE); + mNameRowLbl.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); + mNameRowLbl.setText(Messages.getString("JavaExportPart.AntFile")); //$NON-NLS-1$ + + mNameRowValueLbl = new Label(mNameRow, SWT.NONE); + mNameRowValueLbl.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); + mNameRowValueLbl.setText(mController.getSavePath()); //$NON-NLS-1$ + + mNameRowLbl.setEnabled(mController.isSavePathEnabled()); + mNameRowValueLbl.setEnabled(mController.isSavePathEnabled()); + + } + } + + /** + * {@inheritDoc} + */ + @Override + public void dispose() { + + } + + /** + * {@inheritDoc} + */ + @Override + public void doFinish(UnoPackage pModel) { + + String directory = mAntScriptPage.getPath(); + File antFile = new File(directory + "/build.xml"); + boolean result = false; + + if (antFile.exists()) { + Shell shell = Display.getDefault().getActiveShell(); + result = MessageDialog.openConfirm(shell, "Confirm", + "build.xml exists under the selected project.\nDo you wish to overwrite it?"); + } else { + result = true; + } + + if (mController.getSaveAntScript() && result) { + + // Generate the build script + //****IUnoidlProject unoProject = getPage().getProject(); <--- Can be used When the parent class LanguageExportPart is using the Object Class rather than ManifestExportPage + IUnoidlProject unoProject = mAntScriptPage.getProject(); + String prjName = unoProject.getName(); + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(unoProject.getName()); + + TemplatesHelper.copyTemplate(project, mController.getSavePath(), + JavaExportPart.class, new String(), prjName); + + // Generate the build.properties file + File dir = project.getFile(mController.getSavePath()).getLocation().toFile().getParentFile(); + File propsFile = new File(dir, "build.properties"); //$NON-NLS-1$ + FileWriter writer = null; + + try { + writer = new FileWriter(propsFile); + + Properties props = new Properties(); + + if (OOoContainer.getOOoKeys().size() > 0) + props.put("office.install.dir", //$NON-NLS-1$ + OOoContainer.getOOo(OOoContainer.getOOoKeys().get(0)).getHome()); + else + props.put("office.install.dir", ""); //$NON-NLS-1$ + + if (SDKContainer.getSDKKeys().size() > 0) + props.put("sdk.dir", SDKContainer.getSDK(SDKContainer.getSDKKeys().get(0)).getHome()); //$NON-NLS-1$ + else + props.put("sdk.dir", ""); //$NON-NLS-1$ + + props.store(writer, null); + writer.close(); + + } catch (IOException e) { + PluginLogger.error(Messages.getString("JavaExportPart.BuildPropertiesError"), e); //$NON-NLS-1$ + } + + } + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/export/build.xml.tpl b/python/source/org/libreoffice/ide/eclipse/python/export/build.xml.tpl new file mode 100644 index 0000000..9dd8e77 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/export/build.xml.tpl @@ -0,0 +1,182 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/python/source/org/libreoffice/ide/eclipse/python/messages.properties b/python/source/org/libreoffice/ide/eclipse/python/messages.properties new file mode 100644 index 0000000..098e4b5 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/messages.properties @@ -0,0 +1,18 @@ +Language.JavaNatureSet=Java nature set +Language.NatureSettingFailed=Setting Java nature failed +Language.UnreadableOutputError=Unreadable output error +Language.CreateCodeError=Code generation failed +Language.GetClasspathError=Failed to get the project classpath +JavaExportPart.AntFile=Ant build file name : +JavaExportPart.BuildPropertiesError=Error creating build.properties +JavaExportPart.SaveAntScript=Save as Ant script +JavaExportPart.Title=Java options +PythonWizardPage.IncludeTestClasses=Include base classes for tests +PythonWizardPage.PageTitle=Java implementation configuration +PythonWizardPage.PageDescription=This page helps you to configure the java implementation skeleton creation. + +AntScriptExportWizard.DialogTitle=Build Script File +AntScriptExportWizard.Title=Build Script Files options +AntScriptExportWizard.Description=Define the options for the OXT package Scripts +AntScriptExportWizard.LibraryCreationError=Couldn't create the library to be used for Script creation +AntScriptExportWizard.Project=Project to build Script: diff --git a/python/source/org/libreoffice/ide/eclipse/python/registration/FileRefreshJob.java b/python/source/org/libreoffice/ide/eclipse/python/registration/FileRefreshJob.java new file mode 100644 index 0000000..aadacc4 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/registration/FileRefreshJob.java @@ -0,0 +1,90 @@ +/************************************************************************* + * + * $RCSfile: FileRefreshJob.java,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: cedricbosdo $ $Date: 2007/11/25 20:32:38 $ + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * Sun Microsystems Inc., October, 2000 + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): Cedric Bosdonnat + * + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.registration; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.Job; +import org.libreoffice.ide.eclipse.core.OOEclipsePlugin; + +/** + * Job refreshing the RegistrationHandler.classes files. + */ +public class FileRefreshJob extends Job { + + private IFile mToRefresh; + + /** + * Job constructor. + * + * @param pToRefresh the file to refresh + */ + public FileRefreshJob(IFile pToRefresh) { + super("Registration Handler class refresh job"); //$NON-NLS-1$ + mToRefresh = pToRefresh; + } + + /** + * {@inheritDoc} + */ + @Override + protected IStatus run(IProgressMonitor pMonitor) { + IStatus status = Status.OK_STATUS; + try { + mToRefresh.refreshLocal(IResource.DEPTH_ZERO, null); + } catch (CoreException e) { + status = new Status( + IStatus.WARNING, + OOEclipsePlugin.getDefault().getBundle().getSymbolicName(), + IStatus.WARNING, + Messages.getString("FileRefreshJob.Error"), //$NON-NLS-1$ + e); + } + return status; + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/registration/Messages.java b/python/source/org/libreoffice/ide/eclipse/python/registration/Messages.java new file mode 100644 index 0000000..d3d127d --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/registration/Messages.java @@ -0,0 +1,66 @@ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2009 by Novell, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Cédric Bosdonnat. + * + * Copyright: 2009 by Novell, Inc. + * + * All Rights Reserved. + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.registration; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * Messages for the package. + */ +public class Messages { + private static final String BUNDLE_NAME = "org.libreoffice.ide.eclipse.java.registration.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + /** + * Default constructor. + */ + private Messages() { + } + + /** + * Get the string from it's key. + * + * @param pKey the key of the string + * + * @return the internationalized string + */ + public static String getString(String pKey) { + String string = '!' + pKey + '!'; + try { + string = RESOURCE_BUNDLE.getString(pKey); + } catch (MissingResourceException e) { + } + return string; + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/registration/RegistrationHandler.java.tpl b/python/source/org/libreoffice/ide/eclipse/python/registration/RegistrationHandler.java.tpl new file mode 100644 index 0000000..c1fecb3 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/registration/RegistrationHandler.java.tpl @@ -0,0 +1,175 @@ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * either of the GNU Lesser General Public License Version 2.1 + * + * Sun Microsystems Inc., October, 2000 + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): Cedric Bosdonnat + * + * + ************************************************************************/ +package {0}; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.LineNumberReader; +import java.lang.reflect.Method; +import java.util.ArrayList; + +import com.sun.star.lang.XSingleComponentFactory; +import com.sun.star.registry.XRegistryKey; + +/** + * Component main registration class. + * + *

This class should not be modified.

+ * + * @author Cedric Bosdonnat aka. cedricbosdo + * + */ +public class RegistrationHandler '{' + + /** + * Get a component factory for the implementations handled by this class. + * + *

This method calls all the methods of the same name from the classes listed + * in the RegistrationHandler.classes file. This method + * should not be modified.

+ * + * @param pImplementationName the name of the implementation to create. + * + * @return the factory which can create the implementation. + */ + public static XSingleComponentFactory __getComponentFactory(String sImplementationName ) '{' + XSingleComponentFactory xFactory = null; + + Class[] classes = findServicesImplementationClasses(); + + int i = 0; + while (i < classes.length && xFactory == null) '{' + Class clazz = classes[i]; + if ( sImplementationName.equals( clazz.getCanonicalName() ) ) '{' + try '{' + Class[] getTypes = new Class[]'{'String.class}; + Method getFactoryMethod = clazz.getMethod("__getComponentFactory", getTypes); + Object o = getFactoryMethod.invoke(null, sImplementationName); + xFactory = (XSingleComponentFactory)o; + } catch (Exception e) '{' + // Nothing to do: skip + System.err.println("Error happened"); + e.printStackTrace(); + } + } + i++; + } + return xFactory; + } + + /** + * Writes the services implementation informations to the UNO registry. + * + *

This method calls all the methods of the same name from the classes listed + * in the RegistrationHandler.classes file. This method + * should not be modified.

+ * + * @param pRegistryKey the root registry key where to write the informations. + * + * @return true if the informations have been successfully written + * to the registry key, false otherwise. + */ + public static boolean __writeRegistryServiceInfo(XRegistryKey xRegistryKey ) '{' + + Class[] classes = findServicesImplementationClasses(); + + boolean success = true; + int i = 0; + while (i < classes.length && success) '{' + Class clazz = classes[i]; + try '{' + Class[] writeTypes = new Class[]'{'XRegistryKey.class}; + Method getFactoryMethod = clazz.getMethod("__writeRegistryServiceInfo", writeTypes); + Object o = getFactoryMethod.invoke(null, xRegistryKey); + success = success && ((Boolean)o).booleanValue(); + } catch (Exception e) '{' + success = false; + e.printStackTrace(); + } + i++; + } + return success; + } + + /** + * @return all the UNO implementation classes. + */ + private static Class[] findServicesImplementationClasses() '{' + + ArrayList classes = new ArrayList(); + + InputStream in = RegistrationHandler.class.getResourceAsStream("RegistrationHandler.classes"); + LineNumberReader reader = new LineNumberReader(new InputStreamReader(in)); + + try '{' + String line = reader.readLine(); + while (line != null) '{' + if (!line.equals("")) '{' + line = line.trim(); + try '{' + Class clazz = Class.forName(line); + + Class[] writeTypes = new Class[]'{'XRegistryKey.class}; + Class[] getTypes = new Class[]'{'String.class}; + + Method writeRegMethod = clazz.getMethod("__writeRegistryServiceInfo", writeTypes); + Method getFactoryMethod = clazz.getMethod("__getComponentFactory", getTypes); + + if (writeRegMethod != null && getFactoryMethod != null) '{' + classes.add(clazz); + } + + } catch (Exception e) '{' + e.printStackTrace(); + } + } + line = reader.readLine(); + } + } catch (IOException e) '{' + e.printStackTrace(); + } finally '{' + try '{' + reader.close(); + in.close(); + } catch (Exception e) '{'}; + } + + return classes.toArray(new Class[classes.size()]); + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/registration/RegistrationHelper.java b/python/source/org/libreoffice/ide/eclipse/python/registration/RegistrationHelper.java new file mode 100644 index 0000000..69ed847 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/registration/RegistrationHelper.java @@ -0,0 +1,231 @@ +/************************************************************************* + * + * $RCSfile: RegistrationHelper.java,v $ + * + * $Revision: 1.3 $ + * + * last change: $Author: cedricbosdo $ $Date: 2007/12/07 07:30:55 $ + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * Sun Microsystems Inc., October, 2000 + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): Cedric Bosdonnat + * + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.registration; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.Vector; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.runtime.IPath; +import org.libreoffice.ide.eclipse.core.PluginLogger; +import org.libreoffice.ide.eclipse.core.model.IUnoidlProject; +import org.libreoffice.ide.eclipse.python.utils.TemplatesHelper; + +/** + * This class provides utility methods to generate the class and files needed + * by the UNO services implementation registration. + */ +public abstract class RegistrationHelper { + + public static final String CLASS_FILENAME = "RegistrationHandler"; //$NON-NLS-1$ + + /** + * Creates all the necessary files for the java registration of UNO services + * implementations to the regcomp tool. + * + * @param pProject the project where to create the registration handler + */ + public static void generateFiles(IUnoidlProject pProject) { + + // Copy the RegistrationHandler.java.tpl file + TemplatesHelper.copyTemplate(pProject, CLASS_FILENAME + TemplatesHelper.JAVA_EXT, + RegistrationHelper.class, new String()); + + // Create the empty RegistrationHandler.classes file + ByteArrayInputStream empty = new ByteArrayInputStream(new byte[0]); + try { + File listFile = getClassesListFile(pProject).getLocation().toFile(); + listFile.createNewFile(); + } catch (IOException e) { + PluginLogger.error(Messages.getString("RegistrationHelper.WriteClassesListError"), e); //$NON-NLS-1$ + } finally { + try { + empty.close(); + } catch (Exception e) { + } + } + } + + /** + * Add a UNO service implementation to the list of the project ones. + * + * @param pProject the project where to add the implementation + * @param pImplName the fully qualified name of the implementation to add, + * eg: org.libreoffice.comp.test.MyServiceImpl + */ + public static void addImplementation(IUnoidlProject pProject, String pImplName) { + Vector classes = readClassesList(pProject); + if (!classes.contains(pImplName)) { + classes.add(pImplName); + } + writeClassesList(pProject, classes); + } + + /** + * remove a UNO service implementation from the list of the project ones. + * + * @param pProject the project where to remove the implementation + * @param pImplName the fully qualified name of the implementation to remove, + * eg: org.libreoffice.comp.test.MyServiceImpl + */ + public static void removeImplementation(IUnoidlProject pProject, String pImplName) { + Vector classes = readClassesList(pProject); + classes.remove(pImplName); + writeClassesList(pProject, classes); + } + + /** + * Computes the registration class name for the given Uno project. + * + * The registration class name is generally + * <COMPANY.PREFIX>.<OUTPUTEXT>.RegistrationHandler. + * + * @param pProject the project for which to compute the class name + * @return the registration class name + */ + public static String getRegistrationClassName(IUnoidlProject pProject) { + // Compute the name of the main implementation class + String implPkg = pProject.getCompanyPrefix() + "." + pProject.getOutputExtension(); //$NON-NLS-1$ + return implPkg + "." + CLASS_FILENAME; //$NON-NLS-1$ + } + + /** + * Read the implementation classes list of the given UNO project. + * + * @param pProject the UNO project + * + * @return the implementation classes list + */ + public static Vector readClassesList(IUnoidlProject pProject) { + + Vector classes = new Vector(); + + IFile list = getClassesListFile(pProject); + File file = list.getLocation().toFile(); + if (!file.exists()) { + try { + file.createNewFile(); + } catch (IOException e) { + PluginLogger.error(Messages.getString("RegistrationHelper.WriteClassesListError"), e); //$NON-NLS-1$ + } + } + + // First read all the lines + FileInputStream in = null; + BufferedReader reader = null; + try { + in = new FileInputStream(file); + reader = new BufferedReader(new InputStreamReader(in)); + + String line = reader.readLine(); + while (line != null) { + if (!classes.contains(line)) { + classes.add(line); + } + line = reader.readLine(); + } + } catch (Exception e) { + + } finally { + try { + reader.close(); + in.close(); + } catch (Exception e) { + } + } + return classes; + } + + /** + * Writes the implementation classes list to the UNO project. + * + * @param pProject the project for which to write the list + * @param pClasses the classes to write + */ + private static void writeClassesList(IUnoidlProject pProject, Vector pClasses) { + + IFile list = getClassesListFile(pProject); + File file = list.getLocation().toFile(); + + FileWriter writer = null; + try { + writer = new FileWriter(file); + for (String implClass : pClasses) { + writer.append(implClass + "\n"); //$NON-NLS-1$ + } + } catch (IOException e) { + PluginLogger.error(Messages.getString("RegistrationHelper.WriteClassesListError"), e); //$NON-NLS-1$ + } finally { + try { + writer.close(); + } catch (Exception e) { + } + } + + // update the list file in the workspace + new FileRefreshJob(list).schedule(); + } + + /** + * Get the classes list file for the given UNO project. + * + * @param pProject the UNO project to get the list file from + * + * @return the implementation classes file of the project. + */ + private static IFile getClassesListFile(IUnoidlProject pProject) { + // Get the path where to place the class and the implementations list + IPath relPath = pProject.getImplementationPath(); + IFolder dest = pProject.getFolder(relPath); + + return dest.getFile("RegistrationHandler.classes"); //$NON-NLS-1$ + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/registration/messages.properties b/python/source/org/libreoffice/ide/eclipse/python/registration/messages.properties new file mode 100644 index 0000000..28a67f8 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/registration/messages.properties @@ -0,0 +1,2 @@ +FileRefreshJob.Error=Can't refresh the registration classes file +RegistrationHelper.WriteClassesListError=Error during classes list writing diff --git a/python/source/org/libreoffice/ide/eclipse/python/test/JavaExportPageControlTest.java b/python/source/org/libreoffice/ide/eclipse/python/test/JavaExportPageControlTest.java new file mode 100644 index 0000000..865332f --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/test/JavaExportPageControlTest.java @@ -0,0 +1,63 @@ +/************************************************************************* + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program. + * If not, see . + * + * Copyright: 2010 by Cédric Bosdonnat + * + * All Rights Reserved. + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.libreoffice.ide.eclipse.python.export.JavaExportPageControl; + +/** + * Unit test for the Manifest export page part UI controller. + */ +public class JavaExportPageControlTest { + + /** + * Ensure that the default values are the ones expected. + */ + @Test + public void testDefaults() { + JavaExportPageControl tested = new JavaExportPageControl(); + assertFalse("Save ant script shouldn't be default", tested.getSaveAntScript()); + assertFalse("Save path shouldn't be enabled by default", tested.isSavePathEnabled()); + assertEquals(JavaExportPageControl.DEFAULT_ANT_FILENAME, tested.getSavePath()); + } + + /** + * Test checking and unchecking the Save Ant script box. + */ + @Test + public void testSetSaveAntScript() { + JavaExportPageControl tested = new JavaExportPageControl(); + + tested.setSaveAntScript(true); + assertTrue("Save ant script selection not persisting", tested.getSaveAntScript()); + assertTrue("Save path should be enabled when save ant script is checked", tested.isSavePathEnabled()); + + tested.setSaveAntScript(false); + assertFalse("Save ant script selection not persisting", tested.getSaveAntScript()); + assertFalse("Save path should be disabled after save ant script is unchecked", tested.isSavePathEnabled()); + } + +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/tests/Messages.java b/python/source/org/libreoffice/ide/eclipse/python/tests/Messages.java new file mode 100644 index 0000000..d39ca48 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/tests/Messages.java @@ -0,0 +1,67 @@ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2009 by Novell, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Cédric Bosdonnat. + * + * Copyright: 2009 by Novell, Inc. + * + * All Rights Reserved. + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.tests; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * Messages for the package. + */ +public class Messages { + + private static final String BUNDLE_NAME = "org.libreoffice.ide.eclipse.java.tests.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + /** + * Default constructor. + */ + private Messages() { + } + + /** + * Get the string from it's key. + * + * @param pKey the key of the string + * + * @return the internationalized string + */ + public static String getString(String pKey) { + String string = '!' + pKey + '!'; + try { + string = RESOURCE_BUNDLE.getString(pKey); + } catch (MissingResourceException e) { + } + return string; + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/tests/TestsHelper.java b/python/source/org/libreoffice/ide/eclipse/python/tests/TestsHelper.java new file mode 100644 index 0000000..84536b2 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/tests/TestsHelper.java @@ -0,0 +1,93 @@ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2009 by Cédric Bosdonnat. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Cédric Bosdonnat. + * + * Copyright: 2009 by Cédric Bosdonnat. + * + * All Rights Reserved. + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.tests; + +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.core.JavaModelException; +import org.libreoffice.ide.eclipse.core.PluginLogger; +import org.libreoffice.ide.eclipse.core.model.IUnoidlProject; +import org.libreoffice.ide.eclipse.python.utils.TemplatesHelper; + +/** + * Class used to generate the test files in the Java project. + */ +public class TestsHelper { + + private static final String[] TEMPLATES = new String[] { + "UnoTests", //$NON-NLS-1$ + "base/UnoSuite", //$NON-NLS-1$ + "helper/UnoHelper", + "uno/WriterTest" + }; + private static final String TEST_PATH = "tests"; //$NON-NLS-1$ + + private static final String JUNIT_CONTAINER = "org.eclipse.jdt.junit.JUNIT_CONTAINER"; //$NON-NLS-1$ + private static final String JUNIT4 = "4"; //$NON-NLS-1$ + private static final IPath JUNIT4_PATH = new Path(JUNIT_CONTAINER).append(JUNIT4); + + /** + * Creates all the test classes files in the UNO project. + * + * @param pProject the destination UNO project + */ + public static void writeTestClasses(IUnoidlProject pProject) { + for (String template : TEMPLATES) { + TemplatesHelper.copyTemplate(pProject, template + TemplatesHelper.JAVA_EXT, + TestsHelper.class, TEST_PATH); + } + } + + /** + * Add the JUnit3 library to the project libraries. + * + * @param pProject the project to add the libraries on + */ + public static void addJUnitLibraries(IJavaProject pProject) { + try { + IClasspathEntry[] oldEntries = pProject.getRawClasspath(); + IClasspathEntry[] entries = new IClasspathEntry[oldEntries.length + 1]; + + System.arraycopy(oldEntries, 0, entries, 0, oldEntries.length); + + IClasspathEntry containerEntry = JavaCore.newContainerEntry(JUNIT4_PATH); + entries[entries.length - 1] = containerEntry; + + pProject.setRawClasspath(entries, null); + } catch (JavaModelException e) { + PluginLogger.error( + Messages.getString("TestsHelper.AddJUnitError"), e); //$NON-NLS-1$ + } + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/tests/UnoTests.java.tpl b/python/source/org/libreoffice/ide/eclipse/python/tests/UnoTests.java.tpl new file mode 100644 index 0000000..8bbc507 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/tests/UnoTests.java.tpl @@ -0,0 +1,13 @@ +package {0}.tests; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite.SuiteClasses; + +import {0}.tests.base.UnoSuite; +import {0}.tests.uno.WriterTest; + +@RunWith(UnoSuite.class) +@SuiteClasses('{'WriterTest.class}) +public class UnoTests '{' + +} \ No newline at end of file diff --git a/python/source/org/libreoffice/ide/eclipse/python/tests/base/UnoSuite.java.tpl b/python/source/org/libreoffice/ide/eclipse/python/tests/base/UnoSuite.java.tpl new file mode 100644 index 0000000..d12c581 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/tests/base/UnoSuite.java.tpl @@ -0,0 +1,75 @@ +package {0}.tests.base; + +import java.util.List; + +import org.junit.runner.Runner; +import org.junit.runner.notification.RunNotifier; +import org.junit.runners.Suite; +import org.junit.runners.model.InitializationError; +import org.junit.runners.model.RunnerBuilder; + +import com.sun.star.frame.XDesktop; +import com.sun.star.lang.XMultiComponentFactory; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XComponentContext; + +public class UnoSuite extends Suite '{' + + private static XComponentContext componentContext; + + public UnoSuite(Class klass, RunnerBuilder builder) throws InitializationError '{' + super(klass, builder); + } + + public UnoSuite(RunnerBuilder builder, Class[] classes) throws InitializationError '{' + super(builder, classes); + } + + public UnoSuite(Class klass, Class[] suiteClasses) throws InitializationError '{' + super(klass, suiteClasses); + } + + public UnoSuite(Class klass, List runners) throws InitializationError '{' + super(klass, runners); + } + + public UnoSuite(RunnerBuilder builder, Class klass, Class[] suiteClasses) throws InitializationError '{' + super(builder, klass, suiteClasses); + } + + @Override + public void run(RunNotifier arg0) '{' + try '{' + startOffice(); + } catch (Exception e) '{' + e.printStackTrace(); + } + super.run(arg0); + + stopOffice(); + } + + private void startOffice() throws Exception '{' + componentContext = com.sun.star.comp.helper.Bootstrap.bootstrap(); + } + + private void stopOffice() '{' + try '{' + if (componentContext != null) '{' + // Only the uno test suite which started the office can stop it + XMultiComponentFactory xMngr = componentContext.getServiceManager(); + Object oDesktop = xMngr.createInstanceWithContext("com.sun.star.frame.Desktop", componentContext); + XDesktop xDesktop = (XDesktop)UnoRuntime.queryInterface(XDesktop.class, oDesktop); + + xDesktop.terminate(); + } + } catch (Exception e) '{' + e.printStackTrace(); + } + } + + public static XComponentContext getComponentContext() '{' + return componentContext; + } + +} \ No newline at end of file diff --git a/python/source/org/libreoffice/ide/eclipse/python/tests/helper/UnoHelper.java.tpl b/python/source/org/libreoffice/ide/eclipse/python/tests/helper/UnoHelper.java.tpl new file mode 100644 index 0000000..0fe8be0 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/tests/helper/UnoHelper.java.tpl @@ -0,0 +1,28 @@ +package {0}.tests.helper; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.frame.FrameSearchFlag; +import com.sun.star.frame.XComponentLoader; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiComponentFactory; +import com.sun.star.text.XTextDocument; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; + +import {0}.tests.base.UnoSuite; + +public class UnoHelper '{' + + public static XTextDocument getWriterDocument() throws Exception '{' + XMultiComponentFactory xMngr = UnoSuite.getComponentContext().getServiceManager(); + Object oDesktop = xMngr.createInstanceWithContext("com.sun.star.frame.Desktop", UnoSuite.getComponentContext()); + XComponentLoader xLoader = (XComponentLoader)UnoRuntime.queryInterface( + XComponentLoader.class, oDesktop); + + XComponent xDoc = xLoader.loadComponentFromURL("private:factory/swriter", "_default", + FrameSearchFlag.ALL, new PropertyValue[0]); + + return (XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, xDoc); + } + +} \ No newline at end of file diff --git a/python/source/org/libreoffice/ide/eclipse/python/tests/messages.properties b/python/source/org/libreoffice/ide/eclipse/python/tests/messages.properties new file mode 100644 index 0000000..044e69d --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/tests/messages.properties @@ -0,0 +1 @@ +TestsHelper.AddJUnitError=Error adding JUnit libraries diff --git a/python/source/org/libreoffice/ide/eclipse/python/tests/uno/WriterTest.java.tpl b/python/source/org/libreoffice/ide/eclipse/python/tests/uno/WriterTest.java.tpl new file mode 100644 index 0000000..f04d519 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/tests/uno/WriterTest.java.tpl @@ -0,0 +1,26 @@ +package {0}.tests.uno; + +import static org.junit.Assert.assertNotNull; + +import org.junit.Before; +import org.junit.Test; + +import com.sun.star.text.XTextDocument; + +import {0}.tests.helper.UnoHelper; + +public class WriterTest '{' + + private XTextDocument xTextDocument; + + @Before + public void setUp() throws Exception '{' + xTextDocument = UnoHelper.getWriterDocument(); + } + + @Test + public void test() '{' + assertNotNull(xTextDocument); + } + +} \ No newline at end of file diff --git a/python/source/org/libreoffice/ide/eclipse/python/utils/Messages.java b/python/source/org/libreoffice/ide/eclipse/python/utils/Messages.java new file mode 100644 index 0000000..f8b16a1 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/utils/Messages.java @@ -0,0 +1,79 @@ +/************************************************************************* + * + * $RCSfile: Messages.java,v $ + * + * $Revision: 1.2 $ + * + * last change: $Author: cedricbosdo $ $Date: 2007/11/25 20:32:39 $ + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * Sun Microsystems Inc., October, 2000 + * + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. + * + * Copyright: 2002 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): Cedric Bosdonnat + * + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.utils; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * Messages for the package. + */ +public class Messages { + private static final String BUNDLE_NAME = "org.libreoffice.ide.eclipse.java.utils.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle + .getBundle(BUNDLE_NAME); + + /** + * Default constructor. + */ + private Messages() { + } + + /** + * Get the string from it's key. + * + * @param pKey the key of the string + * + * @return the internationalized string + */ + public static String getString(String pKey) { + String string = '!' + pKey + '!'; + try { + string = RESOURCE_BUNDLE.getString(pKey); + } catch (MissingResourceException e) { + } + return string; + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/utils/TemplatesHelper.java b/python/source/org/libreoffice/ide/eclipse/python/utils/TemplatesHelper.java new file mode 100644 index 0000000..d84fdf0 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/utils/TemplatesHelper.java @@ -0,0 +1,161 @@ +/************************************************************************* + * + * The Contents of this file are made available subject to the terms of + * the GNU Lesser General Public License Version 2.1 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2009 by Cédric Bosdonnat. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * The Initial Developer of the Original Code is: Cédric Bosdonnat. + * + * Copyright: 2009 by Cédric Bosdonnat. + * + * All Rights Reserved. + * + ************************************************************************/ +package org.libreoffice.ide.eclipse.python.utils; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.text.MessageFormat; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.libreoffice.ide.eclipse.core.PluginLogger; +import org.libreoffice.ide.eclipse.core.model.IUnoidlProject; + +/** + * Provides convenient methods to load, and save templates of Java source + * files into a target projet. + * + *

In order to generate the template foo/bar.java.tpl, the following + * call call be used, where LoadingClass is a class from which it is + * possible to run a getResource( "foo/bar.java.tpl" ) to get the file.

+ * + * + * TemplatesHelper.copyTemplate( myProject, "foo/bar", LoadingClass.class ); + * + */ +public class TemplatesHelper { + + public static final String JAVA_EXT = ".java"; //$NON-NLS-1$ + private static final String TEMPLATE_EXT = ".tpl"; //$NON-NLS-1$ + + /** + * Copies the template to the UNO project. + * + * @param pProject the project where to copy the file + * @param pTemplateName the template name (without the extension) + * @param pClazz the class from which to load the resource file + * @param pDestSuffix the subpath in which the file should be copied, relatively to + * the implementation package. + * @param pArgs additional arguments to pass to the formatter + */ + public static void copyTemplate(IUnoidlProject pProject, String pTemplateName, + Class pClazz, String pDestSuffix, Object... pArgs) { + + IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject(pProject.getName()); + + IPath relPath = pProject.getImplementationPath(); + relPath = relPath.append(pDestSuffix); + IFolder dest = pProject.getFolder(relPath); + + // Compute the name of the project's implementation package + String implPkg = pProject.getCompanyPrefix() + "." + pProject.getOutputExtension(); //$NON-NLS-1$ + + Object[] args = new Object[pArgs.length + 1]; + args[0] = implPkg; + System.arraycopy(pArgs, 0, args, 1, pArgs.length); + + copyTemplate(prj, pTemplateName, pClazz, + dest.getProjectRelativePath().toString(), args); + } + + /** + * Copies the template to the project. + * + * @param pProject the project where to copy the file + * @param pTemplateName the template name (without the extension) + * @param pClazz the class from which to load the resource file + * @param pDestPath the path in which the file should be copied, relatively to + * the project root. + * @param pArgs additional arguments to pass to the formatter + */ + public static void copyTemplate(IProject pProject, String pTemplateName, + Class pClazz, String pDestPath, Object... pArgs) { + + String fileName = pTemplateName + TEMPLATE_EXT; + + // Get the path where to place the files + IContainer dest = pProject; + if (pDestPath != null && !pDestPath.equals(new String())) { + dest = pProject.getFolder(pDestPath); + dest.getLocation().toFile().mkdirs(); + } + + // Read the template into a buffer + FileWriter writer = null; + + BufferedReader patternReader = null; + InputStream in = null; + try { + // Destination file opening + IFile classIFile = dest.getFile(new Path(pTemplateName)); + File classFile = classIFile.getLocation().toFile(); + + if (!classFile.exists()) { + classFile.getParentFile().mkdirs(); + classFile.createNewFile(); + } + writer = new FileWriter(classFile); + + // Input template opening + in = pClazz.getResourceAsStream(fileName); + patternReader = new BufferedReader(new InputStreamReader(in)); + + // Loop over the lines, format and write them. + String line = patternReader.readLine(); + while (line != null) { + line = MessageFormat.format(line, pArgs); + writer.append(line + "\n"); //$NON-NLS-1$ + line = patternReader.readLine(); + } + } catch (IOException e) { + // log the error + String msg = MessageFormat.format(Messages.getString("TemplatesHelper.ErrorPattern"), //$NON-NLS-1$ + pTemplateName, Messages.getString("TemplatesHelper.ReadError")); //$NON-NLS-1$ + PluginLogger.error(msg, e); + } finally { + try { + patternReader.close(); + in.close(); + writer.close(); + } catch (Exception e) { + } + } + } +} diff --git a/python/source/org/libreoffice/ide/eclipse/python/utils/messages.properties b/python/source/org/libreoffice/ide/eclipse/python/utils/messages.properties new file mode 100644 index 0000000..7c1ae23 --- /dev/null +++ b/python/source/org/libreoffice/ide/eclipse/python/utils/messages.properties @@ -0,0 +1,3 @@ +TemplatesHelper.ErrorPattern=Error during {0} creation [{1}] +TemplatesHelper.ReadError=reading file +ZipContentHelper.NotDirectoryError=Not a directory: