Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 357411 - Remove ugly reflection code to get IFile from IFileEditorInput
Summary: Remove ugly reflection code to get IFile from IFileEditorInput
Status: CLOSED FIXED
Alias: None
Product: Graphiti
Classification: Modeling
Component: Core (show other bugs)
Version: 0.8.0   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: 0.9.0   Edit
Assignee: Tim Kaiser CLA
QA Contact:
URL:
Whiteboard: Juno M2 Theme_round_offs
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-12 15:45 EDT by Hernan Gonzalez CLA
Modified: 2012-06-28 10:42 EDT (History)
1 user (show)

See Also:
tim.kaiser: juno+


Attachments
patch (for version 0.9) (2.37 KB, text/plain)
2011-09-12 15:45 EDT, Hernan Gonzalez CLA
tim.kaiser: iplog+
Details

Note You need to log in before you can comment on or make changes to this bug.
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)