git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [EGIT PATCH 0/6] Fetch UI, minor improvements/fixes
@ 2008-08-27 18:41 Marek Zawirski
  2008-08-27 18:41 ` [EGIT PATCH 1/6] Reduce PushOperationResult contructor visibility, accept null instead Marek Zawirski
  2008-08-27 19:48 ` [EGIT PATCH 0/6] Fetch UI, minor improvements/fixes Robin Rosenberg
  0 siblings, 2 replies; 10+ messages in thread
From: Marek Zawirski @ 2008-08-27 18:41 UTC (permalink / raw)
  To: robin.rosenberg, spearce; +Cc: git, Marek Zawirski

Simple fetch UI - made smiliar as push UI: no surprise, the same
components are used, code is analogous.

We can later decide to switch to some more complex result displaying
component, like common Transport View as suggested by Shawn. Anyway,
now we have working UI for push and fetch, and other signifficant
changes were introduced in both jgit and egit in the mean time...
isn't that right time to release next version?

OT(?): The only strange thing I observe now is how "refresh" resources
works in egit (master), but maybe I'll open new issues for that.

Marek Zawirski (6):
  Reduce PushOperationResult contructor visibility, accept null instead
  Fix RefSpecPanel to not display mode column in fetch version
  Handle null remoteName in RefSpecPanel better
  Add tag fetching strategy selection to fetch version of RefSpecPage
  Rename ResultDialog to PushResultDialog
  Fetch GUI

 .../spearce/egit/core/op/PushOperationResult.java  |    2 +-
 org.spearce.egit.ui/plugin.properties              |    3 +
 org.spearce.egit.ui/plugin.xml                     |   15 ++
 .../src/org/spearce/egit/ui/UIText.java            |  102 ++++++++++
 .../egit/ui/internal/actions/FetchAction.java      |   51 +++++
 .../egit/ui/internal/components/RefSpecPage.java   |   70 ++++++-
 .../egit/ui/internal/components/RefSpecPanel.java  |   36 +++-
 .../FetchResultDialog.java}                        |   35 ++-
 .../egit/ui/internal/fetch/FetchResultTable.java   |  213 ++++++++++++++++++++
 .../egit/ui/internal/fetch/FetchWizard.java        |  189 +++++++++++++++++
 .../fetch/TrackingRefUpdateContentProvider.java    |   41 ++++
 .../egit/ui/internal/push/ConfirmationPage.java    |    2 +-
 .../{ResultDialog.java => PushResultDialog.java}   |    4 +-
 .../egit/ui/internal/push/PushResultTable.java     |    9 +-
 .../spearce/egit/ui/internal/push/PushWizard.java  |    5 +-
 .../ui/internal/push/RefUpdateContentProvider.java |    8 +-
 .../src/org/spearce/egit/ui/uitext.properties      |   38 ++++
 17 files changed, 784 insertions(+), 39 deletions(-)
 create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/FetchAction.java
 copy org.spearce.egit.ui/src/org/spearce/egit/ui/internal/{push/ResultDialog.java => fetch/FetchResultDialog.java} (67%)
 create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/fetch/FetchResultTable.java
 create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/fetch/FetchWizard.java
 create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/fetch/TrackingRefUpdateContentProvider.java
 rename org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/{ResultDialog.java => PushResultDialog.java} (95%)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [EGIT PATCH 1/6] Reduce PushOperationResult contructor visibility, accept null instead
  2008-08-27 18:41 [EGIT PATCH 0/6] Fetch UI, minor improvements/fixes Marek Zawirski
@ 2008-08-27 18:41 ` Marek Zawirski
  2008-08-27 18:41   ` [EGIT PATCH 2/6] Fix RefSpecPanel to not display mode column in fetch version Marek Zawirski
  2008-08-27 19:48 ` [EGIT PATCH 0/6] Fetch UI, minor improvements/fixes Robin Rosenberg
  1 sibling, 1 reply; 10+ messages in thread
From: Marek Zawirski @ 2008-08-27 18:41 UTC (permalink / raw)
  To: robin.rosenberg, spearce; +Cc: git, Marek Zawirski

This constructor should be instantiated only by PushOperation.

Some changes were needed in RefUpdateContentProvider (and related) - to
accept null value instead of empty PushOperationResult.

Signed-off-by: Marek Zawirski <marek.zawirski@gmail.com>
---
 .../spearce/egit/core/op/PushOperationResult.java  |    2 +-
 .../egit/ui/internal/push/ConfirmationPage.java    |    2 +-
 .../egit/ui/internal/push/PushResultTable.java     |    9 +++++++--
 .../ui/internal/push/RefUpdateContentProvider.java |    8 ++++++--
 4 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/org.spearce.egit.core/src/org/spearce/egit/core/op/PushOperationResult.java b/org.spearce.egit.core/src/org/spearce/egit/core/op/PushOperationResult.java
index 6ffe998..e3a392d 100644
--- a/org.spearce.egit.core/src/org/spearce/egit/core/op/PushOperationResult.java
+++ b/org.spearce.egit.core/src/org/spearce/egit/core/op/PushOperationResult.java
@@ -35,7 +35,7 @@
 	/**
 	 * Construct empty push operation result.
 	 */
-	public PushOperationResult() {
+	PushOperationResult() {
 		this.urisEntries = new LinkedHashMap<URIish, Entry>();
 	}
 
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/ConfirmationPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/ConfirmationPage.java
index c8cdf29..08d21b3 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/ConfirmationPage.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/ConfirmationPage.java
@@ -139,7 +139,7 @@ private void checkPreviousPagesSelections() {
 
 	private void revalidate() {
 		// always update this page
-		resultPanel.setData(local, new PushOperationResult());
+		resultPanel.setData(local, null);
 		confirmedResult = null;
 		displayedRepoSelection = repoPage.getSelection();
 		displayedRefSpecs = refSpecPage.getRefSpecs();
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/PushResultTable.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/PushResultTable.java
index 2cf2be4..c5e476b 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/PushResultTable.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/PushResultTable.java
@@ -120,7 +120,7 @@ public int hashCode(Object element) {
 			}
 		});
 		tableViewer.setContentProvider(new RefUpdateContentProvider());
-		tableViewer.setInput(new PushOperationResult());
+		tableViewer.setInput(null);
 	}
 
 	void setData(final Repository localDb, final PushOperationResult result) {
@@ -128,7 +128,7 @@ void setData(final Repository localDb, final PushOperationResult result) {
 		for (final TableColumn tc : tableViewer.getTable().getColumns())
 			tc.dispose();
 		// Set empty result for a while.
-		tableViewer.setInput(new PushOperationResult());
+		tableViewer.setInput(null);
 
 		// Layout should be recreated to work properly.
 		final TableColumnLayout layout = new TableColumnLayout();
@@ -171,6 +171,11 @@ public String getText(Object element) {
 			}
 		});
 
+		if (result == null) {
+			tablePanel.layout();
+			return;
+		}
+
 		int i = 0;
 		for (final URIish uri : result.getURIs()) {
 			final TableViewerColumn statusViewer = createColumn(layout, NLS
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/RefUpdateContentProvider.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/RefUpdateContentProvider.java
index 862fe59..884c9a3 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/RefUpdateContentProvider.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/RefUpdateContentProvider.java
@@ -21,13 +21,17 @@
  * Content provided for push result table viewer.
  * <p>
  * Input of this provided must be {@link PushOperationResult} instance, while
- * returned elements are instances of {@link RefUpdateElement}.
- *
+ * returned elements are instances of {@link RefUpdateElement}. Null input is
+ * allowed, resulting in no elements.
+ * 
  * @see PushOperationResult
  * @see RefUpdateElement
  */
 class RefUpdateContentProvider implements IStructuredContentProvider {
 	public Object[] getElements(final Object inputElement) {
+		if (inputElement == null)
+			return new RefUpdateElement[0];
+
 		final PushOperationResult result = (PushOperationResult) inputElement;
 
 		final SortedMap<String, String> dstToSrc = new TreeMap<String, String>();
-- 
1.5.6.3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [EGIT PATCH 2/6] Fix RefSpecPanel to not display mode column in fetch version
  2008-08-27 18:41 ` [EGIT PATCH 1/6] Reduce PushOperationResult contructor visibility, accept null instead Marek Zawirski
