-
Notifications
You must be signed in to change notification settings - Fork 24
Run transport check in a new thread to prevent UI freeze #291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aarnapant-sap
wants to merge
5
commits into
abapGit:master
Choose a base branch
from
aarnapant-sap:fix/transport-check-freezing-bug
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6bbc773
Run transport check in a new thread to prevent UI freeze
aarnapant-sap 782a558
switched to progress monitor in wizard container instead of a pop-up
aarnapant-sap 1ceb06b
modularization of check data method and exception handling
aarnapant-sap ef9c974
removed inner try block so that OutdatedClientException can be caught
aarnapant-sap bd488a1
review comments changes
aarnapant-sap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,10 +29,12 @@ | |
import org.eclipse.jface.wizard.Wizard; | ||
import org.eclipse.jface.wizard.WizardDialog; | ||
import org.eclipse.jface.wizard.WizardPage; | ||
import org.eclipse.swt.widgets.Display; | ||
import org.eclipse.ui.PlatformUI; | ||
import org.eclipse.ui.plugin.AbstractUIPlugin; | ||
|
||
import com.sap.adt.communication.resources.ResourceException; | ||
import com.sap.adt.compatibility.exceptions.OutDatedClientException; | ||
import com.sap.adt.tools.core.model.adtcore.IAdtCoreFactory; | ||
import com.sap.adt.tools.core.model.adtcore.IAdtObjectReference; | ||
import com.sap.adt.tools.core.project.AdtProjectServiceFactory; | ||
|
@@ -43,6 +45,7 @@ | |
import com.sap.adt.transport.IAdtTransportService; | ||
import com.sap.adt.transport.ui.wizard.AdtTransportSelectionWizardPageFactory; | ||
import com.sap.adt.transport.ui.wizard.IAdtTransportSelectionWizardPage; | ||
import com.sap.adt.util.ui.AdtUtilUiPlugin; | ||
|
||
/** | ||
* This is wizard that handles pull action on a repository. Includes selective | ||
|
@@ -303,22 +306,12 @@ public void handlePageChanging(final PageChangingEvent event) { | |
|
||
//-> Prepare transport page | ||
if (event.getTargetPage() == AbapGitWizardPull.this.transportPage) { | ||
try { | ||
// The transport service requires URIs to objects we want to create in the | ||
// target package. | ||
// However, we do not know these URIs from the client. | ||
// Instead, give it the URI of the package in which we clone. | ||
IAdtObjectReference packageRef = AbapGitWizardPull.this.cloneData.packageRef; | ||
IAdtObjectReference checkRef = IAdtCoreFactory.eINSTANCE.createAdtObjectReference(); | ||
checkRef.setUri(packageRef.getUri()); | ||
IAdtTransportCheckData checkData = AbapGitWizardPull.this.transportService.check(checkRef, packageRef.getPackageName(), | ||
true); | ||
AbapGitWizardPull.this.transportPage.setCheckData(checkData); | ||
} catch (Exception e) { | ||
AbapGitWizardPull.this.pageBranchAndPackage.setMessage(e.getMessage(), DialogPage.ERROR); | ||
} | ||
IAdtObjectReference packageRef = AbapGitWizardPull.this.cloneData.packageRef; | ||
IAdtTransportCheckData transportCheckData = getTransportCheckData(packageRef); | ||
AbapGitWizardPull.this.transportPage.setCheckData(transportCheckData); | ||
} | ||
|
||
|
||
//-> APACK page -> Any page | ||
if (event.getCurrentPage() == AbapGitWizardPull.this.pageApack) { | ||
if (!AbapGitWizardPull.this.pageApack.validateAll()) { | ||
|
@@ -327,5 +320,55 @@ public void handlePageChanging(final PageChangingEvent event) { | |
} | ||
} | ||
} | ||
|
||
private IAdtTransportCheckData getTransportCheckData(IAdtObjectReference packageRef) { | ||
|
||
IAdtObjectReference checkRef = IAdtCoreFactory.eINSTANCE.createAdtObjectReference(); | ||
checkRef.setUri(packageRef.getUri()); | ||
|
||
final IAdtTransportCheckData[] checkData = new IAdtTransportCheckData[1]; | ||
|
||
try { | ||
getContainer().run(true, true, monitor -> { | ||
monitor.beginTask(Messages.AbapGitWizardPageTransportSelection_transport_check, IProgressMonitor.UNKNOWN); | ||
checkData[0] = AbapGitWizardPull.this.transportService.check(checkRef, packageRef.getPackageName(), true); | ||
}); | ||
return checkData[0]; | ||
|
||
} catch (Exception e) { | ||
// Catches InterruptedException and other general exceptions | ||
WizardPage currentPage = ((WizardPage) getContainer().getCurrentPage()); | ||
handleException(e, currentPage); | ||
return null; | ||
} | ||
} | ||
|
||
private void handleOutdatedClientException(Throwable e) { | ||
|
||
Display.getDefault().asyncExec(() -> { | ||
WizardDialog d = (WizardDialog) getContainer(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. d -> dialog There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure |
||
|
||
if (d != null) { | ||
// Check if the dialog is still open before attempting to close | ||
if (d.getShell() != null && !d.getShell().isDisposed()) { | ||
d.close(); | ||
AdtUtilUiPlugin.getDefault().getAdtStatusService().handle(e, null); | ||
} | ||
} | ||
}); | ||
|
||
} | ||
|
||
private void handleException(Exception exception, WizardPage page) { | ||
|
||
page.setPageComplete(false); | ||
Throwable cause = exception instanceof InvocationTargetException ? exception.getCause() : exception; | ||
if (cause != null && cause instanceof OutDatedClientException) { | ||
handleOutdatedClientException(cause); | ||
} else { | ||
page.setMessage(cause != null ? cause.getMessage() : exception.getMessage(), DialogPage.ERROR); | ||
} | ||
} | ||
|
||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.