Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e71a107a3e4ee781ff4a6e7dd5a7593f81079424 (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
/*******************************************************************************
 * Copyright (c) 2000, 2015 IBM Corporation and others.
 *
 * 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
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.ui.internal.dialogs.cpd;

import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.ui.internal.dialogs.cpd.TreeManager.CheckListener;
import org.eclipse.ui.internal.dialogs.cpd.TreeManager.TreeItem;

/**
 * On a model change, update a filtered listener. While the check listener
 * provided by the model will take care of the elements which change, since we
 * simulate our own check state of parents, the parents may need to be updated.
 *
 * @since 3.5
 */
final class FilteredModelCheckListener implements CheckListener {
	private final ActionSetFilter filter;
	private final StructuredViewer viewer;

	FilteredModelCheckListener(ActionSetFilter filter, StructuredViewer viewer) {
		this.filter = filter;
		this.viewer = viewer;
	}

	@Override
	public void checkChanged(TreeItem changedItem) {
		TreeItem item = changedItem;
		boolean update = false;

		// Force an update on all parents.
		while (item != null) {
			update = update || filter.select(null, null, item);
			if (update) {
				viewer.update(item, null);
			}
			item = item.getParent();
		}
	}
}

Back to the top