Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 116938 Details for
Bug 249588
Datapool (CSV) import/export wizard/operation is slow when importing large CSV files.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch (Part 1).
Defect_249588_Patch_Part_1.txt (text/plain), 21.07 KB, created by
Paul Slauenwhite
on 2008-11-04 09:53:23 EST
(
hide
)
Description:
Patch (Part 1).
Filename:
MIME Type:
Creator:
Paul Slauenwhite
Created:
2008-11-04 09:53:23 EST
Size:
21.07 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.hyades.test.ui >Index: src/org/eclipse/hyades/test/ui/internal/wizard/DatapoolImportWizard.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/wizard/DatapoolImportWizard.java,v >retrieving revision 1.17 >diff -u -r1.17 DatapoolImportWizard.java >--- src/org/eclipse/hyades/test/ui/internal/wizard/DatapoolImportWizard.java 4 Nov 2008 14:20:23 -0000 1.17 >+++ src/org/eclipse/hyades/test/ui/internal/wizard/DatapoolImportWizard.java 4 Nov 2008 14:51:07 -0000 >@@ -46,7 +46,7 @@ > * > * @author Bianca Xue Jiang > * @author Paul E. Slauenwhite >- * @version October 31, 2008 >+ * @version November 4, 2008 > * @since March 18, 2005 > */ > public class DatapoolImportWizard extends Wizard implements IImportWizard { >@@ -110,128 +110,115 @@ > */ > public boolean performFinish() { > >- IRunnableWithProgress operation = new WorkspaceModifyOperation() { >- >- public void execute(IProgressMonitor monitor) throws InvocationTargetException { >- >- monitor.beginTask(UiPluginResourceBundle.DatapoolImportWizard_progressMonitor, 4); >- >- try { >- >- IDatapool datapool = datapoolImportPageTwo.getSelectedDatapool(); >- >- monitor.worked(1); >- >- if(datapool == null){ >- >- //Assumption: The file name will include the file extension (see org.eclipse.tptp.platform.common.ui.wizard.LocationPage.getFileName()). >- String datapoolFileName = locationPage.getFileName(); >- >- datapool = ((DPLDatapool)(DatapoolUtil.createNewDatapool(datapoolFileName.substring(0, datapoolFileName.indexOf('.')), null))); >- >- Resource datapoolResource = EMFUtil.getResourceFactory(locationPage.getFileExtension()).createResource(URI.createPlatformResourceURI(locationPage.getContainerFullPath().append(datapoolFileName).toOSString(), false)); >- datapoolResource.getContents().add(datapool); >- } >- >- //If the existing datapool only contains only an empty default cell, empty the datapool: >- else if(CSVImportExportUtil.getInstance().isDefaultEmptyDatapool(datapool)){ >- >- datapool.removeVariable(0); >- datapool.removeEquivalenceClass(0); >- } >- >- String key = datapoolImportPageTwo.getEncryptedDatapoolPasswordText().getText(); >- >- if(datapoolImportPageTwo.isEncrypted()){ >- if(!DatapoolEncryptManager.isKeyCorrect(datapool, key)){ >- datapoolImportPageTwo.setMessage(UiPluginResourceBundle.DatapoolExportWizard_wrongpass,3); >- datapoolImportPageTwo.getEncryptedDatapoolPasswordText().setText(""); >- datapoolImportPageTwo.getEncryptedDatapoolPasswordText().setFocus(); >- throw new Exception("Password is not correct!"); >- } >- } >- >- if( DatapoolEncryptManager.isDatapoolEncrypted(datapool)) >- { >- DatapoolEncryptManager.decryptDatapool(datapool, key); >- } >- >- monitor.worked(1); >- >- if(datapool.getVariableCount() == 0){ >- >- CSVImportExportUtil.getInstance().importCSV(datapool, >- datapoolImportPage.getCSVFileName(), >- datapoolImportPage.firstRowContainsVariableNameType(), >- datapoolImportPage.firstColumnContainsEquivalenceClassName(), >- datapoolImportPage.getImportEncoding()); >- } >- else{ >- >- CSVImportExportUtil.getInstance().appendFromCSV(datapool, >- datapoolImportPage.getCSVFileName(), >- datapoolImportPage.firstRowContainsVariableNameType(), >- datapoolImportPage.firstColumnContainsEquivalenceClassName(), >- datapoolImportPage.getImportEncoding()); >- } >- >- monitor.worked(1); >- >- if( DatapoolEncryptManager.isDatapoolEncrypted(datapool)) >- { >- DatapoolEncryptManager.encryptDatapool(datapool, key); >- } >- >- Resource datapoolResource = ((EObject)(datapool)).eResource(); >- >- //Save (or serialize) the datapool resource to the workspace: >- EMFUtil.save(datapoolResource); >- >- //Attempt to open the editor: >- TestUIUtilities.openEditor(datapoolResource, TestUIExtension.DATAPOOL_EDITOR_PART_ID); >- >- monitor.worked(1); >- } >- catch(Exception e){ >- >- UiPlugin.logError(e); >- >- new ErrorDialog(getShell(), >- UiPluginResourceBundle.WIZ_DATAPOOL_CSV_ERRDLG_TITLE, >- UiPluginResourceBundle._ERROR_WIZ_DATAPOOL_CSV_ERRDLG_IMPFILE, >- new Status(IStatus.ERROR, >- UiPlugin.PLUGIN_ID, >- IStatus.OK, >- e.toString(), >- e), >- IStatus.ERROR).open(); >- } >- finally{ >- monitor.done(); >- } >- } >- }; >- >- try { >- String key = datapoolImportPageTwo.getEncryptedDatapoolPasswordText().getText(); >- IDatapool datapool = datapoolImportPageTwo.getSelectedDatapool(); >- if(datapoolImportPageTwo.isEncrypted()){ >- if(!DatapoolEncryptManager.isKeyCorrect(datapool, key)){ >- datapoolImportPageTwo.setMessage(UiPluginResourceBundle.DatapoolExportWizard_wrongpass,3); >- datapoolImportPageTwo.getEncryptedDatapoolPasswordText().setText(""); >- datapoolImportPageTwo.getEncryptedDatapoolPasswordText().setFocus(); >- return false; >+ IRunnableWithProgress operation = new WorkspaceModifyOperation() { >+ >+ public void execute(IProgressMonitor monitor) throws InvocationTargetException { >+ >+ monitor.beginTask(UiPluginResourceBundle.DatapoolImportWizard_progressMonitor, 4); >+ >+ //Resolve the selected datapool: >+ IDatapool datapool = datapoolImportPageTwo.getSelectedDatapool(); >+ boolean isEncrypted = datapoolImportPageTwo.isSelectedDatapoolEncrypted(); >+ String password = datapoolImportPageTwo.getEncryptedDatapoolPassword(); >+ >+ try { >+ >+ monitor.worked(1); >+ >+ if(datapool != null){ >+ >+ if(isEncrypted){ >+ DatapoolEncryptManager.decryptDatapool(datapool, password); >+ } >+ >+ //Empty the datapool if it contains only an empty default cell: >+ if(CSVImportExportUtil.getInstance().isDefaultEmptyDatapool(datapool)){ >+ >+ datapool.removeVariable(0); >+ datapool.removeEquivalenceClass(0); >+ } >+ } >+ else { >+ >+ //Assumption: The file name will include the file extension (see org.eclipse.tptp.platform.common.ui.wizard.LocationPage.getFileName()). >+ String datapoolFileName = locationPage.getFileName(); >+ >+ //Create a new datapool: >+ datapool = ((DPLDatapool)(DatapoolUtil.createNewDatapool(datapoolFileName.substring(0, datapoolFileName.indexOf('.')), null))); >+ >+ //Create the resource and add the datapool: >+ EMFUtil.getResourceFactory(locationPage.getFileExtension()).createResource(URI.createPlatformResourceURI(locationPage.getContainerFullPath().append(datapoolFileName).toOSString(), false)).getContents().add(datapool); >+ } >+ >+ monitor.worked(1); >+ >+ if(datapool.getVariableCount() == 0){ >+ >+ //Import the CSV file to the datapool: >+ CSVImportExportUtil.getInstance().importCSV(datapool, >+ datapoolImportPage.getCSVFileName(), >+ datapoolImportPage.firstRowContainsVariableNameType(), >+ datapoolImportPage.firstColumnContainsEquivalenceClassName(), >+ datapoolImportPage.getImportEncoding()); >+ } >+ else{ >+ >+ //Append the CSV file to the datapool: >+ CSVImportExportUtil.getInstance().appendFromCSV(datapool, >+ datapoolImportPage.getCSVFileName(), >+ datapoolImportPage.firstRowContainsVariableNameType(), >+ datapoolImportPage.firstColumnContainsEquivalenceClassName(), >+ datapoolImportPage.getImportEncoding()); >+ } >+ >+ monitor.worked(1); >+ >+ Resource datapoolResource = ((EObject)(datapool)).eResource(); >+ >+ //Save (or serialize) the datapool resource to the workspace: >+ EMFUtil.save(datapoolResource); >+ >+ //Attempt to open the editor: >+ TestUIUtilities.openEditor(datapoolResource, TestUIExtension.DATAPOOL_EDITOR_PART_ID); >+ >+ monitor.worked(1); >+ } >+ catch(Exception e){ >+ >+ UiPlugin.logError(e); >+ >+ new ErrorDialog(getShell(), >+ UiPluginResourceBundle.WIZ_DATAPOOL_CSV_ERRDLG_TITLE, >+ UiPluginResourceBundle._ERROR_WIZ_DATAPOOL_CSV_ERRDLG_IMPFILE, >+ new Status(IStatus.ERROR, >+ UiPlugin.PLUGIN_ID, >+ IStatus.OK, >+ e.toString(), >+ e), >+ IStatus.ERROR).open(); >+ } >+ finally{ >+ >+ //Encrypted the datapool if decrypted: >+ if(isEncrypted){ >+ DatapoolEncryptManager.encryptDatapool(datapool, password); >+ } >+ >+ monitor.done(); > } > } >- getContainer().run(false, false, operation); >- } >- catch (InvocationTargetException e) { >- UiPlugin.logError(e); >- } >- catch (InterruptedException e) { >- //Ignore since the operation cannot be cancelled. >- } >- >+ }; >+ >+ try { >+ getContainer().run(false, false, operation); >+ } >+ catch (InvocationTargetException e) { >+ UiPlugin.logError(e); >+ } >+ catch (InterruptedException e) { >+ //Ignore since the operation cannot be canceled. >+ } >+ > return true; > } > } >Index: src/org/eclipse/hyades/test/ui/internal/wizard/DatapoolExportWizard.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/wizard/DatapoolExportWizard.java,v >retrieving revision 1.14 >diff -u -r1.14 DatapoolExportWizard.java >--- src/org/eclipse/hyades/test/ui/internal/wizard/DatapoolExportWizard.java 4 Nov 2008 14:20:23 -0000 1.14 >+++ src/org/eclipse/hyades/test/ui/internal/wizard/DatapoolExportWizard.java 4 Nov 2008 14:51:07 -0000 >@@ -19,10 +19,12 @@ > import org.eclipse.core.runtime.Path; > import org.eclipse.hyades.edit.datapool.IDatapool; > import org.eclipse.hyades.models.common.datapool.util.DatapoolEncryptManager; >+import org.eclipse.hyades.test.ui.TestUI; > import org.eclipse.hyades.test.ui.TestUIImages; > import org.eclipse.hyades.test.ui.UiPlugin; > import org.eclipse.hyades.test.ui.datapool.internal.util.CSVImportExportUtil; > import org.eclipse.hyades.test.ui.internal.resources.UiPluginResourceBundle; >+import org.eclipse.hyades.test.ui.util.TestUIUtil; > import org.eclipse.jface.dialogs.IDialogConstants; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.viewers.IStructuredSelection; >@@ -38,7 +40,7 @@ > > * @author Peter Sun > * @author Paul E. Slauenwhite >- * @version October 31, 2008 >+ * @version November 4, 2008 > * @since February 1, 2005 > */ > public class DatapoolExportWizard extends Wizard implements IExportWizard { >@@ -49,6 +51,7 @@ > public DatapoolExportWizard() > { > super(); >+ > setDefaultPageImageDescriptor(TestUIImages.INSTANCE.getImageDescriptor(TestUIImages.IMG_WIZBAN_EXPORT_DATAPOOL)); > } > >@@ -68,7 +71,6 @@ > super.createPageControls(pageContainer); > } > >- > public void addPages() > { > csvFileLocationPage = new DatapoolExportCSVFileLocationPage("csvFileSelection"); >@@ -90,66 +92,68 @@ > /* (non-Javadoc) > * @see org.eclipse.jface.wizard.IWizard#performFinish() > */ >- public boolean performFinish() >- { >+ public boolean performFinish() { >+ >+ //Resolve the selected datapool: >+ //Assumption: The datapool is not null. > IDatapool datapool = datapoolSelectionPage.getSelectedDatapool(); >- String key = datapoolSelectionPage.getEncryptedDatapoolPasswordText().getText(); >- >- if(datapoolSelectionPage.isEncrypted()){ >- if(!DatapoolEncryptManager.isKeyCorrect(datapool, key)){ >- datapoolSelectionPage.setMessage(UiPluginResourceBundle.DatapoolExportWizard_wrongpass,3); >- datapoolSelectionPage.getEncryptedDatapoolPasswordText().setText(""); >- datapoolSelectionPage.getEncryptedDatapoolPasswordText().setFocus(); >- return false; >+ boolean isEncrypted = datapoolSelectionPage.isSelectedDatapoolEncrypted(); >+ String password = datapoolSelectionPage.getEncryptedDatapoolPassword(); >+ >+ try { >+ >+ //Decrypt the datapool if encrypted: >+ if(isEncrypted){ >+ DatapoolEncryptManager.decryptDatapool(datapool, password); > } >- } >- >- //decrypt datapool before export it into csv file >- if( DatapoolEncryptManager.isDatapoolEncrypted(datapool)) >- { >- DatapoolEncryptManager.decryptDatapool(datapool, key); >- } >- String csvFileName = csvFileLocationPage.getCSVFileName(); >- if(!csvFileName.endsWith(".csv") && !csvFileName.endsWith(".CSV")) >- csvFileName = csvFileName + ".csv"; > >- File file = new File(csvFileName); >- >- if (file.exists()) >- { >- String message = NLS.bind(UiPluginResourceBundle.WIZ_EXP_DATAPOOL_MSG_EXISTS, csvFileName); >- MessageDialog overwriteDialog = new MessageDialog(getShell(), >- UiPluginResourceBundle.WIZ_EXP_DATAPOOL_TTL, >- null, >- message, >- MessageDialog.WARNING, >- new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}, >- 0); >- >- // user selected - "don't replace", return false >- if (overwriteDialog.open() != 0) >- return false; >+ //Resolve the CSV file: >+ String csvFileName = TestUIUtil.validateExtension(csvFileLocationPage.getCSVFileName().trim(), TestUI.CSV_FILE_EXTENSION); >+ >+ if (new File(csvFileName).exists()){ >+ >+ MessageDialog overwriteDialog = new MessageDialog(getShell(), >+ UiPluginResourceBundle.WIZ_EXP_DATAPOOL_TTL, >+ null, >+ NLS.bind(UiPluginResourceBundle.WIZ_EXP_DATAPOOL_MSG_EXISTS, csvFileName), >+ MessageDialog.WARNING, >+ new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL}, >+ 0); >+ >+ //Return if cannot replace existing CSV file: >+ if (overwriteDialog.open() != IDialogConstants.OK_ID){ >+ return false; >+ } >+ } >+ >+ //Export the datapool to the CSV file: >+ boolean isDatapoolExported = CSVImportExportUtil.getInstance().exportCSV(datapool, csvFileName, >+ csvFileLocationPage.getExportVariables(), >+ csvFileLocationPage.getExportEquivalenceClassNames(), >+ csvFileLocationPage.getExportTags(), >+ csvFileLocationPage.getExportEncoding()); >+ >+ //Refresh the CSV file if exported to the workspace: >+ IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(csvFileName)); >+ >+ for (int counter = 0; counter < files.length; counter++) { >+ >+ try { >+ files[counter].refreshLocal(0, null); >+ } >+ catch (CoreException e) { >+ UiPlugin.logError(e); >+ } >+ } >+ >+ return isDatapoolExported; > } >- >- boolean exportVariables = csvFileLocationPage.getExportVariables(); >- boolean exportEqClsNames = csvFileLocationPage.getExportEquivalenceClassNames(); >- boolean exportTags = csvFileLocationPage.getExportTags(); >- String exportEncoding = csvFileLocationPage.getExportEncoding(); >- boolean close = CSVImportExportUtil.getInstance().exportCSV(datapool, csvFileName, exportVariables, exportEqClsNames, exportTags, exportEncoding); >- IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(csvFileName)); >- for (int i = 0; i < files.length; i++) { >- try { >- files[i].refreshLocal(0, null); >- } catch (CoreException e) { >- UiPlugin.logError(e); >- } >- } >- >- //encrypted datapool again after finish export it >- if( DatapoolEncryptManager.isDatapoolEncrypted(datapool)) >- { >- DatapoolEncryptManager.encryptDatapool(datapool, key); >+ finally{ >+ >+ //Encrypted the datapool if decrypted: >+ if(isEncrypted){ >+ DatapoolEncryptManager.encryptDatapool(datapool, password); >+ } > } >- return close; > } > } >Index: src/org/eclipse/hyades/test/ui/internal/wizard/DatapoolSelectionPage.java >=================================================================== >RCS file: /cvsroot/tptp/test/org.eclipse.hyades.test.ui/src/org/eclipse/hyades/test/ui/internal/wizard/DatapoolSelectionPage.java,v >retrieving revision 1.1 >diff -u -r1.1 DatapoolSelectionPage.java >--- src/org/eclipse/hyades/test/ui/internal/wizard/DatapoolSelectionPage.java 4 Nov 2008 14:20:23 -0000 1.1 >+++ src/org/eclipse/hyades/test/ui/internal/wizard/DatapoolSelectionPage.java 4 Nov 2008 14:51:07 -0000 >@@ -38,7 +38,7 @@ > * > * > * @author Paul E. Slauenwhite >- * @version October 31, 2008 >+ * @version November 4, 2008 > * @since October 31, 2008 > */ > public class DatapoolSelectionPage extends WizardPage { >@@ -48,7 +48,7 @@ > private Text encryptedDatapoolPasswordText = null; > private IStructuredSelection selection = null; > private IDatapool selectedDatapool = null; >- private boolean isEncrypted = false; >+ private boolean isSelectedDatapoolEncrypted = false; > > public DatapoolSelectionPage(String name){ > this(name, null); >@@ -80,7 +80,7 @@ > super.setSelection(); > > selectedDatapool = null; >- isEncrypted = false; >+ isSelectedDatapoolEncrypted = false; > > IProxyNode[] selectedProxyNodes = datapoolSelectionViewer.getSelectedProxyNodes(); > >@@ -93,12 +93,9 @@ > selectedDatapool = ((IDatapool)(eObject)); > > //Determine if the selected datapool is encrypted: >- isEncrypted = DatapoolEncryptManager.isDatapoolEncrypted(selectedDatapool); >+ isSelectedDatapoolEncrypted = DatapoolEncryptManager.isDatapoolEncrypted(selectedDatapool); > >- //Show or hide the encrypted datapool password group: >- encryptedDatapoolPasswordGroup.setVisible(isEncrypted); >- >- if(isEncrypted){ >+ if((isSelectedDatapoolEncrypted) && (!encryptedDatapoolPasswordGroup.isVisible())){ > > //Set the title of the encrypted datapool password group: > encryptedDatapoolPasswordGroup.setText(NLS.bind(UiPluginResourceBundle.DatapoolExportWizard_password, selectedDatapool.getName())); >@@ -107,6 +104,9 @@ > encryptedDatapoolPasswordText.setText(""); > encryptedDatapoolPasswordText.setFocus(); > } >+ >+ //Show or hide the encrypted datapool password group: >+ encryptedDatapoolPasswordGroup.setVisible(isSelectedDatapoolEncrypted); > } > } > >@@ -127,19 +127,7 @@ > encryptedDatapoolPasswordText.addModifyListener(new ModifyListener(){ > > public void modifyText(ModifyEvent e){ >- >- if(encryptedDatapoolPasswordText.getText().trim().length() > 0){ >- >- setErrorMessage(null); >- >- setPageComplete(true); >- } >- else { >- >- setErrorMessage(NLS.bind(UiPluginResourceBundle.DatapoolExportWizard_encrypted, selectedDatapool.getName())); >- >- setPageComplete(false); >- } >+ setPageComplete(validatePage()); > } > }); > >@@ -153,39 +141,55 @@ > public IDatapool getSelectedDatapool(){ > return selectedDatapool; > } >- >- public Text getEncryptedDatapoolPasswordText(){ >- return encryptedDatapoolPasswordText; >- } > >- public boolean isEncrypted(){ >- return isEncrypted; >+ public boolean isSelectedDatapoolEncrypted(){ >+ return isSelectedDatapoolEncrypted; > } > >+ public String getEncryptedDatapoolPassword(){ >+ return (encryptedDatapoolPasswordText.getText().trim()); >+ } >+ > protected boolean validatePage() { > > //Note: The error message is not initially reset to reduce flicker when setting the same error message. > boolean isValid = false; >- >+ > //Validate the selected datapool: > if(selectedDatapool != null){ > > //Validate the selected encrypted datapool and its password: >- if((isEncrypted) && (encryptedDatapoolPasswordText.getText().trim().length() == 0)){ >+ if(isSelectedDatapoolEncrypted){ >+ >+ String password = getEncryptedDatapoolPassword(); > >- setErrorMessage(NLS.bind(UiPluginResourceBundle.DatapoolExportWizard_encrypted, selectedDatapool.getName())); >+ if(password.length() == 0){ >+ >+ setErrorMessage(NLS.bind(UiPluginResourceBundle.DatapoolExportWizard_encrypted, selectedDatapool.getName())); >+ >+ //Set focus to the encrypted datapool password: >+ encryptedDatapoolPasswordText.setFocus(); >+ } >+ else if(!DatapoolEncryptManager.isKeyCorrect(selectedDatapool, password)){ > >- //Set focus to the encrypted datapool password: >- encryptedDatapoolPasswordText.setFocus(); >+ setErrorMessage(UiPluginResourceBundle.DatapoolExportWizard_wrongpass); >+ >+ //Set focus to the encrypted datapool password: >+ encryptedDatapoolPasswordText.setFocus(); >+ } >+ else{ >+ isValid = true; >+ } > } > else{ >- > isValid = true; >- >- setErrorMessage(null); > } > } > >+ if(isValid){ >+ setErrorMessage(null); >+ } >+ > return isValid; > } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 249588
:
116938
|
117601
|
118161
|
118162