[EGIT PATCH 1/6] Reduce PushOperationResult contructor visibility, accept null instead

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 .../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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux