[CONTENTASSIST] Added another auto activation trigger types tizen_studio
authorYoonKi Park <yoonki.park@samsung.com>
Thu, 10 Nov 2016 08:08:55 +0000 (17:08 +0900)
committerYoonKi Park <yoonki.park@samsung.com>
Thu, 10 Nov 2016 11:13:23 +0000 (20:13 +0900)
- Auto-activation is triggered when characters are inserted from preference

Change-Id: Ic632a80afc00db4ecdcc5fa18d0c9d8bdf375908
Signed-off-by: YoonKi Park <yoonki.park@samsung.com>
core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage.java
core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.java
core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PreferencesMessages.properties
core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java
core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistPreference.java

index 0da9965..747ee1c 100644 (file)
  *     Jens Elmenthaler - http://bugs.eclipse.org/173458 (camel case completion)
  *     Thomas Corbat
  *******************************************************************************/
-
+/*
+ * 2016-11-10 yoonki.park@samsung.com
+ * Modifications by S-Core Co., Ltd.
+ * 1. Added text control to auto-activation group
+ */
 package org.eclipse.cdt.internal.ui.preferences;
 
 import java.util.ArrayList;
 
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.PlatformUI;
 
@@ -57,6 +65,10 @@ public class CodeAssistPreferencePage extends AbstractPreferencePage {
                overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW));
                overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON));
                overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW));
+               /* Tizen */
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_AS_TYPES));
+               overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_AS_TYPES_ENABLE));
+               /* ===== */
                overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.DEFAULT_ARGUMENT_DISPLAY_PARAMETERS_WITH_DEFAULT_ARGUMENT));
                overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.DEFAULT_ARGUMENT_DISPLAY_ARGUMENTS));
 //             overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.SHOW_DOCUMENTED_PROPOSALS));
@@ -135,13 +147,13 @@ public class CodeAssistPreferencePage extends AbstractPreferencePage {
                //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
                // The following items are grouped for Auto Activation
                label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationGroupTitle; 
+               /* Tizen */
                Group enableGroup = addGroupBox(contentAssistComposite, label, 2);
-               
+               /* ===== */
                label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationEnableDot; 
                addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOT, 0);
 
                label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationEnableArrow; 
-               addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW, 0);
                
                label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationEnableDoubleColon; 
                addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON, 0);
@@ -149,6 +161,32 @@ public class CodeAssistPreferencePage extends AbstractPreferencePage {
                label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationEnableReplaceDotWithArrow;
                addCheckBox(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW, 0);
 
+               /* Tizen */
+               label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationEnableAsTypes;
+               Composite comp = new Composite(enableGroup, SWT.NONE);
+               GridLayout gridLayout = new GridLayout(3, false);
+               gridLayout.marginWidth = 0;
+               gridLayout.marginHeight = 0;
+               comp.setLayout(gridLayout);
+               GridData gd = new GridData(GridData.FILL_BOTH);
+               gd.horizontalSpan = 3;
+               comp.setLayoutData(gd);
+               final Button btn = addCheckBox(comp, label, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_AS_TYPES_ENABLE, 0);
+               final Text textControl = addTextField(comp, ContentAssistPreference.AUTOACTIVATION_TRIGGERS_AS_TYPES, 30, 0);
+               textControl.setEnabled(fOverlayStore.getBoolean(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_AS_TYPES_ENABLE));
+
+               btn.addSelectionListener(new SelectionListener() {
+
+                       @Override
+                       public void widgetDefaultSelected(SelectionEvent arg0) {
+                               textControl.setEnabled(btn.getSelection());
+                       }
+
+                       @Override
+                       public void widgetSelected(SelectionEvent arg0) {
+                               textControl.setEnabled(btn.getSelection());
+                       }});
+               /* ===== */
                label = PreferencesMessages.CEditorPreferencePage_ContentAssistPage_autoActivationDelay; 
                addTextField(enableGroup, label, ContentAssistPreference.AUTOACTIVATION_DELAY, 4, 0, true);
 
@@ -173,6 +211,20 @@ public class CodeAssistPreferencePage extends AbstractPreferencePage {
                return contentAssistComposite;
        }
 
+       /* Tizen */
+       protected Text addTextField(Composite composite, String key, int textLimit, int indentation) {
+               Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
+               GridData gd = new GridData();
+               gd.grabExcessHorizontalSpace = true;
+               gd.horizontalIndent = indentation;
+               gd.widthHint = convertWidthInCharsToPixels(textLimit - 10);
+               textControl.setLayoutData(gd);
+               textControl.setTextLimit(textLimit);
+               fTextFields.put(textControl, key);
+
+               return textControl;
+       }
+       /* ===== */
        /* (non-Javadoc)
         * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
         */
@@ -189,6 +241,9 @@ public class CodeAssistPreferencePage extends AbstractPreferencePage {
                store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_ARROW, true);
                store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_DOUBLECOLON, true);
                store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW, true);