@ 2008-08-27 18:41   ` Marek Zawirski
  2008-08-27 18:41     ` [EGIT PATCH 3/6] Handle null remoteName in RefSpecPanel better Marek Zawirski
  0 siblings, 1 reply; 10+ messages in thread
From: Marek Zawirski @ 2008-08-27 18:41 UTC (permalink / raw)
  To: robin.rosenberg, spearce; +Cc: git, Marek Zawirski

"Delete" mode is valid only for push, we need only "update/create"
mode for fetch, so there is no need to display this column here.

Signed-off-by: Marek Zawirski <marek.zawirski@gmail.com>
---
 .../egit/ui/internal/components/RefSpecPanel.java  |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/components/RefSpecPanel.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/components/RefSpecPanel.java
index 34d37fd..de82480 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/components/RefSpecPanel.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/components/RefSpecPanel.java
@@ -951,7 +951,8 @@ private void createTableColumns(final Composite tablePanel) {
 		tablePanel.setLayout(columnLayout);
 
 		createDummyColumn(columnLayout);
-		createModeColumn(columnLayout);
+		if (pushSpecs)
+			createModeColumn(columnLayout);
 		createSrcColumn(columnLayout);
 		createDstColumn(columnLayout);
 		createForceColumn(columnLayout);
@@ -1277,7 +1278,8 @@ private TableViewerColumn createColumn(
 	}
 
 	private void createCellEditors(final Table table) {
-		modeCellEditor = new CheckboxCellEditor(table);
+		if (pushSpecs)
+			modeCellEditor = new CheckboxCellEditor(table);
 		localRefCellEditor = createLocalRefCellEditor(table);
 		remoteRefCellEditor = createRemoteRefCellEditor(table);
 		forceUpdateCellEditor = new CheckboxCellEditor(table);
-- 
1.5.6.3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [EGIT PATCH 3/6] Handle null remoteName in RefSpecPanel better
  2008-08-27 18:41   ` [EGIT PATCH 2/6] Fix RefSpecPanel to not display mode column in fetch version Marek Zawirski
@ 2008-08-27 18:41     ` Marek Zawirski
  2008-08-27 18:41       ` [EGIT PATCH 4/6] Add tag fetching strategy selection to fetch version of RefSpecPage Marek Zawirski
  0 siblings, 1 reply; 10+ messages in thread
From: Marek Zawirski @ 2008-08-27 18:41 UTC (permalink / raw)
  To: robin.rosenberg, spearce; +Cc: git, Marek Zawirski

Create more sensible "all branches" ref spec
(refs/remotes/choose_remote_name/*), and don't use RemoteConfig
contructor with null remoteName value, as this behavior is unspecified.

Signed-off-by: Marek Zawirski <marek.zawirski@gmail.com>
---
 .../src/org/spearce/egit/ui/UIText.java            |    3 ++
 .../egit/ui/internal/components/RefSpecPanel.java  |   30 +++++++++++++------
 .../src/org/spearce/egit/ui/uitext.properties      |    1 +
 3 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java
index b45d2e9..2bbe218 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java
@@ -182,6 +182,9 @@
 	public static String RefSpecPanel_refChooseSomeWildcard;
 
 	/** */
+	public static String RefSpecPanel_refChooseRemoteName;
+
+	/** */
 	public static String RefSpecPanel_clickToChange;
 
 	/** */
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/components/RefSpecPanel.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/components/RefSpecPanel.java
index de82480..a2661ae 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/components/RefSpecPanel.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/components/RefSpecPanel.java
@@ -413,14 +413,18 @@ public void setAssistanceData(final Repository localRepo,
 		}
 
 		try {
-			final RemoteConfig rc = new RemoteConfig(localDb.getConfig(),
-					remoteName);
-			if (pushSpecs)
-				predefinedConfigured = rc.getPushRefSpecs();
-			else
-				predefinedConfigured = rc.getFetchRefSpecs();
-			for (final RefSpec spec : predefinedConfigured)
-				addRefSpec(spec);
+			if (remoteName == null)
+				predefinedConfigured = Collections.emptyList();
+			else {
+				final RemoteConfig rc = new RemoteConfig(localDb.getConfig(),
+						remoteName);
+				if (pushSpecs)
+					predefinedConfigured = rc.getPushRefSpecs();
+				else
+					predefinedConfigured = rc.getFetchRefSpecs();
+				for (final RefSpec spec : predefinedConfigured)
+					addRefSpec(spec);
+			}
 		} catch (URISyntaxException e) {
 			predefinedConfigured = null;
 			ErrorDialog.openError(panel.getShell(),
@@ -432,9 +436,15 @@ public void setAssistanceData(final Repository localRepo,
 		updateAddPredefinedButton(addConfiguredButton, predefinedConfigured);
 		if (pushSpecs)
 			predefinedBranches = Transport.REFSPEC_PUSH_ALL;
-		else
+		else {
+			final String r;
+			if (remoteName == null)
+				r = UIText.RefSpecPanel_refChooseRemoteName;
+			else
+				r = remoteName;
 			predefinedBranches = new RefSpec("refs/heads/*:refs/remotes/" //$NON-NLS-1$
-					+ remoteName + "/*"); //$NON-NLS-1$
+					+ r + "/*"); //$NON-NLS-1$
+		}
 		updateAddPredefinedButton(addBranchesButton, predefinedBranches);
 		setEnable(true);
 	}
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties b/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties
index 7fcc77b..c2b91f7 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties
@@ -116,6 +116,7 @@ RefSpecPanel_predefinedTagsDescription=Add specification covering all tags.
 RefSpecPanel_push=push
 RefSpecPanel_refChooseSome=choose/some/ref
 RefSpecPanel_refChooseSomeWildcard=choose/some/ref/*
+RefSpecPanel_refChooseRemoteName=choose_remote_name
 RefSpecPanel_removeAll=Remove all specs
 RefSpecPanel_removeAllDescription=Remove all speficications.
 RefSpecPanel_removeDescription=Click to remove this specification.
-- 
1.5.6.3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [EGIT PATCH 4/6] Add tag fetching strategy selection to fetch version of RefSpecPage
  2008-08-27 18:41     ` [EGIT PATCH 3/6] Handle null remoteName in RefSpecPanel better Marek Zawirski
@ 2008-08-27 18:41       ` Marek Zawirski
  2008-08-27 18:41         ` [EGIT PATCH 5/6] Rename ResultDialog to PushResultDialog Marek Zawirski
  0 siblings, 1 reply; 10+ messages in thread
From: Marek Zawirski @ 2008-08-27 18:41 UTC (permalink / raw)
  To: robin.rosenberg, spearce; +Cc: git, Marek Zawirski

Tag strategy selection determines tagOpt for Transport, which should be
under user control for fetch operation. RefSpecPage seems to be the best
place for such setting.

Signed-off-by: Marek Zawirski <marek.zawirski@gmail.com>
---
 .../src/org/spearce/egit/ui/UIText.java            |   12 ++++
 .../egit/ui/internal/components/RefSpecPage.java   |   70 ++++++++++++++++++--
 .../src/org/spearce/egit/ui/uitext.properties      |    4 +
 3 files changed, 81 insertions(+), 5 deletions(-)

diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java
index 2bbe218..ab70048 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java
@@ -386,6 +386,18 @@
 	public static String RefSpecPage_titlePush;
 
 	/** */
+	public static String RefSpecPage_annotatedTagsGroup;
+
+	/** */
+	public static String RefSpecPage_annotatedTagsAutoFollow;
+
+	/** */
+	public static String RefSpecPage_annotatedTagsFetchTags;
+
+	/** */
+	public static String RefSpecPage_annotatedTagsNoTags;
+
+	/** */
 	public static String Decorator_failedLazyLoading;
 
 	/** */
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/components/RefSpecPage.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/components/RefSpecPage.java
index 45a8505..586e5d9 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/components/RefSpecPage.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/components/RefSpecPage.java
@@ -23,11 +23,13 @@
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
 import org.spearce.egit.core.op.ListRemoteOperation;
 import org.spearce.egit.ui.Activator;
 import org.spearce.egit.ui.UIText;
 import org.spearce.jgit.lib.Repository;
 import org.spearce.jgit.transport.RefSpec;
+import org.spearce.jgit.transport.TagOpt;
 import org.spearce.jgit.transport.URIish;
 
 /**
@@ -54,6 +56,12 @@
 
 	private Button saveButton;
 
+	private Button tagsAutoFollowButton;
+
+	private Button tagsFetchTagsButton;
+
+	private Button tagsNoTagsButton;
+
 	private String transportError;
 
 	/**
@@ -106,14 +114,35 @@ public void selectionChanged() {
 			}
 		});
 
-		saveButton = new Button(panel, SWT.CHECK);
-		saveButton.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, false));
-		saveButton.addSelectionListener(new SelectionAdapter() {
+		final SelectionAdapter changesNotifier = new SelectionAdapter() {
 			@Override
 			public void widgetSelected(SelectionEvent e) {
 				notifySelectionChanged();
 			}
-		});
+		};
+		if (!pushPage) {
+			final Group tagsGroup = new Group(panel, SWT.NULL);
+			tagsGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
+					false));
+			tagsGroup.setText(UIText.RefSpecPage_annotatedTagsGroup);
+			tagsGroup.setLayout(new GridLayout());
+			tagsAutoFollowButton = new Button(tagsGroup, SWT.RADIO);
+			tagsAutoFollowButton
+					.setText(UIText.RefSpecPage_annotatedTagsAutoFollow);
+			tagsFetchTagsButton = new Button(tagsGroup, SWT.RADIO);
+			tagsFetchTagsButton
+					.setText(UIText.RefSpecPage_annotatedTagsFetchTags);
+			tagsNoTagsButton = new Button(tagsGroup, SWT.RADIO);
+			tagsNoTagsButton
+					.setText(UIText.RefSpecPage_annotatedTagsNoTags);
+			tagsAutoFollowButton.addSelectionListener(changesNotifier);
+			tagsFetchTagsButton.addSelectionListener(changesNotifier);
+			tagsNoTagsButton.addSelectionListener(changesNotifier);
+		}
+
+		saveButton = new Button(panel, SWT.CHECK);
+		saveButton.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, true, false));
+		saveButton.addSelectionListener(changesNotifier);
 
 		setControl(panel);
 		notifySelectionChanged();
@@ -147,6 +176,18 @@ public boolean isSaveRequested() {
 	}
 
 	/**
+	 * @return selected tag fetching strategy. This result is relevant only for
+	 *         fetch page.
+	 */
+	public TagOpt getTagOpt() {
+		if (tagsAutoFollowButton.getSelection())
+			return TagOpt.AUTO_FOLLOW;
+		if (tagsFetchTagsButton.getSelection())
+			return TagOpt.FETCH_TAGS;
+		return TagOpt.NO_TAGS;
+	}
+
+	/**
 	 * Compare provided specifications to currently selected ones.
 	 *
 	 * @param specs
@@ -206,12 +247,31 @@ private void revalidateImpl(final RepositorySelection newRepoSelection) {
 		final String remoteName = validatedRepoSelection.getConfigName();
 		specsPanel.setAssistanceData(local, listRemotesOp.getRemoteRefs(),
 				remoteName);
+
+		tagsAutoFollowButton.setSelection(false);
+		tagsFetchTagsButton.setSelection(false);
+		tagsNoTagsButton.setSelection(false);
+
 		if (newRepoSelection.isConfigSelected()) {
 			saveButton.setVisible(true);
 			saveButton.setText(NLS.bind(UIText.RefSpecPage_saveSpecifications,
 					remoteName));
 			saveButton.getParent().layout();
-		}
+			final TagOpt tagOpt = newRepoSelection.getConfig().getTagOpt();
+			switch (tagOpt) {
+			case AUTO_FOLLOW:
+				tagsAutoFollowButton.setSelection(true);
+				break;
+			case FETCH_TAGS:
+				tagsFetchTagsButton.setSelection(true);
+				break;
+			case NO_TAGS:
+				tagsNoTagsButton.setSelection(true);
+				break;
+			}
+		} else
+			tagsAutoFollowButton.setSelection(true);
+
 		checkPage();
 	}
 
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties b/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties
index c2b91f7..2349334 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties
@@ -147,6 +147,10 @@ RefSpecPage_operationCancelled=Operation cancelled.
 RefSpecPage_saveSpecifications=Save specifications in "{0}" configuration
 RefSpecPage_titleFetch=Fetch Ref Specifications
 RefSpecPage_titlePush=Push Ref Specifications
+RefSpecPage_annotatedTagsGroup=Annotated tags fetching strategy
+RefSpecPage_annotatedTagsAutoFollow=Automatically follow tags if we fetch the thing they point at
+RefSpecPage_annotatedTagsFetchTags=Always fetch tags, even if we do not have the thing it points at
+RefSpecPage_annotatedTagsNoTags=Never fetch tags, even if we have the thing it points at
 
 Decorator_failedLazyLoading=Resource decorator failed to load tree contents on demand.
 QuickDiff_failedLoading=Quick diff failed to obtain file data.
-- 
1.5.6.3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [EGIT PATCH 5/6] Rename ResultDialog to PushResultDialog
  2008-08-27 18:41       ` [EGIT PATCH 4/6] Add tag fetching strategy selection to fetch version of RefSpecPage Marek Zawirski
@ 2008-08-27 18:41         ` Marek Zawirski
  2008-08-27 18:41           ` [EGIT PATCH 6/6] Fetch GUI Marek Zawirski
  0 siblings, 1 reply; 10+ messages in thread
From: Marek Zawirski @ 2008-08-27 18:41 UTC (permalink / raw)
  To: robin.rosenberg, spearce; +Cc: git, Marek Zawirski

Let's avoid ambiguity in UIText and other places when we also use
FetchResultDialog.

Signed-off-by: Marek Zawirski <marek.zawirski@gmail.com>
---
 .../{ResultDialog.java => PushResultDialog.java}   |    4 ++--
 .../spearce/egit/ui/internal/push/PushWizard.java  |    5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)
 rename org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/{ResultDialog.java => PushResultDialog.java} (95%)

diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/ResultDialog.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/PushResultDialog.java
similarity index 95%
rename from org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/ResultDialog.java
rename to org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/PushResultDialog.java
index 920494f..bace9ad 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/ResultDialog.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/PushResultDialog.java
@@ -20,14 +20,14 @@
 import org.spearce.egit.ui.UIText;
 import org.spearce.jgit.lib.Repository;
 
-class ResultDialog extends Dialog {
+class PushResultDialog extends Dialog {
 	private final Repository localDb;
 
 	private final PushOperationResult result;
 
 	private final String destinationString;
 
-	ResultDialog(final Shell parentShell, final Repository localDb,
+	PushResultDialog(final Shell parentShell, final Repository localDb,
 			final PushOperationResult result, final String destinationString) {
 		super(parentShell);
 		setShellStyle(getShellStyle() | SWT.RESIZE);
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/PushWizard.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/PushWizard.java
index a5c6339..b2ef5ae 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/PushWizard.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/push/PushWizard.java
@@ -238,8 +238,9 @@ protected IStatus run(final IProgressMonitor monitor) {
 							public void run() {
 								final Shell shell = PlatformUI.getWorkbench()
 										.getActiveWorkbenchWindow().getShell();
-								final Dialog dialog = new ResultDialog(shell,
-										localDb, result, destinationString);
+								final Dialog dialog = new PushResultDialog(
+										shell, localDb, result,
+										destinationString);
 								dialog.open();
 							}
 						});
-- 
1.5.6.3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [EGIT PATCH 6/6] Fetch GUI
  2008-08-27 18:41         ` [EGIT PATCH 5/6] Rename ResultDialog to PushResultDialog Marek Zawirski
@ 2008-08-27 18:41           ` Marek Zawirski
  0 siblings, 0 replies; 10+ messages in thread
From: Marek Zawirski @ 2008-08-27 18:41 UTC (permalink / raw)
  To: robin.rosenberg, spearce; +Cc: git, Marek Zawirski

Fetch GUI is currently implemented similarly to push GUI - it's a wizard
consisting of 2 pages:
- repository seleciton page (configured remote or custom URI)
- ref specs selection page (ref specs + tag options)

Background fetch job is started upon wizard finish. When operation
completes, simple dialog with fetch results is displayed.

Signed-off-by: Marek Zawirski <marek.zawirski@gmail.com>
---
 org.spearce.egit.ui/plugin.properties              |    3 +
 org.spearce.egit.ui/plugin.xml                     |   15 ++
 .../src/org/spearce/egit/ui/UIText.java            |   87 ++++++++
 .../egit/ui/internal/actions/FetchAction.java      |   51 +++++
 .../egit/ui/internal/fetch/FetchResultDialog.java  |   76 +++++++
 .../egit/ui/internal/fetch/FetchResultTable.java   |  213 ++++++++++++++++++++
 .../egit/ui/internal/fetch/FetchWizard.java        |  189 +++++++++++++++++
 .../fetch/TrackingRefUpdateContentProvider.java    |   41 ++++
 .../src/org/spearce/egit/ui/uitext.properties      |   33 +++
 9 files changed, 708 insertions(+), 0 deletions(-)
 create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/FetchAction.java
 create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/fetch/FetchResultDialog.java
 create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/fetch/FetchResultTable.java
 create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/fetch/FetchWizard.java
 create mode 100644 org.spearce.egit.ui/src/org/spearce/egit/ui/internal/fetch/TrackingRefUpdateContentProvider.java

diff --git a/org.spearce.egit.ui/plugin.properties b/org.spearce.egit.ui/plugin.properties
index 8ac3474..da91e48 100644
--- a/org.spearce.egit.ui/plugin.properties
+++ b/org.spearce.egit.ui/plugin.properties
@@ -41,6 +41,9 @@ ResetAction_tooltip=Reset the current branch to the same or another commit
 BranchAction_label=&Branch...
 BranchAction_tooltip=Switch to another branch
 
+FetchAction_label=&Fetch From...
+FetchAction_tooltip=Fetch from another repository
+
 PushAction_label=&Push To...
 PushAction_tooltip=Push to another repository
 
diff --git a/org.spearce.egit.ui/plugin.xml b/org.spearce.egit.ui/plugin.xml
index 4012f19..55207eb 100644
--- a/org.spearce.egit.ui/plugin.xml
+++ b/org.spearce.egit.ui/plugin.xml
@@ -40,6 +40,12 @@
                id="org.spearce.egit.ui.internal.actions.Disconnect">
          </action>
          <action
+               class="org.spearce.egit.ui.internal.actions.FetchAction"
+               id="org.spearce.egit.ui.internal.actions.FetchAction"
+               label="%FetchAction_label"
+               menubarPath="team.main/projectGroup"
+               tooltip="%FetchAction_tooltip"/>
+         <action
                class="org.spearce.egit.ui.internal.actions.PushAction"
                id="org.spearce.egit.ui.internal.actions.PushAction"
                label="%PushAction_label"
@@ -259,6 +265,15 @@
         </separator>
 	    </menu>
 		<action
+		       class="org.spearce.egit.ui.internal.actions.FetchAction"
+		       id="org.spearce.egit.ui.actionfetch"
+		       label="%FetchAction_label"
+		       style="push"
+		       menubarPath="org.spearce.egit.ui.gitmenu/repo"
+		       toolbarPath="org.spearce.egit.ui"
+		       tooltip="%FetchAction_tooltip">
+		</action>
+		<action
 		       class="org.spearce.egit.ui.internal.actions.PushAction"
 		       id="org.spearce.egit.ui.actionpush"
 		       label="%PushAction_label"
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java
index ab70048..b2cb340 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/UIText.java
@@ -614,6 +614,93 @@
 	public static String ResultDialog_label;
 
 	/** */
+	public static String FetchAction_wrongURITitle;
+
+	/** */
+	public static String FetchAction_wrongURIMessage;
+
+	/** */
+	public static String FetchResultDialog_labelEmptyResult;
+
+	/** */
+	public static String FetchResultDialog_labelNonEmptyResult;
+
+	/** */
+	public static String FetchResultDialog_title;
+
+	/** */
+	public static String FetchResultTable_columnDst;
+
+	/** */
+	public static String FetchResultTable_columnSrc;
+
+	/** */
+	public static String FetchResultTable_columnStatus;
+
+	/** */
+	public static String FetchResultTable_statusDetailCouldntLock;
+
+	/** */
+	public static String FetchResultTable_statusDetailFastForward;
+
+	/** */
+	public static String FetchResultTable_statusDetailIOError;
+
+	/** */
+	public static String FetchResultTable_statusDetailNonFastForward;
+
+	/** */
+	public static String FetchResultTable_statusIOError;
+
+	/** */
+	public static String FetchResultTable_statusLockFailure;
+
+	/** */
+	public static String FetchResultTable_statusNewBranch;
+
+	/** */
+	public static String FetchResultTable_statusNew;
+
+	/** */
+	public static String FetchResultTable_statusNewTag;
+
+	/** */
+	public static String FetchResultTable_statusRejected;
+
+	/** */
+	public static String FetchResultTable_statusUnexpected;
+
+	/** */
+	public static String FetchResultTable_statusUpToDate;
+
+	/** */
+	public static String FetchWizard_cantSaveMessage;
+
+	/** */
+	public static String FetchWizard_cantSaveTitle;
+
+	/** */
+	public static String FetchWizard_fetchNotSupported;
+
+	/** */
+	public static String FetchWizard_jobName;
+
+	/** */
+	public static String FetchWizard_transportError;
+
+	/** */
+	public static String FetchWizard_transportNotSupportedMessage;
+
+	/** */
+	public static String FetchWizard_transportNotSupportedTitle;
+
+	/** */
+	public static String FetchWizard_windowTitleDefault;
+
+	/** */
+	public static String FetchWizard_windowTitleWithSource;
+
+	/** */
 	public static String WindowCachePreferencePage_title;
 
 	/** */
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/FetchAction.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/FetchAction.java
new file mode 100644
index 0000000..582cb46
--- /dev/null
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/actions/FetchAction.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * See LICENSE for the full license text, also available.
+ *******************************************************************************/
+package org.spearce.egit.ui.internal.actions;
+
+import java.net.URISyntaxException;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.spearce.egit.ui.Activator;
+import org.spearce.egit.ui.UIText;
+import org.spearce.egit.ui.internal.fetch.FetchWizard;
+import org.spearce.jgit.lib.Repository;
+
+/**
+ * Action for displaying fetch wizard - allowing selection of specifications for
+ * fetch, and fetching objects/refs from another repository.
+ */
+public class FetchAction extends RepositoryAction {
+	@Override
+	public void run(IAction action) {
+		final Repository repository = getRepository(true);
+		if (repository == null)
+			return;
+
+		final FetchWizard fetchWizard;
+		try {
+			fetchWizard = new FetchWizard(repository);
+		} catch (URISyntaxException x) {
+			ErrorDialog.openError(getShell(), UIText.FetchAction_wrongURITitle,
+					UIText.FetchAction_wrongURIMessage, new Status(
+							IStatus.ERROR, Activator.getPluginId(), x
+									.getMessage(), x));
+			return;
+		}
+		final WizardDialog dialog = new WizardDialog(getShell(), fetchWizard);
+		dialog.open();
+	}
+
+	@Override
+	public boolean isEnabled() {
+		return getRepository(false) != null;
+	}
+}
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/fetch/FetchResultDialog.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/fetch/FetchResultDialog.java
new file mode 100644
index 0000000..4b52b8d
--- /dev/null
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/fetch/FetchResultDialog.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * See LICENSE for the full license text, also available.
+ *******************************************************************************/
+package org.spearce.egit.ui.internal.fetch;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.spearce.egit.ui.UIText;
+import org.spearce.jgit.lib.Repository;
+import org.spearce.jgit.transport.FetchResult;
+
+/**
+ * Dialog displaying result of fetch operation.
+ */
+class FetchResultDialog extends Dialog {
+	private final Repository localDb;
+
+	private final FetchResult result;
+
+	private final String sourceString;
+
+	FetchResultDialog(final Shell parentShell, final Repository localDb,
+			final FetchResult result, final String sourceString) {
+		super(parentShell);
+		setShellStyle(getShellStyle() | SWT.RESIZE);
+		this.localDb = localDb;
+		this.result = result;
+		this.sourceString = sourceString;
+	}
+
+	@Override
+	protected void createButtonsForButtonBar(final Composite parent) {
+		createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
+				true);
+	}
+
+	@Override
+	protected Control createDialogArea(final Composite parent) {
+		final Composite composite = (Composite) super.createDialogArea(parent);
+
+		final Label label = new Label(composite, SWT.NONE);
+		final String text;
+		if (!result.getTrackingRefUpdates().isEmpty())
+			text = NLS.bind(UIText.FetchResultDialog_labelNonEmptyResult,
+					sourceString);
+		else
+			text = NLS.bind(UIText.FetchResultDialog_labelEmptyResult,
+					sourceString);
+		label.setText(text);
+		label.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+
+		final FetchResultTable table = new FetchResultTable(composite);
+		table.setData(localDb, result);
+		final Control tableControl = table.getControl();
+		final GridData tableLayout = new GridData(SWT.FILL, SWT.FILL, true,
+				true);
+		tableLayout.widthHint = 600;
+		tableLayout.heightHint = 300;
+		tableControl.setLayoutData(tableLayout);
+
+		getShell().setText(
+				NLS.bind(UIText.FetchResultDialog_title, sourceString));
+		return composite;
+	}
+}
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/fetch/FetchResultTable.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/fetch/FetchResultTable.java
new file mode 100644
index 0000000..868ca94
--- /dev/null
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/fetch/FetchResultTable.java
@@ -0,0 +1,213 @@
+package org.spearce.egit.ui.internal.fetch;
+
+import org.eclipse.jface.layout.TableColumnLayout;
+import org.eclipse.jface.resource.ColorRegistry;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.TableViewerColumn;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.spearce.egit.ui.UIText;
+import org.spearce.jgit.lib.Constants;
+import org.spearce.jgit.lib.RefUpdate;
+import org.spearce.jgit.lib.Repository;
+import org.spearce.jgit.lib.RefUpdate.Result;
+import org.spearce.jgit.transport.FetchResult;
+import org.spearce.jgit.transport.TrackingRefUpdate;
+
+/**
+ * Component displaying table with results of fetch operation.
+ */
+class FetchResultTable {
+	private static final int TABLE_PREFERRED_HEIGHT = 600;
+
+	private static final int TABLE_PREFERRED_WIDTH = 300;
+
+	private static final int COLUMN_SRC_WEIGHT = 10;
+
+	private static final int COLUMN_DST_WEIGHT = 10;
+
+	private static final int COLUMN_STATUS_WEIGHT = 7;
+
+	private static final String COLOR_REJECTED_KEY = "REJECTED"; //$NON-NLS-1$
+
+	private static final RGB COLOR_REJECTED = new RGB(255, 0, 0);
+
+	private static final String COLOR_UPDATED_KEY = "UPDATED"; //$NON-NLS-1$
+
+	private static final RGB COLOR_UPDATED = new RGB(0, 255, 0);
+
+	private static final String COLOR_UP_TO_DATE_KEY = "UP_TO_DATE"; //$NON-NLS-1$
+
+	private static final RGB COLOR_UP_TO_DATE = new RGB(245, 245, 245);
+
+	private final Composite tablePanel;
+
+	private final TableViewer tableViewer;
+
+	private final ColorRegistry colorRegistry;
+
+	private Repository db;
+
+	FetchResultTable(final Composite parent) {
+		tablePanel = new Composite(parent, SWT.NONE);
+		tablePanel.setLayout(new GridLayout());
+		final GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+		layoutData.heightHint = TABLE_PREFERRED_HEIGHT;
+		layoutData.widthHint = TABLE_PREFERRED_WIDTH;
+		tableViewer = new TableViewer(tablePanel);
+		ColumnViewerToolTipSupport.enableFor(tableViewer);
+		final Table table = tableViewer.getTable();
+		table.setLinesVisible(true);
+		table.setHeaderVisible(true);
+
+		colorRegistry = new ColorRegistry(table.getDisplay());
+		colorRegistry.put(COLOR_REJECTED_KEY, COLOR_REJECTED);
+		colorRegistry.put(COLOR_UPDATED_KEY, COLOR_UPDATED);
+		colorRegistry.put(COLOR_UP_TO_DATE_KEY, COLOR_UP_TO_DATE);
+
+		tableViewer.setContentProvider(new TrackingRefUpdateContentProvider());
+		tableViewer.setInput(null);
+
+		createTableColumns();
+	}
+
+	void setData(final Repository db, final FetchResult fetchResult) {
+		tableViewer.setInput(null);
+		this.db = db;
+		tableViewer.setInput(fetchResult);
+	}
+
+	Control getControl() {
+		return tablePanel;
+	}
+
+	private void createTableColumns() {
+		final TableColumnLayout layout = new TableColumnLayout();
+		tablePanel.setLayout(layout);
+
+		final TableViewerColumn srcViewer = createColumn(layout,
+				UIText.FetchResultTable_columnSrc, COLUMN_SRC_WEIGHT, SWT.LEFT);
+		srcViewer.setLabelProvider(new ColumnLabelProvider() {
+			@Override
+			public String getText(Object element) {
+				return ((TrackingRefUpdate) element).getRemoteName();
+			}
+		});
+
+		final TableViewerColumn dstViewer = createColumn(layout,
+				UIText.FetchResultTable_columnDst, COLUMN_DST_WEIGHT, SWT.LEFT);
+		dstViewer.setLabelProvider(new ColumnLabelProvider() {
+			@Override
+			public String getText(Object element) {
+				return ((TrackingRefUpdate) element).getLocalName();
+			}
+		});
+
+		final TableViewerColumn statusViewer = createColumn(layout,
+				UIText.FetchResultTable_columnStatus, COLUMN_STATUS_WEIGHT,
+				SWT.LEFT);
+		statusViewer.setLabelProvider(new ColumnLabelProvider() {
+			@Override
+			public String getText(final Object element) {
+				final TrackingRefUpdate tru = (TrackingRefUpdate) element;
+				final RefUpdate.Result r = tru.getResult();
+				if (r == RefUpdate.Result.LOCK_FAILURE)
+					return UIText.FetchResultTable_statusLockFailure;
+
+				if (r == RefUpdate.Result.IO_FAILURE)
+					return UIText.FetchResultTable_statusIOError;
+
+				if (r == RefUpdate.Result.NEW) {
+					if (tru.getRemoteName().startsWith(Constants.R_HEADS))
+						return UIText.FetchResultTable_statusNewBranch;
+					else if (tru.getLocalName().startsWith(Constants.R_TAGS))
+						return UIText.FetchResultTable_statusNewTag;
+					return UIText.FetchResultTable_statusNew;
+				}
+
+				if (r == RefUpdate.Result.FORCED) {
+					final String aOld = tru.getOldObjectId().abbreviate(db);
+					final String aNew = tru.getNewObjectId().abbreviate(db);
+					return aOld + "..." + aNew; //$NON-NLS-1$
+				}
+
+				if (r == RefUpdate.Result.FAST_FORWARD) {
+					final String aOld = tru.getOldObjectId().abbreviate(db);
+					final String aNew = tru.getNewObjectId().abbreviate(db);
+					return aOld + ".." + aNew; //$NON-NLS-1$
+				}
+
+				if (r == RefUpdate.Result.REJECTED)
+					return UIText.FetchResultTable_statusRejected;
+				if (r == RefUpdate.Result.NO_CHANGE)
+					return UIText.FetchResultTable_statusUpToDate;
+				throw new IllegalArgumentException(NLS.bind(
+						UIText.FetchResultTable_statusUnexpected, r));
+			}
+
+			@Override
+			public String getToolTipText(final Object element) {
+				final Result result = ((TrackingRefUpdate) element).getResult();
+				switch (result) {
+				case FAST_FORWARD:
+					return UIText.FetchResultTable_statusDetailFastForward;
+				case FORCED:
+				case REJECTED:
+					return UIText.FetchResultTable_statusDetailNonFastForward;
+				case NEW:
+				case NO_CHANGE:
+					return null;
+				case IO_FAILURE:
+					return UIText.FetchResultTable_statusDetailIOError;
+				case LOCK_FAILURE:
+					return UIText.FetchResultTable_statusDetailCouldntLock;
+				default:
+					throw new IllegalArgumentException(NLS.bind(
+							UIText.FetchResultTable_statusUnexpected, result));
+				}
+			}
+
+			@Override
+			public Color getBackground(final Object element) {
+				final Result result = ((TrackingRefUpdate) element).getResult();
+				switch (result) {
+				case FAST_FORWARD:
+				case FORCED:
+				case NEW:
+					return colorRegistry.get(COLOR_UPDATED_KEY);
+				case NO_CHANGE:
+					return colorRegistry.get(COLOR_UP_TO_DATE_KEY);
+				case IO_FAILURE:
+				case LOCK_FAILURE:
+				case REJECTED:
+					return colorRegistry.get(COLOR_REJECTED_KEY);
+				default:
+					throw new IllegalArgumentException(NLS.bind(
+							UIText.FetchResultTable_statusUnexpected, result));
+				}
+			}
+		});
+	}
+
+	private TableViewerColumn createColumn(
+			final TableColumnLayout columnLayout, final String text,
+			final int weight, final int style) {
+		final TableViewerColumn viewerColumn = new TableViewerColumn(
+				tableViewer, style);
+		final TableColumn column = viewerColumn.getColumn();
+		column.setText(text);
+		columnLayout.setColumnData(column, new ColumnWeightData(weight));
+		return viewerColumn;
+	}
+}
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/fetch/FetchWizard.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/fetch/FetchWizard.java
new file mode 100644
index 0000000..db383cf
--- /dev/null
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/fetch/FetchWizard.java
@@ -0,0 +1,189 @@
+/*******************************************************************************
+ * Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * See LICENSE for the full license text, also available.
+ *******************************************************************************/
+package org.spearce.egit.ui.internal.fetch;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.List;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.spearce.egit.core.EclipseGitProgressTransformer;
+import org.spearce.egit.ui.Activator;
+import org.spearce.egit.ui.UIIcons;
+import org.spearce.egit.ui.UIText;
+import org.spearce.egit.ui.internal.components.RefSpecPage;
+import org.spearce.egit.ui.internal.components.RepositorySelection;
+import org.spearce.egit.ui.internal.components.RepositorySelectionPage;
+import org.spearce.jgit.errors.NotSupportedException;
+import org.spearce.jgit.errors.TransportException;
+import org.spearce.jgit.lib.Repository;
+import org.spearce.jgit.lib.RepositoryConfig;
+import org.spearce.jgit.transport.FetchResult;
+import org.spearce.jgit.transport.RefSpec;
+import org.spearce.jgit.transport.RemoteConfig;
+import org.spearce.jgit.transport.Transport;
+
+/**
+ * Wizard allowing user to specify all needed data to fetch from another
+ * repository - including selection of remote repository, ref specifications,
+ * annotated tags fetching strategy.
+ * <p>
+ * Fetch operation is performed upon successful completion of this wizard.
+ */
+public class FetchWizard extends Wizard {
+	private final Repository localDb;
+
+	private final RepositorySelectionPage repoPage;
+
+	private final RefSpecPage refSpecPage;
+
+	/**
+	 * Create wizard for provided local repository.
+	 * 
+	 * @param localDb
+	 *            local repository to fetch to.
+	 * @throws URISyntaxException
+	 *             when configuration of this repository contains illegal URIs.
+	 */
+	public FetchWizard(final Repository localDb) throws URISyntaxException {
+		this.localDb = localDb;
+		final List<RemoteConfig> remotes = RemoteConfig
+				.getAllRemoteConfigs(localDb.getConfig());
+		repoPage = new RepositorySelectionPage(true, remotes);
+		refSpecPage = new RefSpecPage(localDb, false, repoPage);
+		// TODO use/create another cool icon
+		setDefaultPageImageDescriptor(UIIcons.WIZBAN_IMPORT_REPO);
+		setNeedsProgressMonitor(true);
+	}
+
+	@Override
+	public void addPages() {
+		addPage(repoPage);
+		addPage(refSpecPage);
+	}
+
+	@Override
+	public boolean performFinish() {
+		if (repoPage.getSelection().isConfigSelected()
+				&& refSpecPage.isSaveRequested())
+			saveConfig();
+
+		final Transport transport;
+		final RepositorySelection repoSelection = repoPage.getSelection();
+		try {
+			if (repoSelection.isConfigSelected())
+				transport = Transport.open(localDb, repoSelection.getConfig());
+			else
+				transport = Transport.open(localDb, repoSelection.getURI());
+		} catch (final NotSupportedException e) {
+			ErrorDialog.openError(getShell(),
+					UIText.FetchWizard_transportNotSupportedTitle,
+					UIText.FetchWizard_transportNotSupportedMessage,
+					new Status(IStatus.ERROR, org.spearce.egit.ui.Activator
+							.getPluginId(), e.getMessage(), e));
+			return false;
+		}
+		transport.setTagOpt(refSpecPage.getTagOpt());
+
+		final Job fetchJob = new FetchJob(transport, refSpecPage.getRefSpecs(),
+				getSourceString());
+		fetchJob.setUser(true);
+		fetchJob.schedule();
+		return true;
+	}
+
+	@Override
+	public String getWindowTitle() {
+		final IWizardPage currentPage = getContainer().getCurrentPage();
+		if (currentPage == repoPage || currentPage == null)
+			return UIText.FetchWizard_windowTitleDefault;
+		return NLS.bind(UIText.FetchWizard_windowTitleWithSource,
+				getSourceString());
+	}
+
+	private void saveConfig() {
+		final RemoteConfig rc = repoPage.getSelection().getConfig();
+		rc.setFetchRefSpecs(refSpecPage.getRefSpecs());
+		rc.setTagOpt(refSpecPage.getTagOpt());
+		final RepositoryConfig config = localDb.getConfig();
+		rc.update(config);
+		try {
+			config.save();
+		} catch (final IOException e) {
+			ErrorDialog.openError(getShell(), UIText.FetchWizard_cantSaveTitle,
+					UIText.FetchWizard_cantSaveMessage, new Status(
+							IStatus.WARNING, Activator.getPluginId(), e
+									.getMessage(), e));
+			// Continue, it's not critical.
+		}
+	}
+
+	private String getSourceString() {
+		final RepositorySelection repoSelection = repoPage.getSelection();
+		if (repoSelection.isConfigSelected())
+			return repoSelection.getConfigName();
+		return repoSelection.getURI().toString();
+	}
+
+	private class FetchJob extends Job {
+		private final Transport transport;
+
+		private final List<RefSpec> refSpecs;
+
+		private final String sourceString;
+
+		public FetchJob(final Transport transport,
+				final List<RefSpec> refSpecs, final String sourceString) {
+			super(NLS.bind(UIText.FetchWizard_jobName, sourceString));
+			this.transport = transport;
+			this.refSpecs = refSpecs;
+			this.sourceString = sourceString;
+		}
+
+		@Override
+		protected IStatus run(IProgressMonitor monitor) {
+			if (monitor == null)
+				monitor = new NullProgressMonitor();
+			final FetchResult result;
+			try {
+				result = transport.fetch(new EclipseGitProgressTransformer(
+						monitor), refSpecs);
+			} catch (final NotSupportedException e) {
+				return new Status(IStatus.ERROR, Activator.getPluginId(),
+						UIText.FetchWizard_fetchNotSupported, e);
+			} catch (final TransportException e) {
+				if (monitor.isCanceled())
+					return Status.CANCEL_STATUS;
+				return new Status(IStatus.ERROR, Activator.getPluginId(),
+						UIText.FetchWizard_transportError, e);
+			}
+
+			PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+				public void run() {
+					final Shell shell = PlatformUI.getWorkbench()
+							.getActiveWorkbenchWindow().getShell();
+					final Dialog dialog = new FetchResultDialog(shell, localDb,
+							result, sourceString);
+					dialog.open();
+				}
+			});
+			return Status.OK_STATUS;
+		}
+	}
+}
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/fetch/TrackingRefUpdateContentProvider.java b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/fetch/TrackingRefUpdateContentProvider.java
new file mode 100644
index 0000000..35d37d0
--- /dev/null
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/internal/fetch/TrackingRefUpdateContentProvider.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (C) 2008, Marek Zawirski <marek.zawirski@gmail.com>
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * See LICENSE for the full license text, also available.
+ *******************************************************************************/
+package org.spearce.egit.ui.internal.fetch;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.spearce.jgit.transport.FetchResult;
+import org.spearce.jgit.transport.TrackingRefUpdate;
+
+/**
+ * Content provided for fetch result table viewer.
+ * <p>
+ * Input of this provided must be {@link FetchResult} instance, while returned
+ * elements are instances of {@link TrackingRefUpdate}. Input may be null (no
+ * elements).
+ * 
+ * @see FetchResult
+ * @see TrackingRefUpdate
+ */
+class TrackingRefUpdateContentProvider implements IStructuredContentProvider {
+	public Object[] getElements(final Object inputElement) {
+		if (inputElement == null)
+			return new TrackingRefUpdate[0];
+
+		final FetchResult result = (FetchResult) inputElement;
+		return result.getTrackingRefUpdates().toArray(new TrackingRefUpdate[0]);
+	}
+
+	public void dispose() {
+		// nothing to do
+	}
+
+	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+		// nothing to do
+	}
+}
diff --git a/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties b/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties
index 2349334..0590e30 100644
--- a/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties
+++ b/org.spearce.egit.ui/src/org/spearce/egit/ui/uitext.properties
@@ -234,6 +234,39 @@ PushResultTable_statusOkNewTag=[new tag]
 ResultDialog_title=Push Results: {0}
 ResultDialog_label=Pushed to {0}.
 
