Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: eb5a2ca8d46b97c7440f674a4777b89e6821f8ab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*****************************************************************************
 * Copyright (c) 2017 CEA LIST, ALL4TEC and others.
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Mickaël ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation
 *****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.service.palette;

import java.io.IOException;

import org.eclipse.core.runtime.Assert;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.gmf.runtime.diagram.ui.services.palette.IPaletteProvider;
import org.eclipse.papyrus.infra.gmfdiag.common.Activator;

/**
 * Palette provider to be used for palettes defined by models, when they are defined with an Architecture model.
 */
public class ArchitectureExtendedPaletteProvider extends ExtendedPluginPaletteProvider implements IPaletteProvider {

	/**
	 * Constructor.
	 */
	public ArchitectureExtendedPaletteProvider() {
	}

	/**
	 * Set the contributions.
	 * 
	 * @param descriptor
	 *            The contribution descriptor
	 */
	public void setContributions(final ArchitectureExtendedProviderDescriptor descriptor) {
		Assert.isNotNull(descriptor);
		contributorID = descriptor.getContributionID();

		Resource resource = loadResourceFromPreferences(new ResourceSetImpl());
		if (null != resource) {
			// contribution have been redefined
			try {
				contributions = loadConfigurationModel(resource);
			} catch (IOException e) {
				Activator.log.error(e);
			}
		} else {
			contributions = descriptor.getDiagram().getPalettes();
		}
	}
}

Back to the top