Extend Sirius tab-bar extension [message #1697448] |
Thu, 04 June 2015 03:44 |
Tuan Hoang Anh Messages: 42 Registered: May 2015 |
Member |
|
|
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 15:00 |
|
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
Maxime Porhel - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
|
|
Re: Extend Sirius tab-bar extension [message #1698384 is a reply to message #1697600] |
Mon, 15 June 2015 08:35 |
|
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
Pierre-Charles David - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04000 seconds