Bug 3018 - After adding a snippet the focus should be changed to the edit view
authorEugene Ostroukhov <eugeneo@symbian.org>
Wed, 16 Jun 2010 17:56:07 -0700
changeset 385 9bf326e3aeb9
parent 384 efc34c5e085b
child 386 7d0a718a6346
Bug 3018 - After adding a snippet the focus should be changed to the edit view
org.symbian.tools.wrttools/META-INF/MANIFEST.MF
org.symbian.tools.wrttools/plugin.xml
org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/SnippetInsertion.java
--- a/org.symbian.tools.wrttools/META-INF/MANIFEST.MF	Wed Jun 16 17:23:29 2010 -0700
+++ b/org.symbian.tools.wrttools/META-INF/MANIFEST.MF	Wed Jun 16 17:56:07 2010 -0700
@@ -27,7 +27,8 @@
  org.eclipse.wst.xml.ui;bundle-version="1.1.2",
  org.eclipse.ltk.core.refactoring,
  org.eclipse.ui.editors,
- org.eclipse.wst.common.snippets
+ org.eclipse.wst.common.snippets,
+ org.eclipse.jface.text;bundle-version="3.6.0"
 Bundle-RequiredExecutionEnvironment: J2SE-1.5,
  JavaSE-1.6
 Bundle-ActivationPolicy: lazy
--- a/org.symbian.tools.wrttools/plugin.xml	Wed Jun 16 17:23:29 2010 -0700
+++ b/org.symbian.tools.wrttools/plugin.xml	Wed Jun 16 17:56:07 2010 -0700
@@ -889,6 +889,7 @@
           smallicon="icons/main16.gif"
           contenttypes="org.eclipse.wst.jsdt.core.jsSource">
        <item
+             class="org.symbian.tools.wrttools.util.SnippetInsertion"
              description="Retrieves list of the contacts"
              id="org.symbian.tools.wrttools.contacts"
              label="Get contacts">
@@ -917,6 +918,7 @@
           </content>
        </item>
        <item
+             class="org.symbian.tools.wrttools.util.SnippetInsertion"
              description="Sends SMS message"
              id="org.symbian.tools.wrttools.contacts"
              label="Send SMS message">
@@ -933,6 +935,7 @@
           </content>
        </item>
        <item
+             class="org.symbian.tools.wrttools.util.SnippetInsertion"
              description="Adds callback that will be notified of orientation chnages"
              id="org.symbian.tools.wrttools.contacts"
              label="Register orientation callback">
@@ -962,6 +965,7 @@
          </content>
        </item>
        <item
+             class="org.symbian.tools.wrttools.util.SnippetInsertion"
              description="This function can be used as a callback in GetLocation and Trace calls to location service."
              id="org.symbian.tools.wrttools.location"
              label="Location callback">
@@ -994,6 +998,7 @@
 }          </content>
        </item>
        <item
+             class="org.symbian.tools.wrttools.util.SnippetInsertion"
              description="Function that processes notifications from the orientation sensor"
              id="org.symbian.tools.wrttools.contacts"
              label="Orientation callback">
@@ -1026,6 +1031,7 @@
           label="PhoneGap"
           smallicon="icons/phonegap.png">
        <item
+             class="org.symbian.tools.wrttools.util.SnippetInsertion"
              description="Accepts accerelometer data"
              id="org.symbian.tools.wrttools.phonegap.accererometer"
              label="Accelerometer callback">
@@ -1042,6 +1048,7 @@
           </content>
        </item>
        <item
+             class="org.symbian.tools.wrttools.util.SnippetInsertion"
              description="Accepts contacts data"
              id="org.symbian.tools.wrttools.phonegap.contacts"
              label="Contacts callback">
@@ -1061,6 +1068,7 @@
           </content>
        </item>
        <item
+             class="org.symbian.tools.wrttools.util.SnippetInsertion"
              description="Accepts location data"
              id="org.symbian.tools.wrttools.phonegap.location"
              label="Location callback">
@@ -1080,6 +1088,7 @@
           </content>
        </item>
        <item
+             class="org.symbian.tools.wrttools.util.SnippetInsertion"
              description="Accepts orientation data"
              id="org.symbian.tools.wrttools.phonegap.orientation"
              label="Orientation callback">
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/SnippetInsertion.java	Wed Jun 16 17:56:07 2010 -0700
@@ -0,0 +1,40 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
+package org.symbian.tools.wrttools.util;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.wst.common.snippets.ui.DefaultSnippetInsertion;
+
+public class SnippetInsertion extends DefaultSnippetInsertion {
+
+    @Override
+    protected void doInsert(final IEditorPart editorPart, ITextEditor textEditor, IDocument document,
+            ITextSelection textSelection) throws BadLocationException {
+        super.doInsert(editorPart, textEditor, document, textSelection);
+        editorPart.getSite().getShell().getDisplay().asyncExec(new Runnable() {
+            public void run() {
+                editorPart.setFocus();
+            }
+        });
+    }
+}