Skip to main content
summaryrefslogtreecommitdiffstats
blob: 2960305e843f08d04dd17dd4ebe08f42568ebc3d (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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*******************************************************************************
 * 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
 * -------- -------- -----------------------------------------------------------
 * 20060106   121199 jesper@selskabet.org - Jesper Møller
 * 20060321   128827 joan - Joan Haggarty, remove redundant wsdl URI, folder and file controls
 *******************************************************************************/
package org.eclipse.jst.ws.internal.axis.creation.ui.widgets.skeleton;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jst.ws.internal.axis.consumption.core.common.JavaWSDLParameter;
import org.eclipse.jst.ws.internal.axis.consumption.ui.AxisConsumptionUIMessages;
import org.eclipse.jst.ws.internal.axis.creation.ui.AxisCreationUIMessages;
import org.eclipse.jst.ws.internal.common.ResourceUtils;
import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
import org.eclipse.jst.ws.internal.ui.common.UIUtils;
import org.eclipse.swt.SWT;
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 SkeletonConfigWidget extends SimpleWidgetDataContributor
{
  private JavaWSDLParameter javaWSDLParam;

  /* CONTEXT_ID PBSC0001 for the Skeleton Config Page */
  private static final String INFOPOP_PBSC_PAGE = "PBSC0001"; //$NON-NLS-1$
  
  // private Text uriText_;
  /* CONTEXT_ID PBCF0002 for the URI field of the Bean Config Page */
  //private final String INFOPOP_PBCF_TEXT_URI = "PBCF0002"; //$NON-NLS-1$
  
  private Combo skeletonFolderText_;
  /* CONTEXT_ID PBSC0004 for the Skeleton Folder field of the Skeleton Config Page */
  private static final String INFOPOP_PBSC_TEXT_SKELETON_FOLDER = "PBSC0004"; //$NON-NLS-1$


  /* CONTEXT_ID PBSC0005 for the Skeleton Folder Browse button of the Skeleton Config Page */
  // private static final String INFOPOP_PBSC_BUTTON_SKELETON_FOLDER_BROWSE = "PBSC0005"; //$NON-NLS-1$
  // private static final String TOOLTIP_PBSC_BUTTON_SKELETON_FOLDER_BROWSE = "TOOLTIP_PBSC_BUTTON_SKELETON_FOLDER_BROWSE";
  
  private Button showMappingsCheckbox_;
  /* CONTEXT_ID PBSC0016 for the Show Mappings checkbox of the Bean Methods Page  */
  private String INFOPOP_N2P_SHOW_MAPPINGS = "PBSC0016"; //$NON-NLS-1$
  
  private IProject serverProject_;
	
  public WidgetDataEvents addControls( Composite parent, Listener statusListener)
  {
    String       pluginId        = "org.eclipse.jst.ws.axis.creation.ui";
    
    UIUtils      uiUtils         = new UIUtils( pluginId );
    UIUtils      conUiUtils      = new UIUtils( pluginId );
    UIUtils      baseConUiUtils  = new UIUtils( pluginId );

  	PlatformUI.getWorkbench().getHelpSystem().setHelp( parent, pluginId + "." +  INFOPOP_PBSC_PAGE );
  	parent.setToolTipText( AxisCreationUIMessages.TOOLTIP_PBSC_PAGE );
    
    Composite textGroup = uiUtils.createComposite( parent, 2, 0, 0 );

    /*
    uriText_ = uiUtils.createText( textGroup, "LABEL_URI",
                                   TOOLTIP_PBCF_TEXT_URI,
                                   INFOPOP_PBCF_TEXT_URI,
                                   SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY );
    */
    
    skeletonFolderText_ = baseConUiUtils.createCombo( textGroup, ConsumptionUIMessages.LABEL_SKELETON_ROOT_NAME,
    		ConsumptionUIMessages.TOOLTIP_PBSC_TEXT_SKELETON_FOLDER,
        INFOPOP_PBSC_TEXT_SKELETON_FOLDER,
        SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY );

    showMappingsCheckbox_ = conUiUtils.createCheckbox( parent, AxisConsumptionUIMessages.LABEL_EXPLORE_MAPPINGS_XML2BEAN,
    													AxisConsumptionUIMessages.TOOLTIP_N2P_SHOW_MAPPINGS,
                                                       INFOPOP_N2P_SHOW_MAPPINGS );
        
    return this;
  }
  
  public void setEndpointURI(String endpointURI)
  {
  	/*
    if (endpointURI != null)
      uriText_.setText(endpointURI);
    */
  }  
  
  public void setOutputJavaFolder(String outputJavaFolder)
  {
    if (outputJavaFolder != null)
    {
      int index = skeletonFolderText_.indexOf(outputJavaFolder);
      if (index != -1)
        skeletonFolderText_.select(index);
      else if (skeletonFolderText_.getItemCount() <= 0)
      {
        String root = getWorkspaceRootLocation();
        if (outputJavaFolder.startsWith(root))
          skeletonFolderText_.setText(outputJavaFolder.substring(root.length()));
        else
          skeletonFolderText_.setText(outputJavaFolder);
      }
    }
  }
  
  public void setShowMapping(boolean showMapping)
  {
    showMappingsCheckbox_.setSelection(showMapping);
  }
  
  public boolean getShowMapping()
  {
    return showMappingsCheckbox_.getSelection();
  }

  /**
   * @return Returns the javaWSDLParam.
   */
  public JavaWSDLParameter getJavaWSDLParam() {

//	  Do not base Java output directory on workspace root since the project could be not 
//	  physically located in the workspace root, get the project specific root instead
	  
	  String projectSpecificRoot = serverProject_.getLocation().toString();
	  String skeletonFolder = skeletonFolderText_.getText();
	  String projectPathString = serverProject_.getFullPath().toString();
	  if (skeletonFolder.startsWith(projectPathString)) {
		  skeletonFolder = skeletonFolder.substring(projectPathString.length());
	  }
	  javaWSDLParam.setJavaOutput(projectSpecificRoot + skeletonFolder);
	  return javaWSDLParam;
  }

  /**
   * @param javaWSDLParam The javaWSDLParam to set.
   */
  public void setJavaWSDLParam(JavaWSDLParameter javaWSDLParam) {
	  this.javaWSDLParam = javaWSDLParam;
  }
  
  public void setServerProject(IProject serviceProject)
  {
	  serverProject_ = serviceProject;
    String originalSkeletonFolder = skeletonFolderText_.getText();
    skeletonFolderText_.removeAll();
    IPath[] paths = ResourceUtils.getAllJavaSourceLocations(serviceProject);
    for (int i = 0; i < paths.length ; i++)
      skeletonFolderText_.add(paths[i].toString());
    int index = skeletonFolderText_.indexOf(originalSkeletonFolder);
    if (index != -1)
      skeletonFolderText_.select(index);
    else
      skeletonFolderText_.select(0);
  }
  
  private String getWorkspaceRootLocation()
  {
  	return ResourcesPlugin.getWorkspace().getRoot().getLocation().removeTrailingSeparator().toString();
  }
}

Back to the top