X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;ds=inline;f=eclipse%2Fplugins%2Forg.argeo.eclipse.ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Feclipse%2Fspring%2FSpringCommandHandler.java;h=0356f57d2e850acd5cbb9930dca51974cd43bd4c;hb=dc6f911c680574a9b57c34dcf515ac8f9aa808da;hp=9f3161c2ecfde0453b19cd19191e2787020da286;hpb=dcaa55aad26d7fd945a713af5854741f82dd13f3;p=lgpl%2Fargeo-commons.git diff --git a/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringCommandHandler.java b/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringCommandHandler.java index 9f3161c2e..0356f57d2 100644 --- a/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringCommandHandler.java +++ b/eclipse/plugins/org.argeo.eclipse.ui/src/main/java/org/argeo/eclipse/spring/SpringCommandHandler.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2010 Mathieu Baudier + * + * 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); } }