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 202695 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/hyades/test/ui/internal/wizard/DatapoolImportPageTwo.java (-1 / +68 lines)
Lines 14-34 Link Here
14
import org.eclipse.core.resources.ResourcesPlugin;
14
import org.eclipse.core.resources.ResourcesPlugin;
15
import org.eclipse.emf.ecore.EObject;
15
import org.eclipse.emf.ecore.EObject;
16
import org.eclipse.hyades.edit.datapool.IDatapool;
16
import org.eclipse.hyades.edit.datapool.IDatapool;
17
import org.eclipse.hyades.models.common.datapool.util.DatapoolEncryptManager;
17
import org.eclipse.hyades.models.common.util.ICommonConstants;
18
import org.eclipse.hyades.models.common.util.ICommonConstants;
18
import org.eclipse.hyades.test.ui.datapool.internal.util.CSVImportExportUtil;
19
import org.eclipse.hyades.test.ui.datapool.internal.util.CSVImportExportUtil;
19
import org.eclipse.hyades.test.ui.internal.component.EObjectResourceSelectionViewer;
20
import org.eclipse.hyades.test.ui.internal.component.EObjectResourceSelectionViewer;
20
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
21
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
21
import org.eclipse.hyades.test.ui.internal.util.TestUIUtilities;
22
import org.eclipse.hyades.test.ui.internal.util.TestUIUtilities;
23
import org.eclipse.hyades.ui.internal.util.GridDataUtil;
22
import org.eclipse.jface.viewers.IStructuredSelection;
24
import org.eclipse.jface.viewers.IStructuredSelection;
23
import org.eclipse.jface.wizard.WizardPage;
25
import org.eclipse.jface.wizard.WizardPage;
24
import org.eclipse.swt.SWT;
26
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.events.ModifyEvent;
28
import org.eclipse.swt.events.ModifyListener;
25
import org.eclipse.swt.events.SelectionAdapter;
29
import org.eclipse.swt.events.SelectionAdapter;
26
import org.eclipse.swt.events.SelectionEvent;
30
import org.eclipse.swt.events.SelectionEvent;
31
import org.eclipse.swt.layout.FormAttachment;
32
import org.eclipse.swt.layout.FormData;
33
import org.eclipse.swt.layout.FormLayout;
27
import org.eclipse.swt.layout.GridData;
34
import org.eclipse.swt.layout.GridData;
28
import org.eclipse.swt.layout.GridLayout;
35
import org.eclipse.swt.layout.GridLayout;
29
import org.eclipse.swt.widgets.Button;
36
import org.eclipse.swt.widgets.Button;
30
import org.eclipse.swt.widgets.Composite;
37
import org.eclipse.swt.widgets.Composite;
31
import org.eclipse.swt.widgets.Group;
38
import org.eclipse.swt.widgets.Group;
39
import org.eclipse.swt.widgets.Text;
32
40
33
/**
41
/**
34
 * Datapool CSV import page two.
42
 * Datapool CSV import page two.
Lines 45-50 Link Here
45
	private IStructuredSelection selection = null;
53
	private IStructuredSelection selection = null;
46
	boolean isPageComplete = false;
54
	boolean isPageComplete = false;
47
	
55
	
56
	private Group group;
57
	private Text textArea;	
58
	private FormData formData;	
59
	private boolean isEncrypted = false;
60
	
48
	public DatapoolImportPageTwo(String name, IStructuredSelection selection){
61
	public DatapoolImportPageTwo(String name, IStructuredSelection selection){
49
		
62
		
50
		super(name);
63
		super(name);
Lines 75-81 Link Here
75
				
88
				
76
				super.setSelection();
89
				super.setSelection();
77
				
90
				
78
				validate();
91
				validate();	
92
				
79
			}
93
			}
80
		};
94
		};
81
		
95
		
Lines 90-95 Link Here
90
				validate();
104
				validate();
91
			}
105
			}
92
		});
106
		});
107
		
108
		group = new Group(pane,SWT.NULL);			
109
		group.setText(UiPluginResourceBundle.DatapoolExportWizard_password);
110
		group.setLayoutData(GridDataUtil.createHorizontalFill());
111
		group.setLayout(new FormLayout());
112
		group.setVisible(false);
113
		textArea = new Text(group, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.PASSWORD);		
114
		formData = new FormData();
115
		formData.left = new FormAttachment(0,5);
116
		formData.top = new FormAttachment(0,5);		
117
		formData.bottom = new FormAttachment(80,-5);
118
		formData.width = 200;
119
		textArea.setLayoutData(formData);		
120
		
121
		
122
		textArea.addModifyListener(new ModifyListener(){
123
			public void modifyText(ModifyEvent e){
124
				if(textArea.getText().length()>0){
125
					isPageComplete = true;
126
					getContainer().updateButtons();
127
				}
128
			}
129
		});
93
130
94
		TestUIUtilities.setEnabled(exisitingDatapoolGroup, useExistingDatapoolButton.getSelection());
131
		TestUIUtilities.setEnabled(exisitingDatapoolGroup, useExistingDatapoolButton.getSelection());
95
	    
132
	    
Lines 148-155 Link Here
148
			}
185
			}
149
		}
186
		}
150
		
187
		
188
		if(isPageComplete){
189
			IDatapool datapool = getSelectedDatapool();
190
			if(datapool != null)
191
			{							
192
				if(DatapoolEncryptManager.isDatapoolEncrypted(datapool)){
193
					isEncrypted = true;
194
					setMessage(org.eclipse.osgi.util.NLS.bind(UiPluginResourceBundle.DatapoolExportWizard_encrypted,datapool.getName()),WARNING);
195
					group.setVisible(true);
196
					group.setText(UiPluginResourceBundle.DatapoolExportWizard_password + " " + datapool.getName() + ".datapool");
197
					textArea.setFocus();					
198
					isPageComplete = false;
199
					//getContainer().updateButtons();
200
				}else{		
201
					isEncrypted = false;
202
					setMessage(org.eclipse.osgi.util.NLS.bind(UiPluginResourceBundle.DatapoolExportWizard_unencrypted,datapool.getName()));
203
					group.setVisible(false);						
204
					textArea.setText("");			
205
					
206
					getContainer().updateButtons();
207
				}
208
			}
209
		}
151
		setErrorMessage(errorMessage);
210
		setErrorMessage(errorMessage);
152
211
153
		getContainer().updateButtons();
212
		getContainer().updateButtons();
154
	}
213
	}
214
	
215
	public Text getTextArea(){
216
		return textArea;
217
	}
218
	
219
	public boolean isEncrypted(){
220
		return isEncrypted;
221
	}	
155
}
222
}
(-)src/org/eclipse/hyades/test/ui/internal/wizard/DatapoolImportWizard.java (-1 / +33 lines)
Lines 21-26 Link Here
21
import org.eclipse.emf.ecore.resource.Resource;
21
import org.eclipse.emf.ecore.resource.Resource;
22
import org.eclipse.hyades.edit.datapool.IDatapool;
22
import org.eclipse.hyades.edit.datapool.IDatapool;
23
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
23
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
24
import org.eclipse.hyades.models.common.datapool.util.DatapoolEncryptManager;
24
import org.eclipse.hyades.models.common.util.DatapoolUtil;
25
import org.eclipse.hyades.models.common.util.DatapoolUtil;
25
import org.eclipse.hyades.models.common.util.ICommonConstants;
26
import org.eclipse.hyades.models.common.util.ICommonConstants;
26
import org.eclipse.hyades.test.core.util.EMFUtil;
27
import org.eclipse.hyades.test.core.util.EMFUtil;
Lines 30-40 Link Here
30
import org.eclipse.hyades.test.ui.datapool.internal.util.CSVImportExportUtil;
31
import org.eclipse.hyades.test.ui.datapool.internal.util.CSVImportExportUtil;
31
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
32
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
32
import org.eclipse.hyades.test.ui.internal.util.TestUIUtilities;
33
import org.eclipse.hyades.test.ui.internal.util.TestUIUtilities;
33
import org.eclipse.tptp.platform.common.ui.wizard.LocationPage;
34
import org.eclipse.jface.dialogs.ErrorDialog;
34
import org.eclipse.jface.dialogs.ErrorDialog;
35
import org.eclipse.jface.operation.IRunnableWithProgress;
35
import org.eclipse.jface.operation.IRunnableWithProgress;
36
import org.eclipse.jface.viewers.IStructuredSelection;
36
import org.eclipse.jface.viewers.IStructuredSelection;
37
import org.eclipse.jface.wizard.Wizard;
37
import org.eclipse.jface.wizard.Wizard;
38
import org.eclipse.tptp.platform.common.ui.wizard.LocationPage;
38
import org.eclipse.ui.IImportWizard;
39
import org.eclipse.ui.IImportWizard;
39
import org.eclipse.ui.IWorkbench;
40
import org.eclipse.ui.IWorkbench;
40
import org.eclipse.ui.actions.WorkspaceModifyOperation;
41
import org.eclipse.ui.actions.WorkspaceModifyOperation;
Lines 141-146 Link Here
141
    					datapool.removeEquivalenceClass(0);
142
    					datapool.removeEquivalenceClass(0);
142
    				}
143
    				}
143
    				
144
    				
145
    				String key = datapoolImportPageTwo.getTextArea().getText();
146
    				
147
    				if(datapoolImportPageTwo.isEncrypted()){
148
    					if(!DatapoolEncryptManager.isKeyCorrect(datapool, key)){
149
    						datapoolImportPageTwo.setMessage(UiPluginResourceBundle.DatapoolExportWizard_wrongpass,3);
150
    						datapoolImportPageTwo.getTextArea().setText("");
151
    						datapoolImportPageTwo.getTextArea().setFocus();
152
    						throw new Exception("Password is not correct!");
153
    					}
154
    				}
155
    				
156
    				if( DatapoolEncryptManager.isDatapoolEncrypted(datapool))
157
    				{
158
    					DatapoolEncryptManager.decrypDatapool(datapool, key);
159
    				}
160
    				
144
    				monitor.worked(1);
161
    				monitor.worked(1);
145
    				
162
    				
146
    				if(datapool.getVariableCount() == 0){
163
    				if(datapool.getVariableCount() == 0){
Lines 162-167 Link Here
162
179
163
    				monitor.worked(1);
180
    				monitor.worked(1);
164
    				
181
    				
182
    				if( DatapoolEncryptManager.isDatapoolEncrypted(datapool))
183
    				{
184
    					DatapoolEncryptManager.encrypDatapool(datapool, key);
185
    				}
186
    				
165
    				Resource datapoolResource = ((EObject)(datapool)).eResource();
187
    				Resource datapoolResource = ((EObject)(datapool)).eResource();
166
    				
188
    				
167
    				EMFUtil.save(datapoolResource);
189
    				EMFUtil.save(datapoolResource);
Lines 193-198 Link Here
193
        };
215
        };
194
        
216
        
195
        try {
217
        try {
218
        	String key = datapoolImportPageTwo.getTextArea().getText();
219
        	IDatapool datapool = datapoolImportPageTwo.getSelectedDatapool();
220
			if(datapoolImportPageTwo.isEncrypted()){
221
				if(!DatapoolEncryptManager.isKeyCorrect(datapool, key)){
222
					datapoolImportPageTwo.setMessage(UiPluginResourceBundle.DatapoolExportWizard_wrongpass,3);
223
					datapoolImportPageTwo.getTextArea().setText("");
224
					datapoolImportPageTwo.getTextArea().setFocus();
225
					return false;
226
				}
227
			}
196
            getContainer().run(false, false, operation);
228
            getContainer().run(false, false, operation);
197
        } 
229
        } 
198
        catch (InvocationTargetException e) {
230
        catch (InvocationTargetException e) {
(-)src/org/eclipse/hyades/test/ui/internal/wizard/ReportExtensionsWizard.java (+1 lines)
Lines 38-43 Link Here
38
import org.eclipse.osgi.util.NLS;
38
import org.eclipse.osgi.util.NLS;
39
import org.eclipse.tptp.platform.common.ui.wizard.LocationPage;
39
import org.eclipse.tptp.platform.common.ui.wizard.LocationPage;
40
40
41
41
/**
42
/**
42
 * This wizard is used for the migration from the reportExtensions to the new reportGenerators extension point.
43
 * This wizard is used for the migration from the reportExtensions to the new reportGenerators extension point.
43
 * 
44
 * 
(-)src/org/eclipse/hyades/test/ui/internal/wizard/DatapoolExportSelectionPage.java (-2 / +57 lines)
Lines 14-19 Link Here
14
import org.eclipse.core.resources.IResource;
14
import org.eclipse.core.resources.IResource;
15
import org.eclipse.core.resources.ResourcesPlugin;
15
import org.eclipse.core.resources.ResourcesPlugin;
16
import org.eclipse.hyades.edit.datapool.IDatapool;
16
import org.eclipse.hyades.edit.datapool.IDatapool;
17
import org.eclipse.hyades.models.common.datapool.util.DatapoolEncryptManager;
17
import org.eclipse.hyades.models.common.util.ICommonConstants;
18
import org.eclipse.hyades.models.common.util.ICommonConstants;
18
import org.eclipse.hyades.test.ui.datapool.internal.util.GridDataUtil;
19
import org.eclipse.hyades.test.ui.datapool.internal.util.GridDataUtil;
19
import org.eclipse.hyades.test.ui.dialog.EObjectResourceContentProvider;
20
import org.eclipse.hyades.test.ui.dialog.EObjectResourceContentProvider;
Lines 27-39 Link Here
27
import org.eclipse.jface.viewers.ViewerSorter;
28
import org.eclipse.jface.viewers.ViewerSorter;
28
import org.eclipse.jface.wizard.WizardPage;
29
import org.eclipse.jface.wizard.WizardPage;
29
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.SWT;
31
import org.eclipse.swt.events.ModifyEvent;
32
import org.eclipse.swt.events.ModifyListener;
30
import org.eclipse.swt.events.SelectionEvent;
33
import org.eclipse.swt.events.SelectionEvent;
31
import org.eclipse.swt.events.SelectionListener;
34
import org.eclipse.swt.events.SelectionListener;
32
import org.eclipse.swt.graphics.Image;
35
import org.eclipse.swt.graphics.Image;
36
import org.eclipse.swt.layout.FormAttachment;
37
import org.eclipse.swt.layout.FormData;
38
import org.eclipse.swt.layout.FormLayout;
33
import org.eclipse.swt.layout.GridData;
39
import org.eclipse.swt.layout.GridData;
34
import org.eclipse.swt.layout.GridLayout;
40
import org.eclipse.swt.layout.GridLayout;
35
import org.eclipse.swt.widgets.Button;
41
import org.eclipse.swt.widgets.Button;
36
import org.eclipse.swt.widgets.Composite;
42
import org.eclipse.swt.widgets.Composite;
43
import org.eclipse.swt.widgets.Group;
44
import org.eclipse.swt.widgets.Text;
37
import org.eclipse.swt.widgets.Tree;
45
import org.eclipse.swt.widgets.Tree;
38
46
39
/**
47
/**
Lines 50-55 Link Here
50
	private EObjectResourceContentProvider contentProvider;
58
	private EObjectResourceContentProvider contentProvider;
51
	private String[] fileExtensions;
59
	private String[] fileExtensions;
52
	private Image fileImage;
60
	private Image fileImage;
61
	private Group group;
62
	private Text textArea;	
63
	private FormData formData;	
64
	private boolean isEncrypted = false;
53
	
65
	
54
	/**
66
	/**
55
	 * @param pageName
67
	 * @param pageName
Lines 148-155 Link Here
148
		};
160
		};
149
		assetViewer.setSorter(sorter);
161
		assetViewer.setSorter(sorter);
150
	
162
	
163
		group = new Group(parent,SWT.NULL);			
164
		group.setText(UiPluginResourceBundle.DatapoolExportWizard_password);
165
		group.setLayoutData(GridDataUtil.createHorizontalFill());
166
		group.setLayout(new FormLayout());
167
		group.setVisible(false);
168
		textArea = new Text(group, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER | SWT.PASSWORD);		
169
		formData = new FormData();
170
		formData.left = new FormAttachment(0,5);
171
		formData.top = new FormAttachment(0,5);		
172
		formData.bottom = new FormAttachment(80,-5);
173
		formData.width = 200;
174
		textArea.setLayoutData(formData);		
175
		textArea.addModifyListener(new ModifyListener(){
176
			public void modifyText(ModifyEvent e){
177
				if(textArea.getText().length()>0){										
178
					setPageComplete(true);
179
				}
180
			}
181
		});
151
		return assetViewer;
182
		return assetViewer;
152
	}
183
	}
184
	
185
	public Text getTextArea(){
186
		return textArea;
187
	}
188
	
189
	public boolean isEncrypted(){
190
		return isEncrypted;
191
	}
153
192
154
	private void setSelection()
193
	private void setSelection()
155
	{
194
	{
Lines 162-169 Link Here
162
				datapool = (IDatapool)selectedObject;
201
				datapool = (IDatapool)selectedObject;
163
				if(datapool != null)
202
				if(datapool != null)
164
				{
203
				{
165
					setPageComplete(true);
204
					if(DatapoolEncryptManager.isDatapoolEncrypted(datapool)){
166
					getContainer().updateButtons();
205
						isEncrypted = true;
206
						setMessage(org.eclipse.osgi.util.NLS.bind(UiPluginResourceBundle.DatapoolExportWizard_encrypted,datapool.getName()),WARNING);
207
						group.setVisible(true);
208
						group.setText(UiPluginResourceBundle.DatapoolExportWizard_password + " " + datapool.getName() + ".datapool");
209
						textArea.setFocus();						
210
						
211
						setPageComplete(false);
212
						//getContainer().updateButtons();
213
					}else{		
214
						isEncrypted = false;
215
						setMessage(org.eclipse.osgi.util.NLS.bind(UiPluginResourceBundle.DatapoolExportWizard_unencrypted,datapool.getName()));
216
						group.setVisible(false);						
217
						textArea.setText("");						
218
						
219
						setPageComplete(true);
220
						getContainer().updateButtons();
221
					}
167
				}
222
				}
168
			}
223
			}
169
		}
224
		}
(-)src/org/eclipse/hyades/test/ui/internal/wizard/DatapoolExportWizard.java (-1 / +23 lines)
Lines 18-23 Link Here
18
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.Path;
19
import org.eclipse.core.runtime.Path;
20
import org.eclipse.hyades.edit.datapool.IDatapool;
20
import org.eclipse.hyades.edit.datapool.IDatapool;
21
import org.eclipse.hyades.models.common.datapool.util.DatapoolEncryptManager;
21
import org.eclipse.hyades.test.ui.TestUIImages;
22
import org.eclipse.hyades.test.ui.TestUIImages;
22
import org.eclipse.hyades.test.ui.UiPlugin;
23
import org.eclipse.hyades.test.ui.UiPlugin;
23
import org.eclipse.hyades.test.ui.datapool.internal.util.CSVImportExportUtil;
24
import org.eclipse.hyades.test.ui.datapool.internal.util.CSVImportExportUtil;
Lines 85-94 Link Here
85
	
86
	
86
	/* (non-Javadoc)
87
	/* (non-Javadoc)
87
	 * @see org.eclipse.jface.wizard.IWizard#performFinish()
88
	 * @see org.eclipse.jface.wizard.IWizard#performFinish()
88
	 */
89
	 */	
89
	public boolean performFinish() 
90
	public boolean performFinish() 
90
	{
91
	{
91
		IDatapool datapool = datapoolSelectionPage.getDatapool();
92
		IDatapool datapool = datapoolSelectionPage.getDatapool();
93
		String key = datapoolSelectionPage.getTextArea().getText();
94
		
95
		if(datapoolSelectionPage.isEncrypted()){
96
			if(!DatapoolEncryptManager.isKeyCorrect(datapool, key)){
97
				datapoolSelectionPage.setMessage(UiPluginResourceBundle.DatapoolExportWizard_wrongpass,3);
98
				datapoolSelectionPage.getTextArea().setText("");
99
				datapoolSelectionPage.getTextArea().setFocus();
100
				return false;
101
			}
102
		}
103
		
104
		if( DatapoolEncryptManager.isDatapoolEncrypted(datapool))
105
		{
106
			DatapoolEncryptManager.decrypDatapool(datapool, key);
107
		}
92
		String csvFileName = csvFileLocationPage.getCSVFileName();
108
		String csvFileName = csvFileLocationPage.getCSVFileName();
93
		if(!csvFileName.endsWith(".csv") && !csvFileName.endsWith(".CSV"))
109
		if(!csvFileName.endsWith(".csv") && !csvFileName.endsWith(".CSV"))
94
			csvFileName = csvFileName + ".csv";
110
			csvFileName = csvFileName + ".csv";
Lines 124-129 Link Here
124
                UiPlugin.logError(e);
140
                UiPlugin.logError(e);
125
            }
141
            }
126
        }
142
        }
143
        
144
        //Encrypted back
145
        if( DatapoolEncryptManager.isDatapoolEncrypted(datapool))
146
		{
147
			DatapoolEncryptManager.encrypDatapool(datapool, key);
148
		}
127
        return close;
149
        return close;
128
	}
150
	}
129
}
151
}
(-)plugin.xml (+8 lines)
Lines 948-953 Link Here
948
                testType="org.eclipse.hyades.test.http.junit.testSuite">
948
                testType="org.eclipse.hyades.test.http.junit.testSuite">
949
          </verdictProvider>
949
          </verdictProvider>
950
       </extension>
950
       </extension>
951
          <extension
952
             point="org.eclipse.hyades.test.core.launchDatapoolCheckPass">
953
          <launchDatapoolCheckPass
954
                UIClass="org.eclipse.hyades.test.ui.dialog.DatapoolCheck">
955
             <supportedTestType>
956
             </supportedTestType>
957
          </launchDatapoolCheckPass>
958
       </extension>
951
   
959
   
952
   
960
   
953
</plugin>
961
</plugin>
(-)src/org/eclipse/hyades/test/ui/datapool/internal/util/ValueObject.java (-1 / +16 lines)
Lines 23-29 Link Here
23
public class ValueObject {
23
public class ValueObject {
24
24
25
	private Object theObject;
25
	private Object theObject;
26
	private IDisplayValueClass valueClass;
26
	protected IDisplayValueClass valueClass;
27
	private String description;
27
	private String description;
28
	private Object display;
28
	private Object display;
29
	
29
	
Lines 65-70 Link Here
65
		return null;
65
		return null;
66
	}
66
	}
67
	
67
	
68
	public Object getEncryptedDisplay(Composite parent)
69
	{
70
		if ( display != null && display instanceof CellEditor )
71
		{
72
			Control control = ((CellEditor)display).getControl();
73
			if ( control != null && !control.isDisposed() )
74
				return display;
75
		}
76
		if ( valueClass != null )
77
		{
78
			display = ((EncryptedStringValueClass)valueClass).getPropertyDisplay(theObject, parent, true);
79
			return display;
80
		}
81
		return null;
82
	}
68
	public Object getDialogDisplay(Composite parent, boolean isEditable)
83
	public Object getDialogDisplay(Composite parent, boolean isEditable)