+FetchAction_wrongURITitle=Corrupted Configuration
+FetchAction_wrongURIMessage=Remote repositories URIs configuration is corrupted.
+
+FetchResultDialog_labelEmptyResult=No ref to fetch from {0} - everything up to date.
+FetchResultDialog_labelNonEmptyResult=Fetched from {0}.
+FetchResultDialog_title=Fetch Results: {0}
+
+FetchResultTable_columnDst=Destination Ref
+FetchResultTable_columnSrc=Source Ref
+FetchResultTable_columnStatus=Status
+FetchResultTable_statusDetailCouldntLock=couldn't lock local tracking ref for update
+FetchResultTable_statusDetailFastForward=fast forward
+FetchResultTable_statusDetailIOError=I/O error occurred during local tracking ref update
+FetchResultTable_statusDetailNonFastForward=non-fast forward
+FetchResultTable_statusIOError=[i/o error]
+FetchResultTable_statusLockFailure=[lock fail]
+FetchResultTable_statusNew=[new]
+FetchResultTable_statusNewBranch=[new branch]
+FetchResultTable_statusNewTag=[new tag]
+FetchResultTable_statusRejected=[rejected]
+FetchResultTable_statusUnexpected=Unexpected update status: {0}
+FetchResultTable_statusUpToDate=[up to date]
+
+FetchWizard_cantSaveMessage=Couldn't save specified specifications in configuration file.
+FetchWizard_cantSaveTitle=Configuration Storage Warning
+FetchWizard_fetchNotSupported=Fetch operation is not supported by this transport.
+FetchWizard_jobName=Fetching from: {0}
+FetchWizard_transportError=Transport error occured during fetch operation.
+FetchWizard_transportNotSupportedMessage=Selected URI is not supported by any transport implementation.
+FetchWizard_transportNotSupportedTitle=Transport Not Supported
+FetchWizard_windowTitleDefault=Fetch From Another Repository
+FetchWizard_windowTitleWithSource=Fetch From: {0}
+
 WindowCachePreferencePage_title=Git Window Cache
 WindowCachePreferencePage_packedGitWindowSize=Window size:
 WindowCachePreferencePage_packedGitLimit=Window cache limit:
