1 /******************************************************************************
2 * Copyright (c) 2011 GitHub Inc.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License 2.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-2.0/
8 * SPDX-License-Identifier: EPL-2.0
11 * Kevin Sawicki (GitHub Inc.) - initial API and implementation
12 *****************************************************************************/
13 package org
.eclipse
.egit
.ui
.internal
.reflog
;
15 import java
.text
.MessageFormat
;
17 import org
.eclipse
.egit
.ui
.internal
.UIText
;
18 import org
.eclipse
.egit
.ui
.internal
.dialogs
.AbstractBranchSelectionDialog
;
19 import org
.eclipse
.egit
.ui
.internal
.repository
.tree
.AdditionalRefNode
;
20 import org
.eclipse
.jface
.viewers
.Viewer
;
21 import org
.eclipse
.jface
.viewers
.ViewerFilter
;
22 import org
.eclipse
.jface
.window
.Window
;
23 import org
.eclipse
.jgit
.lib
.Constants
;
24 import org
.eclipse
.jgit
.lib
.Repository
;
25 import org
.eclipse
.swt
.widgets
.Composite
;
26 import org
.eclipse
.swt
.widgets
.Shell
;
29 * Select the ref to show reflog for
31 public class RefSelectionDialog
extends AbstractBranchSelectionDialog
{
37 public RefSelectionDialog(Shell parentShell
, Repository repository
) {
38 super(parentShell
, repository
, SHOW_LOCAL_BRANCHES
39 | SHOW_REMOTE_BRANCHES
| EXPAND_LOCAL_BRANCHES_NODE
40 | EXPAND_REMOTE_BRANCHES_NODE
| SHOW_REFERENCES
);
44 protected void refNameSelected(String refName
) {
45 getButton(Window
.OK
).setEnabled(refName
!= null);
49 protected String
getTitle() {
52 repoName
= repo
.getDirectory().getParentFile().getName();
54 repoName
= repo
.getDirectory().getName();
55 return MessageFormat
.format(UIText
.RefSelectionDialog_Title
, repoName
);
59 protected void createCustomArea(Composite parent
) {
60 branchTree
.addFilter(new ViewerFilter() {
63 public boolean select(Viewer viewer
, Object parentElement
,
65 if (element
instanceof AdditionalRefNode
) {
66 AdditionalRefNode ref
= (AdditionalRefNode
) element
;
67 return Constants
.HEAD
.equals(ref
.getObject().getName());
75 protected String
getMessageText() {
76 return UIText
.RefSelectionDialog_Message
;