| /******************************************************************************* |
| * Copyright (c) 2010, 2013 E.D.Willink 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: |
| * E.D.Willink - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.ocl.examples.xtext.oclinecore.ui; |
| |
| import java.util.List; |
| |
| import org.eclipse.emf.common.EMFPlugin; |
| import org.eclipse.ocl.examples.xtext.oclinecore.ui.internal.OCLinEcoreActivator; |
| import org.eclipse.ocl.examples.xtext.oclinecore.ui.model.OCLinEcoreDocument; |
| import org.eclipse.ocl.examples.xtext.oclinecore.ui.model.OCLinEcoreDocumentProvider; |
| import org.eclipse.ui.plugin.AbstractUIPlugin; |
| import org.eclipse.xtext.AbstractElement; |
| import org.eclipse.xtext.ui.editor.IXtextEditorCallback; |
| import org.eclipse.xtext.ui.editor.contentassist.antlr.FollowElement; |
| import org.eclipse.xtext.ui.editor.contentassist.antlr.ParserBasedContentAssistContextFactory; |
| import org.eclipse.xtext.ui.editor.model.IResourceForEditorInputFactory; |
| import org.eclipse.xtext.ui.editor.model.XtextDocument; |
| import org.eclipse.xtext.ui.editor.model.XtextDocumentProvider; |
| |
| import com.google.common.collect.Multimap; |
| |
| /** |
| * Use this class to register components to be used within the IDE. |
| */ |
| public class OCLinEcoreUiModule extends org.eclipse.ocl.examples.xtext.oclinecore.ui.AbstractOCLinEcoreUiModule |
| { |
| public static final String PLUGIN_ID = "org.eclipse.ocl.examples.xtext.oclinecore.ui"; |
| public static final String EDITOR_ID = OCLinEcoreActivator.ORG_ECLIPSE_OCL_EXAMPLES_XTEXT_OCLINECORE_OCLINECORE; |
| |
| private static EMFPlugin.InternalHelper helper = new EMFPlugin.InternalHelper(OCLinEcoreActivator.getInstance()); |
| |
| /** |
| * Return the optionally translated value of a plugin.properties key. |
| */ |
| public static String getString(String key, boolean translate) { |
| return helper.getString(key, translate); |
| } |
| |
| /** |
| * Return the optionally translated value of a plugin.properties key with substitutions. |
| */ |
| public static String getString(String key, Object [] substitutions, boolean translate) { |
| return helper.getString(key, substitutions, translate); |
| } |
| |
| public OCLinEcoreUiModule(AbstractUIPlugin plugin) { |
| super(plugin); |
| } |
| |
| @Override |
| public Class<? extends XtextDocument> bindXtextDocument() { |
| return OCLinEcoreDocument.class; |
| } |
| |
| public Class<? extends XtextDocumentProvider> bindXtextDocumentProvider() { |
| return OCLinEcoreDocumentProvider.class; |
| } |
| |
| @Override |
| public Class<? extends IResourceForEditorInputFactory> bindIResourceForEditorInputFactory() { |
| return OCLinEcoreResourceForEditorInputFactory.class; |
| } |
| |
| @Override |
| public Class<? extends IXtextEditorCallback> bindIXtextEditorCallback() { |
| return OCLinEcoreEditorCallback.class; |
| } |
| |
| public static class Bug382088Workaround extends ParserBasedContentAssistContextFactory.StatefulFactory |
| { |
| private int depth = 0; |
| |
| @Override |
| protected void computeFollowElements(ParserBasedContentAssistContextFactory.FollowElementCalculator calculator, |
| FollowElement element, Multimap<Integer, List<AbstractElement>> visited) { |
| try { |
| if (++depth < 10) { |
| super.computeFollowElements(calculator, element, visited); |
| } |
| } finally { |
| depth--; |
| } |
| } |
| } |
| |
| public Class<? extends ParserBasedContentAssistContextFactory.StatefulFactory> bindStatefulFactory() { |
| return Bug382088Workaround.class; // BUG 382088 |
| } |
| } |