Skip to content

Package: AsyncCommandStackListenerHelper

AsyncCommandStackListenerHelper

nameinstructionbranchcomplexitylinemethod
AsyncCommandStackListenerHelper()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
addCommandStackListener(EditingDomain, Widget, AsyncCommandStackListenerClient)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
addCommandStackListener(EditingDomain, Widget, AsyncCommandStackListenerClient, Resource)
M: 0 C: 19
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 6
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2015 RCP Vision (http://www.rcp-vision.com) and others.
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * Lorenzo Bettini - initial API and implementation
10: *******************************************************************************/
11: package org.eclipse.emf.parsley.listeners;
12:
13: import org.eclipse.emf.ecore.resource.Resource;
14: import org.eclipse.emf.edit.domain.EditingDomain;
15: import org.eclipse.swt.widgets.Widget;
16:
17: import com.google.inject.Inject;
18: import com.google.inject.Provider;
19:
20: /**
21: * Helper class for instantiating via injection a
22: * {@link AsyncCommandStackListener}, setting it as a listener in the command
23: * stack and adding a {@link AsyncCommandStackListenerClient}.
24: *
25: * @author Lorenzo Bettini - Initial contribution and API
26: *
27: */
28: public class AsyncCommandStackListenerHelper {
29:
30:         @Inject
31:         private Provider<AsyncCommandStackListener> provider;
32:
33:         /**
34:          * Sets up an {@link AsyncCommandStackListener} observing any
35:          * {@link Resource}'s involved in commands executed in the stack of the
36:          * given {@link EditingDomain}.
37:          *
38:          * @param editingDomain
39:          * @param widget
40:          * @param client
41:          */
42:         public void addCommandStackListener(EditingDomain editingDomain, Widget widget,
43:                         AsyncCommandStackListenerClient client) {
44:                 addCommandStackListener(editingDomain, widget, client, null);
45:         }
46:
47:         /**
48:          * Sets up an {@link AsyncCommandStackListener} observing a specific
49:          * {@link Resource}'s involved in commands executed in the stack of the
50:          * given {@link EditingDomain}.
51:          *
52:          * @param editingDomain
53:          * @param widget
54:          * @param client
55:          * @param resourceToObserve
56:          */
57:         public void addCommandStackListener(EditingDomain editingDomain, Widget widget,
58:                         AsyncCommandStackListenerClient client, Resource resourceToObserve) {
59:                 AsyncCommandStackListener listener = provider.get();
60:                 listener.setWidget(widget);
61:                 listener.setClient(client);
62:                 listener.setResourceToObserve(resourceToObserve);
63:                 editingDomain.getCommandStack().addCommandStackListener(listener);
64:         }
65: }