Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2018-05-27 17:02:43 -0400
committerThomas Wolf2018-05-28 09:00:47 -0400
commitf8d69ebbfa7788f2e0b8ed416dac128aec3ed9dd (patch)
tree47bc9b8f9624416070cb1f8b8d4e433dd301ddbe /org.eclipse.egit.ui/src/org
parent636918dd9989392d7e7a287d30c387fc03069bcc (diff)
downloadegit-f8d69ebbfa7788f2e0b8ed416dac128aec3ed9dd.tar.gz
egit-f8d69ebbfa7788f2e0b8ed416dac128aec3ed9dd.tar.xz
egit-f8d69ebbfa7788f2e0b8ed416dac128aec3ed9dd.zip
FetchGerritChangePage: automatic content-assist on paste
If paste replaces the whole refText but we don't have a complete change number/patch set number combo, then automatically trigger content assist. Bug: 535171 Change-Id: I462c55e7510e9f2db866211017487d0bd01a35fc Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui/src/org')
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/fetch/FetchGerritChangePage.java33
1 files changed, 28 insertions, 5 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 f2a27737a..e301d0bc4 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
@@ -435,7 +435,15 @@ public class FetchGerritChangePage extends WizardPage {
UIText.FetchGerritChangePage_ActivateAdditionalRefsTooltip);
ActionUtils.setGlobalActions(refText, ActionUtils.createGlobalAction(
- ActionFactory.PASTE, () -> doPaste(refText)));
+ ActionFactory.PASTE, () -> {
+ if (doPaste(refText) && contentProposer != null) {
+ refText.getDisplay().asyncExec(() -> {
+ if (!refText.isDisposed()) {
+ contentProposer.openProposalPopup();
+ }
+ });
+ }
+ }));
refText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
@@ -612,7 +620,17 @@ public class FetchGerritChangePage extends WizardPage {
return null;
}
- private void doPaste(Text text) {
+ /**
+ * Paste text from the clipboard into the {@code text} field. If possible,
+ * determine the patch set number automatically. If only a change number can
+ * be determined, return {@code true} to indicate to the caller that a
+ * content assist might be helpful.
+ *
+ * @param text
+ * {@link Text} field to paste into
+ * @return whether invoking a content assist might be helpful to the user
+ */
+ private boolean doPaste(Text text) {
Clipboard clipboard = new Clipboard(text.getDisplay());
try {
String clipText = (String) clipboard
@@ -622,15 +640,18 @@ public class FetchGerritChangePage extends WizardPage {
clipText.trim());
if (input != null) {
String toInsert = input.getChangeNumber().toString();
+ boolean replacesEverything = text.getText().trim().isEmpty()
+ || text.getSelectionText().equals(text.getText());
+ boolean openContentAssist = false;
if (input.getPatchSetNumber() != null) {
- if (text.getText().trim().isEmpty() || text
- .getSelectionText().equals(text.getText())) {
- // Paste will replace everything
+ if (replacesEverything) {
toInsert = input.getRefName();
} else {
toInsert = toInsert + '/'
+ input.getPatchSetNumber();
}
+ } else {
+ openContentAssist = replacesEverything;
}
clipboard.setContents(new Object[] { toInsert },
new Transfer[] { TextTransfer.getInstance() });
@@ -640,6 +661,7 @@ public class FetchGerritChangePage extends WizardPage {
clipboard.setContents(new Object[] { clipText },
new Transfer[] { TextTransfer.getInstance() });
}
+ return openContentAssist;
} else {
text.paste();
}
@@ -647,6 +669,7 @@ public class FetchGerritChangePage extends WizardPage {
} finally {
clipboard.dispose();
}
+ return false;
}
private void storeLastUsedUri(String uri) {

Back to the top