Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Ifile to diagramURI(remove non-API methods)
Ifile to diagramURI [message #1776403] Thu, 16 November 2017 08:26 Go to next message
Yves LEDUC is currently offline Yves LEDUCFriend
Messages: 6
Registered: June 2017
Junior Member
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 08:21 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1935
Registered: July 2009
Location: Walldorf, Germany
Senior Member
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
Previous Topic:How to get the custom GraphicsAlgorithm
Next Topic:Tutorial of e4 RCP application with graphiti
Goto Forum:
  


Current Time: Sat Dec 14 10:27:28 GMT 2024

Powered by FUDForum. Page generated in 0.03559 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top