-- 
1.5.6.3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [EGIT PATCH 0/6] Fetch UI, minor improvements/fixes
  2008-08-27 18:41 [EGIT PATCH 0/6] Fetch UI, minor improvements/fixes Marek Zawirski
  2008-08-27 18:41 ` [EGIT PATCH 1/6] Reduce PushOperationResult contructor visibility, accept null instead Marek Zawirski
@ 2008-08-27 19:48 ` Robin Rosenberg
  2008-08-27 20:09   ` Marek Zawirski
  1 sibling, 1 reply; 10+ messages in thread
From: Robin Rosenberg @ 2008-08-27 19:48 UTC (permalink / raw)
  To: Marek Zawirski; +Cc: spearce, git

onsdagen den 27 augusti 2008 20.41.40 skrev Marek Zawirski:
> Simple fetch UI - made smiliar as push UI: no surprise, the same
> components are used, code is analogous.
> 
> We can later decide to switch to some more complex result displaying
> component, like common Transport View as suggested by Shawn. Anyway,
> now we have working UI for push and fetch, and other signifficant
> changes were introduced in both jgit and egit in the mean 
> isn't that right time to release next version?

Indeed, this is the missing piece for a coherent version.  I'll have yet to
review the stuff, but I have great confidence in your work.
> 
> OT(?): The only strange thing I observe now is how "refresh" resources
> works in egit (master), but maybe I'll open new issues for that.

We might have bugs there.... Or actually, I *know* we have bugs including
lockups. But I can consider bumping the version anyway by next weekend, since
automatic refresh can be disabled. That'll leave us some time for things to cook.

-- robin

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [EGIT PATCH 0/6] Fetch UI, minor improvements/fixes
  2008-08-27 19:48 ` [EGIT PATCH 0/6] Fetch UI, minor improvements/fixes Robin Rosenberg
