| /*=============================================================================# |
| # Copyright (c) 2009, 2021 Stephan Wahlbrink and others. |
| # |
| # This program and the accompanying materials are made available under the |
| # terms of the Eclipse Public License 2.0 which is available at |
| # https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 |
| # which is available at https://www.apache.org/licenses/LICENSE-2.0. |
| # |
| # SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 |
| # |
| # Contributors: |
| # Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation |
| #=============================================================================*/ |
| |
| package org.eclipse.statet.internal.r.ui; |
| |
| import java.lang.reflect.InvocationTargetException; |
| |
| import org.eclipse.core.filesystem.IFileStore; |
| import org.eclipse.core.runtime.SubMonitor; |
| |
| import org.eclipse.statet.jcommons.lang.NonNullByDefault; |
| |
| import org.eclipse.statet.ecommons.text.core.sections.DocContentSections; |
| |
| import org.eclipse.statet.ltk.core.Ltk; |
| import org.eclipse.statet.ltk.core.WorkingContext; |
| import org.eclipse.statet.ltk.model.core.element.SourceDocumentRunnable; |
| import org.eclipse.statet.ltk.model.core.impl.GenericUriSourceUnit2; |
| import org.eclipse.statet.ltk.model.core.impl.WorkingBuffer; |
| import org.eclipse.statet.ltk.ui.FileBufferWorkingBuffer; |
| import org.eclipse.statet.r.core.RCore; |
| import org.eclipse.statet.r.core.RCoreAccess; |
| import org.eclipse.statet.r.core.model.RModel; |
| import org.eclipse.statet.r.core.model.RSourceUnit; |
| import org.eclipse.statet.r.core.source.RDocumentContentInfo; |
| |
| |
| @NonNullByDefault |
| public class REditorUriSourceUnit |
| extends GenericUriSourceUnit2<RUISuModelContainer> |
| implements RSourceUnit { |
| |
| |
| public REditorUriSourceUnit(final String id, final IFileStore store) { |
| super(id, store); |
| } |
| |
| |
| @Override |
| protected RUISuModelContainer createModelContainer() { |
| return new RUISuModelContainer(this); |
| } |
| |
| @Override |
| public WorkingContext getWorkingContext() { |
| return Ltk.EDITOR_CONTEXT; |
| } |
| |
| @Override |
| public String getModelTypeId() { |
| return RModel.R_TYPE_ID; |
| } |
| |
| @Override |
| public DocContentSections getDocumentContentInfo() { |
| return RDocumentContentInfo.INSTANCE; |
| } |
| |
| @Override |
| public int getElementType() { |
| return R_OTHER_SU; |
| } |
| |
| |
| @Override |
| protected WorkingBuffer createWorkingBuffer(final SubMonitor m) { |
| return new FileBufferWorkingBuffer(this); |
| } |
| |
| @Override |
| protected void register() { |
| super.register(); |
| RModel.getRModelManager().registerDependentUnit(this); |
| } |
| |
| @Override |
| protected void unregister() { |
| super.unregister(); |
| RModel.getRModelManager().deregisterDependentUnit(this); |
| } |
| |
| |
| @Override |
| public void syncExec(final SourceDocumentRunnable runnable) throws InvocationTargetException { |
| FileBufferWorkingBuffer.syncExec(runnable); |
| } |
| |
| @Override |
| public RCoreAccess getRCoreAccess() { |
| return RCore.WORKBENCH_ACCESS; |
| } |
| |
| } |