Skip to content
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 repo when starting abapGit for package #17

Closed
christianguenter2 opened this issue Nov 27, 2018 · 15 comments
Closed

Open repo when starting abapGit for package #17

christianguenter2 opened this issue Nov 27, 2018 · 15 comments

Comments

@christianguenter2
Copy link

Currently when we call abapGit in the context menu of a package abapGit is opened with home screen and no repo is opened.
image

It would be nice if we could open the repo corresponding to the selected package automatically. Technically we can solve this with a GET/SET parameter (which doesn't exist yet in abapGit but would be easy to implement). Is it possible to supply GET/SET parameters from ADT when calling a transaction? If yes we can do this.

@andau
Copy link
Owner

andau commented Nov 27, 2018

Well I think thats with the parameter should not be a big deal on ABAP in Eclipse side too (still have to check this).
But If the package changes I have to open a new GUI window and each time ZABAPGIT is opened the user has to provide his login data within abapGit for the GIT repository again (as far as I know).
Well one solution would be that I send also the username/password as parameters, but I am not sure if this opens a security vulnerability.
Then there to think about how the Eclipse editor should behave when a abapGIT is opened several times for the same package or for several packages.

But to sum it up if we can solve the credential issue the rest should not be something which stops us.

@christianguenter2
Copy link
Author

Ṫhere is a userexit for authentication.
abapGit/abapGit#1841
https://github.com/sandraros/abapGit-user-exit-logon-by-rfc
If one uses this auth shouldn't be a problem.

Imho abapGit should only be opened when the user explicitly triggers via context menu. And then I think it's also ok for users to provide their credentials.

@andau
Copy link
Owner

andau commented Nov 29, 2018

INCLUDE zabapgit_unit_test.

Hi Christian!

I added the functionality. Now I send the current package name as parameter, which can be retrieved over CL_ADT_GUI_INTEGRATION_CONTEXT=>read_context( ) ... see sample coding within abapGit below.

The version is not yet releases but commited to this github repository.

Let me know if the parameter name and the mode of transfer is ok for you. From Eclipse site I think you will get requests with a filled parameter and without or with the value ''.

Greetings, Andreas

INCLUDE zabapgit_forms.


INITIALIZATION.

DATA(context) = CL_ADT_GUI_INTEGRATION_CONTEXT=>read_context( ).
DATA(parameters) = context-parameters.
"sample content for parameters: p_package_name%3Dtestpackage

lcl_password_dialog=>on_screen_init( ).

If this proposal works on abapGit side I think I will let Eclipse open for each package a ZABAPGIT transaction. Therefore the user has to login only once for each package (or never when he/she uses the userexit.

@christianguenter2
Copy link
Author

Looks good. Implemented the abapGit part in this branch.
https://github.com/christianguenter2/abapGit/tree/start_with_package

Couldn't test as I don't know how to start eclipse with a plugin from source. Any hints? Do I need the PDE eclipse installation?

@andau
Copy link
Owner

andau commented Nov 30, 2018

Normally it should be quite straightforward to start the plugin in testmode, see the following issue.
#15 Download-and-Install-Plugin-From-Zip

From this issue take step 1 and afterwards build the project and run it as Eclipse application.

@christianguenter2
Copy link
Author

Thanks. I get some errors regarding

import org.powermock.reflect.Whitebox;

Any idea how to resolve them?

image

@andau
Copy link
Owner

andau commented Nov 30, 2018

I think there is a plugin missing which contains the mockito framework
The fastest solution is to remove the entire test folder.

@christianguenter2
Copy link
Author

Ok, deleting the file AbapGitHandlerTest.java seems to work. Btw. it's not in test folder, but in src.

@christianguenter2
Copy link
Author

When I test I get this exception and nothing happens.

!ENTRY org.eclipse.ui 4 0 2018-11-30 17:51:24.400
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.e4.core.di.InjectionException: java.lang.ClassCastException: org.eclipse.ui.part.FileEditorInput cannot be cast to com.sap.adt.sapgui.ui.internal.editors.GuiEditorInput
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:65)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:318)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:252)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:161)
at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:152)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:494)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:487)
at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:204)
at org.eclipse.e4.ui.workbench.renderers.swt.HandledContributionItem.executeItem(HandledContributionItem.java:433)
at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.handleWidgetSelection(AbstractContributionItem.java:446)
at org.eclipse.e4.ui.workbench.renderers.swt.AbstractContributionItem.lambda$2(AbstractContributionItem.java:472)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:86)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4118)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1052)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3931)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3534)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1170)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1059)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:153)
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:667)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:597)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:656)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:592)
at org.eclipse.equinox.launcher.Main.run(Main.java:1498)
at org.eclipse.equinox.launcher.Main.main(Main.java:1471)
Caused by: java.lang.ClassCastException: org.eclipse.ui.part.FileEditorInput cannot be cast to com.sap.adt.sapgui.ui.internal.editors.GuiEditorInput
at abapci.handlers.AbapGitHandler.getAbapGitEditorReference(AbapGitHandler.java:142)
at abapci.handlers.AbapGitHandler.execute(AbapGitHandler.java:105)
at abapci.handlers.AbapGitHandler.execute(AbapGitHandler.java:93)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:291)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
... 37 more

@andau
Copy link
Owner

andau commented Nov 30, 2018

Interesting error message. I am pretty sure that the reason is that you had at least one tab open named with ZABAPGIT.
The old logic is that in this case no new tab is opened, but nevertheless it should be brought to the forefront.

This logic will anyway be changed, thus for testing purposes I would ask you to ensure that ideally no tab is open or at least no tab with the label ZABAPGIT, when pressing the abapGit context menu in the project explorer (with an package entry selected in the project explorer of course)

@christianguenter2
Copy link
Author

You're right, I had an abapGit class open. Now it works! The right repo is opened.

abapgit_adt

@christianguenter2
Copy link
Author

I'll submit a PR for abapGit changes during the weekend.

@andau
Copy link
Owner

andau commented Nov 30, 2018

perfect, I will finalize the Eclipse part and release it also the next week

@andau
Copy link
Owner

andau commented Dec 2, 2018

implemented and new version 0.5.4.4 released, but not yet testet with the latest abapGit version

@christianguenter2
Copy link
Author

Tested successfully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants