| /******************************************************************************* |
| * Copyright (c) 2009, 2012 Sierra Wireless and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Sierra Wireless - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.ldt.ui.internal.editor.templates; |
| |
| import org.eclipse.dltk.core.DLTKLanguageManager; |
| import org.eclipse.dltk.core.IDLTKLanguageToolkit; |
| import org.eclipse.dltk.internal.ui.editor.ScriptEditor; |
| import org.eclipse.dltk.ui.DLTKUIPlugin; |
| import org.eclipse.dltk.ui.templates.ScriptTemplateAccess; |
| import org.eclipse.dltk.ui.templates.ScriptTemplateCompletionProcessor; |
| import org.eclipse.dltk.ui.text.completion.ScriptContentAssistInvocationContext; |
| import org.eclipse.jface.text.IInformationControlCreator; |
| import org.eclipse.jface.window.Window; |
| import org.eclipse.ui.IEditorPart; |
| import org.eclipse.ui.part.IWorkbenchPartOrientation; |
| |
| /** |
| * |
| * @author Kevin KIN-FOO <kkinfoo@sierrawireless.com> |
| * |
| */ |
| public class LuaTemplateCompletionProcessor extends ScriptTemplateCompletionProcessor { |
| |
| private static final char[] IGNORE = { '.', ':' }; |
| |
| public LuaTemplateCompletionProcessor(ScriptContentAssistInvocationContext context) { |
| super(context); |
| } |
| |
| @Override |
| protected String getContextTypeId() { |
| return LuaUniversalTemplateContextType.CONTEXT_TYPE_ID; |
| } |
| |
| protected char[] getIgnore() { |
| return IGNORE; |
| } |
| |
| @Override |
| protected ScriptTemplateAccess getTemplateAccess() { |
| return LuaTemplateAccess.getInstance(); |
| } |
| |
| /** |
| * Copy of super method, but returning a custom TemplateInformationControlCreator |
| */ |
| @Override |
| protected IInformationControlCreator getInformationControlCreator() { |
| int orientation = Window.getDefaultOrientation(); |
| IEditorPart editor = getContext().getEditor(); |
| if (editor == null) |
| editor = DLTKUIPlugin.getActivePage().getActiveEditor(); |
| if (editor instanceof IWorkbenchPartOrientation) |
| orientation = ((IWorkbenchPartOrientation) editor).getOrientation(); |
| IDLTKLanguageToolkit toolkit = null; |
| toolkit = DLTKLanguageManager.getLanguageToolkit(getContext().getLanguageNatureID()); |
| if ((toolkit == null) && (editor instanceof ScriptEditor)) |
| toolkit = ((ScriptEditor) editor).getLanguageToolkit(); |
| return new LuaTemplateInformationControlCreator(orientation, toolkit); |
| } |
| |
| } |