Skip to content
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

Merged
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 34 additions & 6 deletions build/build.xml
Expand Up @@ -47,6 +47,7 @@

<import file="../core/build.xml"/>
<import file="../java/build.xml"/>
<import file="../python/build.xml"/>

<target name="help" description="Tells how to run the script">
<echo>
Expand All @@ -71,7 +72,7 @@
</echo>
</target>

<target name="init-env" depends="core.init-env, java.init-env">
<target name="init-env" depends="core.init-env, java.init-env, python.init-env">

<property name="package.prefix" value="org.libreoffice.ide.eclipse"/>

Expand All @@ -98,12 +99,12 @@
</target>

<target name="purge" description="Cleans all the output results"
depends="core.purge, java.purge">
depends="core.purge, java.purge, python.purge">
<delete dir="../site"/>
<delete file="../loeclipseintegration_site.zip" />
</target>

<target name="versions" depends="core.version, java.version" />
<target name="versions" depends="core.version, java.version, python.version" />

<target name="java.feature.nobuild" if="java.nobuild">
<property name="includes.java" value=""/>
Expand All @@ -127,11 +128,38 @@
</target>

<target name="java.feature" depends="java.feature.build, java.feature.nobuild"/>

<!--Addition of feature.xml for Python plugin starts-->

<target name="python.feature.nobuild" if="python.nobuild">
<property name="includes.python" value=""/>
</target>

<target name="features" depends="versions, java.feature"/>
<target name="plugins" depends="core.plugin, java.plugin"/>
<target name="python.feature.build" depends="versions" unless="python.nobuild">
<copy file="features/python/feature.xml"
tofile="${out.path}/features/feature.xml">
<filterchain>
<expandproperties/>
</filterchain>
</copy>

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the indentation here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation has been looked after.

<zipfileset dir="${out.path}/features" prefix="" defaultexcludes="true">
<include name="feature.xml"/>
</zipfileset>
</jar>

<delete file="${out.path}/features/feature.xml"/>
</target>

<target name="python.feature" depends="python.feature.build, python.feature.nobuild"/>

<!--Addition of feature.xml for Python plugin ends-->

<target name="features" depends="versions, java.feature, python.feature"/>
<target name="plugins" depends="core.plugin, java.plugin, python.plugin"/>

<target name="site" depends="init-env, plugins, features, core.site, java.site"
<target name="site" depends="init-env, plugins, features, core.site, java.site, python.site"
description="Creates the Eclipse update site">

<!--
Expand Down
1 change: 1 addition & 0 deletions build/features/python/build.properties
@@ -0,0 +1 @@
bin.includes = feature.xml
340 changes: 340 additions & 0 deletions build/features/python/feature.xml

Large diffs are not rendered by default.

Expand Up @@ -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")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

// Creation of the unoidl package
createUnoidlPackage(unoProject, pMonitor);

// Creation of the Code Packages
createCodePackage(unoProject, pMonitor);
// Creation of the Code Packages
createCodePackage(unoProject, pMonitor);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order was restored since the source folder was created inside configureProject(UnoFactoryData pData, IProgressMonitor pMonitor)

// Creation of the urd output directory
createUrdDir(unoProject, pMonitor);
// Creation of the urd output directory
createUrdDir(unoProject, pMonitor);
}

