Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 176619a93350524036ce16cccbb0aabe851149be (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
56
57
58
/*******************************************************************************
 * Copyright (c) 2008 Conselleria de Infraestructuras y Transporte, Generalitat 
 * de la Comunitat Valenciana . 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: Francisco Javier Cano Muñoz (Prodevelop) - Initial implementation
 *
 ******************************************************************************/
package org.eclipse.papyrus.navigator.actions;

import org.eclipse.jface.action.Action;
import org.eclipse.papyrus.navigator.ModelNavigator;
import org.eclipse.ui.IPropertyListener;

/**
 * Action that toggles the grouping of children by type in the Model Explorer.
 * 
 * @author <a href="mailto:fjcano@prodevelop.es">Francisco Javier Cano Muñoz</a>
 * @see <a href=https://bugs.eclipse.org/bugs/show_bug.cgi?id=290422>Bug #290422</a>
 */
public class GroupChildrenAction extends Action implements IPropertyListener {

	private final ModelNavigator navigator;

	public GroupChildrenAction(ModelNavigator commonNavigator) {
		super("Group Childs");
		this.navigator = commonNavigator;
		this.setToolTipText("Group Childs");
		init();
	}

	private void init() {

		updateGroupingChildsProperty(navigator.isGroupingChildsEnabled());
		navigator.addPropertyListener(this);
	}

	@Override
	public void run() {
		navigator.setGroupChildsEnabled(!navigator.isGroupingChildsEnabled());
	}

	public void propertyChanged(Object source, int propId) {
		switch(propId) {
		case ModelNavigator.IS_GROUPINGCHILDS_ENABLED_PROPERTY:
			updateGroupingChildsProperty(((ModelNavigator)source).isGroupingChildsEnabled());
		}

	}

	private void updateGroupingChildsProperty(boolean groupingChildsEnabled) {
		setChecked(groupingChildsEnabled);

	}

}

Back to the top