The "Add Repositories" dialog should not scan automatically
[egit.git] / org.eclipse.egit.ui / src / org / eclipse / egit / ui / internal / repository / RepositoryPropertySourceProvider.java
blobec348887ebbb05f42ddeebf460a27a0f25193fce
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.tree.RepositoryTreeNode;
14 import org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNodeType;
15 import org.eclipse.jgit.lib.Repository;
16 import org.eclipse.ui.views.properties.IPropertySource;
17 import org.eclipse.ui.views.properties.IPropertySourceProvider;
18 import org.eclipse.ui.views.properties.PropertySheetPage;
20 /**
21 * PropertySource provider for Resource properties
24 public class RepositoryPropertySourceProvider implements
25 IPropertySourceProvider {
27 private final PropertySheetPage myPage;
29 private Object lastObject;
31 private IPropertySource lastRepositorySource;
33 /**
34 * @param page
35 * the page
37 public RepositoryPropertySourceProvider(PropertySheetPage page) {
38 myPage = page;
41 public IPropertySource getPropertySource(Object object) {
43 if (object == lastObject)
44 return lastRepositorySource;
46 if (!(object instanceof RepositoryTreeNode))
47 return null;
49 RepositoryTreeNode node = (RepositoryTreeNode) object;
51 if (node.getType() == RepositoryTreeNodeType.REPO) {
52 lastObject = object;
53 lastRepositorySource = new RepositoryPropertySource(
54 (Repository) node.getObject(), myPage);
55 return lastRepositorySource;
56 } else if (node.getType() == RepositoryTreeNodeType.REMOTE) {
57 lastObject = object;
58 lastRepositorySource = new RepositoryRemotePropertySource(node
59 .getRepository().getConfig(), (String) node.getObject(),
60 myPage);
61 return lastRepositorySource;
62 } else if (node.getType() == RepositoryTreeNodeType.FETCH
63 || node.getType() == RepositoryTreeNodeType.PUSH) {
64 return getPropertySource(node.getParent());
65 } else {
66 return null;