@ 2008-08-27 20:09   ` Marek Zawirski
  2008-08-27 21:51     ` Shawn O. Pearce
  0 siblings, 1 reply; 10+ messages in thread
From: Marek Zawirski @ 2008-08-27 20:09 UTC (permalink / raw)
  To: Robin Rosenberg; +Cc: spearce, git

Robin Rosenberg wrote:
> onsdagen den 27 augusti 2008 20.41.40 skrev Marek Zawirski:
(...)
>> isn't that right time to release next version?
> 
> Indeed, this is the missing piece for a coherent version.  I'll have yet to
> review the stuff, but I have great confidence in your work.

Sure, I even wouldn't like to have my code accepted without your review:)

>> OT(?): The only strange thing I observe now is how "refresh" resources
>> works in egit (master), but maybe I'll open new issues for that.
> 
> We might have bugs there.... Or actually, I *know* we have bugs including
> lockups. But I can consider bumping the version anyway by next weekend, since
> automatic refresh can be disabled. That'll leave us some time for things to cook.

I also encountered issues with locking workspace one day, but I actually 
meant something different.
See http://code.google.com/p/egit/issues/detail?id=14

BTW, is it possible at code gooogle to receive e-mail notifications 
about new issues?
-- 
Marek Zawirski [zawir]
marek.zawirski@gmail.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [EGIT PATCH 0/6] Fetch UI, minor improvements/fixes
  2008-08-27 20:09   ` Marek Zawirski
@ 2008-08-27 21:51     ` Shawn O. Pearce
  0 siblings, 0 replies; 10+ messages in thread
