Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 6ddc6033958c0eb0d3626174d58de53abe8df5e9 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*******************************************************************************
 * Copyright (C) 2011, 2015 Philipp Thun <philipp.thun@sap.com> and others
 *
 * All rights reserved. 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:
 *    Thomas Wolf <thomas.wolf@paranor.ch> - Factored out ResourceState
 *    Andre Bossert <anb0s@anbos.de> - Cleaning up the DecoratableResourceAdapter
 *******************************************************************************/
package org.eclipse.egit.ui.internal.decorators;

import org.eclipse.core.resources.IResource;
import org.eclipse.egit.ui.internal.resources.ResourceState;

/**
 * Basic implementation of <code>IDecoratableResource</code>
 *
 * @see IDecoratableResource
 */
public class DecoratableResource extends ResourceState
		implements IDecoratableResource {

	/**
	 * Resource to be decorated
	 */
	protected IResource resource = null;

	/**
	 * Name of the repository of the resource
	 */
	protected String repositoryName = null;

	/**
	 * Head commit of the repository of the resource
	 */
	protected String commitMessage = null;

	/**
	 * Current branch of the resource
	 */
	protected String branch = null;

	/**
	 * Branch status relative to remote tracking branch
	 */
	protected String branchStatus = null;

	/**
	 * is resource a repository container ?
	 */
	protected boolean isRepositoryContainer = false;

	/**
	 * Constructs a new decoratable resource
	 *
	 * This object represents the state of a resource used as a basis for
	 * decoration.
	 *
	 * @param resource
	 *            resource to be decorated
	 */
	protected DecoratableResource(IResource resource) {
		this.resource = resource;
	}

	/**
	 * @param isContainer
	 *            set to true if the resource is a repository container
	 */
	protected void setIsRepositoryContainer(boolean isContainer) {
		isRepositoryContainer = isContainer;
	}

	@Override
	public int getType() {
		return resource != null ? resource.getType() : 0;
	}

	@Override
	public String getName() {
		return resource != null ? resource.getName() : null;
	}

	@Override
	public String getRepositoryName() {
		return repositoryName;
	}

	@Override
	public String getCommitMessage() {
		return commitMessage;
	}

	@Override
	public String getBranch() {
		return branch;
	}

	@Override
	public String getBranchStatus() {
		return branchStatus;
	}

	@Override
	public boolean isRepositoryContainer() {
		return isRepositoryContainer;
	}

	@Override
	public String toString() {
		return getClass().getSimpleName() + "[" + getName() //$NON-NLS-1$
				+ (isTracked() ? ", tracked" : "") //$NON-NLS-1$ //$NON-NLS-2$
				+ (isIgnored() ? ", ignored" : "") //$NON-NLS-1$ //$NON-NLS-2$
				+ (isDirty() ? ", dirty" : "") //$NON-NLS-1$//$NON-NLS-2$
				+ (hasConflicts() ? ", conflicts" : "") //$NON-NLS-1$//$NON-NLS-2$
				+ ", staged=" + getStagingState() //$NON-NLS-1$
				+ "]"; //$NON-NLS-1$
	}

}

Back to the top