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/codegen/mrt/provisional/MRTCodeGenerationDelegate.java (-3 / +6 lines)
Lines 87-97 Link Here
87
	public DescriptorHelper run(SubProgressMonitor progressMonitor)
87
	public DescriptorHelper run(SubProgressMonitor progressMonitor)
88
			throws Exception
88
			throws Exception
89
	{
89
	{
90
		File ddFile = createDDFile();
90
		//File ddFile = createDDFile();
91
		IFile ddFile = createDDFile();
91
		return new DescriptorHelper(ddFile);
92
		return new DescriptorHelper(ddFile);
92
	}
93
	}
93
94
94
	private File createDDFile()
95
//	private File createDDFile()
96
	private IFile createDDFile()
95
	{
97
	{
96
		_ddFilePath = createDDFilePath();
98
		_ddFilePath = createDDFilePath();
97
99
Lines 133-139 Link Here
133
135
134
			IFile file = EclipseUtils.getIFile(ResourcesPlugin.getWorkspace()
136
			IFile file = EclipseUtils.getIFile(ResourcesPlugin.getWorkspace()
135
					.getRoot(), fileURI.toString());
137
					.getRoot(), fileURI.toString());
136
			return file.getLocation().toFile();
138
			//return file.getLocation().toFile();
139
			return file;
137
		}
140
		}
138
		catch (Exception exception)
141
		catch (Exception exception)
139
		{
142
		{
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/GenerationOptionsPage.java (-2 / +35 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;
114
	
113
	/**
115
	/**
114
	 * For cheatsheet purpose only This constructor will be used in cheatsheet
116
	 * For cheatsheet purpose only This constructor will be used in cheatsheet
115
	 * only
117
	 * only
Lines 184-194 Link Here
184
		page.setLayoutData(gd);
186
		page.setLayoutData(gd);
185
187
186
		Label projectizerLabel = new Label(page, SWT.NONE);
188
		Label projectizerLabel = new Label(page, SWT.NONE);
187
		projectizerLabel.setText("Projectizer: ");
189
		projectizerLabel.setText(Messages.CODE_GEN_PROJECTIZER);
188
		_projectizerCombo = makeProjectizerCombo(page);
190
		_projectizerCombo = makeProjectizerCombo(page);
189
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
191
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
190
		data.widthHint = 50;
192
		data.widthHint = 50;
191
		_projectizerCombo.setLayoutData(data);
193
		_projectizerCombo.setLayoutData(data);
194
		_projectizerCombo.addListener(SWT.Modify, comboChangeListener);
192
195
193
		Label blankLabel = new Label(page, SWT.NONE);
196
		Label blankLabel = new Label(page, SWT.NONE);
194
		blankLabel.setText(" ");
197
		blankLabel.setText(" ");
Lines 517-522 Link Here
517
		}
520
		}
518
	};
521
	};
519
522
523
	private Listener comboChangeListener = new Listener() {
524
		public void handleEvent(Event e) {
525
		   	dialogChanged();
526
		}
527
	};
528
	
520
	void setLocationForSelection()
529
	void setLocationForSelection()
521
	{
530
	{
522
		// _locationArea.updateProjectName(getProjectNameFieldValue());
531
		// _locationArea.updateProjectName(getProjectNameFieldValue());
Lines 608-614 Link Here
608
			updateStatus(Messages.HOOKUP_WIZARD_ERROR_2);
617
			updateStatus(Messages.HOOKUP_WIZARD_ERROR_2);
609
			return;
618
			return;
610
		}
619
		}
611
620
		
621
		canFlipToNextPage();
622
		
612
		updateStatus(null, DialogPage.NONE);
623
		updateStatus(null, DialogPage.NONE);
613
	}
624
	}
614
625
Lines 738-743 Link Here
738
		}
749
		}
739
		return baseAddress;
750
		return baseAddress;
740
	}
751
	}
752
	
753
	/**
754
	 * Checks to see if the Next Page can be enabled or not.
755
	 */
756
	public boolean canFlipToNextPage(){
757
		if(isPageComplete() && _projectizerCombo.getText().contains("Axis")){
758
			axis2Project = true;
759
			((GenerationProjectPage)this.getNextPage()).makePageComplete(false);
760
			return true;
761
		}
762
		((GenerationProjectPage)this.getNextPage()).makePageComplete(true);
763
		axis2Project = false;
764
		return false;
765
	}
766
767
	/**
768
	 * Returns whether the new Project to be created is a Axis2 project
769
	 * @return
770
	 */
771
	public boolean isAxis2Project(){
772
		return axis2Project;
773
	}	
741
}
774
}
742
775
743
// Not used currently
776
// Not used currently
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/DescriptorHelper.java (-1 / +58 lines)
Lines 13-28 Link Here
13
package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional;
13
package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional;
14
14
15
import java.io.File;
15
import java.io.File;
16
16
import java.io.IOException;
17
import java.util.Collections;
17
import javax.xml.namespace.QName;
18
import javax.xml.namespace.QName;
18
19
19
import org.apache.muse.core.descriptor.DescriptorConstants;
20
import org.apache.muse.core.descriptor.DescriptorConstants;
20
import org.apache.muse.util.xml.XmlUtils;
21
import org.apache.muse.util.xml.XmlUtils;
22
import org.apache.ws.muse.descriptor.AdditionalJarsType;
23
import org.apache.ws.muse.descriptor.DescriptorPackage;
24
import org.apache.ws.muse.descriptor.DocumentRoot;
25
import org.apache.ws.muse.descriptor.RootType;
21
import org.eclipse.core.resources.IFile;
26
import org.eclipse.core.resources.IFile;
22
import org.eclipse.core.resources.IWorkspace;
27
import org.eclipse.core.resources.IWorkspace;
23
import org.eclipse.core.resources.IWorkspaceRoot;
28
import org.eclipse.core.resources.IWorkspaceRoot;
24
import org.eclipse.core.resources.ResourcesPlugin;
29
import org.eclipse.core.resources.ResourcesPlugin;
25
import org.eclipse.core.runtime.IPath;
30
import org.eclipse.core.runtime.IPath;
31
import org.eclipse.emf.common.util.URI;
32
import org.eclipse.emf.ecore.resource.Resource;
33
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
34
import org.eclipse.tptp.wsdm.tooling.editor.dde.util.internal.DdeUtil;
35
import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages;
36
import org.eclipse.tptp.wsdm.tooling.util.internal.MyDescriptorResourceFactoryImpl;
37
import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog;
26
import org.eclipse.tptp.wsdm.tooling.wizard.mrt.internal.NewMrtWizard;
38
import org.eclipse.tptp.wsdm.tooling.wizard.mrt.internal.NewMrtWizard;
27
import org.w3c.dom.Document;
39
import org.w3c.dom.Document;
28
import org.w3c.dom.Element;
40
import org.w3c.dom.Element;
Lines 87-92 Link Here
87
	 * useless "Pair" class.
99
	 * useless "Pair" class.
88
	 */
100
	 */
89
	private Object[][] _instances;
101
	private Object[][] _instances;
102
	
103
	private IFile ddIFile;
90
104
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
Lines 101-106 Link Here
101
	public DescriptorHelper(IFile descriptorFile) throws Exception
115
	public DescriptorHelper(IFile descriptorFile) throws Exception
102
	{
116
	{
103
		this(new File(descriptorFile.getLocation().toString()));
117
		this(new File(descriptorFile.getLocation().toString()));
118
		ddIFile = descriptorFile;
104
	}
119
	}
105
120
106
	/**
121
	/**
Lines 357-360 Link Here
357
	{
372
	{
358
		return fileName.substring(0, fileName.lastIndexOf(".")) + MRT_EXTN;
373
		return fileName.substring(0, fileName.lastIndexOf(".")) + MRT_EXTN;
359
	}
374
	}
375
	
376
	public void addAdditionalJars(String serverLocation, String[] axis2files) {
377
		DocumentRoot root = DdeUtil.getDocRoot(ddIFile);
378
		RootType rootType = root.getRoot();
379
		AdditionalJarsType additionalJars = rootType.getAdditionalJars();
380
		for(int i = 0 ; i < axis2files.length ; i++ ){
381
			additionalJars.getJarPath().add(serverLocation + File.separator + axis2files[i]);
382
		}
383
		
384
		rootType.setAdditionalJars(additionalJars);
385
		root.setRoot(rootType);
386
		save(root);
387
	}
388
	
389
	private void save(DocumentRoot root)
390
	{
391
		ensureMusePackagePresent();
392
		URI ddFileURI = URI.createPlatformResourceURI(ddIFile.getFullPath().toString());
393
		ResourceSetImpl rsImpl = new ResourceSetImpl();
394
		rsImpl.getResourceFactoryRegistry().getExtensionToFactoryMap()
395
		.put(Resource.Factory.Registry.DEFAULT_EXTENSION,
396
				new MyDescriptorResourceFactoryImpl());
397
		rsImpl.getPackageRegistry().put(DescriptorPackage.eNS_URI,
398
		DescriptorPackage.eINSTANCE);
399
		Resource ddRes = rsImpl.getResource(ddFileURI, true);
400
		ddRes.getContents().remove(0);
401
		ddRes.getContents().add(root);
402
		try {
403
			ddRes.save(Collections.EMPTY_MAP);
404
		} catch (IOException e) {
405
			e.printStackTrace();
406
		}
407
	}
408
	
409
	private void ensureMusePackagePresent()
410
	{
411
		// Ensure EMF knows about Muse descriptor
412
		if (DescriptorPackage.eINSTANCE == null)
413
		{
414
		WsdmToolingLog.logError(Messages.FAILED_TO_INITIALIZE_MUSE_DESCRIPTOR_ERROR_, new Throwable());
415
		}
416
	} 	
360
}
417
}
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/NewProjectWizard.java (-18 / +58 lines)
Lines 30-39 Link Here
30
import org.eclipse.core.runtime.SubProgressMonitor;
30
import org.eclipse.core.runtime.SubProgressMonitor;
31
import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
31
import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry;
32
import org.eclipse.jface.operation.IRunnableWithProgress;
32
import org.eclipse.jface.operation.IRunnableWithProgress;
33
import org.eclipse.jface.preference.IPreferenceStore;
33
import org.eclipse.jface.resource.ImageDescriptor;
34
import org.eclipse.jface.resource.ImageDescriptor;
34
import org.eclipse.jface.viewers.IStructuredSelection;
35
import org.eclipse.jface.viewers.IStructuredSelection;
35
import org.eclipse.jface.wizard.Wizard;
36
import org.eclipse.jface.wizard.Wizard;
36
import org.eclipse.swt.graphics.Image;
37
import org.eclipse.swt.graphics.Image;
38
import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator;
37
import org.eclipse.tptp.wsdm.tooling.editor.mrt.internal.ManageableResourceTypeEditorPlugin;
39
import org.eclipse.tptp.wsdm.tooling.editor.mrt.internal.ManageableResourceTypeEditorPlugin;
38
import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages;
40
import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages;
39
import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils;
41
import org.eclipse.tptp.wsdm.tooling.util.internal.EclipseUtils;
Lines 55-60 Link Here
55
57
56
	private GenerationOptionsPage _generationOptionsPage;
58
	private GenerationOptionsPage _generationOptionsPage;
57
59
60
	private GenerationProjectPage _generationProjectPage;
58
	private String _projectName;
61
	private String _projectName;
59
62
60
	private boolean _overwrite;
63
	private boolean _overwrite;
Lines 73-78 Link Here
73
76
74
	private DescriptorHelper _helper;
77
	private DescriptorHelper _helper;
75
78
79
	private String _serverLocation;
80
	
81
	private boolean _isAxis2Project;
82
	private boolean updatePreference;
83
	
84
	java.net.URI _projectLocation;
85
	
86
	/**
87
	 * Class that creates the Code Generation Wizard to create new Project
88
	 * @param codeGenerationDelegate
89
	 */
76
	public NewProjectWizard(CodeGenerationDelegate codeGenerationDelegate)
90
	public NewProjectWizard(CodeGenerationDelegate codeGenerationDelegate)
77
	{
91
	{
78
		setWindowTitle(Messages.HOOKUP_WIZARD_TXT7);
92
		setWindowTitle(Messages.HOOKUP_WIZARD_TXT7);
Lines 85-90 Link Here
85
	{
99
	{
86
		_generationOptionsPage = new GenerationOptionsPage();
100
		_generationOptionsPage = new GenerationOptionsPage();
87
		addPage(_generationOptionsPage);
101
		addPage(_generationOptionsPage);
102
		
103
		_generationProjectPage = new GenerationProjectPage();
104
		addPage(_generationProjectPage);
88
105
89
		// TODO AME why is this hardcoded here? why is it getting reloaded?
106
		// TODO AME why is this hardcoded here? why is it getting reloaded?
90
		Image imgTP = EclipseUtils.loadImage(PlatformUI.getWorkbench()
107
		Image imgTP = EclipseUtils.loadImage(PlatformUI.getWorkbench()
Lines 99-112 Link Here
99
	{
116
	{
100
		try
117
		try
101
		{
118
		{
102
			monitor.beginTask("Working: ", 6);
119
			monitor.beginTask(Messages.CODE_GEN_START, 6);
103
120
					
121
			if(_isAxis2Project){
122
				try{
123
					// Step 1: Validate the server path
124
					monitor.subTask(Messages.CODE_GEN_VALIDATE_SLOCATION);
125
					// Step 2 : Update the Preferences, if needed
126
					if(updatePreference){
127
		        		IPreferenceStore store = Activator.getPlugin().getPreferenceStore();
128
		        		store.setValue("MRT_CODE_GEN.AXIS2_SERVER_LOCATION",_serverLocation);	
129
					}
130
				}catch(Exception e){
131
					throw new RuntimeException(e);
132
				}
133
			}
104
			try
134
			try
105
			{
135
			{
106
				// TODO AME externalize string
136
				monitor.subTask(Messages.CODE_GEN_STEP1);
107
				monitor.subTask("Initializing Code Generation");
108
				_helper = _codeGenerationDelegate.run(new SubProgressMonitor(
137
				_helper = _codeGenerationDelegate.run(new SubProgressMonitor(
109
						monitor, 1));
138
						monitor, 1));
139
				// Step 3 : Copy the axis2 files for CodeGeneration
140
				String[] axis2files = _generationProjectPage.getAxis2Files();
141
				if(_isAxis2Project){
142
					_helper.addAdditionalJars(_serverLocation, axis2files);
143
				}
110
				monitor.worked(1);
144
				monitor.worked(1);
111
			}
145
			}
112
			catch (Exception e)
146
			catch (Exception e)
Lines 119-126 Link Here
119
153
120
			try
154
			try
121
			{
155
			{
122
				// TODO AME externalize string
156
				monitor.subTask(Messages.CODE_GEN_STEP2);
123
				monitor.subTask("Merging WSDL");
124
				_mergedWsdlDocuments = _helper.getWsdlDocuments(_baseAddress);
157
				_mergedWsdlDocuments = _helper.getWsdlDocuments(_baseAddress);
125
				monitor.worked(1);
158
				monitor.worked(1);
126
			}
159
			}
Lines 131-145 Link Here
131
164
132
			try
165
			try
133
			{
166
			{
134
				// TODO AME externalize string
167
				monitor.subTask(Messages.CODE_GEN_STEP3);
135
				monitor.subTask("Creating project");
136
				runProjectizer(monitor);
168
				runProjectizer(monitor);
137
				monitor.worked(1);
169
				monitor.worked(1);
138
			}
170
			}
139
			catch (Exception e)
171
			catch (Exception e)
140
			{
172
			{
141
				throw new InvocationTargetException(new Exception(
173
				throw new InvocationTargetException(new Exception(
142
						"Code generation failed, see Error Log", e));
174
						Messages.CODE_GEN_FAILED_ERROR, e));
143
			}
175
			}
144
		}
176
		}
145
		finally
177
		finally
Lines 161-167 Link Here
161
		_overwrite = _generationOptionsPage.isOverwrite();
193
		_overwrite = _generationOptionsPage.isOverwrite();
162
		_projectName = _generationOptionsPage.getProjectName();
194
		_projectName = _generationOptionsPage.getProjectName();
163
		_baseAddress = _generationOptionsPage.getBaseAddress();
195
		_baseAddress = _generationOptionsPage.getBaseAddress();
164
196
		_isAxis2Project = _generationOptionsPage.isAxis2Project();
197
		
198
		_projectLocation = _generationOptionsPage.getProjectLocationURI();
199
			
200
		if(_isAxis2Project){
201
			_serverLocation = _generationProjectPage.getServerLocation();
202
			updatePreference = _generationProjectPage.isUpdatePreference();
203
		}
165
		IRunnableWithProgress runnable = new IRunnableWithProgress()
204
		IRunnableWithProgress runnable = new IRunnableWithProgress()
166
		{
205
		{
167
			public void run(IProgressMonitor monitor)
206
			public void run(IProgressMonitor monitor)
Lines 178-191 Link Here
178
		}
217
		}
179
		catch (Exception e)
218
		catch (Exception e)
180
		{
219
		{
181
			// TODO AME externalize string
182
			e.printStackTrace();
220
			e.printStackTrace();
183
			handle("Code generation failed, see Error Log", e);
221
			handle(Messages.CODE_GEN_FAILED_ERROR, e);
184
		}
222
		}
185
223
186
		return false;
224
		return false;
187
	}
225
	}
188
226
227
	
189
	/*
228
	/*
190
	 * (non-Javadoc)
229
	 * (non-Javadoc)
191
	 * 
230
	 * 
Lines 234-255 Link Here
234
273
235
		data.addParameter(EclipseConfigurationData.PROGRESS_MONITOR,
274
		data.addParameter(EclipseConfigurationData.PROGRESS_MONITOR,
236
				new SubProgressMonitor(monitor, 1));
275
				new SubProgressMonitor(monitor, 1));
237
		// TODO AME externalize string
276
		
238
		monitor.subTask("Running Analyzer");
277
		monitor.subTask(Messages.CODE_GEN_SUBTASK1);
239
		data = _analyzer.analyze(data);
278
		data = _analyzer.analyze(data);
240
		monitor.worked(1);
279
		monitor.worked(1);
241
280
242
		data.addParameter(EclipseConfigurationData.PROGRESS_MONITOR,
281
		data.addParameter(EclipseConfigurationData.PROGRESS_MONITOR,
243
				new SubProgressMonitor(monitor, 1));
282
				new SubProgressMonitor(monitor, 1));
244
		// TODO AME externalize string
283
		
245
		monitor.subTask("Running Synthesizer");
284
		monitor.subTask(Messages.CODE_GEN_SUBTASK2);
246
		data = _synthesizer.synthesize(data);
285
		data = _synthesizer.synthesize(data);
247
		monitor.worked(1);
286
		monitor.worked(1);
248
287
249
		data.addParameter(EclipseConfigurationData.PROGRESS_MONITOR,
288
		data.addParameter(EclipseConfigurationData.PROGRESS_MONITOR,
250
				new SubProgressMonitor(monitor, 1));
289
				new SubProgressMonitor(monitor, 1));
251
		// TODO AME externalize string
290
		
252
		monitor.subTask("Running Projectizer");
291
		monitor.subTask(Messages.CODE_GEN_SUBTASK3);
253
		_projectizer.projectize(data);
292
		_projectizer.projectize(data);
254
		monitor.worked(1);
293
		monitor.worked(1);
255
	}
294
	}
Lines 272-275 Link Here
272
		}
311
		}
273
		LOG.log(status);
312
		LOG.log(status);
274
	}
313
	}
314
275
}
315
}
(-)src/org/eclipse/tptp/wsdm/tooling/nls/messages/mrt/internal/Messages.java (-2 / +19 lines)
Lines 125-132 Link Here
125
	public static String CODE_GEN_DIR_LOCATION;
125
	public static String CODE_GEN_DIR_LOCATION;
126
	public static String MRT_CODE_GEN;
126
	public static String MRT_CODE_GEN;
127
	public static String MRT_CODE_GEN_TEXT;
127
	public static String MRT_CODE_GEN_TEXT;
128
128
	public static String CODE_GEN_AXIS2_LOCATION;
129
129
	public static String CODE_GEN_UPDATE_PREF;
130
	public static String CODE_GEN_START;
131
	public static String CODE_GEN_STEP1;
132
	public static String CODE_GEN_STEP2;
133
	public static String CODE_GEN_STEP3;
134
	public static String CODE_GEN_FAILED_ERROR;
135
	public static String CODE_GEN_SUBTASK1;
136
	public static String CODE_GEN_SUBTASK2;
137
	public static String CODE_GEN_SUBTASK3;
138
	public static String CODE_GEN_PROJECTIZER;
139
	public static String CODE_GEN_ERROR_AXIS2;
140
	public static String FAILED_TO_INITIALIZE_MUSE_DESCRIPTOR_ERROR_;
141
	public static String CODE_GEN_VALIDATE_SLOCATION;
142
	public static String CODEGEN_PREF_SERVERLOC;
143
	public static String CODE_GEN_AXIS2_PROJECT_DIR;
144
	public static String CODE_GEN_AXIS2_LOCATION_ERROR;
145
	public static String CODE_GEN_AXIS2_INSTAL_LOC_ERROR;
146
	
130
	static
147
	static
131
	{
148
	{
132
		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
149
		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
(-)src/org/eclipse/tptp/wsdm/tooling/nls/messages/mrt/internal/messages.properties (-2 / +18 lines)
Lines 120-124 Link Here
120
CODE_GEN_DIR_LOCATION = Select the location directory.
120
CODE_GEN_DIR_LOCATION = Select the location directory.
121
MRT_CODE_GEN = Code Generation
121
MRT_CODE_GEN = Code Generation
122
MRT_CODE_GEN_TEXT = You can generate code after the creation of the MRT
122
MRT_CODE_GEN_TEXT = You can generate code after the creation of the MRT
123
123
CODE_GEN_AXIS2_LOCATION = Axis2 Server Installation Location
124
124
CODE_GEN_UPDATE_PREF = Update Preferences
125
CODE_GEN_START = Working: 
126
CODE_GEN_STEP1 = Initializing Code Generation
127
CODE_GEN_STEP2 = Merging WSDL
128
CODE_GEN_STEP3 = Creating project
129
CODE_GEN_FAILED_ERROR = Code generation failed, see Error Log
130
CODE_GEN_SUBTASK1 = Running Analyzer
131
CODE_GEN_SUBTASK2 = Running Synthesizer
132
CODE_GEN_SUBTASK3 = Running Projectizer
133
CODE_GEN_PROJECTIZER = Projectizer: 
134
CODE_GEN_ERROR_AXIS2 = Invalid Axis2 Server Location
135
FAILED_TO_INITIALIZE_MUSE_DESCRIPTOR_ERROR_ = IWAT0682E Failed to initialize muse descriptor
136
CODE_GEN_VALIDATE_SLOCATION = Validating the Server Location 
137
CODEGEN_PREF_SERVERLOC = Axis2 Server Loaction
138
CODE_GEN_AXIS2_PROJECT_DIR = Axis2 Server directory must be specified
139
CODE_GEN_AXIS2_LOCATION_ERROR = Invalid Axis2 Server location path
140
CODE_GEN_AXIS2_INSTAL_LOC_ERROR = Invalid Axis2 Server Installation Path
(-)plugin.xml (+10 lines)
Lines 167-172 Link Here
167
     </objectContribution>
167
     </objectContribution>
168
   </extension>
168
   </extension>
169
   
169
   
170
    <extension
171
      point="org.eclipse.ui.preferencePages">
172
      <page
173
            class="org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.MRTPreferencePage"
174
            id="org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional.MRTPreferencePage"
175
            name="MRT Preferences Page">
176
         MRT Preferences Page
177
      </page>
178
   </extension> 
179
  
170
   <extension
180
   <extension
171
         point="org.eclipse.ui.startup">
181
         point="org.eclipse.ui.startup">
172
      <startup
182
      <startup
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/MRTPreferencePage.java (+139 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 *******************************************************************************/
9
10
package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional;
11
12
import org.eclipse.jface.preference.IPreferenceStore;
13
import org.eclipse.jface.preference.PreferencePage;
14
import org.eclipse.jface.resource.ImageDescriptor;
15
import org.eclipse.osgi.util.TextProcessor;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.events.SelectionAdapter;
18
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.layout.GridData;
20
import org.eclipse.swt.layout.GridLayout;
21
import org.eclipse.swt.widgets.Button;
22
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Control;
24
import org.eclipse.swt.widgets.DirectoryDialog;
25
import org.eclipse.swt.widgets.Label;
26
import org.eclipse.swt.widgets.Text;
27
import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator;
28
import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages;
29
import org.eclipse.ui.IWorkbench;
30
import org.eclipse.ui.IWorkbenchPreferencePage;
31
32
/**
33
 * The class is used to create the Preference page for the MRT Editor.
34
 * It is used to set Axis2 Server Location.
35
 *
36
 */
37
public class MRTPreferencePage extends PreferencePage implements
38
		IWorkbenchPreferencePage {
39
40
	private Text _serverLocation;
41
	
42
	private Button _browseButton;
43
	
44
	/**
45
	 * 
46
	 */
47
	public MRTPreferencePage() {
48
		// TODO Auto-generated constructor stub
49
		init();
50
	}
51
52
	/**
53
	 * 
54
	 * @param title
55
	 */
56
	public MRTPreferencePage(String title) {
57
		super(title);
58
		// TODO Auto-generated constructor stub
59
		init();
60
	}
61
62
	public MRTPreferencePage(String title, ImageDescriptor image) {
63
		super(title, image);
64
		// TODO Auto-generated constructor stub
65
		init();
66
	}
67
68
	protected Control createContents(Composite parent) {
69
		Composite composite = new Composite(parent, SWT.NONE);
70
		GridLayout layout = new GridLayout();
71
		layout.numColumns = 2;
72
		composite.setLayout(layout);
73
		
74
		GridData data = new GridData();
75
		data.horizontalSpan = 2;
76
		data.grabExcessHorizontalSpace = true;
77
		Label label = new Label(composite, SWT.NONE);
78
		label.setLayoutData(data);
79
		String labelText = "Axis2 Server Loaction";//Messages.CODEGEN_PREF_SERVERLOC;
80
		label.setText(labelText);
81
		
82
		IPreferenceStore store = Activator.getPlugin().getPreferenceStore();
83
		String ss = store.getString("MRT_CODE_GEN.AXIS2_SERVER_LOCATION");
84
		data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
85
		data.grabExcessHorizontalSpace = true;
86
		data.horizontalSpan = 1;
87
		data.widthHint = 240;
88
	
89
		_serverLocation = new Text(composite, SWT.BORDER);
90
		_serverLocation.setLayoutData(data);
91
		
92
		String runtime = "";
93
		if (runtime != null || runtime.length() > 0) {
94
			_serverLocation.setText(ss);
95
		} else {
96
			_serverLocation.setText("");
97
		}
98
		
99
		_browseButton = new Button(composite, SWT.PUSH);
100
		_browseButton.setText(Messages.HOOKUP_WIZARD_TXT5);
101
		_browseButton.addSelectionListener(new SelectionAdapter() {
102
			public void widgetSelected(SelectionEvent event) {
103
				handleLocationBrowseButtonPressed();
104
			}
105
		});		
106
		return composite;
107
	}
108
109
	public void init(IWorkbench workbench) {
110
		// TODO Auto-generated method stub
111
	}
112
	private void handleLocationBrowseButtonPressed() {
113
		String selectedDirectory = null;
114
		DirectoryDialog dialog = new DirectoryDialog(_serverLocation.getShell());
115
		dialog.setMessage(Messages.CODE_GEN_DIR_LOCATION);
116
		selectedDirectory = dialog.open();
117
		
118
		if (selectedDirectory != null)
119
			_serverLocation.setText(TextProcessor.process(selectedDirectory));
120
121
	}
122
		
123
	protected void performDefaults() {
124
		super.performDefaults();
125
		IPreferenceStore store = Activator.getPlugin().getPreferenceStore();
126
		String defaultValue = store.getDefaultString("MRT_CODE_GEN.AXIS2_SERVER_LOCATION");
127
		_serverLocation.setText(defaultValue);
128
    }
129
130
	protected void performApply(){
131
		IPreferenceStore store = Activator.getPlugin().getPreferenceStore();
132
		store.setValue("MRT_CODE_GEN.AXIS2_SERVER_LOCATION",_serverLocation.getText());
133
	}
134
135
	private void init(){
136
		IPreferenceStore store = Activator.getPlugin().getPreferenceStore();
137
		store.setDefault("MRT_CODE_GEN.AXIS2_SERVER_LOCATION","");
138
	}
139
}
(-)src/org/eclipse/tptp/wsdm/tooling/codegen/mrt/provisional/GenerationProjectPage.java (+219 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *******************************************************************************/
8
9
package org.eclipse.tptp.wsdm.tooling.codegen.mrt.provisional;
10
11
import java.io.File;
12
import org.eclipse.jface.preference.IPreferenceStore;
13
import org.eclipse.jface.wizard.WizardPage;
14
import org.eclipse.osgi.util.TextProcessor;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.events.ModifyEvent;
17
import org.eclipse.swt.events.ModifyListener;
18
import org.eclipse.swt.events.SelectionAdapter;
19
import org.eclipse.swt.events.SelectionEvent;
20
import org.eclipse.swt.layout.GridData;
21
import org.eclipse.swt.layout.GridLayout;
22
import org.eclipse.swt.widgets.Button;
23
import org.eclipse.swt.widgets.Composite;
24
import org.eclipse.swt.widgets.DirectoryDialog;
25
import org.eclipse.swt.widgets.Label;
26
import org.eclipse.swt.widgets.Text;
27
28
import org.eclipse.tptp.wsdm.tooling.editor.internal.Activator;
29
import org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages;
30
31
/**
32
 * This is Wizard Page to show the Axis2 server location details
33
 *
34
 */
35
public class GenerationProjectPage extends WizardPage{
36
	
37
	private Text _serverNameField;
38
	private Button _browseButton;
39
	private Button _preferenceUpdate;
40
	private final String[] axis2files = {"lib/axis2-adb-1.1.1.jar",
41
			"lib/axis2-codegen-1.1.1.jar","lib/axis2-java2wsdl-1.1.1.jar"};
42
43
	/**
44
	 * Instantiates the class.
45
	 */
46
	public GenerationProjectPage() {
47
		super("wizardPage");
48
		setTitle(Messages.HOOKUP_WIZARD_TXT1);
49
		setDescription(Messages.HOOKUP_WIZARD_TXT2);
50
	}
51
52
	/**
53
	 *  Creates wizard controls.
54
	 */
55
	public void createControl(Composite parent) {
56
		Composite page = new Composite(parent, SWT.NULL);
57
		GridLayout layout = new GridLayout(1, false);
58
		page.setLayout(layout);
59
		createPageControls(page);
60
//		dialogChanged();
61
		setControl(page);
62
	}
63
64
	private void createPageControls(Composite page) {
65
		Composite column = new Composite(page, SWT.NULL);
66
		GridLayout layout = new GridLayout(2, false);
67
		column.setLayout(layout);
68
		createServerLocationColumn(column);
69
	}
70
71
	private void createServerLocationColumn(Composite parent) {
72
		GridData data = new GridData(GridData.FILL_HORIZONTAL);
73
		data.horizontalSpan = 2;
74
        // new server location label
75
        Label serverLabel = new Label(parent, SWT.NONE);
76
        serverLabel.setText(Messages.CODE_GEN_AXIS2_LOCATION);
77
        serverLabel.setFont(parent.getFont());
78
        serverLabel.setLayoutData(data);
79
80
		// server location entry field
81
        data = new GridData(GridData.FILL_HORIZONTAL);
82
        data.widthHint = 350;
83
        data.horizontalSpan = 1;
84
        _serverNameField = new Text(parent, SWT.BORDER);
85
        _serverNameField.setLayoutData(data);
86
        _serverNameField.setFont(parent.getFont());
87
        _serverNameField.addModifyListener(new ModifyListener()
88
		{
89
			public void modifyText(ModifyEvent e)
90
			{
91
				boolean pageCompleted = true;
92
				String errorMsg = validateLocation(); 
93
				if(errorMsg == null){
94
					setErrorMessage(errorMsg);
95
					pageCompleted = true;
96
				}else{
97
					setErrorMessage(errorMsg);
98
					pageCompleted = false;
99
				}
100
				makePageComplete(pageCompleted);
101
102
			}
103
		});
104
        
105
        _serverNameField.setText(getPreferenceServerLocation());
106
107
        // browse button
108
		_browseButton = new Button(parent, SWT.PUSH);
109
		_browseButton.setText(Messages.HOOKUP_WIZARD_TXT5);
110
		_browseButton.addSelectionListener(new SelectionAdapter() {
111
			public void widgetSelected(SelectionEvent event) {
112
				handleLocationBrowseButtonPressed();
113
			}
114
		});
115
		
116
		// server location entry field
117
        data = new GridData(GridData.FILL_HORIZONTAL);
118
        //data.widthHint = 350;
119
        data.horizontalSpan = 2;
120
        _preferenceUpdate = new Button(parent, SWT.CHECK);
121
        _preferenceUpdate.setText(Messages.CODE_GEN_UPDATE_PREF);
122
        _preferenceUpdate.setLayoutData(data);
123
        _preferenceUpdate.setFont(parent.getFont());		
124
	}
125
	
126
	private String getPreferenceServerLocation() {
127
		IPreferenceStore store = Activator.getPlugin().getPreferenceStore();
128
		String location = store.getString("MRT_CODE_GEN.AXIS2_SERVER_LOCATION").trim();
129
		if(location != null && !location.equals(""))
130
			return location;
131
		return "";
132
	}
133
134
	private void handleLocationBrowseButtonPressed() {
135
136
		String selectedDirectory = null;
137
138
		DirectoryDialog dialog = new DirectoryDialog(_serverNameField.getShell());
139
		dialog.setMessage(Messages.CODE_GEN_DIR_LOCATION);
140
		//dialog.setFilterPath(dirName);
141
		selectedDirectory = dialog.open();
142
		
143
		if (selectedDirectory != null)
144
			updateLocationField(selectedDirectory);
145
146
	}
147
	private void updateLocationField(String selectedPath) {
148
		_serverNameField.setText(TextProcessor.process(selectedPath));
149
	}
150
151
	/**
152
	 * Returns the server location.
153
	 * @return
154
	 */
155
	public String getServerLocation() {
156
		return _serverNameField.getText();
157
	}
158
159
	/**
160
	 * Checks to see if Update Preferences checkbox is selected
161
	 * @return
162
	 */
163
	public boolean isUpdatePreference(){
164
		return _preferenceUpdate.getSelection();
165
	}
166
	
167
	private String validateLocation(){
168
		String locationFieldContents = _serverNameField.getText();
169
		if (locationFieldContents.length() == 0)
170
		{
171
			return(Messages.CODE_GEN_AXIS2_PROJECT_DIR);
172
		}
173
174
		java.io.File newPath = new java.io.File(_serverNameField.getText());
175
		if (!newPath.exists())
176
		{
177
			return(Messages.CODE_GEN_AXIS2_LOCATION_ERROR);
178
		}
179
		
180
		if(newPath.exists()){
181
			// Step 2 : Check for Axis2 installation libraries
182
			boolean found = true;
183
			
184
			for(int i = 0 ; i < axis2files.length ; i++){
185
				File axisFile = new File(locationFieldContents+ File.separator+axis2files[i]);
186
				if(axisFile.exists())
187
					continue;
188
				else{
189
					found = false;
190
					break;
191
				}
192
			}
193
			if(!found){
194
				return Messages.CODE_GEN_AXIS2_INSTAL_LOC_ERROR;
195
			}
196
		}
197
		return null;
198
	}
199
	
200
	/**
201
	 * Returns the Axis2 files
202
	 * @return
203
	 */
204
	public String[] getAxis2Files(){
205
		return axis2files;
206
	}
207
208
	/**
209
	 * Method to Set the Wizard page to complete state
210
	 * @param validPage 
211
	 */
212
	public void makePageComplete(boolean completePage){
213
		if(completePage){
214
			setPageComplete(true);
215
		}else{
216
			setPageComplete(false);
217
		}
218
	}
219
}

Return to bug 150385