2 * Copyright (C) 2012 BonitaSoft S.A.
3 * BonitaSoft, 31 rue Gustave Eiffel - 38000 Grenoble
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2.0 of the License, or
7 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 package org.bonitasoft.studio.application.coolbar;
17 import org.bonitasoft.studio.application.actions.OpenIntroCommandHandler;
18 import org.bonitasoft.studio.application.i18n.Messages;
19 import org.bonitasoft.studio.common.extension.IBonitaContributionItem;
20 import org.bonitasoft.studio.common.log.BonitaStudioLog;
21 import org.bonitasoft.studio.pics.Pics;
22 import org.bonitasoft.studio.pics.PicsConstants;
23 import org.eclipse.core.commands.ExecutionEvent;
24 import org.eclipse.core.commands.ExecutionException;
25 import org.eclipse.jface.action.ContributionItem;
26 import org.eclipse.swt.SWT;
27 import org.eclipse.swt.events.SelectionAdapter;
28 import org.eclipse.swt.events.SelectionEvent;
29 import org.eclipse.swt.widgets.ToolBar;
30 import org.eclipse.swt.widgets.ToolItem;
33 * @author Romain Bioteau
35 public class WelcomeCoolbarItem extends ContributionItem implements IBonitaContributionItem {
37 private final OpenIntroCommandHandler handler;
39 public WelcomeCoolbarItem() {
40 handler = new OpenIntroCommandHandler();
45 * @see org.eclipse.jface.action.IContributionItem#getId()
48 public String getId() {
49 return "org.bonitasoft.studio.coolbar.welcome";
53 public String getText() {
54 return Messages.WelcomeButtonLabel;
58 public void fill(final ToolBar toolbar, final int index, final int iconSize) {
59 final ToolItem item = new ToolItem(toolbar, SWT.PUSH | SWT.RIGHT);
60 item.setToolTipText(Messages.WelcomeButtonLabel);
62 item.setImage(Pics.getImage(PicsConstants.coolbar_welcome_32));
63 item.setHotImage(Pics.getImage(PicsConstants.coolbar_welcome_hot_32));
65 item.setImage(Pics.getImage(PicsConstants.coolbar_welcome_24));
66 item.setHotImage(Pics.getImage(PicsConstants.coolbar_welcome_hot_24));
68 item.addSelectionListener(new SelectionAdapter() {
71 public void widgetSelected(final SelectionEvent e) {
73 handler.execute(new ExecutionEvent());
74 } catch (final ExecutionException e1) {
75 BonitaStudioLog.error(e1);