Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 65d3e080a4f7455813eff7e5d369103a7831a2ee (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
/*******************************************************************************
 * Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com>
 *
 * 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.egit.ui.internal.push;

import org.eclipse.egit.core.op.PushOperationResult;
import org.eclipse.egit.ui.internal.commit.RepositoryCommit;
import org.eclipse.ui.model.WorkbenchContentProvider;

/**
 * Content provided for push result table viewer.
 * <p>
 * Input of this provided must be {@link PushOperationResult} instance, while
 * returned elements are instances of {@link RefUpdateElement}. Null input is
 * allowed, resulting in no elements.
 *
 * @see PushOperationResult
 * @see RefUpdateElement
 */
class RefUpdateContentProvider extends WorkbenchContentProvider {

	@Override
	public Object[] getElements(final Object element) {
		return element instanceof Object[] ? (Object[]) element : new Object[0];
	}

	@Override
	public Object[] getChildren(Object element) {
		if (element instanceof RepositoryCommit) {
			return ((RepositoryCommit) element).getDiffs();
		}
		return super.getChildren(element);
	}

	@Override
	public boolean hasChildren(Object element) {
		if (element instanceof RepositoryCommit) {
			// always return true for commits to avoid commit diff calculation
			// in UI thread, see bug 458839
			return true;
		}
		return super.hasChildren(element);
	}
}

Back to the top