blob: 43908cfccdd05eb5c6342ced01d0ff34435ec733 [file] [log] [blame]
/*=============================================================================#
# Copyright (c) 2007, 2019 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.r.ui.editors;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.core.filebuffers.IDocumentSetupParticipant;
import org.eclipse.statet.ecommons.preferences.core.PreferenceAccess;
import org.eclipse.statet.base.core.preferences.TaskTagsPreferences;
import org.eclipse.statet.ltk.ui.sourceediting.SourceEditorViewerConfigurator;
import org.eclipse.statet.r.core.IRCoreAccess;
import org.eclipse.statet.r.core.RCodeStyleSettings;
import org.eclipse.statet.r.core.RCore;
import org.eclipse.statet.rj.renv.core.REnv;
/**
* Configurator for Rd source viewers.
*/
public class RdSourceViewerConfigurator extends SourceEditorViewerConfigurator
implements IRCoreAccess {
private static final Set<String> RESET_GROUPS_IDS= new HashSet<>(Arrays.asList(new String[] {
TaskTagsPreferences.GROUP_ID,
}));
private IRCoreAccess fSourceCoreAccess;
public RdSourceViewerConfigurator(final IRCoreAccess core,
final RdSourceViewerConfiguration config) {
super(config);
config.setCoreAccess(this);
setSource(core);
}
@Override
public IDocumentSetupParticipant getDocumentSetupParticipant() {
return new RdDocumentSetupParticipant();
}
@Override
protected Set<String> getResetGroupIds() {
return RESET_GROUPS_IDS;
}
public void setSource(IRCoreAccess newAccess) {
if (newAccess == null) {
newAccess = RCore.getWorkbenchAccess();
}
if (fSourceCoreAccess != newAccess) {
fSourceCoreAccess = newAccess;
handleSettingsChanged(null, null);
}
}
@Override
public PreferenceAccess getPrefs() {
return fSourceCoreAccess.getPrefs();
}
@Override
public REnv getREnv() {
return fSourceCoreAccess.getREnv();
}
@Override
public RCodeStyleSettings getRCodeStyle() {
return null;
}
}