Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Gendoc » element first occurence page number
element first occurence page number [message #1758509] Wed, 29 March 2017 13:11 Go to next message
Geoffrey Jacquemin is currently offline Geoffrey JacqueminFriend
Messages: 13
Registered: February 2017
Junior Member
Hi experts !

I need to refer in my generated document the page number of some elements where they appear for the first time (they can appear multiple times in the document)

For example, en element 'X' appears the first time on the second page of the generated document. I want to display this page number everytime this element 'X' reappear elsewhere in the document

Is it possible to do this ? Or is it possible to store the page number of the first occurence of each element somewhere and use it during the generation to create the link?
Re: element first occurence page number [message #1758583 is a reply to message #1758509] Thu, 30 March 2017 09:52 Go to previous messageGo to next message
Antonio Campesino is currently offline Antonio CampesinoFriend
Messages: 56
Registered: August 2016
Member
Hi!

What you can do,it is setup a bookmark when the element appears the first time, named with the id of the element. You can see how the gendoc handle the bookmarks, and then create a cross reference, Reference Type: Bookmark; Reference To: page number and choose the bookmark you have created.
Then you display the field codes (Toggle Field codes) and change the bookmark to the acceleo query where you get the id of the element.

I think that will do the trick,

Regards,
Antonio
Re: element first occurence page number [message #1759380 is a reply to message #1758583] Mon, 10 April 2017 23:01 Go to previous messageGo to next message
Geoffrey Jacquemin is currently offline Geoffrey JacqueminFriend
Messages: 13
Registered: February 2017
Junior Member
Hi,

Sorry for the delay, i was on vacation.

Thanks a lot for your reply, i'm going to try your solution.
I'll let you know if it works.

[Updated on: Mon, 10 April 2017 23:02]

Report message to a moderator

Re: element first occurence page number [message #1759633 is a reply to message #1759380] Fri, 14 April 2017 08:31 Go to previous messageGo to next message
Geoffrey Jacquemin is currently offline Geoffrey JacqueminFriend
Messages: 13
Registered: February 2017
Junior Member
hi,

i have a problem. I know what to do but i don't know how and not sure if it's even possible to do.
In order to create a bookmark only once (the first time the element appears), i need to set a variable ( for instance from '0' to '1'). In fact, i call a fragment in which i display my element, and this fragment is called many times in my document; i tried to use [let] expression with a counter variable but every time the fragment is called, the counter variable is set back to '0'. So, the bookmark is created more that once.

Is there a way to define a variable outside so that it wouldn't be overwrite with 0 each time ?

An other thing i would like to know: Is there possible in gendoc to call an external service (a java method i.e) ?


ps: Sorry for my bad english

Geoffrey
Re: element first occurence page number [message #1759646 is a reply to message #1759633] Fri, 14 April 2017 12:38 Go to previous messageGo to next message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 460
Registered: July 2009
Senior Member
Hello

indeed fragments is not used for queries

It would be nice to use gGet and gPut but Acceleo caches the result of the queries and it would not allow you to get incremented values

maybe indeed you can use a java service to get the value, explanation to create a java service
you can check for existing code to see how it works http://git.eclipse.org/c/gendoc/org.eclipse.gendoc.git/tree/plugins/org.eclipse.gendoc.bundle.acceleo.papyrus

feel free to ask questions if you are new to eclipse plugin development

To share value across several execution you can use a static field but it is not safe or you can get an instance of IRegistryService : http://git.eclipse.org/c/gendoc/org.eclipse.gendoc.git/tree/plugins/org.eclipse.gendoc.services/src/org/eclipse/gendoc/services/IRegistryService.java

through GendocServices.getDefault.get(IRegistryService.class)




Re: element first occurence page number [message #1760345 is a reply to message #1759646] Wed, 26 April 2017 07:58 Go to previous messageGo to next message
Geoffrey Jacquemin is currently offline Geoffrey JacqueminFriend
Messages: 13
Registered: February 2017
Junior Member
Hi,

Thanks for your reply

I checked the existing code on http://git.eclipse.org/c/gendoc/org.eclipse.gendoc.git/tree/plugins/org.eclipse.gendoc.bundle.acceleo.papyrus

In my Template document, i set the expression:
[query public div(r1 : Real, r2 : Real) : Real = invoke('[package]','div(java.lang.Double, java.lang.Double)', Sequence{r1, r2}) /]
[div(2.1,1.7)/]

The [package] is the package of my Class of course.

I created the div method in my class:
public Double div(Double r1, Double r2){
	return r1/r2;
}

(The Class is an existing Class containing some others méthods which are not used by Javaservice)

When i generate the document with Gendoc, nothing is returned. Is there an Eclipse plugin to install in order to use Javaservice, or do i forget something important in my code ?
Re: element first occurence page number [message #1760698 is a reply to message #1760345] Tue, 02 May 2017 07:49 Go to previous messageGo to next message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 460
Registered: July 2009
Senior Member
Hello
did you modify plugin.xml file to declare extension ? an example : http://git.eclipse.org/c/gendoc/org.eclipse.gendoc.git/tree/plugins/org.eclipse.gendoc.bundle.acceleo.papyrus/plugin.xml




Re: element first occurence page number [message #1760739 is a reply to message #1760698] Tue, 02 May 2017 13:44 Go to previous messageGo to next message
Geoffrey Jacquemin is currently offline Geoffrey JacqueminFriend
Messages: 13
Registered: February 2017
Junior Member
No, i didn't.

I'm a little confused with the example. What exactly do i need to configure in my project ? Do i need just the plugin.xml file for declaring the extension or is there something else?
Re: element first occurence page number [message #1760806 is a reply to message #1760739] Wed, 03 May 2017 07:59 Go to previous messageGo to next message
Tristan Faure is currently offline Tristan FaureFriend
Messages: 460
Registered: July 2009
Senior Member
Yeah I'm sorry if you are not used to eclipse development application.

So to be sure :
you have an eclipse with a workspace containing your sources : we will name it EclipseDev

In EclipseDev you have defined your acceleo code inside an eclipse plugin. In this plugin you should have a plugin.xml file if it is not the case open the manifest.mf file and go to extensions tab and add something random just to force the plugin.xml file creation. After that you can remove the created extension.

In this plugin.xml file you have to insert :

<extension
         point="org.eclipse.gendoc.script.acceleo.services">
      <service
            emtl="bin/org/eclipse/gendoc/bundle/acceleo/papyrus/mtl/youremtlfile_take_care_it_is_hidden_by_default_in_eclipse.emtl"
            importedByDefault="false"
            name="theNameToInsertInImportedBundles">
      </service>
   </extension>


Take care to have in your meta-inf/manifest.mf file a dependency to : org.eclipse.gendoc.script.acceleo

after all of that.

You have to run a new instance of eclipse named EclipseRuntime from EclipseDev.

Does it seem ok for you ?




Re: element first occurence page number [message #1761027 is a reply to message #1760806] Fri, 05 May 2017 11:50 Go to previous message
Geoffrey Jacquemin is currently offline Geoffrey JacqueminFriend
Messages: 13
Registered: February 2017
Junior Member
Hi.
Thanks for your reply.

Unfortunately,i'm an intern and today is my last day.
I will transfer all documentations i found about Javaservice, in particular this topic, for the next experts who will work on in the company.

Thanks a lot for your help. I wil mention this forum (the community) for the appreciations in my report.
Regards,
Geoffrey

[Updated on: Fri, 05 May 2017 11:52]

Report message to a moderator

Previous Topic:looking for sample code...
Next Topic:GenDoc on Eclipse Neon.3
Goto Forum:
  


Current Time: Thu Dec 12 07:03:32 GMT 2024

Powered by FUDForum. Page generated in 0.04680 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top