Skip to main content
summaryrefslogtreecommitdiffstats
blob: bc08bf1191375a894529c9110558725f3a473f9e (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
140
/*******************************************************************************
 * Copyright (c) 2004, 2006 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
 * yyyymmdd bug      Email and other contact information
 * -------- -------- -----------------------------------------------------------
 * 20060216   115144 pmoogk@ca.ibm.com - Peter Moogk
 *******************************************************************************/
package org.eclipse.jst.ws.internal.axis.consumption.ui.widgets;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jst.ws.internal.axis.consumption.ui.AxisConsumptionUIMessages;
import org.eclipse.jst.ws.internal.common.ResourceUtils;
import org.eclipse.jst.ws.internal.ui.common.UIUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.ui.PlatformUI;
import org.eclipse.wst.command.internal.env.ui.widgets.SimpleWidgetDataContributor;
import org.eclipse.wst.command.internal.env.ui.widgets.WidgetDataEvents;


public class AxisProxyWidget extends SimpleWidgetDataContributor
{
  private String pluginId_ = "org.eclipse.jst.ws.axis.consumption.ui";
  
  /*CONTEXT_ID PWJB0001 for the WSDL to Java Bindings Page*/
  private final String INFOPOP_PWJB_PAGE = "PWJB0001";	//$NON-NLS-1$
		
  private Combo outputFolderCombo_;
  /*CONTEXT_ID PWJB0003 for the Folder field of the WSDL to Java Bindings Page*/
  private final String INFOPOP_PWJB_TEXT_FOLDER = "PWJB0003";	//$NON-NLS-1$

  private Button genProxyCheckbox_;
  /*CONTEXT_ID PWJB0009 Indicates whether to generate a proxy or not. */
  private final String INFOPOP_PWJB_CHECKBOX_GENPROXY = "PWJB0009";	//$NON-NLS-1$
		
  private Button showMappingsCheckbox_;
  /*CONTEXT_ID PWJB0016 for the Show Mappings checkbox of the Bean Methods Page*/
  private String INFOPOP_N2P_SHOW_MAPPINGS = "PWJB0016"; //$NON-NLS-1$
  
  public WidgetDataEvents addControls( Composite parent, Listener statusListener )
  {
    UIUtils      uiUtils  = new UIUtils( pluginId_ );
    
	parent.setToolTipText( AxisConsumptionUIMessages.TOOLTIP_PWJB_PAGE );
	PlatformUI.getWorkbench().getHelpSystem().setHelp( parent, pluginId_ + "." +  INFOPOP_PWJB_PAGE);
    
    genProxyCheckbox_ = uiUtils.createCheckbox( parent, AxisConsumptionUIMessages.CHECKBOX_GENPROXY,
    											AxisConsumptionUIMessages.TOOLTIP_PWJB_CHECKBOX_GENPROXY,
                                                INFOPOP_PWJB_CHECKBOX_GENPROXY );
    genProxyCheckbox_.addListener( SWT.Selection, statusListener );
    genProxyCheckbox_.addSelectionListener( new SelectionAdapter()
                                            {
                                              public void widgetSelected( SelectionEvent evt )
                                              {
                                                handleGenProxy();  
                                              }
                                            });
    
    Composite textGroup = uiUtils.createComposite( parent, 2, 5, 0 );
    
    outputFolderCombo_ = uiUtils.createCombo( textGroup, AxisConsumptionUIMessages.LABEL_FOLDER_NAME,
    									AxisConsumptionUIMessages.TOOLTIP_PWJB_TEXT_FOLDER,
    									INFOPOP_PWJB_TEXT_FOLDER,
    									SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY );
    
    showMappingsCheckbox_ = uiUtils.createCheckbox( parent, AxisConsumptionUIMessages.LABEL_EXPLORE_MAPPINGS_XML2BEAN,
    									AxisConsumptionUIMessages.TOOLTIP_N2P_SHOW_MAPPINGS,
    									INFOPOP_N2P_SHOW_MAPPINGS );
    // Since this widget affects whether the next page is shown or not we
    // need to add the statusListener.
    showMappingsCheckbox_.addListener( SWT.Selection, statusListener );
    
    return this;
  }
  
  private void handleGenProxy()
  {
    boolean enabled = genProxyCheckbox_.getSelection();
    
    outputFolderCombo_.setEnabled( enabled );
    showMappingsCheckbox_.setEnabled( enabled );
  }
  
  public void setClientProject(IProject clientProject)
  {  	
    IPath[] paths = ResourceUtils.getAllJavaSourceLocations(clientProject);
    
    for (int i = 0; i < paths.length ; i++)
    {
      outputFolderCombo_.add(paths[i].toString());
    }
    
    if( paths.length > 0 )
    {
    	outputFolderCombo_.select(0);
    }
  }
  
  public String getOutputFolder()
  {
  	return outputFolderCombo_.getText();
  }
        
  public void setGenerateProxy( Boolean genProxy )
  {
    genProxyCheckbox_.setSelection( genProxy.booleanValue() );
  }    
  
  public Boolean getGenerateProxy()
  {
    return new Boolean( genProxyCheckbox_.getSelection() );
  }   
  
  public void setCustomizeClientMappings( boolean showMappings )
  {
    showMappingsCheckbox_.setSelection( showMappings );
  }            
  
  public boolean getCustomizeClientMappings()
  {
    return showMappingsCheckbox_.getSelection() && genProxyCheckbox_.getSelection();
  }   
  
  public void setIsClientScenario( boolean isClientScenario )
  {
    genProxyCheckbox_.setEnabled( !isClientScenario ); 
  }  
}

Back to the top