From 0cd6b6685065fb8dea9ecb4df8a3c0b2bee75c1b Mon Sep 17 00:00:00 2001 From: Pierre-Charles David Date: Tue, 30 May 2017 15:37:22 +0200 Subject: [514682] Avoid exception when Browser can't be created Under some systems (Linux, depending on various parameters), it may be impossible to create an SWT Browser, which results in an SWTException. In this cases, do not display the "Documentation" section on the wizard's first page. Bug: 514682 Change-Id: Ie7f8bf89e8e67bada20cbeaf8ef633653a413f7e Signed-off-by: Pierre-Charles David --- .../newmodel/SelectEMFMetamodelWizardPage.java | 24 ++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/wizards/newmodel/SelectEMFMetamodelWizardPage.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/wizards/newmodel/SelectEMFMetamodelWizardPage.java index 83c03b7181..327cb603ba 100644 --- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/wizards/newmodel/SelectEMFMetamodelWizardPage.java +++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/wizards/newmodel/SelectEMFMetamodelWizardPage.java @@ -21,6 +21,7 @@ import org.eclipse.sirius.common.tools.DslCommonPlugin; import org.eclipse.sirius.common.tools.api.ecore.EPackageMetaData; import org.eclipse.sirius.viewpoint.provider.Messages; import org.eclipse.swt.SWT; +import org.eclipse.swt.SWTError; import org.eclipse.swt.browser.Browser; import org.eclipse.swt.custom.CLabel; import org.eclipse.swt.events.KeyAdapter; @@ -46,7 +47,7 @@ public class SelectEMFMetamodelWizardPage extends WizardPage { /** The package separator used to display qualified name of an EPackage. */ private static final String PACKAGE_SEPARATOR = "::"; //$NON-NLS-1$ - + /** The icon used for EPackages. */ private final Image ePacakgeIcon = ExtendedImageRegistry.getInstance().getImage(EcoreEditPlugin.INSTANCE.getImage("full/obj16/EPackage")); //$NON-NLS-1$ @@ -163,11 +164,15 @@ public class SelectEMFMetamodelWizardPage extends WizardPage { if (selection.length == 1) { dataModel.setSelectedPackage(((Entry) selection[0]).getValue()); String documentation = getDocumentation(dataModel.getSelectedPackage()); - documentationBrowser.setText(documentation); + if (documentationBrowser != null) { + documentationBrowser.setText(documentation); + } setPageComplete(true); } else { dataModel.setSelectedPackage(null); - documentationBrowser.setText(""); //$NON-NLS-1$ + if (documentationBrowser != null) { + documentationBrowser.setText(""); //$NON-NLS-1$ + } setPageComplete(false); } } @@ -184,8 +189,15 @@ public class SelectEMFMetamodelWizardPage extends WizardPage { Label lblDocumentation = new Label(parent, SWT.NONE); lblDocumentation.setText(Messages.SelectEMFMetamodelWizardPage_documentationLabel); - this.documentationBrowser = new Browser(parent, SWT.BORDER); - this.documentationBrowser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 2)); + try { + this.documentationBrowser = new Browser(parent, SWT.BORDER); + this.documentationBrowser.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 2)); + } catch (SWTError error) { + /* + * The browser could not be created: "hide" the "Documentation" label. + */ + lblDocumentation.setText(""); //$NON-NLS-1$ + } } /** @@ -257,7 +269,7 @@ public class SelectEMFMetamodelWizardPage extends WizardPage { } else { String documentation = getDocumentationFromEPackageExtraData(ePackage); if (documentation == null) { - documentation = "" + ePackage.getNsURI() + ""; //$NON-NLS-1$//$NON-NLS-2$ + documentation = "" + ePackage.getNsURI() + ""; //$NON-NLS-1$//$NON-NLS-2$ } else { documentation = documentation + "

" + ePackage.getNsURI() + ""; //$NON-NLS-1$ //$NON-NLS-2$ } -- cgit v1.2.3