From 47f0defa0b64cd520c0638ac1a449fcaba8d3a6b Mon Sep 17 00:00:00 2001 From: Gunnar Wagenknecht Date: Mon, 10 Oct 2016 09:29:08 +0200 Subject: [PATCH] Allow access to component factory for sub-classes. The component factory is used by the content assist. When used outside of a console page (the Eclipse console view) the content assist needs to be created manually. Thus, access to the component factory is necessary. --- .../core/internal/GenericConsolePDETest.java | 16 ++++++++++++++++ .../console/core/internal/GenericConsole.java | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/com.codeaffine.console.core.pdetest/src/com/codeaffine/console/core/internal/GenericConsolePDETest.java b/com.codeaffine.console.core.pdetest/src/com/codeaffine/console/core/internal/GenericConsolePDETest.java index 3ef55e39..65c3309f 100644 --- a/com.codeaffine.console.core.pdetest/src/com/codeaffine/console/core/internal/GenericConsolePDETest.java +++ b/com.codeaffine.console.core.pdetest/src/com/codeaffine/console/core/internal/GenericConsolePDETest.java @@ -12,6 +12,8 @@ import org.junit.Before; import org.junit.Test; +import com.codeaffine.console.core.ConsoleComponentFactory; +import com.codeaffine.console.core.pdetest.console.TestConsoleComponentFactory; import com.codeaffine.console.core.pdetest.console.TestConsoleConfigurer; public class GenericConsolePDETest { @@ -26,6 +28,20 @@ public void testInitialize() { verify( consoleConfigurer ).configure( console ); } + @Test + public void testGetConsoleComponentFactory() { + // should return null without initialization + assertThat( console.getConsoleComponentFactory() ).isNull(); + + // set a console + console.setConsoleComponentFactory( new TestConsoleComponentFactory() ); + + // note, the implementation wraps it into a GenericConsoleComponentFactory + ConsoleComponentFactory componentFactory = console.getConsoleComponentFactory(); + assertThat( componentFactory ).isNotNull(); + assertThat( componentFactory.getClass() ).isSameAs( GenericConsoleComponentFactory.class ); + } + @Test public void testGetEncoding() { String encoding = console.getEncoding(); diff --git a/com.codeaffine.console.core/src/com/codeaffine/console/core/internal/GenericConsole.java b/com.codeaffine.console.core/src/com/codeaffine/console/core/internal/GenericConsole.java index a156aac7..71cedae3 100644 --- a/com.codeaffine.console.core/src/com/codeaffine/console/core/internal/GenericConsole.java +++ b/com.codeaffine.console.core/src/com/codeaffine/console/core/internal/GenericConsole.java @@ -61,6 +61,10 @@ public ColorScheme getColorScheme() { return colorScheme; } + public ConsoleComponentFactory getConsoleComponentFactory() { + return this.consoleComponentFactory; + } + @Override public void setConsoleComponentFactory( ConsoleComponentFactory consoleComponentFactory ) { this.consoleComponentFactory = new GenericConsoleComponentFactory( consoleComponentFactory );