[jbosstools-commits] JBoss Tools SVN: r42622 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Tue Jul 17 11:25:33 EDT 2012


Author: dmaliarevich
Date: 2012-07-17 11:25:33 -0400 (Tue, 17 Jul 2012)
New Revision: 42622

Modified:
   trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
   trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
Log:
https://issues.jboss.org/browse/JBIDE-12290 - In eclipse 4.2 getting command/context services could return null.

Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java	2012-07-17 15:21:55 UTC (rev 42621)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java	2012-07-17 15:25:33 UTC (rev 42622)
@@ -1828,12 +1828,16 @@
 	}
 
 	public void refreshCommands(){
-		ICommandService commandService = (ICommandService) PlatformUI
-				.getWorkbench().getService(ICommandService.class);
-
-		//just refresh state of commands
+		ICommandService commandService = (ICommandService) 
+				editPart.getSite().getService(ICommandService.class);
 		for (String commandId : getVpeCategoryCommands()) {
-			commandService.refreshElements(commandId, null);
+			/*
+			 * https://issues.jboss.org/browse/JBIDE-12290
+			 * In eclipse 4.2 commandService could be null.
+			 */
+			if (commandService != null) {
+				commandService.refreshElements(commandId, null);
+			} 
 		}
 	}
 

Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java	2012-07-17 15:21:55 UTC (rev 42621)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java	2012-07-17 15:25:33 UTC (rev 42622)
@@ -1166,15 +1166,20 @@
 	}
 
 	private void deactivateServices() {
-		IWorkbench workbench = PlatformUI.getWorkbench();
 		if (fContextActivation != null) {
-			IContextService contextService = (IContextService) workbench
-					.getAdapter(IContextService.class);
-			contextService.deactivateContext(fContextActivation);
+			IContextService contextService = (IContextService) 
+					getSite().getService(IContextService.class);
+			/*
+			 * https://issues.jboss.org/browse/JBIDE-12290
+			 * In eclipse 4.2 contextService could be null.
+			 */
+			if (contextService != null) {
+				contextService.deactivateContext(fContextActivation);
+			}
 		}
 
-		IHandlerService handlerService = (IHandlerService) workbench
-				.getService(IHandlerService.class);
+		IHandlerService handlerService = (IHandlerService) 
+				getSite().getService(IHandlerService.class);
 		if (handlerService != null) {
 			if (sourceActivation != null)
 				handlerService.deactivateHandler(sourceActivation);



More information about the jbosstools-commits mailing list