New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for Python in LOEclipse Plugin (GSoC - 18) #68

Open
wants to merge 14 commits into
base: master
from

Conversation

Projects
None yet
2 participants
@shobhanmandal
Contributor

shobhanmandal commented May 13, 2018

Project Summary

This project developed under Google Summer of Code,2018 was all about adding capabilities to the LOEclipse Plugin, which is used to develop plugins/ extensions for LibreOffice, such that developers can use Python language to develop these plugins in addition to the existing Java Language.

The following gives out the list of commits that have been made, so that we can achieve the desired result which is creating an Extension project using Python which we can run in a installed LibreOffice.

The List of Commits:

A new separate module for 'Python is created similar to the Java module such that most of the code which corresponds the creation of a Python extension project and also its export is placed under it.

In the earlier commit the .project file which is associated with Python module was missing. We need to have it for proper execution of the Plugin.

In the first commit one of the redundant file content was removed which has no role to play in the Python module followed by, in the second commit users can start exporting their project as an ".oxt" file which can be imported by LibreOffice which is installed in the system.

Both these commits had a lot of omissions made, which we found that were not required in the Python module. These codes were made specifically for Extensions Projects or other LibreOffice Projects made using Java. Putting them under a separate commit since a large number of files were affected so grouped them under the two. Also we put in two changes, such that the build.xml will help in the including the Python module when we go ahead to create the plugin from the build.xml present in the build module and also a skeleton Python file is created when we create a new project using Python.

Run As -> LibreOffice Extension : This is an important requirement of the LibreOffice Plugin which allows users to run their Project directly from the Eclipse itself without manually exporting the project as ".oxt" file and then opening a LibreOffice instance and importing the same ".oxt". This change launched a LibreOffice instance on its own and deployed the necessary ".oxt" (extension) directly into it.

Till now the project created did not show any language associated with the Project (Example: A Java project has J symbol on the Project folder and also in its properties you will see Java Properties). similarly we needed to have something since it is a Python project in addition to being a LibreOffice Extension Project, this commit made sure we had those changes in place.

One of the final and important requirements of the project was the ability to Debug, Java Extension projects had this feature and we needed to implement the same in the Python Extension projects, we took the aid of the PyDev plugin to help us in Debugging the Python extension. You can go through the below link where you will get the idea why we needed the help of the PyDev plugin : https://wiki.documentfoundation.org/Development/Extension_Development/Python_Extensions_Development#Setting_up_a_debugger and to read about how we took the help of PyDev plugin, you can go through the following link : http://www.pydev.org/manual_adv_remote_debugger.html#remote-debugger

Again an important feature of the LibreOffice Extensions are the presence of the "idl" files, in the Java Extension projects these files were included but I had commented them since initially it was not required, but later on realising its importance we made changes such that these files were created. Also we found that Space " " and Underscore "_" if given in Project names were causing Errors during the creation of the Project therefore we introduced error warning if it was given in Project Name.

This commit allows that users/ developers are now seeing the ServicePage and the Interface page in the New Extension Project Wizard if you selected the Language as Python. As earlier mentioned these were commented that time since initially they were not required for the basic of projects.

This is one of the last commits where we have removed any redundant imports, calls, etc. that were present in the module so that they do not have any warnings, secondly we found that under New URE Project we are getting Python as a Language since we have still not developed that part of the module for Python we give out a error when you select Python Language under New URE Project under LibreOffice.

In continuation of the code clean up, this commit contains the addition of the help content to the LibreOffice Plugin Help under Help-> Help Contents (In Eclipse). The Help document contains how to use Python to create the Extension Project.

I have created a video for the creation of New Extension Projects using Python, where I have also showed debugging and running them as application directly from Eclipse using two versions of LibreOffice. https://youtu.be/64XCukPZsxA

Regards,
Shobhan.

@shobhanmandal

This comment has been minimized.

Show comment
Hide comment
@shobhanmandal

shobhanmandal May 24, 2018

Owner

Currently we need to create the necessary files required inside the Project and on the Export page we need to manually select all those files which will be required in .oxt package, to make the export complete.

Owner

shobhanmandal commented on d47c78c May 24, 2018