69
	{
84
	{
70
		return null;
85
		return null;
(-)src/org/eclipse/hyades/test/ui/internal/editor/extension/DatapoolEditorExtension.java (-4 / +16 lines)
Lines 396-404 Link Here
396
396
397
    /* (non-Javadoc)
397
    /* (non-Javadoc)
398
     * @see org.eclipse.hyades.ui.editor.IEditorExtension#createPages()
398
     * @see org.eclipse.hyades.ui.editor.IEditorExtension#createPages()
399
     */
399
     */    
400
    public void createPages() {
400
    public void createPages() {
401
        IHyadesEditorPart hyadesEditorPart = getHyadesEditorPart();
401
    	IHyadesEditorPart hyadesEditorPart = getHyadesEditorPart();
402
        WidgetFactory widgetFactory = new WidgetFactory();
402
        WidgetFactory widgetFactory = new WidgetFactory();
403
403
404
        datapoolForm = new DatapoolForm(this, widgetFactory);
404
        datapoolForm = new DatapoolForm(this, widgetFactory);
Lines 406-412 Link Here
406
        hyadesEditorPart.setPageText(PAGE_OVERVIEW, UiPluginResourceBundle.W_OVERVIEW); 
406
        hyadesEditorPart.setPageText(PAGE_OVERVIEW, UiPluginResourceBundle.W_OVERVIEW); 
407
        datapoolForm.updateTitle();
407
        datapoolForm.updateTitle();
408
408
409
        IDatapool dp = getDatapool();
409
        IDatapool dp = getDatapool(); 
410
        for (int i = 0; i < dp.getEquivalenceClassCount(); i++) {
410
        for (int i = 0; i < dp.getEquivalenceClassCount(); i++) {
411
            addEquivalenceClassPage(i);
411
            addEquivalenceClassPage(i);
412
        }
412
        }
Lines 631-635 Link Here
631
    public void connectPart(IWorkbenchPart part) {
631
    public void connectPart(IWorkbenchPart part) {
632
        DatapoolActionHandlerListener.INSTANCE.connectPart(part);
632
        DatapoolActionHandlerListener.INSTANCE.connectPart(part);
633
    }
633
    }
634
634
    /**
635
     * used for DatapoolEditorPart to save
636
     * deal with the encrypted datapool
637
     * */
638
    public void save(){
639
    	if(super.getProgressMonitor() != null){
640
    		try{
641
    			super.save(super.getProgressMonitor());
642
    		}catch(Exception e){
643
    			e.printStackTrace();
644
    		}
645
		}
646
    }
635
}
647
}
(-)src/org/eclipse/hyades/test/ui/datapool/internal/control/DatapoolTable.java (-19 / +322 lines)
Lines 25-38 Link Here
25
import org.eclipse.hyades.edit.datapool.IDatapoolRecord;
25
import org.eclipse.hyades.edit.datapool.IDatapoolRecord;
26
import org.eclipse.hyades.edit.datapool.IDatapoolSuggestedType;
26
import org.eclipse.hyades.edit.datapool.IDatapoolSuggestedType;
27
import org.eclipse.hyades.edit.datapool.IDatapoolVariable;
27
import org.eclipse.hyades.edit.datapool.IDatapoolVariable;
28
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
29
import org.eclipse.hyades.models.common.datapool.DPLVariable;
30
import org.eclipse.hyades.models.common.datapool.util.DatapoolEncryptManager;
31
import org.eclipse.hyades.models.common.util.EncryptionManager;
28
import org.eclipse.hyades.test.ui.UiPlugin;
32
import org.eclipse.hyades.test.ui.UiPlugin;
33
import org.eclipse.hyades.test.ui.datapool.internal.dialog.DatapoolChangeKeyDialog;
29
import org.eclipse.hyades.test.ui.datapool.internal.dialog.DatapoolColumnDialog;
34
import org.eclipse.hyades.test.ui.datapool.internal.dialog.DatapoolColumnDialog;
35
import org.eclipse.hyades.test.ui.datapool.internal.dialog.DatapoolConstant;
30
import org.eclipse.hyades.test.ui.datapool.internal.dialog.DatapoolDeleteColumnDialog;
36
import org.eclipse.hyades.test.ui.datapool.internal.dialog.DatapoolDeleteColumnDialog;
37
import org.eclipse.hyades.test.ui.datapool.internal.dialog.DatapoolInputKeyDialog;
31
import org.eclipse.hyades.test.ui.datapool.internal.dialog.DatapoolRowDialog;
38
import org.eclipse.hyades.test.ui.datapool.internal.dialog.DatapoolRowDialog;
32
import org.eclipse.hyades.test.ui.datapool.internal.interfaces.IDatapoolPart;
39
import org.eclipse.hyades.test.ui.datapool.internal.interfaces.IDatapoolPart;
33
import org.eclipse.hyades.test.ui.datapool.internal.interfaces.IValidateValueClass;
40
import org.eclipse.hyades.test.ui.datapool.internal.interfaces.IValidateValueClass;
34
import org.eclipse.hyades.test.ui.datapool.internal.interfaces.IValueClassFactory;
41
import org.eclipse.hyades.test.ui.datapool.internal.interfaces.IValueClassFactory;
35
import org.eclipse.hyades.test.ui.datapool.internal.util.DatapoolUtil;
42
import org.eclipse.hyades.test.ui.datapool.internal.util.DatapoolUtil;
43
import org.eclipse.hyades.test.ui.datapool.internal.util.EncryptedValueObject;
36
import org.eclipse.hyades.test.ui.datapool.internal.util.TypeChecker;
44
import org.eclipse.hyades.test.ui.datapool.internal.util.TypeChecker;
37
import org.eclipse.hyades.test.ui.datapool.internal.util.ValueClassMap;
45
import org.eclipse.hyades.test.ui.datapool.internal.util.ValueClassMap;
38
import org.eclipse.hyades.test.ui.datapool.internal.util.ValueObject;
46
import org.eclipse.hyades.test.ui.datapool.internal.util.ValueObject;
Lines 135-140 Link Here
135
	private boolean showRecords = true;
143
	private boolean showRecords = true;
136
	private boolean isF2Mode = false;
144
	private boolean isF2Mode = false;
137
	private int previousMultiRowSelectionIndex = -1;  // only used for deselecting when multi-selection in place.
145
	private int previousMultiRowSelectionIndex = -1;  // only used for deselecting when multi-selection in place.
146
	private String cellkey;
147
	private boolean passwordExist = false;
148
	private String password = null;
138
	
149
	
139
	private String vendorID = null;
150
	private String vendorID = null;
140
	
151
	
Lines 1379-1397 Link Here
1379
			if(rawValue == null)
1390
			if(rawValue == null)
1380
			{	
1391
			{	
1381
				String typeName = suggestedType.getSuggestedClassName();					
1392
				String typeName = suggestedType.getSuggestedClassName();					
1382
				if(typeName == null || typeName.length() == 0)
1393
				if (typeName == null || typeName.length() == 0) {
1383
				{
1384
					rawValue = new String();
1394
					rawValue = new String();
1385
				}
1395
				} else {
1386
				else
1387
				{
1388
					rawValue = createEmptyCellObject(typeName);
1396
					rawValue = createEmptyCellObject(typeName);
1389
				}
1397
				}
1390
			}
1398
			}
1391
			
1399
			if(DatapoolEncryptManager.isVariabelEncrypted(variable))
1392
			theValueObject = new ValueObject(rawValue);
1400
			{
1393
			cellEditor = (CellEditor)theValueObject.getPropertyDisplay(tableCursor);
1401
				boolean errorKey = true;
1394
		}		
1402
				boolean isCancelChange = false;
1403
				String key = null;
1404
				if(passwordExist){
1405
					key = password;
1406
					cellkey = key;
1407
				}else{
1408
					DatapoolInputKeyDialog logOnDialog = new DatapoolInputKeyDialog(
1409
							Display.getCurrent().getActiveShell(),
1410
							UiPluginResourceBundle.DatapoolDialog_INPUTKEYDIALGOTITLE);
1411
	//				String key = getKeyInDatapool(datapool);
1412
					
1413
					while (errorKey) {
1414
						int openValue = logOnDialog.open();
1415
						if (openValue == IDialogConstants.OK_ID) {
1416
							key = logOnDialog.getKey();
1417
							cellkey = key;
1418
							if (DatapoolEncryptManager.isKeyCorrect(datapool, key)) {
1419
								errorKey = false;
1420
								password = key;
1421
								passwordExist = true;
1422
							} else {//the input key is incorrect
1423
								showErrMes(Display.getCurrent()
1424
										.getActiveShell(),
1425
										UiPluginResourceBundle.DatapoolDialog_WRONGLOGONKEYMES);
1426
							}
1427
						} else if (openValue == IDialogConstants.CANCEL_ID) {// click cancel button
1428
							isCancelChange = true;
1429
							errorKey = false;
1430
	
1431
						}
1432
					}
1433
					
1434
					if(isCancelChange)
1435
					{
1436
						return;
1437
					}
1438
				}
1439
				rawValue = EncryptionManager.decrypt(rawValue.toString(), key);
1440
				theValueObject = new EncryptedValueObject(rawValue);
1441
				cellEditor = (CellEditor) theValueObject
1442
				.getEncryptedDisplay(tableCursor);
1443
			}else{
1444
				theValueObject = new ValueObject(rawValue);
1445
				cellEditor = (CellEditor) theValueObject.getPropertyDisplay(tableCursor);
1446
			}
1447
//			cellEditor = new TextCellEditor(tableCursor,SWT.PASSWORD);
1448
//			cellEditor.setValue(rawValue.toString());
1449
//			int oldStyle = cellEditor.getStyle();
1450
//			cellEditor.setStyle(SWT.PASSWORD|oldStyle);
1451
//			oldStyle = cellEditor.getStyle();
1452
		}
1395
		
1453
		
1396
		if(cellEditor != null && cellEditor.getControl() != null)
1454
		if(cellEditor != null && cellEditor.getControl() != null)
1397
		{
1455
		{
Lines 1491-1498 Link Here
1491
					}
1549
					}
1492
				}
1550
				}
1493
				
1551
				
1494
				if(update)
1552
				if (update) {
1495
				{
1553
					if(DatapoolEncryptManager.isVariabelEncrypted(cell.getCellVariable()))
1554
					{
1555
						String value = String.valueOf(updatedValue);
1556
						String encryptValue = DatapoolEncryptManager.encrypt(value, cellkey);
1557
						updatedValue = (Object)encryptValue;
1558
						
1559
					}
1496
					cell.setCellValue(updatedValue);
1560
					cell.setCellValue(updatedValue);
1497
					selectedTableItem.setText(selectedColumnIndex, newDescription);
1561
					selectedTableItem.setText(selectedColumnIndex, newDescription);
1498
					tableCursor.setSelection(table.getSelectionIndex(), selectedColumnIndex);
1562
					tableCursor.setSelection(table.getSelectionIndex(), selectedColumnIndex);
Lines 1501-1506 Link Here
1501
			}
1565
			}
1502
			
1566
			
1503
			if(dispose)
1567
			if(dispose)
1568
				refreshRows();
1504
				clearCellEditor();
1569
				clearCellEditor();
1505
		}						
1570
		}						
1506
	}
1571
	}
Lines 1838-1852 Link Here
1838
1903
1839
		IDatapool datapool = getDatapool();
1904
		IDatapool datapool = getDatapool();
1840
		DatapoolColumnDialog dialog = new DatapoolColumnDialog(Display.getCurrent().getActiveShell(), datapool, null, previousVariable, UiPluginResourceBundle.DATA_COL_DLG_TITLE_INS);  
1905
		DatapoolColumnDialog dialog = new DatapoolColumnDialog(Display.getCurrent().getActiveShell(), datapool, null, previousVariable, UiPluginResourceBundle.DATA_COL_DLG_TITLE_INS);  
1841
		if ( dialog.open() == IDialogConstants.OK_ID)
1906
		if (dialog.open() == IDialogConstants.OK_ID) {
1842
		{
1907
			if(dialog.isEncrypted()){
1908
			String key = null;			
1909
			if(isKeyExist())
1910
			{
1911
				boolean errorKey = true;
1912
				if(passwordExist && !dialog.isKeyChanged()){
1913
					key = password;
1914
				}else{
1915
					DatapoolInputKeyDialog logOnDialog = new DatapoolInputKeyDialog(
1916
							Display.getCurrent().getActiveShell(),
1917
							UiPluginResourceBundle.DatapoolDialog_INPUTKEYDIALGOTITLE);
1918
					while (errorKey) {
1919
						int openValue = logOnDialog.open();
1920
						if (openValue == IDialogConstants.OK_ID) {
1921
							key = logOnDialog.getKey();
1922
							if (DatapoolEncryptManager.isKeyCorrect(datapool,key)) {
1923
								errorKey = false;
1924
								password = key;
1925
								passwordExist = true;
1926
							} else {
1927
								showErrMes(Display.getCurrent()
1928
										.getActiveShell(),
1929
										UiPluginResourceBundle.DatapoolDialog_WRONGLOGONKEYMES);
1930
							}
1931
						} else if (openValue == IDialogConstants.CANCEL_ID) {
1932
							errorKey = false;
1933
						}
1934
					}
1935
				}
1936
			}
1937
			else
1938
			{
1939
				Shell shell = Display.getCurrent().getActiveShell();
1940
				DatapoolChangeKeyDialog assignKeyDialog = new DatapoolChangeKeyDialog(
1941
						shell, datapool,
1942
						UiPluginResourceBundle.DatapoolDialog_ASSIGNKEYDIALOGTITLE);
1943
				boolean errorKey = true;				
1944
				while (errorKey) {
1945
					if (assignKeyDialog.open() == IDialogConstants.OK_ID) {
1946
						key = assignKeyDialog.getNewKey();
1947
						int ret = assignKeyDialog.isKeyAssignSuccess();
1948
						switch (ret) {
1949
						case DatapoolConstant.NEWKEYNULL:
1950
							showErrMes(shell,
1951
									UiPluginResourceBundle.DatapoolDialog_NEWKEYNULLMES);
1952
							break;
1953
						case DatapoolConstant.NEWKEYNOTCONFIRM:
1954
							showErrMes(
1955
									shell,
1956
									UiPluginResourceBundle.DatapoolDialog_NEWKEYNOTCONFIRMMES);
1957
							break;
1958
						case DatapoolConstant.CHANGEKEYSUCCESS:									
1959
							try{
1960
							DatapoolEncryptManager.changeKey(EncryptionManager.EncoderByMd5(key),
1961
									datapool);
1962
//							
1963
							errorKey = false;
1964
							password = key;
1965
							passwordExist = true;
1966
							}catch(Exception e){}
1967
							break;
1968
						default:// error
1969
						}
1970
					} else {						
1971
						errorKey = false;
1972
					}
1973
				}
1974
			}
1975
			}
1976
			
1843
			setWaitCursor();
1977
			setWaitCursor();
1844
			IDatapoolVariable variable = datapool.constructVariable();
1978
			IDatapoolVariable variable = datapool.constructVariable();
1845
			variable.setName(dialog.getName());
1979
			variable.setName(dialog.getName());
1846
			IDatapoolSuggestedType suggestedType = (IDatapoolSuggestedType)variable.getSuggestedType();
1980
			IDatapoolSuggestedType suggestedType = (IDatapoolSuggestedType)variable.getSuggestedType();
1847
			setVariableType(suggestedType, dialog.getType());
1981
			setVariableType(suggestedType, dialog.getType());
1848
			variable.setSuggestedType(suggestedType);
1982
			variable.setSuggestedType(suggestedType);
1849
			int insertionIndex = findColumnIndex(dialog.getInsertionVariableName());
1983
			
1984
			((DPLVariable)variable).setEncrypted(dialog.isEncrypted());
1985
			
1986
			int insertionIndex = findColumnIndex(dialog
1987
					.getInsertionVariableName());
1850
			if(insertionIndex == -1)
1988
			if(insertionIndex == -1)
1851
				insertionIndex = 0;
1989
				insertionIndex = 0;
1852
1990
Lines 1858-1863 Link Here
1858
			if (tableCursor != null && !tableCursor.isDisposed() && !(row < 0 || row >= table.getItemCount() || insertionIndex < 0 || insertionIndex > maxColumnIndex)) {
1996
			if (tableCursor != null && !tableCursor.isDisposed() && !(row < 0 || row >= table.getItemCount() || insertionIndex < 0 || insertionIndex > maxColumnIndex)) {
1859
                tableCursor.setSelection(row, insertionIndex + 1);			
1997
                tableCursor.setSelection(row, insertionIndex + 1);			
1860
            }
1998
            }
1999
			refreshRows();
1861
		}
2000
		}
1862
	}
2001
	}
1863
2002
Lines 1922-1927 Link Here
1922
	 * Function that actually does the editing of the variable/column.
2061
	 * Function that actually does the editing of the variable/column.
1923
	 */	
2062
	 */	
1924
	private void editColumnAux(TableColumn tableColumn) {
2063
	private void editColumnAux(TableColumn tableColumn) {
2064
		boolean isVariableEncrypted = false;
1925
        try {
2065
        try {
1926
            if (showVariables == false) return;
2066
            if (showVariables == false) return;
1927
2067
Lines 1932-1939 Link Here
1932
            IDatapoolVariable previousVariable = null;
2072
            IDatapoolVariable previousVariable = null;
1933
            if (previousTableColumn != null) previousVariable = (IDatapoolVariable) previousTableColumn.getData(TAG_VARIABLE);
2073
            if (previousTableColumn != null) previousVariable = (IDatapoolVariable) previousTableColumn.getData(TAG_VARIABLE);
1934
            IDatapoolVariable variable = (IDatapoolVariable) tableColumn.getData(TAG_VARIABLE);
2074
            IDatapoolVariable variable = (IDatapoolVariable) tableColumn.getData(TAG_VARIABLE);
1935
            DatapoolColumnDialog dialog = new DatapoolColumnDialog(Display.getCurrent().getActiveShell(), datapool, variable, previousVariable, UiPluginResourceBundle.DATA_COL_DLG_TITLE_EDIT); //$NON-NLS-1$
2075
            DatapoolColumnDialog dialog = new DatapoolColumnDialog(Display
1936
            if (dialog.open() == IDialogConstants.OK_ID) {
2076
					.getCurrent().getActiveShell(), datapool, variable,
2077
					previousVariable,
2078
					UiPluginResourceBundle.DATA_COL_DLG_TITLE_EDIT); //$NON-NLS-1$
2079
			isVariableEncrypted = DatapoolEncryptManager.isVariabelEncrypted(variable);
2080
			String key = null;
2081
			if (dialog.open() == IDialogConstants.OK_ID) {
2082
				if (isNeedKeyVerify(dialog,isVariableEncrypted)) {//need to confrim key or assign a new key
2083
					boolean isCancelChange = false;
2084
					if(isKeyExist())//key exists means it needs to confirm key
2085
					{
2086
						//if(dialog.isKeyChanged())
2087
						//{
2088
							//key = dialog.getKey();							
2089
						//}
2090
						boolean errorKey = true;
2091
						
2092
						if(passwordExist && !dialog.isKeyChanged()){
2093
							key = password;
2094
						}else {
2095
							if(dialog.isKeyChanged()){
2096
								key = dialog.getNewKey();
2097
								password = dialog.getNewKey();
2098
								passwordExist = true;
2099
							}else{						
2100
								DatapoolInputKeyDialog logOnDialog = new DatapoolInputKeyDialog(
2101
										Display.getCurrent().getActiveShell(),
2102
										UiPluginResourceBundle.DatapoolDialog_INPUTKEYDIALGOTITLE);
2103
								while (errorKey) {
2104
									int openValue = logOnDialog.open();
2105
									if (openValue == IDialogConstants.OK_ID) {
2106
										key = logOnDialog.getKey();									
2107
										if (DatapoolEncryptManager.isKeyCorrect(datapool,key)) {
2108
											errorKey = false;
2109
											password = key;
2110
											passwordExist = true;
2111
										} else {//the input key is incorrect
2112
											showErrMes(Display.getCurrent()
2113
													.getActiveShell(),
2114
													UiPluginResourceBundle.DatapoolDialog_WRONGLOGONKEYMES);
2115
										}
2116
									} else if (openValue == IDialogConstants.CANCEL_ID) {// click cancel button
2117
										isCancelChange = true;
2118
										errorKey = false;
2119
									}
2120
								}
2121
							}
2122
							
2123
						}
2124
					}
2125
					else//it should assing a new key
2126
					{
2127
						Shell shell = Display.getCurrent().getActiveShell();
2128
						DatapoolChangeKeyDialog assignKeyDialog = new DatapoolChangeKeyDialog(
2129
								shell, datapool,
2130
								UiPluginResourceBundle.DatapoolDialog_ASSIGNKEYDIALOGTITLE);
2131
						boolean errorKey = true;
2132
						
2133
						while (errorKey) {
2134
2135
							if (assignKeyDialog.open() == IDialogConstants.OK_ID) {
2136
								key = assignKeyDialog.getNewKey();
2137
								int ret = assignKeyDialog.isKeyAssignSuccess();
2138
								switch (ret) {
2139
								case DatapoolConstant.NEWKEYNULL:
2140
									showErrMes(shell,
2141
											UiPluginResourceBundle.DatapoolDialog_NEWKEYNULLMES);
2142
									break;
2143
								case DatapoolConstant.NEWKEYNOTCONFIRM:
2144
									showErrMes(
2145
											shell,
2146
											UiPluginResourceBundle.DatapoolDialog_NEWKEYNOTCONFIRMMES);
2147
									break;
2148
								case DatapoolConstant.CHANGEKEYSUCCESS:									
2149
									try{
2150
									DatapoolEncryptManager.changeKey(EncryptionManager.EncoderByMd5(key),
2151
											datapool);
2152
//									encryptedCellInVarible(variable,newKey);
2153
									errorKey = false;									
2154
									
2155
									password = key;
2156
									passwordExist = true;
2157
									}catch(Exception e){}
2158
									break;
2159
								default:// error
2160
								}
2161
2162
							} else {
2163
								isCancelChange = true;
2164
								errorKey = false;
2165
							}
2166
						}
2167
					}
2168
					if(!isCancelChange)//input the correct key
2169
					{					
2170
						if (dialog.isEncrypted()) {
2171
							if (!isVariableEncrypted) {//encrypted a varible which didn't encrypted
2172
								DatapoolEncryptManager.encryptedCellInVarible(variable,key,datapool);
2173
								if(variable instanceof DPLVariable)
2174
									((DPLVariable)variable).setEncrypted(true);
2175
							}
2176
2177
						} else {
2178
							if (isVariableEncrypted) {//deencrypted a encrypted variable
2179
								DatapoolEncryptManager.decryptedCellInVarible(variable,key,datapool);
2180
								if(variable instanceof DPLVariable)
2181
									((DPLVariable)variable).setEncrypted(false);
2182
							}
2183
						}
1937
                setWaitCursor();
2184
                setWaitCursor();
1938
                String name = dialog.getName();
2185
                String name = dialog.getName();
1939
                String insertionVariableID = dialog.getInsertionVariableID();
2186
                String insertionVariableID = dialog.getInsertionVariableID();
Lines 1945-1952 Link Here
1945
                variable.setName(dialog.getName());
2192
                variable.setName(dialog.getName());
1946
                setVariableType(suggestedType, dialog.getType());
2193
                setVariableType(suggestedType, dialog.getType());
1947
                variable.setSuggestedType(suggestedType);
2194
                variable.setSuggestedType(suggestedType);
2195
						int insertionIndex = findColumnIndex(dialog
2196
								.getInsertionVariableName());
2197
						if (insertionIndex == columnIndex - 1) {
2198
							refresh();
2199
							return;
2200
						}
2201
						if (insertionIndex == -1)
2202
							datapool.moveVariable(columnIndex - 1, 0);
2203
						else if (insertionIndex > columnIndex)
2204
							datapool.moveVariable(columnIndex - 1,
2205
									insertionIndex - 1);
2206
						else
2207
							datapool.moveVariable(columnIndex - 1, insertionIndex);
1948
2208
1949
                int insertionIndex = findColumnIndex(dialog.getInsertionVariableName());
2209
						refreshRows();//needs to refresh row
2210
						tableCursor.setSelection(0, 0);
2211
					}
2212
				
2213
				} else {
2214
					setWaitCursor();
2215
2216
					String name = dialog.getName();
2217
					String insertionVariableID = dialog
2218
							.getInsertionVariableID();
2219
2220
					IDatapoolSuggestedType suggestedType = (IDatapoolSuggestedType) variable
2221
							.getSuggestedType();
2222
					if (name.equals(variable.getName())
2223
							&& insertionVariableID.equals(variable.getId())) {
2224
						return;
2225
					}
2226
					variable.setName(dialog.getName());
2227
					setVariableType(suggestedType, dialog.getType());
2228
					variable.setSuggestedType(suggestedType);
2229
					
2230
					int insertionIndex = findColumnIndex(dialog
2231
							.getInsertionVariableName());
1950
                if (insertionIndex == columnIndex - 1) {
2232
                if (insertionIndex == columnIndex - 1) {
1951
                    return;
2233
                    return;
1952
                }
2234
                }
Lines 1956-1963 Link Here
1956
                    datapool.moveVariable(columnIndex - 1, insertionIndex - 1);
2238
                    datapool.moveVariable(columnIndex - 1, insertionIndex - 1);
1957
                else
2239
                else
1958
                    datapool.moveVariable(columnIndex - 1, insertionIndex);
2240
                    datapool.moveVariable(columnIndex - 1, insertionIndex);
2241
					tableCursor.setSelection(0, 0);
1959
            }
2242
            }
1960
        } finally {
2243
        }} finally {
1961
            unsetWaitCursor();
2244
            unsetWaitCursor();
1962
        }
2245
        }
1963
    }
2246
    }
Lines 2890-2896 Link Here
2890
				IDatapoolVariable cellVariable = (IDatapoolVariable)cell.getCellVariable();
3173
				IDatapoolVariable cellVariable = (IDatapoolVariable)cell.getCellVariable();
2891
				int index = findColumnIndex(cellVariable.getName());
3174
				int index = findColumnIndex(cellVariable.getName());
2892
				String cellValue = cell.getStringValue();
3175
				String cellValue = cell.getStringValue();
2893
				ValueObject valueObject = new ValueObject(cell.getCellValue());
3176
				if(DatapoolEncryptManager.isVariabelEncrypted(cell.getCellVariable()))
3177
				{
3178
					cellValue = DatapoolConstant.DatapoolDialog_ENCRYPTEDDISPLAYVALUE;
3179
				}
3180
//				ValueObject valueObject = new ValueObject(cell.getCellValue());
3181
				ValueObject valueObject = new ValueObject(cellValue);
2894
				if(valueObject != null)
3182
				if(valueObject != null)
2895
					cellValue = valueObject.getDescription();
3183
					cellValue = valueObject.getDescription();
2896
				rowContents[index] = cellValue;
3184
				rowContents[index] = cellValue;
Lines 3013-3016 Link Here
3013
		setMenuMode(datapoolMenuManager);
3301
		setMenuMode(datapoolMenuManager);
3014
	}
3302
	}
3015
	
3303
	
3304
	public void setPassword(String password){
3305
		this.password = password;
3306
	}
3307
	private void showErrMes(Shell shell, String mes) {
3308
		MessageDialog.openError(shell, UiPluginResourceBundle.DatapoolDialog_ERRORDIALOGTITLE, mes);
3309
	}
3310
	
3311
		private boolean isNeedKeyVerify(DatapoolColumnDialog dialog,boolean isVariableEncrypted)
3312
		{
3313
			return dialog.isEncrypted() || isVariableEncrypted;
3314
		}
3315
		private boolean isKeyExist()
3316
		{
3317
			return (datapool instanceof DPLDatapool)?(((DPLDatapool)datapool).getChallenge()!=null):false;	
3318
		}	
3016
}
3319
}
(-)src/org/eclipse/hyades/test/ui/internal/editor/DatapoolEditorPart.java (-1 / +22 lines)
Lines 12-18 Link Here
12
package org.eclipse.hyades.test.ui.internal.editor;
12
package org.eclipse.hyades.test.ui.internal.editor;
13
13
14
import org.eclipse.emf.ecore.EObject;
14
import org.eclipse.emf.ecore.EObject;
15
import org.eclipse.hyades.edit.datapool.IDatapool;
15
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
16
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
17
import org.eclipse.hyades.models.common.datapool.impl.DPLVariableImpl;
18
import org.eclipse.hyades.models.common.datapool.util.DatapoolEncryptManager;
16
import org.eclipse.hyades.models.common.util.ICommonConstants;
19
import org.eclipse.hyades.models.common.util.ICommonConstants;
17
import org.eclipse.hyades.test.ui.TestUIExtension;
20
import org.eclipse.hyades.test.ui.TestUIExtension;
18
import org.eclipse.hyades.test.ui.internal.editor.extension.DatapoolEditorExtension;
21
import org.eclipse.hyades.test.ui.internal.editor.extension.DatapoolEditorExtension;
Lines 86-90 Link Here
86
		return true;
89
		return true;
87
	}
90
	}
88
91
89
	
92
	public void dispose(){		
93
		if(this.getEditorExtension() instanceof DatapoolEditorExtension){
94
			IDatapool dp = ((DatapoolEditorExtension)this.getEditorExtension()).getDatapool();
95
	        boolean isAnyColumnEncrypted = false;
96
	        int variableCount = dp.getVariableCount();
97
			for(int i=0;i<variableCount;i++){			
98
				if(DatapoolEncryptManager.isVariabelEncrypted(((DPLVariableImpl)dp.getVariable(i)))){
99
					isAnyColumnEncrypted = true;
100
					break;
101
				}
102
			}
103
			if(!isAnyColumnEncrypted && (dp instanceof DPLDatapool)){
104
				((DPLDatapool)dp).setChallenge(null);
105
				((DatapoolEditorExtension)this.getEditorExtension()).save();
106
			}		
107
		}
108
		super.dispose();	
109
		
110
	}	
90
}
111
}
(-)src/org/eclipse/hyades/test/ui/datapool/internal/dialog/DatapoolColumnDialog.java (-14 / +188 lines)
Lines 14-31 Link Here
14
14
15
import org.eclipse.hyades.edit.datapool.IDatapool;
15
import org.eclipse.hyades.edit.datapool.IDatapool;
16
import org.eclipse.hyades.edit.datapool.IDatapoolVariable;
16
import org.eclipse.hyades.edit.datapool.IDatapoolVariable;
17
import org.eclipse.hyades.models.common.datapool.DPLVariable;
18
import org.eclipse.hyades.models.common.datapool.util.DatapoolEncryptManager;
19
import org.eclipse.hyades.models.common.util.EncryptionManager;
17
import org.eclipse.hyades.test.ui.datapool.internal.util.DatapoolUtil;
20
import org.eclipse.hyades.test.ui.datapool.internal.util.DatapoolUtil;
18
import org.eclipse.hyades.test.ui.datapool.internal.util.GridDataUtil;
21
import org.eclipse.hyades.test.ui.datapool.internal.util.GridDataUtil;
19
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
22
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
23
import org.eclipse.jface.dialogs.IDialogConstants;
24
import org.eclipse.jface.dialogs.MessageDialog;
20
import org.eclipse.osgi.util.NLS;
25
import org.eclipse.osgi.util.NLS;
21
import org.eclipse.swt.SWT;
26
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.events.KeyEvent;
27
import org.eclipse.swt.events.KeyEvent;
23
import org.eclipse.swt.events.KeyListener;
28
import org.eclipse.swt.events.KeyListener;
29
import org.eclipse.swt.events.MouseEvent;
30
import org.eclipse.swt.events.MouseListener;
24
import org.eclipse.swt.events.SelectionEvent;
31
import org.eclipse.swt.events.SelectionEvent;
25
import org.eclipse.swt.events.SelectionListener;
32
import org.eclipse.swt.events.SelectionListener;
26
import org.eclipse.swt.graphics.Color;
33
import org.eclipse.swt.graphics.Color;
27
import org.eclipse.swt.layout.GridData;
34
import org.eclipse.swt.layout.GridData;
28
import org.eclipse.swt.layout.GridLayout;
35
import org.eclipse.swt.layout.GridLayout;
36
import org.eclipse.swt.widgets.Button;
29
import org.eclipse.swt.widgets.Combo;
37
import org.eclipse.swt.widgets.Combo;
30
import org.eclipse.swt.widgets.Composite;
38
import org.eclipse.swt.widgets.Composite;
31
import org.eclipse.swt.widgets.Control;
39
import org.eclipse.swt.widgets.Control;
Lines 43-49 Link Here
43
 * @author psun
