use of org.eclipse.jgit.events.ListenerHandle in project egit by eclipse.
the class IndexDiffCacheEntry method dispose.
/**
* Dispose cache entry by removing listeners. Pending update or reload jobs
* are canceled.
*/
public void dispose() {
for (ListenerHandle h : listenerHandles) {
h.remove();
}
listenerHandles.clear();
submodules.clear();
if (resourceChangeListener != null) {
ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener);
}
listeners.clear();
if (reloadJob != null) {
reloadJob.cancel();
reloadJob = null;
}
if (updateJob != null) {
updateJob.cleanupAndCancel();
updateJob = null;
}
indexDiffData = null;
lastIndex = null;
}
use of org.eclipse.jgit.events.ListenerHandle in project egit by eclipse.
the class GitRepositoriesViewBranchHandlingTest method testBranchConfiguration.
@Test
public void testBranchConfiguration() throws Exception {
Repository repo = lookupRepository(clonedRepositoryFile);
try (Git git = new Git(repo)) {
git.branchCreate().setName("configTest").setStartPoint("refs/remotes/origin/master").setUpstreamMode(SetupUpstreamMode.TRACK).call();
}
BranchRebaseMode rebase = repo.getConfig().getEnum(BranchRebaseMode.values(), ConfigConstants.CONFIG_BRANCH_SECTION, "configTest", ConfigConstants.CONFIG_KEY_REBASE, BranchRebaseMode.NONE);
assertEquals(BranchRebaseMode.NONE, rebase);
SWTBotView view = getOrOpenView();
SWTBotTreeItem localItem = myRepoViewUtil.getLocalBranchesItem(view.bot().tree(), clonedRepositoryFile);
TestUtil.expandAndWait(localItem).getNode("configTest").select();
ContextMenuHelper.clickContextMenuSync(view.bot().tree(), myUtil.getPluginLocalizedValue("ShowIn"), "Properties");
SWTBotView propsView = bot.viewById(IPageLayout.ID_PROP_SHEET);
SWTBotTreeItem rootItem = propsView.bot().tree().getTreeItem(UIText.BranchPropertySource_UpstreamConfigurationCategory);
SWTBotTreeItem rebaseItem = TestUtil.expandAndWait(rootItem).getNode(UIText.BranchPropertySource_RebaseDescriptor);
assertEquals(UIText.BranchPropertySource_ValueNotSet, rebaseItem.cell(1));
SWTBotTreeItem remoteItem = rootItem.getNode(UIText.BranchPropertySource_RemoteDescriptor);
assertEquals("origin", remoteItem.cell(1));
SWTBotTreeItem upstreamItem = rootItem.getNode(UIText.BranchPropertySource_UpstreamBranchDescriptor);
assertEquals("refs/heads/master", upstreamItem.cell(1));
view = getOrOpenView();
localItem = myRepoViewUtil.getLocalBranchesItem(view.bot().tree(), clonedRepositoryFile);
TestUtil.expandAndWait(localItem).getNode("configTest").select();
ContextMenuHelper.clickContextMenu(view.bot().tree(), myUtil.getPluginLocalizedValue("ConfigurBranchCommand.label"));
SWTBotShell configureBranchDialog = bot.shell(UIText.BranchConfigurationDialog_BranchConfigurationTitle);
assertEquals(MessageFormat.format(UIText.BranchConfigurationDialog_EditBranchConfigMessage, "configTest"), configureBranchDialog.bot().text().getText());
assertEquals("refs/heads/master", configureBranchDialog.bot().comboBoxWithLabel(UIText.BranchConfigurationDialog_UpstreamBranchLabel).getText());
assertEquals("origin", configureBranchDialog.bot().comboBoxWithLabel(UIText.BranchConfigurationDialog_RemoteLabel).getText());
assertEquals(UIText.BranchRebaseMode_None, configureBranchDialog.bot().comboBoxWithLabel(UIText.BranchRebaseModeCombo_RebaseModeLabel).getText());
configureBranchDialog.bot().comboBoxWithLabel(UIText.BranchRebaseModeCombo_RebaseModeLabel).setSelection(0);
// add a listener to wait for the configuration changed event
final AtomicBoolean changed = new AtomicBoolean();
ConfigChangedListener listener = new ConfigChangedListener() {
@Override
public void onConfigChanged(ConfigChangedEvent event) {
changed.set(true);
}
};
ListenerHandle handle = repo.getConfig().addChangeListener(listener);
// only now click ok
configureBranchDialog.bot().button("OK").click();
// cleanup behind ourselves
handle.remove();
if (!changed.get())
fail("We should have received a config change event");
// Repo view updates itself after config change.
refreshAndWait();
rebase = repo.getConfig().getEnum(BranchRebaseMode.values(), ConfigConstants.CONFIG_BRANCH_SECTION, "configTest", ConfigConstants.CONFIG_KEY_REBASE, BranchRebaseMode.NONE);
assertEquals(BranchRebaseMode.REBASE, rebase);
localItem = myRepoViewUtil.getLocalBranchesItem(view.bot().tree(), clonedRepositoryFile);
TestUtil.expandAndWait(localItem).getNode("configTest").select();
ContextMenuHelper.clickContextMenu(view.bot().tree(), myUtil.getPluginLocalizedValue("ShowIn"), "Properties");
propsView = bot.viewById(IPageLayout.ID_PROP_SHEET);
rootItem = propsView.bot().tree().getTreeItem(UIText.BranchPropertySource_UpstreamConfigurationCategory);
rebaseItem = TestUtil.expandAndWait(rootItem).getNode(UIText.BranchPropertySource_RebaseDescriptor);
assertEquals("true", rebaseItem.cell(1));
}
use of org.eclipse.jgit.events.ListenerHandle in project egit by eclipse.
the class RepositoriesViewContentProvider method dispose.
@Override
public void dispose() {
commandState.removeListener(this);
for (ListenerHandle handle : refsChangedListeners.values()) handle.remove();
refsChangedListeners.clear();
}
Aggregations