Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Add Xtext content to toolbar
Add Xtext content to toolbar [message #1815971] Wed, 16 October 2019 11:37 Go to next message
Jozsef Klespitz is currently offline Jozsef KlespitzFriend
Messages: 34
Registered: September 2019
Member
Hello everyone,

I have followed this example and I was able to add a preference setting "icon" to the toolbor.

Now, I wish to further extend this. I have created a new file wizard and new project wizard.
I wish to create dedicated icons for these functionalities on the toolbar.

My question is: How can I create command for MyDslProjectTemplateProvider and MyDslFileTemplateProvider or how to call them in the execute method of MyAbstractHandlerImplementation? (As shown here.)
Re: Add Xtext content to toolbar [message #1816023 is a reply to message #1815971] Thu, 17 October 2019 13:43 Go to previous messageGo to next message
Tamas Miklossy is currently offline Tamas MiklossyFriend
Messages: 157
Registered: February 2016
Senior Member
You may get some insipration from the WizardHandler class.

This class is invoked when the user clicks on the 'Create a plug-in project' button on the toolbar (see screenshot.png).
Re: Add Xtext content to toolbar [message #1816025 is a reply to message #1816023] Thu, 17 October 2019 15:19 Go to previous messageGo to next message
Jozsef Klespitz is currently offline Jozsef KlespitzFriend
Messages: 34
Registered: September 2019
Member
Thank you for the feedback.

The Xtext generates IFileTemplateProvider and IProjectTemplateProvider. Are their usage similar to the WizardHandler in your example?
Re: Add Xtext content to toolbar [message #1816026 is a reply to message #1816025] Thu, 17 October 2019 15:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
dont get this question: the handler invoke the plugin wizard
you create a handler that calls the xtext wizard


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Add Xtext content to toolbar [message #1816027 is a reply to message #1816026] Thu, 17 October 2019 15:29 Go to previous messageGo to next message
Tamas Miklossy is currently offline Tamas MiklossyFriend
Messages: 157
Registered: February 2016
Senior Member
As an alternative you can use the org.eclipse.ui.newWizard command (instead of defining your own one) and parameterize that with the wizard Id you want to invoke:
  <extension
       point="org.eclipse.ui.menus">
    <menuContribution
          allPopups="false"
          locationURI="toolbar:org.eclipse.ui.main.toolbar">
       <toolbar
             id="org.eclipse.xtext.example.fowlerdsl.ui.toolbar">
          <!--
            For some reason the tooltip is not shown when hovering over the toolbar button
            See also https://www.eclipse.org/forums/index.php/t/1079111/
          -->           
          <command
                commandId="org.eclipse.ui.newWizard"
                tooltip="Create a statemachine project">
             <parameter
                   name="newWizardId"
                   value="org.eclipse.xtext.example.fowlerdsl.ui.wizard.StatemachineNewProjectWizard">
             </parameter>
          </command>
       </toolbar>
    </menuContribution>
 </extension>

[Updated on: Fri, 18 October 2019 07:35]

Report message to a moderator

Re: Add Xtext content to toolbar [message #1816059 is a reply to message #1816027] Fri, 18 October 2019 10:52 Go to previous messageGo to next message
Jozsef Klespitz is currently offline Jozsef KlespitzFriend
Messages: 34
Registered: September 2019
Member
Sorry, I was unclear beforehand... Let me rephrase the question:
I have added fileWizard and projectWizard {generate=true} to the mwe2 file of my language.
This generated org.eclipse.xtext.mydsl.ui.wizard package with MyDslFileTemplateProvider and MyDslProjectTemplateProvider in it (implementing IFileTemplateProvider and IProjectTemplateProvider respectively).

This is working fine, if I select the New -> Other... option, then I can select MyDsl -> MyDsl File and MyDsl Project in it. The files and projects are created properly after selection.

I want to create dedicated buttons on the toolbar for these two selections (wizards).
My question is: How can I do this?

-My first idea was to create a package, where I invoke the MyDslFileTemplateProvider. This is the point, where I have no idea how to do this.

-Afterwards, I have followed the idea of @Tamas and created a parametrized command, Here, I have replaced the org.eclipse.xtext.example.fowlerdsl.ui.wizard.StatemachineNewProjectWizard with org.eclipse.xtext.mydsl.ui.wizard.MyDslFileTemplateProvider, but this unfortunately resulted Eclipse error ("Unable to generate parametrized command..."). However, the icon is on the toolbar, but it is deactivated.
My guess would be that the parametrized command also expects to invoke somehow MyDslFileTemplateProvider. Am I correct here? (I guess this leads to my previous point.)

[Updated on: Fri, 18 October 2019 10:54]

Report message to a moderator

Re: Add Xtext content to toolbar [message #1816062 is a reply to message #1816059] Fri, 18 October 2019 11:15 Go to previous messageGo to next message
Tamas Miklossy is currently offline Tamas MiklossyFriend
Messages: 157
Registered: February 2016
Senior Member
Instead of
org.eclipse.xtext.example.fowlerdsl.ui.wizard.StatemachineNewProjectWizard
you have to use the id of your generated wizard.
Re: Add Xtext content to toolbar [message #1816063 is a reply to message #1816059] Fri, 18 October 2019 11:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
i still dont get it.
how is MyDslFileTemplateProvider involved in the problem at all?
its used by the wizard. it not is the wizard

you simply tell it: use that handler.
and the handler you tell to use the wizard


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 18 October 2019 11:16]

Report message to a moderator

Re: Add Xtext content to toolbar [message #1816069 is a reply to message #1816063] Fri, 18 October 2019 15:15 Go to previous messageGo to next message
Jozsef Klespitz is currently offline Jozsef KlespitzFriend
Messages: 34
Registered: September 2019
Member
It is working finally. Thank you a lot for your help.

What I did not understand that you did not understand:
The fileWizard and projectWizard in the mwe2 file generates two files MyDslFileTemplateProvider and MyDslProjectTemplateProvider. These are clearly not wizards...
But in the plugin.xml file MyDslNewFileWizard and MyDslNewProjectWizards are defined! Their ID can be copied from there.

This was maybe trivial for you, but I've struggled with it.

Everything works fine with this information combined with the code of Tamas.
Re: Add Xtext content to toolbar [message #1816079 is a reply to message #1816069] Sat, 19 October 2019 10:42 Go to previous message
Tamas Miklossy is currently offline Tamas MiklossyFriend
Messages: 157
Registered: February 2016
Senior Member
Actually the Xtext team tries to give its best to provide APIs that are self-explanatory. However, if something is understandable for us, it does not mean that it is directly understandable to our users.

That's why such feedbacks from the Xtext users are very valuable to us to know how to improve the Xtext framework in the future!

I created an Xtext issue to extend the Wizard Fragment be able to generate such toolbar buttons for the New Project Wizard / New File Wizard.

[Updated on: Sat, 19 October 2019 10:44]

Report message to a moderator

Previous Topic:JVMModelInferrer code generation
Next Topic:mismatched input '0' expecting RULE_ID
Goto Forum:
  


Current Time: Tue Apr 23 06:47:02 GMT 2024

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

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

Back to the top