### Eclipse Workspace Patch 1.0 #P org.jboss.tools.ws.ui Index: plugin.xml =================================================================== --- plugin.xml (revision 37220) +++ plugin.xml (working copy) @@ -241,5 +241,20 @@ class="javax.ws.rs.ext.Provider" name="Provider"> + + + + + + Index: src/org/jboss/tools/ws/ui/actions/RunWSTesterAction.java =================================================================== --- src/org/jboss/tools/ws/ui/actions/RunWSTesterAction.java (revision 0) +++ src/org/jboss/tools/ws/ui/actions/RunWSTesterAction.java (revision 0) @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2011 Red Hat, Inc. + * Distributed under license by Red Hat, Inc. All rights reserved. + * This program is 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: + * Red Hat, Inc. - initial API and implementation + ******************************************************************************/ +package org.jboss.tools.ws.ui.actions; + +import java.net.MalformedURLException; + +import org.eclipse.core.resources.IFile; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IViewPart; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.jboss.tools.ws.ui.views.JAXRSWSTestView2; + +/** + * Action to fire up the WS Tester from a WSDL in a navigator view + * @author bfitzpat + * + */ +public class RunWSTesterAction implements IObjectActionDelegate { + + private ISelection selection = null; + + public RunWSTesterAction() { + // empty + } + + @Override + public void run(final IAction action) { + if (this.selection instanceof IStructuredSelection) { + IStructuredSelection ssel = (IStructuredSelection) this.selection; + if (ssel.getFirstElement() instanceof IFile) { + IFile wsdlFile = (IFile) ssel.getFirstElement(); + IWorkbench wb = PlatformUI.getWorkbench(); + IWorkbenchWindow win = wb.getActiveWorkbenchWindow(); + IWorkbenchPage page = win.getActivePage(); + String id = JAXRSWSTestView2.ID; + try { + IViewPart part = page.showView(id); + if (part instanceof JAXRSWSTestView2) { + JAXRSWSTestView2 testerView = (JAXRSWSTestView2) part; + String url = wsdlFile.getRawLocationURI().toURL().toExternalForm(); + testerView.setWSDLURL(url); + } + } catch (PartInitException e) { + e.printStackTrace(); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + } + } + } + + @Override + public void selectionChanged(IAction action, ISelection selection) { + this.selection = selection; + } + + @Override + public void setActivePart(IAction action, IWorkbenchPart targetPart) { + // empty + } + +} Index: src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java =================================================================== --- src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java (revision 37220) +++ src/org/jboss/tools/ws/ui/views/JAXRSWSTestView2.java (working copy) @@ -193,6 +193,32 @@ */ public JAXRSWSTestView2() { } + + public void setWSDLURL( String url ) { + this.urlCombo.setText(url); + this.methodCombo.setText(JAX_WS); + setControlsForWSType(JAX_WS); + setControlsForMethodType(methodCombo.getText()); + setControlsForSelectedURL(); + } + + public void setJAXRS ( String url, String method ) { + this.urlCombo.setText(url); + String uCaseMethod = method.toUpperCase(); + if (uCaseMethod.equalsIgnoreCase(GET)) + this.methodCombo.setText(GET); + else if (uCaseMethod.equalsIgnoreCase(POST)) + this.methodCombo.setText(POST); + else if (uCaseMethod.equalsIgnoreCase(PUT)) + this.methodCombo.setText(PUT); + else if (uCaseMethod.equalsIgnoreCase(DELETE)) + this.methodCombo.setText(DELETE); + else if (uCaseMethod.equalsIgnoreCase(OPTIONS)) + this.methodCombo.setText(OPTIONS); + setControlsForWSType(JAX_RS); + setControlsForMethodType(methodCombo.getText()); + setControlsForSelectedURL(); + } private void getImages() { mImageRegistry = new ImageRegistry();