Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
blob: e05e8fd19198e7f1a09c1f4f082352b2e753e18f (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
/*******************************************************************************
 * 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.jst.ws.internal.consumption.ui.widgets;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jst.ws.internal.consumption.ui.widgets.object.WSDLSelectionWidget;
import org.eclipse.jst.ws.internal.consumption.ui.widgets.object.WSDLSelectionWrapper;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.wst.command.internal.env.ui.widgets.SimpleWidgetDataContributor;
import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;
import org.eclipse.wst.ws.internal.parser.wsil.WebServicesParser;

public class WSDLSelectionWidgetWrapper extends SimpleWidgetDataContributor
{
  private WSDLSelectionWidget wsdlSelectionWidget;
  private IProject project;
  private String componentName;
  
  public WSDLSelectionWidgetWrapper()
  {
  }
  
  public WidgetDataEvents addControls(Composite parent, Listener statusListener)
  {
    wsdlSelectionWidget = new WSDLSelectionWidget();
    wsdlSelectionWidget.addControls(parent, statusListener);
    return this;
  }
  
  public IStatus getStatus()
  {
    return wsdlSelectionWidget.getStatus();
  }
  
  public void setWebServiceURI(String wsUri)
  {
    IStructuredSelection sel;
    if (wsUri != null)
      sel = new StructuredSelection(wsUri);
    else
      sel = new StructuredSelection();
    wsdlSelectionWidget.setInitialSelection(sel);
  }
  
  public String getWebServiceURI()
  {
    IStructuredSelection sel    = wsdlSelectionWidget.getObjectSelection();
    Object               object = sel.getFirstElement();
    String               result = null;
    
    if (object != null )
    {
      if( object instanceof WSDLSelectionWrapper )
      {    
        // Get at the inner structured selection object.
        WSDLSelectionWrapper wrapper        = (WSDLSelectionWrapper)object;
        IStructuredSelection innerSelection = wrapper.wsdlSelection;
        Object               innerObject    = innerSelection.getFirstElement();
        
        result = innerObject == null ? null : innerObject.toString();
      }
      else
      {
        result = object.toString();
      }
    }
    
    return result;
  }
  
  public String getWsdlURI()
  {
  	return getWebServiceURI();
  }
  
  public WebServicesParser getWebServicesParser()
  {
    return wsdlSelectionWidget.getWebServicesParser();
  }
  
  public void setProject(IProject project)
  {
  	this.project = project;
  }
  
  public IProject getProject()
  {
  	IProject p = wsdlSelectionWidget.getProject();
  	if (p==null)
  	{
  	  return project;
  	}
  	else
  	  return p;
  }

  public String getComponentName()
  {
    String cname = wsdlSelectionWidget.getComponentName();
    if (cname==null)
    {
      return componentName;
    }
    else
      return cname;
  }

  public void setComponentName(String componentName)
  {
    this.componentName = componentName;
  }
  
    
}

Back to the top