use of org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason in project egit by eclipse.
the class RevertFailureDialog method show.
/**
* Show dialog for failure result
*
* @param shell
* @param commit
* @param result
*/
public static void show(Shell shell, RevCommit commit, MergeResult result) {
String message;
Map<String, MergeFailureReason> reasons = result != null ? result.getFailingPaths() : null;
if (reasons != null && !reasons.isEmpty())
message = MessageFormat.format(UIText.RevertFailureDialog_Message, commit.abbreviate(7).name());
else
message = MessageFormat.format(UIText.RevertFailureDialog_MessageNoFiles, commit.abbreviate(7).name());
RevertFailureDialog dialog = new RevertFailureDialog(shell, message, reasons);
dialog.setShellStyle(dialog.getShellStyle() | SWT.SHEET | SWT.RESIZE);
dialog.open();
}
use of org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason in project egit by eclipse.
the class RevertFailureDialog method createCustomArea.
@Override
protected Control createCustomArea(Composite parent) {
if (reasons == null || reasons.isEmpty())
return null;
Composite fileArea = new Composite(parent, SWT.NONE);
GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 80).applyTo(fileArea);
GridLayoutFactory.fillDefaults().applyTo(fileArea);
TreeViewer viewer = new TreeViewer(fileArea);
viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl());
viewer.setContentProvider(new WorkbenchContentProvider() {
@Override
public Object[] getElements(Object element) {
return ((Collection) element).toArray();
}
});
final IStyledLabelProvider styleProvider = new WorkbenchStyledLabelProvider() {
@Override
public StyledString getStyledText(Object element) {
// supported
if (element instanceof RevertFailure)
return ((RevertFailure) element).getStyledText(element);
if (element instanceof Path)
return ((Path) element).getStyledText(element);
return super.getStyledText(element);
}
};
viewer.setLabelProvider(new DelegatingStyledCellLabelProvider(styleProvider));
viewer.setComparator(new ViewerComparator());
Map<MergeFailureReason, RevertFailure> failures = new HashMap<>();
for (Entry<String, MergeFailureReason> reason : reasons.entrySet()) {
RevertFailure failure = failures.get(reason.getValue());
if (failure == null) {
failure = new RevertFailure(reason.getValue());
failures.put(reason.getValue(), failure);
}
failure.add(reason.getKey());
}
viewer.setInput(failures.values());
return fileArea;
}
use of org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason in project egit by eclipse.
the class CherryPickHandler method getErrorList.
private IStatus getErrorList(Map<String, MergeFailureReason> failingPaths) {
MultiStatus result = new MultiStatus(Activator.getPluginId(), IStatus.ERROR, UIText.CherryPickHandler_CherryPickFailedMessage, null);
for (Entry<String, MergeFailureReason> entry : failingPaths.entrySet()) {
String path = entry.getKey();
String reason = getReason(entry.getValue());
String errorMessage = NLS.bind(UIText.CherryPickHandler_ErrorMsgTemplate, path, reason);
result.add(Activator.createErrorStatus(errorMessage));
}
return result;
}
use of org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason in project egit by eclipse.
the class MergeResultDialog method createDialogArea.
@Override
public Control createDialogArea(final Composite parent) {
final Composite composite = (Composite) super.createDialogArea(parent);
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
composite.setLayout(gridLayout);
// result
Label resultLabel = new Label(composite, SWT.NONE);
resultLabel.setText(UIText.MergeResultDialog_result);
resultLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
Text resultText = new Text(composite, SWT.READ_ONLY);
MergeStatus status = mergeResult.getMergeStatus();
resultText.setText(status.toString());
resultText.setSelection(resultText.getCaretPosition());
resultText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
if (status == MergeStatus.FAILED) {
resultText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_RED));
StringBuilder paths = new StringBuilder();
Label pathsLabel = new Label(composite, SWT.NONE);
pathsLabel.setText(UIText.MergeResultDialog_failed);
pathsLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
Text pathsText = new Text(composite, SWT.READ_ONLY);
pathsText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
Set<Entry<String, MergeFailureReason>> failedPaths = mergeResult.getFailingPaths().entrySet();
int n = 0;
for (Map.Entry<String, MergeFailureReason> e : failedPaths) {
if (n > 0)
paths.append(Text.DELIMITER);
paths.append(e.getValue());
// $NON-NLS-1$
paths.append("\t");
paths.append(e.getKey());
n++;
if (n > 10 && failedPaths.size() > 15)
break;
}
if (n < failedPaths.size()) {
paths.append(Text.DELIMITER);
paths.append(MessageFormat.format(UIText.MergeResultDialog_nMore, Integer.valueOf(n - failedPaths.size())));
}
pathsText.setText(paths.toString());
}
if (status == MergeStatus.FAST_FORWARD || status == MergeStatus.FAST_FORWARD_SQUASHED || status == MergeStatus.MERGED) {
// new head
Label newHeadLabel = new Label(composite, SWT.NONE);
newHeadLabel.setText(UIText.MergeResultDialog_newHead);
newHeadLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
Text newHeadText = new Text(composite, SWT.READ_ONLY);
ObjectId newHead = mergeResult.getNewHead();
if (newHead != null)
newHeadText.setText(getCommitMessage(newHead) + SPACE + abbreviate(mergeResult.getNewHead(), true));
newHeadText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
}
// Merge Input
Label mergeInputLabel = new Label(composite, SWT.NONE);
mergeInputLabel.setText(UIText.MergeResultDialog_mergeInput);
GridDataFactory.fillDefaults().align(SWT.LEAD, SWT.CENTER).span(2, 1).applyTo(mergeInputLabel);
TableViewer viewer = new TableViewer(composite);
viewer.setContentProvider(new IStructuredContentProvider() {
@Override
public void dispose() {
// empty
}
@Override
public void inputChanged(Viewer theViewer, Object oldInput, Object newInput) {
// empty
}
@Override
public Object[] getElements(Object inputElement) {
return getCommits(mergeResult.getMergedCommits());
}
});
final IStyledLabelProvider styleProvider = new IStyledLabelProvider() {
private final WorkbenchLabelProvider wrapped = new WorkbenchLabelProvider();
@Override
public void removeListener(ILabelProviderListener listener) {
// Empty
}
@Override
public boolean isLabelProperty(Object element, String property) {
return false;
}
@Override
public void dispose() {
wrapped.dispose();
}
@Override
public void addListener(ILabelProviderListener listener) {
// Empty
}
@Override
public StyledString getStyledText(Object element) {
// supported
if (element instanceof RepositoryCommit)
return ((RepositoryCommit) element).getStyledText(element);
return new StyledString(wrapped.getText(element));
}
@Override
public Image getImage(Object element) {
return wrapped.getImage(element);
}
};
viewer.setLabelProvider(new DelegatingStyledCellLabelProvider(styleProvider));
applyDialogFont(composite);
GridDataFactory.fillDefaults().grab(true, true).align(SWT.FILL, SWT.FILL).span(2, 1).applyTo(viewer.getControl());
viewer.setInput(mergeResult);
new OpenAndLinkWithEditorHelper(viewer) {
@Override
protected void linkToEditor(ISelection selection) {
// Not supported
}
@Override
protected void open(ISelection selection, boolean activate) {
handleOpen(selection, OpenStrategy.activateOnOpen());
}
@Override
protected void activate(ISelection selection) {
handleOpen(selection, true);
}
private void handleOpen(ISelection selection, boolean activateOnOpen) {
if (selection instanceof IStructuredSelection)
for (Object element : ((IStructuredSelection) selection).toArray()) if (element instanceof RepositoryCommit)
CommitEditor.openQuiet((RepositoryCommit) element, activateOnOpen);
}
};
return composite;
}
use of org.eclipse.jgit.merge.ResolveMerger.MergeFailureReason in project egit by eclipse.
the class RebaseResultDialog method createFailedOrConflictsParts.
/**
* Create the items in composite necessary for a rebase result
*
* @param composite
* @param result
*/
public static void createFailedOrConflictsParts(Composite composite, RebaseResult result) {
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
composite.setLayout(gridLayout);
// result
Label resultLabel = new Label(composite, SWT.NONE);
resultLabel.setText(UIText.MergeResultDialog_result);
resultLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
Text resultText = new Text(composite, SWT.READ_ONLY);
resultText.setText(getStatusText(result.getStatus()));
if (!result.getStatus().isSuccessful())
resultText.setForeground(composite.getParent().getDisplay().getSystemColor(SWT.COLOR_RED));
resultText.setSelection(resultText.getCaretPosition());
resultText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
if (result.getStatus() == Status.FAILED) {
StringBuilder paths = new StringBuilder();
Label pathsLabel = new Label(composite, SWT.NONE);
pathsLabel.setText(UIText.MergeResultDialog_failed);
pathsLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
Text pathsText = new Text(composite, SWT.READ_ONLY);
pathsText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
Set<Entry<String, MergeFailureReason>> failedPaths = result.getFailingPaths().entrySet();
int n = 0;
for (Map.Entry<String, MergeFailureReason> e : failedPaths) {
if (n > 0)
paths.append(Text.DELIMITER);
paths.append(e.getValue());
// $NON-NLS-1$
paths.append("\t");
paths.append(e.getKey());
n++;
if (n > 10 && failedPaths.size() > 15)
break;
}
if (n < failedPaths.size()) {
paths.append(Text.DELIMITER);
paths.append(MessageFormat.format(UIText.MergeResultDialog_nMore, Integer.valueOf(n - failedPaths.size())));
}
pathsText.setText(paths.toString());
} else if (result.getStatus() == Status.CONFLICTS) {
StringBuilder paths = new StringBuilder();
Label pathsLabel = new Label(composite, SWT.NONE);
pathsLabel.setText(UIText.MergeResultDialog_conflicts);
pathsLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
Text pathsText = new Text(composite, SWT.READ_ONLY);
pathsText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
List<String> conflList = result.getConflicts();
int n = 0;
for (String e : conflList) {
if (n > 0)
paths.append(Text.DELIMITER);
paths.append(e);
n++;
if (n > 10 && conflList.size() > 15)
break;
}
if (n < conflList.size()) {
paths.append(Text.DELIMITER);
paths.append(MessageFormat.format(UIText.MergeResultDialog_nMore, Integer.valueOf(n - conflList.size())));
}
pathsText.setText(paths.toString());
}
}
Aggregations