diff options
| author | Fred Eckertson | 2016-10-13 21:08:40 +0000 |
|---|---|---|
| committer | Fred Eckertson | 2016-10-13 21:08:40 +0000 |
| commit | ac8e39ea878007c21911283bc7509a8c2dc834b6 (patch) | |
| tree | 157380cc0857772d0600d2cd109a20daf32dc5db | |
| parent | e9d6802bdc84d3271f950ff44b012ed86603fb67 (diff) | |
| download | org.eclipse.papyrus-ac8e39ea878007c21911283bc7509a8c2dc834b6.tar.gz org.eclipse.papyrus-ac8e39ea878007c21911283bc7509a8c2dc834b6.tar.xz org.eclipse.papyrus-ac8e39ea878007c21911283bc7509a8c2dc834b6.zip | |
Bug 502705 - Export All Diagrams fails unless the model is in the project root directory
Fix algorithm to select/set the output directory,
and populate output format dropdown before determining the output directory
Change-Id: I541c504f5c2f2031c4f9c6455ad143eb595816a1
Signed-off-by: Fred Eckertson <feckertson@yahoo.com>
5 files changed, 39 insertions, 79 deletions
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.export/src/org/eclipse/papyrus/infra/gmfdiag/export/actions/ExportAllDiagramsAction.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.export/src/org/eclipse/papyrus/infra/gmfdiag/export/actions/ExportAllDiagramsAction.java index af901b2b516..50835d707d9 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.export/src/org/eclipse/papyrus/infra/gmfdiag/export/actions/ExportAllDiagramsAction.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.export/src/org/eclipse/papyrus/infra/gmfdiag/export/actions/ExportAllDiagramsAction.java @@ -10,15 +10,15 @@ * Jacques Lescot (Anyware Technologies) - initial API and implementation * Anass RADOUANI (AtoS) - add verification of the selection if it is a papyrus file or not * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 440754 + * Fred Eckertson (Cerner) - fred.eckertson@cerner.com - Bug 502705 ******************************************************************************/ package org.eclipse.papyrus.infra.gmfdiag.export.actions; import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.resources.IResource; import org.eclipse.emf.common.util.URI; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.window.Window; @@ -102,22 +102,13 @@ public class ExportAllDiagramsAction extends AbstractHandler { } - // Ask to user the others export configuration parameters - URI uriFile = null; + // Ask user for the other export configuration parameters + IResource outputDirectory = null; if (file != null) { - IContainer parentResource = file.getParent(); - IContainer containerForParentLocation = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(parentResource.getLocation()); - if (containerForParentLocation != null) { - parentResource = containerForParentLocation; - uriFile = URI.createPlatformResourceURI(parentResource.getLocation().toString(), true); - } else { - // linked resource - uriFile = URI.createPlatformResourceURI(parentResource.getFullPath().toString(), true); - } - + outputDirectory = file.getParent().findMember("."); } - ExportAllDiagramsDialog exportPopup = new ExportAllDiagramsDialog(DialogDisplayUtils.getActiveWorkbenchShell(), uriFile); + ExportAllDiagramsDialog exportPopup = new ExportAllDiagramsDialog(DialogDisplayUtils.getActiveWorkbenchShell(), outputDirectory); if (exportPopup.open() == Window.OK) { // Complete export configuration diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.export/src/org/eclipse/papyrus/infra/gmfdiag/export/actions/ExportAllDiagramsDialog.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.export/src/org/eclipse/papyrus/infra/gmfdiag/export/actions/ExportAllDiagramsDialog.java index f55053f1483..36c9552901c 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.export/src/org/eclipse/papyrus/infra/gmfdiag/export/actions/ExportAllDiagramsDialog.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.export/src/org/eclipse/papyrus/infra/gmfdiag/export/actions/ExportAllDiagramsDialog.java @@ -8,11 +8,11 @@ * Jacques Lescot (Anyware Technologies) - initial API and implementation * Anass Radouani (AtoS) - use of ExporterManager removed * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 440754 + * Fred Eckertson (Cerner) - fred.eckertson@cerner.com - Bug 502705 ******************************************************************************/ package org.eclipse.papyrus.infra.gmfdiag.export.actions; import org.eclipse.core.resources.IResource; -import org.eclipse.emf.common.util.URI; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.papyrus.infra.gmfdiag.export.messages.Messages; import org.eclipse.swt.SWT; @@ -31,8 +31,8 @@ public class ExportAllDiagramsDialog extends Dialog { /** The dialog composite. */ private ExportComposite dialogComposite = null; - /** The selected diagram file. */ - private URI outPutDirectory = null; + /** The output directory. */ + private IResource outPutDirectory = null; /** @@ -40,10 +40,10 @@ public class ExportAllDiagramsDialog extends Dialog { * * @param parentShell * the parent shell - * @param selectedFile - * the selected file + * @param initialOutputDirectory + * the initial output directory */ - public ExportAllDiagramsDialog(Shell parentShell, URI initialOuputDirectory) { + public ExportAllDiagramsDialog(Shell parentShell, IResource initialOuputDirectory) { super(parentShell); outPutDirectory = initialOuputDirectory; setBlockOnOpen(true); @@ -75,7 +75,7 @@ public class ExportAllDiagramsDialog extends Dialog { protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); dialogComposite = new ExportComposite(composite, SWT.NONE); - dialogComposite.setSelectedDiagramFileURI(outPutDirectory); + dialogComposite.setOutputDirectory(outPutDirectory); return composite; } @@ -105,8 +105,4 @@ public class ExportAllDiagramsDialog extends Dialog { public boolean getQualifiedName() { return dialogComposite.getQualifiedName(); } - - - - } diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.export/src/org/eclipse/papyrus/infra/gmfdiag/export/actions/ExportComposite.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.export/src/org/eclipse/papyrus/infra/gmfdiag/export/actions/ExportComposite.java index f58f4591de4..ac56bcc2b7b 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.export/src/org/eclipse/papyrus/infra/gmfdiag/export/actions/ExportComposite.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.export/src/org/eclipse/papyrus/infra/gmfdiag/export/actions/ExportComposite.java @@ -6,14 +6,14 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Anass RADOUANI (AtoS) + * Anass RADOUANI (AtoS) + * Fred Eckertson (Cerner) - fred.eckertson@cerner.com - Bug 502705 *******************************************************************************/ package org.eclipse.papyrus.infra.gmfdiag.export.actions; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.emf.common.util.URI; @@ -55,8 +55,6 @@ public class ExportComposite extends Composite { protected boolean qualifiedName; - private URI uriDiagramFile; - /** * Constructor * @@ -153,45 +151,27 @@ public class ExportComposite extends Composite { } /** - * set the file from which diagrams will be exported + * set the directory to which diagrams will be exported * - * @param file + * @param outputDirectory The output directory. */ - public void setSelectedDiagramFileURI(URI uriFile) { - uriDiagramFile = uriFile; + public void setOutputDirectory(IResource outputDirectory) { + this.outputDirectory = outputDirectory; loadData(); } private void loadData() { - if (uriDiagramFile != null) { - IPath location = new Path(uriDiagramFile.toPlatformString(true)); - outputDirectory = ResourcesPlugin.getWorkspace().getRoot().findMember(location.makeRelativeTo(ResourcesPlugin.getWorkspace().getRoot().getLocation())); - if (outputDirectory == null) { - try { - IResource[] members = ResourcesPlugin.getWorkspace().getRoot().members(); - for (int idx = 0; idx < members.length; idx++) { - if (location.equals(members[idx].getLocation())) { - outputDirectory = members[idx]; - break; - } - } - } catch (CoreException e) { - Activator.log.error(e); - } - } - if (outputDirectory == null) { - Activator.log.error("Impossible to find the output directory", null); - return; - } - outputPathTxt.setText(location.toString()); - } for (ImageFileFormat imageFileFormat : ImageFileFormat.VALUES) { outputFormatCb.add(imageFileFormat.toString()); } - outputFormatCb.setText(ImageFileFormat.getDefaultImageFormat().toString()); - exporter = outputFormatCb.getText(); + + if (outputDirectory == null) { + Activator.log.error("Impossible to find the output directory", null); + return; + } + outputPathTxt.setText(outputDirectory.getLocation().toString()); } /** diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.export/src/org/eclipse/papyrus/infra/gmfdiag/export/wizard/ExportAllWizard.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.export/src/org/eclipse/papyrus/infra/gmfdiag/export/wizard/ExportAllWizard.java index 8a3af3115b6..b9687f37bbf 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.export/src/org/eclipse/papyrus/infra/gmfdiag/export/wizard/ExportAllWizard.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.export/src/org/eclipse/papyrus/infra/gmfdiag/export/wizard/ExportAllWizard.java @@ -9,13 +9,13 @@ * Contributors: * Anass RADOUANI (AtoS) * Gabriel Pascual (ALL4TEC) gabriel.pascual@all4tec.net - Bug 440754 + * Fred Eckertson (Cerner) - fred.eckertson@cerner.com - Bug 502705 *******************************************************************************/ package org.eclipse.papyrus.infra.gmfdiag.export.wizard; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.emf.common.util.URI; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.Wizard; @@ -113,22 +113,15 @@ public class ExportAllWizard extends Wizard implements IExportWizard { } - // Ask to user the others export configuration parameters - URI uriFile = null; + // Ask user the other export configuration parameters + IContainer parentResource = null; if (file != null) { - IContainer parentResource = file.getParent(); - parentResource = ResourcesPlugin.getWorkspace().getRoot().getContainerForLocation(parentResource.getLocation()); - if (parentResource != null) { - uriFile = URI.createPlatformResourceURI(parentResource.getLocation().toString(), true); - - if (parameter == null) { - addErrorPage(); - } else { - page = new ExportDiagramsPage(uriFile); - addPage(page); - } - } else { + parentResource = file.getParent(); + if (parameter == null) { addErrorPage(); + } else { + page = new ExportDiagramsPage(parentResource); + addPage(page); } } else { addErrorPage(); diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.export/src/org/eclipse/papyrus/infra/gmfdiag/export/wizard/ExportDiagramsPage.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.export/src/org/eclipse/papyrus/infra/gmfdiag/export/wizard/ExportDiagramsPage.java index e07469d90de..7ae9206c583 100644 --- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.export/src/org/eclipse/papyrus/infra/gmfdiag/export/wizard/ExportDiagramsPage.java +++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.export/src/org/eclipse/papyrus/infra/gmfdiag/export/wizard/ExportDiagramsPage.java @@ -7,11 +7,12 @@ * * Contributors: * Anass RADOUANI (AtoS) + * Fred Eckertson (Cerner) - fred.eckertson@cerner.com - Bug 502705 *******************************************************************************/ package org.eclipse.papyrus.infra.gmfdiag.export.wizard; -import org.eclipse.emf.common.util.URI; +import org.eclipse.core.resources.IResource; import org.eclipse.jface.wizard.WizardPage; import org.eclipse.papyrus.infra.gmfdiag.export.actions.ExportComposite; import org.eclipse.papyrus.infra.gmfdiag.export.messages.Messages; @@ -29,14 +30,14 @@ public class ExportDiagramsPage extends WizardPage { return export; } - private final URI uriFile; + private final IResource outputDirectory; /** * Create the wizard. */ - public ExportDiagramsPage(URI uriFile) { + public ExportDiagramsPage(IResource outputDirectory) { super(Messages.ExportDiagramsPage_0); - this.uriFile = uriFile; + this.outputDirectory = outputDirectory; setTitle(Messages.ExportDiagramsPage_0); setDescription(Messages.ExportDiagramsPage_2); } @@ -49,8 +50,7 @@ public class ExportDiagramsPage extends WizardPage { @Override public void createControl(Composite parent) { export = new ExportComposite(parent, SWT.NONE); - export.setSelectedDiagramFileURI(uriFile); + export.setOutputDirectory(outputDirectory); setControl(export); } - } |
