Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 150385 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/tptp/wsdm/tooling/wizard/mrt/internal/CapabilitySelectionWizardPage.java (-11 / +68 lines)
Lines 13-18 Link Here
13
package org.eclipse.tptp.wsdm.tooling.wizard.mrt.internal;
13
package org.eclipse.tptp.wsdm.tooling.wizard.mrt.internal;
14
14
15
import java.util.Arrays;
15
import java.util.Arrays;
16
import java.util.Iterator;
16
import java.util.LinkedList;
17
import java.util.LinkedList;
17
import java.util.List;
18
import java.util.List;
18
19
Lines 101-115 Link Here
101
		{
102
		{
102
			public void checkStateChanged(CheckStateChangedEvent event)
103
			public void checkStateChanged(CheckStateChangedEvent event)
103
			{
104
			{
104
				_selectedCapabilities.clear();
105
				//_selectedCapabilities.clear();
105
				Object[] checkedElements = _capsViewer.getCheckedElements();
106
				Object selectedelement = event.getElement();
106
				for (int i = 0; i < checkedElements.length; i++)
107
				setCheckStatus(selectedelement, event.getChecked());
107
				{
108
				
108
					if (checkedElements[i] instanceof Capability)
109
			}});
109
						_selectedCapabilities.add(checkedElements[i]);
110
				}
111
			}
112
		});
113
	}
110
	}
114
111
115
	/*
112
	/*
Lines 118-123 Link Here
118
	public void setContainer(String container)
115
	public void setContainer(String container)
119
	{
116
	{
120
		this._containerName = container;
117
		this._containerName = container;
118
		
121
	}
119
	}
122
120
123
	private boolean showOkDialog(String title, String msg, int dlgType)
121
	private boolean showOkDialog(String title, String msg, int dlgType)
Lines 130-138 Link Here
130
128
131
	public Capability[] getSelectedCapabilities()
129
	public Capability[] getSelectedCapabilities()
132
	{
130
	{
133
		return (Capability[]) _selectedCapabilities
131
		return (Capability[]) _selectedCapabilities.toArray(new Capability[_selectedCapabilities.size()]);
134
				.toArray(new Capability[_selectedCapabilities.size()]);
135
	}
132
	}
136
133
134
    private void setCheckStatus(Object selElement, boolean checkState) {
135
		Object[] checkedElements = _capsViewer.getCheckedElements();
136
		if(selElement instanceof Capability){
137
			Capability selCapability = (Capability)selElement;
138
			
139
			// add/remove the capability from the _selectedCapabilities
140
			boolean found = false;
141
			for (Iterator it = _selectedCapabilities.iterator(); it.hasNext();) {
142
				Capability cap = (Capability)it.next();
143
				if(selCapability.equals(cap)){
144
					found = true;
145
					break;
146
				}
147
			}  
148
			if(!found && checkState){
149
				_selectedCapabilities.add(selCapability);
150
			}else if(found && !checkState){
151
				_selectedCapabilities.remove(selCapability);					
152
			}
153
			
154
			Object parent = _contentProvider.getParent(selElement);
155
			if (_capsViewer.getChecked(parent) && !checkState){
156
				_capsViewer.setChecked(parent, false);
157
			}
158
			else if(!_capsViewer.getChecked(parent) && checkState && allChildrenChecked(parent)){
159
				_capsViewer.setChecked(parent, true);
160
			}
161
			_capsViewer.setChecked(selElement,checkState);
162
		}else if(selElement instanceof Category){ 
163
			// if the Category is selected
164
			Category selCategory = (Category) selElement;
165
		
166
			Object[] categoryList = _contentProvider.getChildren(_capsViewer.getInput());
167
			for (int j=0; j< categoryList.length; j++) {
168
				Category category = (Category) categoryList[j];
169
				if (category.getName().equals(selCategory.getName())) {
170
					Object[] capabilities = _contentProvider.getChildren(category);
171
					if (capabilities.length > 0) {
172
						for (int caps=0; caps<capabilities.length; caps++){
173
						   setCheckStatus(capabilities[caps], checkState);
174
						}
175
					} else _capsViewer.setChecked(selElement,false);
176
				}
177
			}
178
		}
179
    }
180
    
181
    private boolean allChildrenChecked(Object parent) {
182
    	boolean allChecked = true;
183
    	Object[] children = _contentProvider.getChildren(parent);
184
		if (children.length > 0) {
185
			for (int i=0; i<children.length; i++) {
186
				if (!_capsViewer.getChecked(children[i]))
187
					allChecked = false;
188
			}
189
    	}
190
		else return false;
191
		return allChecked;
192
    }
193
137
} // end class NewMr3WizardPage
194
} // end class NewMr3WizardPage
138
195
(-)src/org/eclipse/tptp/wsdm/tooling/wizard/mrt/internal/CapabilitySelectionDialog.java (-7 / +76 lines)
Lines 13-18 Link Here
13
package org.eclipse.tptp.wsdm.tooling.wizard.mrt.internal;
13
package org.eclipse.tptp.wsdm.tooling.wizard.mrt.internal;
14
14
15
import java.util.Arrays;
15
import java.util.Arrays;
16
import java.util.Iterator;
16
import java.util.LinkedList;
17
import java.util.LinkedList;
17
import java.util.List;
18
import java.util.List;
18
19
Lines 20-27 Link Here
20
import org.eclipse.jface.action.Action;
21
import org.eclipse.jface.action.Action;
21
import org.eclipse.jface.dialogs.Dialog;
22
import org.eclipse.jface.dialogs.Dialog;
22
import org.eclipse.jface.dialogs.IDialogConstants;
23
import org.eclipse.jface.dialogs.IDialogConstants;
24
import org.eclipse.jface.viewers.CheckStateChangedEvent;
23
import org.eclipse.jface.viewers.CheckboxTreeViewer;
25
import org.eclipse.jface.viewers.CheckboxTreeViewer;
24
import org.eclipse.jface.viewers.DoubleClickEvent;
26
import org.eclipse.jface.viewers.DoubleClickEvent;
27
import org.eclipse.jface.viewers.ICheckStateListener;
25
import org.eclipse.jface.viewers.IDoubleClickListener;
28
import org.eclipse.jface.viewers.IDoubleClickListener;
26
import org.eclipse.jface.viewers.ISelection;
29
import org.eclipse.jface.viewers.ISelection;
27
import org.eclipse.jface.viewers.IStructuredSelection;
30
import org.eclipse.jface.viewers.IStructuredSelection;
Lines 53-59 Link Here
53
	private CheckboxTreeViewer _capsViewer;
56
	private CheckboxTreeViewer _capsViewer;
54
	private CapsTreeContentProvider _contentProvider;
57
	private CapsTreeContentProvider _contentProvider;
55
58
56
	private List SELECTED_WSDLS = new LinkedList();
59
	private List _selectedCapabilities = new LinkedList();
57
60
58
	/*
61
	/*
59
	 * Constructor which sets the selected capabilities and containerName
62
	 * Constructor which sets the selected capabilities and containerName
Lines 136-142 Link Here
136
		for (int i = 0; i < checkedElements.length; i++)
139
		for (int i = 0; i < checkedElements.length; i++)
137
		{
140
		{
138
			if (checkedElements[i] instanceof Capability)
141
			if (checkedElements[i] instanceof Capability)
139
				SELECTED_WSDLS.add(checkedElements[i]);
142
    			_selectedCapabilities.add(checkedElements[i]);
140
		}
143
		}
141
		super.okPressed();
144
		super.okPressed();
142
	}
145
	}
Lines 144-154 Link Here
144
	/*
147
	/*
145
	 * Return the selected capabilities
148
	 * Return the selected capabilities
146
	 */
149
	 */
147
	public Capability[] getSelectedCaps()
150
    public Capability[] getSelectedCaps() {
148
	{
151
        return (Capability[]) _selectedCapabilities.toArray(new Capability[_selectedCapabilities.size()]);
149
		return (Capability[]) SELECTED_WSDLS
152
    }
150
				.toArray(new Capability[SELECTED_WSDLS.size()]);
151
	}
152
153
153
	private void hookAllListeners()
154
	private void hookAllListeners()
154
	{
155
	{
Lines 172-177 Link Here
172
			{
173
			{
173
				doubleClickAction.run();
174
				doubleClickAction.run();
174
			}
175
			}
176
		});    	
177
		
178
    	_capsViewer.addCheckStateListener(new ICheckStateListener() {
179
			public void checkStateChanged(CheckStateChangedEvent event) {
180
				Object element = event.getElement();
181
				setCheckStatus(element, event.getChecked());
182
				getButton(IDialogConstants.OK_ID).setEnabled(_capsViewer.getCheckedElements().length!=0);
183
			}
175
		});
184
		});
176
	}
185
	}
186
    private void setCheckStatus(Object selElement, boolean checkState) {
187
		Object[] checkedElements = _capsViewer.getCheckedElements();
188
		if(selElement instanceof Capability){
189
			Capability selCapability = (Capability)selElement;
190
			
191
			// add/remove the capability from the _selectedCapabilities
192
			boolean found = false;
193
			for (Iterator it = _selectedCapabilities.iterator(); it.hasNext();) {
194
				Capability cap = (Capability)it.next();
195
				if(selCapability.equals(cap)){
196
					found = true;
197
					break;
198
				}
199
			}  
200
			if(!found && checkState){
201
				_selectedCapabilities.add(selCapability);
202
			}else if(found && !checkState){
203
				_selectedCapabilities.remove(selCapability);					
204
			}
205
			
206
			Object parent = _contentProvider.getParent(selElement);
207
			if (_capsViewer.getChecked(parent) && !checkState){
208
				_capsViewer.setChecked(parent, false);
209
			}
210
			else if(!_capsViewer.getChecked(parent) && checkState && allChildrenChecked(parent)){
211
				_capsViewer.setChecked(parent, true);
212
			}
213
			_capsViewer.setChecked(selElement,checkState);
214
		}else if(selElement instanceof Category){ 
215
			// if the Category is selected
216
			Category selCategory = (Category) selElement;
217
		
218
			Object[] categoryList = _contentProvider.getChildren(_capsViewer.getInput());
219
			for (int j=0; j< categoryList.length; j++) {
220
				Category category = (Category) categoryList[j];
221
				if (category.getName().equals(selCategory.getName())) {
222
					Object[] capabilities = _contentProvider.getChildren(category);
223
					if (capabilities.length > 0) {
224
						for (int caps=0; caps<capabilities.length; caps++){
225
						   setCheckStatus(capabilities[caps], checkState);
226
						}
227
					} else _capsViewer.setChecked(selElement,false);
228
				}
229
			}
230
			
231
		}
232
    }
233
    
234
    private boolean allChildrenChecked(Object parent) {
235
    	boolean allChecked = true;
236
    	Object[] children = _contentProvider.getChildren(parent);
237
		if (children.length > 0) {
238
			for (int i=0; i<children.length; i++) {
239
				if (!_capsViewer.getChecked(children[i]))
240
					allChecked = false;
241
			}
242
    	}
243
		else return false;
244
		return allChecked;
245
    }
177
}
246
}
(-)src/org/eclipse/tptp/wsdm/tooling/nls/messages/mrt/internal/Messages.java (+14 lines)
Lines 123-128 Link Here
123
	public static String CODE_GEN_PROJECT_DIR;
123
	public static String CODE_GEN_PROJECT_DIR;
124
	public static String CODE_GEN_LOCATION_ERROR;
124
	public static String CODE_GEN_LOCATION_ERROR;
125
	public static String CODE_GEN_DIR_LOCATION;
125
	public static String CODE_GEN_DIR_LOCATION;
126
	public static String CODE_GEN_AXIS2_LOCATION;
127
	public static String CODE_GEN_UPDATE_PREF;
128
	public static String CODE_GEN_START;
129
	public static String CODE_GEN_STEP1;
130
	public static String CODE_GEN_STEP2;
131
	public static String CODE_GEN_STEP3;
132
	public static String CODE_GEN_FAILED_ERROR;
133
	public static String CODE_GEN_SUBTASK1;
134
	public static String CODE_GEN_SUBTASK2;
135
	public static String CODE_GEN_SUBTASK3;
136
	public static String CODE_GEN_PROJECTIZER;
137
	public static String CODE_GEN_ERROR_AXIS2;
138
	public static String FAILED_TO_INITIALIZE_MUSE_DESCRIPTOR_ERROR_;
139
	public static String CODE_GEN_VALIDATE_SLOCATION;
126
140
127
	static
141
	static
