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
9 * Mathias Kinzler (SAP AG) - initial implementation
10 *******************************************************************************/
11 package org
.eclipse
.egit
.ui
.internal
.repository
;
13 import java
.io
.IOException
;
14 import java
.util
.ArrayList
;
15 import java
.util
.List
;
17 import org
.eclipse
.egit
.ui
.Activator
;
18 import org
.eclipse
.egit
.ui
.UIText
;
19 import org
.eclipse
.jgit
.errors
.ConfigInvalidException
;
20 import org
.eclipse
.jgit
.lib
.RepositoryConfig
;
21 import org
.eclipse
.ui
.views
.properties
.IPropertyDescriptor
;
22 import org
.eclipse
.ui
.views
.properties
.IPropertySource
;
23 import org
.eclipse
.ui
.views
.properties
.PropertyDescriptor
;
24 import org
.eclipse
.ui
.views
.properties
.PropertySheetPage
;
27 * Read-only view of remote configuration
29 public class RepositoryRemotePropertySource
implements IPropertySource
{
31 private final RepositoryConfig myConfig
;
33 private final String myName
;
41 public RepositoryRemotePropertySource(RepositoryConfig config
,
42 String remoteName
, PropertySheetPage page
) {
47 public Object
getEditableValue() {
51 public IPropertyDescriptor
[] getPropertyDescriptors() {
55 } catch (IOException e
) {
56 Activator
.handleError(
57 UIText
.RepositoryRemotePropertySource_ErrorHeader
, e
, true);
58 } catch (ConfigInvalidException e
) {
59 Activator
.handleError(
60 UIText
.RepositoryRemotePropertySource_ErrorHeader
, e
, true);
62 List
<IPropertyDescriptor
> resultList
= new ArrayList
<IPropertyDescriptor
>();
63 PropertyDescriptor desc
= new PropertyDescriptor(RepositoriesView
.URL
,
64 UIText
.RepositoryRemotePropertySource_RemoteFetchURL_label
);
66 desc
= new PropertyDescriptor(RepositoriesView
.FETCH
,
67 UIText
.RepositoryRemotePropertySource_FetchLabel
);
69 desc
= new PropertyDescriptor(RepositoriesView
.PUSHURL
,
70 UIText
.RepositoryRemotePropertySource_RemotePushUrl_label
);
72 desc
= new PropertyDescriptor(RepositoriesView
.PUSH
,
73 UIText
.RepositoryRemotePropertySource_PushLabel
);
75 return resultList
.toArray(new IPropertyDescriptor
[resultList
.size()]);
78 public Object
getPropertyValue(Object id
) {
79 String
[] list
= myConfig
.getStringList(RepositoriesView
.REMOTE
, myName
,
81 if (list
!= null && list
.length
> 1) {
82 // let's show this as "[some/uri][another/uri]"
83 StringBuffer sb
= new StringBuffer();
84 for (String s
: list
) {
91 return myConfig
.getString(RepositoriesView
.REMOTE
, myName
, (String
) id
);
94 public boolean isPropertySet(Object id
) {
99 public void resetPropertyValue(Object id
) {
103 public void setPropertyValue(Object id
, Object value
) {