Currently we need to create the necessary files required inside the Project and on the Export page we need to manually select all those files which will be required in .oxt package, to make the export complete.

@@ -196,14 +196,16 @@ public static IUnoidlProject createStructure(UnoFactoryData pData, IProgressMoni
// Save all the properties to the configuration file
unoProject.saveAllProperties();
// Creation of the unoidl package
createUnoidlPackage(unoProject, pMonitor);
if (!language.getName().contains("Python")) {

This comment has been minimized.

@smehrbrodt

smehrbrodt May 29, 2018

Contributor

This should be language independent. IDL files can be used in all languages.

@smehrbrodt

smehrbrodt May 29, 2018

Contributor

This should be language independent. IDL files can be used in all languages.

This comment has been minimized.

@shobhanmandal

shobhanmandal May 29, 2018

Contributor

https://drive.google.com/drive/folders/1DvyqQIn5WEE7MjcWXIo76UdPk35YcEB_
Page -5 talks about what the 3 functions does:-
createUnoidlPackage(unoProject, pMonitor); -> This makes the idl folder structure inside the Project folder and adds the folder sequence corresponding to CompanyPrefix (Eg: org.libreoffice.example)
lib
|-org
|-libreoffice
|-example

createCodePackage(unoProject, pMonitor); -> This makes the LibreOffice 5.1 libraries visible again, do refer to the Images(Page-4) and if the Source folder does not exist it creates it

createUrdDir(unoProject, pMonitor); -> This creates the build folder under the Project Folder and also places a urd folder under the build Folder

I am sure that last two functions will not be required for the Python module, and as for createUnoidlPackage(unoProject, pMonitor) I will look into it.

@shobhanmandal

shobhanmandal May 29, 2018

Contributor

https://drive.google.com/drive/folders/1DvyqQIn5WEE7MjcWXIo76UdPk35YcEB_
Page -5 talks about what the 3 functions does:-
createUnoidlPackage(unoProject, pMonitor); -> This makes the idl folder structure inside the Project folder and adds the folder sequence corresponding to CompanyPrefix (Eg: org.libreoffice.example)
lib
|-org
|-libreoffice
|-example

createCodePackage(unoProject, pMonitor); -> This makes the LibreOffice 5.1 libraries visible again, do refer to the Images(Page-4) and if the Source folder does not exist it creates it

createUrdDir(unoProject, pMonitor); -> This creates the build folder under the Project Folder and also places a urd folder under the build Folder

I am sure that last two functions will not be required for the Python module, and as for createUnoidlPackage(unoProject, pMonitor) I will look into it.

Show outdated Hide outdated ...source/org/libreoffice/ide/eclipse/core/wizards/NewUnoProjectWizard.java
@@ -309,7 +312,7 @@ public IWorkbench getWorkbench() {
private void updateLoanguagePage() {
// Create/Remove the language page if needed
AbstractLanguage lang = mMainPage.getChosenLanguage();
if (lang != null) {
if (lang != null && !lang.toString().contains("python")) {

This comment has been minimized.

@smehrbrodt

smehrbrodt May 29, 2018

Contributor

This should also be language independent

@smehrbrodt

smehrbrodt May 29, 2018

Contributor

This should also be language independent

This comment has been minimized.

@shobhanmandal

shobhanmandal May 29, 2018

Contributor

This refers to the checkbox on second page of the New Project Wizard page is to include the testclasses, which are yet to be developed for Python therefore we will not allow that particular page to show up in the New Project Wizard.

I believe if condition is required to stop the page from getting in the sequence when Next is pressed

@shobhanmandal

shobhanmandal May 29, 2018

Contributor

This refers to the checkbox on second page of the New Project Wizard page is to include the testclasses, which are yet to be developed for Python therefore we will not allow that particular page to show up in the New Project Wizard.

I believe if condition is required to stop the page from getting in the sequence when Next is pressed

Show outdated Hide outdated ...source/org/libreoffice/ide/eclipse/core/wizards/NewUnoProjectWizard.java
Show outdated Hide outdated python/META-INF/MANIFEST.MF
Show outdated Hide outdated python/source/org/libreoffice/ide/eclipse/python/build/messages.properties
Show outdated Hide outdated python/source/org/libreoffice/ide/eclipse/python/client/ClientWizard.java
Show outdated Hide outdated ...rce/org/libreoffice/ide/eclipse/python/export/AntScriptExportWizard.java
Show outdated Hide outdated ...libreoffice/ide/eclipse/python/registration/RegistrationHandler.java.tpl
Show outdated Hide outdated ...e/org/libreoffice/ide/eclipse/python/test/JavaExportPageControlTest.java
@shobhanmandal

This comment has been minimized.

Show comment
Hide comment
@shobhanmandal

shobhanmandal Jun 6, 2018

Owner

This allows the creation of the Source Folder inside the Project, checked the ordering and found out that this order change would not have any effect in the creation of the Java Project.

This allows the creation of the Source Folder inside the Project, checked the ordering and found out that this order change would not have any effect in the creation of the Java Project.

This comment has been minimized.

Show comment
Hide comment
@shobhanmandal

shobhanmandal Jun 9, 2018

Owner

This change has been reversed, since during the time of the creation of the Empty Python file during the creation of New project the source folder is created.

Owner

shobhanmandal replied Jun 9, 2018

This change has been reversed, since during the time of the creation of the Empty Python file during the creation of New project the source folder is created.

@shobhanmandal

This comment has been minimized.

Show comment
Hide comment
@shobhanmandal

shobhanmandal Jun 6, 2018

Owner

Earlier any changes in the 'description.xml' was not staying permanent. In the next run of eclipse with LOEclipse plugin was giving exception for 'mModel.fireModelChanged();' in 'PublisherInfos.java' under the same package, this was happening because the mModel was not set. Adding the line resolved the issue.

Earlier any changes in the 'description.xml' was not staying permanent. In the next run of eclipse with LOEclipse plugin was giving exception for 'mModel.fireModelChanged();' in 'PublisherInfos.java' under the same package, this was happening because the mModel was not set. Adding the line resolved the issue.

@shobhanmandal

This comment has been minimized.

Show comment
Hide comment
@shobhanmandal

shobhanmandal Jun 6, 2018

Owner

Right click on any UNO Project be it Python or Java, is giving the option to Generate Ant file under the Export option, now this option should come up only if it is a Java Project. Therefore made the changes.

Right click on any UNO Project be it Python or Java, is giving the option to Generate Ant file under the Export option, now this option should come up only if it is a Java Project. Therefore made the changes.

@shobhanmandal

This comment has been minimized.

Show comment
Hide comment
@shobhanmandal

shobhanmandal Jun 6, 2018

Owner

Right click on any UNO Project be it Python or Java, is giving the option to Generate Ant file under the Export option. Now this option should work only if it is a Java Project. Therefore made the changes.
This change is so that on the second page, the drop down only lists those projects which are Java Uno

Right click on any UNO Project be it Python or Java, is giving the option to Generate Ant file under the Export option. Now this option should work only if it is a Java Project. Therefore made the changes.
This change is so that on the second page, the drop down only lists those projects which are Java Uno

@shobhanmandal

This comment has been minimized.

Show comment
Hide comment
@shobhanmandal

shobhanmandal Jun 6, 2018

Owner

The above changes make sure that the user does not have to select the Python files during the time of the Project Export. They are automatically added to the .oxt package and also they are added to the manifest.xml where it was not getting added earlier during the time of the export.

The source folder is the place where the developers are expected to put their Python files, Secondly developers can put their python files inside folders in hierarchical structure, and the function will find and appropriately put them folder-wise both in .oxt file and manfest.xml

The above changes make sure that the user does not have to select the Python files during the time of the Project Export. They are automatically added to the .oxt package and also they are added to the manifest.xml where it was not getting added earlier during the time of the export.

The source folder is the place where the developers are expected to put their Python files, Secondly developers can put their python files inside folders in hierarchical structure, and the function will find and appropriately put them folder-wise both in .oxt file and manfest.xml

IFile pythonSourceFile = srcDir.getFile(prj.getName() + ".py"); //$NON-NLS-1$
IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
WorkbenchHelper.showFile(pythonSourceFile,
windows[0].getActivePage());

This comment has been minimized.

@shobhanmandal

shobhanmandal Jun 14, 2018

Contributor

The source folder is being created and the empty skeleton file is put inside it.

@shobhanmandal

shobhanmandal Jun 14, 2018

Contributor

The source folder is being created and the empty skeleton file is put inside it.

@@ -3,6 +3,6 @@ JODContainerPage.Title=LibreOffice UNO Connector
OOoClasspathContainer.LibrariesName={0} libraries
OOoContainerPage.DialogDescription=LibreOffice Library edition page
OOoContainerPage.DialogImage=/icons/library_wiz.png
OOoContainerPage.DialogImage=/icons/library_wiz.gif
OOoContainerPage.DialogTitle=LibreOffice Libraries
OOoContainerPage.ClasspathSetFailed=Error while setting the project classpath

This comment has been minimized.

@shobhanmandal

shobhanmandal Jun 14, 2018

Contributor

In the messages.properties file [OOoContainerPage.DialogImage=/icons/library_wiz.png]. When you gor for Right-Click on Java Uno Project -> Java Build Path -> Libraries -> LibreOffice . libraries -> Edit
A wiard comes up, this is the result of OOoContainerPage. [Originally top right corner image is missing] The message.properties has the location of the image, but in that location no image of that name existed. Therefore I downloaded the Eclipse icon pack from
https://git.eclipse.org/c/platform/eclipse.platform.images.git/

TAG DOWNLOAD
R4_6 eclipse.platform.images-R4_6.zip

inside this I used the icon:
/eclipse.platform.images-R4_6/org.eclipse.images/eclipse-gif/org.eclipse.jdt.ui/icons/full/obj16/library_obj.gif and renamed it to 'library_wiz.gif' and placed it under the icons folder inside Java module

@shobhanmandal

shobhanmandal Jun 14, 2018

Contributor

In the messages.properties file [OOoContainerPage.DialogImage=/icons/library_wiz.png]. When you gor for Right-Click on Java Uno Project -> Java Build Path -> Libraries -> LibreOffice . libraries -> Edit
A wiard comes up, this is the result of OOoContainerPage. [Originally top right corner image is missing] The message.properties has the location of the image, but in that location no image of that name existed. Therefore I downloaded the Eclipse icon pack from
https://git.eclipse.org/c/platform/eclipse.platform.images.git/

TAG DOWNLOAD
R4_6 eclipse.platform.images-R4_6.zip

inside this I used the icon:
/eclipse.platform.images-R4_6/org.eclipse.images/eclipse-gif/org.eclipse.jdt.ui/icons/full/obj16/library_obj.gif and renamed it to 'library_wiz.gif' and placed it under the icons folder inside Java module

@smehrbrodt

This comment has been minimized.

Show comment
Hide comment
@smehrbrodt

smehrbrodt Jun 22, 2018

Contributor

Is there a reason for this change?

Is there a reason for this change?

This comment has been minimized.

Show comment
Hide comment
@shobhanmandal

shobhanmandal Jun 22, 2018

Contributor

I was getting a null pointer exception at
ILaunchConfigurationWorkingCopy createdConfiguration = type.newInstance(null, name);
because in the following line
ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(OFFICE_LAUNCH_CONFIG_ID);
type is getting its value as 'null', as there are no ConfigurationType to match 'org.libreoffice.ide.eclipse.core.launchLibreOffice' in the plugin.xml under the core module.

Contributor

shobhanmandal replied Jun 22, 2018

I was getting a null pointer exception at
ILaunchConfigurationWorkingCopy createdConfiguration = type.newInstance(null, name);
because in the following line
ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(OFFICE_LAUNCH_CONFIG_ID);
type is getting its value as 'null', as there are no ConfigurationType to match 'org.libreoffice.ide.eclipse.core.launchLibreOffice' in the plugin.xml under the core module.

@smehrbrodt

Your changes look good, nice :)

Some comments inside...

</filterchain>
</copy>
<jar destfile="${out.path}/features/${package.prefix}.python_${python.Bundle-Version}.jar">

This comment has been minimized.

@smehrbrodt

smehrbrodt Jun 25, 2018

Contributor

Please fix the indentation here

@smehrbrodt

smehrbrodt Jun 25, 2018

Contributor

Please fix the indentation here

This comment has been minimized.

@shobhanmandal

shobhanmandal Jun 26, 2018

Contributor

The indentation has been looked after.

@shobhanmandal

shobhanmandal Jun 26, 2018

Contributor

The indentation has been looked after.

Show outdated Hide outdated ...ce/org/libreoffice/ide/eclipse/python/JavaDebugExtraOptionsProvider.java
Show outdated Hide outdated python/source/org/libreoffice/ide/eclipse/python/PythonBuilder.java
Show outdated Hide outdated python/source/org/libreoffice/ide/eclipse/python/PythonProjectHandler.java
Show outdated Hide outdated python/source/org/libreoffice/ide/eclipse/python/messages.properties
} catch (CoreException e) {
PluginLogger.error(Messages.getString("Language.NatureSettingFailed")); //$NON-NLS-1$
}

This comment has been minimized.

@shobhanmandal

shobhanmandal Jun 29, 2018

Contributor

This allows that in the '.project' file located under the Projct folder. The following set of line is added:-
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>

<nature>org.python.pydev.pythonNature</nature>

Which ultimately adds the Python nature to the Project, one thing to note is PyDev should be present in the Eclipse earlier.

Referenced from: http://www.pydev.org/faq.html#ImportExistingSources

@shobhanmandal

shobhanmandal Jun 29, 2018

Contributor

This allows that in the '.project' file located under the Projct folder. The following set of line is added:-
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>

<nature>org.python.pydev.pythonNature</nature>

Which ultimately adds the Python nature to the Project, one thing to note is PyDev should be present in the Eclipse earlier.

Referenced from: http://www.pydev.org/faq.html#ImportExistingSources

}
}

This comment has been minimized.

@shobhanmandal

shobhanmandal Jul 9, 2018

Contributor

These set of changes makes sure that an error sign is shown when there is a space given in the name of the Project and also the Next and Finish button are disabled.

@shobhanmandal

shobhanmandal Jul 9, 2018

Contributor

These set of changes makes sure that an error sign is shown when there is a space given in the name of the Project and also the Next and Finish button are disabled.

PluginLogger.error("Could not start the debug server and start the LibreOffice Instance.", e);
}
}
}