128
	{
142
	{
(-)src/org/eclipse/tptp/wsdm/tooling/nls/messages/mrt/internal/messages.properties (+14 lines)
Lines 118-120 Link Here
118
CODE_GEN_PROJECT_DIR = Project contents directory must be specified
118
CODE_GEN_PROJECT_DIR = Project contents directory must be specified
119
CODE_GEN_LOCATION_ERROR = Invalid location path
119
CODE_GEN_LOCATION_ERROR = Invalid location path
120
CODE_GEN_DIR_LOCATION = Select the location directory.
120
CODE_GEN_DIR_LOCATION = Select the location directory.
121
CODE_GEN_AXIS2_LOCATION = Server Installation Location
122
CODE_GEN_UPDATE_PREF = Update Preferences
123
CODE_GEN_START = Working: 
124
CODE_GEN_STEP1 = Initializing Code Generation
125
CODE_GEN_STEP2 = Merging WSDL
126
CODE_GEN_STEP3 = Creating project
127
CODE_GEN_FAILED_ERROR = Code generation failed, see Error Log
128
CODE_GEN_SUBTASK1 = Running Analyzer
129
CODE_GEN_SUBTASK2 = Running Synthesizer
130
CODE_GEN_SUBTASK3 = Running Projectizer
131
CODE_GEN_PROJECTIZER = Projectizer: 
132
CODE_GEN_ERROR_AXIS2 = Invalid Axis2 Server Location
133
FAILED_TO_INITIALIZE_MUSE_DESCRIPTOR_ERROR_ = IWAT0682E Failed to initialize muse descriptor
134
CODE_GEN_VALIDATE_SLOCATION = Validating the Server Location 
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/NewProjectWizard.java (-16 / +62 lines)
Lines 21-26 Link Here
21
import org.apache.muse.tools.generator.synthesizer.ServerSynthesizer;
21
import org.apache.muse.tools.generator.synthesizer.ServerSynthesizer;
22
import org.apache.muse.tools.generator.synthesizer.Synthesizer;
22
import org.apache.muse.tools.generator.synthesizer.Synthesizer;
23
import org.apache.muse.tools.generator.util.ConfigurationData;
23
import org.apache.muse.tools.generator.util.ConfigurationData;
24
import org.apache.ws.muse.descriptor.AdditionalJarsType;
24
import org.eclipse.core.resources.IWorkspaceRoot;
25
import org.eclipse.core.resources.IWorkspaceRoot;
25
import org.eclipse.core.resources.ResourcesPlugin;
26
import org.eclipse.core.resources.ResourcesPlugin;
26
import org.eclipse.core.runtime.ILog;
27
import org.eclipse.core.runtime.ILog;
Lines 55-60 Link Here
55
56
56
	private GenerationOptionsPage _generationOptionsPage;
57
	private GenerationOptionsPage _generationOptionsPage;
57
58
59
    private GenerationProjectPage _generationProjectPage;
60
58
	private String _projectName;
61
	private String _projectName;
59
62
60
	private boolean _overwrite;
63
	private boolean _overwrite;
Lines 73-83 Link Here
73
76
74
	private DescriptorHelper _helper;
77
	private DescriptorHelper _helper;
75
78
79
	private String _serverLocation;
80
81
	private boolean _isAxis2Project;
82
76
	public NewProjectWizard(CodeGenerationDelegate codeGenerationDelegate)
83
	public NewProjectWizard(CodeGenerationDelegate codeGenerationDelegate)
77
	{
84
	{
78
		setWindowTitle(Messages.HOOKUP_WIZARD_TXT7);
85
		setWindowTitle(Messages.HOOKUP_WIZARD_TXT7);
79
		setNeedsProgressMonitor(true);
86
		setNeedsProgressMonitor(true);
80
81
		_codeGenerationDelegate = codeGenerationDelegate;
87
		_codeGenerationDelegate = codeGenerationDelegate;
82
	}
88
	}
83
89
Lines 85-90 Link Here
85
	{
91
	{
86
		_generationOptionsPage = new GenerationOptionsPage();
92
		_generationOptionsPage = new GenerationOptionsPage();
87
		addPage(_generationOptionsPage);
93
		addPage(_generationOptionsPage);
94
		_generationProjectPage = new GenerationProjectPage();
95
		addPage(_generationProjectPage);
88
96
89
		// TODO AME why is this hardcoded here? why is it getting reloaded?
97
		// TODO AME why is this hardcoded here? why is it getting reloaded?
90
		Image imgTP = EclipseUtils.loadImage(PlatformUI.getWorkbench()
98
		Image imgTP = EclipseUtils.loadImage(PlatformUI.getWorkbench()
Lines 99-112 Link Here
99
	{
107
	{
100
		try
108
		try
101
		{
109
		{
102
			monitor.beginTask("Working: ", 6);
110
			monitor.beginTask(Messages.CODE_GEN_START, 6);
111
			String[] axis2files = {"lib/axis2-adb-1.1.1.jar",
112
					"lib/axis2-codegen-1.1.1.jar","lib/axis2-java2wsdl-1.1.1.jar",
113
					"lib/axis2-tools-1.1.1.jar"};
114
			
115
			if(_isAxis2Project){
116
				try{
117
					// Step 1: Validate the server path
118
					monitor.subTask(Messages.CODE_GEN_VALIDATE_SLOCATION);
119
					if((new File(_serverLocation)).exists()){
120
						//TODO Nalini
121
						// Step 2 : Update the Preferences, if needed
122
						// Step 3 : Check for Axis2 installation libraries
123
							boolean found = true;
124
							for(int i = 0 ; i < axis2files.length ; i++){
125
								File axisFile = new File(_serverLocation+ File.separator+axis2files[i]);
126
								if(axisFile.exists())
127
									continue;
128
								else{
129
									found = false;
130
									break;
131
								}
132
							}
133
							if(!found){
134
								return;
135
							}
136
					}else{
137
						throw new InvocationTargetException(new Exception(Messages.CODE_GEN_ERROR_AXIS2));
138
					}
139
				
140
				}catch(Exception e){
141
					throw new RuntimeException(e);
142
				}
143
			}
103
144
104
			try
145
			try
105
			{
146
			{
106
				// TODO AME externalize string
147
				// TODO AME externalize string
107
				monitor.subTask("Initializing Code Generation");
148
				monitor.subTask(Messages.CODE_GEN_STEP1);
108
				_helper = _codeGenerationDelegate.run(new SubProgressMonitor(
149
				_helper = _codeGenerationDelegate.run(new SubProgressMonitor(
109
						monitor, 1));
150
						monitor, 1));
151
				// Step 4 : Copy the axis2 files for CodeGeneration
152
				if(_isAxis2Project){
153
					_helper.addAdditionalJars(_serverLocation, axis2files);
154
				}
110
				monitor.worked(1);
155
				monitor.worked(1);
111
			}
156
			}
112
			catch (Exception e)
157
			catch (Exception e)
Lines 120-126 Link Here
120
			try
165
			try
121
			{
166
			{
122
				// TODO AME externalize string
167
				// TODO AME externalize string
123
				monitor.subTask("Merging WSDL");
168
				monitor.subTask(Messages.CODE_GEN_STEP2);
124
				_mergedWsdlDocuments = _helper.getWsdlDocuments(_baseAddress);
169
				_mergedWsdlDocuments = _helper.getWsdlDocuments(_baseAddress);
125
				monitor.worked(1);
170
				monitor.worked(1);
126
			}
171
			}
Lines 132-145 Link Here
132
			try
177
			try
133
			{
178
			{
134
				// TODO AME externalize string
179
				// TODO AME externalize string
135
				monitor.subTask("Creating project");
180
				monitor.subTask(Messages.CODE_GEN_STEP3);
136
				runProjectizer(monitor);
181
				runProjectizer(monitor);
137
				monitor.worked(1);
182
				monitor.worked(1);
138
			}
183
			}
139
			catch (Exception e)
184
			catch (Exception e)
140
			{
185
			{
141
				throw new InvocationTargetException(new Exception(
186
				throw new InvocationTargetException(new Exception(
142
						"Code generation failed, see Error Log", e));
187
						Messages.CODE_GEN_FAILED_ERROR, e));
143
			}
188
			}
144
		}
189
		}
145
		finally
190
		finally
Lines 161-166 Link Here
161
		_overwrite = _generationOptionsPage.isOverwrite();
206
		_overwrite = _generationOptionsPage.isOverwrite();
162
		_projectName = _generationOptionsPage.getProjectName();
207
		_projectName = _generationOptionsPage.getProjectName();
163
		_baseAddress = _generationOptionsPage.getBaseAddress();
208
		_baseAddress = _generationOptionsPage.getBaseAddress();
209
		_isAxis2Project = _generationOptionsPage.isAxis2Project();
210
		
211
		if(_isAxis2Project)
212
			_serverLocation = _generationProjectPage.getServerLocation();
164
213
165
		IRunnableWithProgress runnable = new IRunnableWithProgress()
214
		IRunnableWithProgress runnable = new IRunnableWithProgress()
166
		{
215
		{
Lines 180-186 Link Here
180
		{
229
		{
181
			// TODO AME externalize string
230
			// TODO AME externalize string
182
			e.printStackTrace();
231
			e.printStackTrace();
183
			handle("Code generation failed, see Error Log", e);
232
			handle(Messages.CODE_GEN_FAILED_ERROR, e);
184
		}
233
		}
185
234
186
		return false;
235
		return false;
Lines 235-255 Link Here
235
		data.addParameter(EclipseConfigurationData.PROGRESS_MONITOR,
284
		data.addParameter(EclipseConfigurationData.PROGRESS_MONITOR,
236
				new SubProgressMonitor(monitor, 1));
285
				new SubProgressMonitor(monitor, 1));
237
		// TODO AME externalize string
286
		// TODO AME externalize string
238
		monitor.subTask("Running Analyzer");
287
		monitor.subTask(Messages.CODE_GEN_SUBTASK1);
239
		data = _analyzer.analyze(data);
288
		data = _analyzer.analyze(data);
240
		monitor.worked(1);
289
		monitor.worked(1);
241
290
242
		data.addParameter(EclipseConfigurationData.PROGRESS_MONITOR,
291
		data.addParameter(EclipseConfigurationData.PROGRESS_MONITOR,new SubProgressMonitor(monitor, 1));
243
				new SubProgressMonitor(monitor, 1));
244
		// TODO AME externalize string
292
		// TODO AME externalize string
245
		monitor.subTask("Running Synthesizer");
293
		monitor.subTask(Messages.CODE_GEN_SUBTASK2);
246
		data = _synthesizer.synthesize(data);
294
		data = _synthesizer.synthesize(data);
247
		monitor.worked(1);
295
		monitor.worked(1);
248
296
249
		data.addParameter(EclipseConfigurationData.PROGRESS_MONITOR,
297
		data.addParameter(EclipseConfigurationData.PROGRESS_MONITOR,new SubProgressMonitor(monitor, 1));
250
				new SubProgressMonitor(monitor, 1));
251
		// TODO AME externalize string
298
		// TODO AME externalize string
252
		monitor.subTask("Running Projectizer");
299
		monitor.subTask(Messages.CODE_GEN_SUBTASK3);
253
		_projectizer.projectize(data);
300
		_projectizer.projectize(data);
254
		monitor.worked(1);
301
		monitor.worked(1);
255
	}
302
	}
Lines 263-270 Link Here
263
	private void handle(String message, Exception e)
310
	private void handle(String message, Exception e)
264
	{
311
	{
265
		_generationOptionsPage.setErrorMessage(message);
312
		_generationOptionsPage.setErrorMessage(message);
266
		Status status = new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK,
313
		Status status = new Status(IStatus.ERROR, PLUGIN_ID, IStatus.OK, message, e);
267
				message, e);
268
314
269
		if (LOG == null)
315
		if (LOG == null)
270
		{
316
		{
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/MRTCodeGenerationDelegate.java (-4 / +4 lines)
Lines 69-82 Link Here
69
	public DescriptorHelper run(SubProgressMonitor progressMonitor)
69
	public DescriptorHelper run(SubProgressMonitor progressMonitor)
70
			throws Exception
70
			throws Exception
71
	{
71
	{
72
		File ddFile = createDDFile();
72
		IFile ddFile = createDDFile();
73
		return new DescriptorHelper(ddFile);
73
		return new DescriptorHelper(ddFile);
74
	}
74
	}
75
75
76
	private File createDDFile()
76
	private IFile createDDFile()
77
	{
77
	{
78
		_ddFilePath = createDDFilePath();
78
		_ddFilePath = createDDFilePath();
79
80
		//
79
		//
81
		// Create a resource set
80
		// Create a resource set
82
		//
81
		//
Lines 115-121 Link Here
115
114
116
			IFile file = EclipseUtils.getIFile(ResourcesPlugin.getWorkspace()
115
			IFile file = EclipseUtils.getIFile(ResourcesPlugin.getWorkspace()
117
					.getRoot(), fileURI.toString());
116
					.getRoot(), fileURI.toString());
118
			return file.getLocation().toFile();
117
			//return file.getLocation().toFile();
118
			return file;
119
		}
119
		}
120
		catch (Exception exception)
120
		catch (Exception exception)
121
		{
121
		{
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/GenerationOptionsPage.java (-5 / +26 lines)
Lines 110-115 Link Here
110
	private Map _servicePorts;
110
	private Map _servicePorts;
111
	private Map _servicePaths;
111
	private Map _servicePaths;
112
112
113
	private boolean axis2Project;
113
	/**
114
	/**
114
	 * For cheatsheet purpose only This constructor will be used in cheatsheet
115
	 * For cheatsheet purpose only This constructor will be used in cheatsheet
115
	 * only
116
	 * only
Lines 184-194 Link Here
184
		page.setLayoutData(gd);
185
		page.setLayoutData(gd);
185
186
186
		Label projectizerLabel = new Label(page, SWT.NONE);
187
		Label projectizerLabel = new Label(page, SWT.NONE);
187
		projectizerLabel.setText("Projectizer: ");
188
		projectizerLabel.setText(Messages.CODE_GEN_PROJECTIZER);
188
		_projectizerCombo = makeProjectizerCombo(page);
189
		_projectizerCombo = makeProjectizerCombo(page);
189
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
190
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
190
		data.widthHint = 50;
191
		data.widthHint = 50;
191
		_projectizerCombo.setLayoutData(data);
192
		_projectizerCombo.setLayoutData(data);
193
        _projectizerCombo.addListener(SWT.Modify, comboChangeListener);
192
194
193
		Label blankLabel = new Label(page, SWT.NONE);
195
		Label blankLabel = new Label(page, SWT.NONE);
194
		blankLabel.setText(" ");
196
		blankLabel.setText(" ");
Lines 519-526 Link Here
519
		}
521
		}
520
	};
522
	};
521
523
522
	void setLocationForSelection()
524
    private Listener comboChangeListener = new Listener() {
523
	{
525
        public void handleEvent(Event e) {
526
        	dialogChanged();
527
        }
528
    };
529
    
530
    void setLocationForSelection() {
524
		// _locationArea.updateProjectName(getProjectNameFieldValue());
531
		// _locationArea.updateProjectName(getProjectNameFieldValue());
525
	}
532
	}
526
533
Lines 610-615 Link Here
610
			updateStatus(Messages.HOOKUP_WIZARD_ERROR_2);
617
			updateStatus(Messages.HOOKUP_WIZARD_ERROR_2);
611
			return;
618
			return;
612
		}
619
		}
620
		canFlipToNextPage();
613
621
614
		updateStatus(null, DialogPage.NONE);
622
		updateStatus(null, DialogPage.NONE);
615
	}
623
	}
Lines 625-632 Link Here
625
		setPageComplete(type != DialogPage.ERROR);
633
		setPageComplete(type != DialogPage.ERROR);
626
	}
634
	}
627
635
628
	private Button makeButton(Composite parent, String title, int style)
636
	public boolean canFlipToNextPage(){
629
	{
637
		if(isPageComplete() && _projectizerCombo.getText().contains("Axis2")){
638
			axis2Project = true;
639
			return true;
640
		}
641
		axis2Project = false;
642
		return false;
643
	}
644
	
645
	public boolean isAxis2Project(){
646
		return axis2Project;
647
	}
648
	
649
	private Button makeButton(Composite parent, String title, int style) {
630
		Button b = new Button(parent, style);
650
		Button b = new Button(parent, style);
631
		b.setText(title);
651
		b.setText(title);
632
		return b;
652
		return b;
Lines 872-875 Link Here
872
			text = ((IResource) element).getFullPath().toString();
892
			text = ((IResource) element).getFullPath().toString();
873
		return text;
893
		return text;
874
	}
894
	}
895
	
875
}
896
}
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/DescriptorHelper.java (-1 / +59 lines)
Lines 13-28 Link Here
13
package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal;
13
package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal;
14
14
15
import java.io.File;
15
import java.io.File;
16
import java.io.IOException;
17
import java.util.Collections;
16
18
17
import javax.xml.namespace.QName;
19
import javax.xml.namespace.QName;
18
20
19
import org.apache.muse.core.descriptor.DescriptorConstants;
21
import org.apache.muse.core.descriptor.DescriptorConstants;
20
import org.apache.muse.util.xml.XmlUtils;
22
import org.apache.muse.util.xml.XmlUtils;
23
import org.apache.ws.muse.descriptor.AdditionalJarsType;
24
import org.apache.ws.muse.descriptor.DescriptorPackage;
25
import org.apache.ws.muse.descriptor.DocumentRoot;
26
import org.apache.ws.muse.descriptor.RootType;
21
import org.eclipse.core.resources.IFile;
27
import org.eclipse.core.resources.IFile;
22
import org.eclipse.core.resources.IWorkspace;
28
import org.eclipse.core.resources.IWorkspace;
23
import org.eclipse.core.resources.IWorkspaceRoot;
29
import org.eclipse.core.resources.IWorkspaceRoot;
24
import org.eclipse.core.resources.ResourcesPlugin;
30
import org.eclipse.core.resources.ResourcesPlugin;
25
import org.eclipse.core.runtime.IPath;
31
import org.eclipse.core.runtime.IPath;
32
import org.eclipse.emf.common.util.URI;
33
import org.eclipse.emf.ecore.resource.Resource;
34
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
35
import org.eclipse.tptp.wsdm.tooling.editor.dde.util.internal.DdeUtil;
36
import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages;
37
import org.eclipse.tptp.wsdm.tooling.util.internal.MyDescriptorResourceFactoryImpl;
38
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog;
26
import org.eclipse.tptp.wsdm.tooling.wizard.mrt.internal.NewMrtWizard;
39
import org.eclipse.tptp.wsdm.tooling.wizard.mrt.internal.NewMrtWizard;
27
import org.w3c.dom.Document;
40
import org.w3c.dom.Document;
28
import org.w3c.dom.Element;
41
import org.w3c.dom.Element;
Lines 88-93 Link Here
88
	 */
101
	 */
89
	private Object[][] _instances;
102
	private Object[][] _instances;
90
103
104
	private IFile ddIFile;
91
	/**
105
	/**
92
	 * A do-something constructor. Take a file, if that file is null, then load
106
	 * A do-something constructor. Take a file, if that file is null, then load
93
	 * up a default template. Otherwise load up the file and pull out the
107
	 * up a default template. Otherwise load up the file and pull out the
Lines 104-115 Link Here
104
	public DescriptorHelper(IFile descriptorFile) throws Exception
118
	public DescriptorHelper(IFile descriptorFile) throws Exception
105
	{
119
	{
106
		this(new File(descriptorFile.getLocation().toString()));
120
		this(new File(descriptorFile.getLocation().toString()));
121
		ddIFile = descriptorFile;
107
	}
122
	}
108
123
109
	public DescriptorHelper(File file) throws Exception
124
	public DescriptorHelper(File file) throws Exception
110
	{
125
	{
111
		Document rootDocument = XmlUtils.createDocument(file);
126
		Document rootDocument = XmlUtils.createDocument(file);
112
113
		_descriptorDocument = extractDescriptorDocument(rootDocument);
127
		_descriptorDocument = extractDescriptorDocument(rootDocument);
114
		_instances = extractInstances(rootDocument);
128
		_instances = extractInstances(rootDocument);
115
		_jarFiles = extractJarFiles(rootDocument);
129
		_jarFiles = extractJarFiles(rootDocument);
Lines 340-343 Link Here
340
	{
354
	{
341
		return fileName.substring(0, fileName.lastIndexOf(".")) + MRT_EXTN;
355
		return fileName.substring(0, fileName.lastIndexOf(".")) + MRT_EXTN;
342
	}
356
	}
357
358
	public void addAdditionalJars(String serverLocation, String[] axis2files) {
359
		
360
		DocumentRoot root = DdeUtil.getDocRoot(ddIFile);
361
		RootType rootType = root.getRoot();
362
		AdditionalJarsType additionalJars = rootType.getAdditionalJars();
363
		for(int i = 0 ; i < axis2files.length ; i++ ){
364
			additionalJars.getJarPath().add(serverLocation + File.separator + axis2files[i]);
365
		}
366
		
367
		rootType.setAdditionalJars(additionalJars);
368
		root.setRoot(rootType);
369
		save(root);
370
	}
371
	
372
	private void save(DocumentRoot root)
373
	{
374
		ensureMusePackagePresent();
375
		URI ddFileURI = URI.createPlatformResourceURI(ddIFile.getFullPath().toString());
376
		ResourceSetImpl rsImpl = new ResourceSetImpl();
377
		rsImpl.getResourceFactoryRegistry().getExtensionToFactoryMap()
378
		.put(Resource.Factory.Registry.DEFAULT_EXTENSION,
379
		new MyDescriptorResourceFactoryImpl());
380
		rsImpl.getPackageRegistry().put(DescriptorPackage.eNS_URI,
381
		DescriptorPackage.eINSTANCE);
382
		Resource ddRes = rsImpl.getResource(ddFileURI, true);
383
		ddRes.getContents().remove(0);
384
		ddRes.getContents().add(root);
385
		try {
386
			ddRes.save(Collections.EMPTY_MAP);
387
		} catch (IOException e) {
388
			e.printStackTrace();
389
		}
390
	}
391
	
392
	private void ensureMusePackagePresent()
393
	{
394
		// Ensure EMF knows about Muse descriptor
395
		if (DescriptorPackage.eINSTANCE == null)
396
		{
397
		WsdmToolingLog.logError(Messages.FAILED_TO_INITIALIZE_MUSE_DESCRIPTOR_ERROR_, new Throwable());
398
		}
399
	} 
400
	
343
}
401
}
(-)src/org/eclipse/tptp/wsdm/tooling/editor/mrt/internal/MrtPrototypeForm.java (-54 lines)
Lines 571-588 Link Here
571
		{
571
		{
572
			public void handleEvent(Event event)
572
			public void handleEvent(Event event)
573
			{
573
			{
574
				System.out.println("Capability to delete : "
575
						+ _selectedCapForDelete.getName());
576
				DeleteCapabilityCommand delete = new DeleteCapabilityCommand(
574
				DeleteCapabilityCommand delete = new DeleteCapabilityCommand(
577
						_editingDomain, _mrt, _selectedCapForDelete);
575
						_editingDomain, _mrt, _selectedCapForDelete);
578
				delete.execute();
576
				delete.execute();
579
				// TODO
580
				// deleteDefinition(_selectedCapForDelete);
581
				// _allCaps.add(_selectedCapForDelete);
582
				// RemoveCommand rc = new RemoveCommand(_editingDomain, _mrt
583
				// .getImplements(), _selectedCapForDelete.getLocation());
584
				// _editingDomain.getCommandStack().execute(rc);
585
				// _treeViewer.setInput(getAllNamespaces());
586
				_treeViewer.refresh();
577
				_treeViewer.refresh();
587
				_treeViewer.expandAll();
578
				_treeViewer.expandAll();
588
				_expandAllButton.setEnabled(true);
579
				_expandAllButton.setEnabled(true);
Lines 621-665 Link Here
621
		getForm().reflow(true);
612
		getForm().reflow(true);
622
	}
613
	}
623
614
624
	/**
625
	 * Dialog which brings up workspace capabilities as a JFace
626
	 * CheckboxTableViewer.
627
	 */
628
	protected void selectCaps()
629
	{
630
		// Initialize workspace capabilities.
631
		// TODO
632
		// WorkspaceCapSelector dlg = new WorkspaceCapSelector(_mrtSection
633
		// .getShell(), Messages.ADD_CAP, MRT_CAPS, _containerName);
634
		// int choice = dlg.open();
635
		// if (choice == Window.OK) {
636
		// List selectedCaps = dlg.getSelectedCaps();
637
		// MRT_CAPS.addAll(selectedCaps);
638
		// _allCaps.removeAll(selectedCaps);
639
		// AddCommand ac = new AddCommand(_editingDomain,
640
		// _mrt.getImplements(),
641
		// convertDefinitionsToStrings(selectedCaps));
642
		// _editingDomain.getCommandStack().execute(ac);
643
		// }
644
	}
645
646
	private void deleteDefinition()
647
	{
648
		// TODO
649
		// for (int i = 0; i < MRT_CAPS.size(); i++) {
650
		// Definition d = (Definition) MRT_CAPS.get(i);
651
		// if (d.getLocation().equals(def.getLocation())) {
652
		// if (MrtUtils.isMetadataExchangeCapability(def)
653
		// || MrtUtils.isWSRPCapability(def))
654
		// showOkDialog(Messages.WARNING, NLS.bind(
655
		// Messages.MRT_MAY_NOT_WORK_WITH_MAX, WsdlUtils
656
		// .getName(def)), MessageDialog.INFORMATION);
657
		// MRT_CAPS.remove(d);
658
		// break;
659
		// }
660
		// }
661
	}
662
663
	public void propertyChanged(Object source, int propId)
615
	public void propertyChanged(Object source, int propId)
664
	{
616
	{
665
		Resource res = (Resource) _editingDomain.getResourceSet()
617
		Resource res = (Resource) _editingDomain.getResourceSet()
Lines 677-688 Link Here
677
	{
629
	{
678
		MrtCategoryCollection collection = new MrtCategoryCollection(_mrt);
630
		MrtCategoryCollection collection = new MrtCategoryCollection(_mrt);
679
		Category[] categories = collection.getAllCategories();
631
		Category[] categories = collection.getAllCategories();
680
		/*
681
		 * for(int i = 0 ; i < categories.length ; i++){ Capability[] caps =
682
		 * categories[i].getCapabilities(); for(int j = 0 ; j < caps.length ;
683
		 * j++){ System.out.println("Category : " + categories[i].getName() + "
684
		 * capability : " + caps[j].getName()); } }
685
		 */
686
		_treeViewer.setInput(Arrays.asList(categories));
632
		_treeViewer.setInput(Arrays.asList(categories));
687
		_treeViewer.refresh();
633
		_treeViewer.refresh();
688
634
(-)src/org/eclipse/tptp/wsdm/tooling/editor/dde/util/internal/DdeUtil.java (-195 / +212 lines)
Lines 17-24 Link Here
17
import java.util.Iterator;
17
import java.util.Iterator;
18
import java.util.List;
18
import java.util.List;
19
19
20
import javax.wsdl.Definition;
21
22
import org.apache.ws.muse.descriptor.CapabilityType;
20
import org.apache.ws.muse.descriptor.CapabilityType;
23
import org.apache.ws.muse.descriptor.CustomSerializerType;
21
import org.apache.ws.muse.descriptor.CustomSerializerType;
24
import org.apache.ws.muse.descriptor.DescriptorFactory;
22
import org.apache.ws.muse.descriptor.DescriptorFactory;
Lines 54-67 Link Here
54
import org.eclipse.swt.widgets.Table;
52
import org.eclipse.swt.widgets.Table;
55
import org.eclipse.swt.widgets.TableItem;
53
import org.eclipse.swt.widgets.TableItem;
56
import org.eclipse.swt.widgets.Text;
54
import org.eclipse.swt.widgets.Text;
57
import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.Generation;
58
import org.eclipse.tptp.wsdm.tooling.editor.dde.internal.DescriptorEditor;
55
import org.eclipse.tptp.wsdm.tooling.editor.dde.internal.DescriptorEditor;
56
import org.eclipse.tptp.wsdm.tooling.editor.internal.CapabilityDefinition;
59
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability;
57
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability;
60
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property;
58
import org.eclipse.tptp.wsdm.tooling.model.capabilities.Property;
61
import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType;
59
import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType;
62
import org.eclipse.tptp.wsdm.tooling.nls.messages.dde.internal.Messages;
60
import org.eclipse.tptp.wsdm.tooling.nls.messages.dde.internal.Messages;
61
import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils;
63
import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils;
62
import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils;
64
import org.eclipse.tptp.wsdm.tooling.util.internal.MyDescriptorResourceFactoryImpl;
63
import org.eclipse.tptp.wsdm.tooling.util.internal.MyDescriptorResourceFactoryImpl;
64
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdlUtils;
65
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog;
65
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog;
66
import org.eclipse.ui.IWorkbench;
66
import org.eclipse.ui.IWorkbench;
67
import org.eclipse.ui.IWorkbenchPage;
67
import org.eclipse.ui.IWorkbenchPage;
Lines 74-80 Link Here
74
74
75
/**
75
/**
76
 * This utility class contains some helper methods for DescriptorEditor.
76
 * This utility class contains some helper methods for DescriptorEditor.
77
 * 
77
 *  
78
 */
78
 */
79
public class DdeUtil
79
public class DdeUtil
80
{
80
{
Lines 95-103 Link Here
95
		IWorkbenchPage page = workbenchWindow.getActivePage();
95
		IWorkbenchPage page = workbenchWindow.getActivePage();
96
		if (file.getFullPath().toString().startsWith("/plugin/")) //$NON-NLS-1$
96
		if (file.getFullPath().toString().startsWith("/plugin/")) //$NON-NLS-1$
97
		{
97
		{
98
			MessageDialog.openInformation(page.getActiveEditor()
98
			MessageDialog
99
					.getEditorSite().getShell(), Messages.COMMON_ERROR_TITLE, //$NON-NLS-1$
99
					.openInformation(
100
					Messages.DU_ERROR_MSG1); //$NON-NLS-1$
100
							page.getActiveEditor().getEditorSite().getShell(),
101
							Messages.COMMON_ERROR_TITLE, //$NON-NLS-1$
102
							Messages.DU_ERROR_MSG1); //$NON-NLS-1$
101
			return;
103
			return;
102
		}
104
		}
103
		try
105
		try
Lines 105-116 Link Here
105
			page.openEditor(new FileEditorInput(modelFile), workbench
107
			page.openEditor(new FileEditorInput(modelFile), workbench
106
					.getEditorRegistry().getDefaultEditor(modelFile.getName())
108
					.getEditorRegistry().getDefaultEditor(modelFile.getName())
107
					.getId());
109
					.getId());
108
		}
110
		} catch (Exception ex)
109
		catch (Exception ex)
110
		{
111
		{
111
			WsdmToolingLog.logError(NLS.bind(
112
		    WsdmToolingLog.logError(NLS.bind(Messages.COULDNT_OPEN_DEFAULT_EDITOR_FOR_FILE_ERROR_, file.getName()),ex);
112
					Messages.COULDNT_OPEN_DEFAULT_EDITOR_FOR_FILE_ERROR_, file
113
							.getName()), ex);
114
		}
113
		}
115
	}
114
	}
116
115
Lines 133-142 Link Here
133
	 * 
132
	 * 
134
	 * @return List object containing the resources in the workspace.
133
	 * @return List object containing the resources in the workspace.
135
	 */
134
	 */
136
	public static List loadResources() // throws Exception
135
	public static List loadResources() //throws Exception
137
	{
136
	{
138
		List resourceList = new ArrayList();
137
		List resourceList = new ArrayList();
139
138
		
140
		IProject[] projects = ResourcesPlugin.getWorkspace().getRoot()
139
		IProject[] projects = ResourcesPlugin.getWorkspace().getRoot()
141
				.getProjects();
140
				.getProjects();
142
		if (projects != null && projects.length > 0)
141
		if (projects != null && projects.length > 0)
Lines 148-159 Link Here
148
				{
147
				{
149
					projectResources = projects[i].members();
148
					projectResources = projects[i].members();
150
				}
149
				}
151
				catch (CoreException ex)
150
				catch(CoreException ex)
152
				{
151
				{
153
					// WsdmToolingLog.logError(Messages.FAILED_TO_GET_MEMBERS_FOR_PROJECT_ERROR_
152
					//WsdmToolingLog.logError(Messages.FAILED_TO_GET_MEMBERS_FOR_PROJECT_ERROR_ , ex); this line is commented out because if any project in the workspace is closed, this throws an error in the problems view.
154
					// , ex); this line is commented out because if any project
155
					// in the workspace is closed, this throws an error in the
156
					// problems view.
157
					continue;
153
					continue;
158
				}
154
				}
159
				if (projectResources == null || projectResources.length == 0)
155
				if (projectResources == null || projectResources.length == 0)
Lines 162-168 Link Here
162
					getFilesFromResource(projectResources[j], resourceList);
158
					getFilesFromResource(projectResources[j], resourceList);
163
			}
159
			}
164
		}
160
		}
165
161
		
166
		return resourceList;
162
		return resourceList;
167
	}
163
	}
168
164
Lines 176-190 Link Here
176
	 * @throws Exception
172
	 * @throws Exception
177
	 */
173
	 */
178
	public static void getFilesFromResource(IResource res, List resourceList)
174
	public static void getFilesFromResource(IResource res, List resourceList)
179
	// throws Exception
175
			//throws Exception
180
	{
176
	{
181
		try
177
		try
182
		{
178
		{
183
			if (res.getType() == IResource.FILE)
179
			if (res.getType() == IResource.FILE)
184
			{
180
			{
185
				resourceList.add(res);
181
				resourceList.add(res);
186
			}
182
			} else if (res.getType() == IResource.FOLDER)
187
			else if (res.getType() == IResource.FOLDER)
188
			{
183
			{
189
				IResource[] files = ((IFolder) res).members();
184
				IResource[] files = ((IFolder) res).members();
190
				if (files == null || files.length == 0)
185
				if (files == null || files.length == 0)
Lines 195-205 Link Here
195
				}
190
				}
196
			}
191
			}
197
		}
192
		}
198
		catch (CoreException ex)
193
		catch(CoreException ex)
199
		{
194
		{
200
			WsdmToolingLog.logError(NLS.bind(
195
			WsdmToolingLog.logError(NLS.bind(Messages.FAILED_TO_GET_MEMBERS_FOR_RESOURCE_ERROR_, res.getName()), ex);
201
					Messages.FAILED_TO_GET_MEMBERS_FOR_RESOURCE_ERROR_, res
202
							.getName()), ex);
203
		}
196
		}
204
	}
197
	}
205
198
Lines 255-276 Link Here
255
				.setJavaIdFactoryClass("org.apache.muse.core.routing.CounterResourceIdFactory"); //$NON-NLS-1$
248
				.setJavaIdFactoryClass("org.apache.muse.core.routing.CounterResourceIdFactory"); //$NON-NLS-1$
256
		rtd
249
		rtd
257
				.setJavaResourceClass("org.apache.muse.ws.resource.impl.SimpleWsResource"); //$NON-NLS-1$
250
				.setJavaResourceClass("org.apache.muse.ws.resource.impl.SimpleWsResource"); //$NON-NLS-1$
258
251
		
259
		// Fix for defect 60319
252
		//Fix for defect 60319
260
		rtd.setUseRouterPersistence(true);
253
		rtd.setUseRouterPersistence(true);
261
254
		
262
		rtd.getCapability().addAll(getCapabilitiesFromMRT(mrt));
255
		rtd.getCapability().addAll(getCapabilitiesFromMRT(mrt));
263
		WsdlType wsdlType = DescriptorFactory.eINSTANCE.createWsdlType();
256
		WsdlType wsdlType = DescriptorFactory.eINSTANCE.createWsdlType();
264
		wsdlType.setWsdlFile(wsdlName);
257
		wsdlType.setWsdlFile(wsdlName);
265
258
266
		String namespace = mrt.getNamespace();
259
		String namespace = mrt.getNamespace();
267
		String prefix = getOrCreatePrefix(root, namespace);
260
		String prefix = getOrCreatePrefix(root, namespace);
268
		String localPart = Messages.DU_PORT_TYPE_LOCAL_PART; // Only
261
		String localPart = Messages.DU_PORT_TYPE_LOCAL_PART; // Only "PortType" should come with the //$NON-NLS-1$
269
		// "PortType"
262
		wsdlType.setWsdlPortType(prefix+":"+localPart);
270
		// should come
271
		// with the
272
		// //$NON-NLS-1$
273
		wsdlType.setWsdlPortType(prefix + ":" + localPart);
274
263
275
		rtd.setWsdl(wsdlType);
264
		rtd.setWsdl(wsdlType);
276
265
Lines 356-371 Link Here
356
	 */
345
	 */
357
	public static MuseType loadDecriptorFile(IFile file)
346
	public static MuseType loadDecriptorFile(IFile file)
358
	{
347
	{
359
		URI uri = URI.createPlatformResourceURI(file.getFullPath().toString());
348
		MuseType mt = loadMuseType(file);
360
		if (uri == null)
361
			return null;
362
		MuseType mt = loadMuseType(uri);
363
		return mt;
349
		return mt;
364
	}
350
	}
365
351
366
	// Return MuseType at URI.
352
	// Return MuseType at URI.
367
	private static MuseType loadMuseType(URI uri)
353
	private static MuseType loadMuseType(IFile file)
354
	{
355
		DocumentRoot root = getDocRoot(file);
356
		RootType rt = root.getRoot();
357
		return rt.getMuse();
358
	}
359
360
	/**
361
	 * This method takes a dd file and returns the document root of the file
362
	 * @param file - IFile which is a dd file
363
	 * @return DocumentRoot of the file.
364
	 */
365
	public static DocumentRoot getDocRoot(IFile file)
368
	{
366
	{
367
		URI uri = URI.createPlatformResourceURI(file.getFullPath().toString());
368
		if (uri == null)
369
			return null;
369
		ensureMusePackagePresent();
370
		ensureMusePackagePresent();
370
		ResourceSet resourceSet = new ResourceSetImpl();
371
		ResourceSet resourceSet = new ResourceSetImpl();
371
		resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
372
		resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
Lines 375-392 Link Here
375
				DescriptorPackage.eINSTANCE);
376
				DescriptorPackage.eINSTANCE);
376
		Resource resource = resourceSet.getResource(uri, true);
377
		Resource resource = resourceSet.getResource(uri, true);
377
		DocumentRoot root = (DocumentRoot) resource.getContents().get(0);
378
		DocumentRoot root = (DocumentRoot) resource.getContents().get(0);
378
		RootType rt = root.getRoot();
379
		return root;
379
		return rt.getMuse();
380
	}
380
	}
381
381
	
382
	private static void ensureMusePackagePresent()
382
	private static void ensureMusePackagePresent()
383
	{
383
	{
384
		// Ensure EMF knows about Muse descriptor
384
		// Ensure EMF knows about Muse descriptor
385
		if (DescriptorPackage.eINSTANCE == null)
385
		if (DescriptorPackage.eINSTANCE == null)
386
		{
386
		{
387
			WsdmToolingLog.logError(
387
			WsdmToolingLog.logError(Messages.FAILED_TO_INITIALIZE_MUSE_DESCRIPTOR_ERROR_, new Throwable());
388
					Messages.FAILED_TO_INITIALIZE_MUSE_DESCRIPTOR_ERROR_,
389
					new Throwable());
390
		}
388
		}
391
	}
389
	}
392
390
Lines 404-448 Link Here
404
		if (mrt == null)
402
		if (mrt == null)
405
			return null;
403
			return null;
406
		List capDataList = new ArrayList();
404
		List capDataList = new ArrayList();
407
		Capability[] capabilities = new Capability[0];
405
		List caps = mrt.getImplements();
408
		try
406
		if (caps != null)
409
		{
410
			capabilities = MrtUtils.getCapabilities(mrt);
411
		}
412
		catch (Exception e)
413
		{
414
		}
415
		for (int i = 0; i < capabilities.length; i++)
416
		{
407
		{
417
			Definition definition = capabilities[i].getWsdlDefinition()
408
			for (int i = 0; i < caps.size(); i++)
418
					.getDefinition();
419
			String capNS = "";
420
			if (definition != null)
421
			{
409
			{
422
				String nsURI = capabilities[i].getWsdlDefinition()
410
				CapabilityDefinition def;
423
						.getNamespace("capabilityURI");
411
				try
424
				if (nsURI != null)
412
				{
425
					capNS = nsURI;
413
					IFile iFile = EclipseUtils.getIFile((String) caps.get(i));
426
				else
414
				    def = WsdlUtils.getCapabilityDefinition(iFile);
427
					capNS = definition.getTargetNamespace();
415
				} catch (Exception e)
416
				{
417
				    continue;
418
				}
419
				String capNS = ""; //$NON-NLS-1$
420
				if (def != null)
421
				{
422
					capNS = def.getNamespace("xmlns:capabilityURI");
423
					if(capNS == null)
424
						capNS = def.getNamespace("targetNamespace");
425
					if(capNS == null)
426
						capNS = "";
427
				} else
428
				{
429
					capNS = "";
430
				}
431
				CapabilityTypeImpl ctype = (CapabilityTypeImpl) DescriptorFactory.eINSTANCE
432
						.createCapabilityType();
433
				ctype.setCapabilityUri(capNS);
434
				ctype.setJavaCapabilityClass(""); //$NON-NLS-1$
435
				/*boolean isValid = validateCapability(capDataList, ctype);
436
				if (isValid)*/
437
					capDataList.add(ctype);
428
			}
438
			}
429
			CapabilityTypeImpl ctype = (CapabilityTypeImpl) DescriptorFactory.eINSTANCE
430
					.createCapabilityType();
431
			ctype.setCapabilityUri(capNS);
432
			ctype.setJavaCapabilityClass(""); //$NON-NLS-1$
433
			capDataList.add(ctype);
434
		}
439
		}
435
		return capDataList;
440
		return capDataList;
436
	}
441
	}
437
442
438
	/*
443
	/*private static boolean validateCapability(List capDataList,
439
	 * private static boolean validateCapability(List capDataList,
444
			CapabilityTypeImpl ctype)
440
	 * CapabilityTypeImpl ctype) { if (capDataList == null || capDataList.size() ==
445
	{
441
	 * 0) { capDataList = new ArrayList(); return true; } for (int i = 0; i <
446
		if (capDataList == null || capDataList.size() == 0)
442
	 * capDataList.size(); i++) { CapabilityTypeImpl tmp = (CapabilityTypeImpl)
447
		{
443
	 * capDataList.get(i); if (tmp.getCapabilityUri().trim().equals(
448
			capDataList = new ArrayList();
444
	 * ctype.getCapabilityUri().trim())) return false; } return true; }
449
			return true;
445
	 */
450
		}
451
		for (int i = 0; i < capDataList.size(); i++)
452
		{
453
			CapabilityTypeImpl tmp = (CapabilityTypeImpl) capDataList.get(i);
454
			if (tmp.getCapabilityUri().trim().equals(
455
					ctype.getCapabilityUri().trim()))
456
				return false;
457
		}
458
		return true;
459
	}*/
446
460
447
	private static String getDefaultWsdlFileName(String mrtFileName)
461
	private static String getDefaultWsdlFileName(String mrtFileName)
448
	{
462
	{
Lines 520-526 Link Here
520
				| SWT.LEFT_TO_RIGHT);
534
				| SWT.LEFT_TO_RIGHT);
521
		txtIDFactory.setText(data.getJavaIdFactoryClass());
535
		txtIDFactory.setText(data.getJavaIdFactoryClass());
522
		txtIDFactory.setEnabled(false);
536
		txtIDFactory.setEnabled(false);
523
		txtIDFactory.setToolTipText(Messages.DU_TXT_ID_FACTORY_TOOLTIP); //$NON-NLS-1$
537
		txtIDFactory
538
				.setToolTipText(Messages.DU_TXT_ID_FACTORY_TOOLTIP); //$NON-NLS-1$
524
		controlEditor.setEditor(txtIDFactory, ti, 4);
539
		controlEditor.setEditor(txtIDFactory, ti, 4);
525
		// controlEditor
540
		// controlEditor
526
		// ti.setText(4, data.getJavaIdFactoryClass());
541
		// ti.setText(4, data.getJavaIdFactoryClass());
Lines 545-550 Link Here
545
		ti.setData(data);
560
		ti.setData(data);
546
	}
561
	}
547
562
563
	/*private static Capability getCapability(URI uri)
564
	{
565
		Definition def;
566
		try
567
		{
568
		    def = WsdlUtils.getWSDLDefinition(uri);
569
		} catch (Exception e)
570
		{
571
		    return null;
572
		}
573
		Definition2Capability def2Capability = new Definition2Capability(def);
574
		Capability cap = def2Capability.getCapability();
575
		return cap;
576
	}*/
577
548
	/**
578
	/**
549
	 * Method that checks whether the given {@link InitParamTypeImpl} object is
579
	 * Method that checks whether the given {@link InitParamTypeImpl} object is
550
	 * valid to be added to the initialization parameters table.
580
	 * valid to be added to the initialization parameters table.
Lines 560-576 Link Here
560
	 * @return true if the parameter data is not a duplicate.<br>
590
	 * @return true if the parameter data is not a duplicate.<br>
561
	 *         false otherwise
591
	 *         false otherwise
562
	 */
592
	 */
563
	public static boolean validateParam(EObject data, InitParamTypeImpl pData,
593
	public static boolean validateParam(EObject data,
564
			int idx)
594
			InitParamTypeImpl pData, int idx)
565
	{
595
	{
566
		if (data == null || pData == null)
596
		if (data == null || pData == null)
567
			return false;
597
			return false;
568
		List paramList = null;
598
		List paramList = null;
569
		if (data instanceof ResourceTypeType)
599
		if(data instanceof ResourceTypeType)
570
		{
600
		{
571
			paramList = ((ResourceTypeType) data).getInitParam();
601
			paramList = ((ResourceTypeType) data).getInitParam();
572
		}
602
		}
573
		else if (data instanceof CapabilityTypeImpl)
603
		else if(data instanceof CapabilityTypeImpl)
574
		{
604
		{
575
			paramList = ((CapabilityTypeImpl) data).getInitParam();
605
			paramList = ((CapabilityTypeImpl) data).getInitParam();
576
		}
606
		}
Lines 670-676 Link Here
670
		{
700
		{
671
			IFile file = (IFile) availableFiles.get(i);
701
			IFile file = (IFile) availableFiles.get(i);
672
			// here filename comes with full path....
702
			// here filename comes with full path....
673
			if (file.getFullPath().toString().trim().equals(fileName.trim()))
703
			if (file.getFullPath().toString().trim()
704
					.equals(fileName.trim()))
674
				return file;
705
				return file;
675
		}
706
		}
676
		return null;
707
		return null;
Lines 751-762 Link Here
751
		}
782
		}
752
		return false;
783
		return false;
753
	}
