Skip to main content
summaryrefslogtreecommitdiffstats
blob: a1db9cbbc70603136bfd0f9b309f656f6403fedb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*******************************************************************************
 * Copyright (c) 2000, 2004 IBM Corporation and others.
 * 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:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.jst.ws.internal.ui.action;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jst.ws.internal.common.ServerUtils;

public class WebServiceDeployAction extends WindowActionDelegate {
public void run(org.eclipse.jface.action.IAction action) {

   IProject project = getSelectedResourceProject();

   String [] typeIds = ServerUtils.getServerTypeIdsByModule(project);
   Object theAction = null;

   IExtensionRegistry reg = Platform.getExtensionRegistry();
   IConfigurationElement[] elements = reg.getConfigurationElementsFor("org.eclipse.jst.ws.ui", "webservicedeploy");
   try {
   	
   	if (typeIds == null || typeIds.length <= 0)
   	{
   	 	// that means the module is not attached to a server then pick the first extension found
   	    theAction = elements[0].createExecutableExtension("class");
   	}
   	else if ( typeIds.length == 1)
   	{
   		// that means the module is attached to one server then finds it id and a matchin extension or give a message
   		for (int i = 0; i < elements.length; i++)
      	{
		   	String id = elements[i].getAttribute("factoryId");
    	   	if ( typeIds[0].equals(id))
		   	{
		   		theAction = elements[i].createExecutableExtension("class");
		   		break;
		   	}
   		}
   		if (theAction == null )
   			{
   				// give a message
   			}
   	}
   	else
   	{
		// The module is attached to more than one server find the first server-extension couple
		// TBD: add a dialog to choose the server for deployment
		for (int i = 0; i < elements.length; i++)
      	{
		   	String id = elements[i].getAttribute("factoryId");
		   	for ( int k=0; k< typeIds.length; k++)
		   	{
    	   		if ( typeIds[k].equals(id))
		   		{
		   			theAction = elements[i].createExecutableExtension("class");
		   			break;
		   		}
		   	}
		   if (theAction != null) break;
   		 }
		if (theAction == null) 
			{
				// give a Message
			}
   	}

    if (theAction instanceof WebServiceDeploy)
          ((WebServiceDeploy)theAction).run(project);   
  }

  catch (Exception e) {}
} 
}

Back to the top