2929import org .eclipse .jface .wizard .Wizard ;
3030import org .eclipse .jface .wizard .WizardDialog ;
3131import org .eclipse .jface .wizard .WizardPage ;
32+ import org .eclipse .swt .widgets .Display ;
3233import org .eclipse .ui .PlatformUI ;
3334import org .eclipse .ui .plugin .AbstractUIPlugin ;
3435
3536import com .sap .adt .communication .resources .ResourceException ;
37+ import com .sap .adt .compatibility .exceptions .OutDatedClientException ;
3638import com .sap .adt .tools .core .model .adtcore .IAdtCoreFactory ;
3739import com .sap .adt .tools .core .model .adtcore .IAdtObjectReference ;
3840import com .sap .adt .tools .core .project .AdtProjectServiceFactory ;
4345import com .sap .adt .transport .IAdtTransportService ;
4446import com .sap .adt .transport .ui .wizard .AdtTransportSelectionWizardPageFactory ;
4547import com .sap .adt .transport .ui .wizard .IAdtTransportSelectionWizardPage ;
48+ import com .sap .adt .util .ui .AdtUtilUiPlugin ;
4649
4750/**
4851 * This is wizard that handles pull action on a repository. Includes selective
@@ -303,22 +306,12 @@ public void handlePageChanging(final PageChangingEvent event) {
303306
304307 //-> Prepare transport page
305308 if (event .getTargetPage () == AbapGitWizardPull .this .transportPage ) {
306- try {
307- // The transport service requires URIs to objects we want to create in the
308- // target package.
309- // However, we do not know these URIs from the client.
310- // Instead, give it the URI of the package in which we clone.
311- IAdtObjectReference packageRef = AbapGitWizardPull .this .cloneData .packageRef ;
312- IAdtObjectReference checkRef = IAdtCoreFactory .eINSTANCE .createAdtObjectReference ();
313- checkRef .setUri (packageRef .getUri ());
314- IAdtTransportCheckData checkData = AbapGitWizardPull .this .transportService .check (checkRef , packageRef .getPackageName (),
315- true );
316- AbapGitWizardPull .this .transportPage .setCheckData (checkData );
317- } catch (Exception e ) {
318- AbapGitWizardPull .this .pageBranchAndPackage .setMessage (e .getMessage (), DialogPage .ERROR );
319- }
309+ IAdtObjectReference packageRef = AbapGitWizardPull .this .cloneData .packageRef ;
310+ IAdtTransportCheckData transportCheckData = getTransportCheckData (packageRef );
311+ AbapGitWizardPull .this .transportPage .setCheckData (transportCheckData );
320312 }
321313
314+
322315 //-> APACK page -> Any page
323316 if (event .getCurrentPage () == AbapGitWizardPull .this .pageApack ) {
324317 if (!AbapGitWizardPull .this .pageApack .validateAll ()) {
@@ -327,5 +320,55 @@ public void handlePageChanging(final PageChangingEvent event) {
327320 }
328321 }
329322 }
323+
324+ private IAdtTransportCheckData getTransportCheckData (IAdtObjectReference packageRef ) {
325+
326+ IAdtObjectReference checkRef = IAdtCoreFactory .eINSTANCE .createAdtObjectReference ();
327+ checkRef .setUri (packageRef .getUri ());
328+
329+ final IAdtTransportCheckData [] checkData = new IAdtTransportCheckData [1 ];
330+
331+ try {
332+ getContainer ().run (true , true , monitor -> {
333+ monitor .beginTask (Messages .AbapGitWizardPageTransportSelection_transport_check , IProgressMonitor .UNKNOWN );
334+ checkData [0 ] = AbapGitWizardPull .this .transportService .check (checkRef , packageRef .getPackageName (), true );
335+ });
336+ return checkData [0 ];
337+
338+ } catch (Exception e ) {
339+ // Catches InterruptedException and other general exceptions
340+ WizardPage currentPage = ((WizardPage ) getContainer ().getCurrentPage ());
341+ handleException (e , currentPage );
342+ return null ;
343+ }
344+ }
345+
346+ private void handleOutdatedClientException (Throwable e ) {
347+
348+ Display .getDefault ().asyncExec (() -> {
349+ WizardDialog d = (WizardDialog ) getContainer ();
350+
351+ if (d != null ) {
352+ // Check if the dialog is still open before attempting to close
353+ if (d .getShell () != null && !d .getShell ().isDisposed ()) {
354+ d .close ();
355+ AdtUtilUiPlugin .getDefault ().getAdtStatusService ().handle (e , null );
356+ }
357+ }
358+ });
359+
360+ }
361+
362+ private void handleException (Exception exception , WizardPage page ) {
363+
364+ page .setPageComplete (false );
365+ Throwable cause = exception instanceof InvocationTargetException ? exception .getCause () : exception ;
366+ if (cause != null && cause instanceof OutDatedClientException ) {
367+ handleOutdatedClientException (cause );
368+ } else {
369+ page .setMessage (cause != null ? cause .getMessage () : exception .getMessage (), DialogPage .ERROR );
370+ }
371+ }
372+
330373 }
331374}
0 commit comments