Search in sources :

Example 1 with StringsFilteredDialog

use of com.liferay.ide.ui.dialog.StringsFilteredDialog in project liferay-ide by liferay.

the class TestWebServicesAction method run.

public void run(IAction action) {
    if (selectedServer == null && selectedModule == null) {
        // can't do anything if server has not been selected
        return;
    }
    URL webServicesListURL = null;
    String[] names = null;
    WebServicesHelper helper = null;
    if (selectedServer != null) {
        ILiferayServer portalServer = (ILiferayServer) selectedServer.loadAdapter(ILiferayServer.class, null);
        webServicesListURL = portalServer.getWebServicesListURL();
        helper = new WebServicesHelper(webServicesListURL);
        names = helper.getWebServiceNames();
    } else if (selectedModule != null) {
        selectedModule.getModule()[0].getProject();
        ILiferayServer portalServer = (ILiferayServer) selectedModule.getServer().loadAdapter(ILiferayServer.class, null);
        try {
            webServicesListURL = // $NON-NLS-1$
            new URL(portalServer.getPortalHomeUrl(), selectedModule.getModule()[0].getName() + "/axis");
        } catch (MalformedURLException e) {
            LiferayServerUI.logError(e);
            return;
        }
        helper = new WebServicesHelper(webServicesListURL);
        names = helper.getWebServiceNames();
        if (ListUtil.isEmpty(names)) {
            try {
                webServicesListURL = // $NON-NLS-1$
                new URL(portalServer.getPortalHomeUrl(), selectedModule.getModule()[0].getName() + "/api/axis");
            } catch (MalformedURLException e) {
                LiferayServerUI.logError(e);
                return;
            }
            helper = new WebServicesHelper(webServicesListURL);
            names = helper.getWebServiceNames();
        }
    }
    StringsFilteredDialog dialog = new StringsFilteredDialog(getActiveShell());
    dialog.setTitle(Msgs.webServiceSelection);
    dialog.setMessage(Msgs.selectWebService);
    dialog.setInput(names);
    int retval = dialog.open();
    if (retval == Window.OK) {
        String serviceName = dialog.getFirstResult().toString();
        String url = helper.getWebServiceWSDLURLByName(serviceName);
        String stateLocation = ExplorerPlugin.getInstance().getPluginStateLocation();
        String defaultFavoritesLocation = ExplorerPlugin.getInstance().getDefaultFavoritesLocation();
        WSExplorerLauncherCommand command = new WSExplorerLauncherCommand();
        command.setForceLaunchOutsideIDE(false);
        Vector launchOptions = new Vector();
        addLaunchOptions(launchOptions, url, stateLocation, defaultFavoritesLocation);
        command.setLaunchOptions((LaunchOption[]) launchOptions.toArray(new LaunchOption[0]));
        command.execute();
    }
}
Also used : LaunchOption(org.eclipse.wst.ws.internal.explorer.LaunchOption) MalformedURLException(java.net.MalformedURLException) ILiferayServer(com.liferay.ide.server.core.ILiferayServer) WSExplorerLauncherCommand(org.eclipse.wst.ws.internal.explorer.WSExplorerLauncherCommand) StringsFilteredDialog(com.liferay.ide.ui.dialog.StringsFilteredDialog) Vector(java.util.Vector) URL(java.net.URL) WebServicesHelper(com.liferay.ide.server.util.WebServicesHelper)

Aggregations

ILiferayServer (com.liferay.ide.server.core.ILiferayServer)1 WebServicesHelper (com.liferay.ide.server.util.WebServicesHelper)1 StringsFilteredDialog (com.liferay.ide.ui.dialog.StringsFilteredDialog)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Vector (java.util.Vector)1 LaunchOption (org.eclipse.wst.ws.internal.explorer.LaunchOption)1 WSExplorerLauncherCommand (org.eclipse.wst.ws.internal.explorer.WSExplorerLauncherCommand)1