-
Notifications
You must be signed in to change notification settings - Fork 83
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
Provide TARGET_SAVED and TARGET_DELETED events #1434
Conversation
/request-license-review |
License review requests: After all reviews have concluded, re-run the license-vetting check from the Github Actions web-interface to update its status. Workflow run (with attached summary files): |
Is this really required? Why can't you just listen for the resource changes and see if it is a target file or not? |
Yes.
Not all target definitions are contained in IFiles. By default, actually, they're contained in normal files hidden somewhere under .metadata/.plugins/o.e.pde.core/ |
The I'm a bit confused about the use-case, if you want to capture general save (not sure about delete) I would expect only a change in the target editor or handled it in the target handle / target service (so we capture any save) but not on different places. |
@@ -184,6 +186,9 @@ public void doSave(IProgressMonitor monitor) { | |||
fDirty = false; | |||
editorDirtyStateChanged(); | |||
fInputHandler.setSaving(false); | |||
|
|||
TargetPlatformService service = (TargetPlatformService) TargetPlatformService.getDefault(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? Should not saving the target file already trigger an event by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only if it's the active target.
} | ||
} | ||
} | ||
|
||
static void notifyTargetChanged(ITargetDefinition target) { | ||
IEclipseContext context = EclipseContextFactory.getServiceContext(PDECore.getDefault().getBundleContext()); | ||
public final void scheduleEvent(String topic, Object data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not having
- notifyTargetChanged
- notifyTargetSaved
- notifyTargetDeleted
- ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Counter question: Why have them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To hide implementation details on how the actual notifications are performed, what data is included and so on so we later can change it. Beside that it won't require an change of the internal API but just adding new API what is often less disruptive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I understand your point @laeubi, but considering the way the event firing is currently implemented, based on the E4-EventBroker respectively the OSGi EventHandler
service, the current state of this PR seems fitting to me.
To implement your suggestion the notification mechanism for target-events would have to be re-implemented entirely and would render the existing TargetEvents
API obsolete.
So although type-safety regarding the event-data is not ensured, I think the proposed solution, to extend the list of TargetEvents, is a suitable choice here.
That changes are needed in many different places is caused by PDE's core design. For instance, have a look at how many places are required to maintain the weird TargetPlatformHelper.fgCachedTargetDefinitionMap! And there are at least three (!) different ways to actually save a target: |
I know that EclipseCon is coming soon and is likely causing a lot of work, too. But is there a chance to get this in for M2? I have large downstream changes waiting for it in Oomph 😄 |
I'll try to have a look at it too, but I first have to finish my preparation for EclipseCon.
Can't you use temporarily a fixed I-build repository in Oomph once this is done? |
If its related to Oomph maybe @merks can have a look. By the way sharing a PR that demonstrate the usage of a new feature might also help to convince maintainers its a good addition :-) At the moment at least for me it is not completely clear if/how this would be actually used. In the initial text you wrote
In general there is only one target platform state and that's why there is an event if it changes the target definition to be used for that, so why is it important to know if a target file (?) was edited that is not active at all? As mentioned above if it is about when editing a file I would then see this as a matter of the Target editor or whoever changes that target file as such a file can be e.g. edited/deleted in the file system as well. Also this
Makes me feel you actually want some specific behavior from the target editor itself but also with this change its a bit unclear, e.g. why one can't use some other means (e.g. using the |
In the branch "target-monitor" I implemented a new ViewPart that monitors targets and creates content snapshots which can be compared to each other in order to get a clear picture about the impact of target definition changes. You can check it out from https://github.com/eclipse-oomph/oomph/tree/target-monitor . Here's a screenshot: The new code in TargetEditor.getAdapter() is needed by the "Link With Editor" functionality of the new view. |
@estepper is this really Omph specific or do you think it could be useful to implement such view in PDE directly e.g. does it depend on any oomph specific classes/function? |
It uses a few Oomph-specific classes and a Nebula TableCombo widget. Apart from that I can see that at some point it could be moved to PDE. But especially at this early point I expect that additional changes will be needed to address initial problems and add smaller enhancements. And for those I'm much faster when I have it under my own control. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @estepper, sorry for the delayed reply.
I finally had a look into this PR and think that it's a suitable solution for your problem, although it's not ideal, but that's due to event notification mechanism that's already in use.
Please see my detailed remarks below.
I have a few minor clean-ups that should be applied to this PR, but since I'm currently short in time I'll add the details tomorrow.
} | ||
} | ||
} | ||
|
||
static void notifyTargetChanged(ITargetDefinition target) { | ||
IEclipseContext context = EclipseContextFactory.getServiceContext(PDECore.getDefault().getBundleContext()); | ||
public final void scheduleEvent(String topic, Object data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I understand your point @laeubi, but considering the way the event firing is currently implemented, based on the E4-EventBroker respectively the OSGi EventHandler
service, the current state of this PR seems fitting to me.
To implement your suggestion the notification mechanism for target-events would have to be re-implemented entirely and would render the existing TargetEvents
API obsolete.
So although type-safety regarding the event-data is not ensured, I think the proposed solution, to extend the list of TargetEvents, is a suitable choice here.
ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/targetdefinition/TargetEditor.java
Outdated
Show resolved
Hide resolved
5856baf
to
71139e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With #1466 I have made a few simplifications in the TargetPlatformService class that also simplify this PR. I have rebased this and added a second commit with suggestions for improvements, a few clean-ups and unification of the doc so that there is less duplication.
@estepper if there's no objection from your side I'll squash the suggestions into one commit and submit it this evening.
That's very interesting.
Oomph has multiple quite convenient tools that would (in same cases maybe a bit generalized) also fit very well into PDE. So if you are interested in moving them into the Eclipse-SDK I would be glad to discuss that. |
c5b22c3
to
a3ea2b4
Compare
When building tools on top of PDE's target platform framework it's often necessary to be informed about state changes in targets. PDE already uses an IEventBroker to send "workspaceTargetChanged" events. This change is about sending two new events: TARGET_SAVED and TARGET_DELETED
The comparator differences are unrelated (see #1467), submitting. Thanks again Eike for this contribution. |
When building tools on top of PDE's target platform framework it's often necessary to be informed about state changes in targets. PDE already uses an IEventBroker to send "workspaceTargetChanged" events. This change is about sending two new events:
Please note that I also added the method TargetEditor.getAdapter(), which provides callers with the ITargetHandle of the editor.