PT #159413155: Generic YAML editor with spaces instead of tab indent
This commit is contained in:
@@ -162,7 +162,7 @@
|
||||
<extension
|
||||
point="org.eclipse.ui.editors">
|
||||
<editor
|
||||
class="org.eclipse.ui.internal.genericeditor.ExtensionBasedTextEditor"
|
||||
class="org.springframework.tooling.ls.eclipse.commons.YamlGenericEditor"
|
||||
contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor"
|
||||
icon="icons/spring_yml.png"
|
||||
id="SpringBootYMLPropertyEditor"
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
point="org.eclipse.ui.editors">
|
||||
<editorContentTypeBinding
|
||||
contentTypeId="org.springframework.tooling.bosh.manifest"
|
||||
editorId="org.eclipse.ui.genericeditor.GenericEditor">
|
||||
editorId="org.springframework.tooling.ls.eclipse.commons.YamlGenericEditor">
|
||||
</editorContentTypeBinding>
|
||||
</extension>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
point="org.eclipse.ui.editors">
|
||||
<editorContentTypeBinding
|
||||
contentTypeId="org.springframework.tooling.bosh.cloudconfig"
|
||||
editorId="org.eclipse.ui.genericeditor.GenericEditor">
|
||||
editorId="org.springframework.tooling.ls.eclipse.commons.YamlGenericEditor">
|
||||
</editorContentTypeBinding>
|
||||
</extension>
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
point="org.eclipse.ui.editors">
|
||||
<editorContentTypeBinding
|
||||
contentTypeId="org.springframework.tooling.concourse.pipeline"
|
||||
editorId="org.eclipse.ui.genericeditor.GenericEditor">
|
||||
editorId="org.springframework.tooling.ls.eclipse.commons.YamlGenericEditor">
|
||||
</editorContentTypeBinding>
|
||||
</extension>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
point="org.eclipse.ui.editors">
|
||||
<editorContentTypeBinding
|
||||
contentTypeId="org.springframework.tooling.concourse.task"
|
||||
editorId="org.eclipse.ui.genericeditor.GenericEditor">
|
||||
editorId="org.springframework.tooling.ls.eclipse.commons.YamlGenericEditor">
|
||||
</editorContentTypeBinding>
|
||||
</extension>
|
||||
|
||||
|
||||
@@ -19,7 +19,9 @@ Require-Bundle: org.eclipse.jdt.launching;bundle-version="3.8.0",
|
||||
org.eclipse.ui.ide,
|
||||
org.eclipse.jdt.core,
|
||||
org.eclipse.jdt.ui,
|
||||
org.apache.commons.lang3
|
||||
org.apache.commons.lang3,
|
||||
org.eclipse.ui.genericeditor,
|
||||
org.eclipse.ui.editors
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: org.springframework.tooling.ls.eclipse.commons,
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
<initializer
|
||||
class="org.springframework.tooling.ls.eclipse.commons.console.preferences.LanguageServerConsolesPrefsInitializer">
|
||||
</initializer>
|
||||
<initializer
|
||||
class="org.springframework.tooling.ls.eclipse.commons.YamlGenericEditorPreferencesInitializer">
|
||||
</initializer>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.console.consolePageParticipants">
|
||||
@@ -49,4 +52,15 @@
|
||||
</enablement>
|
||||
</consolePageParticipant>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.editors">
|
||||
<editor
|
||||
class="org.springframework.tooling.ls.eclipse.commons.YamlGenericEditor"
|
||||
contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor"
|
||||
default="false"
|
||||
icon="platform:/plugin/org.eclipse.ui.genericeditor/icons/full/obj16/generic_editor.png"
|
||||
id="org.springframework.tooling.ls.eclipse.commons.YamlGenericEditor"
|
||||
name="Generic YAML Editor">
|
||||
</editor>
|
||||
</extension>
|
||||
</plugin>
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018 Pivotal, Inc.
|
||||
* 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:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.tooling.ls.eclipse.commons;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.editors.text.EditorsUI;
|
||||
import org.eclipse.ui.internal.genericeditor.ExtensionBasedTextEditor;
|
||||
import org.eclipse.ui.texteditor.ChainedPreferenceStore;
|
||||
|
||||
/**
|
||||
* YAML editor based on Generic editor.
|
||||
* Has spaces rather than tab for indentation
|
||||
*
|
||||
* @author Alex Boyko
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("restriction")
|
||||
public class YamlGenericEditor extends ExtensionBasedTextEditor {
|
||||
|
||||
@Override
|
||||
protected boolean isTabsToSpacesConversionEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initializeEditor() {
|
||||
super.initializeEditor();
|
||||
|
||||
List<IPreferenceStore> stores = new ArrayList<>(3);
|
||||
stores.add(LanguageServerCommonsActivator.getInstance().getPreferenceStore());
|
||||
stores.add(EditorsUI.getPreferenceStore());
|
||||
stores.add(PlatformUI.getPreferenceStore());
|
||||
|
||||
setPreferenceStore(new ChainedPreferenceStore(stores.toArray(new IPreferenceStore[stores.size()])));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2018 Pivotal, Inc.
|
||||
* 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:
|
||||
* Pivotal, Inc. - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.springframework.tooling.ls.eclipse.commons;
|
||||
|
||||
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
|
||||
|
||||
/**
|
||||
* Initializers of preferences for Generic editor for YAML ls extensions
|
||||
*
|
||||
* @author Alex Boyko
|
||||
*
|
||||
*/
|
||||
public class YamlGenericEditorPreferencesInitializer extends AbstractPreferenceInitializer {
|
||||
|
||||
@Override
|
||||
public void initializeDefaultPreferences() {
|
||||
IPreferenceStore store = LanguageServerCommonsActivator.getInstance().getPreferenceStore();
|
||||
store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, 2);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user