Skip to main content



      Home
Home » Eclipse Projects » Sirius » Extend Sirius tab-bar extension
Extend Sirius tab-bar extension [message #1697448] Wed, 03 June 2015 23:44 Go to next message
Eclipse UserFriend
Hi all,

I want to expand my Sirius tab-bar extension with a button. My button will show a simple message dialog when user clicks.

Firstly, I created a "Hello World" command contribution follow Extension Wizard. It works fine. And then, I replace the locationURI of menuContribution from "toolbar:org.eclipse.ui.main.toolbar?after=additions" to "toolbar:org.eclipse.sirius.diagram.ui.tabbar?after=additions", but I can't see the button in the Sirius tab-bar. Could anyone please guide me how to do it?
Plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension
         point="org.eclipse.ui.commands">
      <category
            id="test.commands.category"
            name="Sample Category">
      </category>
      <command
            categoryId="test.commands.category"
            id="test.commands.sampleCommand"
            name="Sample Command">
      </command>
   </extension>
   <extension
         point="org.eclipse.ui.handlers">
      <handler
            class="test.handlers.SampleHandler"
            commandId="test.commands.sampleCommand">
      </handler>
   </extension>
   <extension
         point="org.eclipse.ui.bindings">
      <key
            commandId="test.commands.sampleCommand"
            contextId="org.eclipse.ui.contexts.window"
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
            sequence="M1+6">
      </key>
   </extension>
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            locationURI="toolbar:org.eclipse.sirius.diagram.ui.tabbar?after=additions">
         <menu
               id="test.menus.sampleMenu"
               label="Sample Menu"
               mnemonic="M">
            <command
                  commandId="test.commands.sampleCommand"
                  id="test.menus.sampleCommand"
                  mnemonic="S">
            </command>
         </menu>
      </menuContribution>
      <menuContribution
            locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
         <toolbar
               id="test.toolbars.sampleToolbar">
            <command
                  commandId="test.commands.sampleCommand"
                  icon="icons/sample.gif"
                  id="test.toolbars.sampleCommand"
                  tooltip="Say hello world">
            </command>
         </toolbar>
      </menuContribution>
   </extension>

</plugin>


SampleHandler.java
package test.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.jface.dialogs.MessageDialog;

/**
 * Our sample handler extends AbstractHandler, an IHandler base class.
 * @see org.eclipse.core.commands.IHandler
 * @see org.eclipse.core.commands.AbstractHandler
 */
public class SampleHandler extends AbstractHandler {
	/**
	 * The constructor.
	 */
	public SampleHandler() {
	}

	/**
	 * the command has been executed, so extract extract the needed information
	 * from the application context.
	 */
	public Object execute(ExecutionEvent event) throws ExecutionException {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
		MessageDialog.openInformation(
				window.getShell(),
				"Test",
				"Hello, Eclipse world");
		return null;
	}
}
Re: Extend Sirius tab-bar extension [message #1697527 is a reply to message #1697448] Thu, 04 June 2015 11:00 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Do you have any errors in the error log ?

I have just tried the example from our test suite and it works fine with
command elements in the menu contribution.

You should try with (I have removed the menu item to directly provide
the command as menu contribution child):

<extension point="org.eclipse.ui.menus">
<menuContribution
locationURI="toolbar:org.eclipse.sirius.diagram.ui.tabbar?after=additions">
<command
commandId="test.commands.sampleCommand"
id="test.menus.sampleCommand"
mnemonic="S">
</command>
</menuContribution>
</extension>



I have also detected two errors in the documentation [1]
. in the sample property tester: shouldActivateTabbarExtensionid
should be replaced by id
. the Sirius diagram editor id is
org.eclipse.sirius.diagram.ui.part.SiriusDiagramEditorID


Regards

--
Maxime - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius
--
[1]
https://www.eclipse.org/sirius/doc/developer/extensions-provide_tabbar_extensions.html
Re: Extend Sirius tab-bar extension [message #1697567 is a reply to message #1697527] Thu, 04 June 2015 22:24 Go to previous messageGo to next message
Eclipse UserFriend
Hi Maxime,

Thank you so much for support.
I have no error in the error log.

When I tried follow your guide, it works fine.
In my example, I found that when I removed the toolbar tag, the button could be displayed.

<toolbar
               id="test.toolbars.sampleToolbar">
               ...
</toolbar>


Could you please explain me what happens with this tag in the original code?

Thanks and Best Regards,
Tuan
Re: Extend Sirius tab-bar extension [message #1697582 is a reply to message #1697567] Fri, 05 June 2015 03:10 Go to previous messageGo to next message
Eclipse UserFriend
Le 05/06/2015 04:24, Tuan Hoang Anh a écrit :
> Hi Maxime,
>
> Thank you so much for support.
> I have no error in the error log.
>
> When I tried follow your guide, it works fine.
> In my example, I found that when I removed the toolbar tag, the button
> could be displayed.
>
>
> <toolbar
> id="test.toolbars.sampleToolbar">
> ...
> </toolbar>
>
>
> Could you please explain me what happens with this tag in the original
> code?

Sirius simply ask the platform to populate its the toolbar:

IMenuService menuService = (IMenuService)
part.getSite().getService(IMenuService.class);
menuService.populateContributionManager(manager, "toolbar:" +
Tabbar.TABBAR_ID);

Sirius is building its own toolbar so you cannot add a toolbar in it but
you should be able to add separators (see [1]

There should be some limitation in the toolbar contributions.

You will find more information in the org.eclipse.ui.menus extension
point documentation [2]

>
> Thanks and Best Regards,
> Tuan



Regards

--
Maxime - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius
--
[1] https://wiki.eclipse.org/Menu_Contributions#toolbar:
[2]
http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fextension-points%2Forg_eclipse_ui_menus.html
Re: Extend Sirius tab-bar extension [message #1697600 is a reply to message #1697582] Fri, 05 June 2015 05:42 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Thank you for this post, I am also trying to extend the Sirius tab-bar. Wink

So, I followed the tutorial and it does not work yet.

During my code expeditions, i founded in Tabbar.java:

if (canBeDynamic()) {
     diagramFiller = new TabbarFillerWithContributions(manager, page);
} else {
     diagramFiller = new TabbarFillerWithoutContributions(manager, page);
}


where "canBeDynamic()" gives "false" when the application is based on Juno or Kepler.

Given that i am using Kepler... TabbarFillerWithoutContributions is executed... so my contribution is not considered !

I'am using Sirius 2.0.2 on a Kepler RCP Application.

Could anyone say me :
- Is it fixed on Sirius 2.0.5?
- Is there a way to get around it?

Thank you.
Re: Extend Sirius tab-bar extension [message #1698384 is a reply to message #1697600] Mon, 15 June 2015 04:35 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Le 05/06/2015 11:42, Jonathan Lasalle a écrit :
> where "canBeDynamic()" gives "false" when the application is based on
> Juno or Kepler.
>
> Given that i am using Kepler... TabbarFillerWithoutContributions is
> executed... so my contribution is not considered !
>
> I'am using Sirius 2.0.2 on a Kepler RCP Application.
>
> Could anyone say me :
> - Is it fixed on Sirius 2.0.5?
> - Is there a way to get around it?

Sorry, but we can not fix the problem in Sirius, as the bug is/was in
the platform itself: https://bugs.eclipse.org/bugs/show_bug.cgi?id=410426.

We fixed it there (well, Maxime did), but that fix only appeared in
Luna. So Juno and Kepler have the bug, and because they are not
maintained anymore they will always do.

Regards,

--
Pierre-Charles David - Obeo

Need professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Extend Sirius tab-bar extension [message #1731655 is a reply to message #1698384] Mon, 09 May 2016 01:18 Go to previous messageGo to next message
Eclipse UserFriend
Hi All

I have been trying to extend the Sirius tab-bar for the last 1 week but in vain. I have followed the suggestions as mentioned in this message trail as well as followed the link : https://www.eclipse.org/sirius/doc/developer/extensions-provide_tabbar_extensions.html . The problem which looked easy to me at the start seems to become difficult with time. Please help. My plugin.xml has the following lines:
<extension point="org.eclipse.ui.menus">  
    <menuContribution
          allPopups="false"
          locationURI="toolbar:org.eclipse.sirius.diagram.ui.tabbar?after=additions">
       <command
             commandId="com.model.domain.mnc.design.dashboard"
             icon="images/button.png"
             label="Dashboard"
             style="push"
             tooltip="Open Dashboard">
       </command>
    </menuContribution>
 </extension>
  <extension
        point="org.eclipse.ui.commands">
     <command
           id="com.model.domain.mnc.design.dashboard"
           name="Open Dashboard">
     </command>
  </extension>
  <extension
        point="org.eclipse.ui.handlers">
     <handler
           class="com.model.domain.mnc.design.services.tabbar.DashboardHandler"
           commandId="com.model.domain.mnc.design.dashboard">
     </handler>
  </extension>

I have kept it very simple to start with, without any visibleWhen tags etc. But this doesnt reflect in the runtime instance of eclipse on the sirius editor. Where am I making a mistake? Please help

Puneet
Re: Extend Sirius tab-bar extension [message #1731840 is a reply to message #1731655] Tue, 10 May 2016 08:42 Go to previous message
Eclipse UserFriend
You should have to define the tabbar contribution in UI projects plugin.xml
Previous Topic:Swimlanes with Sirius
Next Topic:Quick question: Retrieving View eObject
Goto Forum:
  


Current Time: Thu Mar 27 17:14:42 EDT 2025

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

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

Back to the top