From ccd2087f6b000a771e82c28002ad6fcb4a2930f1 Mon Sep 17 00:00:00 2001 From: Thomas Wolf Date: Tue, 7 Jun 2016 22:17:33 +0200 Subject: [PATCH] Paste in repo view need not log error The PasteCommand shows an alert to the user _and_ logs an error. That's overkill here. Just showing an alert is good enough. Besides, it's not really an error. Even better would be to deactivate the handler when the clipboard doesn't contain a git repo location. But I suspect a property tester for this would be rather expensive, so I opted for this simpler solution. Also add a missing clipboard.dispose() in the FetchGerritChangePage. Bug: 495629 Change-Id: I8d0dbf14ad168e38fe722827a67fcd58ef9f4cf8 Signed-off-by: Thomas Wolf --- .../ui/internal/fetch/FetchGerritChangePage.java | 1 + .../repository/tree/command/PasteCommand.java | 24 ++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangePage.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangePage.java index b16306d24..34b131c14 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangePage.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangePage.java @@ -185,6 +185,7 @@ public class FetchGerritChangePage extends WizardPage { Clipboard clipboard = new Clipboard(parent.getDisplay()); String clipText = (String) clipboard.getContents(TextTransfer .getInstance()); + clipboard.dispose(); String defaultUri = null; String defaultCommand = null; String defaultChange = null; diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PasteCommand.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PasteCommand.java index 5d396adca..f44580db7 100644 --- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PasteCommand.java +++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/command/PasteCommand.java @@ -91,23 +91,26 @@ public class PasteCommand extends if (util.addConfiguredRepository(file)) { // let's do the auto-refresh the rest - } else + } else { errorMessage = NLS.bind( UIText.RepositoriesView_PasteRepoAlreadyThere, content); - + } return null; } finally { - if (clip != null) + if (clip != null) { // we must dispose ourselves clip.dispose(); - if (errorMessage != null) - Activator.handleError(errorMessage, null, true); + } + if (errorMessage != null) { + Activator.showError(errorMessage, null); + } } } private URIish getCloneURI(String content) { - if (content.startsWith("git clone")) //$NON-NLS-1$ + if (content.startsWith("git clone")) { //$NON-NLS-1$ content = content.substring("git clone".length()); //$NON-NLS-1$ + } URIish finalURI; try { finalURI = new URIish(content.trim()); @@ -115,13 +118,12 @@ public class PasteCommand extends || Protocol.GIT.handles(finalURI) || Protocol.HTTP.handles(finalURI) || Protocol.HTTPS.handles(finalURI) - || Protocol.SSH.handles(finalURI)) + || Protocol.SSH.handles(finalURI)) { return finalURI; - else - return null; + } } catch (URISyntaxException e) { - Activator.handleError(e.getLocalizedMessage(), e, true); - return null; + // Swallow, caller will show an error message when we return null } + return null; } } -- 2.11.4.GIT