Ifile to diagramURI [message #1776403] |
Thu, 16 November 2017 03:26  |
Eclipse User |
|
|
|
In my graphiti diagram editor project (Diagrams SA) I have two warnings on the lines of code given below:
private IFile getCurrentSelectedDiagram (IDoubleClickContext context) {
int i = 0;
boolean stop = false;
IFile iFile = null;
String pathRelative = "/ src / diagrams /";
// Name of the selected figure
GraphicsAlgorithm iga = context.getInnerGraphicsAlgorithm ();
Text text = (Text) iga;
String diagramSelName = text.getValue () + ".diagram";
// Now you have to check if the diagram exists with its file, in which project and path and open it
IWorkspace workspace = ResourcesPlugin.getWorkspace ();
IWorkspaceRoot root = workspace.getRoot ();
IProject [] projects = root.getProjects ();
do {
IProject project = projects [i];
if (project.isOpen ()) {
iFile = project.getFile (relativePath + diagramSelName);
if (! iFile.exists ()) {
// create an diagram
final Diagram diagram = Graphiti.getCreateService (). createDiagram (DIAGRAM_TYPE_ID, diagramSelName, true);
////////////////// TO BE REVIEWED: METHODS NOT API //////////////////////
// Create an Graphiti Diagram File on given path
URI diagramFileUri = GraphitiUiInternal.getEmfService (). GetFileURI (iFile);
// the file's first base node has a diagram
URI diagramUri = GraphitiUiInternal.getEmfService (). MapDiagramFileUriToDiagramUri (diagramFileUri);
////////////////////////////////////////////////////////////////////////////////////////
FileService.createEmfFileForDiagram (diagramUri, diagram);
}
stop = true;
}
} while (! stop && ++ i <projects.length);
return iFile;
}
The warning message says:
Multiple markers at this line
- Discouraged access: The method 'GraphitiUiInternal.getEmfService ()' is not API (restriction on required
library 'C: \ Users \ yvesl \ .p2 \ pool \ plugins \ org.eclipse.graphiti.ui_0.14.0.201705161212.jar')
- Discouraged access: The method 'IEmfService.getFileURI (IFile)' is not API (restriction on required library
'C: \ Users \ yvesl \ .p2 \ pool \ Plugins \ org.eclipse.graphiti.ui_0.14.0.201705161212.jar')
- Discouraged access: The type 'GraphitiUiInternal' is not API (restriction on required library 'C:
\ Users \ yvesl \ .p2 \ pool \ plugins \ org.eclipse.graphiti.ui_0.14.0.201705161212.jar ')
Where can I replace these two lines to get the URI of the diagram (diagramUri )from the associated iFile?
|
|
|
Re: Ifile to diagramURI [message #1776838 is a reply to message #1776403] |
Wed, 22 November 2017 03:21  |
Eclipse User |
|
|
|
Yves,
the question how to retrieve a file for a specific EMF resource basically depends on the typ of that resource. We did not find a generic way to do that for all kinds of resources at the point of writing that code, so we decided to not offer a public API for that (internal class, that is why you get that warning).
Not sure if by now EMF offers something for that, but I would suggest to ask in the EMF forum in that topic and state the concrete EMF resource type you are using.
HTH,
Michael
|
|
|
Powered by
FUDForum. Page generated in 0.02575 seconds