784
	}
754
785
	
755
	/**
786
	/**
756
	 * Formats the given path string to return the display name of the file.
787
	 * Formats the given path string to return the display name of the file.
757
	 * 
788
	 * @param jp - file path
758
	 * @param jp -
759
	 *            file path
760
	 * @return displayName - name of the file.
789
	 * @return displayName - name of the file.
761
	 */
790
	 */
762
	public static String formatPath(String jp)
791
	public static String formatPath(String jp)
Lines 764-770 Link Here
764
		jp = jp.trim();
793
		jp = jp.trim();
765
		jp = jp.replace('\\', '/');
794
		jp = jp.replace('\\', '/');
766
		int idx = jp.trim().lastIndexOf('/');
795
		int idx = jp.trim().lastIndexOf('/');
767
		if (idx == -1)
796
		if(idx == -1)
768
		{
797
		{
769
			return jp;
798
			return jp;
770
		}
799
		}
Lines 775-788 Link Here
775
	}
804
	}
776
805
777
	/**
806
	/**
778
	 * Create and return a new instance of given ResourceTypeType. Only
807
	 * Create and return a new instance of given ResourceTypeType.
779
	 * ContextPath, JavaIdFactoryClass, JavaResourceClass and WsdlType fields
808
	 * Only ContextPath, JavaIdFactoryClass, JavaResourceClass and WsdlType fields have been copied.
780
	 * have been copied.
781
	 */
