Git Repositories View: Allow to "remove" multiple Repositories
[egit.git] / org.eclipse.egit.ui / src / org / eclipse / egit / ui / internal / repository / RepositoryPropertySourceProvider.java
blobb5c66f70cd1a23c2c17e16c4fa633459d3223098
1 /*******************************************************************************
2 * Copyright (c) 2010 SAP AG.
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
8 * Contributors:
9 * Mathias Kinzler (SAP AG) - initial implementation
10 *******************************************************************************/
11 package org.eclipse.egit.ui.internal.repository;
13 import org.eclipse.egit.ui.internal.repository.RepositoryTreeNode.RepositoryTreeNodeType;
14 import org.eclipse.jgit.lib.Repository;
15 import org.eclipse.ui.views.properties.IPropertySource;
16 import org.eclipse.ui.views.properties.IPropertySourceProvider;
17 import org.eclipse.ui.views.properties.PropertySheetPage;
19 /**
20 * PropertySource provider for Resource properties
23 public class RepositoryPropertySourceProvider implements
24 IPropertySourceProvider {
26 private final PropertySheetPage myPage;
28 private Object lastObject;
30 private IPropertySource lastRepositorySource;
32 /**
33 * @param page
34 * the page
36 public RepositoryPropertySourceProvider(PropertySheetPage page) {
37 myPage = page;
40 public IPropertySource getPropertySource(Object object) {
42 if (object == lastObject)
43 return lastRepositorySource;
45 if (!(object instanceof RepositoryTreeNode))
46 return null;
48 RepositoryTreeNode node = (RepositoryTreeNode) object;
50 if (node.getType() == RepositoryTreeNodeType.REPO) {
51 lastObject = object;
52 lastRepositorySource = new RepositoryPropertySource(
53 (Repository) node.getObject(), myPage);
54 return lastRepositorySource;
55 } else if (node.getType() == RepositoryTreeNodeType.REMOTE) {
56 lastObject = object;
57 lastRepositorySource = new RepositoryRemotePropertySource(node
58 .getRepository().getConfig(), (String) node.getObject(),
59 myPage);
60 return lastRepositorySource;
61 } else if (node.getType() == RepositoryTreeNodeType.FETCH
62 || node.getType() == RepositoryTreeNodeType.PUSH) {
63 return getPropertySource(node.getParent());
64 } else {
65 return null;