I'm working on a new project using the Papyrus plugin for Eclipse to do the UML design. Luckily I found your plug in to export the images so I can include them in my documentation.
It has been a while since the your last release and I was wondering what the status of the project is. Is it still being developed/supported?
Thanks,
Maurice
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Maurice, although we have been busy with other projects it's still supported. We only work on new features if our users make a feature request but we will fix bugs and we will also accept contributions, *hint* *hint* ;). Another release is actually overdue, it will be out this week or next week the latest. Cheers, Thomas.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I was looking into the code yesterday to see about exporting all diagrams on a multi diagram page and, with a few minor changes I got it to work.
In the class ExportImagesOfDiagramOperation the only changes were in the exportDiagramOpeningEditor method (commented with 'MHM'). This will only work if the editor is already open (which is fine for my needs for now) and I don't really understand enough of the Eclipse architecture to go much farther.
I don't know if this has already been implemented or not for the next release, so here is the change:
// Added to process all diagrams in the file. (MHM)
List<IEditorPart> diagrams = new ArrayList<IEditorPart>();
IEditorPart openedEditorPart = activePage.findEditor(new FileEditorInput(
diagramFile));
try
{
if (openedEditorPart != null)
{
log.debug("Using editor that is aready open: " + openedEditorPart);
// If the current document is MultiPage add each page to the list of
// diagrams, otherwise just add it to the list. (MHM)
if (openedEditorPart instanceof MultiPageEditorPart)
{
MultiPageEditorPart me = (MultiPageEditorPart) openedEditorPart;
IEditorPart[] parts = me
.findEditors(new FileEditorInput(diagramFile));
for (int i = 0; i < parts.length; i++)
{
diagrams.add(parts[i]);
}
}
else
{
diagrams.add(openedEditorPart);
}
}
else
{
try
{
log.debug("Opening editor for " + diagramFile.getFullPath());
/*
* Unfortunately this opens an "Error editor" instead of opening none
* or throwing an exception. The error editor is even internal so I
* cannot cleanly test for an error. Not that easily, that is.
*/
openedEditorPart = IDE.openEditor(activePage, diagramFile, false,
true);
// To be consistent with the List of Diagrams, add this to the list.
// (MHM)
diagrams.add(openedEditorPart);
log.debug("Opened editor: " + openedEditorPart);
closeEditorWhenFinished = true;
}
catch (PartInitException e)
{
status.add(IStatus.ERROR, "Could not open an editor to export '"
+ diagramFile.getFullPath() + "'", e);
}
}
// Changed from if() to for(). (MHM)
for (IEditorPart editorPart : diagrams)
{
GraphicalViewer graphicalViewer = (GraphicalViewer) editorPart
.getAdapter(GraphicalViewer.class);
if (graphicalViewer != null)
{
IFigure figure = AbstractFigureProvider
.getExportFigure(graphicalViewer);
if (figure != null)
{
// Added the editorPart.getTitle() value to the output file name.
// (MHM)
IFile imageIFile = getImageIFile(diagramFile,
AbstractFigureProvider.getBaseName(diagramFile) + "_"
+ editorPart.getTitle());
File imageFile = new File(imageIFile.getRawLocation().toString());
if (allowedToWrite(imageIFile))
{
exporterDescriptor.createExporter().export(
Collections.singletonList(figure), imageFile, antialiasing);
refreshContainer(imageIFile.getParent(), monitor);
}
}
else
{
status.add(IStatus.ERROR, "Could not get image for "
+ diagramFile.getFullPath() + "'", null);
}
}
else
{
status.add(IStatus.ERROR,
"Editor does not return a graphical viewer to get the image for "
+ diagramFile.getFullPath() + "'", null);
}
}
// Removed because it is not necessary. (MHM)
// else
// {
// status.add(IStatus.ERROR, "Do not know how to create an image for '"
// + diagramFile.getFullPath() + "'", null);
// }
}
finally
{
if (openedEditorPart != null && closeEditorWhenFinished)
{
activePage.closeEditor(openedEditorPart, true);
}
}
}
Thanks again,
Maury
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Maury, sorry for being so slow these days, my life has been quite a mess recently and kind of still is. Great to see you got your hands dirty and hacked the code. I never wrote a multi diagram editor so your patch is more than welcome. I will pimp it up to use Java 1.5 features and probably a whole new design and will include it in the next release which I will shove out as soon as possible. Are you ok if I include your name and email address in the credits or do you prefer your email address to be excluded? Would you be willing to test a prerelease?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok, I used your patch as an inspiration to improve the overall design. So you won't find your patch in the code but there is experimental support for multi page editors in 0.11.0. Let me know if it works for you. Thanks again for pointing out MultiPageEditorPart.findEditors() to me and sending working code, Thomas.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I'm working on a new project using the Papyrus plugin for Eclipse to do the UML design. Luckily I found your plug in to export the images so I can include them in my documentation.
It has been a while since the your last release and I was wondering what the status of the project is. Is it still being developed/supported?
Thanks,
Maurice
Hi Maurice, although we have been busy with other projects it's still supported. We only work on new features if our users make a feature request but we will fix bugs and we will also accept contributions, *hint* *hint* ;). Another release is actually overdue, it will be out this week or next week the latest. Cheers, Thomas.
Thomas,
Thanks for the quick response.
I was looking into the code yesterday to see about exporting all diagrams on a multi diagram page and, with a few minor changes I got it to work.
In the class ExportImagesOfDiagramOperation the only changes were in the exportDiagramOpeningEditor method (commented with 'MHM'). This will only work if the editor is already open (which is fine for my needs for now) and I don't really understand enough of the Eclipse architecture to go much farther.
I don't know if this has already been implemented or not for the next release, so here is the change:
private void exportDiagramOpeningEditor(IFile diagramFile,
IProgressMonitor monitor) throws InterruptedException
{
boolean closeEditorWhenFinished = false;
IWorkbenchPage activePage = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
// Added to process all diagrams in the file. (MHM)
List<IEditorPart> diagrams = new ArrayList<IEditorPart>();
IEditorPart openedEditorPart = activePage.findEditor(new FileEditorInput(
diagramFile));
try
{
if (openedEditorPart != null)
{
log.debug("Using editor that is aready open: " + openedEditorPart);
// If the current document is MultiPage add each page to the list of
// diagrams, otherwise just add it to the list. (MHM)
if (openedEditorPart instanceof MultiPageEditorPart)
{
MultiPageEditorPart me = (MultiPageEditorPart) openedEditorPart;
IEditorPart[] parts = me
.findEditors(new FileEditorInput(diagramFile));
for (int i = 0; i < parts.length; i++)
{
diagrams.add(parts[i]);
}
}
else
{
diagrams.add(openedEditorPart);
}
}
else
{
try
{
log.debug("Opening editor for " + diagramFile.getFullPath());
/*
* Unfortunately this opens an "Error editor" instead of opening none
* or throwing an exception. The error editor is even internal so I
* cannot cleanly test for an error. Not that easily, that is.
*/
openedEditorPart = IDE.openEditor(activePage, diagramFile, false,
true);
// To be consistent with the List of Diagrams, add this to the list.
// (MHM)
diagrams.add(openedEditorPart);
log.debug("Opened editor: " + openedEditorPart);
closeEditorWhenFinished = true;
}
catch (PartInitException e)
{
status.add(IStatus.ERROR, "Could not open an editor to export '"
+ diagramFile.getFullPath() + "'", e);
}
}
// Changed from if() to for(). (MHM)
for (IEditorPart editorPart : diagrams)
{
GraphicalViewer graphicalViewer = (GraphicalViewer) editorPart
.getAdapter(GraphicalViewer.class);
if (graphicalViewer != null)
{
IFigure figure = AbstractFigureProvider
.getExportFigure(graphicalViewer);
if (figure != null)
{
// Added the editorPart.getTitle() value to the output file name.
// (MHM)
IFile imageIFile = getImageIFile(diagramFile,
AbstractFigureProvider.getBaseName(diagramFile) + "_"
+ editorPart.getTitle());
File imageFile = new File(imageIFile.getRawLocation().toString());
if (allowedToWrite(imageIFile))
{
exporterDescriptor.createExporter().export(
Collections.singletonList(figure), imageFile, antialiasing);
refreshContainer(imageIFile.getParent(), monitor);
}
}
else
{
status.add(IStatus.ERROR, "Could not get image for "
+ diagramFile.getFullPath() + "'", null);
}
}
else
{
status.add(IStatus.ERROR,
"Editor does not return a graphical viewer to get the image for "
+ diagramFile.getFullPath() + "'", null);
}
}
// Removed because it is not necessary. (MHM)
// else
// {
// status.add(IStatus.ERROR, "Do not know how to create an image for '"
// + diagramFile.getFullPath() + "'", null);
// }
}
finally
{
if (openedEditorPart != null && closeEditorWhenFinished)
{
activePage.closeEditor(openedEditorPart, true);
}
}
}
Thanks again,
Maury
Maury, sorry for being so slow these days, my life has been quite a mess recently and kind of still is. Great to see you got your hands dirty and hacked the code. I never wrote a multi diagram editor so your patch is more than welcome. I will pimp it up to use Java 1.5 features and probably a whole new design and will include it in the next release which I will shove out as soon as possible. Are you ok if I include your name and email address in the credits or do you prefer your email address to be excluded? Would you be willing to test a prerelease?
Ok, I used your patch as an inspiration to improve the overall design. So you won't find your patch in the code but there is experimental support for multi page editors in 0.11.0. Let me know if it works for you. Thanks again for pointing out MultiPageEditorPart.findEditors() to me and sending working code, Thomas.
Hallo Maurice
I am working on papyrus plugin for Eclipse to do the UML design.i have problem in export diagram as a image.could you plz help me?
thanx