809
	 */
782
	public static ResourceTypeType cloneResourceType(ResourceTypeType rt)
810
	public static ResourceTypeType cloneResourceType(ResourceTypeType rt)
783
	{
811
	{
784
		ResourceTypeType clone = DescriptorFactory.eINSTANCE
812
		ResourceTypeType clone = DescriptorFactory.eINSTANCE.createResourceTypeType();
785
				.createResourceTypeType();
786
		clone.setContextPath(rt.getContextPath());
813
		clone.setContextPath(rt.getContextPath());
787
		clone.setJavaIdFactoryClass(rt.getJavaIdFactoryClass());
814
		clone.setJavaIdFactoryClass(rt.getJavaIdFactoryClass());
788
		clone.setJavaResourceClass(rt.getJavaResourceClass());
815
		clone.setJavaResourceClass(rt.getJavaResourceClass());
Lines 792-935 Link Here
792
		clone.setWsdl(wClone);
819
		clone.setWsdl(wClone);
793
		return clone;
820
		return clone;
794
	}
821
	}
795
822
	
796
	/**
823
	/**
797
	 * Returns the initial instances provided for given ResourceTypeType.
824
	 * Returns the initial instances provided for given ResourceTypeType.
798
	 */
825
	 */
799
	public static InitialInstancesType[] getInitialInstances(RootType root,
826
	public static InitialInstancesType[] getInitialInstances(RootType root, ResourceTypeType resourceType)
800
			ResourceTypeType resourceType)