+               /* Tizen */
+               store.setDefault(ContentAssistPreference.AUTOACTIVATION_TRIGGERS_AS_TYPES_ENABLE, true);
+               /* ===== */
                store.setDefault(ContentAssistPreference.AUTOACTIVATION_DELAY, 500);
                store.setDefault(ContentAssistPreference.DEFAULT_ARGUMENT_DISPLAY_PARAMETERS_WITH_DEFAULT_ARGUMENT, true);
                store.setDefault(ContentAssistPreference.DEFAULT_ARGUMENT_DISPLAY_ARGUMENTS, true);
index 1664bbd..80da9a4 100644 (file)
@@ -49,6 +49,8 @@ public final class PreferencesMessages extends NLS {
        public static String CEditorPreferencePage_ContentAssistPage_autoActivationEnableArrow;
        public static String CEditorPreferencePage_ContentAssistPage_autoActivationEnableDoubleColon;
        public static String CEditorPreferencePage_ContentAssistPage_autoActivationEnableReplaceDotWithArrow;
+       /// Tizen
+       public static String CEditorPreferencePage_ContentAssistPage_autoActivationEnableAsTypes;
        public static String CEditorPreferencePage_ContentAssistPage_autoActivationDelay;
        public static String CEditorPreferencePage_ContentAssistPage_defaultArgumentsGroupTitle;
        public static String CEditorPreferencePage_ContentAssistPage_displayParametersWithDefaultArgument;
index a9209d3..f618761 100644 (file)
@@ -34,7 +34,9 @@ CEditorPreferencePage_ContentAssistPage_autoActivationGroupTitle=Auto-Activation
 CEditorPreferencePage_ContentAssistPage_autoActivationEnableDot=Enable "." as &trigger
 CEditorPreferencePage_ContentAssistPage_autoActivationEnableArrow=Enable "->" as tri&gger
 CEditorPreferencePage_ContentAssistPage_autoActivationEnableDoubleColon=Enable "::" as trigg&er
+### Tizen
 CEditorPreferencePage_ContentAssistPage_autoActivationEnableReplaceDotWithArrow=Enable aut&o-replace of '.' with '->' for pointer types
+CEditorPreferencePage_ContentAssistPage_autoActivationEnableAsTypes=Prompt when these characters are inserted:
 CEditorPreferencePage_ContentAssistPage_autoActivationDelay=Dela&y (ms)
 CEditorPreferencePage_ContentAssistPage_proposalFilterSelect=Completion Proposal Filter:
 CEditorPreferencePage_ContentAssistPage_completionProposalBackgroundColor=Completion proposal background
index ad6df3d..44c5acf 100644 (file)
  *     Markus Schorn (Wind River Systems)
  *     Kirk Beitz (Nokia)
  *******************************************************************************/
+/*
+ * 2016-11-10 yoonki.park@samsung.com
+ * Modifications by S-Core Co., Ltd.
+ * 1. Added another auto activation trigger types
+ */
 package org.eclipse.cdt.internal.ui.text.contentassist;
 
 import java.util.ArrayList;
@@ -355,6 +360,10 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
                                        return false;
                                }
                                return true;
+                       /* === Tizen === */
+                       default:
+                               return true;
+                       /* ==== */
                        }
                } catch (BadLocationException e) {
                }
index 257486d..d9777ad 100644 (file)
  *     Kirk Beitz (Nokia)
  *     Thomas Corbat (IFS)
  *******************************************************************************/
+/*
+ * 2016-11-10 yoonki.park@samsung.com
+ * Modifications by S-Core Co., Ltd.
+ * 1. Added another auto activation trigger types
+ */
 package org.eclipse.cdt.internal.ui.text.contentassist;
 
 import org.eclipse.jface.preference.IPreferenceStore;
