Skip to content

Commit

Permalink
Fetch modified objects for pull in Modal thread (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamWaghmare-sap authored Oct 16, 2024
1 parent 4dcaf3b commit 63df509
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public class Messages extends NLS {
public static String AbapGitWizardPageBranchAndPackage_btn_browse;
public static String AbapGitWizardPageBranchAndPackage_combobox_branch_message;
public static String AbapGitWizardPageBranchAndPackage_description;
public static String AbapGitWizardPageBranchAndPackage_FetchingModifiedObjectsForPull;
public static String AbapGitWizardPageBranchAndPackageAndFolderLogic_description;
public static String AbapGitWizardPageFolderLogic_AlreadyExists_Full;
public static String AbapGitWizardPageFolderLogic_AlreadyExists_Prefix;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ AbapGitWizardPageBranchAndPackage_chbox_activate_tooltip=Try to activate all obj
AbapGitWizardPageBranchAndPackage_btn_browse=Browse...
AbapGitWizardPageBranchAndPackage_combobox_branch_message=Specify a branch
AbapGitWizardPageBranchAndPackage_description=Select repository branch, target ABAP package
AbapGitWizardPageBranchAndPackage_FetchingModifiedObjectsForPull=Fetching objects differing between local and remote repository.
AbapGitWizardPageBranchAndPackageAndFolderLogic_description=Select repository branch, target ABAP package and folder logic
AbapGitWizardPageBranchAndPackage_label_branch=Branch\:
AbapGitWizardPageBranchAndPackage_label_package=Package\:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,20 +268,20 @@ public void handlePageChanging(final PageChangingEvent event) {
return;
}

//-> Any Page -> Folder Logic page
//-> Any Page -> Folder Logic page
//(If only linking a repository and no APACK dependencies, no need to show transport page and finish wizard )
if (event.getTargetPage() == AbapGitWizard.this.pageFolderlogic && !AbapGitWizard.this.pageBranchAndPackage.getLnpSequence() && !AbapGitWizard.this.cloneData.hasDependencies() ) {
AbapGitWizard.this.transportPage.setPageComplete(true);
AbapGitWizard.this.pageFolderlogic.setPageComplete(true);
}

// -> Folder Logic page -> Branch & Package page
if (event.getCurrentPage() == AbapGitWizard.this.pageFolderlogic
&& event.getTargetPage() == AbapGitWizard.this.pageBranchAndPackage) {
AbapGitWizard.this.transportPage.setPageComplete(false);
}

//-> Any Page -> APACK page
//-> Any Page -> APACK page
//(If only linking a repository, no need to show transport page and finish wizard)
if (event.getTargetPage() == AbapGitWizard.this.pageApack && !AbapGitWizard.this.pageBranchAndPackage.getLnpSequence()) {
AbapGitWizard.this.transportPage.setPageComplete(true);
Expand Down Expand Up @@ -375,22 +375,47 @@ public boolean hasDependencies() {

/**
* Fetch the modified objects for the main repository and dependencies (if
* any) Then maintain the overWrite objects and warning package objects,
* separately in the clone data object
* any). Then maintain the overWrite objects and warning package objects,
* separately in the clone data object.
*
* Return true in case there are modified objects, otherwise return false.
*/
private boolean fillModifiedObjectsinCloneData(IRepositoryService repoService, IRepository repository) {

IRepositories repositories = repoService.getRepositories(new NullProgressMonitor());

RepositoryUtil.fetchAndExtractModifiedObjectsToPull(repository, repoService, this.cloneData);
try {
getContainer().run(true, true, new IRunnableWithProgress() {

@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(Messages.AbapGitWizardPageBranchAndPackage_FetchingModifiedObjectsForPull, IProgressMonitor.UNKNOWN);
RepositoryUtil.fetchAndExtractModifiedObjectsToPull(repository, repoService, AbapGitWizard.this.cloneData);
}
});
} catch (InvocationTargetException | InterruptedException e) {
e.printStackTrace();
}

if (this.cloneData.hasDependencies()) {
for (IApackDependency apackDependency : this.cloneData.apackManifest.getDescriptor().getDependencies()) {
IRepository dependencyRepository = repoService.getRepositoryByURL(repositories, apackDependency.getGitUrl());
if (dependencyRepository != null) {
RepositoryUtil.fetchAndExtractModifiedObjectsToPull(dependencyRepository, repoService, this.cloneData);

try {
getContainer().run(true, true, new IRunnableWithProgress() {

@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(Messages.AbapGitWizardPageBranchAndPackage_FetchingModifiedObjectsForPull,
IProgressMonitor.UNKNOWN);
RepositoryUtil.fetchAndExtractModifiedObjectsToPull(dependencyRepository, repoService,
AbapGitWizard.this.cloneData);
}
});
} catch (InvocationTargetException | InterruptedException e) {
e.printStackTrace();
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;

import com.sap.adt.communication.resources.ResourceException;
import com.sap.adt.tools.core.model.adtcore.IAdtCoreFactory;
import com.sap.adt.tools.core.model.adtcore.IAdtObjectReference;
import com.sap.adt.tools.core.ui.packages.AdtPackageServiceUIFactory;
Expand Down Expand Up @@ -390,8 +389,17 @@ public IWizardPage getNextPage() {
// If selectivePull is not supported, fetching modified objects is not required and all objects are to be pulled
if (dependencyRepository != null && abapGitService.isSelectivePullSupported(dependencyRepository)) {
try {
RepositoryUtil.fetchAndExtractModifiedObjectsToPull(dependencyRepository, repoService, this.cloneData);
} catch (ResourceException e) {
getContainer().run(true, true, new IRunnableWithProgress() {

@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(Messages.AbapGitWizardPageBranchAndPackage_FetchingModifiedObjectsForPull,
IProgressMonitor.UNKNOWN);
RepositoryUtil.fetchAndExtractModifiedObjectsToPull(dependencyRepository, repoService,
AbapGitWizardPageApack.this.cloneData);
}
});
} catch (InvocationTargetException | InterruptedException e) {
setMessage(e.getMessage(), DialogPage.ERROR);
setPageComplete(false);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;

import com.sap.adt.communication.resources.ResourceException;
import com.sap.adt.tools.core.model.adtcore.IAdtObjectReference;
import com.sap.adt.tools.core.ui.packages.AdtPackageProposalProviderFactory;
import com.sap.adt.tools.core.ui.packages.AdtPackageServiceUIFactory;
Expand Down Expand Up @@ -318,8 +317,16 @@ public IWizardPage getNextPage() {
// If selectivePull is not supported, fetching modified objects is not required and all objects are to be pulled
if (abapGitService.isSelectivePullSupported(repository)) {
try {
RepositoryUtil.fetchAndExtractModifiedObjectsToPull(repository, repoService, this.cloneData);
} catch (ResourceException e) {
getContainer().run(true, true, new IRunnableWithProgress() {

@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask(Messages.AbapGitWizardPageBranchAndPackage_FetchingModifiedObjectsForPull, IProgressMonitor.UNKNOWN);
RepositoryUtil.fetchAndExtractModifiedObjectsToPull(repository, repoService,
AbapGitWizardPageBranchAndPackage.this.cloneData);
}
});
} catch (InvocationTargetException | InterruptedException e) {
setMessage(e.getMessage(), DialogPage.ERROR);
setPageComplete(false);
return null;
Expand Down

0 comments on commit 63df509

Please sign in to comment.