Update org.apache.commons:commons-compress to 1.25.0
[egit/eclipse.git] / org.eclipse.egit.ui / src / org / eclipse / egit / ui / internal / reflog / RefSelectionDialog.java
blob499f275a2eb87429d9d68fb8a67e0687c0159207
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
10 * Contributors:
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;
28 /**
29 * Select the ref to show reflog for
31 public class RefSelectionDialog extends AbstractBranchSelectionDialog {
33 /**
34 * @param parentShell
35 * @param repository
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);
43 @Override
44 protected void refNameSelected(String refName) {
45 getButton(Window.OK).setEnabled(refName != null);
48 @Override
49 protected String getTitle() {
50 String repoName;
51 if (!repo.isBare())
52 repoName = repo.getDirectory().getParentFile().getName();
53 else
54 repoName = repo.getDirectory().getName();
55 return MessageFormat.format(UIText.RefSelectionDialog_Title, repoName);
58 @Override
59 protected void createCustomArea(Composite parent) {
60 branchTree.addFilter(new ViewerFilter() {
62 @Override
63 public boolean select(Viewer viewer, Object parentElement,
64 Object element) {
65 if (element instanceof AdditionalRefNode) {
66 AdditionalRefNode ref = (AdditionalRefNode) element;
67 return Constants.HEAD.equals(ref.getObject().getName());
69 return true;
71 });
74 @Override
75 protected String getMessageText() {
76 return UIText.RefSelectionDialog_Message;