]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringCommandHandler.java
Introduce Argeo user edition
[lgpl/argeo-commons.git] / eclipse / plugins / org.argeo.eclipse.ui / src / main / java / org / argeo / eclipse / spring / SpringCommandHandler.java
index 9f3161c2ecfde0453b19cd19191e2787020da286..0356f57d2e850acd5cbb9930dca51974cd43bd4c 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.argeo.eclipse.spring;
 
 import org.apache.commons.logging.Log;
@@ -19,36 +35,14 @@ public class SpringCommandHandler implements IHandler {
        }
 
        public Object execute(ExecutionEvent event) throws ExecutionException {
+               String commandId = event.getCommand().getId();
+               String bundleSymbolicName = commandId.substring(0,
+                               commandId.lastIndexOf('.'));
                try {
-                       if (log.isDebugEnabled())
-                               log.debug("Execute " + event + " via spring command handler "
+                       if (log.isTraceEnabled())
+                               log.trace("Execute " + event + " via spring command handler "
                                                + this);
-
-                       // Find the application context of the bundle defining the command
-                       // extension
-                       // ICommandService commandService =
-                       // (ICommandService)ArgeoUiPlugin.getDefault().getWorkbench().getService(ICommandService.class);
-                       //              
-                       // Command command =
-                       // commandService.getCommand(event.getCommand().getId());
-                       // log.debug("command=" + command);
-                       // log.debug("Command id " + command.getId());
-                       //              
-                       // Platform.getExtensionRegistry().getE
-                       //              
-                       // IExtension extension =
-                       // Platform.getExtensionRegistry().getExtension(
-                       // "org.eclipse.ui.commands", command.getId());
-                       // log.debug("extension=" + extension);
-                       // String bundleSymbolicName = extension.getContributor().getName();
-
-                       // Assume that the defining bundle name is the first part of the
-                       // command
-                       // id
                        // TODO: make it more flexible and robust
-                       String commandId = event.getCommand().getId();
-                       String bundleSymbolicName = commandId.substring(0, commandId
-                                       .lastIndexOf('.'));
                        ApplicationContext applicationContext = ApplicationContextTracker
                                        .getApplicationContext(bundleSymbolicName);
 
@@ -68,8 +62,9 @@ public class SpringCommandHandler implements IHandler {
                        return handler.execute(event);
                } catch (Exception e) {
                        // TODO: use eclipse error management
-                       log.error(e);
-                       return null;
+//                     log.error(e);
+                       throw new ExecutionException("Cannot execute Spring command "
+                                       + commandId + " in bundle " + bundleSymbolicName, e);
                }
        }