Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 357411

Summary: Remove ugly reflection code to get IFile from IFileEditorInput
Product: [Modeling] Graphiti Reporter: Hernan Gonzalez <hjg.com.ar>
Component: CoreAssignee: Tim Kaiser <tim.kaiser>
Status: CLOSED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: michael.wenz
Version: 0.8.0Flags: tim.kaiser: juno+
Target Milestone: 0.9.0   
Hardware: All   
OS: All   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=349439
Whiteboard: Juno M2 Theme_round_offs
Attachments:
Description Flags
patch (for version 0.9) tim.kaiser: iplog+

Description Hernan Gonzalez CLA 2011-09-12 15:45:30 EDT
Created attachment 203186 [details]
patch (for version 0.9)

I believe that the (very) ugly code in org.eclipse.graphiti.ui.internal.util.ReflectionUtil to deal with IFileEditorInput   could be more elegantly done in this way:

public static IFile getFile(Object input) {
 if(input instanceof IAdaptable) {
  IFile file = (IFile)((IAdaptable)input).getAdapter(IFile.class);
  if(file!=null) return file;
 }
 return null;
}

That's the point of adapters, isn't it?
Comment 1 Michael Wenz CLA 2011-09-13 04:56:11 EDT
You're right in that this coding is ugly, unfortunatly it is necessary to enable Graphiti to run in an RCP application without IDE being installed, but on the other hand benefit from the IFile stuff provided in the IDE installation.
For details on this issue see the comments in the class and https://bugs.eclipse.org/bugs/show_bug.cgi?id=349439.

If you know a better way to solve this please let us know.

Michael
Comment 2 Michael Wenz CLA 2011-09-13 05:12:09 EDT
(In reply to comment #1)
Sorry, just forget that comment, that's of course nonsense... :-(

> You're right in that this coding is ugly, unfortunatly it is necessary to
> enable Graphiti to run in an RCP application without IDE being installed, but
> on the other hand benefit from the IFile stuff provided in the IDE
> installation.
> For details on this issue see the comments in the class and
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=349439.
> If you know a better way to solve this please let us know.
> Michael
Comment 3 Michael Wenz CLA 2011-09-13 06:31:25 EDT
It should be possible to apply that change, but I would like to consult the colleague who did the RCP enabling (on vacation this week).

Michael
Comment 4 Tim Kaiser CLA 2011-09-20 05:13:09 EDT
I applied the patch.
Comment 5 Michael Wenz CLA 2012-04-11 10:36:02 EDT
Bookkeeping: Set target release
Comment 6 Michael Wenz CLA 2012-06-28 10:42:58 EDT
Part of Graphiti 0.9.0 (Eclipse Juno)