51
 * @author psun
44
 *
52
 *
45
 */
53
 */
46
public class DatapoolColumnDialog extends DatapoolBaseDialog implements KeyListener, SelectionListener{
54
public class DatapoolColumnDialog extends DatapoolBaseDialog implements KeyListener, SelectionListener,MouseListener{
47
55
48
	private static final String TAG_VARIABLES = "variables"; //$NON-NLS-1$
56
	private static final String TAG_VARIABLES = "variables"; //$NON-NLS-1$
49
	
57
	
Lines 64-71 Link Here
64
	private String type = new String();
72
	private String type = new String();
65
	private String insertionVariableID = null;
73
	private String insertionVariableID = null;
66
	private String insertionVariableName = null;
74
	private String insertionVariableName = null;
67
	private int defaultNameCounter = 1;
75
	private int defaultNameCounter = 1;	
76
	private Button checkBox;
77
	private Button changeKeyButton;
78
	private boolean isEncrypted;
79
	private boolean isKeyChanged = false;
80
	private String newKey;
68
	
81
	
82
	public boolean isKeyChanged() {
83
		return isKeyChanged;
84
	}
69
	public DatapoolColumnDialog(Shell parentShell, 
85
	public DatapoolColumnDialog(Shell parentShell, 
70
									     IDatapool datapool,
86
									     IDatapool datapool,
71
									     IDatapoolVariable selectedVariable,
87
									     IDatapoolVariable selectedVariable,
Lines 77-83 Link Here
77
		this.datapool = datapool;
93
		this.datapool = datapool;
78
		this.title = title; 
94
		this.title = title; 
79
		this.selectedVariable = selectedVariable;
95
		this.selectedVariable = selectedVariable;
80
		this.previousVariable = previousVariable;
96
		this.previousVariable = previousVariable;			
81
	}
97
	}
82
98
83
	/**
99
	/**
Lines 122-127 Link Here
122
		typeField.setLayoutData(gridData);
138
		typeField.setLayoutData(gridData);
123
		typeField.addKeyListener(this);
139
		typeField.addKeyListener(this);
124
		typeFieldForeground = typeField.getForeground();
140
		typeFieldForeground = typeField.getForeground();
141
		
125
	
142
	
126
		IDatapoolVariable[] variables = DatapoolUtil.getInstance().getVariables(datapool, null);
143
		IDatapoolVariable[] variables = DatapoolUtil.getInstance().getVariables(datapool, null);
127
		if(selectedVariable != null)
144
		if(selectedVariable != null)
Lines 156-162 Link Here
156
		else {
173
		else {
157
			insertionLabel.setText(UiPluginResourceBundle.DATA_DLG_MOVE); 
174
			insertionLabel.setText(UiPluginResourceBundle.DATA_DLG_MOVE); 
158
        }
175
        }
159
176
		
160
		insertionVariables = new Combo(superComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
177
		insertionVariables = new Combo(superComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
161
		insertionVariables.setItems(variableLabels);
178
		insertionVariables.setItems(variableLabels);
162
		insertionVariables.setData(TAG_VARIABLES, variables);
179
		insertionVariables.setData(TAG_VARIABLES, variables);
Lines 165-171 Link Here
165
		
182
		
166
		if(variables.length > 0 && previousVariable != null)
183
		if(variables.length > 0 && previousVariable != null)
167
		{
184
		{
168
			int selectIndex = findVariableIndexInCombo(variables, previousVariable) - 1;
185
			int selectIndex = findVariableIndexInCombo(variables, previousVariable);
169
            if (selectIndex < 0) {
186
            if (selectIndex < 0) {
170
                insertionVariables.select(0);
187
                insertionVariables.select(0);
171
                insertionVariableName = new String();
188
                insertionVariableName = new String();
Lines 184-211 Link Here
184
		}
201
		}
185
        if (title.equals(UiPluginResourceBundle.DATA_COL_DLG_TITLE_EDIT) && variables.length == 1) { 
202
        if (title.equals(UiPluginResourceBundle.DATA_COL_DLG_TITLE_EDIT) && variables.length == 1) { 
186
            //- Move field hidden 
203
            //- Move field hidden 
187
            insertionVariables.setVisible(false);
204
             insertionVariables.setVisible(false);
188
            insertionLabel.setVisible(false);
205
            insertionLabel.setVisible(false);
189
        }
206
        }
207
        
208
        checkBox = new Button(superComposite,SWT.CHECK);
209
		checkBox.setText(UiPluginResourceBundle.DatapoolDialog_ENCRYPTED);
210
		checkBox.addMouseListener(this);
211
		changeKeyButton = new Button(superComposite,SWT.NONE);
212
		changeKeyButton.setText(UiPluginResourceBundle.DatapoolDialog_CHANGEKEY);
213
		changeKeyButton.addMouseListener(this);
214
		if(isVariabelEncrypted(selectedVariable))
215
		{
216
			if(DatapoolEncryptManager.isDatapoolEncrypted(datapool))
217
				changeKeyButton.setEnabled(true);
218
			checkBox.setSelection(true);
219
			isEncrypted =true;
220
		}
221
		else
222
		{
223
			changeKeyButton.setEnabled(false);
224
			checkBox.setSelection(false);
225
			isEncrypted = false;
226
		}
227
        
190
		nameErrorLabel = new Label(superComposite, SWT.NONE);
228
		nameErrorLabel = new Label(superComposite, SWT.NONE);
191
		// set text to error labels in order to get the proper layout. 
229
		// set text to error labels in order to get the proper layout. 
192
		nameErrorLabel.setText(UiPluginResourceBundle.DATA_DLG_ERROR_INDICATOR + 
230
		nameErrorLabel.setText(UiPluginResourceBundle.DATA_DLG_ERROR_INDICATOR + 
193
								UiPluginResourceBundle.DATA_COL_DLG_ERROR_NAME_NOT_VALID); 
231
								UiPluginResourceBundle.DATA_COL_DLG_ERROR_NAME_NOT_VALID); 
194
		gridData = new GridData(GridData.FILL_HORIZONTAL);
232
		gridData = new GridData(GridData.FILL_HORIZONTAL);
195
		gridData.horizontalSpan = 2;
233
		gridData.horizontalSpan = 2;		
196
		nameErrorLabel.setLayoutData(gridData);
234
		nameErrorLabel.setLayoutData(gridData);
197
		nameErrorLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
235
		nameErrorLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
198
		nameErrorLabel.setVisible(false);
236
		nameErrorLabel.setVisible(false);
199
237
		
200
		typeErrorLabel = new Label(superComposite, SWT.NONE);
238
		typeErrorLabel = new Label(superComposite, SWT.NONE);
201
		typeErrorLabel.setText(UiPluginResourceBundle.DATA_DLG_ERROR_INDICATOR +  
239
		typeErrorLabel.setText(UiPluginResourceBundle.DATA_DLG_ERROR_INDICATOR +  
202
								UiPluginResourceBundle.DATA_COL_DLG_ERROR_TYPE_NOT_VALID); 
240
								UiPluginResourceBundle.DATA_COL_DLG_ERROR_TYPE_NOT_VALID); 
203
		gridData = new GridData(GridData.FILL_HORIZONTAL);
241
		gridData = new GridData(GridData.FILL_HORIZONTAL);
204
		gridData.horizontalSpan = 2;
242
		gridData.horizontalSpan = 2;		
205
		typeErrorLabel.setLayoutData(gridData);
243
		typeErrorLabel.setLayoutData(gridData);
206
		typeErrorLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
244
		typeErrorLabel.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
207
		typeErrorLabel.setVisible(false);
245
		typeErrorLabel.setVisible(false);
208
246
		
209
		superComposite.pack();
247
		superComposite.pack();
210
		return superComposite;
248
		return superComposite;
211
	}
249
	}
Lines 236-242 Link Here
236
		String _name = nameField.getText();
274
		String _name = nameField.getText();
237
		if(_name == null || _name.length() == 0)
275
		if(_name == null || _name.length() == 0)
238
		{
276
		{
239
			enableButton = false;
277
			enableButton = false;			
240
			nameErrorLabel.setVisible(false);
278
			nameErrorLabel.setVisible(false);
241
		}
279
		}
242
		if(_name != null && _name.length() > 0)
280
		if(_name != null && _name.length() > 0)
Lines 245-252 Link Here
245
			boolean isNameValid = DatapoolUtil.getInstance().isVariableNameValid(_name);
283
			boolean isNameValid = DatapoolUtil.getInstance().isVariableNameValid(_name);
246
			if(isNameUnique && isNameValid)
284
			if(isNameUnique && isNameValid)
247
			{		
285
			{		
248
				nameField.setForeground(nameFieldForeground);
286
				nameField.setForeground(nameFieldForeground);				
249
				nameErrorLabel.setVisible(false);
287
				nameErrorLabel.setVisible(false);				
250
			}
288
			}
251
			else
289
			else
252
			{
290
			{
Lines 261-272 Link Here
261
				{
299
				{
262
					nameErrorText += UiPluginResourceBundle.DATA_COL_DLG_ERROR_NAME_NOT_VALID; 
300
					nameErrorText += UiPluginResourceBundle.DATA_COL_DLG_ERROR_NAME_NOT_VALID; 
263
				}
301
				}
264
				nameErrorLabel.setText(nameErrorText);
302
				nameErrorLabel.setText(nameErrorText);				
265
				nameErrorLabel.setVisible(true);
303
				nameErrorLabel.setVisible(true);
266
			}
304
			}
267
		}
305
		}
268
		
306
		
269
		getOKButton().setEnabled(enableButton);
307
		getOKButton().setEnabled(enableButton);
308
		getDialogArea().pack();	
309
		getShell().redraw();
270
		return enableButton;
310
		return enableButton;
271
	}
311
	}
272
	
312
	
Lines 384-387 Link Here
384
		defaultNameCounter++;
424
		defaultNameCounter++;
385
		return NLS.bind(UiPluginResourceBundle.DATA_VARIABLE_NAME, NumberFormat.getInstance().format(defaultNameCounter)); 
425
		return NLS.bind(UiPluginResourceBundle.DATA_VARIABLE_NAME, NumberFormat.getInstance().format(defaultNameCounter)); 
386
	}	
426
	}	
427
	public void mouseDoubleClick(MouseEvent e) {
428
		// TODO Auto-generated method stub
429
		
430
	}
431
432
	public void mouseDown(MouseEvent e) {
433
		// TODO Auto-generated method stub
434
		
435
	}
436
437
	public void mouseUp(MouseEvent e) {
438
		// TODO Auto-generated method stub
439
		Button clickButton = (Button)e.getSource();
440
		if(clickButton == null)
441
		{
442
			return;
443
		}
444
		String title = clickButton.getText();
445
		if(title != null)
446
		{
447
			if(title.equals(UiPluginResourceBundle.DatapoolDialog_ENCRYPTED))
448
			{
449
				dealClickCheckBox(clickButton);
450
			}
451
			else if(title.equals(UiPluginResourceBundle.DatapoolDialog_CHANGEKEY))
452
			{
453
				dealClickChangeKey(clickButton);
454
			}
455
		}
456
		
457
		
458
		
459
	}
460
	private void dealClickCheckBox(Button checkBoxButton)
461
	{
462
		//if(key == null || key.equals(""))
463
		//{
464
		//	isEncrypted = checkBox.getSelection();
465
		//	changeKeyButton.setEnabled(false);
466
		//	return ;
467
		//}
468
		checkBox = checkBoxButton;
469
		isEncrypted = checkBox.getSelection();
470
		if(changeKeyButton != null)
471
		{
472
			if(DatapoolEncryptManager.isDatapoolEncrypted(datapool))
473
				changeKeyButton.setEnabled(isChangeKeyButtonEnable());
474
		}
475
	}
476
	public boolean isEncrypted()
477
	{
478
		return isEncrypted;
479
	}
480
	private void dealClickChangeKey(Button changeKeyButton)
481
	{
482
483
		boolean errorKey = true;
484
		Shell shell = Display.getCurrent().getActiveShell();
485
		DatapoolChangeKeyDialog changeKeyDialog = new DatapoolChangeKeyDialog(shell, datapool, UiPluginResourceBundle.DatapoolDialog_CHANGEKEYDIALOGTITLE);
486
		String key = null;
487
		int retVal = 0;
488
			while(errorKey)
489
			{
490
			if (changeKeyDialog.open() == IDialogConstants.OK_ID) {
491
				
492
				key = changeKeyDialog.getOldKey();
493
				retVal = changeKeyDialog.isKeyChangeSuccess(datapool);
494
				switch(retVal)
495
				{
496
				case DatapoolConstant.ORIGINTKEYERROR:
497
					showErrMes(shell,UiPluginResourceBundle.DatapoolDialog_ORIGINKEYERRORMES);
498
					break;
499
				case DatapoolConstant.NEWKEYNULL:
500
					showErrMes(shell,UiPluginResourceBundle.DatapoolDialog_NEWKEYNULLMES);
501
					break;
502
				case DatapoolConstant.NEWKEYNOTCONFIRM:
503
					showErrMes(shell,UiPluginResourceBundle.DatapoolDialog_NEWKEYNOTCONFIRMMES);
504
					break;
505
				case DatapoolConstant.CHANGEKEYSUCCESS:
506
					newKey = changeKeyDialog.getNewKey();
507
					DatapoolEncryptManager.changeKeyOfEncryCell(datapool, key, newKey);
508
					key = newKey;
509
					try{
510
					DatapoolEncryptManager.changeKey(EncryptionManager.EncoderByMd5(key),
511
							datapool);
512
					}catch(Exception e){						
513
					}
514
					errorKey = false;
515
					isKeyChanged = true;
516
					break;
517
				default://error
518
						errorKey = false;
519
				        isKeyChanged = false;
520
				}
521
			}
522
			else
523
			{
524
				errorKey = false;
525
				isKeyChanged = false;
526
			}
527
528
		}
529
		
530
	}
531
	private void showErrMes(Shell shell,String mes)
532
	{
533
		MessageDialog.openError(shell,UiPluginResourceBundle.DatapoolDialog_ERRORDIALOGTITLE ,mes);
534
	}
535
    private boolean isChangeKeyButtonEnable()
536
    {
537
    	boolean retValue = true;
538
    	if(checkBox != null)
539
    	{
540
    		if(!checkBox.getSelection())
541
    		{
542
    			retValue = false;
543
    		}
544
    			
545
    	}
546
   
547
    	return retValue;	
548
    	
549
    }
550
551
    private boolean isVariabelEncrypted(IDatapoolVariable varible)
552
    {
553
    	return (varible instanceof DPLVariable)?((DPLVariable)varible).isEncrypted():false;
554
    }
555
556
	public String getNewKey() {
557
		return newKey;
558
	}
559
    
560
  
387
}
561
}
(-)src/org/eclipse/hyades/test/ui/internal/resources/UiPluginResourceBundle.java (+31 lines)
Lines 70-76 Link Here
70
	public static String DatapoolImportWizard_PageTwo_useExistingButton;
70
	public static String DatapoolImportWizard_PageTwo_useExistingButton;
71
	public static String DatapoolImportWizard_PageTwo_datapoolsGroup;
71
	public static String DatapoolImportWizard_PageTwo_datapoolsGroup;
72
	public static String DatapoolImportWizard_diffVariableInfoWarning;
72
	public static String DatapoolImportWizard_diffVariableInfoWarning;
73
	public static String DatapoolImportWizard_editOrSelectDatapool;
74
	public static String DatapoolImportWizard_selectCSV;
75
	public static String DatapoolImportWizard_selectDatapool;
76
	public static String DatapoolExportWizard_encrypted;
77
	public static String DatapoolExportWizard_unencrypted;
73
	public static String DatapoolImportWizard_progressMonitor;
78
	public static String DatapoolImportWizard_progressMonitor;
79
	public static String DatapoolExportWizard_wrongpass;
80
	public static String DatapoolExportWizard_rightpass;
81
	public static String DatapoolExportWizard_password;
82
	public static String DatapoolDialog_CHANGEKEY;
83
	public static String DatapoolDialog_ENCRYPTED;
84
	public static String DatapoolDialog_ASSIGNKEYDIALOGTITLE;
85
	public static String DatapoolDialog_CHANGEKEYDIALOGTITLE;
86
	public static String DatapoolDialog_OLDKEY;
87
	public static String DatapoolDialog_NEWKEY;
88
	public static String DatapoolDialog_CONFIRMNEWKEY;
89
	public static String DatapoolDialog_ORIGINKEYERRORMES;
90
	public static String DatapoolDialog_NEWKEYNULLMES;
91
	public static String DatapoolDialog_NEWKEYNOTCONFIRMMES;
92
	public static String DatapoolDialog_WRONGLOGONKEYMES;
93
	public static String DatapoolDialog_ERRORDIALOGTITLE;
94
	public static String DatapoolDialog_KEY;
95
	public static String DatapoolDialog_LOGONDIALOGTITLE;
96
	public static String DatapoolDialog_ENCRYPTEDID;	
97
	public static String DatapoolDialog_ERRORFOREDITENCRYPTEDVALUE;
98
	public static String DatapoolDialog_INPUTKEYDIALGOTITLE;
99
	public static String DatapoolDialog_TRUE;
100
	public static String DatapoolDialog_OK;
101
	public static String DatapoolDialog_PASSWORDSHINT;	
102
	public static String DatapoolDialog_TRYAGAIN;
103
	public static String DatapoolDialog_NOTALLMATCH;
104
	public static String DatapoolDialog_INPUTPASSHINT;
74
	public static String ToggleViewAction_resource_label;
105
	public static String ToggleViewAction_resource_label;
75
	public static String ToggleViewAction_resource_description;
106
	public static String ToggleViewAction_resource_description;
76
	public static String ToggleViewAction_resource_tooltip;
107
	public static String ToggleViewAction_resource_tooltip;
(-)src/org/eclipse/hyades/test/ui/internal/resources/messages.properties (-1 / +29 lines)
Lines 65-72 Link Here
65
DatapoolImportWizard_PageTwo_datapoolsGroup=Datapools
65
DatapoolImportWizard_PageTwo_datapoolsGroup=Datapools
66
DatapoolImportWizard_LocationPage_description=Import data from a CSV file to a new datapool.
66
DatapoolImportWizard_LocationPage_description=Import data from a CSV file to a new datapool.
67
DatapoolImportWizard_diffVariableInfoWarning=The variable (column) name or type information in the datapool are different than the CSV file.
67
DatapoolImportWizard_diffVariableInfoWarning=The variable (column) name or type information in the datapool are different than the CSV file.
68
DatapoolExportWizard_encrypted= {0} is encrypted. Please supply the password.
69
DatapoolExportWizard_unencrypted= {0} is not encrypted. Press Finish to complete.
68
DatapoolImportWizard_progressMonitor=Importing the CSV file
70
DatapoolImportWizard_progressMonitor=Importing the CSV file
69
71
DatapoolExportWizard_wrongpass=Wrong password. Try again or cancel.
72
DatapoolExportWizard_rightpass=You passed. Check Finish to complete.
73
DatapoolExportWizard_password=Password for
74
75
DatapoolDialog_CHANGEKEY=Change Password
76
DatapoolDialog_ENCRYPTED=Encrypted
77
DatapoolDialog_ASSIGNKEYDIALOGTITLE=Assign Password
78
DatapoolDialog_CHANGEKEYDIALOGTITLE=Change Password
79
DatapoolDialog_OLDKEY=Origin Password
80
DatapoolDialog_NEWKEY=New Password
81
DatapoolDialog_CONFIRMNEWKEY=Confirm New Password
82
DatapoolDialog_ORIGINKEYERRORMES=The origin Password is wrong
83
DatapoolDialog_NEWKEYNULLMES=The new Password should not be null
84
DatapoolDialog_NEWKEYNOTCONFIRMMES=The confirm Password is not the same as the new Password
85
DatapoolDialog_WRONGLOGONKEYMES=The Password input is incorrect
86
DatapoolDialog_ERRORDIALOGTITLE=Error
87
DatapoolDialog_KEY=Key
88
DatapoolDialog_LOGONDIALOGTITLE=Log on
89
DatapoolDialog_ENCRYPTEDID=isencrypted
90
DatapoolDialog_ERRORFOREDITENCRYPTEDVALUE=The cell has been encrypted ,please decrypted it before editing
91
DatapoolDialog_INPUTKEYDIALGOTITLE=Input Password
92
DatapoolDialog_TRUE=true
93
DatapoolDialog_OK=OK
94
DatapoolDialog_PASSWORDSHINT=Password for the following are not correct!:\n\n
95
DatapoolDialog_TRYAGAIN=\n\nPlease try again or Cancel
96
DatapoolDialog_NOTALLMATCH=Passwords not all matched!
97
DatapoolDialog_INPUTPASSHINT=Please enter the passwords for each encrypted datapool:
70
ToggleViewAction_resource_label=Resource test navigator
98
ToggleViewAction_resource_label=Resource test navigator
71
ToggleViewAction_resource_description=Show the resource test navigator
99
ToggleViewAction_resource_description=Show the resource test navigator
72
ToggleViewAction_resource_tooltip=Show the resource test navigator
100
ToggleViewAction_resource_tooltip=Show the resource test navigator
(-)src/org/eclipse/hyades/test/ui/datapool/internal/dialog/DatapoolChangeKeyDialog.java (+199 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 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
 * $Id: DatapoolChangeKeyDialog.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.datapool.internal.dialog;
13
14
import org.eclipse.hyades.edit.datapool.IDatapool;
15
import org.eclipse.hyades.models.common.datapool.util.DatapoolEncryptManager;
16
import org.eclipse.hyades.test.ui.datapool.internal.util.GridDataUtil;
17
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
18
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.events.ModifyEvent;
20
import org.eclipse.swt.events.ModifyListener;
21
import org.eclipse.swt.graphics.Color;
22
import org.eclipse.swt.layout.GridData;
23
import org.eclipse.swt.layout.GridLayout;
24
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.swt.widgets.Control;
26
import org.eclipse.swt.widgets.Display;
27
import org.eclipse.swt.widgets.Label;
28
import org.eclipse.swt.widgets.Shell;
29
import org.eclipse.swt.widgets.Text;
30
31
/**
32
 * It's used to provide dialog for key change function .
33
 * 
34
 * @author Huang Xin Ying
35
 */
36
public class DatapoolChangeKeyDialog extends DatapoolBaseDialog implements
37
		ModifyListener {
38
39
	private String title = null;
40
	private Text oldKeyField = null;
41
	private Text newKeyField = null;
42
	private Text confirmKeyField = null;
43
	private String oldKey = null;
44
	private String newKey = null;
45
	private String confirmKey = null;
46
	private Label errorLabel = null;
47
	private IDatapool datapool = null;
48
49
	public DatapoolChangeKeyDialog(Shell parentShell, IDatapool datapool,
50
			String title) {
51
		super(parentShell);
52
		this.datapool = datapool;
53
		this.title = title;
54
	}
55
	
56
	protected void createButtonsForButtonBar(Composite parent) {
57
		super.createButtonsForButtonBar(parent);
58
		getOKButton().setEnabled(false);
59
	}	
60
61
	protected Control createDialogArea(Composite parent) {
62
		getShell().setText(title);
63
		Composite superComposite = (Composite) super.createDialogArea(parent);
64
		GridData gridData = GridDataUtil.createFill();
65
		gridData.minimumWidth = 250;
66
		superComposite.setLayoutData(gridData);
67
68
		GridLayout gridLayout = new GridLayout();
69
		gridLayout.numColumns = 2;
70
		superComposite.setLayout(gridLayout);
71
		if (title
72
				.equals(UiPluginResourceBundle.DatapoolDialog_CHANGEKEYDIALOGTITLE)) {
73
			Label oldKeyLabel = new Label(superComposite, SWT.NONE);
74
			oldKeyLabel.setText(UiPluginResourceBundle.DatapoolDialog_OLDKEY);
75
			oldKeyField = new Text(superComposite, SWT.SINGLE | SWT.BORDER
76
					| SWT.PASSWORD);
77
			gridData = new GridData(GridData.FILL_HORIZONTAL);
78
			oldKeyField.setLayoutData(gridData);
79
			oldKeyField.addModifyListener(this);
80
		}
81
		Label newKeyLabel = new Label(superComposite, SWT.NONE);
82
		newKeyLabel.setText(UiPluginResourceBundle.DatapoolDialog_NEWKEY);
83
		newKeyField = new Text(superComposite, SWT.SINGLE | SWT.BORDER
84
				| SWT.PASSWORD);
85
		gridData = new GridData(GridData.FILL_HORIZONTAL);
86
		newKeyField.setLayoutData(gridData);
87
		newKeyField.addModifyListener(this);
88
89
		Label confirmKeyLabel = new Label(superComposite, SWT.NONE);
90
		confirmKeyLabel
91
				.setText(UiPluginResourceBundle.DatapoolDialog_CONFIRMNEWKEY);
92
		confirmKeyField = new Text(superComposite, SWT.SINGLE | SWT.BORDER
93
				| SWT.PASSWORD);
94
		gridData = new GridData(GridData.FILL_HORIZONTAL);
95
		confirmKeyField.setLayoutData(gridData);		
96
		confirmKeyField.addModifyListener(this);
97
		
98
		errorLabel = new Label(superComposite,SWT.NONE);
99
		gridData = new GridData(GridData.FILL_HORIZONTAL);
100
		gridData.horizontalSpan = 2;
101
		errorLabel.setLayoutData(gridData);
102
		
103
		superComposite.pack();
104
		return superComposite;
105
	}
106
107
	public String getOldKey() {
108
		return oldKey;
109
	}
110
111
	public String getNewKey() {
112
		return newKey;
113
	}
114
115
	public String getConfirmKey() {
116
		return confirmKey;
117
	}	
118
	
119
	public void okPressed(){
120
		int retValue = isKeyChangeSuccess(datapool);
121
		switch(retValue)
122
		{
123
		case DatapoolConstant.ORIGINTKEYERROR:
124
			if(title
125
					.equals(UiPluginResourceBundle.DatapoolDialog_CHANGEKEYDIALOGTITLE)){
126
				showErrMes(UiPluginResourceBundle.DatapoolDialog_ORIGINKEYERRORMES);
127
			}else{
128
				super.okPressed();
129
			}
130
			break;
131
		case DatapoolConstant.NEWKEYNULL:
132
			showErrMes(UiPluginResourceBundle.DatapoolDialog_NEWKEYNULLMES);
133
			break;
134
		case DatapoolConstant.NEWKEYNOTCONFIRM:
135
			showErrMes(UiPluginResourceBundle.DatapoolDialog_NEWKEYNOTCONFIRMMES);
136
			break;
137
		case DatapoolConstant.CHANGEKEYSUCCESS:
138
			super.okPressed();
139
		}
140
	}
141
142
	public int isKeyChangeSuccess(IDatapool datapool) {
143
		int retValue = DatapoolConstant.CHANGEKEYSUCCESS;
144
		if (!DatapoolEncryptManager.isKeyCorrect(datapool, oldKey)) {
145
			retValue = DatapoolConstant.ORIGINTKEYERROR;
146
		} else if (newKey == null || newKey.equals("")) {
147
			retValue = DatapoolConstant.NEWKEYNULL;
148
		} else if (!newKey.equals(confirmKey)) {
149
			retValue = DatapoolConstant.NEWKEYNOTCONFIRM;
150
		}
151
		return retValue;
152
153
	}
154
155
	public int isKeyAssignSuccess() {
156
		int retValue = DatapoolConstant.CHANGEKEYSUCCESS;
157
		if (newKey == null || newKey.equals("")) {
158
			retValue = DatapoolConstant.NEWKEYNULL;
159
		} else if (!newKey.equals(confirmKey)) {
160
			retValue = DatapoolConstant.NEWKEYNOTCONFIRM;
161
		}
162
		return retValue;
163
164
	}
165
166
	public void modifyText(ModifyEvent e) {		
167
		if (oldKeyField != null) {
168
			oldKey = oldKeyField.getText();
169
		}
170
		if (newKeyField != null) {
171
			newKey = newKeyField.getText();
172
		}
173
		if (confirmKeyField != null) {
174
			confirmKey = confirmKeyField.getText();
175
		}
176
		
177
		if(newKey!=null	&& !"".equals(newKey) && confirmKey != null && !"".equals(confirmKey)){
178
			if(title
179
				.equals(UiPluginResourceBundle.DatapoolDialog_CHANGEKEYDIALOGTITLE)){
180
				if(oldKey!=null	&& !"".equals(oldKey)){
181
					getOKButton().setEnabled(true);
182
				}else{
183
					getOKButton().setEnabled(false);
184
				}
185
			}else{
186
				getOKButton().setEnabled(true);
187
			}			
188
		}else{
189
			getOKButton().setEnabled(false);
190
		}
191
	}
192
	
193
	private void showErrMes(String mess){
194
		Color color= Display.getDefault().getSystemColor(SWT.COLOR_RED);
195
		errorLabel.setForeground(color);
196
		errorLabel.setText(mess);
197
	}
198
199
}
(-)src/org/eclipse/hyades/test/ui/datapool/internal/dialog/DatapoolConstant.java (+27 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 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
 * $Id: DatapoolConstant.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
package org.eclipse.hyades.test.ui.datapool.internal.dialog;
13
14
/**
15
* It's used to provide constant message for datapool related dialog .
16
* 
17
* @author Huang Xin Ying 
18
*/
19
public class DatapoolConstant {
20
	public static final int CHANGEKEYSUCCESS = 0;
21
	public static final int ORIGINTKEYERROR = 1;
22
	public static final int NEWKEYNULL = 2;
23
	public static final int NEWKEYNOTCONFIRM = 3;
24
	
25
	public static final String DatapoolDialog_SPLITMARK = "::";
26
	public static final String DatapoolDialog_ENCRYPTEDDISPLAYVALUE = "******";
27
}
(-)src/org/eclipse/hyades/test/ui/datapool/internal/util/EncryptedStringValueClass.java (+40 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 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
 * $Id: EncryptedStringValueClass.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
package org.eclipse.hyades.test.ui.datapool.internal.util;
13
14
import org.eclipse.jface.viewers.TextCellEditor;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.widgets.Composite;
17
import org.eclipse.swt.widgets.Label;
18
19
/**
20
* @author Huang Xin Ying 
21
*/
22
public class EncryptedStringValueClass extends StringValueClass{
23
	public Object getPropertyDisplay(Object theObject, Composite parent, boolean editable)
24
	{
25
		if(editable && theObject != null)
26
		{
27
			TextCellEditor cellEditor = new TextCellEditor(parent,SWT.PASSWORD);
28
29
			cellEditor.setValue(theObject.toString());
30
			return cellEditor;
31
		}
32
		else
33
		{
34
			Label label = new Label(parent, SWT.NONE);
35
			label.setText(getPropertyDescription(theObject));
36
			return label;
37
		}
38
	}
39
40
}
(-)src/org/eclipse/hyades/test/ui/dialog/DatapoolCheck.java (+345 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 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
 * $Id: DatapoolCheck.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
package org.eclipse.hyades.test.ui.dialog;
13
14
import java.util.ArrayList;
15
import java.util.HashMap;
16
import java.util.List;
17
import java.util.Map;
18
19
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
20
import org.eclipse.hyades.models.common.util.EncryptionManager;
21
import org.eclipse.hyades.test.core.launch.extensions.IPassInfoCollector;
22
import org.eclipse.hyades.test.ui.datapool.internal.dialog.DatapoolConstant;
23
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
24
import org.eclipse.jface.dialogs.Dialog;
25
import org.eclipse.jface.dialogs.IDialogConstants;
26
import org.eclipse.jface.dialogs.MessageDialog;
27
import org.eclipse.swt.SWT;
28
import org.eclipse.swt.events.KeyEvent;
29
import org.eclipse.swt.events.KeyListener;
30
import org.eclipse.swt.events.MouseAdapter;
31
import org.eclipse.swt.events.MouseEvent;
32
import org.eclipse.swt.layout.FormAttachment;
33
import org.eclipse.swt.layout.FormData;
34
import org.eclipse.swt.layout.FormLayout;
35
import org.eclipse.swt.widgets.Button;
36
import org.eclipse.swt.widgets.Composite;
37
import org.eclipse.swt.widgets.Control;
38
import org.eclipse.swt.widgets.Display;
39
import org.eclipse.swt.widgets.Label;
40
import org.eclipse.swt.widgets.Shell;
41
import org.eclipse.swt.widgets.Text;
42
43
/**
44
 * 
45
 * It's the implementation of launchDatapoolCheckPass extension point , provide
46
 * dialog to prompt user input password for encrypted datapool during launching a test 
47
 * on workbench side .
48
 * 
49
 * @author Huang Xin Ying 
50
 */
51
public class DatapoolCheck implements IPassInfoCollector {
52
53
	public DatapoolCheck() {
54
	}
55
56
	public void execute(DPLDatapool[] dp, Map pass, List isContinue) {
57
		DialogRun dr = new DialogRun();
58
		dr.setDp(dp);
59
		dr.setContinue(isContinue);
60
		dr.setPass(pass);
61
		Display.getDefault().syncExec(dr);
62
	}
63
64
	private class DialogRun implements Runnable {
65
		private DPLDatapool[] dp;
66
		private Map pass;
67
		private List isContinue;
68
69
		public void setDp(DPLDatapool[] dp) {
70
			this.dp = dp;
71
		}
72
73
		public void setPass(Map pass) {
74
			this.pass = pass;
75
		}
76
77
		public void setContinue(List isContinue) {
78
			this.isContinue = isContinue;
79
		}
80
81
		public void run() {
82
			String testId = null;
83
			if(isContinue != null && isContinue.size() == 1){
84
				testId = (String)isContinue.get(0);
85
				isContinue.clear();
86
			}
87
			DatapoolCheckDialog db = new DatapoolCheckDialog(null, 
88
					dp, 
89
					UiPluginResourceBundle.DatapoolDialog_INPUTKEYDIALGOTITLE,
90
					pass,
91
					testId);
92
			db.setBlockOnOpen(true);
93
			if (db.open() == IDialogConstants.OK_ID) {
94
				isContinue.add(UiPluginResourceBundle.DatapoolDialog_TRUE);
95
			}
96
		}
97
	}
98
    
99
	
100
	private class DatapoolCheckDialog extends Dialog implements KeyListener {
101
		private Button okButton;
102
103
		private Button checkButton;
104
105
		private DPLDatapool[] dp;
106
		private String title;
107
		private int dpNameLength = 0;
108
		private int oriHeight = 0;
109
		private Label[] name;
110
		private Text[] pass;
111
		private Button[] status;
112
		private List unCorrectList = new ArrayList();
113
		private Map passed;
114
		private String testId;
115
116
		/**
117
		 * @param parentShell
118
		 */
119
		public DatapoolCheckDialog(Shell parentShell) {
120
			super(parentShell);
121
		}
122
123
		public DatapoolCheckDialog(Shell parentShell, DPLDatapool[] dp,
124
				String title, Map passed,String testId) {
125
			super(parentShell);
126
			this.dp = dp;
127
			this.title = title;
128
			this.passed = passed;
129
			this.testId = testId;
130
		}
131
132
		/*
133
		 * (non-Javadoc)
134
		 * 
135
		 * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
136
		 */
137
		protected void createButtonsForButtonBar(Composite parent) {
138
			// create OK and Cancel buttons by default
139
			okButton = createButton(parent, IDialogConstants.OK_ID,
140
					IDialogConstants.OK_LABEL, true);
141
			checkButton = createButton(parent, IDialogConstants.YES_ID,
142
					IDialogConstants.YES_LABEL, false);
143
			checkButton.setText(UiPluginResourceBundle.DatapoolDialog_OK);
144
			checkButton.addMouseListener(new MouseAdapter() {
145
				public void mouseDown(MouseEvent e) {
146
					enableOK();
147
				}
148
			});
149
150
			createButton(parent, IDialogConstants.CANCEL_ID,
151
					IDialogConstants.CANCEL_LABEL, false);
152
			okButton.setVisible(false);
153
		}
154
155
		/*
156
		 * (non-Javadoc)
157
		 * 
158
		 * @see org.eclipse.jface.dialogs.Dialog#getButton(int)
159
		 */
160
		protected Button getButton(int id) {
161
			if (id == IDialogConstants.OK_ID)
162
				return okButton;
163
			return super.getButton(id);
164
		}
165
166
		/*
167
		 * (non-Javadoc)
168
		 * 
169
		 * @see org.eclipse.jface.dialogs.Dialog#getOKButton()
170
		 */
171
		protected Button getOKButton() {
172
			return okButton;
173
		}
174
175
		/* modified the content */
176
		protected Control createDialogArea(Composite parent) {
177
			getShell().setText(title);
178
			Composite superComposite = (Composite) super
179
					.createDialogArea(parent);
180
181
			superComposite.setLayout(new FormLayout());
182
183
			FormData formData;
184
185
			Label hint = new Label(superComposite, SWT.NULL);
186
			hint.setText(UiPluginResourceBundle.DatapoolDialog_INPUTPASSHINT);
187
			formData = new FormData();
188
			formData.left = new FormAttachment(superComposite, 5);
189
			formData.top = new FormAttachment(superComposite, 5);
190
			hint.setLayoutData(formData);
191
192
			if (dp != null && dp.length > 0) {
193
194
				name = new Label[dp.length];
195
				pass = new Text[dp.length];
196
				status = new Button[dp.length];
197
198
				name[0] = new Label(superComposite, SWT.NONE);
199
				formData = new FormData();
200
				formData.left = new FormAttachment(superComposite, 5);
201
				formData.top = new FormAttachment(hint, 15);
202
				name[0].setLayoutData(formData);
203
				name[0].setText(getdpNameLength());
204
				name[0].pack();
205
				dpNameLength = name[0].getSize().x;
206
				oriHeight = name[0].getSize().y;
207
				formData.width = dpNameLength;
208
				formData.height = oriHeight;
209
				name[0].setLayoutData(formData);
210
				name[0].setText(dp[0].getName().split(DatapoolConstant.DatapoolDialog_SPLITMARK)[0] + ":");
211
212
				pass[0] = new Text(superComposite, SWT.PASSWORD | SWT.BORDER);
213
				formData = new FormData();
214
				formData.left = new FormAttachment(name[0], 10);
215
				formData.top = new FormAttachment(hint, 15);
216
				formData.width = 90;
217
				formData.height = oriHeight;
218
				pass[0].setLayoutData(formData);
219
				pass[0].addKeyListener(this);
220
221
				status[0] = new Button(superComposite, SWT.CHECK);
222
				formData = new FormData();
223
				formData.left = new FormAttachment(pass[0], 10);
224
				formData.top = new FormAttachment(hint, 15);
225
				formData.height = oriHeight;
226
				status[0].setLayoutData(formData);
227
				status[0].setSelection(false);
228
				status[0].setEnabled(false);
229
				status[0].setVisible(false);
230
231
				for (int i = 1; i < dp.length; i++) {
232
					name[i] = new Label(superComposite, SWT.NONE);
233
					formData = new FormData();
234
					formData.left = new FormAttachment(superComposite, 5);
235
					formData.top = new FormAttachment(name[i - 1], 15);
236
					formData.width = dpNameLength;
237
					formData.height = oriHeight;
238
					name[i].setLayoutData(formData);
239
					name[i].setText(dp[i].getName().split(DatapoolConstant.DatapoolDialog_SPLITMARK)[0] + ":");
240
241
					pass[i] = new Text(superComposite, SWT.PASSWORD
242
							| SWT.BORDER);
243
					formData = new FormData();
244
					formData.left = new FormAttachment(name[i], 10);
245
					formData.top = new FormAttachment(name[i - 1], 15);
246
					formData.width = 90;
247
					formData.height = oriHeight;
248
					pass[i].setLayoutData(formData);
249
					pass[i].addKeyListener(this);
250
251
					status[i] = new Button(superComposite, SWT.CHECK);
252
					formData = new FormData();
253
					formData.left = new FormAttachment(pass[i], 10);
254
					formData.top = new FormAttachment(name[i - 1], 15);
255
					formData.height = oriHeight;
256
					status[i].setLayoutData(formData);
257
					status[i].setSelection(false);
258
					status[i].setEnabled(false);
259
					status[i].setVisible(false);
260
				}
261
			}
262
263
			superComposite.pack();
264
			return superComposite;
265
		}
266
		
267
		private void enableOK(){
268
			// check all the passwords
269
			for (int i = 0; i < dp.length; i++) {
270
				try {
271
					if (status[i].getSelection()) {
272
						continue;
273
					} else if (dp[i].getChallenge().equals(
274
							EncryptionManager.EncoderByMd5(pass[i].getText()))) {
275
						
276
						if(passed.get(testId) == null){
277
							passed.put(testId, new HashMap());
278
						}
279
						HashMap thm = (HashMap)passed.get(testId);
280
						thm.put(dp[i].getName(), pass[i].getText());
281
						
282
						pass[i].setEnabled(false);
283
						status[i].setSelection(true);
284
						if (unCorrectList != null
285
								&& unCorrectList.contains(dp[i])) {
286
							unCorrectList.remove(dp[i]);
287
						}
288
					} else {
289
						pass[i].setText("");
290
						if (!unCorrectList.contains(dp[i]))
291
							unCorrectList.add(dp[i]);
292
					}
293
				} catch (Exception er) {
294
					er.printStackTrace();
295
				}
296
			}
297
			// if all status is true, then set ok button can be pressed
298
			if (unCorrectList.size() == 0) {
299
				okPressed();
300
				return;
301
			}
302
303
			StringBuffer toShow = new StringBuffer();
304
			toShow
305
					.append(UiPluginResourceBundle.DatapoolDialog_PASSWORDSHINT);
306
			for (int i = 0; i < unCorrectList.size(); i++) {
307
				toShow.append(((DPLDatapool) unCorrectList.get(i))
308
						.getName().split(DatapoolConstant.DatapoolDialog_SPLITMARK)[0]);
309
				if (i < unCorrectList.size() - 1) {
310
					toShow.append(",\n");
311
				}
312
			}
313
			toShow.append(UiPluginResourceBundle.DatapoolDialog_TRYAGAIN);
314
315
			MessageDialog dialog = new MessageDialog(null,
316
					UiPluginResourceBundle.DatapoolDialog_NOTALLMATCH, // the dialog title
317
					null, toShow.toString(), // text to be displayed
318
					MessageDialog.WARNING, // dialog type
319
					new String[] { UiPluginResourceBundle.DatapoolDialog_OK }, // button labels
320
					0);
321
			dialog.open();
322
		}
323
324
		private String getdpNameLength() {
325
			
326
			String datapoolName = "";
327
			
328
			for (int counter = 0; counter < dp.length; counter++) {
329
330
				if(dp[counter].getName().length() > datapoolName.length()){
331
					datapoolName = dp[counter].getName();
332
				}
333
			}
334
			
335
			return datapoolName;
336
		}
337
338
		public void keyPressed(KeyEvent e) {}
339
340
		public void keyReleased(KeyEvent e) {
341
			enableOK();			
342
		}
343
	}
344
345
}
(-)src/org/eclipse/hyades/test/ui/datapool/internal/util/EncryptedValueObject.java (+28 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 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
 * $Id: EncryptedValueObject.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
13
package org.eclipse.hyades.test.ui.datapool.internal.util;
14
15
/**
16
* @author Huang Xin Ying 
17
*/
18
public class EncryptedValueObject extends ValueObject{
19
20
	public EncryptedValueObject(Object theObject) {
21
		super(theObject);
22
		valueClass = new EncryptedStringValueClass();
23
		
24
		// TODO Auto-generated constructor stub
25
	}
26
	
27
28
}
(-)src/org/eclipse/hyades/test/ui/datapool/internal/dialog/DatapoolInputKeyDialog.java (+90 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 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
 * $Id: DatapoolInputKeyDialog.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.ui.datapool.internal.dialog;
13
14
import org.eclipse.hyades.test.ui.datapool.internal.util.GridDataUtil;
15
import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.events.KeyEvent;
18
import org.eclipse.swt.events.KeyListener;
19
import org.eclipse.swt.layout.GridData;
20
import org.eclipse.swt.layout.GridLayout;
21
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Control;
23
import org.eclipse.swt.widgets.Label;
24
import org.eclipse.swt.widgets.Shell;
25
import org.eclipse.swt.widgets.Text;
26
27
/**
28
 * It's used to provide dialog for key input function .
29
 * 
30
 * @author Huang Xin Ying
31
 */
32
public class DatapoolInputKeyDialog extends DatapoolBaseDialog implements
33
		KeyListener {
34
35
	private String title;
36
37
	private Text logOnField = null;
38
39
	private String key = "";
40
41
	public DatapoolInputKeyDialog(Shell parentShell, String title) {
42
		super(parentShell);
43
		this.title = title;
44
		// TODO Auto-generated constructor stub
45
	}
46
47
	public void keyPressed(KeyEvent e) {
48
		// TODO Auto-generated method stub
49
50
	}
51
52
	public void keyReleased(KeyEvent e) {
53
		// TODO Auto-generated method stub
54
		if (logOnField != null) {
55
			key = logOnField.getText();
56
		}
57
58
	}
59
60
	protected Control createDialogArea(Composite parent) {
61
		getShell().setText(title);
62
		Composite superComposite = (Composite) super.createDialogArea(parent);
63
		GridData gridData = GridDataUtil.createFill();
64
		gridData.minimumWidth = 250;
65
		superComposite.setLayoutData(gridData);
66
67
		GridLayout gridLayout = new GridLayout();
68
		gridLayout.numColumns = 2;
69
		superComposite.setLayout(gridLayout);
70
71
		Label logOnLabe = new Label(superComposite, SWT.NONE);
72
		logOnLabe
73
				.setText(UiPluginResourceBundle.DatapoolDialog_INPUTKEYDIALGOTITLE);
74
		logOnField = new Text(superComposite, SWT.SINGLE | SWT.BORDER
75
				| SWT.PASSWORD);
76
		gridData = new GridData(GridData.FILL_HORIZONTAL);
77
		logOnField.setLayoutData(gridData);
78
		logOnField.addKeyListener(this);
79
		if (key != null) {
80
			logOnField.setText(key);
81
		}
82
		superComposite.pack();
83
		return superComposite;
84
	}
85
86
	public String getKey() {
87
		return key;
88
	}
89
90
}
(-)src/org/eclipse/hyades/test/core/internal/launch/processes/TestExecutionProcess.java (+3 lines)
Lines 44-49 Link Here
44
import org.eclipse.hyades.test.core.internal.resources.TestCorePluginResourceBundle;
44
import org.eclipse.hyades.test.core.internal.resources.TestCorePluginResourceBundle;
45
import org.eclipse.hyades.test.core.launch.configurations.TestLaunchConfigurationFacade;
45
import org.eclipse.hyades.test.core.launch.configurations.TestLaunchConfigurationFacade;
46
import org.eclipse.hyades.test.core.launch.extensions.IRunHandler;
46
import org.eclipse.hyades.test.core.launch.extensions.IRunHandler;
47
import org.eclipse.hyades.test.core.testservices.resources.PasswordCollection;
47
48
48
/**
49
/**
49
 * Fake process that represents a Hyades Execution Session. The lifecycle of
50
 * Fake process that represents a Hyades Execution Session. The lifecycle of
Lines 146-151 Link Here
146
147
147
	protected synchronized void onTerminate() {
148
	protected synchronized void onTerminate() {
148
		if (!terminated) {
149
		if (!terminated) {
150
			//remove the dps and passwords from passwordCollection
151
			PasswordCollection.getInstance().clear(test.getImplementor().getId());
149
			// Notify the run handler (if any)
152
			// Notify the run handler (if any)
150
			IRunHandler runHandler = LaunchConfigurationExtensionsManager.getInstance().getRunHandler(test);
153
			IRunHandler runHandler = LaunchConfigurationExtensionsManager.getInstance().getRunHandler(test);
151
			if (runHandler != null) {
154
			if (runHandler != null) {
(-)plugin.xml (+19 lines)
Lines 32-37 Link Here
32
   <extension-point id="RecorderApplication" name="%RecorderApplication" schema="schema/RecorderAppAdapter.exsd"/>
32
   <extension-point id="RecorderApplication" name="%RecorderApplication" schema="schema/RecorderAppAdapter.exsd"/>
33
   <extension-point id="Recorder" name="%Recorder" schema="schema/Recorder.exsd"/>
33
   <extension-point id="Recorder" name="%Recorder" schema="schema/Recorder.exsd"/>
34
   <extension-point id="executionHarnessListener" name="%executionHarnessListener" schema="schema/executionHarnessListener.exsd"/>
34
   <extension-point id="executionHarnessListener" name="%executionHarnessListener" schema="schema/executionHarnessListener.exsd"/>
35
   <extension-point id="launchconfigDatapoolHandler" name="launchconfigDatapoolHandler" schema="schema/launchconfigDatapoolHandler.exsd"/>
36
   <extension-point id="launchDatapoolCheckPass" name="check passwords while launching" schema="schema/launchDatapoolCheckPass.exsd"/>
35
37
36
   <extension
38
   <extension
37
         id="org.eclipse.hyades.execution.harness.RegisteredExecutionComponentImpl.JAVA"
39
         id="org.eclipse.hyades.execution.harness.RegisteredExecutionComponentImpl.JAVA"
Lines 216-220 Link Here
216
       point="org.eclipse.hyades.execution.testService">
218
       point="org.eclipse.hyades.execution.testService">
217
    <testService class="org.eclipse.hyades.test.core.testservices.resources.FilesystemResourceProviderService"/>
219
    <testService class="org.eclipse.hyades.test.core.testservices.resources.FilesystemResourceProviderService"/>
218
 </extension>
220
 </extension>
221
 <extension
222
       point="org.eclipse.hyades.test.core.launchconfigDatapoolHandler">
223
    <launchconfigDatapoolHandler
224
          class="org.eclipse.hyades.test.core.internal.launch.datapool.extensions.JUnitLaunchconfigDatapoolHandler">
225
       <supportedTestType
226
             name="org.eclipse.hyades.test.java.junit.testSuite">
227
       </supportedTestType>
228
    </launchconfigDatapoolHandler>
229
 </extension>
230
 <extension
231
       id="DatapoolPasswordProvider"
232
       name="DatapoolPasswordProvider"
233
       point="org.eclipse.hyades.execution.testService">
234
    <testService
235
          class="org.eclipse.hyades.test.core.testservices.resources.DatapoolPasswordsService">
236
    </testService>
237
 </extension>
219
238
220
</plugin>
239
</plugin>
(-)src/org/eclipse/hyades/test/core/launch/delegates/AbstractLaunchConfigurationDelegate2.java (-1 / +27 lines)
Lines 12-17 Link Here
12
package org.eclipse.hyades.test.core.launch.delegates;
12
package org.eclipse.hyades.test.core.launch.delegates;
13
13
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.HashMap;
15
import java.util.Iterator;
16
import java.util.Iterator;
16
import java.util.List;
17
import java.util.List;
17
18
Lines 27-39 Link Here
27
import org.eclipse.emf.ecore.resource.ResourceSet;
28
import org.eclipse.emf.ecore.resource.ResourceSet;
28
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
29
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
29
import org.eclipse.hyades.execution.core.IExecutor;
30
import org.eclipse.hyades.execution.core.IExecutor;
31
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
30
import org.eclipse.hyades.test.core.TestCorePlugin;
32
import org.eclipse.hyades.test.core.TestCorePlugin;
33
import org.eclipse.hyades.test.core.internal.launch.datapool.extensions.LaunchDatapoolExtensionManager;
31
import org.eclipse.hyades.test.core.internal.launch.extensions.LaunchConfigurationExtensionsManager;
34
import org.eclipse.hyades.test.core.internal.launch.extensions.LaunchConfigurationExtensionsManager;
32
import org.eclipse.hyades.test.core.internal.launch.processes.TestExecutionProcess;
35
import org.eclipse.hyades.test.core.internal.launch.processes.TestExecutionProcess;
33
import org.eclipse.hyades.test.core.internal.resources.TestCorePluginResourceBundle;
36
import org.eclipse.hyades.test.core.internal.resources.TestCorePluginResourceBundle;
37
import org.eclipse.hyades.test.core.launch.configurations.DeploymentLaunchConfigurationFacade;
38
import org.eclipse.hyades.test.core.launch.configurations.TestLaunchConfigurationFacade;
39
import org.eclipse.hyades.test.core.launch.extensions.ILaunchconfigDatapoolHandler;
40
import org.eclipse.hyades.test.core.launch.extensions.IPassInfoCollector;
34
import org.eclipse.hyades.test.core.launch.extensions.IRunHandler;
41
import org.eclipse.hyades.test.core.launch.extensions.IRunHandler;
35
import org.eclipse.hyades.test.core.launch.extensions.IRunHandler2;
42
import org.eclipse.hyades.test.core.launch.extensions.IRunHandler2;
36
import org.eclipse.hyades.test.core.launch.extensions.ITestLaunchConfigurationValidator;
43
import org.eclipse.hyades.test.core.launch.extensions.ITestLaunchConfigurationValidator;
44
import org.eclipse.hyades.test.core.testservices.resources.PasswordCollection;
37
import org.eclipse.osgi.util.NLS;
45
import org.eclipse.osgi.util.NLS;
38
46
39
/**
47
/**
Lines 185-194 Link Here
185
	    		}
193
	    		}
186
	    	}
194
	    	}
187
			
195
			
196
	    	// find the datapools which is encrypted   	
197
	    	ILaunchconfigDatapoolHandler datapoolHandler = LaunchDatapoolExtensionManager.getInstance().getRunHandler(getLaunchedElement(configuration));
198
			DPLDatapool[] dp = null;
199
			if(datapoolHandler != null){
200
				dp = datapoolHandler.getAllDatapools(TestLaunchConfigurationFacade.getTest(configuration, getResourceSet()), 
201
						DeploymentLaunchConfigurationFacade.getDeployment(configuration, getResourceSet()));				
202
			}
203
			HashMap pass = PasswordCollection.getInstance().getDatapoolPassword();
204
			
205
			// show a dialog to collect the passwords
206
			if(dp!=null && dp.length > 0){
207
				IPassInfoCollector collector = LaunchDatapoolExtensionManager.getInstance().getCollector(getLaunchedElement(configuration));
208
				List isContinue = new ArrayList();
209
				isContinue.add(TestLaunchConfigurationFacade.getTest(configuration, getResourceSet()).getImplementor().getId());
210
				collector.execute(dp, pass, isContinue);
211
				if(isContinue.size()==0)				
212
					return;
213
			}				
188
			// Invoke the Test Execution Harness
214
			// Invoke the Test Execution Harness
189
			StringBuffer errorMessages = new StringBuffer();
215
			StringBuffer errorMessages = new StringBuffer();
190
			IExecutor executor = null;
216
			IExecutor executor = null;
191
			try {
217
			try {				
192
				executor = invokeTestExecutionHarness(configuration, mode, errorMessages, new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
218
				executor = invokeTestExecutionHarness(configuration, mode, errorMessages, new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
193
				if (errorMessages.length() > 0) {
219
				if (errorMessages.length() > 0) {
194
					IStatus status = new Status(IStatus.ERROR, TestCorePlugin.getPluginId(), 0, TestCorePluginResourceBundle._EXC_AbstractLaunchConfigurationDelegate_testHarnessProblems + errorMessages, null); 
220
					IStatus status = new Status(IStatus.ERROR, TestCorePlugin.getPluginId(), 0, TestCorePluginResourceBundle._EXC_AbstractLaunchConfigurationDelegate_testHarnessProblems + errorMessages, null); 
(-)META-INF/MANIFEST.MF (+1 lines)
Lines 21-26 Link Here
21
 org.eclipse.hyades.test.core,
21
 org.eclipse.hyades.test.core,
22
 org.eclipse.hyades.test.core.internal,
22
 org.eclipse.hyades.test.core.internal,
23
 org.eclipse.hyades.test.core.internal.changes,
23
 org.eclipse.hyades.test.core.internal.changes,
24
 org.eclipse.hyades.test.core.internal.launch.datapool.extensions,
24
 org.eclipse.hyades.test.core.internal.launch.debug,
25
 org.eclipse.hyades.test.core.internal.launch.debug,
25
 org.eclipse.hyades.test.core.internal.launch.extensions,
26
 org.eclipse.hyades.test.core.internal.launch.extensions,
26
 org.eclipse.hyades.test.core.internal.launch.processes,
27
 org.eclipse.hyades.test.core.internal.launch.processes,
(-)src/org/eclipse/hyades/test/core/internal/launch/datapool/extensions/LaunchDatapoolExtensionManager.java (+199 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 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
 * $Id: LaunchDatapoolExtensionManager.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
package org.eclipse.hyades.test.core.internal.launch.datapool.extensions;
13
14
import java.util.HashMap;
15
import java.util.Map;
16
17
import org.eclipse.core.runtime.CoreException;
18
import org.eclipse.core.runtime.IConfigurationElement;
19
import org.eclipse.core.runtime.IExtensionPoint;
20
import org.eclipse.core.runtime.Platform;
21
import org.eclipse.hyades.models.common.testprofile.TPFTest;
22
import org.eclipse.hyades.test.core.TestCorePlugin;
23
import org.eclipse.hyades.test.core.launch.extensions.ILaunchconfigDatapoolHandler;
24
import org.eclipse.hyades.test.core.launch.extensions.IPassInfoCollector;
25
26
/**
27
 * It's used to manage extensions for launchconfigDatapoolHandler and 
28
 * launchDatapoolCheckPass extension points ,based on the type of each test .
29
 * 
30
 * @author Huang Xin Ying 
31
 *
32
 */
33
public class LaunchDatapoolExtensionManager {
34
35
	private static LaunchDatapoolExtensionManager instance;
36
37
	public static LaunchDatapoolExtensionManager getInstance() {
38
		if (instance == null) {
39
			instance = new LaunchDatapoolExtensionManager();
40
		}
41
		return instance;
42
	}
43
44
	private LaunchDatapoolExtensionManager() {
45
		registerDatapoolHandlers();
46
		registerCheckPass();
47
	}
48
49
	private Map datapoolHandlerExtensionMap = new HashMap();
50
51
	public ILaunchconfigDatapoolHandler getRunHandler(Object testElement) {
52
		LaunchDatapoolExtensionDescriper ed = getLaunchDatapoolDescriptor(testElement);
53
		if (ed != null) {
54
			return ed.getRunHandler();
55
		}
56
		return null;
57
	}
58
	
59
	public IPassInfoCollector getCollector(Object testElement) {
60
		LaunchDatapoolExtensionDescriper ed = getLaunchDatapoolDescriptor(testElement);
61
		if (ed != null && ed.getCollector()!= null) 
62
			return ed.getCollector();
63
64
		return getExtensionDescriptor("default").getCollector();
65
	}
66
67
	private void registerDatapoolHandlers() {
68
		IExtensionPoint extPoint = Platform.getExtensionRegistry()
69
				.getExtensionPoint(
70
						TestCorePlugin.getPluginId()
71
								+ ".launchconfigDatapoolHandler");
72
		if (extPoint != null) {
73
			IConfigurationElement[] datapoolHandlers = extPoint
74
					.getConfigurationElements();
75
			for (int i = 0; i < datapoolHandlers.length; i++) {
76
				IConfigurationElement[] supportedTypes = datapoolHandlers[i]
77
						.getChildren();
78
				for (int j = 0; j < supportedTypes.length; j++) {
79
					String type = supportedTypes[j].getAttribute("name"); //$NON-NLS-1$					
80
					try {
81
						LaunchDatapoolExtensionDescriper ed = getExtensionDescriptor(type);
82
						ed.launchDatapoolConfigElem = datapoolHandlers[i];
83
					} catch (Exception e) {
84
						TestCorePlugin
85
								.getDefault()
86
								.logError(
87
										"Extension "
88
												+ datapoolHandlers[i].getName()
89
												+ " was ignored. See next messages for details.");
90
						TestCorePlugin.getDefault().logError(e);
91
					}
92
				}
93
			}
94
		}
95
	}
96
	
97
	private void registerCheckPass() {
98
		IExtensionPoint extPoint = Platform.getExtensionRegistry()
99
				.getExtensionPoint(
100
						TestCorePlugin.getPluginId()
101
								+ ".launchDatapoolCheckPass");
102
		if (extPoint != null) {
103
			IConfigurationElement[] datapoolHandlers = extPoint
104
					.getConfigurationElements();
105
			for (int i = 0; i < datapoolHandlers.length; i++) {
106
				IConfigurationElement[] supportedTypes = datapoolHandlers[i]
107
						.getChildren();
108
				for (int j = 0; j < supportedTypes.length; j++) {
109
					String type = supportedTypes[j].getAttribute("name"); //$NON-NLS-1$	
110
					if(type == null || type.equals(""))
111
						type = "default";
112
					try {
113
						LaunchDatapoolExtensionDescriper ed = getExtensionDescriptor(type);
114
						ed.CheckPassConfigElem = datapoolHandlers[i];
115
					} catch (Exception e) {
116
						TestCorePlugin
117
								.getDefault()
118
								.logError(
119
										"Extension "
120
												+ datapoolHandlers[i].getName()
121
												+ " was ignored. See next messages for details.");
122
						TestCorePlugin.getDefault().logError(e);
123
					}
124
				}
125
			}
126
		}
127
	}
128
129
	private LaunchDatapoolExtensionDescriper getExtensionDescriptor(String type) {
130
131
		if (type == null) {
132
			throw new NullPointerException("Type must be non-null"); //$NON-NLS-1$
133
		}
134
135
		Object o = datapoolHandlerExtensionMap.get(type);
136
		if (o == null) {
137
			o = new LaunchDatapoolExtensionDescriper();
138
			datapoolHandlerExtensionMap.put(type, o);
139
		}
140
		return (LaunchDatapoolExtensionDescriper) o;
141
	}
142
143
	private LaunchDatapoolExtensionDescriper getLaunchDatapoolDescriptor(
144
			Object testElement) {
145
		if (testElement != null) {
146
			if (testElement instanceof TPFTest) {
147
				TPFTest test = (TPFTest) testElement;
148
				if (test.getType() != null) {
149
					return getExtensionDescriptor(test.getType());
150
				}
151
			}
152
		}
153
		return null;
154
	}
155
156
	private class LaunchDatapoolExtensionDescriper {
157
		public IConfigurationElement launchDatapoolConfigElem = null;
158
		public IConfigurationElement CheckPassConfigElem = null;
159
		private ILaunchconfigDatapoolHandler hanler = null;
160
		private IPassInfoCollector collector = null;
161
		public String launchConfigurationType = null;
162
163
		public ILaunchconfigDatapoolHandler getRunHandler() {
164
			if (this.hanler == null) {
165
				if (this.launchDatapoolConfigElem != null) {
166
					try {
167
						this.hanler = (ILaunchconfigDatapoolHandler) this.launchDatapoolConfigElem
168
								.createExecutableExtension("class"); //$NON-NLS-1$
169
					} catch (CoreException e) {
170
						TestCorePlugin.getDefault().logError(e);
171
						this.launchDatapoolConfigElem = null;
172
					}
173
				}
174
			}
175
			return this.hanler;
176
		}
177
		
178
		public IPassInfoCollector getCollector() {
179
			if (this.collector == null) {
180
				if (this.CheckPassConfigElem != null) {
181
					try {
182
						this.collector = (IPassInfoCollector) this.CheckPassConfigElem
183
								.createExecutableExtension("UIClass"); //$NON-NLS-1$
184
					} catch (CoreException e) {
185
						TestCorePlugin.getDefault().logError(e);
186
						this.CheckPassConfigElem = null;
187
					}
188
				}
189
			}
190
			return this.collector;
191
		}
192
193
		public boolean isLaunchConfigurationTypeSupported(String lcType) {
194
			return (this.launchConfigurationType == lcType)
195
					|| (lcType != null && lcType
196
							.equals(this.launchConfigurationType));
197
		}
198
	}
199
}
(-)src/org/eclipse/hyades/test/core/launch/extensions/IPassInfoCollector.java (+28 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 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
 * $Id: IPassInfoCollector.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
package org.eclipse.hyades.test.core.launch.extensions;
13
14
import java.util.List;
15
import java.util.Map;
16
17
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
18
19
/**
20
*  
21
* It's the interface for the launchDatapoolCheckPass extension point.
22
* @author Huang Xin Ying 
23
*
24
*/
25
public interface IPassInfoCollector {
26
	
27
	void execute(DPLDatapool[] dp, Map pass, List isContinue);
28
}
(-)src/org/eclipse/hyades/test/core/launch/extensions/ILaunchconfigDatapoolHandler.java (+30 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 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
 * $Id: ILaunchconfigDatapoolHandler.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
13
package org.eclipse.hyades.test.core.launch.extensions;
14
15
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
16
import org.eclipse.hyades.models.common.testprofile.TPFDeployment;
17
import org.eclipse.hyades.models.common.testprofile.TPFTest;
18
19
/**
20
*  
21
* It's the interface for the  launchconfigDatapoolHandler extension point.
22
* 
23
* @author Huang Xin Ying 
24
*
25
*/
26
public interface ILaunchconfigDatapoolHandler {
27
	
28
	public	DPLDatapool[] getAllDatapools(TPFTest test, TPFDeployment deploy);
29
30
}
(-)src/org/eclipse/hyades/test/core/testservices/resources/DatapoolPasswordsService.java (+60 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 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
 * $Id: DatapoolPasswordsService.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
package org.eclipse.hyades.test.core.testservices.resources;
13
14
import java.util.HashMap;
15
import java.util.Iterator;
16
import java.util.Map;
17
import java.util.regex.Matcher;
18
import java.util.regex.Pattern;
19
20
import org.eclipse.hyades.execution.local.testservices.AbstractTestService;
21
import org.eclipse.hyades.execution.local.testservices.ITestService;
22
import org.eclipse.hyades.internal.execution.local.control.Agent;
23
24
/**
25
*  
26
* It's the class of DatapoolPasswordsService ,used to provide list of datapool and it's encryption 
27
* password to the agent controller side .
28
* @author Huang Xin Ying 
29
*
30
*/
31
public class DatapoolPasswordsService extends AbstractTestService implements ITestService{
32
	
33
	/**
34
	 * @param agent
35
	 * @param methodArgs
36
	 * @param errBuf
37
	 * @return
38
	 */
39
	public String getDatapoolList(Agent agent, String methodArgs, StringBuffer errBuf){
40
		Pattern pattern = Pattern.compile("testId=(.*)"); //$NON-NLS-1$
41
		Matcher matcher = pattern.matcher(methodArgs);
42
		String testId = null;
43
		if (matcher.find()) {
44
			testId = matcher.group(1);
45
		}
46
		HashMap data = PasswordCollection.getInstance().getDatapoolPassword(testId);
47
		
48
		if(data == null || data.size() == 0)
49
			return null;
50
		
51
		StringBuffer result = new StringBuffer();
52
		
53
		for( Iterator it = data.entrySet().iterator();it.hasNext();){
54
			Map.Entry entry = (Map.Entry)it.next();
55
			result.append(entry.getKey() + "=" + entry.getValue() + ";");
56
		}
57
		
58
		return result.toString();
59
	}	
60
}
(-)src/org/eclipse/hyades/test/core/internal/launch/datapool/extensions/JUnitLaunchconfigDatapoolHandler.java (+74 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 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
 * $Id: JUnitLaunchconfigDatapoolHandler.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
13
package org.eclipse.hyades.test.core.internal.launch.datapool.extensions;
14
15
import java.util.ArrayList;
16
import java.util.Iterator;
17
import java.util.List;
18
19
import org.eclipse.hyades.models.common.configuration.CFGArtifactLocationPair;
20
import org.eclipse.hyades.models.common.configuration.CFGClass;
21
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
22
import org.eclipse.hyades.models.common.testprofile.TPFDeployment;
23
import org.eclipse.hyades.models.common.testprofile.TPFTest;
24
import org.eclipse.hyades.test.core.launch.extensions.ILaunchconfigDatapoolHandler;
25
26
27
/**
28
 * This class runs on the workbench, and provides the workbench side 
29
 * implementation of the launchconfigDatapoolHandler extension point.
30
 * 
31
 * It's used to get datapool[] from test or delpoy for Junit test type .
32
 * 
33
 * @author Huang Xin Ying 
34
 *
35
 */
36
public class JUnitLaunchconfigDatapoolHandler implements
37
		ILaunchconfigDatapoolHandler {
38
	
39
	/**
40
	 * @param test,deploy
41
	 * @return DPLDatapool[]
42
	 */
43
	public DPLDatapool[] getAllDatapools(TPFTest test, TPFDeployment deploy) {
44
		if(deploy == null)
45
			return null;
46
		
47
		List keyList = new ArrayList();
48
		List pairs = deploy.getArtifactLocations();
49
		
50
		if(pairs == null)
51
			return null;
52
		for(Iterator iti = pairs.iterator();iti.hasNext();){
53
			CFGArtifactLocationPair aflp = (CFGArtifactLocationPair)iti.next();
54
			if(aflp == null)
55
				continue;
56
			if(aflp.getArtifact() == null)
57
				continue;
58
			List deploys = aflp.getArtifact().getDeployableInstances();
59
			if(deploys == null)
60
				continue;
61
			for(Iterator it=deploys.iterator();it.hasNext();){
62
				CFGClass cfg = (CFGClass)it.next();
63
				if(cfg instanceof DPLDatapool && ((DPLDatapool)cfg).getChallenge()!= null){					
64
					keyList.add(cfg);
65
				}
66
			}			
67
		}
68
		
69
		if(keyList.size() == 0)			
70
			return null;		
71
	
72
		return (DPLDatapool[])(keyList.toArray(new DPLDatapool[]{}));
73
	}
74
}
(-)schema/launchconfigDatapoolHandler.exsd (+135 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.hyades.test.core">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.hyades.test.core" id="launchconfigDatapoolHandler" name="launchconfigDatapoolHandler"/>
7
      </appInfo>
8
      <documentation>
9
         This extension point provides a mechanism to get datapool model for each test type when launching a test case .
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <complexType>
15
         <sequence>
16
            <element ref="launchconfigDatapoolHandler"/>
17
         </sequence>
18
         <attribute name="point" type="string" use="required">
19
            <annotation>
20
               <documentation>
21
                  
22
               </documentation>
23
            </annotation>
24
         </attribute>
25
         <attribute name="id" type="string">
26
            <annotation>
27
               <documentation>
28
                  
29
               </documentation>
30
            </annotation>
31
         </attribute>
32
         <attribute name="name" type="string">
33
            <annotation>
34
               <documentation>
35
                  
36
               </documentation>
37
               <appInfo>
38
                  <meta.attribute translatable="true"/>
39
               </appInfo>
40
            </annotation>
41
         </attribute>
42
      </complexType>
43
   </element>
44
45
   <element name="launchconfigDatapoolHandler">
46
      <complexType>
47
         <sequence>
48
            <element ref="supportedTestType"/>
49
         </sequence>
50
         <attribute name="class" type="string" use="required">
51
            <annotation>
52
               <documentation>
53
                  
54
               </documentation>
55
            </annotation>
56
         </attribute>
57
      </complexType>
58
   </element>
59
60
   <element name="supportedTestType">
61
      <complexType>
62
         <attribute name="name" type="string" use="required">
63
            <annotation>
64
               <documentation>
65
                  
66
               </documentation>
67
            </annotation>
68
         </attribute>
69
      </complexType>
70
   </element>
71
72
   <annotation>
73
      <appInfo>
74
         <meta.section type="since"/>
75
      </appInfo>
76
      <documentation>
77
         [4.5 ]
78
      </documentation>
79
   </annotation>
80
81
   <annotation>
82
      <appInfo>
83
         <meta.section type="examples"/>
84
      </appInfo>
85
      <documentation>
86
         The following example associates a DatapoolHandler class with tests of type org.eclipse.hyades.test.:
87
88
&lt;pre&gt;
89
90
 &lt;extension
91
92
       point=&quot;org.eclipse.hyades.test.core.launchconfigDatapoolHandler&quot;&gt;
93
94
    &lt;launchconfigDatapoolHandler class=&quot; &quot;&gt;
95
96
       &lt;supportedType
97
98
             name =&quot;  &quot;/&gt;
99
100
    &lt;/runHandler&gt;
101
102
 &lt;/extension&gt;
103
104
&lt;/pre&gt;
105
      </documentation>
106
   </annotation>
107
108
   <annotation>
109
      <appInfo>
110
         <meta.section type="apiInfo"/>
111
      </appInfo>
112
      <documentation>
113
         [org.eclipse.hyades.test.core.launch.extensions.ILaunchconfigDatapoolHandler]
114
      </documentation>
115
   </annotation>
116
117
   <annotation>
118
      <appInfo>
119
         <meta.section type="implementation"/>
120
      </appInfo>
121
      <documentation>
122
         [Enter information about supplied implementation of this extension point.]
123
      </documentation>
124
   </annotation>
125
126
   <annotation>
127
      <appInfo>
128
         <meta.section type="copyright"/>
129
      </appInfo>
130
      <documentation>
131
         
132
      </documentation>
133
   </annotation>
134
135
</schema>
(-)src/org/eclipse/hyades/test/core/testservices/resources/PasswordCollection.java (+75 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 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
 * $Id: PasswordCollection.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
13
package org.eclipse.hyades.test.core.testservices.resources;
14
15
16
17
import java.util.HashMap;
18
19
/**
20
 * This class runs on the workbench, and used to save HashMap of
21
 *  datapool & password for this datapool during luaching  tests .
22
 *  
23
 * It's supposed to support mult-lauch on the workbench side . 
24
 *  
25
 * @author Xin Ying Huang
26
 *
27
 */
28
public class PasswordCollection {
29
	
30
	private static PasswordCollection instance = null;
31
	private HashMap datapoolPassword = new HashMap();
32
	
33
	
34
	private PasswordCollection(){}
35
	
36
	/**
37
	 * @param 
38
	 * @return PasswordCollection
39
	 */
40
	public static PasswordCollection getInstance(){
41
		if(instance == null){
42
			instance = new PasswordCollection();
43
		}
44
		return instance;
45
	}	
46
   
47
	/**
48
	 * @param 
49
	 * @return HashMap
50
	 */
51
	public HashMap getDatapoolPassword() {
52
		return datapoolPassword;
53
	}
54
	
55
	/**
56
	 * @param  testId
57
	 * @return HashMap
58
	 */
59
	public HashMap getDatapoolPassword(String testId){
60
		if(testId == null)
61
			return null;
62
		return (HashMap)datapoolPassword.get(testId);
63
	}
64
	
65
	/**
66
	 * @param  testId
67
	 * @return HashMap
68
	 */
69
	public void clear(String testId){
70
		if(testId == null)
71
			return;
72
		datapoolPassword.remove(testId);
73
		return;
74
	}
75
}
(-)schema/launchDatapoolCheckPass.exsd (+140 lines)
Added Link Here
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!-- Schema file written by PDE -->
3
<schema targetNamespace="org.eclipse.hyades.test.core">
4
<annotation>
5
      <appInfo>
6
         <meta.schema plugin="org.eclipse.hyades.test.core" id="launchDatapoolCheckPass" name="check passwords while launching"/>
7
      </appInfo>
8
      <documentation>
9
         [Used to collect password for each enctypted datapool which used in current test on workbench side .]
10
      </documentation>
11
   </annotation>
12
13
   <element name="extension">
14
      <complexType>
15
         <sequence>
16
            <element ref="launchDatapoolCheckPass"/>
17
         </sequence>
18
         <attribute name="point" type="string" use="required">
19
            <annotation>
20
               <documentation>
21
                  
22
               </documentation>
23
            </annotation>
24
         </attribute>
25
         <attribute name="id" type="string">
26
            <annotation>
27
               <documentation>
28
                  
29
               </documentation>
30
            </annotation>
31
         </attribute>
32
         <attribute name="name" type="string">
33
            <annotation>
34
               <documentation>
35
                  
36
               </documentation>
37
               <appInfo>
38
                  <meta.attribute translatable="true"/>
39
               </appInfo>
40
            </annotation>
41
         </attribute>
42
      </complexType>
43
   </element>
44
45
   <element name="launchDatapoolCheckPass">
46
      <complexType>
47
         <sequence>
48
            <element ref="supportedTestType"/>
49
         </sequence>
50
         <attribute name="UIClass" type="string" use="required">
51
            <annotation>
52
               <documentation>
53
                  
54
               </documentation>
55
            </annotation>
56
         </attribute>
57
      </complexType>
58
   </element>
59
60
   <element name="supportedTestType">
61
      <complexType>
62
         <attribute name="name" type="string" use="default" value="">
63
            <annotation>
64
               <documentation>
65
                  
66
               </documentation>
67
            </annotation>
68
         </attribute>
69
      </complexType>
70
   </element>
71
72
   <annotation>
73
      <appInfo>
74
         <meta.section type="since"/>
75
      </appInfo>
76
      <documentation>
77
         [4.5.]
78
      </documentation>
79
   </annotation>
80
81
   <annotation>
82
      <appInfo>
83
         <meta.section type="examples"/>
84
      </appInfo>
85
      <documentation>
86
         [  &lt;element name=&quot;extension&quot;&gt;
87
      &lt;complexType&gt;
88
         &lt;sequence&gt;
89
            &lt;element ref=&quot;launchDatapoolCheckPass&quot;/&gt;
90
         &lt;/sequence&gt;
91
         &lt;attribute name=&quot;point&quot; type=&quot;string&quot; use=&quot;required&quot;&gt;
92
            &lt;annotation&gt;
93
               &lt;documentation&gt;
94
                  
95
               &lt;/documentation&gt;
96
            &lt;/annotation&gt;
97
         &lt;/attribute&gt;
98
         &lt;attribute name=&quot;id&quot; type=&quot;string&quot;&gt;
99
            &lt;annotation&gt;
100
               &lt;documentation&gt;
101
                  
102
               &lt;/documentation&gt;
103
            &lt;/annotation&gt;
104
         &lt;/attribute&gt;
105
         &lt;attribute name=&quot;name&quot; type=&quot;string&quot;&gt;
106
            &lt;annotation&gt;
107
               &lt;documentation&gt;
108
                  
109
               &lt;/documentation&gt;
110
               &lt;appInfo&gt;
111
                  &lt;meta.attribute translatable=&quot;true&quot;/&gt;
112
               &lt;/appInfo&gt;
113
            &lt;/annotation&gt;
114
         &lt;/attribute&gt;
115
      &lt;/complexType&gt;
116
   &lt;/element&gt;
117
.]
118
      </documentation>
119
   </annotation>
120
121
   <annotation>
122
      <appInfo>
123
         <meta.section type="apiInfo"/>
124
      </appInfo>
125
      <documentation>
126
         [org.eclipse.hyades.test.core.launch.extensions.IPassInfoCollector .]
127
      </documentation>
128
   </annotation>
129
130
   <annotation>
131
      <appInfo>
132
         <meta.section type="implementation"/>
133
      </appInfo>
134
      <documentation>
135
         [Enter information about supplied implementation of this extension point.]
136
      </documentation>
137
   </annotation>
138
139
140
</schema>
(-)src-common-runner/org/eclipse/hyades/test/common/runner/HyadesRunner.java (+11 lines)
Lines 22-33 Link Here
22
import org.eclipse.hyades.internal.execution.remote.AgentControllerUnavailableException;
22
import org.eclipse.hyades.internal.execution.remote.AgentControllerUnavailableException;
23
import org.eclipse.hyades.internal.execution.remote.CustomCommandHandler;
23
import org.eclipse.hyades.internal.execution.remote.CustomCommandHandler;
24
import org.eclipse.hyades.internal.execution.remote.RemoteComponentSkeleton;
24
import org.eclipse.hyades.internal.execution.remote.RemoteComponentSkeleton;
25
import org.eclipse.hyades.models.common.datapool.util.DPLPasswordCollection;
25
import org.eclipse.hyades.models.common.facades.behavioral.impl.FacadeResourceFactoryImpl;
26
import org.eclipse.hyades.models.common.facades.behavioral.impl.FacadeResourceFactoryImpl;
26
import org.eclipse.hyades.models.common.testprofile.impl.Common_TestprofilePackageImpl;
27
import org.eclipse.hyades.models.common.testprofile.impl.Common_TestprofilePackageImpl;
27
import org.eclipse.hyades.test.common.agent.ComptestAgent;
28
import org.eclipse.hyades.test.common.agent.ComptestAgent;
28
import org.eclipse.hyades.test.common.agent.PrimaryTestAgent;
29
import org.eclipse.hyades.test.common.agent.PrimaryTestAgent;
29
import org.eclipse.hyades.test.common.agent.ServiceCommandHandler;
30
import org.eclipse.hyades.test.common.agent.ServiceCommandHandler;
31
import org.eclipse.hyades.test.common.agent.UnknownTestServiceException;
30
import org.eclipse.hyades.test.common.event.ExecutionEvent;
32
import org.eclipse.hyades.test.common.event.ExecutionEvent;
33
import org.eclipse.hyades.test.common.testservices.resources.DatapoolPasswordProvider;
31
34
32
/**
35
/**
33
 * @author jsutton
36
 * @author jsutton
Lines 234-239 Link Here
234
				}
237
				}
235
			}
238
			}
236
		}
239
		}
240
		//set password to Models
241
		try {
242
			DPLPasswordCollection.getInstance().
243
			setDatapoolPassword(DatapoolPasswordProvider.getDatapoolPassword(testID));
244
		} catch (UnknownTestServiceException e) {			
245
		}
237
246
238
	}
247
	}
239
	
248
	
Lines 246-251 Link Here
246
	};
255
	};
247
	
256
	
248
	public void dispose() {
257
	public void dispose() {
258
		//clear the passwords in Models
259
		DPLPasswordCollection.getInstance().clear();
249
		if (agent != null && agent.isRegistered()) {
260
		if (agent != null && agent.isRegistered()) {
250
			Runtime.getRuntime().removeShutdownHook(disposeOnExitHook);
261
			Runtime.getRuntime().removeShutdownHook(disposeOnExitHook);
251
			agent.deregister();
262
			agent.deregister();
(-)src/org/eclipse/hyades/test/tools/core/internal/java/codegen/GenTestSuiteConstructor.java (-12 / +1 lines)
Lines 1-14 Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2008 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
 * $Id: GenTestSuiteConstructor.java,v 1.18 2008/02/28 17:04:24 jkubasta Exp $
8
 * 
9
 * Contributors: 
10
 * IBM Corporation - initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.hyades.test.tools.core.internal.java.codegen;
1
package org.eclipse.hyades.test.tools.core.internal.java.codegen;
13
2
14
import org.eclipse.hyades.test.tools.core.internal.common.codegen.Helper;
3
import org.eclipse.hyades.test.tools.core.internal.common.codegen.Helper;
Lines 24-30 Link Here
24
    return result;
13
    return result;
25
  }
14
  }
26
15
27
  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
16
  protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
28
  protected final String TEXT_1 = "\t\t";
17
  protected final String TEXT_1 = "\t\t";
29
  protected final String TEXT_2 = NL;
18
  protected final String TEXT_2 = NL;
30
  protected final String TEXT_3 = "\t/**" + NL + "\t * Constructor for ";
19
  protected final String TEXT_3 = "\t/**" + NL + "\t * Constructor for ";
(-)src/org/eclipse/hyades/test/tools/core/internal/java/codegen/GenTestSuite.java (-46 / +37 lines)
Lines 1-14 Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2008 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
 * $Id: GenTestSuite.java,v 1.27 2008/02/28 17:04:24 jkubasta Exp $
8
 * 
9
 * Contributors: 
10
 * IBM Corporation - initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.hyades.test.tools.core.internal.java.codegen;
1
package org.eclipse.hyades.test.tools.core.internal.java.codegen;
13
2
14
import java.util.Iterator;
3
import java.util.Iterator;
Lines 30-60 Link Here
30
    return result;
19
    return result;
31
  }
20
  }
32
21
33
  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
22
  protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
34
  protected final String TEXT_1 = "\t\t";
23
  protected final String TEXT_1 = "\t\t";
35
  protected final String TEXT_2 = NL + "package ";
24
  protected final String TEXT_2 = NL;
36
  protected final String TEXT_3 = ";";
25
  protected final String TEXT_3 = NL + "package ";
37
  protected final String TEXT_4 = NL;
26
  protected final String TEXT_4 = ";";
38
  protected final String TEXT_5 = NL + NL + "/**" + NL + " * Generated code for the test suite <b>";
27
  protected final String TEXT_5 = NL;
39
  protected final String TEXT_6 = "</b> located at" + NL + " * <i>";
28
  protected final String TEXT_6 = NL + NL + "/**" + NL + " * Generated code for the test suite <b>";
40
  protected final String TEXT_7 = "</i>";
29
  protected final String TEXT_7 = "</b> located at" + NL + " * <i>";
41
  protected final String TEXT_8 = ".";
30
  protected final String TEXT_8 = "</i>";
42
  protected final String TEXT_9 = NL + " *" + NL + " * ";
31
  protected final String TEXT_9 = ".";
43
  protected final String TEXT_10 = NL + " */" + NL + "public class ";
32
  protected final String TEXT_10 = NL + " *" + NL + " * ";
44
  protected final String TEXT_11 = NL + "extends ";
33
  protected final String TEXT_11 = NL + " */" + NL + "public class ";
45
  protected final String TEXT_12 = NL + "{";
34
  protected final String TEXT_12 = NL + "extends ";
46
  protected final String TEXT_13 = NL;
35
  protected final String TEXT_13 = NL + "{";
47
  protected final String TEXT_14 = NL + "\t" + NL + "\t/**" + NL + "\t * @see junit.framework.TestCase#setUp()" + NL + "\t */" + NL + "\tprotected void setUp()" + NL + "\tthrows ";
36
  protected final String TEXT_14 = NL;
48
  protected final String TEXT_15 = NL + "\t{" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @see junit.framework.TestCase#tearDown()" + NL + "\t */" + NL + "\tprotected void tearDown()" + NL + "\tthrows ";
37
  protected final String TEXT_15 = NL + "\t" + NL + "\t/**" + NL + "\t * @see junit.framework.TestCase#setUp()" + NL + "\t */" + NL + "\tprotected void setUp()" + NL + "\tthrows ";
49
  protected final String TEXT_16 = NL + "\t{" + NL + "\t}\t";
38
  protected final String TEXT_16 = NL + "\t{" + NL + "\t}" + NL + "" + NL + "\t/**" + NL + "\t * @see junit.framework.TestCase#tearDown()" + NL + "\t */" + NL + "\tprotected void tearDown()" + NL + "\tthrows ";
50
  protected final String TEXT_17 = NL;
39
  protected final String TEXT_17 = NL + "\t{" + NL + "\t}\t";
51
  protected final String TEXT_18 = NL + "}";
40
  protected final String TEXT_18 = NL;
52
  protected final String TEXT_19 = NL;
41
  protected final String TEXT_19 = NL + "}";
42
  protected final String TEXT_20 = NL;
53
43
54
	public String generate(ITestSuite testSuite, final Helper helper)
44
	public String generate(ITestSuite testSuite, final Helper helper)
55
  {
45
  {
56
    final StringBuffer stringBuffer = new StringBuffer();
46
    final StringBuffer stringBuffer = new StringBuffer();
57
    stringBuffer.append(TEXT_1);
47
    stringBuffer.append(TEXT_1);
48
    stringBuffer.append(TEXT_2);
58
    
49
    
59
	String packageName = helper.getPackageName(testSuite);
50
	String packageName = helper.getPackageName(testSuite);
60
	String className = helper.retrieveClassName(testSuite);
51
	String className = helper.retrieveClassName(testSuite);
Lines 68-78 Link Here
68
	helper.getImportedName(packageName + "." + className);
59
	helper.getImportedName(packageName + "." + className);
69
60
70
     if (!packageName.equals("")) { 
61
     if (!packageName.equals("")) { 
71
    stringBuffer.append(TEXT_2);
72
    stringBuffer.append(packageName);
73
    stringBuffer.append(TEXT_3);
62
    stringBuffer.append(TEXT_3);
74
     } 
63
    stringBuffer.append(packageName);
75
    stringBuffer.append(TEXT_4);
64
    stringBuffer.append(TEXT_4);
65
     } 
66
    stringBuffer.append(TEXT_5);
76
    
67
    
77
	helper.addImport(helper.getSuperclassName());
68
	helper.addImport(helper.getSuperclassName());
78
	helper.markImportLocation(stringBuffer);
69
	helper.markImportLocation(stringBuffer);
Lines 81-117 Link Here
81
	String exceptionClassName = helper.getImportedName(Helper.EXCEPTION_CLASS_NAME);
72
	String exceptionClassName = helper.getImportedName(Helper.EXCEPTION_CLASS_NAME);
82
	String filePath = helper.getFilePath(testSuite);
73
	String filePath = helper.getFilePath(testSuite);
83
74
84
    stringBuffer.append(TEXT_5);
75
    stringBuffer.append(TEXT_6);
85
    stringBuffer.append(testSuite.getName());
76
    stringBuffer.append(testSuite.getName());
86
    if(filePath != null){
77
    if(filePath != null){
87
    stringBuffer.append(TEXT_6);
88
    stringBuffer.append(filePath);
89
    stringBuffer.append(TEXT_7);
78
    stringBuffer.append(TEXT_7);
90
    }
79
    stringBuffer.append(filePath);
91
    stringBuffer.append(TEXT_8);
80
    stringBuffer.append(TEXT_8);
92
    if(description.length() > 0){
81
    }
93
    stringBuffer.append(TEXT_9);
82
    stringBuffer.append(TEXT_9);
83
    if(description.length() > 0){
84
    stringBuffer.append(TEXT_10);
94
    stringBuffer.append(description);
85
    stringBuffer.append(description);
95
    }
86
    }
96
    stringBuffer.append(TEXT_10);
97
    stringBuffer.append(className);
98
    stringBuffer.append(TEXT_11);
87
    stringBuffer.append(TEXT_11);
99
    stringBuffer.append(superclassName);
88
    stringBuffer.append(className);
100
    stringBuffer.append(TEXT_12);
89
    stringBuffer.append(TEXT_12);
90
    stringBuffer.append(superclassName);
91
    stringBuffer.append(TEXT_13);
101
    
92
    
102
	GenTestSuiteConstructor constructorGenerator = new GenTestSuiteConstructor();
93
	GenTestSuiteConstructor constructorGenerator = new GenTestSuiteConstructor();
103
	stringBuffer.append(constructorGenerator.generate(className, helper));
94
	stringBuffer.append(constructorGenerator.generate(className, helper));
104
95
105
    stringBuffer.append(TEXT_13);
96
    stringBuffer.append(TEXT_14);
106
    
97
    
107
	GenSuiteMethod suiteMethodGenerator = new GenSuiteMethod();
98
	GenSuiteMethod suiteMethodGenerator = new GenSuiteMethod();
108
	stringBuffer.append(suiteMethodGenerator.generate(testSuite, helper));
99
	stringBuffer.append(suiteMethodGenerator.generate(testSuite, helper));
109
100
110
    stringBuffer.append(TEXT_14);
111
    stringBuffer.append(exceptionClassName);
112
    stringBuffer.append(TEXT_15);
101
    stringBuffer.append(TEXT_15);
113
    stringBuffer.append(exceptionClassName);
102
    stringBuffer.append(exceptionClassName);
114
    stringBuffer.append(TEXT_16);
103
    stringBuffer.append(TEXT_16);
104
    stringBuffer.append(exceptionClassName);
105
    stringBuffer.append(TEXT_17);
115
    
106
    
116
	for(Iterator i=testSuite.getITestCases().iterator(); i.hasNext();)
107
	for(Iterator i=testSuite.getITestCases().iterator(); i.hasNext();)
117
	{
108
	{
Lines 120-129 Link Here
120
		stringBuffer.append(generator.generate(testCase, helper));
111
		stringBuffer.append(generator.generate(testCase, helper));
121
	}
112
	}
122
113
123
    stringBuffer.append(TEXT_17);
124
    stringBuffer.append(TEXT_18);
114
    stringBuffer.append(TEXT_18);
125
    helper.emitSortedImports();
126
    stringBuffer.append(TEXT_19);
115
    stringBuffer.append(TEXT_19);
116
    helper.emitSortedImports();
117
    stringBuffer.append(TEXT_20);
127
    
118
    
128
    return stringBuffer.toString();
119
    return stringBuffer.toString();
129
  }
120
  }
(-)src/org/eclipse/hyades/test/tools/core/internal/java/codegen/GenTestMethod.java (-30 / +21 lines)
Lines 1-14 Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2008 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
 * $Id: GenTestMethod.java,v 1.25 2008/02/28 17:04:24 jkubasta Exp $
8
 * 
9
 * Contributors: 
10
 * IBM Corporation - initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.hyades.test.tools.core.internal.java.codegen;
1
package org.eclipse.hyades.test.tools.core.internal.java.codegen;
13
2
14
import org.eclipse.hyades.models.common.facades.behavioral.ITestCase;
3
import org.eclipse.hyades.models.common.facades.behavioral.ITestCase;
Lines 26-47 Link Here
26
    return result;
15
    return result;
27
  }
16
  }
28
17
29
  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
18
  protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
30
  protected final String TEXT_1 = "\t\t";
19
  protected final String TEXT_1 = "\t\t";
31
  protected final String TEXT_2 = NL + "\t/**" + NL + "\t * ";
20
  protected final String TEXT_2 = NL;
32
  protected final String TEXT_3 = NL + "\t *" + NL + "\t * ";
21
  protected final String TEXT_3 = NL + "\t/**" + NL + "\t * ";
33
  protected final String TEXT_4 = NL + "\t * ";
22
  protected final String TEXT_4 = NL + "\t *" + NL + "\t * ";
34
  protected final String TEXT_5 = NL + "\t * @throws ";
23
  protected final String TEXT_5 = NL + "\t * ";
35
  protected final String TEXT_6 = NL + "\t */" + NL + "\tpublic void ";
24
  protected final String TEXT_6 = NL + "\t * @throws ";
36
  protected final String TEXT_7 = "()" + NL + "\tthrows ";
25
  protected final String TEXT_7 = NL + "\t */" + NL + "\tpublic void ";
37
  protected final String TEXT_8 = NL + "\t{" + NL + "\t\t";
26
  protected final String TEXT_8 = "()" + NL + "\tthrows ";
38
  protected final String TEXT_9 = NL + "\t}" + NL + "\t" + NL;
27
  protected final String TEXT_9 = NL + "\t{" + NL + "\t\t";
39
  protected final String TEXT_10 = NL;
28
  protected final String TEXT_10 = NL + "\t}" + NL + "\t" + NL;
29
  protected final String TEXT_11 = NL;
40
30
41
	public String generate(ITestCase testCase, final Helper helper)
31
	public String generate(ITestCase testCase, final Helper helper)
42
  {
32
  {
43
    final StringBuffer stringBuffer = new StringBuffer();
33
    final StringBuffer stringBuffer = new StringBuffer();
44
    stringBuffer.append(TEXT_1);
34
    stringBuffer.append(TEXT_1);
35
    stringBuffer.append(TEXT_2);
45
    
36
    
46
	class MethodBodyGenerator
37
	class MethodBodyGenerator
47
	{
38
	{
Lines 64-89 Link Here
64
		String description = testCase.getDescription();
55
		String description = testCase.getDescription();
65
		description = StringUtil.replace(description, NL, NL + " * ");	
56
		description = StringUtil.replace(description, NL, NL + " * ");	
66
57
67
    stringBuffer.append(TEXT_2);
58
    stringBuffer.append(TEXT_3);
68
    stringBuffer.append(testCase.getName());
59
    stringBuffer.append(testCase.getName());
69
    if(description != null){
60
    if(description != null){
70
    stringBuffer.append(TEXT_3);
71
    stringBuffer.append(description);
72
    stringBuffer.append(TEXT_4);
61
    stringBuffer.append(TEXT_4);
73
    }
62
    stringBuffer.append(description);
74
    stringBuffer.append(TEXT_5);
63
    stringBuffer.append(TEXT_5);
75
    stringBuffer.append(exceptionClassName);
64
    }
76
    stringBuffer.append(TEXT_6);
65
    stringBuffer.append(TEXT_6);
77
    stringBuffer.append(identifier);
78
    stringBuffer.append(TEXT_7);
79
    stringBuffer.append(exceptionClassName);
66
    stringBuffer.append(exceptionClassName);
67
    stringBuffer.append(TEXT_7);
68
    stringBuffer.append(identifier);
80
    stringBuffer.append(TEXT_8);
69
    stringBuffer.append(TEXT_8);
81
    stringBuffer.append(code);
70
    stringBuffer.append(exceptionClassName);
82
    stringBuffer.append(TEXT_9);
71
    stringBuffer.append(TEXT_9);
72
    stringBuffer.append(code);
73
    stringBuffer.append(TEXT_10);
83
    
74
    
84
	}
75
	}
85
76
86
    stringBuffer.append(TEXT_10);
77
    stringBuffer.append(TEXT_11);
87
    
78
    
88
    return stringBuffer.toString();
79
    return stringBuffer.toString();
89
  }
80
  }
(-)src/org/eclipse/hyades/test/tools/core/internal/java/codegen/GenSuiteMethod.java (-46 / +37 lines)
Lines 1-14 Link Here
1
/**********************************************************************
2
 * Copyright (c) 2005, 2008 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
 * $Id: GenSuiteMethod.java,v 1.26 2008/02/28 17:04:24 jkubasta Exp $
8
 * 
9
 * Contributors: 
10
 * IBM Corporation - initial API and implementation
11
 **********************************************************************/
12
package org.eclipse.hyades.test.tools.core.internal.java.codegen;
1
package org.eclipse.hyades.test.tools.core.internal.java.codegen;
13
2
14
import java.util.Iterator;
3
import java.util.Iterator;
Lines 33-62 Link Here
33
    return result;
22
    return result;
34
  }
23
  }
35
24
36
  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
25
  protected final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
37
  protected final String TEXT_1 = "\t\t";
26
  protected final String TEXT_1 = "\t\t";
38
  protected final String TEXT_2 = NL + "/**" + NL + " * Returns the JUnit test suite that implements the <b>";
27
  protected final String TEXT_2 = NL;
39
  protected final String TEXT_3 = "</b>" + NL + " * definition." + NL + " */" + NL + "public static ";
28
  protected final String TEXT_3 = NL + "/**" + NL + " * Returns the JUnit test suite that implements the <b>";
40
  protected final String TEXT_4 = " suite()" + NL + "{";
29
  protected final String TEXT_4 = "</b>" + NL + " * definition." + NL + " */" + NL + "public static ";
41
  protected final String TEXT_5 = "\t";
30
  protected final String TEXT_5 = " suite()" + NL + "{";
42
  protected final String TEXT_6 = " ";
31
  protected final String TEXT_6 = "\t";
43
  protected final String TEXT_7 = " = new ";
32
  protected final String TEXT_7 = " ";
44
  protected final String TEXT_8 = "(\"";
33
  protected final String TEXT_8 = " = new ";
45
  protected final String TEXT_9 = "\");" + NL + "\t";
34
  protected final String TEXT_9 = "(\"";
46
  protected final String TEXT_10 = ".setArbiter(DefaultTestArbiter.INSTANCE).setId(\"";
35
  protected final String TEXT_10 = "\");" + NL + "\t";
47
  protected final String TEXT_11 = "\");" + NL + "\t" + NL + "\t";
36
  protected final String TEXT_11 = ".setArbiter(DefaultTestArbiter.INSTANCE).setId(\"";
48
  protected final String TEXT_12 = "\t";
37
  protected final String TEXT_12 = "\");" + NL + "\t" + NL + "\t";
49
  protected final String TEXT_13 = " ";
38
  protected final String TEXT_13 = "\t";
50
  protected final String TEXT_14 = " = new ";
39
  protected final String TEXT_14 = " ";
51
  protected final String TEXT_15 = "(";
40
  protected final String TEXT_15 = " = new ";
52
  protected final String TEXT_16 = ".class);";
41
  protected final String TEXT_16 = "(";
53
  protected final String TEXT_17 = NL + "\treturn ";
42
  protected final String TEXT_17 = ".class);";
54
  protected final String TEXT_18 = ";" + NL + "}" + NL;
43
  protected final String TEXT_18 = NL + "\treturn ";
44
  protected final String TEXT_19 = ";" + NL + "}" + NL;
55
45
56
	public String generate(ITestSuite testSuite, final Helper helper)
46
	public String generate(ITestSuite testSuite, final Helper helper)
57
  {
47
  {
58
    final StringBuffer stringBuffer = new StringBuffer();
48
    final StringBuffer stringBuffer = new StringBuffer();
59
    stringBuffer.append(TEXT_1);
49
    stringBuffer.append(TEXT_1);
50
    stringBuffer.append(TEXT_2);
60
    
51
    
61
	class InvocationGenerator
52
	class InvocationGenerator
62
	{
53
	{
Lines 176-225 Link Here
176
	testSuiteClassName = helper.getImportedName(testSuiteClassName);
167
	testSuiteClassName = helper.getImportedName(testSuiteClassName);
177
	final String junitTestClassName = helper.getImportedName(Helper.JUNIT_TEST_CLASS_NAME);
168
	final String junitTestClassName = helper.getImportedName(Helper.JUNIT_TEST_CLASS_NAME);
178
169
179
    stringBuffer.append(TEXT_2);
180
    stringBuffer.append(testSuite.getName());
181
    stringBuffer.append(TEXT_3);
170
    stringBuffer.append(TEXT_3);
182
    stringBuffer.append(junitTestClassName);
171
    stringBuffer.append(testSuite.getName());
183
    stringBuffer.append(TEXT_4);
172
    stringBuffer.append(TEXT_4);
173
    stringBuffer.append(junitTestClassName);
174
    stringBuffer.append(TEXT_5);
184
    
175
    
185
	String javaElement = helper.retrieveIdentifierName(testSuite, "SUITE"); 
176
	String javaElement = helper.retrieveIdentifierName(testSuite, "SUITE"); 
186
177
187
	if (!isCodeBehavior) {
178
	if (!isCodeBehavior) {
188
		String code = new InvocationGenerator(testSuiteClassName).generate(javaElement, testSuite.getImplementor().getBlock().getActions()).toString();
179
		String code = new InvocationGenerator(testSuiteClassName).generate(javaElement, testSuite.getImplementor().getBlock().getActions()).toString();
189
180
190
    stringBuffer.append(TEXT_5);
191
    stringBuffer.append(testSuiteClassName);
192
    stringBuffer.append(TEXT_6);
181
    stringBuffer.append(TEXT_6);
193
    stringBuffer.append(javaElement);
194
    stringBuffer.append(TEXT_7);
195
    stringBuffer.append(testSuiteClassName);
182
    stringBuffer.append(testSuiteClassName);
183
    stringBuffer.append(TEXT_7);
184
    stringBuffer.append(javaElement);
196
    stringBuffer.append(TEXT_8);
185
    stringBuffer.append(TEXT_8);
197
    stringBuffer.append(testSuite.getName());
186
    stringBuffer.append(testSuiteClassName);
198
    stringBuffer.append(TEXT_9);
187
    stringBuffer.append(TEXT_9);
199
    stringBuffer.append(javaElement);
188
    stringBuffer.append(testSuite.getName());
200
    stringBuffer.append(TEXT_10);
189
    stringBuffer.append(TEXT_10);
201
    stringBuffer.append(testSuite.getId());
190
    stringBuffer.append(javaElement);
202
    stringBuffer.append(TEXT_11);
191
    stringBuffer.append(TEXT_11);
192
    stringBuffer.append(testSuite.getId());
193
    stringBuffer.append(TEXT_12);
203
    stringBuffer.append(code);
194
    stringBuffer.append(code);
204
    
195
    
205
	} else {
196
	} else {
206
		String className = helper.retrieveClassName(testSuite);
197
		String className = helper.retrieveClassName(testSuite);
207
198
208
    stringBuffer.append(TEXT_12);
209
    stringBuffer.append(testSuiteClassName);
210
    stringBuffer.append(TEXT_13);
199
    stringBuffer.append(TEXT_13);
211
    stringBuffer.append(javaElement);
212
    stringBuffer.append(TEXT_14);
213
    stringBuffer.append(testSuiteClassName);
200
    stringBuffer.append(testSuiteClassName);
201
    stringBuffer.append(TEXT_14);
202
    stringBuffer.append(javaElement);
214
    stringBuffer.append(TEXT_15);
203
    stringBuffer.append(TEXT_15);
215
    stringBuffer.append(className);
204
    stringBuffer.append(testSuiteClassName);
216
    stringBuffer.append(TEXT_16);
205
    stringBuffer.append(TEXT_16);
206
    stringBuffer.append(className);
207
    stringBuffer.append(TEXT_17);
217
    
208
    
218
	}
209
	}
219
210
220
    stringBuffer.append(TEXT_17);
221
    stringBuffer.append(javaElement);
222
    stringBuffer.append(TEXT_18);
211
    stringBuffer.append(TEXT_18);
212
    stringBuffer.append(javaElement);
213
    stringBuffer.append(TEXT_19);
223
    
214
    
224
    return stringBuffer.toString();
215
    return stringBuffer.toString();
225
  }
216
  }
(-).settings/org.eclipse.core.resources.prefs (+3 lines)
Added Link Here
1
#Mon Mar 10 16:37:47 CST 2008
2
eclipse.preferences.version=1
3
encoding//src-common-runner/org/eclipse/hyades/test/common/util/XMLUtil.java=ISO-8859-1
(-)src-common-runner/org/eclipse/hyades/test/common/testservices/resources/DatapoolPasswordProvider.java (+75 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 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
 * $Id: DatapoolPasswordProvider.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/
12
package org.eclipse.hyades.test.common.testservices.resources;
13
14
import java.util.HashMap;
15
16
import org.eclipse.hyades.test.common.agent.ServiceInvoker;
17
import org.eclipse.hyades.test.common.agent.UnconfiguredComptestAgentException;
18
import org.eclipse.hyades.test.common.agent.UnknownTestServiceException;
19
20
/**
21
 * 
22
 * It's the client of DatapoolPasswordsService ,used to get list of datapool and
23
 * it's encryption password from workbench side.
24
 * 
25
 * @author Huang Xin Ying
26
 * 
27
 */
28
public class DatapoolPasswordProvider {
29
30
	protected static final String DATAPOOL_PASSWORD_PROVIDER = "org.eclipse.hyades.test.core.DatapoolPasswordProvider";
31
32
	/**
33
	 * @param testId
34
	 * @return
35
	 */
36
	public static HashMap getDatapoolPassword(String testId)
37
			throws UnknownTestServiceException {
38
		String result = null;
39
		try {
40
41
			result = ServiceInvoker.invokeService(getProviderName(),
42
					"method=getDatapoolList,args:testId={0}".concat(testId));
43
44
		} catch (UnconfiguredComptestAgentException e) {
45
			throw new UnknownTestServiceException(e);
46
		}
47
48
		return parseResult(result);
49
	}
50
51
	/**
52
	 * @param result
53
	 * @return
54
	 */
55
	private static HashMap parseResult(String result) {
56
		if (result == null)
57
			return null;
58
59
		HashMap pr = new HashMap();
60
		if (result.indexOf(";") > 0) {
61
			String[] pairs = result.split(";");
62
			for (int i = 0; i < pairs.length; i++) {
63
				if (pairs[i].indexOf("=")>0) {
64
					pr.put(pairs[i].split("=")[0], pairs[i].split("=")[1]);
65
				}
66
			}
67
		}
68
69
		return pr;
70
	}
71
72
	public static String getProviderName() {
73
		return DATAPOOL_PASSWORD_PROVIDER;
74
	}
75
}
(-)src-test/org/eclipse/hyades/models/common/datapool/impl/DPLVariableImpl.java (+59 lines)
Lines 48-53 Link Here
48
 * <ul>
48
 * <ul>
49
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLVariableImpl#getType <em>Type</em>}</li>
49
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLVariableImpl#getType <em>Type</em>}</li>
50
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLVariableImpl#getRole <em>Role</em>}</li>
50
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLVariableImpl#getRole <em>Role</em>}</li>
51
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLVariableImpl#isEncrypted <em>Encrypted</em>}</li>
51
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLVariableImpl#getVariables <em>Variables</em>}</li>
52
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLVariableImpl#getVariables <em>Variables</em>}</li>
52
 * </ul>
53
 * </ul>
53
 * </p>
54
 * </p>
Lines 105-110 Link Here
105
	protected DPLRole role = ROLE_EDEFAULT;
106
	protected DPLRole role = ROLE_EDEFAULT;
106
107
107
	/**
108
	/**
109
	 * The default value of the '{@link #isEncrypted() <em>Encrypted</em>}' attribute.
110
	 * <!-- begin-user-doc -->
111
	 * <!-- end-user-doc -->
112
	 * @see #isEncrypted()
113
	 * @generated
114
	 * @ordered
115
	 */
116
	protected static final boolean ENCRYPTED_EDEFAULT = false;
117
118
	/**
119
	 * The cached value of the '{@link #isEncrypted() <em>Encrypted</em>}' attribute.
120
	 * <!-- begin-user-doc -->
121
	 * <!-- end-user-doc -->
122
	 * @see #isEncrypted()
123
	 * @generated
124
	 * @ordered
125
	 */
126
	protected boolean encrypted = ENCRYPTED_EDEFAULT;
127
128
	/**
108
	 * The cached value of the '{@link #getVariables() <em>Variables</em>}' containment reference list.
129
	 * The cached value of the '{@link #getVariables() <em>Variables</em>}' containment reference list.
109
	 * <!-- begin-user-doc -->
130
	 * <!-- begin-user-doc -->
110
	 * <!-- end-user-doc -->
131
	 * <!-- end-user-doc -->
Lines 179-184 Link Here
179
	 * <!-- end-user-doc -->
200
	 * <!-- end-user-doc -->
180
	 * @generated
201
	 * @generated
181
	 */
202
	 */
203
	public boolean isEncrypted() {
204
		return encrypted;
205
	}
206
207
	/**
208
	 * <!-- begin-user-doc -->
209
	 * <!-- end-user-doc -->
210
	 * @generated
211
	 */
212
	public void setEncrypted(boolean newEncrypted) {
213
		boolean oldEncrypted = encrypted;
214
		encrypted = newEncrypted;
215
		if (eNotificationRequired())
216
			eNotify(new ENotificationImpl(this, Notification.SET, Common_DatapoolPackage.DPL_VARIABLE__ENCRYPTED, oldEncrypted, encrypted));
217
	}
218
219
	/**
220
	 * <!-- begin-user-doc -->
221
	 * <!-- end-user-doc -->
222
	 * @generated
223
	 */
182
	public EList getVariables() {
224
	public EList getVariables() {
183
		if (variables == null) {
225
		if (variables == null) {
184
			variables = new EObjectContainmentEList(DPLVariable.class, this, Common_DatapoolPackage.DPL_VARIABLE__VARIABLES);
226
			variables = new EObjectContainmentEList(DPLVariable.class, this, Common_DatapoolPackage.DPL_VARIABLE__VARIABLES);
Lines 210-215 Link Here
210
				return getType();
252
				return getType();
211
			case Common_DatapoolPackage.DPL_VARIABLE__ROLE:
253
			case Common_DatapoolPackage.DPL_VARIABLE__ROLE:
212
				return getRole();
254
				return getRole();
255
			case Common_DatapoolPackage.DPL_VARIABLE__ENCRYPTED:
256
				return isEncrypted() ? Boolean.TRUE : Boolean.FALSE;
213
			case Common_DatapoolPackage.DPL_VARIABLE__VARIABLES:
257
			case Common_DatapoolPackage.DPL_VARIABLE__VARIABLES:
214
				return getVariables();
258
				return getVariables();
215
		}
259
		}
Lines 229-234 Link Here
229
			case Common_DatapoolPackage.DPL_VARIABLE__ROLE:
273
			case Common_DatapoolPackage.DPL_VARIABLE__ROLE:
230
				setRole((DPLRole)newValue);
274
				setRole((DPLRole)newValue);
231
				return;
275
				return;
276
			case Common_DatapoolPackage.DPL_VARIABLE__ENCRYPTED:
277
				setEncrypted(((Boolean)newValue).booleanValue());
278
				return;
232
			case Common_DatapoolPackage.DPL_VARIABLE__VARIABLES:
279
			case Common_DatapoolPackage.DPL_VARIABLE__VARIABLES:
233
				getVariables().clear();
280
				getVariables().clear();
234
				getVariables().addAll((Collection)newValue);
281
				getVariables().addAll((Collection)newValue);
Lines 250-255 Link Here
250
			case Common_DatapoolPackage.DPL_VARIABLE__ROLE:
297
			case Common_DatapoolPackage.DPL_VARIABLE__ROLE:
251
				setRole(ROLE_EDEFAULT);
298
				setRole(ROLE_EDEFAULT);
252
				return;
299
				return;
300
			case Common_DatapoolPackage.DPL_VARIABLE__ENCRYPTED:
301
				setEncrypted(ENCRYPTED_EDEFAULT);
302
				return;
253
			case Common_DatapoolPackage.DPL_VARIABLE__VARIABLES:
303
			case Common_DatapoolPackage.DPL_VARIABLE__VARIABLES:
254
				getVariables().clear();
304
				getVariables().clear();
255
				return;
305
				return;
Lines 267-273 Link Here
267
			case Common_DatapoolPackage.DPL_VARIABLE__TYPE:
317
			case Common_DatapoolPackage.DPL_VARIABLE__TYPE:
268
				return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type);
318
				return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type);
269
			case Common_DatapoolPackage.DPL_VARIABLE__ROLE:
319
			case Common_DatapoolPackage.DPL_VARIABLE__ROLE:
320
       		
270
				return role != ROLE_EDEFAULT;
321
				return role != ROLE_EDEFAULT;
322
	        
323
			case Common_DatapoolPackage.DPL_VARIABLE__ENCRYPTED:
324
       		
325
				return encrypted != ENCRYPTED_EDEFAULT;
326
	        
271
			case Common_DatapoolPackage.DPL_VARIABLE__VARIABLES:
327
			case Common_DatapoolPackage.DPL_VARIABLE__VARIABLES:
272
				return variables != null && !variables.isEmpty();
328
				return variables != null && !variables.isEmpty();
273
		}
329
		}
Lines 287-296 Link Here
287
		result.append(type);
343
		result.append(type);
288
		result.append(", role: ");
344
		result.append(", role: ");
289
		result.append(role);
345
		result.append(role);
346
		result.append(", encrypted: ");
347
		result.append(encrypted);
290
		result.append(')');
348
		result.append(')');
291
		return result.toString();
349
		return result.toString();
292
	}
350
	}
293
351
352
	
294
	//Beginning of non-generated classes
353
	//Beginning of non-generated classes
295
	
354
	
296
	//org.eclipse.hyades.edit.datapool.IDatapoolVariable methods
355
	//org.eclipse.hyades.edit.datapool.IDatapoolVariable methods
(-)src-test/org/eclipse/hyades/models/common/datapool/impl/DPLDatapoolImpl.java (+68 lines)
Lines 55-60 Link Here
55
 * <p>
55
 * <p>
56
 * The following features are implemented:
56
 * The following features are implemented:
57
 * <ul>
57
 * <ul>
58
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLDatapoolImpl#getChallenge <em>Challenge</em>}</li>
58
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLDatapoolImpl#getEquivalenceClasses <em>Equivalence Classes</em>}</li>
59
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLDatapoolImpl#getEquivalenceClasses <em>Equivalence Classes</em>}</li>
59
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLDatapoolImpl#getDatapoolSpec <em>Datapool Spec</em>}</li>
60
 *   <li>{@link org.eclipse.hyades.models.common.datapool.impl.DPLDatapoolImpl#getDatapoolSpec <em>Datapool Spec</em>}</li>
60
 * </ul>
61
 * </ul>
Lines 73-78 Link Here
73
	public static final String copyright = "";
74
	public static final String copyright = "";
74
75
75
	/**
76
	/**
77
	 * The default value of the '{@link #getChallenge() <em>Challenge</em>}' attribute.
78
	 * <!-- begin-user-doc -->
79
	 * <!-- end-user-doc -->
80
	 * @see #getChallenge()
81
	 * @generated
82
	 * @ordered
83
	 */
84
	protected static final String CHALLENGE_EDEFAULT = null;
85
86
	/**
87
	 * The cached value of the '{@link #getChallenge() <em>Challenge</em>}' attribute.
88
	 * <!-- begin-user-doc -->
89
	 * <!-- end-user-doc -->
90
	 * @see #getChallenge()
91
	 * @generated
92
	 * @ordered
93
	 */
94
	protected String challenge = CHALLENGE_EDEFAULT;
95
96
	/**
76
	 * The cached value of the '{@link #getEquivalenceClasses() <em>Equivalence Classes</em>}' containment reference list.
97
	 * The cached value of the '{@link #getEquivalenceClasses() <em>Equivalence Classes</em>}' containment reference list.
77
	 * <!-- begin-user-doc -->
98
	 * <!-- begin-user-doc -->
78
	 * <!-- end-user-doc -->
99
	 * <!-- end-user-doc -->
Lines 132-137 Link Here
132
	 * <!-- end-user-doc -->
153
	 * <!-- end-user-doc -->
133
	 * @generated
154
	 * @generated
134
	 */
155
	 */
156
	public String getChallenge() {
157
		return challenge;
158
	}
159
160
	/**
161
	 * <!-- begin-user-doc -->
162
	 * <!-- end-user-doc -->
163
	 * @generated
164
	 */
165
	public void setChallenge(String newChallenge) {
166
		String oldChallenge = challenge;
167
		challenge = newChallenge;
168
		if (eNotificationRequired())
169
			eNotify(new ENotificationImpl(this, Notification.SET, Common_DatapoolPackage.DPL_DATAPOOL__CHALLENGE, oldChallenge, challenge));
170
	}
171
172
	/**
173
	 * <!-- begin-user-doc -->
174
	 * <!-- end-user-doc -->
175
	 * @generated
176
	 */
135
	public EList getEquivalenceClasses() {
177
	public EList getEquivalenceClasses() {
136
		if (equivalenceClasses == null) {
178
		if (equivalenceClasses == null) {
137
			equivalenceClasses = new EObjectContainmentEList(DPLEquivalenceClass.class, this, Common_DatapoolPackage.DPL_DATAPOOL__EQUIVALENCE_CLASSES);
179
			equivalenceClasses = new EObjectContainmentEList(DPLEquivalenceClass.class, this, Common_DatapoolPackage.DPL_DATAPOOL__EQUIVALENCE_CLASSES);
Lines 204-209 Link Here
204
	 */
246
	 */
205
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
247
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
206
		switch (featureID) {
248
		switch (featureID) {
249
			case Common_DatapoolPackage.DPL_DATAPOOL__CHALLENGE:
250
				return getChallenge();
207
			case Common_DatapoolPackage.DPL_DATAPOOL__EQUIVALENCE_CLASSES:
251
			case Common_DatapoolPackage.DPL_DATAPOOL__EQUIVALENCE_CLASSES:
208
				return getEquivalenceClasses();
252
				return getEquivalenceClasses();
209
			case Common_DatapoolPackage.DPL_DATAPOOL__DATAPOOL_SPEC:
253
			case Common_DatapoolPackage.DPL_DATAPOOL__DATAPOOL_SPEC:
Lines 219-224 Link Here
219
	 */
263
	 */
220
	public void eSet(int featureID, Object newValue) {
264
	public void eSet(int featureID, Object newValue) {
221
		switch (featureID) {
265
		switch (featureID) {
266
			case Common_DatapoolPackage.DPL_DATAPOOL__CHALLENGE:
267
				setChallenge((String)newValue);
268
				return;
222
			case Common_DatapoolPackage.DPL_DATAPOOL__EQUIVALENCE_CLASSES:
269
			case Common_DatapoolPackage.DPL_DATAPOOL__EQUIVALENCE_CLASSES:
223
				getEquivalenceClasses().clear();
270
				getEquivalenceClasses().clear();
224
				getEquivalenceClasses().addAll((Collection)newValue);
271
				getEquivalenceClasses().addAll((Collection)newValue);
Lines 237-242 Link Here
237
	 */
284
	 */
238
	public void eUnset(int featureID) {
285
	public void eUnset(int featureID) {
239
		switch (featureID) {
286
		switch (featureID) {
287
			case Common_DatapoolPackage.DPL_DATAPOOL__CHALLENGE:
288
				setChallenge(CHALLENGE_EDEFAULT);
289
				return;
240
			case Common_DatapoolPackage.DPL_DATAPOOL__EQUIVALENCE_CLASSES:
290
			case Common_DatapoolPackage.DPL_DATAPOOL__EQUIVALENCE_CLASSES:
241
				getEquivalenceClasses().clear();
291
				getEquivalenceClasses().clear();
242
				return;
292
				return;
Lines 254-259 Link Here
254
	 */
304
	 */
255
	public boolean eIsSet(int featureID) {
305
	public boolean eIsSet(int featureID) {
256
		switch (featureID) {
306
		switch (featureID) {
307
			case Common_DatapoolPackage.DPL_DATAPOOL__CHALLENGE:
308
				return CHALLENGE_EDEFAULT == null ? challenge != null : !CHALLENGE_EDEFAULT.equals(challenge);
257
			case Common_DatapoolPackage.DPL_DATAPOOL__EQUIVALENCE_CLASSES:
309
			case Common_DatapoolPackage.DPL_DATAPOOL__EQUIVALENCE_CLASSES:
258
				return equivalenceClasses != null && !equivalenceClasses.isEmpty();
310
				return equivalenceClasses != null && !equivalenceClasses.isEmpty();
259
			case Common_DatapoolPackage.DPL_DATAPOOL__DATAPOOL_SPEC:
311
			case Common_DatapoolPackage.DPL_DATAPOOL__DATAPOOL_SPEC:
Lines 262-267 Link Here
262
		return super.eIsSet(featureID);
314
		return super.eIsSet(featureID);
263
	}
315
	}
264
316
317
	/**
318
	 * <!-- begin-user-doc -->
319
	 * <!-- end-user-doc -->
320
	 * @generated
321
	 */
322
	public String toString() {
323
		if (eIsProxy()) return super.toString();
324
325
		StringBuffer result = new StringBuffer(super.toString());
326
		result.append(" (challenge: ");
327
		result.append(challenge);
328
		result.append(')');
329
		return result.toString();
330
	}
331
332
	
265
	/* (non-Javadoc)
333
	/* (non-Javadoc)
266
	 * @see org.eclipse.hyades.models.common.configuration.impl.CFGClassImpl#getLocation()
334
	 * @see org.eclipse.hyades.models.common.configuration.impl.CFGClassImpl#getLocation()
267
	 */
335
	 */
(-)src-test/org/eclipse/hyades/models/common/datapool/impl/DPLCellImpl.java (-10 / +33 lines)
Lines 16-21 Link Here
16
16
17
package org.eclipse.hyades.models.common.datapool.impl;
17
package org.eclipse.hyades.models.common.datapool.impl;
18
18
19
import java.util.HashMap;
20
19
import org.eclipse.emf.common.notify.Notification;
21
import org.eclipse.emf.common.notify.Notification;
20
import org.eclipse.emf.ecore.EClass;
22
import org.eclipse.emf.ecore.EClass;
21
import org.eclipse.emf.ecore.InternalEObject;
23
import org.eclipse.emf.ecore.InternalEObject;
Lines 28-34 Link Here
28
import org.eclipse.hyades.models.common.datapool.Common_DatapoolPackage;
30
import org.eclipse.hyades.models.common.datapool.Common_DatapoolPackage;
29
import org.eclipse.hyades.models.common.datapool.DPLCell;
31
import org.eclipse.hyades.models.common.datapool.DPLCell;
30
import org.eclipse.hyades.models.common.datapool.DPLVariable;
32
import org.eclipse.hyades.models.common.datapool.DPLVariable;
33
import org.eclipse.hyades.models.common.datapool.util.DPLPasswordCollection;
31
import org.eclipse.hyades.models.common.util.DatapoolUtil;
34
import org.eclipse.hyades.models.common.util.DatapoolUtil;
35
import org.eclipse.hyades.models.common.util.EncryptionManager;
32
import org.eclipse.hyades.models.common.util.XMLParserUtil;
36
import org.eclipse.hyades.models.common.util.XMLParserUtil;
33
import org.w3c.dom.Document;
37
import org.w3c.dom.Document;
34
38
Lines 361-367 Link Here
361
	{
365
	{
362
		Object cellValue = this.getCellValue();
366
		Object cellValue = this.getCellValue();
363
		if(cellValue != null)
367
		if(cellValue != null)
364
			return cellValue.toString();
368
			return decryptValue(cellValue.toString());
365
		else
369
		else
366
			return new String();
370
			return new String();
367
	}
371
	}
Lines 376-382 Link Here
376
	 */
380
	 */
377
	public long getLongValue()
381
	public long getLongValue()
378
	{
382
	{
379
		return Long.parseLong((String)this.getCellValue());
383
		return Long.parseLong(decryptValue((String)this.getCellValue()));
380
	}
384
	}
381
	
385
	
382
	/**
386
	/**
Lines 389-395 Link Here
389
	 */
393
	 */
390
	public int getIntValue()
394
	public int getIntValue()
391
	{
395
	{
392
		return Integer.parseInt((String)this.getCellValue());
396
		return Integer.parseInt(decryptValue((String)this.getCellValue()));
393
	}
397
	}
394
	
398
	
395
	/**
399
	/**
Lines 402-408 Link Here
402
	 */
406
	 */
403
	public short getShortValue()
407
	public short getShortValue()
404
	{
408
	{
405
		return Short.parseShort((String)this.getCellValue());
409
		return Short.parseShort(decryptValue((String)this.getCellValue()));
406
	}
410
	}
407
	
411
	
408
	/**
412
	/**
Lines 415-421 Link Here
415
	 */
419
	 */
416
	public byte getByteValue()
420
	public byte getByteValue()
417
	{
421
	{
418
		return Byte.parseByte((String)this.getCellValue());
422
		return Byte.parseByte(decryptValue((String)this.getCellValue()));
419
	}
423
	}
420
	
424
	
421
	/**
425
	/**
Lines 428-434 Link Here
428
	 */
432
	 */
429
	public double getDoubleValue()
433
	public double getDoubleValue()
430
	{
434
	{
431
		return Double.parseDouble((String)this.getCellValue());
435
		return Double.parseDouble(decryptValue((String)this.getCellValue()));
432
	}
436
	}
433
	
437
	
434
	/**
438
	/**
Lines 441-447 Link Here
441
	 */
445
	 */
442
	public float getFloatValue()
446
	public float getFloatValue()
443
	{
447
	{
444
		return Float.parseFloat((String)this.getCellValue());
448
		return Float.parseFloat(decryptValue((String)this.getCellValue()));
445
	}
449
	}
446
	
450
	
447
	/**
451
	/**
Lines 454-460 Link Here
454
	 */
458
	 */
455
	public boolean getBooleanValue()
459
	public boolean getBooleanValue()
456
	{
460
	{
457
		return Boolean.getBoolean ((String)this.getCellValue());
461
		return Boolean.getBoolean (decryptValue((String)this.getCellValue()));
458
	}
462
	}
459
	
463
	
460
	/**
464
	/**
Lines 468-474 Link Here
468
	 */
472
	 */
469
	public char getCharValue()
473
	public char getCharValue()
470
	{
474
	{
471
		return ((String)this.getCellValue()).charAt(0);
475
		return decryptValue(((String)this.getCellValue())).charAt(0);
472
	}
476
	}
473
477
474
	/**
478
	/**
Lines 504-510 Link Here
504
		{
508
		{
505
	        //get the tag and value from the XML fragment
509
	        //get the tag and value from the XML fragment
506
			try {	
510
			try {	
507
				Document doc = XMLParserUtil.parse(value.toString());		
511
				Document doc = XMLParserUtil.parse(value.toString());					
508
				tag = doc.getFirstChild().getNodeName();
512
				tag = doc.getFirstChild().getNodeName();
509
				val = doc.getFirstChild().getFirstChild().getNodeValue();
513
				val = doc.getFirstChild().getFirstChild().getNodeValue();
510
		    }
514
		    }
Lines 569-572 Link Here
569
		else
573
		else
570
			return START_LITERAL + END_LITERAL;
574
			return START_LITERAL + END_LITERAL;
571
	}	
575
	}	
576
	/*
577
	 * decryptValue the cell value
578
	 */
579
	public String decryptValue(String value){
580
		String result = null;
581
		if(value == null)
582
			return result;
583
		
584
		result = value;
585
		HashMap passes = DPLPasswordCollection.getInstance().getDatapoolPassword();		
586
	    String dpName = this.getCellRecord().getEquivalenceClass().getDatapool().getName();
587
		if(passes!=null && passes.size()>0 && dpName != null && this.getVariable().isEncrypted()){
588
	    	String pass = (String)passes.get(dpName);
589
	    	if(pass != null){
590
	    		result = EncryptionManager.decrypt(value, pass);
591
	    	}
592
	    }
593
		return result;
594
	}
572
} //DPLCellImpl
595
} //DPLCellImpl
(-)src-test/org/eclipse/hyades/models/common/datapool/impl/Common_DatapoolPackageImpl.java (-3 / +25 lines)
Lines 227-234 Link Here
227
	 * <!-- end-user-doc -->
227
	 * <!-- end-user-doc -->
228
	 * @generated
228
	 * @generated
229
	 */
229
	 */
230
	public EAttribute getDPLDatapool_Challenge() {
231
		return (EAttribute)dplDatapoolEClass.getEStructuralFeatures().get(0);
232
	}
233
234
	/**
235
	 * <!-- begin-user-doc -->
236
	 * <!-- end-user-doc -->
237
	 * @generated
238
	 */
230
	public EReference getDPLDatapool_EquivalenceClasses() {
239
	public EReference getDPLDatapool_EquivalenceClasses() {
231
		return (EReference)dplDatapoolEClass.getEStructuralFeatures().get(0);
240
		return (EReference)dplDatapoolEClass.getEStructuralFeatures().get(1);
232
	}
241
	}
233
242
234
	/**
243
	/**
Lines 237-243 Link Here
237
	 * @generated
246
	 * @generated
238
	 */
247
	 */
239
	public EReference getDPLDatapool_DatapoolSpec() {
248
	public EReference getDPLDatapool_DatapoolSpec() {
240
		return (EReference)dplDatapoolEClass.getEStructuralFeatures().get(1);
249
		return (EReference)dplDatapoolEClass.getEStructuralFeatures().get(2);
241
	}
250
	}
242
251
243
	/**
252
	/**
Lines 344-351 Link Here
344
	 * <!-- end-user-doc -->
353
	 * <!-- end-user-doc -->
345
	 * @generated
354
	 * @generated
346
	 */
355
	 */
356
	public EAttribute getDPLVariable_Encrypted() {
357
		return (EAttribute)dplVariableEClass.getEStructuralFeatures().get(2);
358
	}
359
360
	/**
361
	 * <!-- begin-user-doc -->
362
	 * <!-- end-user-doc -->
363
	 * @generated
364
	 */
347
	public EReference getDPLVariable_Variables() {
365
	public EReference getDPLVariable_Variables() {
348
		return (EReference)dplVariableEClass.getEStructuralFeatures().get(2);
366
		return (EReference)dplVariableEClass.getEStructuralFeatures().get(3);
349
	}
367
	}
350
368
351
	/**
369
	/**
Lines 402-410 Link Here
402
		dplVariableEClass = createEClass(DPL_VARIABLE);
420
		dplVariableEClass = createEClass(DPL_VARIABLE);
403
		createEAttribute(dplVariableEClass, DPL_VARIABLE__TYPE);
421
		createEAttribute(dplVariableEClass, DPL_VARIABLE__TYPE);
404
		createEAttribute(dplVariableEClass, DPL_VARIABLE__ROLE);
422
		createEAttribute(dplVariableEClass, DPL_VARIABLE__ROLE);
423
		createEAttribute(dplVariableEClass, DPL_VARIABLE__ENCRYPTED);
405
		createEReference(dplVariableEClass, DPL_VARIABLE__VARIABLES);
424
		createEReference(dplVariableEClass, DPL_VARIABLE__VARIABLES);
406
425
407
		dplDatapoolEClass = createEClass(DPL_DATAPOOL);
426
		dplDatapoolEClass = createEClass(DPL_DATAPOOL);
427
		createEAttribute(dplDatapoolEClass, DPL_DATAPOOL__CHALLENGE);
408
		createEReference(dplDatapoolEClass, DPL_DATAPOOL__EQUIVALENCE_CLASSES);
428
		createEReference(dplDatapoolEClass, DPL_DATAPOOL__EQUIVALENCE_CLASSES);
409
		createEReference(dplDatapoolEClass, DPL_DATAPOOL__DATAPOOL_SPEC);
429
		createEReference(dplDatapoolEClass, DPL_DATAPOOL__DATAPOOL_SPEC);
410
430
Lines 464-472 Link Here
464
		initEClass(dplVariableEClass, DPLVariable.class, "DPLVariable", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
484
		initEClass(dplVariableEClass, DPLVariable.class, "DPLVariable", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
465
		initEAttribute(getDPLVariable_Type(), ecorePackage.getEString(), "type", null, 0, 1, DPLVariable.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
485
		initEAttribute(getDPLVariable_Type(), ecorePackage.getEString(), "type", null, 0, 1, DPLVariable.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
466
		initEAttribute(getDPLVariable_Role(), this.getDPLRole(), "role", null, 0, 1, DPLVariable.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
486
		initEAttribute(getDPLVariable_Role(), this.getDPLRole(), "role", null, 0, 1, DPLVariable.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
487
		initEAttribute(getDPLVariable_Encrypted(), ecorePackage.getEBoolean(), "encrypted", "false", 0, 1, DPLVariable.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
467
		initEReference(getDPLVariable_Variables(), this.getDPLVariable(), null, "variables", null, 0, -1, DPLVariable.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
488
		initEReference(getDPLVariable_Variables(), this.getDPLVariable(), null, "variables", null, 0, -1, DPLVariable.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
468
489
469
		initEClass(dplDatapoolEClass, DPLDatapool.class, "DPLDatapool", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
490
		initEClass(dplDatapoolEClass, DPLDatapool.class, "DPLDatapool", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
491
		initEAttribute(getDPLDatapool_Challenge(), ecorePackage.getEString(), "challenge", null, 0, 1, DPLDatapool.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
470
		initEReference(getDPLDatapool_EquivalenceClasses(), this.getDPLEquivalenceClass(), null, "equivalenceClasses", null, 0, -1, DPLDatapool.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
492
		initEReference(getDPLDatapool_EquivalenceClasses(), this.getDPLEquivalenceClass(), null, "equivalenceClasses", null, 0, -1, DPLDatapool.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
471
		initEReference(getDPLDatapool_DatapoolSpec(), this.getDPLDatapoolSpec(), null, "datapoolSpec", null, 1, 1, DPLDatapool.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
493
		initEReference(getDPLDatapool_DatapoolSpec(), this.getDPLDatapoolSpec(), null, "datapoolSpec", null, 1, 1, DPLDatapool.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
472
494
(-)src-test/org/eclipse/hyades/models/common/datapool/DPLVariable.java (-1 / +33 lines)
Lines 32-37 Link Here
32
 * <ul>
32
 * <ul>
33
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLVariable#getType <em>Type</em>}</li>
33
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLVariable#getType <em>Type</em>}</li>
34
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLVariable#getRole <em>Role</em>}</li>
34
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLVariable#getRole <em>Role</em>}</li>
35
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLVariable#isEncrypted <em>Encrypted</em>}</li>
35
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLVariable#getVariables <em>Variables</em>}</li>
36
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLVariable#getVariables <em>Variables</em>}</li>
36
 * </ul>
37
 * </ul>
37
 * </p>
38
 * </p>
Lines 40-46 Link Here
40
 * @model
41
 * @model
41
 * @generated
42
 * @generated
42
 */
43
 */
43
public interface DPLVariable extends CMNNamedElement, IDatapoolVariable{
44
public interface DPLVariable extends CMNNamedElement, IDatapoolVariable {
44
	/**
45
	/**
45
	 * <!-- begin-user-doc -->
46
	 * <!-- begin-user-doc -->
46
	 * <!-- end-user-doc -->
47
	 * <!-- end-user-doc -->
Lines 104-109 Link Here
104
	void setRole(DPLRole value);
105
	void setRole(DPLRole value);
105
106
106
	/**
107
	/**
108
	 * Returns the value of the '<em><b>Encrypted</b></em>' attribute.
109
	 * The default value is <code>"false"</code>.
110
	 * <!-- begin-user-doc -->
111
	 * <p>
112
	 * If the meaning of the '<em>Encrypted</em>' attribute isn't clear,
113
	 * there really should be more of a description here...
114
	 * </p>
115
	 * <!-- end-user-doc -->
116
	 * <!-- begin-model-doc -->
117
	 * This boolean specifies whether or not this DPLVariable is encrypted.
118
	 * <!-- end-model-doc -->
119
	 * @return the value of the '<em>Encrypted</em>' attribute.
120
	 * @see #setEncrypted(boolean)
121
	 * @see org.eclipse.hyades.models.common.datapool.Common_DatapoolPackage#getDPLVariable_Encrypted()
122
	 * @model default="false"
123
	 * @generated
124
	 */
125
	boolean isEncrypted();
126
127
	/**
128
	 * Sets the value of the '{@link org.eclipse.hyades.models.common.datapool.DPLVariable#isEncrypted <em>Encrypted</em>}' attribute.
129
	 * <!-- begin-user-doc -->
130
	 * <!-- end-user-doc -->
131
	 * @param value the new value of the '<em>Encrypted</em>' attribute.
132
	 * @see #isEncrypted()
133
	 * @generated
134
	 */
135
	void setEncrypted(boolean value);
136
137
	/**
107
	 * Returns the value of the '<em><b>Variables</b></em>' containment reference list.
138
	 * Returns the value of the '<em><b>Variables</b></em>' containment reference list.
108
	 * The list contents are of type {@link org.eclipse.hyades.models.common.datapool.DPLVariable}.
139
	 * The list contents are of type {@link org.eclipse.hyades.models.common.datapool.DPLVariable}.
109
	 * <!-- begin-user-doc -->
140
	 * <!-- begin-user-doc -->
Lines 119-122 Link Here
119
	 */
150
	 */
120
	EList getVariables();
151
	EList getVariables();
121
152
153
	
122
} // DPLVariable
154
} // DPLVariable
(-)src-test/org/eclipse/hyades/models/common/datapool/DPLDatapool.java (-1 / +28 lines)
Lines 31-36 Link Here
31
 * <p>
31
 * <p>
32
 * The following features are supported:
32
 * The following features are supported:
33
 * <ul>
33
 * <ul>
34
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLDatapool#getChallenge <em>Challenge</em>}</li>
34
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLDatapool#getEquivalenceClasses <em>Equivalence Classes</em>}</li>
35
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLDatapool#getEquivalenceClasses <em>Equivalence Classes</em>}</li>
35
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLDatapool#getDatapoolSpec <em>Datapool Spec</em>}</li>
36
 *   <li>{@link org.eclipse.hyades.models.common.datapool.DPLDatapool#getDatapoolSpec <em>Datapool Spec</em>}</li>
36
 * </ul>
37
 * </ul>
Lines 40-46 Link Here
40
 * @model
41
 * @model
41
 * @generated
42
 * @generated
42
 */
43
 */
43
public interface DPLDatapool extends CFGClass, CMNNamedElement, IDatapool{
44
public interface DPLDatapool extends CFGClass, CMNNamedElement, IDatapool {
44
	/**
45
	/**
45
	 * <!-- begin-user-doc -->
46
	 * <!-- begin-user-doc -->
46
	 * <!-- end-user-doc -->
47
	 * <!-- end-user-doc -->
Lines 49-54 Link Here
49
	String copyright = "";
50
	String copyright = "";
50
51
51
	/**
52
	/**
53
	 * Returns the value of the '<em><b>Challenge</b></em>' attribute.
54
	 * <!-- begin-user-doc -->
55
	 * <!-- end-user-doc -->
56
	 * <!-- begin-model-doc -->
57
	 * This string is used to determine whether a user supplied password for an encrypted datapool is correct.
58
	 * <!-- end-model-doc -->
59
	 * @return the value of the '<em>Challenge</em>' attribute.
60
	 * @see #setChallenge(String)
61
	 * @see org.eclipse.hyades.models.common.datapool.Common_DatapoolPackage#getDPLDatapool_Challenge()
62
	 * @model
63
	 * @generated
64
	 */
65
	String getChallenge();
66
67
	/**
68
	 * Sets the value of the '{@link org.eclipse.hyades.models.common.datapool.DPLDatapool#getChallenge <em>Challenge</em>}' attribute.
69
	 * <!-- begin-user-doc -->
70
	 * <!-- end-user-doc -->
71
	 * @param value the new value of the '<em>Challenge</em>' attribute.
72
	 * @see #getChallenge()
73
	 * @generated
74
	 */
75
	void setChallenge(String value);
76
77
	/**
52
	 * Returns the value of the '<em><b>Equivalence Classes</b></em>' containment reference list.
78
	 * Returns the value of the '<em><b>Equivalence Classes</b></em>' containment reference list.
53
	 * The list contents are of type {@link org.eclipse.hyades.models.common.datapool.DPLEquivalenceClass}.
79
	 * The list contents are of type {@link org.eclipse.hyades.models.common.datapool.DPLEquivalenceClass}.
54
	 * <!-- begin-user-doc -->
80
	 * <!-- begin-user-doc -->
Lines 90-93 Link Here
90
	 */
116
	 */
91
	void setDatapoolSpec(DPLDatapoolSpec value);
117
	void setDatapoolSpec(DPLDatapoolSpec value);
92
118
119
	
93
} // DPLDatapool
120
} // DPLDatapool
(-)src-test/org/eclipse/hyades/models/common/datapool/Common_DatapoolPackage.java (-5 / +61 lines)
Lines 330-342 Link Here
330
	int DPL_VARIABLE__ROLE = CommonPackage.CMN_NAMED_ELEMENT_FEATURE_COUNT + 1;
330
	int DPL_VARIABLE__ROLE = CommonPackage.CMN_NAMED_ELEMENT_FEATURE_COUNT + 1;
331
331
332
	/**
332
	/**
333
	 * The feature id for the '<em><b>Encrypted</b></em>' attribute.
334
	 * <!-- begin-user-doc -->
335
	 * <!-- end-user-doc -->
336
	 * @generated
337
	 * @ordered
338
	 */
339
	int DPL_VARIABLE__ENCRYPTED = CommonPackage.CMN_NAMED_ELEMENT_FEATURE_COUNT + 2;
340
341
	/**
333
	 * The feature id for the '<em><b>Variables</b></em>' containment reference list.
342
	 * The feature id for the '<em><b>Variables</b></em>' containment reference list.
334
	 * <!-- begin-user-doc -->
343
	 * <!-- begin-user-doc -->
335
	 * <!-- end-user-doc -->
344
	 * <!-- end-user-doc -->
336
	 * @generated
345
	 * @generated
337
	 * @ordered
346
	 * @ordered
338
	 */
347
	 */
339
	int DPL_VARIABLE__VARIABLES = CommonPackage.CMN_NAMED_ELEMENT_FEATURE_COUNT + 2;
348
	int DPL_VARIABLE__VARIABLES = CommonPackage.CMN_NAMED_ELEMENT_FEATURE_COUNT + 3;
340
349
341
	/**
350
	/**
342
	 * The number of structural features of the '<em>DPL Variable</em>' class.
351
	 * The number of structural features of the '<em>DPL Variable</em>' class.
Lines 345-351 Link Here
345
	 * @generated
354
	 * @generated
346
	 * @ordered
355
	 * @ordered
347
	 */
356
	 */
348
	int DPL_VARIABLE_FEATURE_COUNT = CommonPackage.CMN_NAMED_ELEMENT_FEATURE_COUNT + 3;
357
	int DPL_VARIABLE_FEATURE_COUNT = CommonPackage.CMN_NAMED_ELEMENT_FEATURE_COUNT + 4;
349
358
350
	/**
359
	/**
351
	 * The feature id for the '<em><b>Id</b></em>' attribute.
360
	 * The feature id for the '<em><b>Id</b></em>' attribute.
Lines 402-414 Link Here
402
	int DPL_DATAPOOL__INSTANTIATIONS = Common_ConfigurationPackage.CFG_CLASS__INSTANTIATIONS;
411
	int DPL_DATAPOOL__INSTANTIATIONS = Common_ConfigurationPackage.CFG_CLASS__INSTANTIATIONS;
403
412
404
	/**
413
	/**
414
	 * The feature id for the '<em><b>Challenge</b></em>' attribute.
415
	 * <!-- begin-user-doc -->
416
	 * <!-- end-user-doc -->
417
	 * @generated
418
	 * @ordered
419
	 */
420
	int DPL_DATAPOOL__CHALLENGE = Common_ConfigurationPackage.CFG_CLASS_FEATURE_COUNT + 0;
421
422
	/**
405
	 * The feature id for the '<em><b>Equivalence Classes</b></em>' containment reference list.
423
	 * The feature id for the '<em><b>Equivalence Classes</b></em>' containment reference list.
406
	 * <!-- begin-user-doc -->
424
	 * <!-- begin-user-doc -->
407
	 * <!-- end-user-doc -->
425
	 * <!-- end-user-doc -->
408
	 * @generated
426
	 * @generated
409
	 * @ordered
427
	 * @ordered
410
	 */
428
	 */
411
	int DPL_DATAPOOL__EQUIVALENCE_CLASSES = Common_ConfigurationPackage.CFG_CLASS_FEATURE_COUNT + 0;
429
	int DPL_DATAPOOL__EQUIVALENCE_CLASSES = Common_ConfigurationPackage.CFG_CLASS_FEATURE_COUNT + 1;
412
430
413
	/**
431
	/**
414
	 * The feature id for the '<em><b>Datapool Spec</b></em>' containment reference.
432
	 * The feature id for the '<em><b>Datapool Spec</b></em>' containment reference.
Lines 417-423 Link Here
417
	 * @generated
435
	 * @generated
418
	 * @ordered
436
	 * @ordered
419
	 */
437
	 */
420
	int DPL_DATAPOOL__DATAPOOL_SPEC = Common_ConfigurationPackage.CFG_CLASS_FEATURE_COUNT + 1;
438
	int DPL_DATAPOOL__DATAPOOL_SPEC = Common_ConfigurationPackage.CFG_CLASS_FEATURE_COUNT + 2;
421
439
422
	/**
440
	/**
423
	 * The number of structural features of the '<em>DPL Datapool</em>' class.
441
	 * The number of structural features of the '<em>DPL Datapool</em>' class.
Lines 426-432 Link Here
426
	 * @generated
444
	 * @generated
427
	 * @ordered
445
	 * @ordered
428
	 */
446
	 */
429
	int DPL_DATAPOOL_FEATURE_COUNT = Common_ConfigurationPackage.CFG_CLASS_FEATURE_COUNT + 2;
447
	int DPL_DATAPOOL_FEATURE_COUNT = Common_ConfigurationPackage.CFG_CLASS_FEATURE_COUNT + 3;
430
448
431
	/**
449
	/**
432
	 * The meta object id for the '{@link org.eclipse.hyades.models.common.datapool.DPLRole <em>DPL Role</em>}' enum.
450
	 * The meta object id for the '{@link org.eclipse.hyades.models.common.datapool.DPLRole <em>DPL Role</em>}' enum.
Lines 471-476 Link Here
471
	EClass getDPLDatapool();
489
	EClass getDPLDatapool();
472
490
473
	/**
491
	/**
492
	 * Returns the meta object for the attribute '{@link org.eclipse.hyades.models.common.datapool.DPLDatapool#getChallenge <em>Challenge</em>}'.
493
	 * <!-- begin-user-doc -->
494
	 * <!-- end-user-doc -->
495
	 * @return the meta object for the attribute '<em>Challenge</em>'.
496
	 * @see org.eclipse.hyades.models.common.datapool.DPLDatapool#getChallenge()
497
	 * @see #getDPLDatapool()
498
	 * @generated
499
	 */
500
	EAttribute getDPLDatapool_Challenge();
501
502
	/**
474
	 * Returns the meta object for the containment reference list '{@link org.eclipse.hyades.models.common.datapool.DPLDatapool#getEquivalenceClasses <em>Equivalence Classes</em>}'.
503
	 * Returns the meta object for the containment reference list '{@link org.eclipse.hyades.models.common.datapool.DPLDatapool#getEquivalenceClasses <em>Equivalence Classes</em>}'.
475
	 * <!-- begin-user-doc -->
504
	 * <!-- begin-user-doc -->
476
	 * <!-- end-user-doc -->
505
	 * <!-- end-user-doc -->
Lines 610-615 Link Here
610
	EAttribute getDPLVariable_Role();
639
	EAttribute getDPLVariable_Role();
611
640
612
	/**
641
	/**
642
	 * Returns the meta object for the attribute '{@link org.eclipse.hyades.models.common.datapool.DPLVariable#isEncrypted <em>Encrypted</em>}'.
643
	 * <!-- begin-user-doc -->
644
	 * <!-- end-user-doc -->
645
	 * @return the meta object for the attribute '<em>Encrypted</em>'.
646
	 * @see org.eclipse.hyades.models.common.datapool.DPLVariable#isEncrypted()
647
	 * @see #getDPLVariable()
648
	 * @generated
649
	 */
650
	EAttribute getDPLVariable_Encrypted();
651
652
	/**
613
	 * Returns the meta object for the containment reference list '{@link org.eclipse.hyades.models.common.datapool.DPLVariable#getVariables <em>Variables</em>}'.
653
	 * Returns the meta object for the containment reference list '{@link org.eclipse.hyades.models.common.datapool.DPLVariable#getVariables <em>Variables</em>}'.
614
	 * <!-- begin-user-doc -->
654
	 * <!-- begin-user-doc -->
615
	 * <!-- end-user-doc -->
655
	 * <!-- end-user-doc -->
Lines 767-772 Link Here
767
		EAttribute DPL_VARIABLE__ROLE = eINSTANCE.getDPLVariable_Role();
807
		EAttribute DPL_VARIABLE__ROLE = eINSTANCE.getDPLVariable_Role();
768
808
769
		/**
809
		/**
810
		 * The meta object literal for the '<em><b>Encrypted</b></em>' attribute feature.
811
		 * <!-- begin-user-doc -->
812
		 * <!-- end-user-doc -->
813
		 * @generated
814
		 */
815
		EAttribute DPL_VARIABLE__ENCRYPTED = eINSTANCE.getDPLVariable_Encrypted();
816
817
		/**
770
		 * The meta object literal for the '<em><b>Variables</b></em>' containment reference list feature.
818
		 * The meta object literal for the '<em><b>Variables</b></em>' containment reference list feature.
771
		 * <!-- begin-user-doc -->
819
		 * <!-- begin-user-doc -->
772
		 * <!-- end-user-doc -->
820
		 * <!-- end-user-doc -->
Lines 785-790 Link Here
785
		EClass DPL_DATAPOOL = eINSTANCE.getDPLDatapool();
833
		EClass DPL_DATAPOOL = eINSTANCE.getDPLDatapool();
786
834
787
		/**
835
		/**
836
		 * The meta object literal for the '<em><b>Challenge</b></em>' attribute feature.
837
		 * <!-- begin-user-doc -->
838
		 * <!-- end-user-doc -->
839
		 * @generated
840
		 */
841
		EAttribute DPL_DATAPOOL__CHALLENGE = eINSTANCE.getDPLDatapool_Challenge();
842
843
		/**
788
		 * The meta object literal for the '<em><b>Equivalence Classes</b></em>' containment reference list feature.
844
		 * The meta object literal for the '<em><b>Equivalence Classes</b></em>' containment reference list feature.
789
		 * <!-- begin-user-doc -->
845
		 * <!-- begin-user-doc -->
790
		 * <!-- end-user-doc -->
846
		 * <!-- end-user-doc -->
(-)src-test/org/eclipse/hyades/models/common/util/EncryptionManager.java (+148 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 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
 * $Id: EncryptionManager.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
13
package org.eclipse.hyades.models.common.util;
14
15
import java.io.UnsupportedEncodingException;
16
import java.security.MessageDigest;
17
import java.security.NoSuchAlgorithmException;
18
19
import javax.crypto.Cipher;
20
import javax.crypto.spec.SecretKeySpec;
21
22
import org.eclipse.hyades.models.plugin.ModelsPlugin;
23
24
/**
25
 * It's used to provide encryption and decryption algorithm for a datapool .
26
 * 
27
 * @author Huang Xin Ying 
28
 */
29
public class EncryptionManager {
30
31
	public static String encrypt(String content, String pass) {		
32
		return new RC4Encrypter().cipherMessage(pass, content);
33
	}
34
35
	public static String decrypt(String content, String pass) {		
36
		return new RC4Encrypter().decipherMessage(pass, content);
37
	}
38
39
	public static String EncoderByMd5(String str)
40
			throws NoSuchAlgorithmException, UnsupportedEncodingException {
41
		if (str == null)
42
			return null;
43
		
44
		return new RC4Encrypter().byteArrayToHexString(MessageDigest.getInstance("MD5").digest(str.getBytes()));
45
	}
46
47
	public static class RC4Encrypter {
48
		
49
		public static final String[] HEXARRAY = {
50
	        "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"
51
	    };
52
53
		public String cipherMessage(String pass, String content) {
54
			if (pass == null || pass.equals("") || content == null
55
					|| content.equals("")) {
56
				return content;
57
			}
58
			try {
59
				SecretKeySpec key = this.generateKey(pass);
60
				Cipher cipher = Cipher.getInstance("RC4");
61
				cipher.init(Cipher.ENCRYPT_MODE, key);
62
				byte[] code = cipher.update(content.getBytes());
63
				return byteArrayToHexString(code);
64
			} catch (Exception e) {
65
				ModelsPlugin.getPlugin().log(e);
66
			}
67
			return null;
68
		}
69
70
		public String decipherMessage(String pass, String encryptStr)
71
72
		{
73
			if (pass == null || pass.equals("") || encryptStr == null
74
					|| encryptStr.equals("")) {
75
				return encryptStr;
76
			}
77
			try {
78
				SecretKeySpec key = this.generateKey(pass);
79
				Cipher cipher = Cipher.getInstance("RC4");
80
				cipher.init(Cipher.DECRYPT_MODE, key);
81
				byte[] text = hexStringToByteArray(encryptStr);
82
				byte[] code = cipher.update(text);
83
				return new String(code);
84
			} catch (Exception e) {
85
				ModelsPlugin.getPlugin().log(e);
86
			}
87
			return null;
88
		}
89
90
		private SecretKeySpec generateKey(String inpass)
91
92
		{
93
			try {
94
				byte[] pass = inpass.getBytes();
95
96
				MessageDigest md5 = MessageDigest.getInstance("MD5");
97
98
				md5.update(pass);
99
				byte temp[] = md5.digest();
100
101
				SecretKeySpec key = new SecretKeySpec(temp, "RC4");
102
				return key;
103
104
			} catch (Exception e) {
105
				ModelsPlugin.getPlugin().log(e);
106
			}
107
			return null;
108
		}
109
		
110
		/**
111
	      * Method converting byte array into String.
112
	      *
113
	      * @param The byte array to be converted.
114
	      * @return A <code>String[]</code> containing String value of byte array.
115
	      */
116
	     public  String byteArrayToHexString(byte[] bytes){
117
	        
118
	         String result = "";
119
	          for (int i = 0; i < bytes.length; i++){
120
	            //the up 4 bits
121
	            int tmp = bytes[i] >>> 4;
122
	            result += HEXARRAY[tmp % 16];
123
	            //the lower 4 bits
124
	            tmp = bytes[i] & 0x0f;
125
	              result += HEXARRAY[tmp % 16];
126
	           }
127
	         
128
	           return result;
129
	     }
130
	    
131
	     /**
132
	      * Method converting String into byte[].
133
	      *
134
	      * @param The String to be converted.
135
	      * @return A <code>byte[]</code> containing byte[] value of string.
136
	      */ 
137
	    public  byte[] hexStringToByteArray(String hex){
138
	        
139
	         byte[] bytes = new byte[hex.length() / 2];
140
	         for (int i = 0; i < bytes.length; i++){
141
	              bytes[i] = (byte) Integer.parseInt(hex.substring(2*i, 2*i+2), 16);
142
	         }
143
	           
144
	       
145
	        return bytes;
146
	    }		
147
	}	
148
}
(-)src-test/org/eclipse/hyades/models/common/datapool/util/DatapoolEncryptManager.java (+162 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 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
 * $Id: DatapoolEncryptManager.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
13
package org.eclipse.hyades.models.common.datapool.util;
14
15
import org.eclipse.hyades.edit.datapool.IDatapool;
16
import org.eclipse.hyades.edit.datapool.IDatapoolCell;
17
import org.eclipse.hyades.edit.datapool.IDatapoolRecord;
18
import org.eclipse.hyades.execution.runtime.datapool.IDatapoolEquivalenceClass;
19
import org.eclipse.hyades.execution.runtime.datapool.IDatapoolVariable;
20
import org.eclipse.hyades.models.common.datapool.DPLDatapool;
21
import org.eclipse.hyades.models.common.datapool.DPLVariable;
22
import org.eclipse.hyades.models.common.util.EncryptionManager;
23
import org.eclipse.hyades.models.plugin.ModelsPlugin;
24
25
/**
26
 * It's used to provide functions of encryption for a datapool .
27
 * 
28
 * @author Huang Xin Ying 
29
 */
30
public class DatapoolEncryptManager {
31
32
	public static void encryptedCellInVarible(IDatapoolVariable varible,
33
			String key, IDatapool datapool) {
34
35
		int index = datapool.getDefaultEquivalenceClassIndex();
36
		if (index == -1) {
37
38
			return;
39
		}
40
		IDatapoolEquivalenceClass equivalenceClass = datapool
41
				.getEquivalenceClass(index);
42
		
43
		for (int i = 0; i < equivalenceClass.getRecordCount(); i++) {
44
			IDatapoolRecord record = (IDatapoolRecord) equivalenceClass
45
					.getRecord(i);			
46
			for (int k = 0; k < record.getCellCount(); k++) {
47
				IDatapoolCell cell = (IDatapoolCell) record.getCell(k);
48
				if (cell.getCellVariable().getId().equals(varible.getId())) {
49
					cell.setCellValue(EncryptionManager.encrypt(cell.getStringValue(),
50
							key));
51
				}
52
			}
53
		}
54
	}
55
56
	public static void decryptedCellInVarible(IDatapoolVariable varible,
57
			String key, IDatapool datapool) {
58
		int index = datapool.getDefaultEquivalenceClassIndex();
59
		if (index == -1) {
60
			return;
61
		}
62
		IDatapoolEquivalenceClass equivalenceClass = datapool
63
				.getEquivalenceClass(index);
64
65
		for (int i = 0; i < equivalenceClass.getRecordCount(); i++) {
66
			IDatapoolRecord record = (IDatapoolRecord) equivalenceClass
67
					.getRecord(i);			
68
			for (int k = 0; k < record.getCellCount(); k++) {
69
				IDatapoolCell cell = (IDatapoolCell) record.getCell(k);
70
				if (cell.getCellVariable().getId().equals(varible.getId())) {
71
					cell.setCellValue(EncryptionManager.decrypt(cell.getStringValue(),
72
							key));
73
				}
74
			}
75
		}
76
	}
77
78
	public static void changeKey(String newKey, IDatapool datapool) {
79
		if (!(datapool instanceof DPLDatapool))
80
			return;
81
		if (newKey == null || newKey.equals(""))
82
			((DPLDatapool) datapool).setChallenge(null);
83
		else
84
			((DPLDatapool) datapool).setChallenge(newKey);
85
	}
86
87
	public static void changeKeyOfEncryCell(IDatapool datapool, String oldKey,
88
			String newKey) {
89
		int variableCount = datapool.getVariableCount();
90
		IDatapoolVariable variable = null;
91
		for (int i = 0; i < variableCount; i++) {
92
			variable = datapool.getVariable(i);
93
			if (isVariabelEncrypted(variable)) {
94
				decryptedCellInVarible(variable, oldKey, datapool);
95
				encryptedCellInVarible(variable, newKey, datapool);
96
			}
97
		}
98
	}
99
	
100
	public static void decrypDatapool(IDatapool datapool, String key){
101
		int variableCount = datapool.getVariableCount();
102
		IDatapoolVariable variable = null;
103
		for (int i = 0; i < variableCount; i++) {
104
			variable = datapool.getVariable(i);
105
			if (isVariabelEncrypted(variable)) {
106
				decryptedCellInVarible(variable, key, datapool);				
107
			}
108
		}
109
	}
110
	
111
	public static void encrypDatapool(IDatapool datapool, String key){
112
		int variableCount = datapool.getVariableCount();
113
		IDatapoolVariable variable = null;
114
		for (int i = 0; i < variableCount; i++) {
115
			variable = datapool.getVariable(i);
116
			if (isVariabelEncrypted(variable)) {
117
				encryptedCellInVarible(variable, key, datapool);			
118
			}
119
		}
120
	}
121
122
	public static boolean isDatapoolEncrypted(IDatapool datapool) {
123
		if (!(datapool instanceof DPLDatapool))
124
			return false;
125
126
		if (((DPLDatapool) datapool).getChallenge() == null
127
				|| ((DPLDatapool) datapool).getChallenge().equals(""))
128
			return false;
129
		return true;
130
	}
131
132
	public static boolean isKeyCorrect(IDatapool datapool, String key) {
133
		if (!(datapool instanceof DPLDatapool))
134
			return false;
135
		if (key == null)
136
			return false;
137
		boolean flag = false;
138
		try {
139
			flag = EncryptionManager.EncoderByMd5(key).equals(
140
					((DPLDatapool) datapool).getChallenge());
141
		} catch (Exception e) {
142
			ModelsPlugin.getPlugin().log("invalid key exception occurs");
143
			ModelsPlugin.getPlugin().log(e);
144
		}
145
		return flag;
146
147
	}
148
149
	public static boolean isVariabelEncrypted(IDatapoolVariable varible) {
150
		return (varible instanceof DPLVariable) ? ((DPLVariable) varible)
151
				.isEncrypted() : false;
152
	}
153
154
	public static String encrypt(String content, String pass) {
155
		return EncryptionManager.encrypt(content, pass);
156
	}
157
158
	public static String decrypt(String content, String pass) {
159
		return EncryptionManager.decrypt(content, pass);
160
	}
161
162
}
(-)src-test/org/eclipse/hyades/models/common/datapool/util/DPLPasswordCollection.java (+48 lines)
Added Link Here
1
/********************************************************************** 
2
 * Copyright (c) 2008 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
 * $Id: DPLPasswordCollection.java,v 1.0 2008/01/16 14:42:35 Xin Ying Exp $ 
8
 * 
9
 * Contributors: 
10
 * IBM - Initial API and implementation 
11
 **********************************************************************/ 
12
package org.eclipse.hyades.models.common.datapool.util;
13
14
import java.util.HashMap;
15
16
/**
17
 * It's used to save HashMap of datapools and passwords for the test 
18
 * during executing a test in agent controller side .
19
 * 
20
 * @author Huang Xin Ying 
21
 */
22
public class DPLPasswordCollection {
23
	private static DPLPasswordCollection instance = null;
24
25
	private HashMap datapoolPassword = new HashMap();
26
27
	private DPLPasswordCollection() {
28
	}
29
30
	public static DPLPasswordCollection getInstance() {
31
		if (instance == null) {
32
			instance = new DPLPasswordCollection();
33
		} 
34
		return instance;
35
	}
36
37
	public HashMap getDatapoolPassword() {
38
		return datapoolPassword;
39
	}
40
41
	public void setDatapoolPassword(HashMap datapoolPassword) {
42
		this.datapoolPassword = datapoolPassword;
43
	}
44
	
45
	public void clear(){
46
		this.datapoolPassword.clear();
47
	}	
48
}

Return to bug 202695