Commit d1074765 authored by Adrien's avatar Adrien Committed by Romain Bioteau
Browse files

* bind commands to images (#1397)

parent b1abac28
......@@ -105,7 +105,6 @@
locationURI="popup:org.bonitasoft.studio.application.project.explorer.new?after=org.bonitasoft.studio.application.placeholder.organization">
<command
commandId="org.bonitasoft.studio.organization.manage"
icon="icons/organization.png"
id="org.bonitasoft.studio.organization.manage.popup.menu"
label="%newOrganizationLabel"
mnemonic="O"
......@@ -135,7 +134,6 @@
locationURI="popup:org.bonitasoft.studio.application.project.explorer.new?after=org.bonitasoft.studio.application.placeholder.actor">
<command
commandId="org.bonitasoft.studio.actors.newFilterDef"
icon="icons/actor_filter-def-new.png"
label="%newFilterDefMenu"
style="push">
<visibleWhen
......@@ -158,7 +156,6 @@
</command>
<command
commandId="org.bonitasoft.studio.actors.newFilterImpl"
icon="icons/actor_filter-implem-new.png"
label="%newFilterImplMenu"
style="push">
<visibleWhen
......@@ -447,5 +444,20 @@
type="org.eclipse.core.runtime.IAdaptable">
</propertyTester>
</extension>
<extension
point="org.eclipse.ui.commandImages">
<image
commandId="org.bonitasoft.studio.organization.manage"
icon="icons/organization.png">
</image>
<image
commandId="org.bonitasoft.studio.actors.newFilterDef"
icon="icons/actor_filter-def-new.png">
</image>
<image
commandId="org.bonitasoft.studio.actors.newFilterImpl"
icon="icons/actor_filter-implem-new.png">
</image>
</extension>
</plugin>
......@@ -56,4 +56,4 @@ connectorDef=Connector definition...
connectorImpl=Connector implementation...
actorFilterDef=Actor filter definition...
actorFilterImpl=Actor filter implementation...
groovyClass=Groovy class...
\ No newline at end of file
groovyClass=Groovy class...
......@@ -14,6 +14,8 @@
*/
package org.bonitasoft.studio.application.coolbar;
import java.util.Optional;
import org.bonitasoft.studio.application.i18n.Messages;
import org.bonitasoft.studio.businessobject.core.repository.BusinessObjectModelFileStore;
import org.bonitasoft.studio.businessobject.core.repository.BusinessObjectModelRepositoryStore;
......@@ -25,9 +27,11 @@ import org.bonitasoft.studio.pics.PicsConstants;
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.common.NotDefinedException;
import org.eclipse.jface.action.ContributionItem;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Menu;
......@@ -35,6 +39,7 @@ import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandImageService;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.handlers.IHandlerService;
......@@ -43,10 +48,12 @@ public class NewCoolbarItem extends ContributionItem implements IBonitaContribut
protected static final String NEW_DIAGRAM_CMD_ID = "org.bonitasoft.studio.diagram.command.newDiagram";
private ICommandService commandService;
private IHandlerService handlerService;
private ICommandImageService imageService;
public NewCoolbarItem() {
commandService = PlatformUI.getWorkbench().getService(ICommandService.class);
handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class);
imageService = PlatformUI.getWorkbench().getService(ICommandImageService.class);
}
@Override
......@@ -77,6 +84,7 @@ public class NewCoolbarItem extends ContributionItem implements IBonitaContribut
final MenuItem menuItem = new MenuItem(menu, SWT.CHECK);
try {
menuItem.setText(label != null ? label : command.getName());
getCommandImage(commandId).ifPresent(menuItem::setImage);
} catch (NotDefinedException e1) {
BonitaStudioLog.error(e1);
menuItem.setText("unknown command: " + commandId);
......@@ -172,4 +180,9 @@ public class NewCoolbarItem extends ContributionItem implements IBonitaContribut
}
private Optional<Image> getCommandImage(String command) {
return Optional.ofNullable(imageService.getImageDescriptor(command))
.map(ImageDescriptor::createImage);
}
}
......@@ -49,7 +49,6 @@
locationURI="popup:org.bonitasoft.studio.application.project.explorer.new?after=org.bonitasoft.studio.application.placeholder.bdm">
<command
commandId="org.bonitasoft.studio.businessobject.manage"
icon="icons/bdm.png"
id="org.bonitasoft.studio.businessobject.manage.popup.menu"
label="%defineBDMMenu"
mnemonic="B"
......@@ -81,7 +80,6 @@
locationURI="popup:org.bonitasoft.studio.application.project.explorer?after=additions">
<command
commandId="org.bonitasoft.studio.businessobject.openH2Console"
icon="icons/h2.png"
mnemonic="h"
style="push">
<visibleWhen>
......@@ -194,6 +192,17 @@
</activeWhen>
</handler>
</extension>
<extension
point="org.eclipse.ui.commandImages">
<image
commandId="org.bonitasoft.studio.businessobject.manage"
icon="icons/bdm.png">
</image>
<image
commandId="org.bonitasoft.studio.businessobject.openH2Console"
icon="icons/h2.png">
</image>
</extension>
......
......@@ -192,7 +192,6 @@
locationURI="popup:org.bonitasoft.studio.application.project.explorer.new?after=org.bonitasoft.studio.application.placeholder.connector">
<command
commandId="org.bonitasoft.studio.connectors.newDefinition"
icon="icons/connector_def-new.png"
label="%newConnectorDefMenu"
style="push">
<visibleWhen
......@@ -216,7 +215,6 @@
</command>
<command
commandId="org.bonitasoft.studio.connectors.newImplementation"
icon="icons/connector_implem-new.png"
label="%newConnectorImplementationMenu"
style="push">
<visibleWhen
......@@ -338,4 +336,15 @@
</activeWhen>
</handler>
</extension>
<extension
point="org.eclipse.ui.commandImages">
<image
commandId="org.bonitasoft.studio.connectors.newDefinition"
icon="icons/connector_def-new.png">
</image>
<image
commandId="org.bonitasoft.studio.connectors.newImplementation"
icon="icons/connector_implem-new.png">
</image>
</extension>
</plugin>
......@@ -16,7 +16,6 @@
locationURI="popup:org.bonitasoft.studio.application.project.explorer.new?after=org.bonitasoft.studio.application.placeholder.uidartifact">
<command
commandId="org.bonitasoft.studio.designer.command.create.page"
icon="icons/page.png"
label="%newApplicationPage"
style="push">
<visibleWhen
......@@ -40,7 +39,6 @@
</command>
<command
commandId="org.bonitasoft.studio.designer.command.create.layout"
icon="icons/page.png"
label="%newLayout"
style="push">
<visibleWhen
......@@ -64,7 +62,6 @@
</command>
<command
commandId="org.bonitasoft.studio.designer.command.create.widget"
icon="icons/custom_widget.png"
label="%newCustomWidget"
style="push">
<visibleWhen
......@@ -276,4 +273,19 @@
type="org.eclipse.core.runtime.IAdaptable">
</propertyTester>
</extension>
<extension
point="org.eclipse.ui.commandImages">
<image
commandId="org.bonitasoft.studio.designer.command.create.page"
icon="icons/page.png">
</image>
<image
commandId="org.bonitasoft.studio.designer.command.create.widget"
icon="icons/custom_widget.png">
</image>
<image
commandId="org.bonitasoft.studio.designer.command.create.layout"
icon="icons/page.png">
</image>
</extension>
</plugin>
......@@ -364,7 +364,6 @@
locationURI="popup:org.bonitasoft.studio.application.project.explorer.new?after=org.bonitasoft.studio.application.placeholder.diagram">
<command
commandId="org.bonitasoft.studio.diagram.command.newDiagram"
icon="icons/ProcessDiagramFile.gif"
id="org.bonitasoft.studio.diagram.command.newDiagram.popup.menu"
mnemonic="D"
style="push">
......@@ -840,4 +839,11 @@
type="org.eclipse.core.runtime.IAdaptable">
</propertyTester>
</extension>
<extension
point="org.eclipse.ui.commandImages">
<image
commandId="org.bonitasoft.studio.diagram.command.newDiagram"
icon="icons/ProcessDiagramFile.gif">
</image>
</extension>
</plugin>
......@@ -36,7 +36,6 @@
</separator>
<command
commandId="org.bonitasoft.studio.groovy.ui.newScript"
icon="icons/newgroovyclass_wiz.gif"
style="push">
<visibleWhen
checkEnabled="true">
......@@ -115,6 +114,13 @@
</activeWhen>
</handler>
</extension>
<extension
point="org.eclipse.ui.commandImages">
<image
commandId="org.bonitasoft.studio.groovy.ui.newScript"
icon="icons/newgroovyclass_wiz.gif">
</image>
</extension>
</plugin>
......@@ -61,7 +61,6 @@
locationURI="popup:org.bonitasoft.studio.application.project.explorer.new?after=org.bonitasoft.studio.application.placeholder.application">
<command
commandId="org.bonitasoft.studio.la.new.command"
icon="icons/applicationStore.gif"
id="org.bonitasoft.studio.la.new.popup.menu"
label="%newApplicationMenu"
mnemonic="A"
......@@ -213,4 +212,11 @@
type="org.eclipse.core.runtime.IAdaptable">
</propertyTester>
</extension>
<extension
point="org.eclipse.ui.commandImages">
<image
commandId="org.bonitasoft.studio.la.new.command"
icon="icons/applicationStore.gif">
</image>
</extension>
</plugin>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment