Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas FAUVERGUE2016-02-11 15:08:36 +0000
committerGerrit Code Review @ Eclipse.org2016-02-24 15:31:08 +0000
commit2f0dd86c51f8543f56a99cd4371965a01287fcaa (patch)
tree8255f00b8202347c0f0fbb64a09df5b27668c352 /plugins/infra
parent3dec4967ac2a6fcfb71f059bf7e347091b81df89 (diff)
downloadorg.eclipse.papyrus-2f0dd86c51f8543f56a99cd4371965a01287fcaa.tar.gz
org.eclipse.papyrus-2f0dd86c51f8543f56a99cd4371965a01287fcaa.tar.xz
org.eclipse.papyrus-2f0dd86c51f8543f56a99cd4371965a01287fcaa.zip
Bug 481835: [Table] java.lang.IndexOutOfBoundsException: Index: 0, Size:
0 with UMLReferenceTextWithCompletionCellEditor https://bugs.eclipse.org/bugs/show_bug.cgi?id=481835 If the object to edit has a same namespace and shortest qualified name, use the simple reference selection dialog instead of text completion. It is possible to choose class with same name by the xtext (and the completion (which displayed all objects names)) and the element choose is the first. Change-Id: I35e31fc6612cef5e7827638315d33d23da5e2763 Signed-off-by: Nicolas FAUVERGUE <nicolas.fauvergue@all4tec.net>
Diffstat (limited to 'plugins/infra')
-rwxr-xr-xplugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/converter/StringResolutionProblemPapyrusConverter.java21
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringEditorWithCompletionWrapper.java10
-rw-r--r--plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/util/INameResolutionHelper.java28
3 files changed, 48 insertions, 11 deletions
diff --git a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/converter/StringResolutionProblemPapyrusConverter.java b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/converter/StringResolutionProblemPapyrusConverter.java
index fbd4d18250f..48d9347a015 100755
--- a/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/converter/StringResolutionProblemPapyrusConverter.java
+++ b/plugins/infra/nattable/org.eclipse.papyrus.infra.nattable/src/org/eclipse/papyrus/infra/nattable/converter/StringResolutionProblemPapyrusConverter.java
@@ -63,13 +63,24 @@ public class StringResolutionProblemPapyrusConverter implements IPapyrusConverte
}
/**
+ * {@inheritDoc}
+ *
* @see org.eclipse.papyrus.infra.widgets.util.INameResolutionHelper#getShortestQualifiedNames(java.lang.Object)
- *
- * @param element
- * @return
+ * @deprecated since 1.2.0
+ */
+ @Override
+ public List<String> getShortestQualifiedNames(final Object element) {
+ return getShortestQualifiedNames(element, true);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.papyrus.infra.widgets.util.INameResolutionHelper#getShortestQualifiedNames(java.lang.Object, boolean)
*/
- public List<String> getShortestQualifiedNames(Object element) {
- return wrappedDisplayConverter.getShortestQualifiedNames(element);
+ @Override
+ public List<String> getShortestQualifiedNames(final Object element, final boolean manageDuplicate) {
+ return wrappedDisplayConverter.getShortestQualifiedNames(element, manageDuplicate);
}
/**
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringEditorWithCompletionWrapper.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringEditorWithCompletionWrapper.java
index 7de49d963cc..98d34d0acd5 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringEditorWithCompletionWrapper.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/StringEditorWithCompletionWrapper.java
@@ -20,6 +20,7 @@ import org.eclipse.jface.text.contentassist.ContentAssistEvent;
import org.eclipse.jface.text.contentassist.ContentAssistant;
import org.eclipse.jface.text.contentassist.ICompletionListener;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposalSorter;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.papyrus.infra.widgets.util.IPapyrusConverter;
import org.eclipse.papyrus.infra.widgets.util.ISetPapyrusConverter;
@@ -144,6 +145,15 @@ public class StringEditorWithCompletionWrapper implements ISetPapyrusConverter{
assistant.setContentAssistProcessor(this.processor, IDocument.DEFAULT_CONTENT_TYPE);
}
+ // Manage the sorter for the completion proposal
+ assistant.setSorter(new ICompletionProposalSorter() {
+
+ @Override
+ public int compare(final ICompletionProposal p1, final ICompletionProposal p2) {
+ return p1.getDisplayString().compareTo(p2.getDisplayString());
+ }
+ });
+
assistant.install(textViewer);
assistant.addCompletionListener(new ICompletionListener() {
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/util/INameResolutionHelper.java b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/util/INameResolutionHelper.java
index 727c9c6b46e..cadecebe16f 100644
--- a/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/util/INameResolutionHelper.java
+++ b/plugins/infra/ui/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/util/INameResolutionHelper.java
@@ -20,13 +20,13 @@ import java.util.List;
*
*/
public interface INameResolutionHelper {
-
+
/**
*
* @param aString
* a string
* @return
- * all elements whose the name starts with this string, or all found element if the string is <code>null</code> or empty
+ * all elements whose the name starts with this string, or all found element if the string is <code>null</code> or empty
*/
public List<?> getMatchingElements(final String aString);
@@ -35,16 +35,32 @@ public interface INameResolutionHelper {
* @param aString
* a string
* @return
- * all elements which have the wanted string as (qualified) name
+ * all elements which have the wanted string as (qualified) name
*/
public List<?> getElementsByName(final String aString);
/**
- * @param namedElement
+ * Get the shortest qualified name.
+ *
+ * @param element
+ * The element to get the shortest qualified name.
* @return
- * the shortest qualified to use for the element
+ * the shortest qualified to use for the element
+ * @deprecated since 1.2.0
+ */
+ @Deprecated
+ public List<String> getShortestQualifiedNames(final Object element);
+
+ /**
+ * Get the shortest qualified name.
+ *
+ * @param element
+ * The element to get the shortest qualified name.
+ * @param manageDuplicate
+ * Boolean to determinate if the duplicated shortest qualified names must be remove from the returned list.
+ * @return the shortest qualified to use for the element
*/
- public List<String> getShortestQualifiedNames(Object element);
+ public List<String> getShortestQualifiedNames(final Object element, final boolean manageDuplicate);
}

Back to the top