diff options
author | Michal Niewrzal | 2016-12-16 10:13:24 +0000 |
---|---|---|
committer | Michal Niewrzal | 2017-06-29 13:54:38 +0000 |
commit | a960a556bb97303083f87165350bdc44c55d701e (patch) | |
tree | 6d554619adc4d97945f2910be0c13350e477946a /org.eclipse.ui.genericeditor.tests | |
parent | 2da5c4c44f32c6db2c1b5c27c49a93846ee7eefb (diff) | |
download | eclipse.platform.text-a960a556bb97303083f87165350bdc44c55d701e.tar.gz eclipse.platform.text-a960a556bb97303083f87165350bdc44c55d701e.tar.xz eclipse.platform.text-a960a556bb97303083f87165350bdc44c55d701e.zip |
Bug 508677 - [Generic Editor] Extension point for auto edit strategies
Change-Id: I275a82c443e6a9e612ea8e3297b2c78f6cae8ac0
Signed-off-by: Michal Niewrzal <michal.n@zend.com>
Diffstat (limited to 'org.eclipse.ui.genericeditor.tests')
8 files changed, 122 insertions, 3 deletions
diff --git a/org.eclipse.ui.genericeditor.tests/META-INF/MANIFEST.MF b/org.eclipse.ui.genericeditor.tests/META-INF/MANIFEST.MF index eda150653f0..813cb18ad98 100644 --- a/org.eclipse.ui.genericeditor.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.ui.genericeditor.tests/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Plugin.name Bundle-SymbolicName: org.eclipse.ui.genericeditor.tests;singleton:=true -Bundle-Version: 1.0.0.qualifier +Bundle-Version: 1.1.0.qualifier Bundle-Vendor: %Plugin.providerName Bundle-Localization: plugin Export-Package: org.eclipse.ui.genericeditor.tests, diff --git a/org.eclipse.ui.genericeditor.tests/plugin.xml b/org.eclipse.ui.genericeditor.tests/plugin.xml index e9a65d19eb6..4f199ed08d8 100644 --- a/org.eclipse.ui.genericeditor.tests/plugin.xml +++ b/org.eclipse.ui.genericeditor.tests/plugin.xml @@ -53,5 +53,20 @@ priority="normal"> </content-type> </extension> + <extension + point="org.eclipse.ui.genericeditor.autoEditStrategies"> + <autoEditStrategy + class="org.eclipse.ui.genericeditor.tests.contributions.TheAutoEditStrategyFirst" + contentType="org.eclipse.core.runtime.text"> + </autoEditStrategy> + <autoEditStrategy + class="org.eclipse.ui.genericeditor.tests.contributions.TheAutoEditStrategySecond" + contentType="org.eclipse.core.runtime.text"> + </autoEditStrategy> + <autoEditStrategy + class="org.eclipse.ui.genericeditor.tests.contributions.TheAutoEditStrategyThird" + contentType="org.eclipse.core.runtime.text"> + </autoEditStrategy> + </extension> </plugin> diff --git a/org.eclipse.ui.genericeditor.tests/pom.xml b/org.eclipse.ui.genericeditor.tests/pom.xml index e16cc5a1f20..8dce90bc2c1 100644 --- a/org.eclipse.ui.genericeditor.tests/pom.xml +++ b/org.eclipse.ui.genericeditor.tests/pom.xml @@ -19,7 +19,7 @@ </parent> <groupId>org.eclipse.ui</groupId> <artifactId>org.eclipse.ui.genericeditor.tests</artifactId> - <version>1.0.0-SNAPSHOT</version> + <version>1.1.0-SNAPSHOT</version> <packaging>eclipse-test-plugin</packaging> <properties> <testSuite>${project.artifactId}</testSuite> diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/AutoEditTest.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/AutoEditTest.java new file mode 100644 index 00000000000..8a30f57a70d --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/AutoEditTest.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2017 Rogue Wave Software Inc. 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: + * Michał Niewrzał (Rogue Wave Software Inc.) - initial implementation + *******************************************************************************/ +package org.eclipse.ui.genericeditor.tests; + +import org.junit.Assert; +import org.junit.Test; + +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.widgets.Control; + +import org.eclipse.jface.text.IDocument; + +public class AutoEditTest extends AbstratGenericEditorTest { + + @Test + public void testAutoEdit() throws Exception { + IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput()); + StyledText control= (StyledText) editor.getAdapter(Control.class); + control.setText(""); + Assert.assertEquals("AutoAddedFirst! AutoAddedSecond! AutoAddedThird!", document.get()); + } + +} diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/GenericEditorTestSuite.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/GenericEditorTestSuite.java index e349652f2ff..96361db40d1 100644 --- a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/GenericEditorTestSuite.java +++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/GenericEditorTestSuite.java @@ -19,7 +19,8 @@ import org.junit.runners.Suite.SuiteClasses; CompletionTest.class, StylingTest.class, HoverTest.class, - EditorTest.class + EditorTest.class, + AutoEditTest.class }) public class GenericEditorTestSuite { // see @SuiteClasses diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/TheAutoEditStrategyFirst.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/TheAutoEditStrategyFirst.java new file mode 100644 index 00000000000..8a36c3963c0 --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/TheAutoEditStrategyFirst.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2017 Rogue Wave Software Inc. 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: + * Michał Niewrzał (Rogue Wave Software Inc.) - initial implementation + *******************************************************************************/ +package org.eclipse.ui.genericeditor.tests.contributions; + +import org.eclipse.jface.text.DocumentCommand; +import org.eclipse.jface.text.IAutoEditStrategy; +import org.eclipse.jface.text.IDocument; + +public class TheAutoEditStrategyFirst implements IAutoEditStrategy { + + @Override + public void customizeDocumentCommand(IDocument document, DocumentCommand command) { + command.text = command.text + "AutoAddedFirst!"; + } + +} diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/TheAutoEditStrategySecond.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/TheAutoEditStrategySecond.java new file mode 100644 index 00000000000..37e2587d8ed --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/TheAutoEditStrategySecond.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2017 Rogue Wave Software Inc. 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: + * Michał Niewrzał (Rogue Wave Software Inc.) - initial implementation + *******************************************************************************/ +package org.eclipse.ui.genericeditor.tests.contributions; + +import org.eclipse.jface.text.DocumentCommand; +import org.eclipse.jface.text.IAutoEditStrategy; +import org.eclipse.jface.text.IDocument; + +public class TheAutoEditStrategySecond implements IAutoEditStrategy { + + @Override + public void customizeDocumentCommand(IDocument document, DocumentCommand command) { + command.text = command.text + " AutoAddedSecond!"; + } + +} diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/TheAutoEditStrategyThird.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/TheAutoEditStrategyThird.java new file mode 100644 index 00000000000..c7882aaf446 --- /dev/null +++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/TheAutoEditStrategyThird.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2017 Rogue Wave Software Inc. 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: + * Michał Niewrzał (Rogue Wave Software Inc.) - initial implementation + *******************************************************************************/ +package org.eclipse.ui.genericeditor.tests.contributions; + +import org.eclipse.jface.text.DocumentCommand; +import org.eclipse.jface.text.IAutoEditStrategy; +import org.eclipse.jface.text.IDocument; + +public class TheAutoEditStrategyThird implements IAutoEditStrategy { + + @Override + public void customizeDocumentCommand(IDocument document, DocumentCommand command) { + command.text = command.text + " AutoAddedThird!"; + } + +} |