Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 280409 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/rap/internal/design/example/business/managers/BusinessCoolBarManager.java (-10 / +4 lines)
Lines 15-22 Link Here
15
import java.util.Map;
15
import java.util.Map;
16
16
17
import org.eclipse.core.commands.Command;
17
import org.eclipse.core.commands.Command;
18
import org.eclipse.core.commands.ExecutionEvent;
19
import org.eclipse.core.commands.ExecutionException;
20
import org.eclipse.core.runtime.Assert;
18
import org.eclipse.core.runtime.Assert;
21
import org.eclipse.jface.action.Action;
19
import org.eclipse.jface.action.Action;
22
import org.eclipse.jface.action.ActionContributionItem;
20
import org.eclipse.jface.action.ActionContributionItem;
Lines 686-697 Link Here
686
      button.setImage( param.getIcon() );
684
      button.setImage( param.getIcon() );
687
      button.addSelectionListener( new SelectionAdapter() {
685
      button.addSelectionListener( new SelectionAdapter() {
688
        public void widgetSelected( final SelectionEvent e ) {
686
        public void widgetSelected( final SelectionEvent e ) {
689
          try {
687
          Command buttonCommand = ( Command ) button.getData();
690
            Command buttonCommand = ( Command ) button.getData();
688
          CommandUtil.executeCommand( buttonCommand );
691
            buttonCommand.getHandler().execute( new ExecutionEvent() );
692
          } catch( ExecutionException e1 ) {
693
            e1.printStackTrace();
694
          }
695
        };
689
        };
696
      } );
690
      } );
697
      button.addDisposeListener( new DisposeListener() {      
691
      button.addDisposeListener( new DisposeListener() {      
Lines 701-708 Link Here
701
      } );
695
      } );
702
      buttonItemMap.put( button, item );
696
      buttonItemMap.put( button, item );
703
    }          
697
    }          
704
  }  
698
  }   
705
  
699
706
  private CommandParameter extractCommandInformation( 
700
  private CommandParameter extractCommandInformation( 
707
    final CommandContributionItem item ) 
701
    final CommandContributionItem item ) 
708
  {
702
  {
(-)src/org/eclipse/rap/internal/design/example/business/CommandUtil.java (-8 / +27 lines)
Lines 11-18 Link Here
11
11
12
import org.eclipse.core.commands.Command;
12
import org.eclipse.core.commands.Command;
13
import org.eclipse.core.commands.CommandManager;
13
import org.eclipse.core.commands.CommandManager;
14
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.core.commands.ExecutionException;
14
import org.eclipse.core.commands.ExecutionException;
15
import org.eclipse.core.commands.NotEnabledException;
16
import org.eclipse.core.commands.NotHandledException;
17
import org.eclipse.core.commands.common.NotDefinedException;
16
import org.eclipse.jface.action.Action;
18
import org.eclipse.jface.action.Action;
17
import org.eclipse.jface.action.IAction;
19
import org.eclipse.jface.action.IAction;
18
import org.eclipse.jface.action.MenuManager;
20
import org.eclipse.jface.action.MenuManager;
Lines 20-25 Link Here
20
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.graphics.Image;
23
import org.eclipse.swt.graphics.Image;
22
import org.eclipse.swt.widgets.Composite;
24
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.swt.widgets.Event;
23
import org.eclipse.swt.widgets.Menu;
26
import org.eclipse.swt.widgets.Menu;
24
import org.eclipse.swt.widgets.ToolBar;
27
import org.eclipse.swt.widgets.ToolBar;
25
import org.eclipse.swt.widgets.ToolItem;
28
import org.eclipse.swt.widgets.ToolItem;
Lines 27-32 Link Here
27
import org.eclipse.ui.IWorkbenchWindow;
30
import org.eclipse.ui.IWorkbenchWindow;
28
import org.eclipse.ui.PlatformUI;
31
import org.eclipse.ui.PlatformUI;
29
import org.eclipse.ui.commands.ICommandService;
32
import org.eclipse.ui.commands.ICommandService;
33
import org.eclipse.ui.handlers.IHandlerService;
30
import org.eclipse.ui.menus.CommandContributionItem;
34
import org.eclipse.ui.menus.CommandContributionItem;
31
import org.eclipse.ui.menus.IMenuService;
35
import org.eclipse.ui.menus.IMenuService;
32
36
Lines 105-117 Link Here
105
    result = new Action( text, style ){
109
    result = new Action( text, style ){
106
      public void run() {
110
      public void run() {
107
        Command command = param.getCommand();
111
        Command command = param.getCommand();
108
        if( command != null ) {
112
        executeCommand( command );
109
          try {
110
            command.getHandler().execute( new ExecutionEvent() );
111
          } catch( final ExecutionException e ) {
112
            e.printStackTrace();
113
          }
114
        }
115
      }
113
      }
116
    };
114
    };
117
    ImageDescriptor desc = new ImageDescriptor() {
115
    ImageDescriptor desc = new ImageDescriptor() {
Lines 181-184 Link Here
181
    toolbar.dispose();
179
    toolbar.dispose();
182
    return result;
180
    return result;
183
  }
181
  }
182
  
183
  public static void executeCommand( final Command command ) {
184
    if( command != null ) {
185
      IWorkbench workbench = PlatformUI.getWorkbench();
186
      Object service = workbench.getService( IHandlerService.class );
187
      if( service != null && service instanceof IHandlerService ) {
188
        IHandlerService handlerService = ( IHandlerService ) service;
189
        try {
190
          handlerService.executeCommand( command.getId(), new Event() );
191
        } catch( ExecutionException e ) {
192
          e.printStackTrace();
193
        } catch( NotDefinedException e ) {
194
          e.printStackTrace();
195
        } catch( NotEnabledException e ) {
196
          e.printStackTrace();
197
        } catch( NotHandledException e ) {
198
          e.printStackTrace();
199
        }
200
      }
201
    }
202
  }
184
}
203
}

Return to bug 280409