This comment has been minimized.

@shobhanmandal

shobhanmandal Jul 9, 2018

Contributor

This allows us to start the PyDev server to be started when user selects the Debug mode, we have to go for create a new thread and execute it in a asynchronus mode since in the same thread it will throw 'Invalid thread access'

@shobhanmandal

shobhanmandal Jul 9, 2018

Contributor

This allows us to start the PyDev server to be started when user selects the Debug mode, we have to go for create a new thread and execute it in a asynchronus mode since in the same thread it will throw 'Invalid thread access'

wizardSetData.setProperty(IUnoFactoryConstants.PROJECT_NAME, prj.getName());
UnoFactory.makeSkeleton(wizardSetData, pActivePage, pMonitor);
wizardSetData.dispose();
}

This comment has been minimized.

@shobhanmandal

shobhanmandal Jul 14, 2018

Contributor

The makeSkeleton function is actually responsible for creating the <Project_NAME>Impl.java file using the command "uno-skeletonmaker" since this is not of any help towards the python files therefore had to put under the if else condition. "http://bosdonnat.fr/improving-the-uno-skeletonmaker.html"

@shobhanmandal

shobhanmandal Jul 14, 2018

Contributor

The makeSkeleton function is actually responsible for creating the <Project_NAME>Impl.java file using the command "uno-skeletonmaker" since this is not of any help towards the python files therefore had to put under the if else condition. "http://bosdonnat.fr/improving-the-uno-skeletonmaker.html"

@shobhanmandal shobhanmandal changed the title from A new Module is created for placing the codes for Python (Deliverable 1) to Add Support for Python in LOEclipse Plugin Jul 24, 2018

@shobhanmandal shobhanmandal changed the title from Add Support for Python in LOEclipse Plugin to Add Support for Python in LOEclipse Plugin (GSOC - 18) Jul 24, 2018

@shobhanmandal shobhanmandal changed the title from Add Support for Python in LOEclipse Plugin (GSOC - 18) to Add Support for Python in LOEclipse Plugin (GSoC - 18) Jul 24, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment