Skip to main content
summaryrefslogtreecommitdiffstats
blob: 1805f2bfcc95e78c7ac0fd766f4e756658e29a16 (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
/*******************************************************************************
 * Copyright (c) 2010 itemis AG (http://www.itemis.eu) 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
 *******************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.xtext.glue.partialEditing;

import java.util.List;

import com.google.inject.Binding;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Singleton;
import com.google.inject.TypeLiteral;

/**
 * 
 */
public interface IActionContributor {
	/**
	 * hook used to contribute any actions on editor start up.
	 * @param editor 
	 */
	public void contributeActions(PartialModelEditor editor);
	
	
	/**
	 * composite action contributor delegating call to all registered {@link IActionContributor}
	 */
	@Singleton
	public class CompositeImpl implements IActionContributor {
		
		@Inject
		private Injector injector;

		public void contributeActions(PartialModelEditor editor) {
			List<Binding<IActionContributor>> bindingsByType = injector.findBindingsByType(TypeLiteral.get(IActionContributor.class));
			for (Binding<IActionContributor> binding : bindingsByType) {
				IActionContributor actionContributor = injector.getInstance(binding.getKey());
				actionContributor.contributeActions(editor);
			}
		}

	}
}

Back to the top