aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Baumgart2010-08-30 10:59:21 (EDT)
committerChris Aniszczyk2010-08-30 16:50:03 (EDT)
commit898dcebccec88f896e0265d70243e7f8adfbca8a (patch)
tree0d9d71edc2cf4d732f539bbaa7aca21846b0217c
parent3fcca7e07e5e9657473ee4cc0ba2ee2a550833ee (diff)
downloadegit-898dcebccec88f896e0265d70243e7f8adfbca8a.zip
egit-898dcebccec88f896e0265d70243e7f8adfbca8a.tar.gz
egit-898dcebccec88f896e0265d70243e7f8adfbca8a.tar.bz2
Display details of push resultrefs/changes/56/1456/4
PushResultTable was enhanced to show the details of a push result. Error messages and the information returned by the push operation (e.g. the gerrit review URL) are shown in a separate text control. The colors of the result status (green, red) were replaced by an icon. Bug: 319974 Change-Id: I4000c80b8a3365dea3b4b6977f3e03271e634154 Signed-off-by: Jens Baumgart <jens.baumgart@sap.com> Signed-off-by: Chris Aniszczyk <caniszczyk@gmail.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java3
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushResultTable.java119
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/RefUpdateElement.java4
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties1
4 files changed, 103 insertions, 24 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
index 99439ac..aaa2e71 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/UIText.java
@@ -1495,6 +1495,9 @@ public class UIText extends NLS {
public static String PushResultTable_refNonExisting;
/** */
+ public static String PushResultTable_repository;
+
+ /** */
public static String PushResultTable_statusDetailDeleted;
/** */
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushResultTable.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushResultTable.java
index 54df1de..267b432 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushResultTable.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/PushResultTable.java
@@ -10,7 +10,9 @@ package org.eclipse.egit.ui.internal.push;
import java.io.IOException;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
+import java.util.Set;
import org.eclipse.egit.core.op.PushOperationResult;
import org.eclipse.egit.ui.UIIcons;
@@ -22,6 +24,11 @@ import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ColumnViewerToolTipSupport;
import org.eclipse.jface.viewers.ColumnWeightData;
import org.eclipse.jface.viewers.IElementComparer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jgit.lib.Constants;
@@ -30,13 +37,12 @@ import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.transport.RemoteRefUpdate;
-import org.eclipse.jgit.transport.URIish;
import org.eclipse.jgit.transport.RemoteRefUpdate.Status;
+import org.eclipse.jgit.transport.URIish;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -44,6 +50,7 @@ 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.eclipse.swt.widgets.Text;
/**
* Table displaying push operation results.
@@ -53,6 +60,8 @@ class PushResultTable {
private static final int TABLE_PREFERRED_HEIGHT = 300;
+ private static final int TEXT_PREFERRED_HEIGHT = 100;
+
private static final int COLUMN_STATUS_WEIGHT = 40;
private static final int COLUMN_DST_WEIGHT = 40;
@@ -65,18 +74,16 @@ class PushResultTable {
private static final String IMAGE_ADD = "MODE_ADD"; //$NON-NLS-1$
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+
+ private static final String SPACE = " "; //$NON-NLS-1$
+
private final TableViewer tableViewer;
private final Composite tablePanel;
private final ImageRegistry imageRegistry;
- private final Color rejectedColor;
-
- private final Color updatedColor;
-
- private final Color upToDateColor;
-
private ObjectReader reader;
private Map<ObjectId, String> abbrevations;
@@ -97,19 +104,10 @@ class PushResultTable {
imageRegistry.put(IMAGE_ADD, UIIcons.ELCL16_ADD);
imageRegistry.put(IMAGE_DELETE, UIIcons.ELCL16_DELETE);
- rejectedColor = new Color(parent.getDisplay(), 255, 0, 0);
- updatedColor = new Color(parent.getDisplay(), 0, 255, 0);
- upToDateColor = new Color(parent.getDisplay(), 245, 245, 245);
-
tablePanel.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
if (reader != null)
reader.release();
-
- // dispose of our allocated Color instances
- rejectedColor.dispose();
- updatedColor.dispose();
- upToDateColor.dispose();
imageRegistry.dispose();
}
});
@@ -127,6 +125,74 @@ class PushResultTable {
});
tableViewer.setContentProvider(new RefUpdateContentProvider());
tableViewer.setInput(null);
+ // detail message
+ final Text text = new Text(parent, SWT.MULTI | SWT.READ_ONLY
+ | SWT.BORDER);
+ GridData textLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ textLayoutData.heightHint = TEXT_PREFERRED_HEIGHT;
+ text.setLayoutData(textLayoutData);
+ tableViewer
+ .addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ ISelection selection = event.getSelection();
+ if (!(selection instanceof IStructuredSelection)) {
+ text.setText(EMPTY_STRING);
+ return;
+ }
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ if (structuredSelection.size() != 1) {
+ text.setText(EMPTY_STRING);
+ return;
+ }
+ RefUpdateElement element = (RefUpdateElement) structuredSelection
+ .getFirstElement();
+ text.setText(getResult(element));
+ }
+ });
+ }
+
+ private String getResult(RefUpdateElement element) {
+ StringBuilder result = new StringBuilder(EMPTY_STRING);
+ PushOperationResult pushOperationResult = element
+ .getPushOperationResult();
+ Set<URIish> urIs = pushOperationResult.getURIs();
+ Iterator<URIish> iterator = urIs.iterator();
+ while(iterator.hasNext()) {
+ boolean lineBreakNeeded = false;
+ URIish uri = iterator.next();
+ result.append(UIText.PushResultTable_repository);
+ result.append(SPACE);
+ result.append(uri.toString());
+ result.append(Text.DELIMITER);
+ result.append(Text.DELIMITER);
+ String message = element.getRemoteRefUpdate(uri).getMessage();
+ if (message != null) {
+ result.append(message);
+ result.append(Text.DELIMITER);
+ lineBreakNeeded = true;
+ }
+ StringBuilder messagesBuffer = new StringBuilder(pushOperationResult
+ .getPushResult(uri).getMessages());
+ trim(messagesBuffer);
+ if (messagesBuffer.length()>0) {
+ result.append(messagesBuffer);
+ result.append(Text.DELIMITER);
+ lineBreakNeeded = true;
+ }
+ if (iterator.hasNext() && lineBreakNeeded)
+ result.append(Text.DELIMITER);
+ }
+ trim(result);
+ return result.toString();
+ }
+
+ private static void trim(StringBuilder s) {
+ // remove leading line breaks
+ while (s.length()>0 && (s.charAt(0)=='\n' || s.charAt(0)=='\r'))
+ s.deleteCharAt(0);
+ // remove trailing line breaks
+ while (s.length()>0 && (s.charAt(s.length()-1)=='\n' || s.charAt(s.length()-1)=='\r'))
+ s.deleteCharAt(s.length()-1);
}
void setData(final Repository localDb, final PushOperationResult result) {
@@ -189,11 +255,17 @@ class PushResultTable {
for (final URIish uri : result.getURIs()) {
final TableViewerColumn statusViewer = createColumn(layout, NLS
.bind(UIText.PushResultTable_columnStatusRepo, Integer
- .toString(++i)), COLUMN_STATUS_WEIGHT, SWT.CENTER);
+ .toString(++i)), COLUMN_STATUS_WEIGHT, SWT.LEFT);
statusViewer.getColumn().setToolTipText(uri.toString());
statusViewer.setLabelProvider(new UpdateStatusLabelProvider(uri));
}
tableViewer.setInput(result);
+ // select the first row of table to get the details of the first
+ // push result shown in the Text control
+ Table table = tableViewer.getTable();
+ if (table.getItemCount()>0) {
+ tableViewer.setSelection(new StructuredSelection(table.getItem(0).getData()));
+ }
tablePanel.layout();
}
@@ -272,23 +344,22 @@ class PushResultTable {
}
@Override
- public Color getBackground(Object element) {
+ public Image getImage(Object element) {
final RefUpdateElement rue = (RefUpdateElement) element;
if (!rue.isSuccessfulConnection(uri))
- return rejectedColor;
-
+ return imageRegistry.get(IMAGE_DELETE);
final Status status = rue.getRemoteRefUpdate(uri).getStatus();
switch (status) {
case OK:
- return updatedColor;
+ return null; // no icon for ok
case UP_TO_DATE:
case NON_EXISTING:
- return upToDateColor;
+ return null; // no icon for up to date
case REJECTED_NODELETE:
case REJECTED_NONFASTFORWARD:
case REJECTED_REMOTE_CHANGED:
case REJECTED_OTHER_REASON:
- return rejectedColor;
+ return imageRegistry.get(IMAGE_DELETE);
default:
throw new IllegalArgumentException(NLS.bind(
UIText.PushResultTable_statusUnexpected, status));
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/RefUpdateElement.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/RefUpdateElement.java
index cb993d3..c20d860 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/RefUpdateElement.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/push/RefUpdateElement.java
@@ -50,6 +50,10 @@ class RefUpdateElement {
return srcRefName == null;
}
+ PushOperationResult getPushOperationResult() {
+ return result;
+ }
+
boolean isSuccessfulConnection(final URIish uri) {
return result.isSuccessfulConnection(uri);
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
index 8a404bb..951f3c3 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/uitext.properties
@@ -506,6 +506,7 @@ PushResultTable_statusUnexpected=Unexpected update status: {0}
PushResultTable_statusConnectionFailed=[connection failed]
PushResultTable_statusDetailChanged=remote ref object changed,\nnow it's: {0},\nnot expected: {1}
PushResultTable_refNonExisting=(non existing)
+PushResultTable_repository=Repository
PushResultTable_statusDetailDeleted=old value: {0}
PushResultTable_statusDetailNonFastForward=non-fast forward
PushResultTable_statusDetailNoDelete=remote side does not support deleting refs