Extend Sirius tab-bar extension [message #1697448] |
Wed, 03 June 2015 23:44  |
Eclipse User |
|
|
|
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;
}
}
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05123 seconds