eclipse-platform / eclipse.platform.swt

Eclipse SWT
https://www.eclipse.org/swt/
Eclipse Public License 2.0
118 stars 137 forks source link

SWT Browser component (Windows Edge): URLs sent to LocationListener are not complete #1581

Closed hmackamul closed 5 days ago

hmackamul commented 1 week ago

Describe the bug In Eclipse APP4MC we are using SVG diagrams to show specific aspects of the data model. The diagram is:

The links are used to navigate in the model and select the corresponding object in the model editor (handled by a LocationListener).

The LocationListener of

Details

Screenshots SVG_displayed_in_SWT_Browser

Environment:

  1. Select the platform(s) on which the behavior is seen:

      • [ ] All OS
      • [x] Windows
      • [ ] Linux
      • [ ] macOS
  2. Additional OS info (e.g. OS version, Linux Desktop, etc) Windows 11

Version Eclipse 2024-12 M2

sratz commented 1 week ago

The behavior with regards to fragments broke with the recent changes to the location events (#1451).

@hmackamul Could you test whether #1584 fixes the issue for your use-case?

hmackamul commented 1 week ago

The behavior with regards to fragments broke with the recent changes to the location events (#1451).

@hmackamul Could you test whether #1584 fixes the issue for your use-case?

I downloaded the integration build from yesterday evening but the pull request (#1584) is not included there. Do you have a simple possibility to test the patch? (I do not have the SWT repos/builds locally)

sratz commented 1 week ago

Do you have a simple possibility to test the patch?

Can you try with this win32 fragment? https://ci.eclipse.org/releng/job/eclipse.platform.swt/job/PR-1584/2/execution/node/3/ws/eclipse.platform.swt/binaries/org.eclipse.swt.win32.win32.x86_64/target/org.eclipse.swt.win32.win32.x86_64-3.128.0-SNAPSHOT.jar

hmackamul commented 1 week ago

Can you try with this win32 fragment? https://ci.eclipse.org/releng/job/eclipse.platform.swt/job/PR-1584/2/execution/node/3/ws/eclipse.platform.swt/binaries/org.eclipse.swt.win32.win32.x86_64/target/org.eclipse.swt.win32.win32.x86_64-3.128.0-SNAPSHOT.jar

Sorry, I got: Access Denied ... is missing the Job/Workspace permission

sratz commented 6 days ago

Can you try with this win32 fragment? https://ci.eclipse.org/releng/job/eclipse.platform.swt/job/PR-1584/2/execution/node/3/ws/eclipse.platform.swt/binaries/org.eclipse.swt.win32.win32.x86_64/target/org.eclipse.swt.win32.win32.x86_64-3.128.0-SNAPSHOT.jar

Sorry, I got: Access Denied ... is missing the Job/Workspace permission

Hmm, weird, I was able to download even without logon from incognito.

Here it is (rename .zip to .jar): org.eclipse.swt.win32.win32.x86_64-3.128.0.v20241110-0844.zip

hmackamul commented 6 days ago

Thanks, I got the file and will test it.

hmackamul commented 6 days ago

Sorry, I was not able to test the fragment.

My attempt:

Result was 1731417804740.log

Any idea?

HeikoKlare commented 6 days ago

You will probably have to adapt the configuration in your installation folder under configuration/org.eclipse.equinox.simpleconfigurator/bundles.info. There should be a line referring to the SWT fragment, in which you have to adapt the version so that the fragment is properly resolved at startup.

hmackamul commented 5 days ago

Thanks for the hint. With the update of simpleconfigurator I could start the fragment. capture_2024-11-12_205202_001

But no reaction in the editor. I assume the LocationEvent with for #fragment navigation is still missing.

sratz commented 5 days ago

But no reaction in the editor. I assume the LocationEvent with for #fragment navigation is still missing.

According to your initial post in this issue you are only reacting to the changing event:

browser.addLocationListener(LocationListener.changingAdapter(c -> {
    int idx = c.location.lastIndexOf('#');
    if (idx >= 0) {
        <compute link to object>
        <sent (topic + link) to IEventBroker to select object in editor>
    }
}));

Edge however does not send out any event before fragment navigation that we could forward via a changing event and it is impossible to cancel such a fragment navigation event.

Edge only sends out an event after the navigation, which we forward as a changed event in the LocationListener.

You'd have to adapt your code to

- browser.addLocationListener(LocationListener.changingAdapter(c -> {
+ browser.addLocationListener(LocationListener.changedAdapter(c -> {
    int idx = c.location.lastIndexOf('#');
    if (idx >= 0) {
        <compute link to object>
        <sent (topic + link) to IEventBroker to select object in editor>
    }
}));
hmackamul commented 5 days ago

Thanks! The changed event works perfectly with Edge.

https://github.com/user-attachments/assets/4e90a29d-ec23-45a7-8c77-f6d384ebd5f4

hmackamul commented 14 hours ago

Some more results (for the records):

  1. LocationListener.changed does not work with WebKit under Linux

  2. In case of links generated by PlantUML:

    • Internet Explorer shows a unwanted behavior (other than Edge):
      • after klick a blank page is shown
    • Generated links looked like:
      • <a href="#obj1" target="_top" title="#obj1" xlink:actuate="onRequest" xlink:href="#obj1" xlink:show="new" xlink:title="#obj1" xlink:type="simple">

I fixed the problems in my application by

It is possible to handle the different behavior but it makes it harder to write platform independent applications.