801
	{
827
	{
802
		List mrtInitInstances = new ArrayList();
828
	    List mrtInitInstances = new ArrayList();
803
		List allInitInstances = root.getInitialInstances();
829
	    List allInitInstances =  root.getInitialInstances();
804
		for (int i = 0; i < allInitInstances.size(); i++)
830
	    for(int i=0;i<allInitInstances.size();i++)
805
		{
831
	    {
806
			InitialInstancesType initInstance = (InitialInstancesType) allInitInstances
832
		InitialInstancesType initInstance = (InitialInstancesType) allInitInstances.get(i);
807
					.get(i);
833
		ResourceTypeType rt = initInstance.getResourceType();
808
			ResourceTypeType rt = initInstance.getResourceType();
834
		if(rt.getContextPath().equals(resourceType.getContextPath()) 
809
			if (rt.getContextPath().equals(resourceType.getContextPath())
835
			&& rt.getWsdl().getWsdlFile().equals(resourceType.getWsdl().getWsdlFile()))			
810
					&& rt.getWsdl().getWsdlFile().equals(
836
		    mrtInitInstances.add(initInstance);
811
							resourceType.getWsdl().getWsdlFile()))
837
	    }
812
				mrtInitInstances.add(initInstance);
838
	    return (InitialInstancesType[])mrtInitInstances.toArray(new InitialInstancesType[mrtInitInstances.size()]);
813
		}
839
	}
814
		return (InitialInstancesType[]) mrtInitInstances
840
	
815
				.toArray(new InitialInstancesType[mrtInitInstances.size()]);
841
	/**
816
	}
842
	 * Checks whether the given mrt file is already added to the deployment descriptor.
817
843
	 * @param mrtFileName - name of the file 
818
	/**
844
	 * @param editor - DescriptorEditor instance
819
	 * Checks whether the given mrt file is already added to the deployment
820
	 * descriptor.
821
	 * 
822
	 * @param mrtFileName -
823
	 *            name of the file
824
	 * @param editor -
825
	 *            DescriptorEditor instance
826
	 * @return true if already added, else false.
845
	 * @return true if already added, else false.
827
	 */
846
	 */
828
	public static boolean presentInTheList(String mrtFileName,
847
	public static boolean presentInTheList(String mrtFileName, DescriptorEditor editor)
829
			DescriptorEditor editor)
830
	{
848
	{
831
		if (mrtFileName == null || mrtFileName.trim().length() == 0)
849
		if(mrtFileName == null || mrtFileName.trim().length() == 0)
832
		{
850
		{
833
			return true;
851
			return true;
834
		}
852
		}
835
		org.eclipse.swt.widgets.List lst = editor.getLstAddedMrts();
853
		org.eclipse.swt.widgets.List lst = editor.getLstAddedMrts();
836
		String items[] = lst.getItems();
854
		String items[] = lst.getItems();
837
		if (items == null || items.length == 0)
855
		if(items == null || items.length == 0)
838
		{
856
		{
839
			return false;
857
			return false;
840
		}
858
		}
841
		for (int i = 0; i < items.length; i++)
859
		for(int i = 0; i < items.length; i++)
842
		{
860
		{
843
			if (items[i].equals(mrtFileName))
861
			if(items[i].equals(mrtFileName))
844
			{
862
			{
845
				return true;
863
				return true;
846
			}
864
			}
847
		}
865
		}
848
		return false;
866
		return false;
849
	}
867
	}
850
868
	
851
	/**
869
	/**
852
	 * Returns all the CustomSerializerType available in given
870
	 * Returns all the capabilities available in given ManageableResourceType.
853
	 * ManageableResourceType.
854
	 */
871
	 */
855
	public static CustomSerializerType[] getCustomSerializerType(
872
	public static Capability[] getAllCapabilities(ManageableResourceType mrt) throws IOException, CoreException
856
			ManageableResourceType mrt) throws IOException, CoreException
857
	{
873
	{
858
		List serializerTypes = new ArrayList();
874
	    Capability[] caps = null;
859
		Capability[] capability = new Capability[0];
875
		try {
860
		try
876
			caps = MrtUtils.getCapabilities(mrt);
861
		{
877
		}  catch (Exception e) {
862
			capability = MrtUtils.getCapabilities(mrt);
878
    		WsdmToolingLog.logError(
863
		}
879
    				org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages.MRT_ERROR_CANNOT_TRACE_CAPS, e);
864
		catch (Exception e)
865
		{
866
		}
880
		}
867
		for (int capIndex = 0; capIndex < capability.length; capIndex++)
881
	    if(caps != null)
882
	    	return caps;
883
	    return new Capability[0];
884
	}
885
	
886
	/**
887
	 * Returns all the CustomSerializerType available in given ManageableResourceType.
888
	 */
889
	public static CustomSerializerType[] getCustomSerializerType(ManageableResourceType mrt) throws IOException, CoreException
890
	{
891
	    List serializerTypes = new ArrayList();
892
	    Capability[] capability = getAllCapabilities(mrt);
893
	    for(int capIndex=0; capIndex<capability.length; capIndex++)
894
	    {
895
		List props = capability[capIndex].getProperties();
896
		for(int propIndex=0; propIndex<props.size(); propIndex++)
868
		{
897
		{
869
			List props = capability[capIndex].getProperties();
898
		    Property property = (Property) props.get(propIndex);
870
			for (int propIndex = 0; propIndex < props.size(); propIndex++)
899
		    XSDElementDeclaration element = property.getElement();
871
			{
900
		    if(element != null)
872
				Property property = (Property) props.get(propIndex);
901
		    {
873
				XSDElementDeclaration element = property.getElement();
902
			CustomSerializerType serializer = getCustomSerializerType(element);
874
				if (element != null)
903
			if(serializer != null)
875
				{
904
			    serializerTypes.add(serializer);
876
					CustomSerializerType serializer = getCustomSerializerType(element);
905
		    }
877
					if (serializer != null)
878
						serializerTypes.add(serializer);
879
				}
880
			}
881
		}
906
		}
882
		return (CustomSerializerType[]) serializerTypes
907
	    }
883
				.toArray(new CustomSerializerType[serializerTypes.size()]);
908
	    return (CustomSerializerType[]) serializerTypes.toArray(new CustomSerializerType[serializerTypes.size()]);
884
	}
909
	}
885
910
	
886
	private static CustomSerializerType getCustomSerializerType(
911
	private static CustomSerializerType getCustomSerializerType(XSDElementDeclaration elementDeclaration)
887
			XSDElementDeclaration elementDeclaration)
888
	{
912
	{
889
		XSDTypeDefinition typeDef = elementDeclaration.getTypeDefinition();
913
	    XSDTypeDefinition typeDef = elementDeclaration.getTypeDefinition();
890
		if (typeDef == null)
914
	    if(typeDef == null)
891
			return null;
915
		return null;
892
		if (!(typeDef instanceof XSDComplexTypeDefinition))
916
	    if(!(typeDef instanceof XSDComplexTypeDefinition))
893
			return null;
917
		return null;
894
		XSDComplexTypeDefinition complexTypeDef = (XSDComplexTypeDefinition) typeDef;
918
	    XSDComplexTypeDefinition complexTypeDef = (XSDComplexTypeDefinition) typeDef;
895
		CustomSerializerType serializer = DescriptorFactory.eINSTANCE
919
	    CustomSerializerType serializer = DescriptorFactory.eINSTANCE.createCustomSerializerType();
896
				.createCustomSerializerType();
920
	    String ns = complexTypeDef.getTargetNamespace();
897
		String ns = complexTypeDef.getTargetNamespace();
921
	    String name = complexTypeDef.getName();
898
		String name = complexTypeDef.getName();
922
	    if(name == null)
899
		if (name == null)
923
	    	name = "";
900
			name = "";
924
	    serializer.setJavaSerializableType("{"+ns+"}"+name);
901
		serializer.setJavaSerializableType("{" + ns + "}" + name);
925
	    serializer.setJavaSerializerClass("");
902
		serializer.setJavaSerializerClass("");
926
	    return serializer;
903
		return serializer;
904
	}
927
	}
905
928
	
906
	/**
929
	/**
907
	 * Loads the CustomSerializerType obtained from given MRT to the MuseType.
930
	 * Loads the CustomSerializerType obtained from given MRT to the MuseType.
908
	 */
931
	 */
909
	public static void loadCustomSerializerTypeData(ManageableResourceType mrt,
932
	public static void loadCustomSerializerTypeData(ManageableResourceType mrt, MuseType muse) throws IOException, CoreException
910
			MuseType muse) throws IOException, CoreException
911
	{
933
	{
912
		CustomSerializerType[] serializers = getCustomSerializerType(mrt);
934
	    CustomSerializerType[] serializers = getCustomSerializerType(mrt);
913
		List ddSerializers = muse.getCustomSerializer();
935
	    List ddSerializers = muse.getCustomSerializer();
914
		for (int serializersIndex = 0; serializersIndex < serializers.length; serializersIndex++)
936
	    for(int serializersIndex=0; serializersIndex<serializers.length; serializersIndex++)
915
		{
937
	    {
916
			boolean found = false;
938
			boolean found = false;
917
			for (int ddSerializersIndex = 0; ddSerializersIndex < ddSerializers
939
			for(int ddSerializersIndex=0; ddSerializersIndex<ddSerializers.size(); ddSerializersIndex++)
918
					.size(); ddSerializersIndex++)
940
			{ 
919
			{
941
			    CustomSerializerType ddSerializer = (CustomSerializerType) ddSerializers.get(ddSerializersIndex);
920
				CustomSerializerType ddSerializer = (CustomSerializerType) ddSerializers
942
			    if(ddSerializer.getJavaSerializableType().equals(serializers[serializersIndex].getJavaSerializableType()))
921
						.get(ddSerializersIndex);
943
			    {
922
				if (ddSerializer.getJavaSerializableType()
923
						.equals(
924
								serializers[serializersIndex]
925
										.getJavaSerializableType()))
926
				{
927
					found = true;
944
					found = true;
928
					break;
945
					break;
929
				}
946
			    }
930
			}
947
			}
931
			if (!found)
948
			if(!found)
932
				muse.getCustomSerializer().add(serializers[serializersIndex]);
949
			    muse.getCustomSerializer().add(serializers[serializersIndex]);
933
		}
950
	    }	    
934
	}
951
	}
935
}
952
}
(-)plugin.xml (+9 lines)
Lines 155-160 Link Here
155
   </extension>
155
   </extension>
156
   
156
   
157
   <extension
157
   <extension
158
         point="org.eclipse.ui.preferencePages">
159
      <page
160
            class="org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.MRTPreferencePage"
161
            id="org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.MRTPreferencePage"
162
            name="MRT Preferences Page">
163
         MRT Preferences Page
164
      </page>
165
   </extension>
166
   <extension
158
         point="org.eclipse.ui.startup">
167
         point="org.eclipse.ui.startup">
159
      <startup
168
      <startup
160
            class="org.eclipse.tptp.wsdm.tooling.editor.internal.StartupCapabilitiesCollector"></startup>
169
            class="org.eclipse.tptp.wsdm.tooling.editor.internal.StartupCapabilitiesCollector"></startup>
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/MRTPreferencePage.java (+122 lines)
Added Link Here
1
package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal;
2
3
import org.eclipse.jface.preference.IPreferenceStore;
4
import org.eclipse.jface.preference.PreferencePage;
5
import org.eclipse.jface.resource.ImageDescriptor;
6
import org.eclipse.osgi.util.TextProcessor;
7
import org.eclipse.swt.SWT;
8
import org.eclipse.swt.events.SelectionAdapter;
9
import org.eclipse.swt.events.SelectionEvent;
10
import org.eclipse.swt.layout.GridData;
11
import org.eclipse.swt.layout.GridLayout;
12
import org.eclipse.swt.widgets.Button;
13
import org.eclipse.swt.widgets.Composite;
14
import org.eclipse.swt.widgets.Control;
15
import org.eclipse.swt.widgets.DirectoryDialog;
16
import org.eclipse.swt.widgets.Label;
17
import org.eclipse.swt.widgets.Text;
18
import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator;
19
import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages;
20
import org.eclipse.ui.IWorkbench;
21
import org.eclipse.ui.IWorkbenchPreferencePage;
22
23
/**
24
 * The class is used to create the Preference page for the MRT Editor.
25
 * It is used to set Axis2 Server Location.
26
 *
27
 */