return unoProject;
}
Expand Down
Expand Up @@ -53,7 +53,7 @@
*/
public class OfficeLaunchShortcut implements ILaunchShortcut {

private static final String OFFICE_LAUNCH_CONFIG_ID = "org.libreoffice.ide.eclipse.core.launchLibreOffice"; //$NON-NLS-1$
private static final String OFFICE_LAUNCH_CONFIG_ID = "org.libreoffice.ide.eclipse.core.launchlibreoffice"; //$NON-NLS-1$

/**
* {@inheritDoc}
Expand Down
Expand Up @@ -287,6 +287,7 @@ public void endElement(String pUri, String pLocalName, String pName) throws SAXE

if (XMLTokens.ELEMENT_NAME.equals(pName) && mLocale != null) {
PublisherInfos infos = new PublisherInfos();
infos.setModel(mModel);
infos.setName(mName);
infos.setUrl(mRef);
mModel.addPublisherInfo(mLocale, infos);
Expand Down
Expand Up @@ -309,7 +309,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")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be language independent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

UnoFactoryData data = new UnoFactoryData();
LanguageWizardPage page = lang.getNewWizardPage();
if (page != null) {
Expand Down
Expand Up @@ -551,12 +551,14 @@ public void doFinish(IProgressMonitor pMonitor, IWorkbenchPage pActivePage) {
UnoidlProjectHelper.forceBuild(prj, pMonitor);

// Create the implementation skeleton
UnoFactoryData wizardSetData = new UnoFactoryData();
wizardSetData.addInnerData(serviceData);
wizardSetData.setProperty(IUnoFactoryConstants.PROJECT_LANGUAGE, prj.getLanguage());
wizardSetData.setProperty(IUnoFactoryConstants.PROJECT_NAME, prj.getName());
UnoFactory.makeSkeleton(wizardSetData, pActivePage, pMonitor);
wizardSetData.dispose();
if (!prj.getLanguage().getName().contains("Python")) {
UnoFactoryData wizardSetData = new UnoFactoryData();
wizardSetData.addInnerData(serviceData);
wizardSetData.setProperty(IUnoFactoryConstants.PROJECT_LANGUAGE, prj.getLanguage());
wizardSetData.setProperty(IUnoFactoryConstants.PROJECT_NAME, prj.getName());
UnoFactory.makeSkeleton(wizardSetData, pActivePage, pMonitor);
wizardSetData.dispose();
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"


} catch (Exception e) {
PluginLogger.error(Messages.getString("ServiceWizardSet.ServiceCreationError"), e); //$NON-NLS-1$
Expand Down
Expand Up @@ -44,6 +44,7 @@ NewUnoProjectWizard.ProjectCreationErrorMessage=An error occured during the proj
NewUnoProjectPage.InvalidPrefixError=The company prefix is a package like name
NewUnoProjectPage.ProjectCreationError=Error during the project folder creation
NewUnoProjectPage.WhiteSpacesWarning=It is not recommended to have any whitespace in the project path:\nthe project might fail to build
NewUnoProjectPage.SpecialSymbolsInProjectNameError=No Blank Space and _ allowed in Project Name.
NewUnoProjectPage.CustomSourcesLabel=Sources
NewScopedElementWizardPage.Published=Published. Defines wether the type is stable \
enough to be used by client code.
Expand Down
Expand Up @@ -147,6 +147,7 @@ public class NewUnoProjectPage extends WizardNewProjectCreationPage implements I
@Override
public void modifyText(ModifyEvent pEvent) {
checkWhiteSpaces();
checkSpecialSymbolsinProjectName();
((NewUnoProjectWizard) getWizard()).pageChanged(NewUnoProjectPage.this);
}
};
Expand Down Expand Up @@ -410,6 +411,19 @@ private void checkWhiteSpaces() {
}
}

/**
* Shows a error if there are spaces in the project name.
*/
private void checkSpecialSymbolsinProjectName() {

if (getProjectName().contains(" ") || getProjectName().contains("_")) { //$NON-NLS-1$
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If '_' is used in the Project name then the <Project_NAME>Impl.java file is not created if projects are created using Java language during New Extension PRoject creation, therefore had to put a check on it.

setMessage(Messages.getString("NewUnoProjectPage.SpecialSymbolsInProjectNameError"), //$NON-NLS-1$
ERROR);
setPageComplete(false);
}

}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

/**
* Add the modify listener to all the Text children of the control.
*
Expand Down
Expand Up @@ -238,9 +238,6 @@ public void widgetSelected(SelectionEvent pE) {
dlg.setFilterExtensions(new String[] { "*.oxt" });
String path = dlg.open();
if (path != null) {
if (!path.substring(path.length() - 4).equalsIgnoreCase(".oxt")) {
path += ".oxt";
}
mDestinationCombo.setText(path);
}
}
Expand Down
2 changes: 2 additions & 0 deletions 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
Binary file added java/icons/library_wiz.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Expand Up @@ -92,6 +92,9 @@ public void init(IWorkbench pWorkbench, IStructuredSelection pSelection) {
IResource res = ((IAdaptable) o).getAdapter(IResource.class);
if (res != null) {
prj = ProjectsManager.getProject(res.getProject().getName());
if (!prj.getLanguage().getName().equalsIgnoreCase("Java")) {
prj = null;
}
}
}
}
Expand Down
Expand Up @@ -154,11 +154,15 @@ private void createProjectSelection() {
lbl.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));

IUnoidlProject[] prjs = ProjectsManager.getProjects();
String[] prjNames = new String[prjs.length];
ArrayList<String> tempPrjNames = new ArrayList<>();
for (int i = 0; i < prjs.length; i++) {
IUnoidlProject prj = prjs[i];
prjNames[i] = prj.getName();
//The Dropdown for Ant Script should only have Java Uno Projects
if (prjs[i].getLanguage().getName().equalsIgnoreCase("Java")) {
IUnoidlProject prj = prjs[i];
tempPrjNames.add(prj.getName());
}
}
String[] prjNames = tempPrjNames.toArray(new String[tempPrjNames.size()]);

sProjectsList = new Combo(selectionBody, SWT.DROP_DOWN | SWT.READ_ONLY);
sProjectsList.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
Expand Down
9 changes: 9 additions & 0 deletions python/.checkstyle
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<fileset-config file-format-version="1.2.0" simple-config="true">
<local-check-config name="style ooeclipseintegration" location="/org.libreoffice.ide.eclipse.build/checkstyle.xml" type="project" description="">
<additional-data name="protect-config-file" value="true"/>
</local-check-config>
<fileset name="tous" enabled="true" check-config-name="style ooeclipseintegration" local="true">
<file-match-pattern match-pattern="." include-pattern="true"/>
</fileset>
</fileset-config>
10 changes: 10 additions & 0 deletions python/.classpath
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="src" path="source"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/ANT"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/LO-Classes"/>
<classpathentry kind="output" path="bin"/>
</classpath>
34 changes: 34 additions & 0 deletions python/.project
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.libreoffice.ide.eclipse.python</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>