[jbosstools-commits] JBoss Tools SVN: r42538 - in trunk/forge/plugins/org.jboss.tools.forge.ui: src/org/jboss/tools/forge/ui/console and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu Jul 12 09:36:37 EDT 2012


Author: koen.aers at jboss.com
Date: 2012-07-12 09:36:36 -0400 (Thu, 12 Jul 2012)
New Revision: 42538

Modified:
   trunk/forge/plugins/org.jboss.tools.forge.ui/plugin.xml
   trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeTextViewer.java
Log:
JBIDE-12223: Forge should use the console font + listen to font changes

Modified: trunk/forge/plugins/org.jboss.tools.forge.ui/plugin.xml
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.ui/plugin.xml	2012-07-12 12:32:10 UTC (rev 42537)
+++ trunk/forge/plugins/org.jboss.tools.forge.ui/plugin.xml	2012-07-12 13:36:36 UTC (rev 42538)
@@ -191,4 +191,17 @@
              class="org.jboss.tools.forge.ui.startup.ForgeStarter">
        </startup>
     </extension>
+    <extension
+          point="org.eclipse.ui.themes">
+       <fontDefinition
+             categoryId="org.jboss.tools.forge.ui"
+             defaultsTo="org.eclipse.debug.ui.consoleFont"
+             id="org.jboss.tools.forge.console.font"
+             label="Forge Console Font">
+       </fontDefinition>
+       <themeElementCategory
+             id="org.jboss.tools.forge.ui"
+             label="Forge ">
+       </themeElementCategory>
+    </extension>
 </plugin>

Modified: trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeTextViewer.java
===================================================================
--- trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeTextViewer.java	2012-07-12 12:32:10 UTC (rev 42537)
+++ trunk/forge/plugins/org.jboss.tools.forge.ui/src/org/jboss/tools/forge/ui/console/ForgeTextViewer.java	2012-07-12 13:36:36 UTC (rev 42538)
@@ -4,6 +4,8 @@
 import org.eclipse.jface.text.DocumentEvent;
 import org.eclipse.jface.text.IDocumentListener;
 import org.eclipse.jface.text.TextViewer;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.ST;
 import org.eclipse.swt.custom.StyleRange;
@@ -28,6 +30,8 @@
 	private static String NEXT_HISTORY = new Character((char)14).toString();
 	private static String DELETE_NEXT_CHAR = new Character((char)127).toString();
 	
+	private static final String FORGE_CONSOLE_FONT = "org.jboss.tools.forge.console.font";
+	
 	private class DocumentListener implements IDocumentListener, ForgeDocument.CursorListener {
     	@Override
         public void documentAboutToBeChanged(DocumentEvent event) {
@@ -63,7 +67,19 @@
     private void initialize() {
         initDocument();
         initViewer();
+        initFontListener();
     }
+    
+    private void initFontListener() {
+    	JFaceResources.getFontRegistry().addListener(new IPropertyChangeListener() {			
+			@Override
+			public void propertyChange(PropertyChangeEvent event) {
+				if (FORGE_CONSOLE_FONT.equals(event.getProperty())) {
+					getTextWidget().setFont(JFaceResources.getFont(FORGE_CONSOLE_FONT));
+				}
+			}
+		});
+    }
         
     private void initDocument() {
         ForgeDocument.INSTANCE.addDocumentListener(documentListener);
@@ -73,7 +89,7 @@
     
     private void initViewer() {
 		getTextWidget().setStyleRanges(ForgeDocument.INSTANCE.getStyleRanges());
-    	getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
+    	getTextWidget().setFont(JFaceResources.getFont(FORGE_CONSOLE_FONT));
     	getTextWidget().addVerifyKeyListener(new VerifyKeyListener() {			
 			@Override
 			public void verifyKey(VerifyEvent event) {



More information about the jbosstools-commits mailing list