28
public class MRTPreferencePage extends PreferencePage implements
29
		IWorkbenchPreferencePage {
30
31
	private Text _serverLocation;
32
	
33
	private Button _browseButton;
34
	
35
	/**
36
	 * 
37
	 */
38
	public MRTPreferencePage() {
39
		// TODO Auto-generated constructor stub
40
	}
41
42
	/**
43
	 * 
44
	 * @param title
45
	 */
46
	public MRTPreferencePage(String title) {
47
		super(title);
48
		// TODO Auto-generated constructor stub
49
	}
50
51
	public MRTPreferencePage(String title, ImageDescriptor image) {
52
		super(title, image);
53
		// TODO Auto-generated constructor stub
54
	}
55
56
	@Override
57
	protected Control createContents(Composite parent) {
58
		Composite composite = new Composite(parent, SWT.NONE);
59
		GridLayout layout = new GridLayout();
60
		layout.numColumns = 2;
61
		composite.setLayout(layout);
62
		
63
		GridData data = new GridData();
64
		data.horizontalSpan = 2;
65
		data.grabExcessHorizontalSpace = true;
66
		Label label = new Label(composite, SWT.NONE);
67
		label.setLayoutData(data);
68
		label.setText("Axis2 Server Location");
69
		
70
		IPreferenceStore store = Activator.getPlugin().getPreferenceStore();
71
		String ss = store.getString("MRT_CODE_GEN.AXIS2_SERVER_LOCATION");
72
		data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
73
		//data.horizontalAlignment = SWT.FILL;
74
		data.grabExcessHorizontalSpace = true;
75
		data.horizontalSpan = 1;
76
		data.widthHint = 240;
77
	
78
		_serverLocation = new Text(composite, SWT.BORDER);
79
		_serverLocation.setLayoutData(data);
80
		
81
		//_combo.setItems(WSDMRuntimeFactory.getConreteRuntimes());
82
		String runtime = "";
83
		if (runtime != null || runtime.length() > 0) {
84
			_serverLocation.setText(ss);
85
		} else {
86
			//if (_combo.getItemCount() > 0) {
87
			_serverLocation.setText("");
88
			//}
89
		}
90
		
91
		_browseButton = new Button(composite, SWT.PUSH);
92
		_browseButton.setText(Messages.HOOKUP_WIZARD_TXT5);
93
		_browseButton.addSelectionListener(new SelectionAdapter() {
94
			public void widgetSelected(SelectionEvent event) {
95
				handleLocationBrowseButtonPressed();
96
			}
97
		});		
98
		return composite;
99
	}
100
101
	public void init(IWorkbench workbench) {
102
		// TODO Auto-generated method stub
103
	}
104
	private void handleLocationBrowseButtonPressed() {
105
		String selectedDirectory = null;
106
		DirectoryDialog dialog = new DirectoryDialog(_serverLocation.getShell());
107
		dialog.setMessage(Messages.CODE_GEN_DIR_LOCATION);
108
		selectedDirectory = dialog.open();
109
		
110
		if (selectedDirectory != null)
111
			_serverLocation.setText(TextProcessor.process(selectedDirectory));
112
113
	}
114
	/*	@Override
115
	protected void performDefaults() {
116
		super.performDefaults();
117
		IPreferenceStore store = Activator.getDefault().getPreferenceStore();
118
//		store.setValue("MRT_CODE_GEN.AXIS2_SERVER_LOCATION","");
119
    }
120
*/
121
122
}
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/internal/GenerationProjectPage.java (+148 lines)
Added Link Here
1
/**
2
 * 
3
 */
4
package org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal;
5
6
import org.eclipse.jface.preference.IPreferenceStore;
7
import org.eclipse.jface.wizard.WizardPage;
8
import org.eclipse.osgi.util.TextProcessor;
9
import org.eclipse.swt.SWT;
10
import org.eclipse.swt.events.SelectionAdapter;
11
import org.eclipse.swt.events.SelectionEvent;
12
import org.eclipse.swt.layout.GridData;
13
import org.eclipse.swt.layout.GridLayout;
14
import org.eclipse.swt.widgets.Button;
15
import org.eclipse.swt.widgets.Composite;
16
import org.eclipse.swt.widgets.DirectoryDialog;
17
import org.eclipse.swt.widgets.Label;
18
import org.eclipse.swt.widgets.Text;
19
20
import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator;
21
import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages;
22
23
/**
24
 * This is Wizard Page to show the Axis2 server location details
25
 *
26
 */
27
public class GenerationProjectPage extends WizardPage{
28
	
29
	private Text _serverNameField;
30
	private Button _browseButton;
31
	private Button _preferenceUpdate;
32
33
	/**
34
	 * Instantiates the class.
35
	 */
36
	public GenerationProjectPage() {
37
		super("wizardPage");
38
		setTitle(Messages.HOOKUP_WIZARD_TXT1);
39
		setDescription(Messages.HOOKUP_WIZARD_TXT2);
40
	}
41
42
	public void createControl(Composite parent) {
43
		Composite page = new Composite(parent, SWT.NULL);
44
		GridLayout layout = new GridLayout(1, false);
45
		page.setLayout(layout);
46
		createPageControls(page);
47
//		dialogChanged();
48
		setControl(page);
49
	}
50
51
	private void createPageControls(Composite page) {
52
		Composite column = new Composite(page, SWT.NULL);
53
		GridLayout layout = new GridLayout(2, false);
54
		column.setLayout(layout);
55
		
56
		createServerLocationColumn(column);
57
		
58
	}
59
60
	private void createServerLocationColumn(Composite parent) {
61
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
62
		data.horizontalSpan = 2;
63
        // new server location label
64
        Label serverLabel = new Label(parent, SWT.NONE);
65
        serverLabel.setText(Messages.CODE_GEN_AXIS2_LOCATION);
66
        serverLabel.setFont(parent.getFont());
67
        serverLabel.setLayoutData(data);
68
69
		// server location entry field
70
        data = new GridData(GridData.FILL_HORIZONTAL);
71
        data.widthHint = 350;
72
        data.horizontalSpan = 1;
73
        _serverNameField = new Text(parent, SWT.BORDER);
74
        _serverNameField.setText(getPreferenceServerLocation());
75
        _serverNameField.setLayoutData(data);
76
        _serverNameField.setFont(parent.getFont());
77
         
78
		// browse button
79
		_browseButton = new Button(parent, SWT.PUSH);
80
		_browseButton.setText(Messages.HOOKUP_WIZARD_TXT5);
81
		_browseButton.addSelectionListener(new SelectionAdapter() {
82
			public void widgetSelected(SelectionEvent event) {
83
				handleLocationBrowseButtonPressed();
84
			}
85
		});
86
		
87
		// server location entry field
88
        data = new GridData(GridData.FILL_HORIZONTAL);
89
        //data.widthHint = 350;
90
        data.horizontalSpan = 2;
91
        _preferenceUpdate = new Button(parent, SWT.CHECK);
92
        _preferenceUpdate.setText(Messages.CODE_GEN_UPDATE_PREF);
93
        _preferenceUpdate.setLayoutData(data);
94
        _preferenceUpdate.setFont(parent.getFont());
95
		
96
        _preferenceUpdate.addSelectionListener(new SelectionAdapter(){
97
        	public void widgetSelected(SelectionEvent event){
98
        		if(_preferenceUpdate.getSelection()){
99
        			IPreferenceStore store = Activator.getPlugin().getPreferenceStore();
100
        			store.setValue("MRT_CODE_GEN.AXIS2_SERVER_LOCATION",_serverNameField.getText());
101
        		}else{
102
        			// Do nothing, just leave the preference
103
        		}
104
        	}});
105
		
106
	}
107
	
108
	private String getPreferenceServerLocation() {
109
		IPreferenceStore store = Activator.getPlugin().getPreferenceStore();
110
		String location = store.getString("MRT_CODE_GEN.AXIS2_SERVER_LOCATION").trim();
111
		if(location != null && !location.equals(""))
112
			return location;
113
		return "";
114
	}
115
116
	private void handleLocationBrowseButtonPressed() {
117
118
		String selectedDirectory = null;
119
120
		DirectoryDialog dialog = new DirectoryDialog(_serverNameField.getShell());
121
		dialog.setMessage(Messages.CODE_GEN_DIR_LOCATION);
122
		//dialog.setFilterPath(dirName);
123
		selectedDirectory = dialog.open();
124
		
125
		if (selectedDirectory != null)
126
			updateLocationField(selectedDirectory);
127
128
	}
129
	private void updateLocationField(String selectedPath) {
130
		_serverNameField.setText(TextProcessor.process(selectedPath));
131
	}
132
133
	/**
134
	 * Returns the server location.
135
	 * @return
136
	 */
137
	public String getServerLocation() {
138
		return _serverNameField.getText();
139
	}
140
	
141
	private boolean validateLocation(){
142
		
143
		return false;
144
	}
145
146
147
148
}

Return to bug 150385