Skip to main content
summaryrefslogtreecommitdiffstats
blob: eb349ec89e59e9e94ec187ed7c56182636a3ff6c (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*******************************************************************************
 * Copyright (c) 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.wst.ws.internal.explorer.platform.wsil.transformer;

import java.util.Hashtable;
import org.eclipse.wst.ws.internal.explorer.platform.constants.ActionInputs;
import org.eclipse.wst.ws.internal.explorer.platform.datamodel.TreeElement;
import org.eclipse.wst.ws.internal.explorer.platform.engine.transformer.ViewSelectionTransformer;
import org.eclipse.wst.ws.internal.explorer.platform.perspective.Controller;
import org.eclipse.wst.ws.internal.explorer.platform.perspective.Node;
import org.eclipse.wst.ws.internal.explorer.platform.perspective.Tool;
import org.eclipse.wst.ws.internal.explorer.platform.perspective.ToolManager;
import org.eclipse.wst.ws.internal.explorer.platform.wsil.constants.WsilModelConstants;
import org.eclipse.wst.ws.internal.explorer.platform.wsil.datamodel.WsilElement;
import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.ListUDDIBusinessTool;
import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.ListUDDIServicesTool;
import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.ListWSDLServicesTool;
import org.eclipse.wst.ws.internal.explorer.platform.wsil.perspective.ListWSILLinksTool;

public class WSILViewSelectionTransformer extends ViewSelectionTransformer
{
  public static final byte NONE = 0;
  public static final byte WSDL_SERVICE = 1;
  public static final byte UDDI_SERVICE = 2;
  public static final byte UDDI_BUSINESS = 3;
  public static final byte WSIL_LINK = 4;
  public static final byte FROM_TOOLID = 5;
  private byte type;

  public WSILViewSelectionTransformer(Controller controller)
  {
    this(controller, "", ActionInputs.VIEWID, FROM_TOOLID);
  }

  public WSILViewSelectionTransformer(Controller controller, String listManagerKey, String viewKey, byte type)
  {
    super(controller, listManagerKey, viewKey);
    this.type = type;
  }

  public Hashtable normalize(Hashtable properties)
  {
    if (type == FROM_TOOLID)
    {
      Node currNode = controller.getCurrentPerspective().getNodeManager().getSelectedNode();
      if (currNode != null)
      {
        try
        {
          int toolId = Integer.parseInt((String) properties.get(ActionInputs.TOOLID));
          ToolManager toolManager = currNode.getToolManager();
          Tool tool = toolManager.getTool(toolId);
          if (tool instanceof ListWSDLServicesTool)
            listManagerKey = WsilModelConstants.LIST_MANAGER_WSDL_SERVICES;
          else if (tool instanceof ListUDDIServicesTool)
            listManagerKey = WsilModelConstants.LIST_MANAGER_UDDI_SERVICES;
          else if (tool instanceof ListUDDIBusinessTool)
            listManagerKey = WsilModelConstants.LIST_MANAGER_UDDI_LINKS;
          else if (tool instanceof ListWSILLinksTool)
            listManagerKey = WsilModelConstants.LIST_MANAGER_WSIL_LINKS;
        }
        catch (NumberFormatException nfe)
        {
        }
      }
    }
    return super.normalize(properties);
  }

  public Hashtable deNormalize(Hashtable properties)
  {
    Node currNode = controller.getCurrentPerspective().getNodeManager().getSelectedNode();
    if (currNode != null)
    {
      TreeElement currElement = currNode.getTreeElement();
      if (currElement instanceof WsilElement)
      {
        WsilElement wsilElement = (WsilElement) currElement;
        switch (type)
        {
          case WSDL_SERVICE :
            wsilElement.getAllWSDLServices();
            break;
          case UDDI_SERVICE :
            wsilElement.getAllUDDIServices();
            break;
          case UDDI_BUSINESS :
            wsilElement.getAllUDDILinks();
            break;
          case WSIL_LINK :
            wsilElement.getAllWSILLinks();
            break;
          case FROM_TOOLID :
            try
            {
              int toolId = Integer.parseInt((String) properties.get(ActionInputs.TOOLID));
              ToolManager toolManager = currNode.getToolManager();
              Tool tool = toolManager.getTool(toolId);
              if (tool instanceof ListWSDLServicesTool)
              {
                listManagerKey = WsilModelConstants.LIST_MANAGER_WSDL_SERVICES;
                wsilElement.getAllWSDLServices();
              }
              else if (tool instanceof ListUDDIServicesTool)
              {
                listManagerKey = WsilModelConstants.LIST_MANAGER_UDDI_SERVICES;
                wsilElement.getAllUDDIServices();
              }
              else if (tool instanceof ListUDDIBusinessTool)
              {
                listManagerKey = WsilModelConstants.LIST_MANAGER_UDDI_LINKS;
                wsilElement.getAllUDDILinks();
              }
              else if (tool instanceof ListWSILLinksTool)
              {
                listManagerKey = WsilModelConstants.LIST_MANAGER_WSIL_LINKS;
                wsilElement.getAllWSILLinks();
              }
            }
            catch (NumberFormatException nfe)
            {
            }
            break;
          default :
            break;
        }
      }
    }
    return super.deNormalize(properties);
  }
}

Back to the top