Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 139549 Details for
Bug 280409
[Design] View action throws NullPointerException when there is no handler
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
HandlerService Solution
handlerNullPointerExc (text/plain), 4.78 KB, created by
Holger Staudacher
on 2009-06-18 10:49:59 EDT
(
hide
)
Description:
HandlerService Solution
Filename:
MIME Type:
Creator:
Holger Staudacher
Created:
2009-06-18 10:49:59 EDT
Size:
4.78 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.design.example >Index: src/org/eclipse/rap/internal/design/example/business/managers/BusinessCoolBarManager.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.design.example/src/org/eclipse/rap/internal/design/example/business/managers/BusinessCoolBarManager.java,v >retrieving revision 1.2 >diff -u -r1.2 BusinessCoolBarManager.java >--- src/org/eclipse/rap/internal/design/example/business/managers/BusinessCoolBarManager.java 15 Jun 2009 17:02:53 -0000 1.2 >+++ src/org/eclipse/rap/internal/design/example/business/managers/BusinessCoolBarManager.java 18 Jun 2009 14:49:43 -0000 >@@ -15,8 +15,6 @@ > import java.util.Map; > > import org.eclipse.core.commands.Command; >-import org.eclipse.core.commands.ExecutionEvent; >-import org.eclipse.core.commands.ExecutionException; > import org.eclipse.core.runtime.Assert; > import org.eclipse.jface.action.Action; > import org.eclipse.jface.action.ActionContributionItem; >@@ -686,12 +684,8 @@ > button.setImage( param.getIcon() ); > button.addSelectionListener( new SelectionAdapter() { > public void widgetSelected( final SelectionEvent e ) { >- try { >- Command buttonCommand = ( Command ) button.getData(); >- buttonCommand.getHandler().execute( new ExecutionEvent() ); >- } catch( ExecutionException e1 ) { >- e1.printStackTrace(); >- } >+ Command buttonCommand = ( Command ) button.getData(); >+ CommandUtil.executeCommand( buttonCommand ); > }; > } ); > button.addDisposeListener( new DisposeListener() { >@@ -701,8 +695,8 @@ > } ); > buttonItemMap.put( button, item ); > } >- } >- >+ } >+ > private CommandParameter extractCommandInformation( > final CommandContributionItem item ) > { >Index: src/org/eclipse/rap/internal/design/example/business/CommandUtil.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.design.example/src/org/eclipse/rap/internal/design/example/business/CommandUtil.java,v >retrieving revision 1.1 >diff -u -r1.1 CommandUtil.java >--- src/org/eclipse/rap/internal/design/example/business/CommandUtil.java 28 May 2009 13:18:24 -0000 1.1 >+++ src/org/eclipse/rap/internal/design/example/business/CommandUtil.java 18 Jun 2009 14:49:43 -0000 >@@ -11,8 +11,10 @@ > > import org.eclipse.core.commands.Command; > import org.eclipse.core.commands.CommandManager; >-import org.eclipse.core.commands.ExecutionEvent; > import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.commands.NotEnabledException; >+import org.eclipse.core.commands.NotHandledException; >+import org.eclipse.core.commands.common.NotDefinedException; > import org.eclipse.jface.action.Action; > import org.eclipse.jface.action.IAction; > import org.eclipse.jface.action.MenuManager; >@@ -20,6 +22,7 @@ > import org.eclipse.swt.SWT; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Event; > import org.eclipse.swt.widgets.Menu; > import org.eclipse.swt.widgets.ToolBar; > import org.eclipse.swt.widgets.ToolItem; >@@ -27,6 +30,7 @@ > import org.eclipse.ui.IWorkbenchWindow; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.commands.ICommandService; >+import org.eclipse.ui.handlers.IHandlerService; > import org.eclipse.ui.menus.CommandContributionItem; > import org.eclipse.ui.menus.IMenuService; > >@@ -105,13 +109,7 @@ > result = new Action( text, style ){ > public void run() { > Command command = param.getCommand(); >- if( command != null ) { >- try { >- command.getHandler().execute( new ExecutionEvent() ); >- } catch( final ExecutionException e ) { >- e.printStackTrace(); >- } >- } >+ executeCommand( command ); > } > }; > ImageDescriptor desc = new ImageDescriptor() { >@@ -181,4 +179,25 @@ > toolbar.dispose(); > return result; > } >+ >+ public static void executeCommand( final Command command ) { >+ if( command != null ) { >+ IWorkbench workbench = PlatformUI.getWorkbench(); >+ Object service = workbench.getService( IHandlerService.class ); >+ if( service != null && service instanceof IHandlerService ) { >+ IHandlerService handlerService = ( IHandlerService ) service; >+ try { >+ handlerService.executeCommand( command.getId(), new Event() ); >+ } catch( ExecutionException e ) { >+ e.printStackTrace(); >+ } catch( NotDefinedException e ) { >+ e.printStackTrace(); >+ } catch( NotEnabledException e ) { >+ e.printStackTrace(); >+ } catch( NotHandledException e ) { >+ e.printStackTrace(); >+ } >+ } >+ } >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 280409
:
139536
| 139549