]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.ui/src/org/simantics/scl/ui/editor/completion/SCLCompletionProposal.java
Externalize strings in org.simantics.scl.ui
[simantics/platform.git] / bundles / org.simantics.scl.ui / src / org / simantics / scl / ui / editor / completion / SCLCompletionProposal.java
index 11749a4b2b24eef1c717eec74e9129731da58ce6..fb63c18e020a9adc33d5724f9a25f9cd65047df1 100644 (file)
@@ -23,10 +23,10 @@ import org.simantics.scl.ui.Activator;
 
 public class SCLCompletionProposal implements ICompletionProposal, ICompletionProposalExtension, ICompletionProposalExtension2, ICompletionProposalExtension3, ICompletionProposalExtension4, ICompletionProposalExtension5 {
     
-    private static final Image PRIVATE = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/private_co.gif").createImage();
-    private static final Image PUBLIC = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/public_co.gif").createImage();
-    private static final Image CONST = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/container_obj.gif").createImage();
-    private static final Image TYPE = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/typedef_obj.gif").createImage();
+    private static final Image PRIVATE = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/private_co.gif").createImage(); //$NON-NLS-1$ //$NON-NLS-2$
+    private static final Image PUBLIC = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/public_co.gif").createImage(); //$NON-NLS-1$ //$NON-NLS-2$
+    private static final Image CONST = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/container_obj.gif").createImage(); //$NON-NLS-1$ //$NON-NLS-2$
+    private static final Image TYPE = Activator.imageDescriptorFromPlugin("org.simantics.scl.ui", "icons/typedef_obj.gif").createImage(); //$NON-NLS-1$ //$NON-NLS-2$
     
     private final String content;
     private final String name;
@@ -41,13 +41,13 @@ public class SCLCompletionProposal implements ICompletionProposal, ICompletionPr
         String tempModule = value.getName().module;
         int p = tempName.lastIndexOf('.');
         if(p >= 0) {
-            tempModule = tempModule + "." + tempName.substring(0, p);
+            tempModule = tempModule + "." + tempName.substring(0, p); //$NON-NLS-1$
             tempName = tempName.substring(p+1);
         }
         this.name = tempName;
         this.module = tempModule;
         this.documentation = value.getDocumentation();
-        this.content = name + " :: " + value.getType() + "  (" + module + ")";
+        this.content = name + " :: " + value.getType() + "  (" + module + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         this.replacementOffset = replacementOffset;
         this.prefix = prefix;
 //        System.out.println(prefix);
@@ -60,7 +60,7 @@ public class SCLCompletionProposal implements ICompletionProposal, ICompletionPr
     public SCLCompletionProposal(String name, String module, SCLCompletionType completionType, int replacementOffset, String prefix) {
         this.name = name;
         this.module = module;
-        this.content = name + " (" + module + ")";
+        this.content = name + " (" + module + ")"; //$NON-NLS-1$ //$NON-NLS-2$
         this.documentation = null;
         this.replacementOffset = replacementOffset;
         this.prefix = prefix;
@@ -141,13 +141,13 @@ public class SCLCompletionProposal implements ICompletionProposal, ICompletionPr
 //            String sadd = doc.get(start, end);
 //            System.out.println("toReplace : " + sadd);
             if (p.y > 0) {
-                doc.replace(p.x, p.y, "");
+                doc.replace(p.x, p.y, ""); //$NON-NLS-1$
                 doc.replace(offset, 0, getName());
             } else {
                 String currentText = doc.get(offset - prefix.length(), prefix.length());
                 if (currentText.equals(getName()))
                     return;
-                doc.replace(offset - prefix.length(), prefix.length(), "");
+                doc.replace(offset - prefix.length(), prefix.length(), ""); //$NON-NLS-1$
                 doc.replace(offset - prefix.length(), 0, getName());
             }
         } catch (BadLocationException x) {
@@ -166,14 +166,15 @@ public class SCLCompletionProposal implements ICompletionProposal, ICompletionPr
     @Override
     public boolean validate(IDocument document, int offset, DocumentEvent event) {
         try {
-//            System.out.println("replacementOffset : " + replacementOffset);
-//            System.out.println("offset : " + offset);
+            String n = getName();
+            //System.out.println(n + " (" + n.length() + ") " + replacementOffset + " " + offset);
             boolean a = offset >= replacementOffset;
-            boolean b = offset < replacementOffset + getName().length();
+            boolean b = offset <= replacementOffset + n.length();
             String s = document.get(replacementOffset, offset - replacementOffset);
             prefix = s;
-            String d = getName();//.substring(0, offset - prefixStart);
-            boolean c = d.toLowerCase().startsWith(s.toLowerCase());
+            //System.out.println("prefix: " + s + " - " + prefix);
+            boolean c = n.toLowerCase().startsWith(s.toLowerCase());
+            //System.out.println("matches: " + a + " " + b + " " + c);
             return a && b && c;
         } catch (BadLocationException x) {
             //x.printStackTrace();