/*******************************************************************************
* Copyright (c) 2009, 2010 Innovation Gate GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Innovation Gate GmbH - initial API and implementation
******************************************************************************/
package de.innovationgate.eclipse.wgadesigner.commands;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path;
import de.innovationgate.eclipse.wgadesigner.actions.OpenModulInBrowser;
import de.innovationgate.eclipse.wgadesigner.tomcat.TomcatUtils;
public class OpenModuleInBrowser extends AbstractHandler {
public static final String ID = "de.innovationgate.eclipse.ids.commands.OpenModuleInBrowser";
public static final String PARAM_TMLFilePath = "de.innovationgate.eclipse.ids.commands.OpenModuleInBrowser.paramTMLFilePath";
public Object execute(ExecutionEvent event) throws ExecutionException {
if (TomcatUtils.getInstance().getCurrentRuntime() == null) {
throw new ExecutionException("The runtime is not started.");
}
String param = event.getParameter(PARAM_TMLFilePath);
if (param != null) {
Path path = new Path(param);
IFile tmlFile = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
String dbkey = OpenModulInBrowser.determineContentStoreOfFile(tmlFile);
if (dbkey == null) {
throw new ExecutionException("None of the web applications of the current runtime are connected to this design resource.");
}
OpenModulInBrowser.openBrowser(dbkey, tmlFile);
}
return null;
}
}