Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryPropertySourceProvider.java')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryPropertySourceProvider.java72
1 files changed, 38 insertions, 34 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryPropertySourceProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryPropertySourceProvider.java
index d0a11a35ff..4de70cc575 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryPropertySourceProvider.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoryPropertySourceProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2019 SAP AG and others.
+ * Copyright (c) 2010, 2021 SAP AG 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
@@ -14,11 +14,10 @@
package org.eclipse.egit.ui.internal.repository;
import org.eclipse.core.runtime.Adapters;
+import org.eclipse.egit.ui.internal.properties.TagPropertySource;
import org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode;
import org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNodeType;
import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jgit.events.ConfigChangedEvent;
-import org.eclipse.jgit.events.ConfigChangedListener;
import org.eclipse.jgit.events.ListenerHandle;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
@@ -26,13 +25,13 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IActionBars;
import org.eclipse.ui.views.properties.IPropertySource;
import org.eclipse.ui.views.properties.IPropertySourceProvider;
import org.eclipse.ui.views.properties.PropertySheetPage;
/**
- * PropertySource provider for Resource properties
- *
+ * A {@link IPropertySourceProvider} for git repository properties.
*/
public class RepositoryPropertySourceProvider implements
IPropertySourceProvider {
@@ -44,7 +43,7 @@ public class RepositoryPropertySourceProvider implements
private IPropertySource lastRepositorySource;
private enum SourceType {
- UNDEFINED, REPOSITORY, REMOTE, BRANCH
+ UNDEFINED, REPOSITORY, REMOTE, BRANCH, TAG
}
private SourceType lastSourceType = SourceType.UNDEFINED;
@@ -85,9 +84,20 @@ public class RepositoryPropertySourceProvider implements
handle.remove();
}
+ private void refreshPage() {
+ lastObject = null;
+ myPage.getSite().getShell().getDisplay()
+ .asyncExec(() -> myPage.setPropertySourceProvider(this));
+ }
+
@Override
public IPropertySource getPropertySource(Object object) {
+ if (object instanceof IPropertySource) {
+ // Enable nested properties
+ return (IPropertySource) object;
+ }
+
if (object == lastObject) {
return lastRepositorySource;
}
@@ -103,20 +113,7 @@ public class RepositoryPropertySourceProvider implements
RepositoryTreeNode node = (RepositoryTreeNode) object;
listenerHandle = node.getRepository().getListenerList()
- .addConfigChangedListener(new ConfigChangedListener() {
- @Override
- public void onConfigChanged(ConfigChangedEvent event) {
- // force a refresh of the page
- lastObject = null;
- myPage.getSite().getShell().getDisplay().asyncExec(new Runnable() {
-
- @Override
- public void run() {
- myPage.setPropertySourceProvider(RepositoryPropertySourceProvider.this);
- }
- });
- }
- });
+ .addConfigChangedListener(event -> refreshPage());
if (node.getType() == RepositoryTreeNodeType.REPO) {
lastObject = object;
@@ -144,27 +141,34 @@ public class RepositoryPropertySourceProvider implements
return lastRepositorySource;
}
return null;
- } else
- return null;
+ } else if (node.getType() == RepositoryTreeNodeType.TAG) {
+ lastObject = object;
+ checkChangeType(SourceType.TAG);
+ lastRepositorySource = new TagPropertySource(node.getRepository(),
+ (Ref) node.getObject(), myPage);
+ return lastRepositorySource;
+ }
+ return null;
}
private void checkChangeType(SourceType type) {
// the different pages contribute different actions, so if we
// change to a different page type, we need to clear them
if (lastSourceType != type) {
- IToolBarManager mgr = myPage.getSite().getActionBars()
- .getToolBarManager();
+ IActionBars bars = myPage.getSite().getActionBars();
+ IToolBarManager mgr = bars.getToolBarManager();
boolean update = false;
- update = update
- | mgr.remove(RepositoryPropertySource.CHANGEMODEACTIONID) != null;
- update = update
- | mgr.remove(RepositoryPropertySource.SINGLEVALUEACTIONID) != null;
- update = update
- | mgr.remove(RepositoryPropertySource.EDITACTIONID) != null;
- update = update
- | mgr.remove(BranchPropertySource.EDITACTIONID) != null;
- if (update)
- mgr.update(false);
+ update |= mgr.remove(
+ RepositoryPropertySource.CHANGEMODEACTIONID) != null;
+ update |= mgr.remove(RepositoryPropertySource.SINGLEVALUEACTIONID) != null;
+ update |= mgr.remove(RepositoryPropertySource.EDITACTIONID) != null;
+ update |= mgr.remove(BranchPropertySource.EDITACTIONID) != null;
+ if (update) {
+ // Need to update the full IActionBars, not just the toolbar
+ // manager, to get proper layout when items are added or
+ // removed.
+ bars.updateActionBars();
+ }
}
lastSourceType = type;
}

Back to the top