diff options
author | ptessier | 2018-10-01 12:02:10 +0000 |
---|---|---|
committer | Patrick Tessier | 2018-10-15 13:46:23 +0000 |
commit | e883b2e637c0b07478c1fbf0a9f6d8ce79d92e49 (patch) | |
tree | ba77eacf70e2c03d8eefeab12d8b545a8a3d2e80 /plugins/uml | |
parent | f918cae5013606cd4163a1b2fcbb3759ba4ad691 (diff) | |
download | org.eclipse.papyrus-e883b2e637c0b07478c1fbf0a9f6d8ce79d92e49.tar.gz org.eclipse.papyrus-e883b2e637c0b07478c1fbf0a9f6d8ce79d92e49.tar.xz org.eclipse.papyrus-e883b2e637c0b07478c1fbf0a9f6d8ce79d92e49.zip |
Bug 539632 - null pointer exception with AF
Change-Id: I9492d5b61e55ef684d076da6f0bbe40ce08bf79a
Diffstat (limited to 'plugins/uml')
-rw-r--r-- | plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectArchitectureContextPage.java | 84 |
1 files changed, 50 insertions, 34 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectArchitectureContextPage.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectArchitectureContextPage.java index cacfc3d900c..842d03c6469 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectArchitectureContextPage.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.wizards/src/org/eclipse/papyrus/uml/diagram/wizards/pages/SelectArchitectureContextPage.java @@ -1,6 +1,6 @@ /***************************************************************************** - * Copyright (c) 2016 CEA LIST and others. - * + * Copyright (c) 2016, 2018 CEA LIST and others. + * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -10,7 +10,8 @@ * * Contributors: * CEA LIST - Initial API and implementation - * + * Patrick Tessier (CEA list) - + * *****************************************************************************/ package org.eclipse.papyrus.uml.diagram.wizards.pages; @@ -50,7 +51,7 @@ public class SelectArchitectureContextPage extends WizardPage { public static final String PAGE_ID = "SelectArchitectureContextPage"; //$NON-NLS-1$ private SettingsHelper settingsHelper; - + private final boolean allowSeveralContexts; private String[] selectedContexts; @@ -63,8 +64,8 @@ public class SelectArchitectureContextPage extends WizardPage { public SelectArchitectureContextPage(boolean allowSeveralContexts) { super(PAGE_ID); - setTitle("Select Architecture Context"); - setDescription("Select the architecture context(s) and viewpoints to apply to the Papyrus model"); + setTitle("Select Architecture Context"); //$NON-NLS-1$ + setDescription("Select the architecture context(s) and viewpoints to apply to the Papyrus model"); //$NON-NLS-1$ this.allowSeveralContexts = allowSeveralContexts; } @@ -72,19 +73,20 @@ public class SelectArchitectureContextPage extends WizardPage { public void setWizard(IWizard newWizard) { super.setWizard(newWizard); settingsHelper = new SettingsHelper(getDialogSettings()); - + List<String> contextIds = asList(settingsHelper.getArchitectureContexts()); if (!allowSeveralContexts) { String defaultContextId = ArchitectureDomainManager.getInstance().getDefaultArchitectureContextId(); - if (defaultContextId != null) + if (defaultContextId != null) { contextIds = asList(defaultContextId); - else if (!contextIds.isEmpty()) + } else if (!contextIds.isEmpty()) { contextIds = asList(contextIds.get(0)); - else + } else { contextIds = Collections.emptyList(); + } } - - List<String> viewpoints = new ArrayList<String>(); + + List<String> viewpoints = new ArrayList<>(); for (Iterator<String> i = contextIds.iterator(); i.hasNext();) { String contextId = i.next(); if (isVisibleContext(contextId)) { @@ -92,29 +94,43 @@ public class SelectArchitectureContextPage extends WizardPage { for (MergedArchitectureViewpoint viewpoint : context.getViewpoints()) { viewpoints.add(viewpoint.getId()); } - } else + } else { i.remove(); + } } selectedContexts = contextIds.toArray(new String[0]); selectedViewpoints = viewpoints.toArray(new String[0]); } - - private <T> List<T> asList(T... elements) { - List<T> list = new ArrayList<T>(); - for (T element : elements) - list.add(element); - return list; - } + + private <T> List<T> asList(T... elements) { + List<T> list = new ArrayList<>(); + for (T element : elements) { + list.add(element); + } + return list; + } private boolean isVisibleContext(String contextId) { - for (MergedArchitectureContext context : ArchitectureDomainManager.getInstance().getVisibleArchitectureContexts()) { - if (context.getId().equals(contextId)) - return true; + if (contextId != null) { + for (MergedArchitectureContext context : ArchitectureDomainManager.getInstance().getVisibleArchitectureContexts()) { + + if (context.getId() == null) { + org.eclipse.papyrus.uml.diagram.wizards.Activator.log.info(" context has a null id" + context); //$NON-NLS-1$ + } + if (contextId.equals(context.getId())) { + return true; + } + + } + + } else { + org.eclipse.papyrus.uml.diagram.wizards.Activator.log.info(" a context has not been loaded"); //$NON-NLS-1$ } return false; + } - + /** * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) * @@ -129,10 +145,10 @@ public class SelectArchitectureContextPage extends WizardPage { ArchitectureDomainManager manager = ArchitectureDomainManager.getInstance(); MergedArchitectureContext[] contexts; - //if (allowSeveralContexts || manager.getDefaultArchitectureContext() == null) - contexts = manager.getVisibleArchitectureContexts().toArray(new MergedArchitectureContext[0]); - //else - //contexts = new ArchitectureContext[] { manager.getDefaultArchitectureContext() }; + // if (allowSeveralContexts || manager.getDefaultArchitectureContext() == null) + contexts = manager.getVisibleArchitectureContexts().toArray(new MergedArchitectureContext[0]); + // else + // contexts = new ArchitectureContext[] { manager.getDefaultArchitectureContext() }; final ArchitectureContextComposite acc = new ArchitectureContextComposite(comp, 1, 1, GridData.FILL_BOTH, 0, 0); acc.setAllowSeveralContexts(allowSeveralContexts); @@ -154,7 +170,7 @@ public class SelectArchitectureContextPage extends WizardPage { public void performHelp() { PlatformUI.getWorkbench().getHelpSystem().displayHelp("org.eclipse.papyrus.uml.diagram.wizards.Category"); //$NON-NLS-1$ } - + /** * Gets the selected architecture contexts. * @@ -163,17 +179,17 @@ public class SelectArchitectureContextPage extends WizardPage { public String[] getSelectedContexts() { return selectedContexts; } - + /** * Respond to completion of the wizard. Includes saving settings for the next * invocation of the wizard. - * + * * @since 2.0 */ public void performFinish() { settingsHelper.saveArchitectureContexts(selectedContexts); } - + public String[] getSelectContexts() { return selectedContexts; } @@ -183,7 +199,7 @@ public class SelectArchitectureContextPage extends WizardPage { } private void updateButtons() { - setPageComplete(selectedContexts.length!=0 && validatePage()); + setPageComplete(selectedContexts.length != 0 && validatePage()); } /** @@ -238,7 +254,7 @@ public class SelectArchitectureContextPage extends WizardPage { g.setLayoutData(gd); return g; } - + private static void createVerticalSpacer(Composite parent, int numlines) { Label lbl = new Label(parent, SWT.NONE); GridData gd = new GridData(GridData.FILL_HORIZONTAL); |