From: Shawn O. Pearce @ 2008-08-27 21:51 UTC (permalink / raw)
  To: Marek Zawirski; +Cc: Robin Rosenberg, git

Marek Zawirski <marek.zawirski@gmail.com> wrote:
> BTW, is it possible at code gooogle to receive e-mail notifications  
> about new issues?

It send updates out to the owner of the issue.  It also sends them
if you CC people.  Otherwise it doesn't send stuff out.  E.g. I
did not get email for issue 15 "Allow user to fetch from/push to
preconfigured remote from menu" or issue 16 "Push to read-only
repository produce cryptic error message".

-- 
Shawn.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-08-27 21:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-27 18:41 [EGIT PATCH 0/6] Fetch UI, minor improvements/fixes Marek Zawirski
2008-08-27 18:41 ` [EGIT PATCH 1/6] Reduce PushOperationResult contructor visibility, accept null instead Marek Zawirski
2008-08-27 18:41   ` [EGIT PATCH 2/6] Fix RefSpecPanel to not display mode column in fetch version Marek Zawirski
2008-08-27 18:41     ` [EGIT PATCH 3/6] Handle null remoteName in RefSpecPanel better Marek Zawirski
2008-08-27 18:41       ` [EGIT PATCH 4/6] Add tag fetching strategy selection to fetch version of RefSpecPage Marek Zawirski
2008-08-27 18:41         ` [EGIT PATCH 5/6] Rename ResultDialog to PushResultDialog Marek Zawirski
2008-08-27 18:41           ` [EGIT PATCH 6/6] Fetch GUI Marek Zawirski
2008-08-27 19:48 ` [EGIT PATCH 0/6] Fetch UI, minor improvements/fixes Robin Rosenberg
2008-08-27 20:09   ` Marek Zawirski
2008-08-27 21:51     ` Shawn O. Pearce

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).