@@ -61,6 +66,11 @@ public class ContentAssistPreference {
        public final static String AUTOACTIVATION_TRIGGERS_ARROW= "content_assist_autoactivation_trigger_arrow"; //$NON-NLS-1$
        public final static String AUTOACTIVATION_TRIGGERS_DOUBLECOLON= "content_assist_autoactivation_trigger_doublecolon"; //$NON-NLS-1$
        public final static String AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW= "content_assist_autoactivation_trigger_replace_dot_with_arrow"; //$NON-NLS-1$
+       /* Tizen */
+       public final static String AUTOACTIVATION_TRIGGERS_AS_TYPES = "content_assist_autoactivation_trigger_as_types"; //$NON-NLS-1$
+       public final static String AUTOACTIVATION_TRIGGERS_AS_TYPES_ENABLE = "content_assist_autoactivation_trigger_as_types_enabled"; //$NON-NLS-1$
+       public final static String AUTOACTIVATION_TRIGGERS_AS_TYPES_DEFAULT = "_abcdefghighklmnopqrstuvwxyzABCDEFGHIGHKLMNOPQRSTUVWXYZ";
+       /* ===== */
        /** Preference key for display of defaulted parameters in content assist  */
        public final static String DEFAULT_ARGUMENT_DISPLAY_PARAMETERS_WITH_DEFAULT_ARGUMENT = "content_assist_default_argument_display_parameters_with_default_argument"; //$NON-NLS-1$
        /** Preference key for display of default arguments in content assist  */
@@ -125,6 +135,9 @@ public class ContentAssistPreference {
                boolean useDotAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOT);
                boolean useArrowAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
                boolean useDoubleColonAsTrigger = store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
+               /* Tizen */
+               boolean triggerCharsEnabled = store.getBoolean(AUTOACTIVATION_TRIGGERS_AS_TYPES_ENABLE);
+               String triggerChars = store.getString(AUTOACTIVATION_TRIGGERS_AS_TYPES);
 
                if (useDotAsTrigger)
                        triggers = "."; //$NON-NLS-1$
@@ -132,6 +145,14 @@ public class ContentAssistPreference {
                        triggers += ">"; //$NON-NLS-1$
                if (useDoubleColonAsTrigger)
                        triggers += ":"; //$NON-NLS-1$
+               /* Tizen */
+               if (triggerCharsEnabled) {
+                       triggers += AUTOACTIVATION_TRIGGERS_AS_TYPES_DEFAULT;
+                       if (!triggerChars.isEmpty()) {
+                               triggers += triggerChars;
+                       }
+               }
+               /* ===== */
                ccp.setCContentAutoActivationCharacters(triggers);
 
                boolean dotTriggersAutoReplace = store.getBoolean(AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW);
@@ -164,10 +185,12 @@ public class ContentAssistPreference {
                boolean enabledDoubleColon= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
                boolean enabledReplaceDotWithArrow
                        = store.getBoolean(AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW);
+               /// Tizen
+               boolean enabledTyped = store.getBoolean(AUTOACTIVATION_TRIGGERS_AS_TYPES);
 
                boolean enabled
                        =  (enabledDot || enabledArrow || enabledDoubleColon
-                                       || enabledReplaceDotWithArrow);
+                                       || enabledReplaceDotWithArrow || enabledTyped);
                assistant.enableAutoActivation(enabled);
                
                int delay= store.getInt(AUTOACTIVATION_DELAY);
@@ -201,11 +224,12 @@ public class ContentAssistPreference {
                CContentAssistProcessor ccp= getCProcessor(assistant);
                if (ccp == null)
                        return;
-                       
+               /// Tizen
                if ( (AUTOACTIVATION_TRIGGERS_DOT.equals(key))
                     || (AUTOACTIVATION_TRIGGERS_ARROW.equals(key))
                         || (AUTOACTIVATION_TRIGGERS_DOUBLECOLON.equals(key)) 
-                        || (AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW.equals(key))){
+                        || (AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW.equals(key))
+                        || (AUTOACTIVATION_TRIGGERS_AS_TYPES_ENABLE.equals(key))) {
                        configureActivationCharacters(store, ccp);
                }
 //             else if (SHOW_DOCUMENTED_PROPOSALS.equals(key)) {
@@ -241,7 +265,9 @@ public class ContentAssistPreference {
                        boolean enabledArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_ARROW);
                        boolean enabledDoubleColon= store.getBoolean(AUTOACTIVATION_TRIGGERS_DOUBLECOLON);
                        boolean enabledReplaceDotWithArrow= store.getBoolean(AUTOACTIVATION_TRIGGERS_REPLACE_DOT_WITH_ARROW);
-                       boolean enabled =  ((enabledDot) || ( enabledArrow ) || (enabledDoubleColon ) || (enabledReplaceDotWithArrow ));
+                       /// Tizen
+                       boolean enabledAlways = store.getBoolean(AUTOACTIVATION_TRIGGERS_AS_TYPES);
+                       boolean enabled =  ((enabledDot) || ( enabledArrow ) || (enabledDoubleColon ) || (enabledReplaceDotWithArrow )) || (enabledAlways);
                        assistant.enableAutoActivation(enabled);
 
                } else if (AUTOACTIVATION_DELAY.equals(p)) {