1 /*******************************************************************************
2 * Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com>
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
9 package org
.eclipse
.egit
.ui
.internal
.fetch
;
11 import org
.eclipse
.egit
.ui
.UIText
;
12 import org
.eclipse
.jface
.dialogs
.Dialog
;
13 import org
.eclipse
.jface
.dialogs
.IDialogConstants
;
14 import org
.eclipse
.osgi
.util
.NLS
;
15 import org
.eclipse
.swt
.SWT
;
16 import org
.eclipse
.swt
.layout
.GridData
;
17 import org
.eclipse
.swt
.widgets
.Composite
;
18 import org
.eclipse
.swt
.widgets
.Control
;
19 import org
.eclipse
.swt
.widgets
.Label
;
20 import org
.eclipse
.swt
.widgets
.Shell
;
21 import org
.eclipse
.jgit
.lib
.Repository
;
22 import org
.eclipse
.jgit
.transport
.FetchResult
;
25 * Dialog displaying result of fetch operation.
27 class FetchResultDialog
extends Dialog
{
28 private final Repository localDb
;
30 private final FetchResult result
;
32 private final String sourceString
;
34 FetchResultDialog(final Shell parentShell
, final Repository localDb
,
35 final FetchResult result
, final String sourceString
) {
37 setShellStyle(getShellStyle() | SWT
.RESIZE
);
38 this.localDb
= localDb
;
40 this.sourceString
= sourceString
;
44 protected void createButtonsForButtonBar(final Composite parent
) {
45 createButton(parent
, IDialogConstants
.OK_ID
, IDialogConstants
.OK_LABEL
,
50 protected Control
createDialogArea(final Composite parent
) {
51 final Composite composite
= (Composite
) super.createDialogArea(parent
);
53 final Label label
= new Label(composite
, SWT
.NONE
);
55 if (!result
.getTrackingRefUpdates().isEmpty())
56 text
= NLS
.bind(UIText
.FetchResultDialog_labelNonEmptyResult
,
59 text
= NLS
.bind(UIText
.FetchResultDialog_labelEmptyResult
,
62 label
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, false));
64 final FetchResultTable table
= new FetchResultTable(composite
);
65 table
.setData(localDb
, result
);
66 final Control tableControl
= table
.getControl();
67 final GridData tableLayout
= new GridData(SWT
.FILL
, SWT
.FILL
, true,
69 tableLayout
.widthHint
= 600;
70 tableLayout
.heightHint
= 300;
71 tableControl
.setLayoutData(tableLayout
);
74 NLS
.bind(UIText
.FetchResultDialog_title
, sourceString
));
75 applyDialogFont(composite
);